use of com.hippo.app.CheckBoxDialogBuilder in project EhViewer by seven332.
the class DownloadsScene method onClickSecondaryFab.
@Override
public void onClickSecondaryFab(FabLayout view, FloatingActionButton fab, int position) {
Context context = getContext2();
Activity activity = getActivity2();
EasyRecyclerView recyclerView = mRecyclerView;
if (null == context || null == activity || null == recyclerView) {
return;
}
if (0 == position) {
recyclerView.checkAll();
} else {
List<DownloadInfo> list = mList;
if (list == null) {
return;
}
LongList gidList = null;
List<DownloadInfo> downloadInfoList = null;
// Start, Stop, Delete
boolean collectGid = position == 1 || position == 2 || position == 3;
// Delete or Move
boolean collectDownloadInfo = position == 3 || position == 4;
if (collectGid) {
gidList = new LongList();
}
if (collectDownloadInfo) {
downloadInfoList = new LinkedList<>();
}
SparseBooleanArray stateArray = recyclerView.getCheckedItemPositions();
for (int i = 0, n = stateArray.size(); i < n; i++) {
if (stateArray.valueAt(i)) {
DownloadInfo info = list.get(stateArray.keyAt(i));
if (collectDownloadInfo) {
downloadInfoList.add(info);
}
if (collectGid) {
gidList.add(info.gid);
}
}
}
switch(position) {
case 1:
{
// Start
Intent intent = new Intent(activity, DownloadService.class);
intent.setAction(DownloadService.ACTION_START_RANGE);
intent.putExtra(DownloadService.KEY_GID_LIST, gidList);
activity.startService(intent);
// Cancel check mode
recyclerView.outOfCustomChoiceMode();
break;
}
case 2:
{
// Stop
if (null != mDownloadManager) {
mDownloadManager.stopRangeDownload(gidList);
}
// Cancel check mode
recyclerView.outOfCustomChoiceMode();
break;
}
case 3:
{
// Delete
CheckBoxDialogBuilder builder = new CheckBoxDialogBuilder(context, getString(R.string.download_remove_dialog_message_2, gidList.size()), getString(R.string.download_remove_dialog_check_text), Settings.getRemoveImageFiles());
DeleteRangeDialogHelper helper = new DeleteRangeDialogHelper(downloadInfoList, gidList, builder);
builder.setTitle(R.string.download_remove_dialog_title).setPositiveButton(android.R.string.ok, helper).show();
break;
}
case 4:
{
// Move
List<DownloadLabel> labelRawList = EhApplication.getDownloadManager(context).getLabelList();
List<String> labelList = new ArrayList<>(labelRawList.size() + 1);
labelList.add(getString(R.string.default_download_label_name));
for (int i = 0, n = labelRawList.size(); i < n; i++) {
labelList.add(labelRawList.get(i).getLabel());
}
String[] labels = labelList.toArray(new String[labelList.size()]);
MoveDialogHelper helper = new MoveDialogHelper(labels, downloadInfoList);
new AlertDialog.Builder(context).setTitle(R.string.download_move_dialog_title).setItems(labels, helper).show();
break;
}
}
}
}
use of com.hippo.app.CheckBoxDialogBuilder in project EhViewer by seven332.
the class GalleryListScene method showQuickSearchTipDialog.
private void showQuickSearchTipDialog(final List<QuickSearch> list, final ArrayAdapter<QuickSearch> adapter, final ListView listView, final TextView tip) {
Context context = getContext2();
if (null == context) {
return;
}
final CheckBoxDialogBuilder builder = new CheckBoxDialogBuilder(context, getString(R.string.add_quick_search_tip), getString(R.string.get_it), false);
builder.setTitle(R.string.readme);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (builder.isChecked()) {
Settings.putQuickSearchTip(false);
}
showAddQuickSearchDialog(list, adapter, listView, tip);
}
}).show();
}
Aggregations