use of android.widget.Toast in project android_frameworks_base by AOSPA.
the class MediaRouteButton method performLongClick.
@Override
public boolean performLongClick() {
if (super.performLongClick()) {
return true;
}
if (!mCheatSheetEnabled) {
return false;
}
final CharSequence contentDesc = getContentDescription();
if (TextUtils.isEmpty(contentDesc)) {
// Don't show the cheat sheet if we have no description
return false;
}
final int[] screenPos = new int[2];
final Rect displayFrame = new Rect();
getLocationOnScreen(screenPos);
getWindowVisibleDisplayFrame(displayFrame);
final Context context = getContext();
final int width = getWidth();
final int height = getHeight();
final int midy = screenPos[1] + height / 2;
final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
Toast cheatSheet = Toast.makeText(context, contentDesc, Toast.LENGTH_SHORT);
if (midy < displayFrame.height()) {
// Show along the top; follow action buttons
cheatSheet.setGravity(Gravity.TOP | Gravity.END, screenWidth - screenPos[0] - width / 2, height);
} else {
// Show along the bottom center
cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
}
cheatSheet.show();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
return true;
}
use of android.widget.Toast in project android_packages_apps_Settings by LineageOS.
the class WebViewUpdateServiceWrapper method showInvalidChoiceToast.
/**
* Show a toast to explain the chosen package can no longer be chosen.
*/
public void showInvalidChoiceToast(Context context) {
// The user chose a package that became invalid since the list was last updated,
// show a Toast to explain the situation.
Toast toast = Toast.makeText(context, R.string.select_webview_provider_toast_text, Toast.LENGTH_SHORT);
toast.show();
}
use of android.widget.Toast in project Slide by ccrama.
the class ToastHelpCreation method makeToast.
public static void makeToast(View view, String message, Context context) {
int x = view.getLeft();
int y = view.getTop() + 2 * view.getHeight();
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP | Gravity.LEFT, x, y);
toast.show();
}
use of android.widget.Toast in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method blockUserProcess.
public void blockUserProcess(final String userId, final boolean block, final boolean isFromChannel) {
final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.please_wait_info), true);
UserBlockTask.TaskListener listener = new UserBlockTask.TaskListener() {
@Override
public void onSuccess(ApiResponse apiResponse) {
if (block && typingStarted) {
((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle("");
Intent intent = new Intent(getActivity(), ApplozicMqttIntentService.class);
intent.putExtra(ApplozicMqttIntentService.CONTACT, contact);
intent.putExtra(ApplozicMqttIntentService.STOP_TYPING, true);
ApplozicMqttIntentService.enqueueWork(getActivity(), intent);
}
menu.findItem(R.id.userBlock).setVisible(!block);
menu.findItem(R.id.userUnBlock).setVisible(block);
}
@Override
public void onFailure(ApiResponse apiResponse, Exception exception) {
String error = getString(Utils.isInternetAvailable(getActivity()) ? R.string.applozic_server_error : R.string.you_need_network_access_for_block_or_unblock);
Toast toast = Toast.makeText(getActivity(), error, Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
@Override
public void onCompletion() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (!isFromChannel) {
contact = appContactService.getContactById(userId);
}
}
};
new UserBlockTask(getActivity(), listener, userId, block).execute((Void) null);
}
use of android.widget.Toast in project Applozic-Android-SDK by AppLozic.
the class InstructionUtil method showToast.
public static void showToast(Context context, int resId, int colorId) {
Toast toast = Toast.makeText(context, context.getString(resId), Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.getView().setBackgroundColor(context.getResources().getColor(colorId));
toast.show();
}
Aggregations