android.support.v4.app.DialogFragment Java Examples

The following examples show how to use android.support.v4.app.DialogFragment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsActivity.java    From Camera-Roll-Android-App with Apache License 2.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    if (callback != null) {
        callback.onSettingChanged();
    }

    DialogFragment dialogFragment = null;
    if (preference instanceof StylePreference) {
        dialogFragment
                = StylePreferenceDialogFragment
                .newInstance(preference);
    } else if (preference instanceof ColumnCountPreference) {
        dialogFragment
                = ColumnCountPreferenceDialogFragment
                .newInstance(preference);
    }

    if (dialogFragment != null) {
        dialogFragment.setTargetFragment(this, 0);
        dialogFragment.show(this.getFragmentManager(), DIALOG_FRAGMENT_TAG);
        return;
    }

    super.onDisplayPreferenceDialog(preference);
}
 
Example #2
Source File: FragmentDialogOrActivitySupport.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_dialog_or_activity);

    if (savedInstanceState == null) {
        // First-time init; create fragment to embed in activity.

        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        DialogFragment newFragment = MyDialogFragment.newInstance();
        ft.add(R.id.embedded, newFragment);
        ft.commit();

    }

    // Watch for button clicks.
    Button button = (Button)findViewById(R.id.show_dialog);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            showDialog();
        }
    });
}
 
Example #3
Source File: CustomCommandActivity.java    From rpicheck with MIT License 6 votes vote down vote up
@Override
public void onPassphraseOKClick(DialogFragment dialog, String passphrase, boolean savePassphrase, String type) {
    LOGGER.debug("Key passphrase entered.");
    if (savePassphrase) {
        LOGGER.debug("Saving passphrase..");
        currentDevice.setKeyfilePass(passphrase);
        currentDevice.setModifiedAt(new Date());
        new Thread() {
            @Override
            public void run() {
                deviceDb.update(currentDevice);
            }
        }.start();
    }
    // dirty hack: type is commandId
    Long commandId = Long.parseLong(type);
    LOGGER.debug("Starting command dialog for command id " + commandId);
    openCommandDialog(commandId, passphrase);
}
 
Example #4
Source File: FragmentDialogSupport.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mNum = getArguments().getInt("num");

    // Pick a style based on the num.
    int style = DialogFragment.STYLE_NORMAL, theme = 0;
    switch ((mNum-1)%6) {
        case 1: style = DialogFragment.STYLE_NO_TITLE; break;
        case 2: style = DialogFragment.STYLE_NO_FRAME; break;
        case 3: style = DialogFragment.STYLE_NO_INPUT; break;
        case 4: style = DialogFragment.STYLE_NORMAL; break;
        case 5: style = DialogFragment.STYLE_NO_TITLE; break;
        case 6: style = DialogFragment.STYLE_NO_FRAME; break;
        case 7: style = DialogFragment.STYLE_NORMAL; break;
    }
    switch ((mNum-1)%6) {
        case 2: theme = android.R.style.Theme_Panel; break;
        case 4: theme = android.R.style.Theme; break;
        case 5: theme = android.R.style.Theme_Light; break;
        case 6: theme = android.R.style.Theme_Light_Panel; break;
        case 7: theme = android.R.style.Theme_Light; break;
    }
    setStyle(style, theme);
}
 
