use of org.edx.mobile.model.VideoModel in project edx-app-android by edx.
the class DbOperationGetVideos method execute.
@Override
public List<VideoModel> execute(SQLiteDatabase db) {
List<VideoModel> list = new ArrayList<VideoModel>();
Cursor c = getCursor(db);
if (c.moveToFirst()) {
do {
VideoModel video = DatabaseModelFactory.getModel(c);
list.add(video);
} while (c.moveToNext());
}
c.close();
return list;
}
use of org.edx.mobile.model.VideoModel in project edx-app-android by edx.
the class Storage method removeDownloadsFromApp.
private int removeDownloadsFromApp(List<VideoModel> result, String username) {
// Remove all downloads from db
long[] videoIds = new long[result.size()];
VideoModel model;
for (int i = 0; i < result.size(); i++) {
model = result.get(i);
if (username == null) {
db.deleteVideoByVideoId(model, null);
} else {
db.deleteVideoByVideoId(model, username, null);
}
deleteFile(model.getFilePath());
videoIds[i] = model.getDmId();
}
// Remove all downloads from NativeDownloadManager
return videoIds.length > 0 ? dm.removeDownloads(videoIds) : 0;
}
use of org.edx.mobile.model.VideoModel in project edx-app-android by edx.
the class Storage method getDownloadProgressOfCourseVideos.
@Override
public void getDownloadProgressOfCourseVideos(@Nullable String courseId, final DataCallback<NativeDownloadModel> callback) {
final IDatabase db = DatabaseFactory.getInstance(DatabaseFactory.TYPE_DATABASE_NATIVE);
db.getListOfOngoingDownloadsByCourseId(courseId, new DataCallback<List<VideoModel>>() {
@Override
public void onResult(List<VideoModel> result) {
final long[] dmids = new long[result.size()];
for (int i = 0; i < result.size(); i++) {
dmids[i] = result.get(i).getDmId();
}
callback.onResult(dm.getProgressDetailsForDownloads(dmids));
}
@Override
public void onFail(Exception ex) {
callback.onFail(ex);
}
});
}
use of org.edx.mobile.model.VideoModel in project edx-app-android by edx.
the class Storage method getAverageDownloadProgress.
@Override
public void getAverageDownloadProgress(final DataCallback<Integer> callback) {
IDatabase db = DatabaseFactory.getInstance(DatabaseFactory.TYPE_DATABASE_NATIVE);
db.getListOfOngoingDownloads(new DataCallback<List<VideoModel>>() {
@Override
public void onResult(List<VideoModel> result) {
long[] dmids = new long[result.size()];
for (int i = 0; i < result.size(); i++) {
dmids[i] = result.get(i).getDmId();
}
int averageProgress = dm.getAverageProgressForDownloads(dmids);
callback.onResult(averageProgress);
}
@Override
public void onFail(Exception ex) {
callback.onFail(ex);
}
});
}
use of org.edx.mobile.model.VideoModel in project edx-app-android by edx.
the class DbOperationGetVideo method execute.
@Override
public VideoModel execute(SQLiteDatabase db) {
VideoModel video = null;
Cursor c = getCursor(db);
if (c.moveToFirst()) {
video = DatabaseModelFactory.getModel(c);
}
if (c.moveToNext()) {
logger.warn("More than one records available that match your query, " + "but you chose only first one");
}
c.close();
return video;
}
Aggregations