Example usage for android.widget Toast cancel

List of usage examples for android.widget Toast cancel

Introduction

In this page you can find the example usage for android.widget Toast cancel.

Prototype

public void cancel() 

Source Link

Document

Close the view if it's showing, or don't show it if it isn't showing yet.

Usage

From source file:com.filemanager.free.utils.MainActivityHelper.java

public void rename(int mode, String f, String f1, final Activity context, boolean rootmode) {
    final Toast toast = Toast.makeText(context, R.string.renaming, Toast.LENGTH_LONG);
    toast.show();//from w  ww . j  a  v a 2s . c om
    Operations.rename(new HFile(mode, f), new HFile(mode, f1), rootmode, context,
            new Operations.ErrorCallBack() {
                @Override
                public void exists(HFile file) {
                    context.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (toast != null)
                                toast.cancel();
                            Toast.makeText(mainActivity, (R.string.fileexist), Toast.LENGTH_SHORT).show();
                        }
                    });
                }

                @Override
                public void launchSAF(HFile file) {

                }

                @Override
                public void launchSAF(final HFile file, final HFile file1) {
                    context.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (toast != null)
                                toast.cancel();
                            mainActivity.oppathe = file.getPath();
                            mainActivity.oppathe1 = file1.getPath();
                            mainActivity.operation = DataUtils.RENAME;
                            guideDialogForLEXA(mainActivity.oppathe1);
                        }
                    });
                }

                @Override
                public void done(HFile hFile, final boolean b) {
                    context.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (toast != null)
                                toast.cancel();
                            if (b) {
                                Intent intent = new Intent("loadlist");
                                mainActivity.sendBroadcast(intent);
                            } else
                                Toast.makeText(context, R.string.operationunsuccesful, Toast.LENGTH_SHORT)
                                        .show();

                        }
                    });
                }
            });
}

From source file:com.example.android.recyclingbanks.MainActivity.java

public void onClick(View view) {
    int buttonId = view.getId();
    String toastText = (String) view.getTag();
    Boolean activated = buttonActivationMap.get(buttonId);

    //change button state
    activated = !activated;/*from  www .jav a 2s .  c o m*/
    buttonActivationMap.put(buttonId, activated);

    if (activated == true) {
        // turning button on
        setButtonColor(buttonId, BUTTONonCOLOR);
    } else {
        // turning button off
        toastText = "Hiding " + toastText;
        setButtonColor(buttonId, BUTTONoffCOLOR);
    }
    // show toast, funkiness to make 650 milli secs
    final Toast toast = Toast.makeText(getApplicationContext(), toastText, Toast.LENGTH_SHORT);
    toast.show();
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            toast.cancel();
        }
    }, 650);

    // hide or show banks on map
    // TODO make asyncTask possibly.
    // TODO this isn't filtering CombinedBanks properly
    switch (buttonId) {
    case R.id.packagingBanks:
        // filter combinedBanks
        hideOrShowCombinedBanks(activated, 0);

        if (mPackagingBankMarkers.isEmpty()) {
            // if haven't already loaded the markers do so and display them
            mPackagingBankMarkers = addBankListToMap(mPackagingBanks);
            break;
        }
        // the markers HAVE been loaded, so flip their visibility
        hideOrShowBanks(mPackagingBankMarkers, activated);
        break;
    case R.id.paperBanks:
        hideOrShowCombinedBanks(activated, 1);
        if (mPaperBankMarkers.isEmpty()) {
            mPaperBankMarkers = addBankListToMap(mPaperBanks);
            break;
        }
        Log.e("onClick", "num pure paper banks? " + Integer.toString(mPaperBankMarkers.size()));
        hideOrShowBanks(mPaperBankMarkers, activated);
        break;
    case R.id.textileBanks:
        hideOrShowCombinedBanks(activated, 2);
        if (mTextileBankMarkers.isEmpty()) {
            mTextileBankMarkers = addBankListToMap(mTextileBanks);
            break;
        }
        hideOrShowBanks(mTextileBankMarkers, activated);
        return;
    case R.id.bottleBanks:
        hideOrShowCombinedBanks(activated, 3);
        if (mBottleBankMarkers.isEmpty()) {
            mBottleBankMarkers = addBankListToMap(mBottleBanks);
            break;
        }
        hideOrShowBanks(mBottleBankMarkers, activated);
        break;
    case R.id.cansBooksFoodBins:
        hideOrShowCombinedBanks(activated, 4);
        if (mOtherBankMarkers.isEmpty()) {
            mOtherBankMarkers = addBankListToMap(mOthers);
            break;
        }
        hideOrShowBanks(mOtherBankMarkers, activated);
        break;
    }
    return;
}

From source file:com.lewa.crazychapter11.MainActivity.java

private void showTost(String content, int tostLength) {
    Toast mToast;
    if (mToastReference != null) {
        mToast = mToastReference.get();/*from   w  w w .  j a v a 2 s .  c  o  m*/
        if (mToast != null) {
            mToast.cancel();
            mToastReference = null;
        }
    }
    mToast = Toast.makeText(MainActivity.this, content, tostLength);
    mToastReference = new WeakReference<Toast>(mToast);
    mToast.show();
}

From source file:com.bookkos.bircle.CaptureActivity.java

private void customToast(String toast_text, int icon, boolean bool) {
    getLayoutInflater();/*from   www. j  a  v a  2  s.c o m*/
    LayoutInflater inflater = getLayoutInflater();

    int resource = 0;

    if (bool == true) {
        resource = R.layout.success_toast;
    } else {
        resource = R.layout.failure_toast;
    }

    View layout = inflater.inflate(resource, null);
    ImageView image = (ImageView) layout.findViewById(R.id.image);
    image.setImageResource(icon);

    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(Html.fromHtml(toast_text));

    final Toast toast = new Toast(this);

    layout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            toast.cancel();
        }
    });

    toast.setView(layout);
    toast.setGravity(Gravity.CENTER, 0, 0);
    if (modeFlag == true) {
        toast.setDuration(Toast.LENGTH_SHORT);
    } else {
        toast.setDuration(Toast.LENGTH_LONG);
    }
    toast.show();

    //      Toast.makeText(context, toast_text, Toast.LENGTH_SHORT).show();
}

From source file:com.yaniv.online.MainActivity.java

private void displayToastForLimitTime(String message, long time) {
    Log.d(TAG, "displayToastForLimitTime() mes:" + message + " time:" + time);

    final Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT);
    toast.show();/*  w w  w  . ja  v a 2 s.c o  m*/

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            toast.cancel();
        }
    }, time);
}