use of com.odysee.app.dialog.AddToListsDialogFragment in project odysee-android by OdyseeTeam.
the class MainActivity method handleAddUrlToList.
public void handleAddUrlToList(String url, String builtInId) {
if (!Arrays.asList(OdyseeCollection.BUILT_IN_ID_FAVORITES, OdyseeCollection.BUILT_IN_ID_WATCHLATER).contains(builtInId)) {
// add to list. show bottom sheet dialog with playlists
AddToListsDialogFragment dialog = AddToListsDialogFragment.newInstance();
dialog.setUrl(url);
dialog.show(getSupportFragmentManager(), AddToListsDialogFragment.TAG);
return;
}
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public void run() {
try {
SQLiteDatabase db = dbHelper.getWritableDatabase();
DatabaseHelper.addCollectionItem(builtInId, url, db);
runOnUiThread(new Runnable() {
@Override
public void run() {
showMessage(getString(R.string.added_to_list, OdyseeCollection.BUILT_IN_ID_FAVORITES.equalsIgnoreCase(builtInId) ? getString(R.string.favorites) : getString(R.string.watch_later)), getString(R.string.see_list), new View.OnClickListener() {
@Override
public void onClick(View view) {
// open the playlist fragment with the id
openPlaylistFragment(builtInId);
}
});
}
});
// initiate sync afterwards
saveSharedUserState();
} catch (SQLiteException ex) {
// failed
showError(getString(R.string.could_not_add_to_list, OdyseeCollection.BUILT_IN_ID_FAVORITES.equalsIgnoreCase(builtInId) ? getString(R.string.favorites) : getString(R.string.watch_later)));
}
}
});
}
Aggregations