Java Code Examples for android.widget.Toast

The following are top voted examples for showing how to use android.widget.Toast. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: android-dev-challenge   File: SettingsFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    Toast error = Toast.makeText(getContext(), "Please select a number between 0.1 and 3", Toast.LENGTH_SHORT);

    String sizeKey = getString(R.string.pref_size_key);
    if (preference.getKey().equals(sizeKey)) {
        String stringSize = ((String) newValue).trim();

        try {
            float size = Float.parseFloat(stringSize);
            if (size > 3 || size <= 0.1) {
                error.show();
                return false;
            }
        } catch (NumberFormatException nfe) {
            error.show();
            return false;
        }
    }
    return true;
}
 
Example 2
Project: Paathshala   File: LoginActivity.java   View source code 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = result.getSignInAccount();
            //mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName()));
            firebaseAuthWithGoogle(account);
        } else {
            // Google Sign In failed, update UI appropriately
            // [START_EXCLUDE]
            //updateUI(null);
            // [END_EXCLUDE]
            Toast.makeText(LoginActivity.this, "Authentication failed.",
                    Toast.LENGTH_SHORT).show();
        }
    }
}
 
Example 3
Project: BalaFM   File: PersonFragment.java   View source code 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case PERSON_INFO_SETTING_CODE:
            switch (resultCode){
                case RESULT_OK:
                    init();
                    return;
            }
            break;
        case USER_SAFE_CODE:
            break;
        case REPORT_QUESTIONG_CODE:
            Toast.makeText(getActivity(),"感谢您的建议~~",Toast.LENGTH_SHORT).show();
            break;
        case PERSON_LOGIN_CODE:
            if (AppKt.getGlobalUid() == 0) {
                Toast.makeText(getActivity(), "未登陆", Toast.LENGTH_LONG).show();
            }
            break;
    }
    return;
}
 
Example 4
Project: decoy   File: AdvancedTeamMemberInfoActivity.java   View source code 6 votes vote down vote up
/**
 * 更新群昵称
 *
 * @param name
 */
