private void showDialogFragment(int dialogId, String customMessage) { if (mDestroyed) { return; } mProgressBar.setIndeterminate(false); DialogFragment fragment; switch (dialogId) { case R.id.dialog_account_setup_error: { fragment = ConfirmationDialogFragment.newInstance(dialogId, getString(R.string.account_setup_failed_dlg_title), customMessage, getString(R.string.account_setup_failed_dlg_edit_details_action), getString(R.string.account_setup_failed_dlg_continue_action) ); break; } default: { throw new RuntimeException("Called showDialog(int) with unknown dialog id."); } } FragmentTransaction ta = getFragmentManager().beginTransaction(); ta.add(fragment, getDialogTag(dialogId)); ta.commitAllowingStateLoss(); // TODO: commitAllowingStateLoss() is used to prevent https://code.google.com/p/android/issues/detail?id=23761 // but is a bad... //fragment.show(ta, getDialogTag(dialogId)); }
@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_NORMAL; break; case 6: style = DialogFragment.STYLE_NO_TITLE; break; case 7: style = DialogFragment.STYLE_NO_FRAME; break; case 8: style = DialogFragment.STYLE_NORMAL; break; } switch ((mNum-1)%6) { case 4: theme = android.R.style.Theme_Holo; break; case 5: theme = android.R.style.Theme_Holo_Light_Dialog; break; case 6: theme = android.R.style.Theme_Holo_Light; break; case 7: theme = android.R.style.Theme_Holo_Light_Panel; break; case 8: theme = android.R.style.Theme_Holo_Light; break; } setStyle(style, theme); }
public static View.OnClickListener getPickImageClickListener(final FragmentActivity activity,final DialogFragment fragment, final int requestCode){ return new View.OnClickListener() { @Override public void onClick(View v) { pickIntent(); } private void pickIntent(){ Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); activity.startActivityFromFragment(fragment, Intent.createChooser(intent, "Complete action using"), requestCode); } }; }
/** * Location button clicked, record location. * @param dialog * @return currentLoc */ @Override public Location onLocButtonClick(DialogFragment dialog) { if (checkLocationPermission()){ mFusedLocationClient.getLastLocation() .addOnSuccessListener(this, new OnSuccessListener<Location>() { @Override public void onSuccess(Location location) { // Got last known location. In some rare situations this can be null. if (location != null) { currentLoc = location; } } }); }else{requestPermission();} return currentLoc; }
/** * Handles the call back from the date picker * @param dialog DatePicker * @param date Habit Date */ @Override public void onDatePicked(DialogFragment dialog, Date date) { boolean allowed=true; ArrayList<HabitEvent> events = habit.getEvents(); if (events!=null){ for (HabitEvent event : events){ if (Util.isDateAfter(event.getDate(),date)){ allowed=false; break; } } } if (allowed) { TextView habitDate = (TextView) findViewById(R.id.textHabitDate); habitDate.setText(dateFormat.format(date)); habit.setStartDate(date); }else{ Toast.makeText(ViewHabitActivity.this,"An event already exists prior to " + dateFormat.format(date) + "!",Toast.LENGTH_LONG).show(); } }
/** * User clicked the request dialog's positive option * @param dialog Send Request Dialog Fragment * @param userName Username of profile to follow */ public void onDialogPositiveClick(DialogFragment dialog, String userName) { Log.i("Info", "requested to follow "+userName); ElasticSearchController.GetProfilesTask sendARequest = new ElasticSearchController.GetProfilesTask(); sendARequest.execute(userName); try { matches = sendARequest.get(); }catch (Exception e){ Log.i("Error", "Failed to get profiles from async object"); } followee = matches.get(0); if (followee.getFollowRequests()==null) { followee.setFollowRequests(new ArrayList<Profile>()); } followee.addFollowReq(me); if (!followee.getFollowRequests().isEmpty()) { Log.i("Info", "Added " + me.getUsername() + " to " + followee.getUsername()); } saveData(); }
/** * User clicked the Accept Follower Dialog's positive option. The follow request is deleted, and * the follower adds the user to their users follower. * @param dialog Accept Follower Dialog Fragment * @param followerName Username of new follower profile */ @Override public void onDialogPositiveClick(DialogFragment dialog, String followerName) { Log.i("Info", "accepted follow from "+followerName); ElasticSearchController.GetProfilesTask acceptFollow = new ElasticSearchController.GetProfilesTask(); acceptFollow.execute(followerName); try { followers = acceptFollow.get(); }catch (Exception e){ Log.i("Error", "Failed to get profiles from async object"); } follower = followers.get(0); if (follower.getUsersFollowed()==null) { follower.setUsersFollowed(new ArrayList<Profile>()); } follower.addFollowee(me); if (follower.getUsersFollowed().get(follower.getUsersFollowed().size()-1).getUsername().equals(me.getUsername())) { Log.i("Info", "Added " + me.getUsername() + " as user followed to " + follower.getUsername()); } saveData(); me.removeFollowReq(pos); saveProfile(); usersArrayAdapter.notifyDataSetChanged(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if(R.id.add_photo == id) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.add_photo)), PICK_IMAGE); } else if(R.id.clear == id) { List<Drawable> drawables = imageViewPagerAdapter.drawables; drawables.clear(); addDefaultImages(drawables); imageViewPagerAdapter.notifyDataSetChanged(); } else if(R.id.info == id) { DialogFragment infoDialogFragment = new InfoDialogFragment(); infoDialogFragment.show(getFragmentManager(), "info"); } return super.onOptionsItemSelected(item); }
private void updateSummary(String key, boolean changing) { switch (key) { case Constants.PREF_APP_LANGUAGE: entrySummary(key); if (changing) { DialogFragment dialogFragment = new SettingsAlertDialog().newInstance(R.string.restart_dialog_message); dialogFragment.show(getActivity().getFragmentManager(), "restartApp"); } break; case Constants.PREF_MOVIES_LANGUAGE: entrySummary(key); break; case Constants.PREF_IMAGES_CACHE: File cacheDir = getActivity().getCacheDir(); File picassoCacheDir = new File(cacheDir, "picasso-cache"); double size = AppUtils.getDirSize(picassoCacheDir); preferenceSummary(key, getString(R.string.pref_summary_cache_size, size)); break; } }
/** * For working with pre-Android M security permissions * @param gpsEnabled If the cacheManifest and system allow gps * @param networkLocationEnabled If the cacheManifest and system allow network location access * @param cellularEnabled If the cacheManifest and system allow cellular data access */ private void alertDialog(boolean gpsEnabled, boolean networkLocationEnabled, boolean cellularEnabled){ if(!gpsEnabled || !networkLocationEnabled){ sendCallback(PluginResult.Status.ERROR, JSONHelper.errorJSON(PROVIDER_PRIMARY, ErrorMessages.LOCATION_SERVICES_UNAVAILABLE())); final DialogFragment gpsFragment = new GPSAlertDialogFragment(); gpsFragment.show(_cordovaActivity.getFragmentManager(), "GPSAlert"); } if(!cellularEnabled){ sendCallback(PluginResult.Status.ERROR, JSONHelper.errorJSON(PROVIDER_PRIMARY, ErrorMessages.CELL_DATA_NOT_AVAILABLE())); final DialogFragment networkUnavailableFragment = new NetworkUnavailableDialogFragment(); networkUnavailableFragment.show(_cordovaActivity.getFragmentManager(), "NetworkUnavailableAlert"); } }
private static void showDialog(Activity activity, Class clazz, String tag) { FragmentManager fm = activity.getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag(tag); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); try { ((DialogFragment) clazz.newInstance()).show(ft, tag); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } }
@Override public void onDialogPositiveClick(DialogFragment dialog) { Dialog dialogView = dialog.getDialog(); EditText txt_seed = (EditText) dialogView.findViewById(R.id.txt_seed); seed = txt_seed.getText().toString(); generate_potd_list(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Do not create a new Fragment when the Activity is re-created such as orientation changes. setRetainInstance(true); setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog); }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference.equals(findPreference(Constants.PREF_IMAGES_CACHE))) { File cacheDir = getActivity().getCacheDir(); File picassoCacheDir = new File(cacheDir, "picasso-cache"); int messageId = AppUtils.deleteDir(picassoCacheDir) ? R.string.clear_cache_message_ok : R.string.clear_cache_message_fail; DialogFragment dialogFragment = new SettingsAlertDialog().newInstance(messageId); dialogFragment.show(getActivity().getFragmentManager(), "clearCache"); updateSummary(Constants.PREF_IMAGES_CACHE, false); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen); if (openBlur()) {// 是否开启模糊效果 dialogEngine = new BlurEngine(getActivity()); dialogEngine.setBlurDegree(getBlurDegree()); dialogEngine.setBlurRadius(getBlurRadius()); dialogEngine.setSwitchEngine(isSwitchEngine()); dialogEngine.setDebugMode(isDebugMode()); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notification_settings); getSupportActionBar().setDisplayHomeAsUpEnabled(true); setTitle(R.string.title_settings_notification); notificationListView = (ListView) findViewById(R.id.notificationListView); preferences = getApplicationContext().getSharedPreferences( getString(R.string.preference_file_key), Context.MODE_PRIVATE); addNotificationFab = (FloatingActionButton) findViewById(R.id.timePickerFAB); addNotificationFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new TimePickerFragment(); newFragment.show(getFragmentManager(), "timePicker"); } }); notifications = new ArrayList<>(); String notificationsGsonString = preferences.getString(getString(R.string.preference_notifications), ""); Type type = new TypeToken<List<NotificationSetting>>() { }.getType(); if (!notificationsGsonString.equals("")) { notifications = new Gson().fromJson(notificationsGsonString, type); } refreshList(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog); fingerprintLoginTask = new FingerprintLoginTask(this, userService); passwordLoginTask = new PasswordLoginTask(this, userService); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog); }
@Override protected void onPostExecute(final JSONArray newsList) { if (newsList != null && newsList.length() > 0 && !serverConn.hasError()) for (int i = 0; i < newsList.length(); i++) if (!isCancelled() && !Thread.interrupted()) try { final JSONObject newsItem = newsList.getJSONObject(i); final DialogFragment newFragment = RMBTAlertDialogFragment.newInstance( newsItem.optString("title", activity.getString(R.string.news_title)), newsItem.optString("text", activity.getString(R.string.news_no_message)), null); newFragment.show(activity.getFragmentManager(), "dialog"); if (newsItem.has("uid")) { if (lastNewsUid < newsItem.getLong("uid")) lastNewsUid = newsItem.getLong("uid"); } } catch (final JSONException e) { e.printStackTrace(); } ConfigHelper.setLastNewsUid(activity.getApplicationContext(), lastNewsUid); }
/** * When accept button clicked,save changes * @param dialog * @param newcomment * @param newloc */ @Override public void onDialogPositiveClick(DialogFragment dialog, String newcomment, Location newloc) { if (newloc != null) { event.setLocation(newloc); } event.setComment(newcomment); comment.setText(newcomment); }
/** * Receives new information from edit habit dialog and makes appropriate updates to the habit. * Closes dialog. * @param dialog Edit Habit Dialog Fragment * @param newreason Updated habit reason string * @param newtitle Updated habit name string */ @Override public void onDialogPositiveClick(DialogFragment dialog, String newreason, String newtitle, HashSet<Integer> newschedule) { reason.setText(newreason); toolbar.setTitle(newtitle); schedule.setText(getScheduleString(newschedule)); habit.setReason(newreason); habit.setTitle(newtitle); habit.setSchedule(newschedule); }
/** * User clicked the positive option of the dialog, and the app searches for the requested user * @param dialog User Search Dialog Fragment * @param userSearch Username input */ @Override public void onDialogPositiveClick(DialogFragment dialog, String userSearch) { if (userSearch.equals("")) { Toast.makeText(FollowActivity.this,"Please enter a user to search for!", Toast.LENGTH_SHORT).show(); } else { Intent results = new Intent(FollowActivity.this, SearchResultsActivity.class); results.putExtra("search", userSearch); startActivity(results); } }
@Override public void onPositiveClick(DialogFragment dialog, String title, String desc) { // add the post to Firebase Database DatabaseReference ref = postsRef.push(); ref.child("post_title").setValue(title); ref.child("post_desc").setValue(desc); ref.child("uid").setValue(firebaseUser.getUid()); List<String> joinedUsers = new ArrayList<>(); for (int i = 1; i <= 7; i++) joinedUsers.add("uid" + i); ref.child("joined_users").setValue(joinedUsers); ref.child("name").setValue(firebaseUser.getDisplayName()); ref.child("type").setValue(User.getInstance().getType()); }
private static void cancelDialog(FragmentManager fragmentManager, String tag) { Fragment fragment = fragmentManager.findFragmentByTag(tag); if (fragment == null) return; DialogFragment dialogFragment = (DialogFragment) fragment; if (dialogFragment.getDialog() == null) return; dialogFragment.getDialog().cancel(); }
private void closeDialogIfOpen(String tag) { FragmentManager manager = getFragmentManager(); if (manager == null) { // Do nothing if the manager doesn't exist yet; see http://crbug.com/480544. return; } DialogFragment df = (DialogFragment) manager.findFragmentByTag(tag); if (df != null) { df.dismiss(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Do not create a new Fragment when the Activity is re-created such as orientation changes. setRetainInstance(true); setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Material_Light_Dialog); mKeyguardManager = (KeyguardManager) getContext().getSystemService(Context.KEYGUARD_SERVICE); mFingerprintUiHelperBuilder = new FingerprintUiHelper.FingerprintUiHelperBuilder( getContext(), getContext().getSystemService(FingerprintManager.class)); }
void hideDonateDialog() { DialogFragment fragment = (DialogFragment) getFragmentManager() .findFragmentByTag(FRAGMENT_DONATION_PROGRESS); if (fragment != null && !isStopped()) { fragment.dismiss(); } }
private void dismissDialog(String tag, boolean allowStateLoss) { DialogFragment fragment = (DialogFragment) getFragmentManager().findFragmentByTag(tag); if (fragment != null) { if (Log.isLoggable(UILog.TAG, Log.DEBUG)) { UILog.d("dismiss " + tag + ", " + allowStateLoss + ": " + allowStateLoss + ", stopped: " + isStopped()); } if (allowStateLoss) { fragment.dismissAllowingStateLoss(); } else if (!isStopped()) { fragment.dismiss(); } } }
public void onEventMainThread(ThrowableFailureEvent event) { if (ErrorDialogManager.isInExecutionScope(this.executionScope, event)) { ErrorDialogManager.checkLogException(event); FragmentManager fm = getFragmentManager(); fm.executePendingTransactions(); DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(ErrorDialogManager.TAG_ERROR_DIALOG); if (existingFragment != null) { existingFragment.dismiss(); } DialogFragment errorFragment = (DialogFragment) ErrorDialogManager.factory.prepareErrorFragment(event, this.finishAfterDialog, this.argumentsForErrorDialog); if (errorFragment != null) { errorFragment.show(fm, ErrorDialogManager.TAG_ERROR_DIALOG); } } }
public void onEventMainThread(ThrowableFailureEvent event) { if (ErrorDialogManager.isInExecutionScope(this.executionScope, event)) { ErrorDialogManager.checkLogException(event); android.support.v4.app.FragmentManager fm = getFragmentManager(); fm.executePendingTransactions(); android.support.v4.app.DialogFragment existingFragment = (android.support.v4.app.DialogFragment) fm.findFragmentByTag(ErrorDialogManager.TAG_ERROR_DIALOG); if (existingFragment != null) { existingFragment.dismiss(); } android.support.v4.app.DialogFragment errorFragment = (android.support.v4.app.DialogFragment) ErrorDialogManager.factory.prepareErrorFragment(event, this.finishAfterDialog, this.argumentsForErrorDialog); if (errorFragment != null) { errorFragment.show(fm, ErrorDialogManager.TAG_ERROR_DIALOG); } } }
public static void show(Activity activity) { if(!InstallationInfo.isVersionFirstExecution(activity)) return; DialogFragment dialog = new WhatsNewDialogFragment(activity); dialog.setCancelable(false); dialog.show(activity.getFragmentManager(), "WhatsNewDialogFragment"); }
@Override public void dontAllow(int reason) { if (activity.isFinishing()) return; activity.runOnUiThread(new Runnable() { public void run() { DialogFragment dialogFragment = new LicenseDialogFragment(activity); dialogFragment.setCancelable(false); dialogFragment.show(activity.getFragmentManager(), "LicenseDialogFragment"); } }); }
@Override public void applicationError(int errorCode) { activity.runOnUiThread(new Runnable() { public void run() { DialogFragment dialogFragment = new LicenseDialogFragment(activity); dialogFragment.setCancelable(false); dialogFragment.show(activity.getFragmentManager(), "LicenseDialogFragment"); } }); }
public static void show(Activity activity) { if( !android.os.Build.VERSION.RELEASE.startsWith("5.") ) return; if( InstallationInfo.consentLollipopProblems() ) return; DialogFragment dialog = new LollipopDialogFragment(activity); dialog.setCancelable(false); dialog.show(activity.getFragmentManager(), "LollipopDialogFragment"); }
@Override public void showTimePicker(int viewID) { SublimePickerDialog pickerFrag = new SublimePickerDialog(); SublimePickerDialog.Callback onTimePickedCallback = mNewGoalPresenter.getTimePickerCallbackListener(); pickerFrag.setCallback(onTimePickedCallback); Bundle bundle = new Bundle(); bundle.putParcelable("SUBLIME_OPTIONS", mNewGoalPresenter.getSublimePickerOptions(viewID)); bundle.putInt("viewID", viewID); pickerFrag.setArguments(bundle); pickerFrag.setStyle(DialogFragment.STYLE_NO_TITLE, 0); pickerFrag.show(getActivity().getSupportFragmentManager(), "SublimePickerDialog"); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Dialog); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NO_TITLE, R.style.ProgressDialogStyle); }