Example #5
Source File: RequestManagerRetriever.java    From ImmersionBar with Apache License 2.0 6 votes vote down vote up
/**
 * Get immersion bar.
 *
 * @param fragment the fragment
 * @param isOnly   the is only
 * @return the immersion bar
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public ImmersionBar get(android.app.Fragment fragment, boolean isOnly) {
    checkNotNull(fragment, "fragment is null");
    checkNotNull(fragment.getActivity(), "fragment.getActivity() is null");
    if (fragment instanceof android.app.DialogFragment) {
        checkNotNull(((android.app.DialogFragment) fragment).getDialog(), "fragment.getDialog() is null");
    }
    String tag = mTag;
    if (isOnly) {
        tag += fragment.getClass().getName();
    } else {
        tag += System.identityHashCode(fragment);
    }
    return getFragment(fragment.getChildFragmentManager(), tag).get(fragment);
}
 
Example #6
Source File: JsonRequest.java    From openshop.io-android with MIT License 6 votes vote down vote up
@Override
protected VolleyError parseNetworkError(VolleyError volleyError) {
    if (volleyError.networkResponse != null) {
        // Save request status code
        requestStatusCode = volleyError.networkResponse.statusCode;
        if (BuildConfig.DEBUG)
            Timber.e("%s URL: %s. ERROR: %s", this.getClass().getSimpleName(), requestUrl, new String(volleyError.networkResponse.data));

        // If AccessToken expired. Logout user and redirect to home page.
        if (getStatusCode() == HttpURLConnection.HTTP_FORBIDDEN && fragmentManager != null) {
            LoginDialogFragment.logoutUser();
            DialogFragment loginExpiredDialogFragment = new LoginExpiredDialogFragment();
            loginExpiredDialogFragment.show(fragmentManager, LoginExpiredDialogFragment.class.getSimpleName());
        }
    } else {
        requestStatusCode = CONST.MissingStatusCode;
    }
    return super.parseNetworkError(volleyError);
}
 
Example #7
Source File: InstantReadFragment.java    From JReadHub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mTheme = mPresenter.getTheme();
    switch (mTheme) {
        case Constants.ThemeType.Blue:
            setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AlertDialogStyle_Blue);
            break;
        case Constants.ThemeType.Gray:
            setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AlertDialogStyle_Gray);
            break;
        case Constants.ThemeType.Dark:
            setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AlertDialogStyle_Dark);
            mDarkThemeJS = getDarkThemeJS();
            break;
        default:
            setStyle(DialogFragment.STYLE_NO_TITLE, R.style.AlertDialogStyle_Base);
            break;
    }
}
 
Example #8
Source File: ProgressDialogFragment.java    From BambooPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	final ProgressDialog dialog = new ProgressDialog(getActivity());
    //
	Bundle b = getArguments();
	if (b != null) {
		String title = b.getString("title");
		String content = b.getString("content");
		dialog.setTitle(title);
		dialog.setMessage(content);
	}
    
	
    //dialog.setCanceledOnTouchOutside(true);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setIndeterminate(true);
    //dialog.setCancelable(true);
    

    // etc...
    this.setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme);
    return dialog;
}
 
Example #9
Source File: AdvOptionsDialog.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
private void showTimePickerFragment(int action) {
    DialogFragment newFragment = null;
    switch (action){
        case PickTimeFragment.ACTION_JUMP_TO_TIME:
            newFragment = JumpToTimeDialog.newInstance(mTheme);
            break;
        case PickTimeFragment.ACTION_SLEEP_TIMER:
            newFragment = SleepTimerDialog.newInstance(mTheme);
            break;
        default:
            return;
    }
    if (newFragment != null)
        newFragment.show(getActivity().getSupportFragmentManager(), "time");
    dismiss();
}
 
Example #10
Source File: DatePickerDialogTestCase.java    From react-native-GPay with MIT License 6 votes vote down vote up
public void testCallback() throws Throwable {
  final WritableMap options = new WritableNativeMap();
  options.putDouble("date", getDateInMillis(2020, 5, 6));

  final DialogFragment datePickerFragment = showDialog(options);

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          ((DatePickerDialog) datePickerFragment.getDialog())
              .getButton(DialogInterface.BUTTON_POSITIVE).performClick();
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(0, mRecordingModule.getErrors());
  assertEquals(1, mRecordingModule.getDates().size());
  assertEquals(2020, (int) mRecordingModule.getDates().get(0)[0]);
  assertEquals(5, (int) mRecordingModule.getDates().get(0)[1]);
  assertEquals(6, (int) mRecordingModule.getDates().get(0)[2]);
}
 
Example #11
Source File: TimeLineWhoLikesDialog.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setStyle( DialogFragment.STYLE_NORMAL, R.style.TimelineCommentsDialog );
    final Context c = getActivity();

    final View dialogView = LayoutInflater.from(c).inflate(R.layout.dialog_wholikes, null);
    likesNumber = Integer.valueOf(getArguments().getString(LIKES));
    id=getArguments().getLong(POSTID);
    lv = (ListView) dialogView.findViewById(R.id.TimeLineListView);
    final TextView likes = (TextView) dialogView.findViewById(R.id.likes);

    if(likesNumber == 1) {
        likes.setText(likesNumber + " " + getString(R.string.timeline_like));
    }else{
        likes.setText(likesNumber + " " + getString(R.string.likes));
    }

    return new AlertDialog.Builder(c)
            .setView(dialogView)
            .create();
}
 
Example #12
Source File: BasePurchaseActivity.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onClick(int payType, String imsi,  String price, String currency) {
    DialogFragment df = new ProgressDialogFragment();

    df.setCancelable(false);
    df.show(getSupportFragmentManager(), "pleaseWaitDialog");
    PayProductRequestUnitel requestUnitel = new PayProductRequestUnitel();
    requestUnitel.setProductId(String.valueOf(aptoideProductId));
    requestUnitel.setPayType(String.valueOf(payType));
    requestUnitel.setToken(token);
    requestUnitel.setImsi(imsi);
    requestUnitel.setPrice(price);
    requestUnitel.setCurrency(currency);
    requestUnitel.setRepo(repo);
    requestsetExtra(requestUnitel);
    requestUnitel.setRetryPolicy(noRetryPolicy);
    spiceManager.execute(requestUnitel, new PurchaseRequestListener());

}
 
Example #13
Source File: PhotosetsFragment.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
public void onLongClickDialogSelection(Photoset photoset, int which) {
    Log.d(TAG, "onLongClickDialogSelection()");
    FragmentTransaction ft =
        mActivity.getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(android.R.anim.fade_in,
            android.R.anim.fade_out);
    if (photoset != null) {
        Fragment prev = mActivity.getSupportFragmentManager()
            .findFragmentByTag(AddToPhotosetDialogFragment.TAG);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);

        DialogFragment newFragment =
            AddToPhotosetDialogFragment.newInstance(photoset);
        newFragment.show(ft, AddToPhotosetDialogFragment.TAG);
    } else {
        Log.e(TAG, "onLongClickDialogSelection: photoset is null");
    }
}
 
Example #14
Source File: IntentChooserFragment.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
public static void showIntentChooserDialog(@NonNull FragmentManager fm, int type) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG);
    if (prev != null) {
        ft.remove(prev);
    }

    try {
        DialogFragment dialog = IntentChooserFragment.newInstance(type);
        dialog.show(ft, TAG);
    } catch (IllegalArgumentException | IllegalStateException ignored) {}
}
 
Example #15
Source File: DialogPreference.java    From android_external_MicroGUiTools with Apache License 2.0 5 votes vote down vote up
public static DialogFragment newInstance(String key) {
    final DialogPreferenceCompatDialogFragment fragment = new DialogPreferenceCompatDialogFragment();
    final Bundle b = new Bundle(1);
    b.putString(ARG_KEY, key);
    fragment.setArguments(b);
    return fragment;
}
 
Example #16
Source File: FolderChooserDialogCreate.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public void show(FragmentActivity context) {
    final String tag = getBuilder().mTag;
    Fragment frag = context.getSupportFragmentManager().findFragmentByTag(tag);
    if (frag != null) {
        ((DialogFragment) frag).dismiss();
        context.getSupportFragmentManager().beginTransaction()
                .remove(frag).commit();
    }
    show(context.getSupportFragmentManager(), tag);
}
 
Example #17
Source File: RequestManagerRetriever.java    From MNImageBrowser with GNU General Public License v3.0 5 votes vote down vote up
public ImmersionBar get(Fragment fragment) {
    checkNotNull(fragment, "fragment is null");
    checkNotNull(fragment.getActivity(), "fragment.getActivity() is null");
    if (fragment instanceof DialogFragment) {
        checkNotNull(((DialogFragment) fragment).getDialog(), "fragment.getDialog() is null");
    }
    return getSupportFragment(fragment.getChildFragmentManager(), mTag + fragment.toString()).get(fragment);
}
 
Example #18
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static void forceShowDialog(FragmentActivity activity, DialogFragment dialogFragment) {
    try {
        dialogFragment.show(activity.getSupportFragmentManager(), "");
        activity.getSupportFragmentManager().executePendingTransactions();
    } catch (Exception ignored) {

    }
}
 
Example #19
Source File: AppRateController.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
public void showRateDialog(AppCompatActivity activity) {
    if (!activity.isFinishing()) {
        DialogFragment DonationReminderDialogFragment = new DonationReminderDialogFragment();
        DonationReminderDialogFragment.show(activity.getSupportFragmentManager(), "DonationReminderDialogFragment");
        PreferenceHelper.resetLaunchTimes(activity);
        PreferenceHelper.reSetLastRemind(activity);
    }
}
 
Example #20
Source File: PreferenceActivity.java    From Color-picker-library with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onColorSelection(DialogFragment dialogFragment, int color) {

    int tag;

    tag = Integer.valueOf(dialogFragment.getTag());

    switch (tag) {

        //do something on color selection
        case 3:
            colorDialog.setColorPreferenceSummary(firstPreference, color, PreferenceActivity.this, getResources());
            colorDialog.setPickerColor(PreferenceActivity.this, 3, color);

            //do your shit here
            Toast.makeText(getBaseContext(), getResources().getString(R.string.selection) + tag + getResources().getString(R.string.is) + Integer.toHexString(color).toUpperCase(), Toast.LENGTH_SHORT)
                    .show();
            break;

        case 4:
            colorDialog.setColorPreferenceSummary(secondPreference, color, PreferenceActivity.this, getResources());
            colorDialog.setPickerColor(PreferenceActivity.this, 4, color);

            //do your shit here
            Toast.makeText(getBaseContext(), getResources().getString(R.string.selection) + tag + getResources().getString(R.string.is) + Integer.toHexString(color).toUpperCase(), Toast.LENGTH_SHORT)
                    .show();
            break;
    }

}
 
Example #21
Source File: LoadingDialog.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Override
public void showLoading() {
    if (mWaitForHide.compareAndSet(false, true)) {
        if (mFm.findFragmentByTag(LoadingDialog.class.getName()) == null) {
            DialogFragment dialog = new LoadingDialog();
            dialog.show(mFm, LoadingDialog.class.getName());
        }
    }
}
 
Example #22
Source File: MainActivity.java    From ActivityDiary with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNoteEditPositiveClock(String str, DialogFragment dialog) {
    ContentValues values = new ContentValues();
    values.put(ActivityDiaryContract.Diary.NOTE, str);

    mQHandler.startUpdate(0,
            null,
            viewModel.getCurrentDiaryUri(),
            values,
            null, null);

    viewModel.mNote.postValue(str);
    ActivityHelper.helper.setCurrentNote(str);
}
 
Example #23
Source File: CreateEditActivity.java    From recurrence with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRepeatSelection(DialogFragment dialog, int which, String repeatText) {
    interval = 1;
    repeatType = which;
    this.repeatText.setText(repeatText);
    if (which == Reminder.DOES_NOT_REPEAT) {
        showFrequency(false);
    } else {
        showFrequency(true);
    }
}
 
Example #24
Source File: BookCollectionDialogFragmnet.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setStyle(DialogFragment.STYLE_NORMAL, R.style.ThemeOverlay_AppCompat_Dialog_Alert);
    Bundle arguments = getArguments();


    Gson gson = new Gson();
    String serializedBookCollectionInfo = arguments.getString(KEY_COLLECTION_IDS);
    bookCollectionInfo = gson.fromJson(serializedBookCollectionInfo, BookCollectionInfo.class);
    bookCollectionsController = new BookCollectionsController(getContext(), bookCollectionsControllerCallback);
    bookCollections = bookCollectionsController.getAllBookCollections(getContext(), false, true);
    bookCollectionRecyclerViewAdapter = new BookCollectionRecyclerViewAdapter(bookCollections, bookCollectionInfo);

}
 
Example #25
Source File: AppViewActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
private void showDialogIfComingFromBrowser() {
    if (getActivity().getIntent().getBooleanExtra(Constants.FROM_MY_APP_KEY, false) && !isPaidApp()) {
        final InstallListener installListener = new InstallListener(iconUrl, appName, versionName, packageName, md5sum, isPaidApp());
        DialogFragment dialog = AptoideDialog.myAppInstall(appName, installListener, onDismissListener);
        AptoideDialog.showDialogAllowingStateLoss(dialog, getChildFragmentManager(),"myApp");
    }
}
 
Example #26
Source File: TimePickerDialogTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
public void testPresetTimeAndCallback() throws Throwable {
  final WritableMap options = new WritableNativeMap();
  options.putInt("hour", 4);
  options.putInt("minute", 5);

  final DialogFragment fragment = showDialog(options);

  List<Integer[]> recordedTimes = mRecordingModule.getTimes();
  assertEquals(0, recordedTimes.size());

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          ((TimePickerDialog) fragment.getDialog())
              .getButton(DialogInterface.BUTTON_POSITIVE).performClick();
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(0, mRecordingModule.getErrors());
  assertEquals(0, mRecordingModule.getDismissed());

  recordedTimes = mRecordingModule.getTimes();
  assertEquals(1, recordedTimes.size());
  assertEquals(4, (int) recordedTimes.get(0)[0]);
  assertEquals(5, (int) recordedTimes.get(0)[1]);
}
 
Example #27
Source File: LoginActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public void setShowProgress(final boolean showProgress) {
    final DialogFragment progress = (DialogFragment) getSupportFragmentManager().findFragmentByTag(TAG_PROGRESS);
    if (progress == null && showProgress) {
        try {
            AptoideDialog.pleaseWaitDialog().show(getSupportFragmentManager(), TAG_PROGRESS);
        // https://code.google.com/p/android/issues/detail?id=23761
        } catch (IllegalStateException ignore) { }
    } else if (progress != null && !showProgress) {
        progress.dismissAllowingStateLoss();
    }
}
 
Example #28
Source File: FullScannerFragment.java    From alpha-wallet-android with MIT License 5 votes vote down vote up
public void closeDialog(String dialogName) {
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    DialogFragment fragment = (DialogFragment) fragmentManager.findFragmentByTag(dialogName);
    if(fragment != null) {
        fragment.dismiss();
    }
}
 
Example #29
Source File: OptionDialogFragment.java    From RhymeMusic with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{

    switch ( position )
    {
        case PLAY_MODE:
            MusicApplication application =
                    (MusicApplication) getActivity().getApplication();
            MusicService.MusicBinder musicBinder = application.getMusicBinder();

            musicBinder.changePlayMode();
            break;

        case AUTO_STOP:
            getDialog().dismiss(); // 关闭父对话框

            DialogFragment dialogFragment = new ASDialogFragment();
            FragmentManager manager = getFragmentManager();
            dialogFragment.show(manager, "dialog auto stop");
            break;

        case AUDIO_INFO:
            getDialog().dismiss(); // 关闭父对话框

            DialogFragment dialogFragment1 = new AIDialogFragment();
            FragmentManager manager1 = getFragmentManager();
            dialogFragment1.show(manager1, "dialog audio info");
            break;

        case MORE_INFO:
            getDialog().dismiss(); // 关闭父对话框

            Toast.makeText(getActivity(), "暂未开发", Toast.LENGTH_SHORT).show();
            break;

        default:
            break;
    }
}
 
Example #30
Source File: ChangeLogDialogFragment.java    From openwebnet-android with MIT License 5 votes vote down vote up
public static void show(AppCompatActivity activity) {
    DialogFragment dialogFragment = new ChangeLogDialogFragment();
    FragmentManager fm = activity.getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag(TAG_FRAGMENT);
    if (prev != null) {
        ft.remove(prev);
    }
    dialogFragment.show(ft, TAG_FRAGMENT);
}