private void setNickname(final String name) {
    DialogMaker.showProgressDialog(this, getString(R.string.empty), true);
    NIMClient.getService(TeamService.class).updateMemberNick(teamId, account, name).setCallback(new RequestCallback<Void>() {
        @Override
        public void onSuccess(Void param) {
            DialogMaker.dismissProgressDialog();
            nickName.setText(name != null ? name : getString(R.string.team_nickname_none));
            Toast.makeText(AdvancedTeamMemberInfoActivity.this, R.string.update_success, Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onFailed(int code) {
            DialogMaker.dismissProgressDialog();
            Toast.makeText(AdvancedTeamMemberInfoActivity.this, String.format(getString(R.string.update_failed), code),
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onException(Throwable exception) {
            DialogMaker.dismissProgressDialog();
        }
    });
}
 
Example 5
Project: Personal-Chef   File: Feedback.java   View source code 5 votes vote down vote up
void sendFeedback()
{
    String feedback;

    String subject = "Feedback";
    feedback=fftext.getText().toString();
    if(!feedback.trim().isEmpty())
    {

        Log.i("Send email", "");
        String TO = "[email protected]";

        Intent send = new Intent(Intent.ACTION_SENDTO);
        String uriText = "mailto:" + Uri.encode(TO) +
                "?subject=" + Uri.encode(subject) +
                "&body=" + Uri.encode(feedback);
        Uri uri = Uri.parse(uriText);

        send.setData(uri);
        startActivity(Intent.createChooser(send, "Send mail..."));
    }
    else
    {
        Toast.makeText(getApplicationContext(), "Please Enter Text in Feedback Details", Toast.LENGTH_SHORT).show();
    }
}
 
Example 6
Project: KTools   File: ToastUtils.java   View source code 5 votes vote down vote up
public static void showToast(String msg, int duration) {
    final Timer timer = new Timer();
    final Toast toast = Toast.makeText(King.getApplicationContext(), msg, Toast.LENGTH_LONG);
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            toast.show();
        }
    }, 0, 1000);

    new Timer().schedule(new TimerTask() {
        @Override
        public void run() {
            toast.cancel();
            timer.cancel();
        }
    }, duration);

}
 
Example 7
Project: decoy   File: AdvancedTeamInfoActivity.java   View source code 5 votes vote down vote up
/**
 * 更新群信息
 *
 * @param t
 */
private void updateTeamInfo(final Team t) {
    this.team = t;

    if (team == null) {
        Toast.makeText(this, getString(R.string.team_not_exist), Toast.LENGTH_SHORT).show();
        finish();
        return;
    } else {
        creator = team.getCreator();
        if (creator.equals(NimUIKit.getAccount())) {
            isSelfAdmin = true;
        }

        setTitle(team.getName());
    }

    teamHeadImage.loadTeamIconByTeam(team);
    teamNameText.setText(team.getName());
    teamIdText.setText(team.getId());
    teamCreateTimeText.setText(TimeUtil.getTimeShowString(team.getCreateTime(), true));

    ((TextView) layoutTeamName.findViewById(R.id.item_detail)).setText(team.getName());
    introduceEdit.setText(team.getIntroduce());
    extensionTextView.setText(team.getExtension());
    notificationConfigText.setText(team.mute() ? "关闭" : "开启");
    memberCountText.setText(String.format("共%d人", team.getMemberCount()));

    setAnnouncement(team.getAnnouncement());
    setAuthenticationText(team.getVerifyType());
    updateInviteText(team.getTeamInviteMode());
    updateInfoUpateText(team.getTeamUpdateMode());
    updateBeInvitedText(team.getTeamBeInviteMode());
}
 
Example 8
Project: GitHub   File: DetailsFragment.java   View source code 5 votes vote down vote up
@Override public void onClick(View v) {
  if (mail != null) {
    presenter.starMail(mail, !mail.isStarred());
  } else {
    Toast.makeText(getActivity(), R.string.error_wait_mail_loaded, Toast.LENGTH_SHORT).show();
  }
}
 
Example 9
Project: ChewSnap   File: LoginActivity.java   View source code 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_SIGNUP) {
        if (resultCode == RESULT_OK) {

            // TODO: Implement successful signup logic here
            // By default we just finish the Activity and log them in automatically
            Toast.makeText(getBaseContext(), "Welcome to ChewSnap!", Toast.LENGTH_LONG).show();
            onLoginSuccess();
            //this.finish();
        }
    }
}
 
