List of usage examples for android.widget Toast cancel
public void cancel()
From source file:Main.java
public static void hideToast() { if (sToastRef != null) { Toast previousToast = sToastRef.get(); if (previousToast != null) { previousToast.cancel(); }//from w ww . j av a 2 s. co m } }
From source file:com.pdftron.pdf.utils.Utils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static Toast showToast(Context context, Toast toast, String text, int duration) { if (toast != null) { toast.cancel(); }//ww w . j a va 2 s .c o m toast = Toast.makeText(context, text, duration); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); } toast.show(); return toast; }
From source file:com.pdftron.pdf.utils.Utils.java
public static Toast showToast(Context context, Toast toast, int stringId, int duration) { if (toast != null) { toast.cancel(); }/*from www . j a va 2 s . c o m*/ toast = Toast.makeText(context, stringId, duration); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); } toast.show(); return toast; }
From source file:info.guardianproject.iocipher.camera.StillCameraActivity.java
private void notifyUserImageWasSavedSuccessfully() { final Toast toast = Toast.makeText(getApplicationContext(), "image saved successfully!", Toast.LENGTH_SHORT);//from w ww. ja va 2 s .c o m toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); final int DURATION = 500; new CountDownTimer(DURATION, DURATION) { public void onTick(long millisUntilFinished) { toast.show(); } public void onFinish() { toast.cancel(); } }.start(); }
From source file:com.areebbeigh.qrcodeutility.BaseActivity.java
@Override public void onBackPressed() { Toast t = Toast.makeText(this, R.string.backpress_hint, Toast.LENGTH_SHORT); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer != null && drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else {//w w w.ja v a 2 s. com if (shouldIgnoreBackStack()) { if (System.currentTimeMillis() - onRecentBackPressedTime > 2000) { onRecentBackPressedTime = System.currentTimeMillis(); t.show(); return; } } super.onBackPressed(); t.cancel(); } }
From source file:org.creativecommons.thelist.activities.RandomActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_random); mContext = this; mRequestMethods = new RequestMethods(mContext); mSharedPref = new SharedPreferencesMethods(mContext); mMessageHelper = new MessageHelper(mContext); mCurrentUser = new ListUser(RandomActivity.this); //Google Analytics Tracker ((ListApplication) getApplication()).getTracker(ListApplication.TrackerName.GLOBAL_TRACKER); mItemList = new ArrayList<>(); //UI Elements mBackground = (RelativeLayout) findViewById(R.id.random_item_background); mTextView = (TextView) findViewById(R.id.random_item_text); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mDoneButton = (Button) findViewById(R.id.doneButton); mYesButton = (ImageButton) findViewById(R.id.YesButton); mNoButton = (ImageButton) findViewById(R.id.NoButton); //ImageButton CameraButton = (ImageButton) findViewById(R.id.CameraButton); mRequestMethods.getRandomItems(new RequestMethods.ResponseCallback() { @Override//from w w w. ja v a 2s. c om public void onSuccess(JSONArray response) { Log.v(TAG, "> getRandomListItems > onSuccess: " + response); mRandomItemData = response; updateView(); } @Override public void onFail(VolleyError error) { Log.d(TAG, "> getRandomListItems > onFail: " + error.getMessage()); mMessageHelper.noItemsFound(); //TODO: Take user elsewhere if items dont load } }); //Add list item to my list mYesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Add items to ItemList MainListItem listItem = new MainListItem(); listItem.setItemID(mItemID); listItem.setItemName(mItemName); listItem.setMakerName(mMakerName); listItem.setCategoryID(mCategoryID); mItemList.add(listItem); //Toast: Confirm List Item has been added //TODO: add this to addItemToUserList callback final Toast toast = Toast.makeText(RandomActivity.this, "Added to Your List", Toast.LENGTH_SHORT); toast.show(); new android.os.Handler().postDelayed(new Runnable() { @Override public void run() { toast.cancel(); } }, 1000); //If logged in, add item to users list right away if (!(mCurrentUser.isTempUser())) { Log.v(TAG, "> isTempUser, user is logged in"); mCurrentUser.addItemToUserList(mItemID); } //Display a new item updateView(); //show doneButton if user has selected at least 3 items if (mItemList.size() == 1) { //once it has 3 items mDoneButton.setVisibility(View.VISIBLE); } } //OnClick }); //YesButton.setOnClickListener //Decline adding list item to my list mNoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateView(); if (itemPositionCount >= 1 && mDoneButton.getVisibility() == View.INVISIBLE) { mDoneButton.setVisibility(View.VISIBLE); } } }); //Im done with picking items mDoneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Get array of selected item IDS if (mCurrentUser.isTempUser()) { saveTempUserItems(); } //Clear ItemList mItemList.clear(); Intent intent = new Intent(mContext, DrawerActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); //Done Button }
From source file:com.secupwn.aimsicd.ui.activities.MainActivity.java
/** * Exit application if Back button is pressed twice *///from w ww . jav a2 s .c om @Override public void onBackPressed() { Toast onBackPressedToast = Toast.makeText(this, R.string.press_once_again_to_exit, Toast.LENGTH_SHORT); long currentTime = System.currentTimeMillis(); if (currentTime - mLastPress > 5000) { onBackPressedToast.show(); mLastPress = currentTime; } else { onBackPressedToast.cancel(); super.onBackPressed(); try { if (mAimsicdService.isSmsTracking()) { mAimsicdService.stopSmsTracking(); } } catch (Exception ee) { log.error("Error: Stopping SMS detection : " + ee.getMessage()); } finish(); } }
From source file:com.SecUpwN.AIMSICD.AIMSICD.java
/** * Exit application if Back button is pressed twice *///w w w .j a v a2 s . c o m @Override public void onBackPressed() { Toast onBackPressedToast = Toast.makeText(this, R.string.press_once_again_to_exit, Toast.LENGTH_SHORT); long currentTime = System.currentTimeMillis(); if (currentTime - mLastPress > 5000) { onBackPressedToast.show(); mLastPress = currentTime; } else { onBackPressedToast.cancel(); super.onBackPressed(); finish(); } }
From source file:com.filemanager.free.utils.MainActivityHelper.java
public void mkFile(final HFile path, final Main ma) { final Toast toast = Toast.makeText(ma.getActivity(), R.string.creatingfile, Toast.LENGTH_LONG); toast.show();//from ww w. j a va 2s.co m Operations.mkfile(path, ma.getActivity(), ma.ROOT_MODE, new Operations.ErrorCallBack() { @Override public void exists(final HFile file) { ma.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (toast != null) toast.cancel(); Toast.makeText(mainActivity, (R.string.fileexist), Toast.LENGTH_SHORT).show(); if (ma != null && ma.getActivity() != null) mkfile(file.getMode(), file.getPath(), ma); } }); } @Override public void launchSAF(HFile file) { ma.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (toast != null) toast.cancel(); mainActivity.oppathe = path.getPath(); mainActivity.operation = DataUtils.NEW_FOLDER; guideDialogForLEXA(mainActivity.oppathe); } }); } @Override public void launchSAF(HFile file, HFile file1) { } @Override public void done(HFile hFile, final boolean b) { ma.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (toast != null) toast.cancel(); if (b) { ma.updateList(); } else Toast.makeText(ma.getActivity(), "Operation Failed", Toast.LENGTH_SHORT).show(); } }); } }); }
From source file:com.filemanager.free.utils.MainActivityHelper.java
public void mkDir(final HFile path, final Main ma) { final Toast toast = Toast.makeText(ma.getActivity(), R.string.creatingfolder, Toast.LENGTH_LONG); toast.show();//from w w w . j a v a2 s .c o m Operations.mkdir(path, ma.getActivity(), ma.ROOT_MODE, new Operations.ErrorCallBack() { @Override public void exists(final HFile file) { ma.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (toast != null) toast.cancel(); Toast.makeText(mainActivity, (R.string.fileexist), Toast.LENGTH_SHORT).show(); if (ma != null && ma.getActivity() != null) mkdir(file.getMode(), file.getPath(), ma); } }); } @Override public void launchSAF(HFile file) { if (toast != null) toast.cancel(); ma.getActivity().runOnUiThread(new Runnable() { @Override public void run() { mainActivity.oppathe = path.getPath(); mainActivity.operation = DataUtils.NEW_FOLDER; guideDialogForLEXA(mainActivity.oppathe); } }); } @Override public void launchSAF(HFile file, HFile file1) { } @Override public void done(HFile hFile, final boolean b) { ma.getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (toast != null) toast.cancel(); if (b) { ma.updateList(); } else Toast.makeText(ma.getActivity(), R.string.operationunsuccesful, Toast.LENGTH_SHORT) .show(); } }); } }); }