Android Open Source - mclib Toast Helper






From Project

Back to project page mclib.

License

The source code is released under:

Apache License, Version 2.0 FoundationProjectsPeopleGet InvolvedDownloadSupport ApacheHome ? Licenses Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITION...

If you think the Android project mclib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
   Copyright 2012 Mikhail Chabanov/*from ww w . ja v a  2s  .  c  o m*/

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package mc.lib.io;

import mc.lib.screen.ScreenHelper;
import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;

public class ToastHelper
{
    public static int TOAST_LENGTH = Toast.LENGTH_LONG;

    /**
     * Show toast.
     * 
     * @param context
     * @param strResId
     *            text string id.
     */
    public static Toast showToastCenter(Context context, int strResId)
    {
        return showToast(context, context.getString(strResId), Gravity.CENTER_VERTICAL, 0, 0);
    }

    /**
     * Show toast.
     * 
     * @param context
     * @param text
     */
    public static Toast showToastCenter(Context context, String text)
    {
        return showToast(context, text, Gravity.CENTER_VERTICAL, 0, 0);
    }

    /**
     * Show toast.
     * 
     * @param context
     * @param strResId
     *            text string id.
     */
    public static Toast showToastTop(Context context, int strResId)
    {
        return showToastTop(context, context.getString(strResId));
    }

    /**
     * Show toast.
     * 
     * @param context
     * @param text
     */
    public static Toast showToastTop(Context context, String text)
    {
        int y = (int)(ScreenHelper.getHeight(context) * .1f);
        return showToast(context, text, Gravity.TOP, 0, y);
    }

    /**
     * Show toast.
     * 
     * @param context
     * @param strResId
     *            text string id.
     */
    public static Toast showToast(Context context, int strResId)
    {
        Toast t = Toast.makeText(context, strResId, TOAST_LENGTH);
        t.show();
        return t;
    }

    /**
     * Show toast.
     * 
     * @param context
     * @param text
     */
    public static Toast showToast(Context context, String text)
    {
        Toast t = Toast.makeText(context, text, TOAST_LENGTH);
        t.show();
        return t;
    }

    /**
     * Show toast with offset.
     * 
     * @param context
     * @param text
     * @param gravity
     * @param x
     *            - x offset
     * @param y
     *            - y offset
     * @return the toast
     */
    public static Toast showToast(Context context, String text, int gravity, int x, int y)
    {
        Toast t = Toast.makeText(context.getApplicationContext(), text, TOAST_LENGTH);
        t.setGravity(gravity, x, y);
        t.show();
        return t;
    }
}




Java Source Code List

mc.lib.archives.ArchivesHelper.java
mc.lib.assets.AssetsHelper.java
mc.lib.audio.AudioSource.java
mc.lib.audio.IAudioPlayer.java
mc.lib.audio.MediaAudioPlayer.java
mc.lib.files.FileHelper.java
mc.lib.files.FileReadingHelper.java
mc.lib.files.PermissionHelper.java
mc.lib.identity.IdentityHelper.java
mc.lib.image.BitmapTools.java
mc.lib.image.ImageHelper.java
mc.lib.image.InputStreamFullSkip.java
mc.lib.interfaces.OnCompleteListener.java
mc.lib.interfaces.OnProgressListener.java
mc.lib.interfaces.OnStartListener.java
mc.lib.io.KeyboardHelper.java
mc.lib.io.ToastHelper.java
mc.lib.location.LocationHelper.java
mc.lib.location.OnLocationChangeListener.java
mc.lib.log.Log.java
mc.lib.network.AsyncFileDownloader.java
mc.lib.network.AsyncNetworkHelper.java
mc.lib.network.EmailHelper.java
mc.lib.network.NetworkHelper.java
mc.lib.regexp.PopularRegexp.java
mc.lib.regexp.Validator.java
mc.lib.screen.ScreenHelper.java
mc.lib.stream.AdvancedStreamHelper.java
mc.lib.stream.StreamHelper.java
mc.lib.video.BasicVideoPlayer.java
mc.lib.video.IVideoPlayer.java
mc.lib.video.VideoViewPlayer.java