Search in sources :

Example 71 with Toast

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;
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) Toast(android.widget.Toast)

Example 72 with Toast

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();
}
Also used : Toast(android.widget.Toast)

Example 73 with Toast

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();
}
Also used : Toast(android.widget.Toast)

Example 74 with Toast

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);
}
Also used : Toast(android.widget.Toast) UserBlockTask(com.applozic.mobicomkit.api.account.user.UserBlockTask) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) ApiResponse(com.applozic.mobicomkit.feed.ApiResponse)

Example 75 with Toast

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();
}
Also used : Toast(android.widget.Toast)

Aggregations

Toast (android.widget.Toast)485 Context (android.content.Context)89 View (android.view.View)86 TextView (android.widget.TextView)74 Intent (android.content.Intent)55 Rect (android.graphics.Rect)34 LayoutInflater (android.view.LayoutInflater)31 SuppressLint (android.annotation.SuppressLint)30 JSONObject (org.json.JSONObject)23 ImageView (android.widget.ImageView)21 RequestQueue (com.android.volley.RequestQueue)20 Response (com.android.volley.Response)20 EditText (android.widget.EditText)19 JSONException (org.json.JSONException)18 VolleyError (com.android.volley.VolleyError)17 JsonObjectRequest (com.android.volley.toolbox.JsonObjectRequest)17 User (model.User)16 PendingIntent (android.app.PendingIntent)15 File (java.io.File)15 HashMap (java.util.HashMap)15