use of androidx.fragment.app.DialogFragment in project zype-android by zype.
the class VideosActivity method updateListItem.
// Download progress
protected static void updateListItem(Activity activity, View view, Intent intent, int action, String fileId, VideosCursorAdapter.VideosViewHolder viewHolder) {
if (TextUtils.equals(fileId, viewHolder.videoId)) {
String errorMessage;
int progress;
switch(action) {
case DownloadConstants.PROGRESS_CANCELED_AUDIO:
viewHolder.isAudioDownloaded = false;
UiUtils.showWarningSnackbar(view, "Audio download has canceled");
hideProgress(viewHolder);
break;
case DownloadConstants.PROGRESS_CANCELED_VIDEO:
viewHolder.isVideoDownloaded = false;
UiUtils.showWarningSnackbar(view, "VideoList Download has canceled");
hideProgress(viewHolder);
break;
case DownloadConstants.PROGRESS_END_AUDIO:
viewHolder.isAudioDownloaded = true;
UiUtils.showPositiveSnackbar(view, "Audio was downloaded");
hideProgress(viewHolder);
break;
case DownloadConstants.PROGRESS_END_VIDEO:
viewHolder.isVideoDownloaded = true;
UiUtils.showPositiveSnackbar(view, "VideoList was downloaded");
hideProgress(viewHolder);
break;
case DownloadConstants.PROGRESS_FAIL_AUDIO:
viewHolder.isAudioDownloaded = false;
errorMessage = intent.getStringExtra(BundleConstants.PROGRESS_ERROR_MESSAGE);
UiUtils.showErrorSnackbar(view, errorMessage);
hideProgress(viewHolder);
break;
case DownloadConstants.PROGRESS_FAIL_VIDEO:
viewHolder.isVideoDownloaded = false;
errorMessage = intent.getStringExtra(BundleConstants.PROGRESS_ERROR_MESSAGE);
UiUtils.showErrorSnackbar(view, errorMessage);
hideProgress(viewHolder);
break;
case DownloadConstants.PROGRESS_START_AUDIO:
viewHolder.isAudioDownloaded = false;
UiUtils.showPositiveSnackbar(view, "Audio downloading has started");
updateListView(viewHolder, 0);
break;
case DownloadConstants.PROGRESS_START_VIDEO:
viewHolder.isVideoDownloaded = false;
UiUtils.showPositiveSnackbar(view, "VideoList downloading was started");
updateListView(viewHolder, 0);
break;
case DownloadConstants.PROGRESS_UPDATE_AUDIO:
viewHolder.isAudioDownloaded = false;
progress = intent.getIntExtra(BundleConstants.PROGRESS, 0);
updateListView(viewHolder, progress);
break;
case DownloadConstants.PROGRESS_UPDATE_VIDEO:
viewHolder.isVideoDownloaded = false;
progress = intent.getIntExtra(BundleConstants.PROGRESS, 0);
updateListView(viewHolder, progress);
break;
case DownloadConstants.PROGRESS_FREE_SPACE:
viewHolder.isVideoDownloaded = false;
viewHolder.isAudioDownloaded = false;
hideProgress(viewHolder);
if (activity instanceof BaseActivity) {
int error = intent.getIntExtra(BundleConstants.PROGRESS_ERROR_MESSAGE, -1);
if (error == -1) {
error = R.string.alert_dialog_message_free_space;
}
DialogFragment newFragment = CustomAlertDialog.newInstance(R.string.alert_dialog_title_free_space, error);
newFragment.show(((BaseActivity) activity).getSupportFragmentManager(), "dialog_free_space");
} else {
UiUtils.showWarningSnackbar(view, activity.getString(R.string.alert_dialog_message_free_space));
}
break;
default:
throw new IllegalStateException("unknown action=" + action);
}
}
}
use of androidx.fragment.app.DialogFragment in project ETSMobile-Android2 by ApplETS.
the class BandwidthFragment method displayPhase3Dialog.
private void displayPhase3Dialog() {
FragmentTransaction fT = getFragmentManager().beginTransaction();
DialogFragment fragment = (DialogFragment) getFragmentManager().findFragmentByTag(PHASE_3_DIALOG_TAG);
if (fragment == null)
fragment = BandwidthPhase3DialogFragment.newInstance();
if (!fragment.isAdded())
fragment.show(fT, PHASE_3_DIALOG_TAG);
}
use of androidx.fragment.app.DialogFragment in project collect by opendatakit.
the class DateTimeWidgetUtilsTest method assertDialogIsShowing.
private void assertDialogIsShowing(DatePickerDetails.DatePickerType datePickerType, Class dialogClass) {
when(datePickerDetails.getDatePickerType()).thenReturn(datePickerType);
dateTimeWidgetUtils.showDatePickerDialog(activity, datePickerDetails, date);
DialogFragment dialog = (DialogFragment) activity.getSupportFragmentManager().findFragmentByTag(dialogClass.getName());
assertNotNull(dialog);
assertEquals(dialog.getClass(), dialogClass);
}
use of androidx.fragment.app.DialogFragment in project collect by opendatakit.
the class DateTimeWidgetUtilsTest method displayDatePickerDialogWithYearMode_showsDatePickerWithDayAndMonthFixedToJanuaryFirst.
@Test
public void displayDatePickerDialogWithYearMode_showsDatePickerWithDayAndMonthFixedToJanuaryFirst() {
when(datePickerDetails.getDatePickerType()).thenReturn(GREGORIAN);
dateTimeWidgetUtils.showDatePickerDialog(activity, gregorianYear, date);
DialogFragment dialog = (DialogFragment) activity.getSupportFragmentManager().findFragmentByTag(FixedDatePickerDialog.class.getName());
assertThat(((DatePickerDialog) dialog.getDialog()).getDatePicker().getYear(), is(date.getYear()));
assertThat(((DatePickerDialog) dialog.getDialog()).getDatePicker().getMonth(), is(0));
assertThat(((DatePickerDialog) dialog.getDialog()).getDatePicker().getDayOfMonth(), is(1));
}
use of androidx.fragment.app.DialogFragment in project android by nextcloud.
the class ConflictsResolveActivityIT method keepNew.
@Test
@ScreenshotTest
public void keepNew() {
returnCode = false;
OCUpload newUpload = new OCUpload(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt", "/newFile.txt", user.getAccountName());
OCFile existingFile = new OCFile("/newFile.txt");
existingFile.setFileLength(1024000);
existingFile.setModificationTimestamp(1582019340);
existingFile.setRemoteId("123abc");
OCFile newFile = new OCFile("/newFile.txt");
newFile.setFileLength(56000);
newFile.setModificationTimestamp(1522019340);
newFile.setStoragePath(FileStorageUtils.getSavePath(user.getAccountName()) + "/nonEmpty.txt");
FileDataStorageManager storageManager = new FileDataStorageManager(user, targetContext.getContentResolver());
storageManager.saveNewFile(existingFile);
Intent intent = new Intent(targetContext, ConflictsResolveActivity.class);
intent.putExtra(ConflictsResolveActivity.EXTRA_FILE, newFile);
intent.putExtra(ConflictsResolveActivity.EXTRA_EXISTING_FILE, existingFile);
intent.putExtra(ConflictsResolveActivity.EXTRA_CONFLICT_UPLOAD_ID, newUpload.getUploadId());
ConflictsResolveActivity sut = activityRule.launchActivity(intent);
sut.listener = decision -> {
assertEquals(decision, ConflictsResolveDialog.Decision.KEEP_LOCAL);
returnCode = true;
};
getInstrumentation().waitForIdleSync();
onView(withId(R.id.new_checkbox)).perform(click());
DialogFragment dialog = (DialogFragment) sut.getSupportFragmentManager().findFragmentByTag("conflictDialog");
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
onView(withText("OK")).perform(click());
assertTrue(returnCode);
}
Aggregations