Example 10
Project: ucar-weex-core   File: WXDebugActivity.java   View source code 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
    if (result != null) {
        if (result.getContents() == null) {
            Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
        } else {
            handleDecodeInternally(result.getContents());
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example 11
Project: SmartisanDialog   File: MainActivity.java   View source code 5 votes vote down vote up
/**
 * 带单选按钮的Dialog
 *
 * @param view
 */
public void singleChoiceDialog(View view) {
    final SingleChoiceDialog dialog = SmartisanDialog.createSingleChoiceDialog(this);
    dialog.setTitle("蜂窝移动数据")
        .setLeftBtnText("取消")
        .setSingleChoiceItems(new String[]{"关", "使用 SIM 卡 1", "使用 SIM 卡 2"}, 0)
        .show();
    dialog.setOnSingleChoiceSelectListener(new OnSingleChoiceSelectListener() {
        @Override
        public void onSelect(int position) {
            Toast.makeText(MainActivity.this, "position = " + position, Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });
    dialog.setOnBtnSelectListener(new SingleChoiceDialog.OnBtnSelectListener() {
        @Override
        public void onLeftSelect() {
            dialog.dismiss();
        }

        @Override
        public void onRightSelect() {

        }
    });
}
 
Example 12
Project: USay   File: UpdatePasswordActivity.java   View source code 5 votes vote down vote up
private void updatePasswordClickEvent() {
    mUpdateCompile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            oldPaw = mUpdateOldPassword.getText().toString().trim();
            newPaw = mUpdateNewPassword.getText().toString().trim();

            if (TextUtils.isEmpty(oldPaw)) {
                Toast.makeText(UpdatePasswordActivity.this, "请输入旧密码!", Toast.LENGTH_SHORT).show();
            } else if (TextUtils.isEmpty(newPaw)) {
                Toast.makeText(UpdatePasswordActivity.this, "请输入新密码!", Toast.LENGTH_SHORT).show();
            } else {
                if (mMyUser != null) {
                    MyUser.updateCurrentUserPassword(oldPaw, newPaw, new UpdateListener() {
                        @Override
                        public void done(BmobException e) {
                            if (e == null) {
                                PersonSettingActivity.sSettingActivity.finishAfterTransition();
                                Toast.makeText(UpdatePasswordActivity.this,
                                        "修改成功,请用新密码登录!", Toast.LENGTH_SHORT).show();
                                Intent intent = new Intent(UpdatePasswordActivity.this,
                                        LoginActivity.class);
                                startActivity(intent);
                                finishAfterTransition();
                            } else {
                                Toast.makeText(UpdatePasswordActivity.this,
                                        "修改失败,请重新检查!", Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
            }
        }
    });
}
 
Example 13
Project: android-radiobutton-extended   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public <V extends View & Checkable> void onCheckedChange(ExampleViewHolder vh, V view, boolean isChecked) {
    if (view.isPressed()) {
        Toast.makeText(
                MainActivity.this,
                String.format(
                        "position=%d; label=%s; isChecked=%b;",
                        vh.getAdapterPosition(),
                        vh.getRadioButton().getText(),
                        isChecked
                ),
                Toast.LENGTH_SHORT
        ).show();
    }
}
 
Example 14
Project: polling-station-app   File: PassportConActivity.java   View source code 5 votes vote down vote up
/**
 * Method to start the ResultActivity once all the data is loaded.
 * Creates new intent with the read data
 * @param pubKey The public key.
 * @param signedTransactions Signed data.
 * @param voter The voter.
 */
public void startResultActivity(PublicKey pubKey, ArrayList<byte[]> signedTransactions, Voter voter) {
    if(pubKey != null && signedTransactions != null) {

        Intent intent = new Intent(getApplicationContext(), ResultActivity.class);
        intent.putExtra("voter", voter);
        intent.putExtra("pubKey", pubKey);
        intent.putExtra("signedTransactions", signedTransactions);
        startActivity(intent);
        finish();
    } else {
        Toast.makeText(this, getString(R.string.NFC_error), Toast.LENGTH_LONG).show();
        progressView.setImageResource(R.drawable.nfc_icon_empty);
    }
}
 
Example 15
Project: CatchSpy   File: ImportActivity.java   View source code 5 votes vote down vote up
private void advancedImportDialog(Context context) {
    LayoutInflater inflater = getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_advanced_import, (ViewGroup) findViewById(R.id.dialog_layout_import_advanced));
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.import_advanced);
    final TextInputEditText group = mView.findViewById(R.id.edittext_import_advanced_group);
    final TextInputEditText word = mView.findViewById(R.id.edittext_import_advanced_word);
    final CheckBox ignoreChangeLine = mView.findViewById(R.id.checkbox_import_advanced_ignore_change_line);
    builder.setPositiveButton(R.string.import_file, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String groupReg = group.getText().toString();
            String wordReg = word.getText().toString();
            if (!groupReg.isEmpty()) {
                if (!wordReg.isEmpty()) {
                    int result = ImportMethod.extraFileRegImporter(DictionaryPath, DictionaryName, groupReg, wordReg, ignoreChangeLine.isChecked());
                    if (result == Config.IMPORT_OK) {
                        Toast.makeText(ImportActivity.this, R.string.import_success, Toast.LENGTH_SHORT).show();
                        finish();
                    } else if (result == Config.IMPORT_FILE_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_file_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_OUTPUT_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_output_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_GROUP_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_group_match_error, Snackbar.LENGTH_SHORT).show();
                    } else if (result == Config.IMPORT_WORDS_ERROR) {
                        Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_word_match_error, Snackbar.LENGTH_SHORT).show();
                    }
                } else {
                    Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_word_match_error, Snackbar.LENGTH_SHORT).show();
                }
            } else {
                Snackbar.make(findViewById(R.id.import_layout_content), R.string.import_advanced_group_match_error, Snackbar.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
Example 16
Project: FancyToast-Android   File: FancyToast.java   View source code 5 votes vote down vote up
public static Toast makeText(Context context,String message,int duration,int type,boolean androidicon){
    Toast toast = new Toast(context);
    toast.setDuration(duration);
    View layout = LayoutInflater.from(context).inflate(R.layout.fancytoast_layout, null, false);
    TextView l1 = (TextView) layout.findViewById(R.id.toast_text);
    LinearLayout linearLayout=(LinearLayout) layout.findViewById(R.id.toast_type);
    ImageView img=(ImageView) layout.findViewById(R.id.toast_icon);
    ImageView img1=(ImageView) layout.findViewById(R.id.imageView4);
    l1.setText(message);
    if(androidicon==true)
    img1.setVisibility(View.VISIBLE);
    else if(androidicon==false)
    img1.setVisibility(View.GONE);
    if(type==1)
    { linearLayout.setBackgroundResource(R.drawable.success_shape);
      img.setImageResource(R.drawable.ic_check_black_24dp);
    }
    else if (type==2)
    { linearLayout.setBackgroundResource(R.drawable.warning_shape);
      img.setImageResource(R.drawable.ic_pan_tool_black_24dp);
    }
    else if (type==3)
    { linearLayout.setBackgroundResource(R.drawable.error_shape);
      img.setImageResource(R.drawable.ic_clear_black_24dp);
    }
    else if (type==4)
    { linearLayout.setBackgroundResource(R.drawable.info_shape);
      img.setImageResource(R.drawable.ic_info_outline_black_24dp);
    }
    else if (type==5)
    { linearLayout.setBackgroundResource(R.drawable.default_shape);
      img.setVisibility(View.GONE);
    }
    else if (type==6)
    { linearLayout.setBackgroundResource(R.drawable.confusing_shape);
      img.setImageResource(R.drawable.ic_refresh_black_24dp);
    }
    toast.setView(layout);
    return toast;
}
 
Example 17
Project: My-Sheep   File: KidDetail.java   View source code 5 votes vote down vote up
private void visitHistoryDialog(){
    AlertDialog.Builder visitHistoryBuilder = new AlertDialog.Builder(KidDetail.this);
    visitHistoryBuilder.setCancelable(true);
    LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
    View view = inflater.inflate(R.layout.visit_history,null);
    visitHistoryBuilder.setView(view);
    final TextView historyText = (TextView) view.findViewById(R.id.historyText);
    final StringBuilder historyString = new StringBuilder();
    ParseQuery<Visit> query = ParseQuery.getQuery(Visit.class);//.fromLocalDatastore();
    query.whereContains("kidId",myKid.getObjectId());
    query.orderByAscending("createdAt");
    query.findInBackground(new FindCallback<Visit>() {
        @Override
        public void done(@NonNull List<Visit> list, @Nullable ParseException e) {
            if (e == null){
                if(list.size()!=0){
                for (int i = 0; i < list.size() ; i++) {
                    Visit visit = list.get(i);
                    historyString.append("Visit No. : "+ (i+1)+"\n");
                    historyString.append("Visit Date: "+visit.getVisitDate()+"\n");
                    historyString.append("Servants:\n "+visit.getServants()+"\n");
                    historyString.append("Visit summary:\n "+visit.getSummary()+"\n\n\n");
                    }
                    historyText.setText(historyString);
                }else{
                    historyText.setText("No visit history found!\nPlease pay a visit asap.");
                }

            }else{Toast.makeText(getApplicationContext(),"Error!",Toast.LENGTH_LONG).show();}
        }
    });

    AlertDialog historyDialog = visitHistoryBuilder.create();
    historyDialog.show();
}
 
Example 18
Project: lockit   File: BaseFragment.java   View source code 5 votes vote down vote up
private void genericError(final Throwable throwable) {
    Logger.logError(throwable);

    if (isAuthError(throwable)) {
        showUnauthorizedDialog();
        return;
    }

    String errorMessage =
            isNetworkError(throwable) ? "Network error" : "Some error occurred. Try again.";
    if (getActivity() != null) {
        Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
        hideLoader();
    }
}
 
Example 19
Project: GCSApp   File: PayUnionStart.java   View source code 5 votes vote down vote up
void toast(final String str) {
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(context,str,Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 20
Project: LuaViewPlayground   File: ToastUtil.java   View source code 5 votes vote down vote up
/**
 * show a toast using resource Globals.getId()
 *
 * @param context
 * @param resId
 * @param isLong
 */
public static void showToast(final Context context, final int resId, final boolean isLong) {
    if (isLong) {
        LENGTH = Toast.LENGTH_LONG;
    } else {
        LENGTH = Toast.LENGTH_SHORT;
    }
    showToast(context, context.getString(resId));
}
 
Example 21
Project: yass-android   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onPostExecute(File file) {
    super.onPostExecute(file);
    if (dialog != null) {
        dialog.dismiss();
    }

    if (file == null) {
        Toast.makeText(MainActivity.this, "Could not download file", Toast.LENGTH_LONG).show();
        return;
    }

    Uri uri = FileProvider.getUriForFile(MainActivity.this, "org.gaul.yass", file);
    String mime = object.getObjectMetadata().getContentType();

    if (mime == null) {
        int index = object.getKey().lastIndexOf('.');
        if (index != -1) {
            mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
                    object.getKey().substring(index + 1));
            Log.d(TAG, "guessed mime type: " + mime);
        }
    }

    // TODO: does not work for HTML
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(uri, mime);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException anfe) {
        // TODO: convert to text/plain?
        Log.e(TAG, "No intent for " + object.getKey() + " " + anfe);
        Toast.makeText(MainActivity.this, "No registered intent", Toast.LENGTH_LONG).show();
        return;
    }
}
 
Example 22
Project: Android-Code-Demos   File: RegionClickView.java   View source code 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            int x = (int) event.getX();
            int y = (int) event.getY();

            if (mCircleRegion.contains(x, y)) {
                Toast.makeText(mCurrentContext, "Click", Toast.LENGTH_SHORT).show();
            }
            break;
    }
    return true;
}
 
Example 23
Project: FinalProject   File: MessageActivity.java   View source code 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()){
        case R.id.chat_image:
            changeProfileRequest();
            break;
        case R.id.main_activity_emoji:
            emojiPopup.toggle();
            break;
        case R.id.emoji_send_message:
            if (editText.getText().toString().trim().isEmpty()){
                Toast.makeText(MessageActivity.this, "Please enter some message", Toast.LENGTH_SHORT).show();
            } else {

                sendTextMessage();
            }
            break;

    }
}
 
Example 24
Project: CacheManage   File: MainActivity.java   View source code 5 votes vote down vote up
private void initObserver() {
    CacheObserver.getInstance().addObserver("key1", new IDataChangeListener() {
        @Override
        public void onDataChange(String key, String str) {
            Toast.makeText(MainActivity.this, str, Toast.LENGTH_SHORT).show();
            Gson gson = new Gson();
            Test test = gson.fromJson(str, Test.class);
        }
    });
}
 
Example 25
Project: SimpleUILauncher   File: Launcher.java   View source code 5 votes vote down vote up
public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
    if (mIsSafeModeEnabled && !Utilities.isSystemApp(this, intent)) {
        Toast.makeText(this, R.string.safemode_shortcut_error, Toast.LENGTH_SHORT).show();
        return false;
    }
    // Only launch using the new animation if the shortcut has not opted out (this is a
    // private contract between launcher and may be ignored in the future).
    boolean useLaunchAnimation = (v != null) &&
            !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
    Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;

    UserHandleCompat user = null;
    if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
        long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
        user = UserManagerCompat.getInstance(this).getUserForSerialNumber(serialNumber);
    }

    // Prepare intent
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (v != null) {
        intent.setSourceBounds(getViewBounds(v));
    }
    try {
        if (Utilities.ATLEAST_MARSHMALLOW && item != null
                && (item.itemType == Favorites.ITEM_TYPE_SHORTCUT
                || item.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT)
                && ((ShortcutInfo) item).promisedIntent == null) {
            // Shortcuts need some special checks due to legacy reasons.
            startShortcutIntentSafely(intent, optsBundle, item);
        } else if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
            // Could be launching some bookkeeping activity
            startActivity(intent, optsBundle);
        } else {
            LauncherAppsCompat.getInstance(this).startActivityForProfile(
                    intent.getComponent(), user, intent.getSourceBounds(), optsBundle);
        }
        return true;
    } catch (ActivityNotFoundException|SecurityException e) {
        Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        Log.e(TAG, "Unable to launch. tag=" + item + " intent=" + intent, e);
    }
    return false;
}
 
