Java Code Examples for android.widget.Toast#makeText()

The following examples show how to use android.widget.Toast#makeText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConversationActivity.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
  if (menu == null) {
    return super.onMenuOpened(featureId, null);
  }

  if (!SignalStore.uiHints().hasSeenGroupSettingsMenuToast()) {
    MenuItem settingsMenuItem = menu.findItem(R.id.menu_group_settings);

    if (settingsMenuItem != null && settingsMenuItem.isVisible()) {
      Toast toast = Toast.makeText(this, R.string.ConversationActivity__more_options_now_in_group_settings, Toast.LENGTH_SHORT);

      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();

      SignalStore.uiHints().markHasSeenGroupSettingsMenuToast();
    }
  }

  return super.onMenuOpened(featureId, menu);
}
 
Example 2
Source File: wlflActivity.java    From stynico with MIT License 6 votes vote down vote up
public void ShowToast(String text)
   {
       if (!TextUtils.isEmpty(text))
{
           try
    {
               if (mToast == null)
	{
                   mToast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
               }
	else
	{
                   mToast.setText(text);
               }
               mToast.show();
           }
    catch (Exception e)
    {
               e.printStackTrace();
           }
       }
   }
 
Example 3
Source File: FileDisplayActivity.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates the view associated to the activity after the finish of an operation trying to copy a
 * file.
 *
 * @param operation Copy operation performed.
 * @param result    Result of the copy operation.
 */
private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperationResult result) {
    if (result.isSuccess()) {
        dismissLoadingDialog();
        refreshListOfFilesFragment();
    } else {
        dismissLoadingDialog();
        try {
            Toast msg = Toast.makeText(FileDisplayActivity.this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message ", e);
        }
    }
}
 
Example 4
Source File: ToastUtil.java    From QrScan with Apache License 2.0 6 votes vote down vote up
public static void showToast(Context context, String message, int duration, int gravity, int xOffset, int yOffset) {
    if (message == null){
        return;
    }

    if (sToast == null) {
        sToast = Toast.makeText(context, "", duration);
    } else {
        sToast.cancel();
        sToast = Toast.makeText(context, "", duration);
    }
    sToast.setText(message);
    sToast.setDuration(duration);
    sToast.setGravity(gravity, xOffset, yOffset);
    sToast.show();
}
 
Example 5
Source File: CubeFragmentActivity.java    From cube-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * process back pressed
 */
@Override
public void onBackPressed() {

    // process back for fragment
    if (processBackPressed()) {
        return;
    }

    // process back for fragment
    boolean enableBackPressed = true;
    if (mCurrentFragment != null) {
        enableBackPressed = !mCurrentFragment.processBackPressed();
    }
    if (enableBackPressed) {
        int cnt = getSupportFragmentManager().getBackStackEntryCount();
        if (cnt <= 1 && isTaskRoot()) {
            String closeWarningHint = getCloseWarning();
            if (!mCloseWarned && !TextUtils.isEmpty(closeWarningHint)) {
                Toast toast = Toast.makeText(this, closeWarningHint, Toast.LENGTH_SHORT);
                toast.show();
                mCloseWarned = true;
            } else {
                doReturnBack();
            }
        } else {
            mCloseWarned = false;
            doReturnBack();
        }
    }
}
 
Example 6
Source File: MainActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 5 votes vote down vote up
private void listing13_26() {
  // Listing 13-26: Displaying a Toast
  Context context = this;
  String msg = "To health and happiness!";
  int duration = Toast.LENGTH_SHORT;
  Toast toast = Toast.makeText(context, msg, duration);

  // Remember, you must *always* call show()
  toast.show();
}
 
Example 7
Source File: MainActivity.java    From Stock-Hawk with Apache License 2.0 5 votes vote down vote up
@Override
public void showStockAlreadyExist() {
    Toast toast = Toast.makeText(this, getResources().getString(R.string.stocks_already_exist),
            Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, Gravity.CENTER, 0);
    toast.show();
}
 
Example 8
Source File: StickGridItemListFragment.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onHeaderClick(AdapterView<?> parent, View view, long id) {
    String text = "Header " + ((TextView)view.findViewById(android.R.id.text1)).getText() + " was tapped.";
    if (mToast == null) {
        mToast = Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT);
    } else {
        mToast.setText(text);
    }
    mToast.show();
}
 
Example 9
Source File: ToastUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 长时间显示Toast
 *
 * @param context
 * @param message
 */
public static void showLong(Context context, int message) {
    if (null == toast) {
        toast = Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_LONG);
        // toast.setGravity(Gravity.CENTER, 0, 0);
    } else {
        toast.setText(message);
    }
    toast.show();
}
 
Example 10
Source File: ToastUtil.java    From stynico with MIT License 5 votes vote down vote up
public static void show(Context context,CharSequence character,int duration){
    if(toast==null){
        toast=Toast.makeText(context,character,duration);
    }else {
        toast.setText(character);
        toast.setDuration(duration);
    }
    toast.show();
}
 
Example 11
Source File: Util.java    From AutoInteraction-Library with Apache License 2.0 5 votes vote down vote up
public static Toast showToast(Context context, int i) {

        if (mContext == context) {
            mToast.setText(i);
        } else {
            mContext = context;
            mToast = Toast.makeText(context, i, Toast.LENGTH_SHORT);
        }
        mToast.show();
        return mToast;
    }
 
