I have following Model
public class VideosOwn {
public long _id;
public String _title;
public String _width;
public long _height;
public String _orientation;
public long _size;
public VideosOwn(long _id, String _title, String _width, long _height, String _orientation, long _size) {
this._id = _id;
this._title = _title;
this._width = _width;
this._height = _height;
this._orientation = _orientation;
this._size = _size;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
and following method to get the data as an array using ContentResolover
public ArrayList<VideosOwn> GetVideoList(Context mContext) {
ArrayList<VideosOwn> videos = new ArrayList<>();
Cursor cursor = mContext.getContentResolver().query(VideosUri,
VideosProjection, null, null, MediaStore.Video.Media.DATE_ADDED + " DESC");
if (cursor != null && cursor.moveToFirst()) {
do {
VideosOwn videoval = new VideosOwn(
cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media._ID)),
cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.TITLE)),
cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.WIDTH)),
cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media.HEIGHT)),
cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.ORIENTATION)),
cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media.SIZE))
);
videos.add(videoval);
} while (cursor.moveToNext());
}
if (cursor != null) {
cursor.close();
}
return videos;
}
I am new to Rxjava/RxAndroid, I want emit The data as an ArrayList
How can that be done , Should we use Disposalbe
, Observable.fromCallable
, what would be the Best solution.
question from:
https://stackoverflow.com/questions/65879653/use-rxandroid-with-cursor-to-emit-data 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…