Java Code Examples for android.widget.Toast.cancel()

The following are Jave code examples for showing how to use cancel() of the android.widget.Toast class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.

+ Save this method
Example 1
Project: Tofu-Notes-master View Source Vote up 6 votes
private static void clean() {
	Iterator<Toast> i = toasts.iterator();
	while(i.hasNext()) {
		Toast t = i.next();
		t.cancel();
	}
	
	toasts = new ArrayList<Toast>();
}
 
Example 2
Project: FasterGallery-master View Source Vote up 6 votes
private void hideEmptyAlbumToast() {
	if (mEmptyAlbumToast != null) {
		Toast toast = mEmptyAlbumToast.get();
		if (toast != null)
			toast.cancel();
	}
}
 
Example 3
Project: O2OMobile_Android-master View Source Vote up 6 votes
public ToastView(Context context, String text) {
	LayoutInflater inflater = LayoutInflater.from(context);
	View view = inflater.inflate(R.layout.toast_view, null);
	TextView t = (TextView) view.findViewById(R.id.toast_text);
	t.setText(text);
	if(toast != null) {
		toast.cancel();
	}
	toast = new Toast(context);
	toast.setDuration(Toast.LENGTH_SHORT);
	toast.setView(view);
}
 
Example 4
Project: MUtils-master View Source Vote up 6 votes
public static void toast(IToastOwner owner, CharSequence s) {
	if (!isEnabled(owner)) {
		return;
	}
	Toast t = owner.getToast();
	if (s == null) {
		t.cancel();
	} else {
		if (s.equals("")) {
			t.cancel();
		} else {
			t.setText(s);
			t.show();
		}
	}
}
 
Example 5
Project: managed_toast-master View Source Vote up 6 votes
/**
 * Cancels currently showing ManagedToast and remove all ManagedToasts from the queue
 */
public static void cancelAll() {
    Iterator<Toast> i = sToasts.iterator();
    while (i.hasNext()) {
        Toast toast = i.next();
        if (toast != null) toast.cancel();
        i.remove();
    }
}
 
Example 6
Project: z-validations-master View Source Vote up 6 votes
@Override
public void clear() {
    for (Toast toast : mToasts) {
        toast.cancel();
    }
    mToasts.clear();
}
 
Example 7
Project: Android-IMSI-Catcher-Detector-master View Source Vote up 6 votes
/**
 * Exit application if Back button is pressed twice
 */
@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.e(TAG, "Error: Stopping SMS detection : " + ee.getMessage());
        }
        // Close database on Exit
        Log.i(TAG, "Closing db from onBackPressed()");
        new AIMSICDDbAdapter(getApplicationContext()).close();
        finish();
    }
}
 
Example 8
Project: ECMobile_Android-master View Source Vote up 6 votes
public ToastView(Context context, String text) {
	LayoutInflater inflater = LayoutInflater.from(context);
	View view = inflater.inflate(R.layout.toast_view, null);
	TextView t = (TextView) view.findViewById(R.id.toast_text);
	t.setText(text);
	if(toast != null) {
		toast.cancel();
	}
	toast = new Toast(context);
	toast.setDuration(Toast.LENGTH_SHORT);
	toast.setView(view);
}
 
Example 9
Project: WiFi_Connect-master View Source Vote up 6 votes
public void displayToastMessage(String message) {
	if (message == null || "".equals(message))
		return;

	if (!isMainThread()) {
		Message msg = new Message();
		msg.obj = message;
		ServalBatPhoneApplication.this.displayMessageHandler.sendMessage(msg);
		return;
	}

	if (toast != null)
		toast.cancel();

	LayoutInflater li = LayoutInflater.from(this);
	View layout = li.inflate(R.layout.toastview, null);
	toast = new Toast(getApplicationContext());
	toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
	toast.setDuration(Toast.LENGTH_LONG);
	toast.setView(layout);

	TextView text = (TextView) toast.getView().findViewById(R.id.toastText);
	text.setText(message);
	toast.show();
}
 
Example 10
Project: BeeFramework_Android-master View Source Vote up 6 votes
public ToastView(Context context, String text) {
	LayoutInflater inflater = LayoutInflater.from(context);
	View view = inflater.inflate(R.layout.taost_view, null);
	TextView t = (TextView) view.findViewById(R.id.toast_text);
	t.setText(text);
	if(toast != null) {
		toast.cancel();
	}
	toast = new Toast(context);
	toast.setDuration(Toast.LENGTH_SHORT);
	toast.setView(view);
}
 
Example 11
Project: LandousApp-master View Source Vote up 6 votes
public ToastView(Context context, String text) {
	LayoutInflater inflater = LayoutInflater.from(context);
	View view = inflater.inflate(R.layout.taost_view, null);
	TextView t = (TextView) view.findViewById(R.id.toast_text);
	t.setText(text);
	if(toast != null) {
		toast.cancel();
	}
	toast = new Toast(context);
	toast.setDuration(Toast.LENGTH_SHORT);
	toast.setView(view);
}