List of usage examples for android.widget Toast setDuration
public void setDuration(@Duration int duration)
From source file:piuk.blockchain.android.ui.AbstractWalletActivity.java
public final void toast(final int textResId, final int imageResId, final int duration, final Object... formatArgs) { final View view = getLayoutInflater().inflate(R.layout.transient_notification, null); TextView tv = (TextView) view.findViewById(R.id.transient_notification_text); tv.setText(getString(textResId, formatArgs)); tv.setCompoundDrawablesWithIntrinsicBounds(imageResId, 0, 0, 0); final Toast toast = new Toast(this); toast.setView(view);//from w w w . j av a 2 s .co m toast.setDuration(duration); toast.show(); }
From source file:piuk.blockchain.android.ui.AbstractWalletActivity.java
public final void toast(final String text, final int imageResId, final int duration, final Object... formatArgs) { if (text == null) return;//ww w. j av a 2 s . c o m final View view = getLayoutInflater().inflate(R.layout.transient_notification, null); TextView tv = (TextView) view.findViewById(R.id.transient_notification_text); tv.setText(String.format(text, formatArgs)); tv.setCompoundDrawablesWithIntrinsicBounds(imageResId, 0, 0, 0); final Toast toast = new Toast(this); toast.setView(view); toast.setDuration(duration); toast.show(); }
From source file:com.sean.takeastand.alarmprocess.AlarmService.java
private void showPraise() { String praise = praiseForUser(); if (mainActivityVisible) { Intent intent = new Intent(Constants.PRAISE_FOR_USER); intent.putExtra("Praise", praise); LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent); } else {//from w ww. j a va 2s . co m if (Utils.getToastEnabled(this)) { LayoutInflater inflater = (LayoutInflater) getApplication() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.custom_toast, null); TextView text = (TextView) layout.findViewById(R.id.toast_text); text.setText(praise); Toast toast = new Toast(getApplicationContext()); //toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); } } }
From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java
private void showToast(int msgID, String msg, int duration) { Toast toast = new Toast(this); LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_success, (ViewGroup) findViewById(R.id.lytLayout)); TextView txtMsg = (TextView) layout.findViewById(R.id.toastMessage); if (msg == null) { txtMsg.setText(getString(msgID)); } else {/*from ww w . ja v a 2 s .c om*/ txtMsg.setText(msg); } toast.setDuration(duration); toast.setView(layout); toast.show(); }
From source file:com.netcompss.ffmpeg4android_client.BaseVideo.java
public void toastsettext(String string1) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_activity, (ViewGroup) ((Activity) context).findViewById(R.id.toast_rl)); TextView txt = (TextView) layout.findViewById(R.id.toast_txt); txt.setText(string1);/* w ww . j a v a2 s . c om*/ Toast tst = new Toast(context); tst.setGravity(Gravity.CENTER_VERTICAL, 0, 0); tst.setDuration(Toast.LENGTH_SHORT); tst.setView(layout); tst.show(); }
From source file:org.osm.keypadmapper2.KeypadMapper2Activity.java
@Override public void onResume() { super.onResume(); instance = this; Log.d(TAG, "resume"); ControllableResourceInitializerService.startResourceLoading(getApplicationContext(), "lang_support_codes", "lang_support_names", "lang_support_urls"); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mapper.addNotificationListener(this); if (KeypadMapperApplication.getInstance().getSettings().isCompassAvailable()) { sensorManager.registerListener(this, gsensor, SensorManager.SENSOR_DELAY_UI); sensorManager.registerListener(this, msensor, SensorManager.SENSOR_DELAY_UI); }//from ww w. j a v a 2 s.com locationProvider.addLocationListener(this); mapper.onResume(); menu.onResume(); satelliteInfo.onResume(); String languageToLoad = KeypadMapperApplication.getInstance().getSettings().getCurrentLanguageCode(); if (!lang.equals(languageToLoad) || uiOptimizationEnabled != KeypadMapperApplication.getInstance() .getSettings().isLayoutOptimizationEnabled()) { Intent localIntent = new Intent(this, KeypadMapper2Activity.class); Bundle data = new Bundle(); data.putInt("state", state.ordinal()); data.putBoolean("extended_address", extendedAddressActive); data.putBoolean("sat_info", satteliteInfoVisible); localIntent.putExtras(data); startActivity(localIntent); finish(); } else { updateLocale(); } if (!locationProvider.isLocationServiceEnabled()) { showDialogGpsDisabled(); } else if (gpsDialog != null) { gpsDialog.dismiss(); gpsDialog = null; } if (KeypadMapperApplication.getInstance().getSettings().isLayoutOptimizationEnabled()) { // show empty toast so that there's no problem with showing // optimized view. On some phones with Android 2.3 and maybe others, // layout isn't rendered in fullscreen and showing toast fixes it. View etv = getLayoutInflater().inflate(R.layout.empty_toast_view, null); Toast t = new Toast(getApplicationContext()); t.setView(etv); t.setDuration(1); t.show(); } RateMeActivity.startRateMe(this); }
From source file:io.plaidapp.ui.DribbbleLogin.java
void showLoggedInUser() { final Call<User> authenticatedUser = dribbblePrefs.getApi().getAuthenticatedUser(); authenticatedUser.enqueue(new Callback<User>() { @Override/*from w w w .ja v a 2 s.c om*/ public void onResponse(Call<User> call, Response<User> response) { final User user = response.body(); dribbblePrefs.setLoggedInUser(user); final Toast confirmLogin = new Toast(getApplicationContext()); final View v = LayoutInflater.from(DribbbleLogin.this) .inflate(R.layout.toast_logged_in_confirmation, null, false); ((TextView) v.findViewById(R.id.name)).setText(user.name.toLowerCase()); // need to use app context here as the activity will be destroyed shortly Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player) .transform(new CircleTransform(getApplicationContext())) .into((ImageView) v.findViewById(R.id.avatar)); v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable( ContextCompat.getColor(DribbbleLogin.this, R.color.scrim), 5, Gravity.BOTTOM)); confirmLogin.setView(v); confirmLogin.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0); confirmLogin.setDuration(Toast.LENGTH_LONG); confirmLogin.show(); } @Override public void onFailure(Call<User> call, Throwable t) { } }); }
From source file:io.plaidapp.ui.DribbbleLogin.java
private void showLoggedInUser() { Gson gson = new GsonBuilder().setDateFormat(DribbbleService.DATE_FORMAT).create(); RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(DribbbleService.ENDPOINT) .setConverter(new GsonConverter(gson)) .setRequestInterceptor(new AuthInterceptor(dribbblePrefs.getAccessToken())).build(); DribbbleService dribbbleApi = restAdapter.create((DribbbleService.class)); dribbbleApi.getAuthenticatedUser(new Callback<User>() { @Override//w w w . j a va 2 s . c om public void success(User user, Response response) { dribbblePrefs.setLoggedInUser(user); Toast confirmLogin = new Toast(getApplicationContext()); View v = LayoutInflater.from(DribbbleLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false); ((TextView) v.findViewById(R.id.name)).setText(user.name); // need to use app context here as the activity will be destroyed shortly Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player) .transform(new CircleTransform(getApplicationContext())) .into((ImageView) v.findViewById(R.id.avatar)); v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable( ContextCompat.getColor(DribbbleLogin.this, R.color.scrim), 5, Gravity.BOTTOM)); confirmLogin.setView(v); confirmLogin.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0); confirmLogin.setDuration(Toast.LENGTH_LONG); confirmLogin.show(); } @Override public void failure(RetrofitError error) { } }); }
From source file:com.concentricsky.android.khanacademy.data.remote.KAAPIAdapter.java
/** * Call me from the UI thread, please./*from w ww .j a v a 2 s .c om*/ * * Meant for use by broadcast receivers receiving ACTION_BADGE_EARNED. * */ public void toastBadge(Badge badge) { BadgeCategory category = badge.getCategory(); // Dao<BadgeCategory, Integer> dao = dataService.getHelper().getDao(BadgeCategory.class); // dao.refresh(category); Toast toast = new Toast(dataService); View content = LayoutInflater.from(dataService).inflate(R.layout.badge, null, false); ImageView iconView = (ImageView) content.findViewById(R.id.badge_image); TextView pointsView = (TextView) content.findViewById(R.id.badge_points); TextView titleView = (TextView) content.findViewById(R.id.badge_title); TextView descView = (TextView) content.findViewById(R.id.badge_description); iconView.setImageResource(category.getIconResourceId()); int points = badge.getPoints(); if (points > 0) { pointsView.setText(points + ""); } else { pointsView.setVisibility(View.GONE); } titleView.setText(badge.getDescription()); descView.setText(badge.getSafe_extended_description()); toast.setView(content); toast.setDuration(Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 200); toast.show(); }
From source file:org.nla.tarotdroid.lib.ui.TabGameSetActivity.java
/** * Starts the whole Facebook post process. * // w w w . java2 s.c om * @param session */ private void launchPostProcess(final Session session) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(R.drawable.icon_facebook_released); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(this.getString(R.string.msgFacebookNotificationInProgress)); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (session == Session.getActiveSession()) { if (user != null) { int notificationId = FacebookHelper.showNotificationStartProgress(TabGameSetActivity.this); AppContext.getApplication().getNotificationIds() .put(TabGameSetActivity.this.gameSet.getUuid(), notificationId); AppContext.getApplication().setLoggedFacebookUser(user); UpSyncGameSetTask task = new UpSyncGameSetTask(TabGameSetActivity.this, progressDialog); task.setCallback(TabGameSetActivity.this.upSyncCallback); task.execute(TabGameSetActivity.this.gameSet); } } if (response.getError() != null) { AuditHelper.auditErrorAsString(ErrorTypes.facebookNewMeRequestFailed, response.getError().toString(), TabGameSetActivity.this); } } }); request.executeAsync(); }