Example 26
Project: SmartisanDialog   File: MainActivity.java   View source code 5 votes vote down vote up
/**
 * 警告Dialog
 *
 * @param view
 */
public void warningDialog(View view) {
    final WarningDialog dialog = SmartisanDialog.createWarningDialog(this);
    dialog.setTitle("确定退出登录吗")
        .setConfirmText("退出登录")
        .show();
    dialog.setOnConfirmListener(new WarningDialog.OnConfirmListener() {
        @Override
        public void onConfirm() {
            Toast.makeText(MainActivity.this, "onConfirm", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });
}
 
Example 27
Project: Runnest   File: ChallengeActivity.java   View source code 5 votes vote down vote up
/**
 * Handle request permissions result. Update what is needed and give a feedback to the user.
 *
 * @param requestCode       Code of the request.
 * @param permissions       Requested permissions.
 * @param grantResults      Result of the request.
 */
@Override
public void onRequestPermissionsResult(int requestCode,
                                       @NonNull String[] permissions,
                                       @NonNull int[] grantResults)
{
    switch (requestCode) {
        case PERMISSION_REQUEST_CODE_FINE_LOCATION:
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Toast.makeText(getApplicationContext(), R.string.toast_start_challenge,Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(getApplicationContext(), R.string.toast_start_challenge_denied,
                        Toast.LENGTH_LONG).show();
            }
            break;
    }
}
 
Example 28
Project: techstar-shop   File: ActivitySignup.java   View source code 5 votes vote down vote up
public void signup() {
    if (!validate()) {
        onSignupFailed();
        return;
    }
    signUpButton.setEnabled(false);
    final ProgressDialog progressDialog = new ProgressDialog(ActivitySignup.this,
            R.style.AppTheme_Dark_Dialog);
    progressDialog.setIndeterminate(true);
    progressDialog.setMessage(getString(R.string.register_loaging));
    progressDialog.show();

    new android.os.Handler().postDelayed(
            new Runnable() {
                public void run() {

                    Toast.makeText(getBaseContext(), getString(R.string.register_success), Toast.LENGTH_LONG).show();
                    String name = nameEditText.getText().toString();
                    String email = emailEditText.getText().toString();
                    String password = passwordEditText.getText().toString();

                    register(name,password,email, bitmap);
                    progressDialog.dismiss();
                    finish();
                }
            }, 3000);
}
 
Example 29
Project: Cable-Android   File: VerifyIdentityActivity.java   View source code 5 votes vote down vote up
private void handleShare(@NonNull Fingerprint fingerprint, int segmentCount) {
  String shareString =
      getString(R.string.VerifyIdentityActivity_our_signal_safety_number) + "\n" +
          getFormattedSafetyNumbers(fingerprint, segmentCount) + "\n";

  Intent intent = new Intent();
  intent.setAction(Intent.ACTION_SEND);
  intent.putExtra(Intent.EXTRA_TEXT, shareString);
  intent.setType("text/plain");

  try {
    startActivity(Intent.createChooser(intent, getString(R.string.VerifyIdentityActivity_share_safety_number_via)));
  } catch (ActivityNotFoundException e) {
    Toast.makeText(getActivity(), R.string.VerifyIdentityActivity_no_app_to_share_to, Toast.LENGTH_LONG).show();
  }
}
 
Example 30
Project: buildAPKsSamples   File: BasicManagedProfileFragment.java   View source code 5 votes vote down vote up
/**
 * Clears restrictions to Chrome
 */
private void clearChromeRestrictions() {
    final Activity activity = getActivity();
    if (null == activity) {
        return;
    }
    final DevicePolicyManager manager =
            (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
    // In order to clear restrictions, pass null as the restriction Bundle for
    // setApplicationRestrictions
    manager.setApplicationRestrictions
            (BasicDeviceAdminReceiver.getComponentName(activity),
                    PACKAGE_NAME_CHROME, null);
    Toast.makeText(activity, R.string.cleared, Toast.LENGTH_SHORT).show();
}
 
Example 31
Project: Mix   File: DaggerMainActivity.java   View source code 5 votes vote down vote up
private boolean isEmptyWord(String input, boolean withEmptyPoint) {
    if (TextUtils.isEmpty(input)) {
        if (withEmptyPoint) {
            Toast.makeText(DaggerMainActivity.this, "请输入日期", Toast.LENGTH_SHORT).show();
        }
        return true;
    }
    return false;
}
 
Example 32
Project: Android-LSS   File: StreamingActivity.java   View source code 5 votes vote down vote up
public void onClickQuit(View v) {
    if (isSessionStarted || isConnecting) {
        Toast.makeText(this, "直播过程中不能返回,请先停止直播!", Toast.LENGTH_SHORT).show();
    } else {
        // 提前让surface自动销毁,防止后续的慢销毁可能带来的兼容问题
        if (mCameraView != null) {
            mCameraView.setVisibility(View.INVISIBLE);
        }
        this.finish();
    }
}
 
Example 33
Project: anitrend-app   File: UserProfileActivity.java   View source code 5 votes vote down vote up
@Override
protected void startInit() {
    if(mCurrentUser != null) {
        user_anime_time.setText(mPresenter.getAnimeTime(mCurrentUser.getAnime_time()));
        user_manga_chap.setText(mCurrentUser.getManga_chap());
        user_anime_total.setText("0");
        user_manga_total.setText("0");

        UserStats userStats = mCurrentUser.getStats();
        if(userStats != null) {
            if(userStats.getStatus_distribution() != null)
                if(userStats.getStatus_distribution().getAnime() != null)
                    user_anime_total.setText(userStats.getStatus_distribution().getAnime().getTotalAnime());
            if(userStats.getStatus_distribution().getManga() != null)
                user_manga_total.setText(userStats.getStatus_distribution().getManga().getTotalManga());
        }

        Glide.with(this)
                .load(mCurrentUser.getImage_url_banner())
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(user_banner);

        updateUI();
    } else{
        Toast.makeText(this, R.string.text_error_request, Toast.LENGTH_LONG).show();
    }
}
 
Example 34
Project: notify-me   File: TextToSpeech.java   View source code 5 votes vote down vote up
void readNotification(String text) {
    if (sTextToSpeech == null) return;

    int speak = sTextToSpeech.speak(text, android.speech.tts.TextToSpeech.QUEUE_FLUSH,
            null, "111");

    if (speak < 0) {
        Toast.makeText(mContext, "Unable to speak!", Toast.LENGTH_SHORT).show();
        Log.e(TAG, "readNotification: Unable to speak!");
    }
}
 
Example 35
Project: GCSApp   File: UserProfileActivity.java   View source code 5 votes vote down vote up
private void uploadUserAvatar(final byte[] data) {
	dialog = ProgressDialog.show(this, getString(R.string.dl_update_photo), getString(R.string.dl_waiting));
	new Thread(new Runnable() {

		@Override
		public void run() {
			final String avatarUrl = DemoHelper.getInstance().getUserProfileManager().uploadUserAvatar(data);
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					dialog.dismiss();
					if (avatarUrl != null) {
						Toast.makeText(UserProfileActivity.this, getString(R.string.toast_updatephoto_success),
								Toast.LENGTH_SHORT).show();
					} else {
						Toast.makeText(UserProfileActivity.this, getString(R.string.toast_updatephoto_fail),
								Toast.LENGTH_SHORT).show();
					}

				}
			});

		}
	}).start();

	dialog.show();
}
 