Example 12
Source File: MessageActivity.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public void showToast(int resId) {
    String text = getResources().getString(resId);
    if (mToast == null) {
        mToast = Toast.makeText(MessageActivity.this, text, Toast.LENGTH_SHORT);
    } else {
        mToast.setText(text);
        mToast.setDuration(Toast.LENGTH_SHORT);
    }
    mToast.setGravity(Gravity.CENTER, 0, 0);
    mToast.show();
}
 
Example 13
Source File: WordSelectionActivity.java    From jterm-cswithandroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_word_selection);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new PathDictionary(inputStream);
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
}
 
Example 14
Source File: CameraActivity_OldAPI.java    From microbit with Apache License 2.0 5 votes vote down vote up
/**
 * Starts taking a picture countdown with playing an audio
 * and showing a text countdown for defined interval, and then takes a picture.
 */
private void startTakePicCounter() {

    playAudioPresenter.setInternalPathForPlay(InternalPaths.TAKING_PHOTO_AUDIO);
    playAudioPresenter.start();

    @SuppressLint("ShowToast") final Toast toast = Toast.makeText(MBApp.getApp().getApplicationContext(), "bbb", Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);

    //Toast.LENGTH_SHORT will keep the toast for 2s, our interval is 1s and calling toast.show()
    //after 1s will cause some count to be missed. Only call toast.show() just before 2s interval.
    //Also add delay to show the "Ready" toast.
    new CountDownTimer(Constants.PIC_COUNTER_DURATION_MILLIS, Constants.PIC_COUNTER_INTERVAL_MILLIS) {

        public void onTick(long millisUntilFinished) {
            int count = (int) millisUntilFinished / Constants.PIC_COUNTER_INTERVAL_MILLIS;
            toast.setText("Ready in... " + count);
            if(count % 2 != 0)
                toast.show();
        }

        public void onFinish() {
            toast.setText("Ready");
            toast.show();
            mButtonClick.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mButtonClick.callOnClick();
                }

            }, 200);
        }
    }.start();
}
 
Example 15
Source File: RxGetActivity.java    From EasyHttp with Apache License 2.0 4 votes vote down vote up
@OnClick(R.id.go)
public void go() {
    Editable url = urlView.getText();

    if (TextUtils.isEmpty(url)) {
        Toast.makeText(this, "url is empty", Toast.LENGTH_SHORT);
        return;
    }

    RxEasyHttp.get(url.toString(), new RxEasyStringConverter())
            .doOnSubscribe(new Consumer<Subscription>() {
                @Override
                public void accept(@NonNull Subscription subscription) throws Exception {
                    dialog.show();
                    body.setText("");
                }
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new FlowableSubscriber<String>() {
                @Override
                public void onSubscribe(Subscription s) {
                    s.request(Long.MAX_VALUE);
                    dialog.show();
                    body.setText("");
                }

                @Override
                public void onNext(String response) {
                    body.setText(response);
                }

                @Override
                public void onError(Throwable t) {
                    body.setText(t.toString());
                }

                @Override
                public void onComplete() {
                    dialog.cancel();
                }
            });
}
 
Example 16
Source File: HUDView.java    From scrog with Apache License 2.0 4 votes vote down vote up
private void init(){
    TapDetector tapDetector = new TapDetector(mPaint, this, colMan);
    mDetector = new GestureDetector(mContext, tapDetector);
    Toast toast = Toast.makeText(mContext, "You may double tap, move or resize info window", Toast.LENGTH_LONG);
    toast.show();
}
 
Example 17
Source File: BigScreenDemo.java    From LoyalNativeSlider with MIT License 4 votes vote down vote up
@Override
public void onSliderClick(BaseSliderView coreSlider) {
    Toast.makeText(this, "Clicked Item", Toast.LENGTH_SHORT);
}
 
Example 18
Source File: MainActivity.java    From ud867 with MIT License 3 votes vote down vote up
public void tellJoke(View view) {

        Context context = this;
        CharSequence text = this.getString(R.string.toast_text);
        int duration = Toast.LENGTH_LONG;

        Toast toast = Toast.makeText(context, text, duration);
        toast.show();


    }
 
Example 19
Source File: Boast.java    From RetailStore with Apache License 2.0 2 votes vote down vote up
/**
 * Make a standard {@link Boast} that just contains a text view with the
 * text from a resource.
 *
 * @param context  The context to use. Usually your {@link android.app.Application}
 *                 or {@link android.app.Activity} object.
 * @param resId    The resource id of the string resource to use. Can be formatted
 *                 text.
 * @param duration How long to display the message. Either {@link //LENGTH_SHORT} or
 *                 {@link //LENGTH_LONG}
 * @throws Resources.NotFoundException if the resource can't be found.
 */
@SuppressLint("ShowToast")
public static Boast makeText(Context context, int resId, int duration)
        throws Resources.NotFoundException {
    return new Boast(Toast.makeText(context, resId, duration));
}
 
Example 20
Source File: MainPresenter.java    From Android-Architecture-Fairy with Apache License 2.0 2 votes vote down vote up
/**
 * Creat a Toast object with given message
 * @param msg   Toast message
 * @return      A Toast object
 */
private Toast makeToast(String msg) {
    return Toast.makeText(getView().getAppContext(), msg, Toast.LENGTH_SHORT);
}