List of usage examples for android.app AlertDialog cancel
@Override public void cancel()
From source file:org.brandroid.openmanager.fragments.DialogHandler.java
/** * Show a warning that has a specific count down to auto-cancel. * @param context Context./*from w ww . java2s. c om*/ * @param msg Message String ID. * @param countSecs Length in seconds to show message before auto-cancelling. * @param onOK Callback for when "OK" is selected. * @return */ public static AlertDialog showWarning(final Context context, int msg, int countSecs, DialogInterface.OnClickListener onOK) { final Timer timer = new Timer("Count Down"); final AlertDialog dlg = new AlertDialog.Builder(context).setMessage(msg) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); timer.cancel(); } }).setCancelable(true).setPositiveButton(android.R.string.ok, onOK).show(); final int[] cnt = new int[] { countSecs }; final Button btCancel = dlg.getButton(DialogInterface.BUTTON_NEGATIVE); TimerTask tt = new TimerTask() { @Override public void run() { if (dlg.isShowing()) { btCancel.post(new Runnable() { public void run() { btCancel.setText(context.getResources().getString(android.R.string.cancel) + " (" + cnt[0]-- + ")"); } }); } else cnt[0] = 0; if (cnt[0] <= 0) cancel(); } @Override public boolean cancel() { dlg.cancel(); return super.cancel(); } }; timer.scheduleAtFixedRate(tt, 0, 1000); return dlg; }
From source file:com.metinkale.prayerapp.vakit.fragments.SortFragment.java
public void onItemDismiss(final int position) { final Times times = Times.getTimesAt(position); AlertDialog dialog = new AlertDialog.Builder(getActivity()).create(); dialog.setTitle(R.string.delete);/*from w w w.j a v a 2 s . c om*/ dialog.setMessage(getString(R.string.delConfirm, times.getName())); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int buttonId) { times.delete(); mAdapter.notifyItemRemoved(position); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int buttonId) { dialog.cancel(); mAdapter.notifyDataSetChanged(); } }); dialog.show(); }
From source file:com.media.HomeFragmentActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {// ? if (resultCode == RESULT_OK) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(HomeFragmentActivity.this).create(); alertDialog.show();//from w w w . j a v a 2s.c o m handler.postDelayed(new Runnable() { @Override public void run() { // Do something after 5000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); if (videoFragment == null) { VideoFragment newVideoFragment = new VideoFragment(); newVideoFragment.addItem(fileUriString); } else { videoFragment.addItem(fileUriString); } alertDialog.cancel(); } }, 1500); } else if (resultCode == RESULT_CANCELED) { // User cancelled the video capture } else { // Video capture failed, advise user } } else if (requestCode == MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {// ? if (resultCode == RESULT_OK) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(HomeFragmentActivity.this).create(); alertDialog.show(); handler.postDelayed(new Runnable() { @Override public void run() { // Do something after 5000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); if (imageFragment == null) { ImageFragment newImageFragment = new ImageFragment(); newImageFragment.addItem(fileUriString); } else { imageFragment.addItem(fileUriString); } alertDialog.cancel(); } }, 1500); } } else if (requestCode == 300) {// if (resultCode == RESULT_OK) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(HomeFragmentActivity.this).create(); alertDialog.show(); handler.postDelayed(new Runnable() { @Override public void run() { luyinFragment = new LuYinFragment(); getSupportFragmentManager().beginTransaction().replace(R.id.contain, luyinFragment) .commit(); // Do something after 5000ms // String fileUriString = // fileUri.toString().replaceFirst("file:///", // "/").trim(); // if(luyinFragment == null) // { // LuYinFragment newLuYinFragment = new LuYinFragment(); // newLuYinFragment.addItem(fileUriString); // // }else // { // luyinFragment.addItem(fileUriString); // } alertDialog.cancel(); } }, 1500); } } }
From source file:org.rm3l.ddwrt.DDWRTMainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data); // Check which request we're responding to switch (requestCode) { case LISTENED_REQUEST_CODE: //Forward to listener if (mCurrentActivityResultListener != null) { final DDWRTTile.ActivityResultListener listener = mCurrentActivityResultListener; mCurrentActivityResultListener = null; listener.onResultCode(resultCode, data); }/*from w w w . ja va 2 s.c o m*/ break; case ROUTER_SETTINGS_ACTIVITY_CODE: // Make sure the request was successful and reload U if necessary if (resultCode == RESULT_OK) { if (this.mCurrentSyncInterval != this.mPreferences.getLong(SYNC_INTERVAL_MILLIS_PREF, -1l) || this.mCurrentTheme != this.mPreferences.getLong(THEMING_PREF, -1l) || !this.mCurrentSortingStrategy .equals(this.mPreferences.getString(SORTING_STRATEGY_PREF, ""))) { //Reload UI final AlertDialog alertDialog = Utils.buildAlertDialog(this, null, "Reloading UI...", false, false); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)) .setGravity(Gravity.CENTER_HORIZONTAL); new Handler().postDelayed(new Runnable() { @Override public void run() { finish(); startActivity(getIntent()); alertDialog.cancel(); } }, 2000); } } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceTile.java
@Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.tile_status_wireless_iface_qrcode: if (wifiEncryptionType == null || (isNullOrEmpty(wifiSsid) && isNullOrEmpty(wifiPassword))) { //menu item should have been disabled, but anyways, you never know :) Toast.makeText(mParentFragmentActivity, "Missing parameters to generate QR-Code - try again later", Toast.LENGTH_SHORT).show(); return true; }/* w ww . j a v a2s.c o m*/ //https://github.com/zxing/zxing/wiki/Barcode-Contents //noinspection ConstantConditions final String wifiSsidNullToEmpty = nullToEmpty(wifiSsid); final String wifiQrCodeString = String.format("WIFI:S:%s;T:%s;P:%s;%s;", escapeString(wifiSsidNullToEmpty), wifiEncryptionType.toString(), escapeString(nullToEmpty(wifiPassword)), wifiSsidNullToEmpty.isEmpty() ? "H:true" : ""); final String routerUuid = mRouter.getUuid(); final Class<?> activityClass = Utils.isThemeLight(mParentFragmentActivity, routerUuid) ? WirelessIfaceQrCodeActivityLight.class : WirelessIfaceQrCodeActivity.class; final Intent intent = new Intent(mParentFragmentActivity, activityClass); intent.putExtra(RouterManagementActivity.ROUTER_SELECTED, routerUuid); intent.putExtra(WirelessIfaceQrCodeActivity.SSID, wifiSsidNullToEmpty); intent.putExtra(WirelessIfaceQrCodeActivity.WIFI_QR_CODE, wifiQrCodeString); final AlertDialog alertDialog = Utils.buildAlertDialog(mParentFragmentActivity, null, String.format("Generating QR Code for '%s'", wifiSsidNullToEmpty), false, false); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_HORIZONTAL); new Handler().postDelayed(new Runnable() { @Override public void run() { mParentFragmentActivity.startActivity(intent); alertDialog.cancel(); } }, 2500); return true; default: break; } return false; }
From source file:com.juick.android.ThreadActivity.java
private void previewAndSendReply(final String msg) { final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (sp.getBoolean("previewReplies", false)) { final TextView tv = new TextView(this); JuickMessage jm = new JuickMessage(); jm.User = new JuickUser(); jm.User.UName = "You"; jm.Text = msg;//from w w w.j a v a 2 s.co m jm.tags = new Vector<String>(); if (rid != 0) { // insert destination user name JuickMessage reply = tf.findReply(tf.getListView(), rid); if (reply != null) { jm.Text = "@" + reply.User.UName + " " + jm.Text; } } JuickMessagesAdapter.ParsedMessage parsedMessage = JuickMessagesAdapter.formatMessageText(this, jm, true); tv.setText(parsedMessage.textContent); tv.setPadding(10, 10, 10, 10); MainActivity.restyleChildrenOrWidget(tv); final AlertDialog dialog = new AlertDialog.Builder( new ContextThemeWrapper(this, R.style.Theme_Sherlock_Light)).setTitle("Post reply - preview") .setView(tv).setCancelable(true) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }).setPositiveButton("Post reply", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); sendReplyMain(msg); } }).create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface i) { tv.setBackgroundColor(JuickMessagesAdapter.getColorTheme(dialog.getContext()).getBackground()); MainActivity.restyleChildrenOrWidget(tv); } }); dialog.show(); } else { sendReplyMain(msg); } }
From source file:org.rm3l.ddwrt.tiles.status.wan.WANMonthlyTrafficTile.java
@Override public void onLoadFinished(Loader<NVRAMInfo> loader, NVRAMInfo data) { Log.d(LOG_TAG, "onLoadFinished: loader=" + loader + " / data=" + data + " / traffData=" + traffData); setLoadingViewVisibility(View.GONE); Exception preliminaryCheckException = null; if (data == null) { preliminaryCheckException = new DDWRTNoDataException("No Data!"); } else //noinspection ThrowableResultOfMethodCallIgnored if (data.getException() == null) { if (!"1".equals(data.getProperty(NVRAMInfo.TTRAFF_ENABLE))) { preliminaryCheckException = new IllegalStateException("Traffic monitoring disabled!"); } else if (traffData == null || traffData.isEmpty()) { preliminaryCheckException = new DDWRTNoDataException("No Traffic Data!"); }//from www .j a v a 2 s.c om } if (preliminaryCheckException != null) { data = new NVRAMInfo().setException(preliminaryCheckException); } @NotNull final TextView errorPlaceHolderView = (TextView) this.layout .findViewById(R.id.tile_status_wan_monthly_traffic_error); @Nullable final Exception exception = data.getException(); final View displayButton = this.layout .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_display_button); final View currentButton = this.layout .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_current); final View previousButton = this.layout .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_previous); final View nextButton = this.layout .findViewById(R.id.tile_status_wan_monthly_traffic_graph_placeholder_next); final TextView monthYearDisplayed = (TextView) this.layout .findViewById(R.id.tile_status_wan_monthly_month_displayed); final View[] ctrlViews = new View[] { monthYearDisplayed, displayButton, currentButton, previousButton, nextButton }; if (exception == null) { errorPlaceHolderView.setVisibility(View.GONE); final String currentMonthYearAlreadyDisplayed = monthYearDisplayed.getText().toString(); final Date currentDate = new Date(); final String currentMonthYear = (isNullOrEmpty(currentMonthYearAlreadyDisplayed) ? SIMPLE_DATE_FORMAT.format(currentDate) : currentMonthYearAlreadyDisplayed); //TODO Load last value from preferences monthYearDisplayed.setText(currentMonthYear); displayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Intent intent = WANMonthlyTrafficTile.this .renderTraffDateForMonth(monthYearDisplayed.getText().toString()); if (intent == null) { Toast.makeText(WANMonthlyTrafficTile.this.mParentFragmentActivity, String.format("No traffic data for '%s'", monthYearDisplayed.getText()), Toast.LENGTH_SHORT).show(); } else { final AlertDialog alertDialog = Utils.buildAlertDialog(mParentFragmentActivity, null, String.format("Loading traffic data for '%s'", monthYearDisplayed.getText()), false, false); alertDialog.show(); ((TextView) alertDialog.findViewById(android.R.id.message)) .setGravity(Gravity.CENTER_HORIZONTAL); new Handler().postDelayed(new Runnable() { @Override public void run() { WANMonthlyTrafficTile.this.mParentFragmentActivity.startActivity(intent); alertDialog.cancel(); } }, 2500); } } }); currentButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { monthYearDisplayed.setText(SIMPLE_DATE_FORMAT.format(currentDate)); } }); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final int[] currentYearMonth = getCurrentYearAndMonth(currentDate, monthYearDisplayed.getText().toString()); if (currentYearMonth.length < 2) { return; } final int currentMonth = currentYearMonth[1]; final int currentYear = currentYearMonth[0]; final int previousMonth = currentMonth - 1; final String previousMonthYear = ((previousMonth <= 0) ? ("12-" + (currentYear - 1)) : (((previousMonth <= 9) ? ("0" + previousMonth) : previousMonth) + "-" + currentYear)); monthYearDisplayed.setText(previousMonthYear); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final int[] currentYearMonth = getCurrentYearAndMonth(currentDate, monthYearDisplayed.getText().toString()); if (currentYearMonth.length < 2) { return; } final int currentMonth = currentYearMonth[1]; final int currentYear = currentYearMonth[0]; final int nextMonth = currentMonth + 1; final String nextMonthYear = ((nextMonth >= 13) ? ("01-" + (currentYear + 1)) : (((nextMonth <= 9) ? ("0" + nextMonth) : nextMonth) + "-" + currentYear)); monthYearDisplayed.setText(nextMonthYear); } }); setVisibility(ctrlViews, View.VISIBLE); } if (exception != null && !(exception instanceof DDWRTTileAutoRefreshNotAllowedException)) { //noinspection ThrowableResultOfMethodCallIgnored final Throwable rootCause = Throwables.getRootCause(exception); errorPlaceHolderView.setText("Error: " + (rootCause != null ? rootCause.getMessage() : "null")); final Context parentContext = this.mParentFragmentActivity; errorPlaceHolderView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { //noinspection ThrowableResultOfMethodCallIgnored if (rootCause != null) { Toast.makeText(parentContext, rootCause.getMessage(), Toast.LENGTH_LONG).show(); } } }); errorPlaceHolderView.setVisibility(View.VISIBLE); setVisibility(ctrlViews, View.GONE); } else { if (traffData == null || traffData.isEmpty()) { errorPlaceHolderView.setText("Error: No Data!"); errorPlaceHolderView.setVisibility(View.VISIBLE); setVisibility(ctrlViews, View.GONE); } } doneWithLoaderInstance(this, loader, R.id.tile_status_wan_monthly_traffic_togglebutton_title, R.id.tile_status_wan_monthly_traffic_togglebutton_separator); Log.d(LOG_TAG, "onLoadFinished(): done loading!"); }
From source file:abanoubm.dayra.main.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { if (Utility.getArabicLang(getApplicationContext()) == 1) { Utility.setArabicLang(getApplicationContext(), 2); Locale myLocale = new Locale("ar"); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale;//from w ww . ja va 2 s. com res.updateConfiguration(conf, dm); finish(); startActivity(new Intent(getIntent())); } super.onCreate(savedInstanceState); setContentView(R.layout.act_main); ((TextView) findViewById(R.id.subhead1)).setText(R.string.app_name); ((TextView) findViewById(R.id.subhead2)).setText(BuildConfig.VERSION_NAME); findViewById(R.id.nav_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ((TextView) findViewById(R.id.footer)).setText("dayra " + BuildConfig.VERSION_NAME + " @" + new SimpleDateFormat("yyyy", Locale.getDefault()).format(new Date()) + " Abanoub M."); if (!Utility.getDayraName(getApplicationContext()).equals("")) { startActivity(new Intent(getApplicationContext(), Home.class)); finish(); } ListView lv = (ListView) findViewById(R.id.home_list); mMenuItemAdapter = new MenuItemAdapter(getApplicationContext(), new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.sign_menu))), 1); lv.setAdapter(mMenuItemAdapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: sign(); break; case 1: register(); break; case 2: if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { importDB(); } else { ActivityCompat.requestPermissions(Main.this, new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, IMPORT_REQUEST); } break; case 3: startActivity(new Intent(Intent.ACTION_VIEW).setData( Uri.parse("https://drive.google.com/file/d/0B1rNCm5K9cvwVXJTTzNqSFdrVk0/view"))); break; case 4: startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse( "https://drive.google.com/open?id=1flSRdoiIT_hNd96Kxz3Ww3EhXDLZ45FhwFJ2hF9vl7g"))); break; case 5: { AlertDialog.Builder builder = new AlertDialog.Builder(Main.this); builder.setTitle(R.string.label_choose_language); builder.setItems(getResources().getStringArray(R.array.language_menu), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String temp; if (which == 1) { temp = "en"; Utility.setArabicLang(getApplicationContext(), 0); } else { temp = "ar"; Utility.setArabicLang(getApplicationContext(), 2); } Locale myLocale = new Locale(temp); Resources res = getResources(); DisplayMetrics dm = res.getDisplayMetrics(); Configuration conf = res.getConfiguration(); conf.locale = myLocale; res.updateConfiguration(conf, dm); finish(); startActivity(new Intent(getIntent())); } }); builder.create().show(); } break; case 6: try { getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/453595434816965")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/dayraapp")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } break; case 7: try { getPackageManager().getPackageInfo("com.facebook.katana", 0); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/1363784786")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } catch (Exception e) { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/EngineeroBono")) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } break; case 8: Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(goToMarket); } catch (Exception e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + getPackageName()))); } break; case 9: if (Build.VERSION.SDK_INT < 23 || ContextCompat.checkSelfPermission(Main.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { Intent intent = new Intent(Intent.ACTION_VIEW).addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.setDataAndType(Uri.fromFile(new File(Utility.getDayraFolder())), "*/*"); startActivity( intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)); } else { ActivityCompat.requestPermissions(Main.this, new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, FOLDER_REQUEST); } break; case 10: LayoutInflater li = LayoutInflater.from(getApplicationContext()); final View aboutView = li.inflate(R.layout.dialogue_about, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(aboutView, 0, 0, 0, 0); ad.show(); ((TextView) aboutView.findViewById(R.id.about)) .setText(String.format(getResources().getString(R.string.copyright), Calendar.getInstance().get(Calendar.YEAR))); ((TextView) aboutView.findViewById(R.id.notice)).setText(GoogleApiAvailability.getInstance() .getOpenSourceSoftwareLicenseInfo(getApplicationContext())); aboutView.findViewById(R.id.btn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ad.cancel(); } }); break; } } }); }
From source file:com.projecty.sleepgroundbox.activity.HomeActivity.java
@Override public void onBackPressed() { int num = getSupportFragmentManager().getBackStackEntryCount(); if (num <= 1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { int[] colors = new int[] { 0xffffffff, 0xffa8a8a8, 0xff404040, 0xff404040, 0xffdfdfdf }; _amanager.showAdDialog("", "?", "App ? ? ?", colors, new AdlibDialogAdListener() { @Override public void onLeftClicked() { }/* w ww . j a v a 2 s . c o m*/ @Override public void onRightClicked() { HomeActivity.this.finish(); } }); } else { AlertDialog dialog; dialog = new AlertDialog.Builder(this) // .setIcon(R.drawable.warning) .setMessage("?") .setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub //dialog.dismiss(); finish(); } }).setNegativeButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.cancel(); } }).show(); } } else { FragmentManager.BackStackEntry topFr = getSupportFragmentManager().getBackStackEntryAt(num - 2); String name = topFr.getName(); backStack(name); getSupportFragmentManager().popBackStackImmediate(); } }
From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) { if (resultCode == RESULT_OK) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(HomeFragmentActivity.this).create(); alertDialog.show();/* w w w . ja va 2 s .co m*/ handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 5000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); FragmentManager fragmentManager = getSupportFragmentManager(); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); // if (videoFragment == null) { VideoFragment newVideoFragment = new VideoFragment(); newVideoFragment.addItem(fileUriString); } else { videoFragment.addItem(fileUriString); } alertDialog.cancel(); } }, 5000); } else if (resultCode == RESULT_CANCELED) { // User cancelled the video capture } else { // Video capture failed, advise user } } else if (requestCode == MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { if (resultCode == RESULT_OK) { sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, fileUri)); final AlertDialog alertDialog = MediaChooserConstants.getDialog(HomeFragmentActivity.this).create(); alertDialog.show(); handler.postDelayed(new Runnable() { @Override public void run() { //Do something after 5000ms String fileUriString = fileUri.toString().replaceFirst("file:///", "/").trim(); FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); if (imageFragment == null) { ImageFragment newImageFragment = new ImageFragment(); newImageFragment.addItem(fileUriString); } else { imageFragment.addItem(fileUriString); } alertDialog.cancel(); } }, 5000); } } }