Example 36
Project: Shared-Route   File: PayBillActivity.java   View source code 5 votes vote down vote up
@Override
        protected void onPostExecute(final Boolean success) {
            mAuthTask = null;
            showProgress(false);

            if (success) {
                new AlertDialog.Builder(PayBillActivity.this)
                        .setIcon(R.drawable.share_icon_with_background)//这里是显示提示框的图片信息,我这里使用的默认androidApp的图标
                        .setTitle("支付成功")
                        .setMessage("即将返回主页")
                        .setPositiveButton("确认", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                startActivity(new Intent(PayBillActivity.this, MainActivity.class));
                                finish();
                            }
                        }).show();
//                Toast.makeText(getApplicationContext(),"支付成功,即将返回主页!", Toast.LENGTH_SHORT).show();
//                Thread thread = new Thread() {
//                    public void run(){
//                        try {
//                            Thread.sleep(2000);
//                        } catch (InterruptedException e) {
//                            e.printStackTrace();
//                        }
//                        startActivity(new Intent(PayBillActivity.this,MainActivity.class));
//                        finish();
//                    }
//                };
//                thread.start();
            }
            else
            {
                Toast.makeText(getApplicationContext(),result.toString(), Toast.LENGTH_SHORT).show();
            }
        }
 
Example 37
Project: TaipeiTechRefined   File: Utility.java   View source code 5 votes vote down vote up
public static boolean checkAccount(Context context) {
    String account = Model.getInstance().getAccount();
    String password = Model.getInstance().getPassword();
    if (TextUtils.isEmpty(account) || TextUtils.isEmpty(password)) {
        Toast.makeText(context, R.string.account_password_empty_toast_text, Toast.LENGTH_LONG).show();
        return false;
    }
    return true;
}
 
Example 38
Project: javaide   File: EditorFragment.java   View source code 5 votes vote down vote up
@Override
public void redo() {
    if (mCodeEditor == null) return;
    if (mCodeEditor.canRedo()) {
        mCodeEditor.redo();
    } else {
        Toast.makeText(getContext(), R.string.cant_redo, Toast.LENGTH_SHORT).show();
    }
}
 
Example 39
Project: GitHub   File: MainActivity.java   View source code 5 votes vote down vote up
@Override public void onRequestPermissionsResult(int requestCode,
                                                 @NonNull String[] permissions,
                                                 @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (requestCode == STORAGE_PERMISSION_RC) {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            handler.postDelayed(() -> findViewById(chooserDialog).performClick(), 1000);
        } else {
            Toast.makeText(this, "The folder or file chooser will not work without " +
                    "permission to read external storage.", Toast.LENGTH_LONG).show();
        }
    }
}
 
Example 40
Project: CodeWatch   File: DashboardFragment.java   View source code 5 votes vote down vote up
@OnClick({R.id.share_activity_chart, R.id.share_editors_chart, R.id.share_language_chart, R.id.share_os_chart})
public void onShareClick(View view) {
    Bitmap bitmap = null;
    switch (view.getId()) {
        case R.id.share_activity_chart:
            bitmap = lineChart.getChartBitmap();
            break;
        case R.id.share_editors_chart:
            bitmap = pieChartEditors.getChartBitmap();
            break;
        case R.id.share_language_chart:
            bitmap = pieChartLanguages.getChartBitmap();
            break;
        case R.id.share_os_chart:
            bitmap = pieChartOs.getChartBitmap();
            break;
        default:
            break;
    }
    if (bitmap != null) {
        //add watermark
        bitmap = UiUtils.addWaterMark(bitmap, context);

        try {
            FileProviderUtils.shareBitmap(context, bitmap);
        } catch (IOException e) {
            Timber.d(e, "IO Error while saving image");
            Toast.makeText(context, R.string.share_error, Toast.LENGTH_SHORT).show();
        }
        bitmap.recycle();
    }
}