Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

In this page you can find the example usage for android.app ProgressDialog dismiss.

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:cn.hbm.superwechat.activity.SettingsFragment.java

void logout() {

    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);/* w  ww  . ja  v a2s .  c om*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    Map<String, UserAvatar> map = SuperWeChatApplication.getInstance().getMap();
                    List<UserAvatar> userList = SuperWeChatApplication.getInstance().getUserList();
                    List<GroupAvatar> groupAvatarList = SuperWeChatApplication.getInstance()
                            .getGroupAvatarList();
                    if (map != null) {
                        map.clear();
                    }
                    if (userList != null) {
                        userList.clear();
                    }
                    if (groupAvatarList != null) {
                        groupAvatarList.clear();
                    }
                    pd.dismiss();
                    // ??
                    getActivity().finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}

From source file:piuk.blockchain.android.ui.dialogs.NewAccountDialog.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);

    final FragmentActivity activity = getActivity();
    final LayoutInflater inflater = LayoutInflater.from(activity);

    final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog))
            .setTitle(R.string.new_account_title);

    final View view = inflater.inflate(R.layout.new_account_dialog, null);

    dialog.setView(view);//from w ww .j  av a  2s.  c o m

    final Button createButton = (Button) view.findViewById(R.id.create_button);
    final TextView password = (TextView) view.findViewById(R.id.password);
    final TextView password2 = (TextView) view.findViewById(R.id.password2);
    final TextView captcha = (TextView) view.findViewById(R.id.captcha);

    refreshCaptcha(view);

    createButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            final WalletApplication application = (WalletApplication) getActivity().getApplication();

            if (password.getText().length() < 11 || password.getText().length() > 255) {
                Toast.makeText(application, R.string.new_account_password_length_error, Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (!password.getText().toString().equals(password2.getText().toString())) {
                Toast.makeText(application, R.string.new_account_password_mismatch_error, Toast.LENGTH_LONG)
                        .show();
                return;
            }

            if (captcha.getText().length() == 0) {
                Toast.makeText(application, R.string.new_account_no_kaptcha_error, Toast.LENGTH_LONG).show();
                return;
            }

            final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "",
                    getString(R.string.creating_account), true);

            progressDialog.show();

            final Handler handler = new Handler();

            new Thread() {
                @Override
                public void run() {
                    try {
                        try {
                            application.generateNewWallet();
                        } catch (Exception e1) {
                            throw new Exception("Error Generating Wallet");
                        }

                        application.getRemoteWallet().setTemporyPassword(password.getText().toString());

                        if (!application.getRemoteWallet().remoteSave(captcha.getText().toString())) {
                            throw new Exception("Unknown Error Inserting wallet");
                        }

                        EventListeners.invokeWalletDidChange();

                        handler.post(new Runnable() {
                            public void run() {
                                try {
                                    progressDialog.dismiss();

                                    dismiss();

                                    Toast.makeText(getActivity().getApplication(), R.string.new_account_success,
                                            Toast.LENGTH_LONG).show();

                                    PinEntryActivity.clearPrefValues(application);

                                    Editor edit = PreferenceManager
                                            .getDefaultSharedPreferences(application.getApplicationContext())
                                            .edit();

                                    edit.putString("guid", application.getRemoteWallet().getGUID());
                                    edit.putString("sharedKey", application.getRemoteWallet().getSharedKey());

                                    AbstractWalletActivity activity = (AbstractWalletActivity) getActivity();

                                    if (edit.commit()) {
                                        application.checkWalletStatus(activity);
                                    } else {
                                        throw new Exception("Error saving preferences");
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();

                                    application.clearWallet();

                                    Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(),
                                            Toast.LENGTH_LONG).show();
                                }
                            }
                        });
                    } catch (final Exception e) {
                        e.printStackTrace();

                        application.clearWallet();

                        handler.post(new Runnable() {
                            public void run() {
                                progressDialog.dismiss();

                                refreshCaptcha(view);

                                captcha.setText(null);

                                Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(),
                                        Toast.LENGTH_LONG).show();
                            }
                        });
                    }
                }
            }.start();
        }
    });

    Dialog d = dialog.create();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();

    lp.dimAmount = 0;
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;

    d.show();

    d.getWindow().setAttributes(lp);

    d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return d;
}

From source file:de.schildbach.wallet.ui.SendCoinsFragmentBackup.java

private void requestPaymentRequest(final String paymentRequestUrl) {
    final String host = Uri.parse(paymentRequestUrl).getHost();
    final ProgressDialog progressDialog = ProgressDialog.show(activity, null,
            getString(R.string.send_coins_fragment_request_payment_request_progress, host), true, true, null);

    new RequestPaymentRequestTask.HttpRequestTask(backgroundHandler,
            new RequestPaymentRequestTask.ResultCallback() {
                @Override//from ww w .  j a  va  2  s  . c o  m
                public void onPaymentIntent(final PaymentIntent paymentIntent) {
                    progressDialog.dismiss();

                    if (SendCoinsFragmentBackup.this.paymentIntent.isSecurityExtendedBy(paymentIntent)) {
                        updateStateFrom(paymentIntent);
                    } else {
                        final DialogBuilder dialog = DialogBuilder.warn(activity,
                                R.string.send_coins_fragment_request_payment_request_failed_title);
                        dialog.setMessage(getString(
                                R.string.send_coins_fragment_request_payment_request_wrong_signature));
                        dialog.singleDismissButton(null);
                        dialog.show();
                    }
                }

                @Override
                public void onFail(final int messageResId, final Object... messageArgs) {
                    progressDialog.dismiss();

                    final DialogBuilder dialog = DialogBuilder.warn(activity,
                            R.string.send_coins_fragment_request_payment_request_failed_title);
                    dialog.setMessage(getString(messageResId, messageArgs));
                    dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            requestPaymentRequest(paymentRequestUrl);
                        }
                    });
                    dialog.setNegativeButton(R.string.button_dismiss, null);
                    dialog.show();
                }
            }, application.httpUserAgent()).requestPaymentRequest(paymentRequestUrl);
}

From source file:com.m2dl.mini_projet.mini_projet_android.MainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            Uri selectedImage = imageUri;
            getContentResolver().notifyChange(selectedImage, null);

            ContentResolver cr = getContentResolver();
            try {
                myBitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, selectedImage);
                myBitmap = BitmapUtil.resize(myBitmap);
                imageFilePath = imageUri.getPath();
                ExifInterface exif = new ExifInterface(imageFilePath);
                int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                        ExifInterface.ORIENTATION_NORMAL);
                switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    myBitmap = BitmapUtil.rotateImage(myBitmap, 90);
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    myBitmap = BitmapUtil.rotateImage(myBitmap, 180);
                    break;
                }/*from ww w .j a v  a2  s .c  o m*/
                String dialogTitle;
                String dialogMessage;
                if (!isGPSOn) {
                    dialogTitle = "Golocalisation GPS...";
                    dialogMessage = "Veuillez activer votre GPS puis patienter pendant la golocalisation";
                } else {
                    dialogTitle = "Golocalisation GPS...";
                    dialogMessage = "Veuillez patienter pendant la golocalisation";
                }
                final ProgressDialog progDialog = ProgressDialog.show(MainActivity.this, dialogTitle,
                        dialogMessage, true);
                new Thread() {
                    public void run() {
                        try {
                            while (coordLat.equals(0.0d) && coordLong.equals(0.0d))
                                ;
                            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                            Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
                            if (prev != null) {
                                ft.remove(prev);
                            }
                            ft.addToBackStack(null);
                            DialogFragment newFragment = PhotoDialogFragment.newInstance(myBitmap, coordLat,
                                    coordLong, imageFilePath);
                            newFragment.show(ft, "dialog");
                        } catch (Exception e) {
                            Log.e(TAG, e.getMessage());
                        }
                        progDialog.dismiss();
                    }
                }.start();
            } catch (Exception e) {
                Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT).show();
                Log.e("Camera", e.toString());
            }
        }
    }
}

From source file:cc.mintcoin.wallet.ui.SendCoinsFragment.java

private void requestPaymentRequest(final String paymentRequestUrl) {
    final String host = Uri.parse(paymentRequestUrl).getHost();
    final ProgressDialog progressDialog = ProgressDialog.show(activity, null,
            getString(R.string.send_coins_fragment_request_payment_request_progress, host), true, true, null);

    new RequestPaymentRequestTask.HttpRequestTask(backgroundHandler,
            new RequestPaymentRequestTask.ResultCallback() {
                @Override/*from   www .ja  va  2 s  . c  o m*/
                public void onPaymentIntent(final PaymentIntent paymentIntent) {
                    progressDialog.dismiss();

                    if (SendCoinsFragment.this.paymentIntent.isSecurityExtendedBy(paymentIntent)) {
                        updateStateFrom(paymentIntent);
                    } else {
                        final DialogBuilder dialog = DialogBuilder.warn(activity,
                                R.string.send_coins_fragment_request_payment_request_failed_title);
                        dialog.setMessage(getString(
                                R.string.send_coins_fragment_request_payment_request_wrong_signature));
                        dialog.singleDismissButton(null);
                        dialog.show();
                    }
                }

                @Override
                public void onFail(final int messageResId, final Object... messageArgs) {
                    progressDialog.dismiss();

                    final DialogBuilder dialog = DialogBuilder.warn(activity,
                            R.string.send_coins_fragment_request_payment_request_failed_title);
                    dialog.setMessage(getString(messageResId, messageArgs));
                    dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int which) {
                            requestPaymentRequest(paymentRequestUrl);
                        }
                    });
                    dialog.setNegativeButton(R.string.button_dismiss, null);
                    dialog.show();
                }
            }, application.httpUserAgent()).requestPaymentRequest(paymentRequestUrl);
}

From source file:com.piggate.sdk.Piggate.java

public boolean validateCard(String cardNumber, int cardExpMonth, int cardExpYear, String cardCVC, String token,
        Context context, String title, String msg) {

    final PiggateCard creditCard = new PiggateCard(cardNumber, cardCVC, cardExpMonth, cardExpYear);
    Card card = new Card(cardNumber, cardExpMonth, cardExpYear, cardCVC); //Create the Card object
    if (card.validateCard()) { //Validate the credit card
        final ProgressDialog loadingDialog = ProgressDialog.show(context, title, msg, true);
        //Create the Stripe token
        new Stripe().createToken(card, token, new TokenCallback() {
            public void onSuccess(Token token) { //If create the token successfully
                creditCard.setTokenID(token.getId()); //Set the token ID in the PiggateCard object
                addCreditCard(creditCard); //Add the credit card to the ArrayList
                loadingDialog.dismiss();
            }//  w  w w .j ava 2 s .co  m

            public void onError(Exception error) { //If there's an error creating the token
                //Handle the error
                loadingDialog.dismiss();
            }
        });
        return true; //Return true if card is validated
    } else
        return false; //Return false if card is not validated
}

From source file:com.yi4all.rupics.ImageDetailActivity.java

private void initBtn() {
    topBarPanel = findViewById(R.id.image_top_bar);
    topBarPanel.setVisibility(View.GONE);

    popMenuPanel = findViewById(R.id.image_pop_menu);

    TextView tv = (TextView) findViewById(R.id.image_title_txt);
    tv.setText(issue.getCategory().getName() + "-" + issue.getName());

    ImageView back = (ImageView) findViewById(R.id.image_back_btn);
    back.setOnClickListener(new OnClickListener() {

        @Override/*from ww w .ja v  a 2s .  c o m*/
        public void onClick(View v) {
            finish();
        }
    });

    ImageView pop = (ImageView) findViewById(R.id.image_pop_btn);
    pop.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (popMenuPanel.getVisibility() == View.VISIBLE) {
                popMenuPanel.setVisibility(View.GONE);
            } else {
                popMenuPanel.setVisibility(View.VISIBLE);
            }
        }
    });

    //      final TextView wallpaperBtn = (TextView) findViewById(R.id.wallpaperBtn);

    final TextView slideshowBtn = (TextView) findViewById(R.id.slideshowBtn);

    final TextView shareBtn = (TextView) findViewById(R.id.shareBtn);

    final TextView downloadBtn = (TextView) findViewById(R.id.downloadBtn);

    //      wallpaperBtn.setOnClickListener(new OnClickListener() {
    //         public void onClick(View v) {
    //            String img = imgList.get(imageSequence).getUrl();
    //            String path = Utils.convertUrl2Path(ImageDetailActivity.this, img);
    //            if (path != null && new File(path).exists()) {
    //               try {
    //                  ImageDetailActivity.this.setWallpaper(BitmapFactory.decodeFile(path));
    //               } catch (IOException e) {
    //                  e.printStackTrace();
    //               }
    //            } else {
    //               // give a tip to user
    //               Utils.toastMsg(ImageDetailActivity.this, R.string.noImageWallpaper);
    //            }
    //            Utils.toastMsg(ImageDetailActivity.this, R.string.setWallpaperSuccess);
    //         }
    //      });

    slideshowBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            isSlideshow = !isSlideshow;
            if (isSlideshow) {

                startSlideShow();
                topBarPanel.setVisibility(View.GONE);
                popMenuPanel.setVisibility(View.GONE);

                slideshowBtn.setText(R.string.slideshow_pause);
            } else {
                topBarPanel.setVisibility(View.VISIBLE);

                slideshowBtn.setText(R.string.slideshow);
            }

        }
    });

    shareBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //            Intent intent = createShareIntent();
            byte[] bytes = getCurrentImage();
            if (bytes == null) {
                Utils.toastMsg(ImageDetailActivity.this, R.string.noImageShare);
            } else {
                //             ImageDetailActivity.this.startActivity(intent);
                popMenuPanel.setVisibility(View.GONE);
                UMServiceFactory.shareTo(ImageDetailActivity.this, getString(R.string.shareImageMmsBody),
                        bytes);
            }

        }
    });

    downloadBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (getService().sureLimitation()) {
                popMenuPanel.setVisibility(View.GONE);

                final ProgressDialog pd = ProgressDialog.show(ImageDetailActivity.this,
                        getString(R.string.waitTitle), getString(R.string.downloadAllImage), false, false);
                final Handler handler = new Handler() {
                    int current = 0;
                    int total = imgList.size();
                    int size = 0;

                    @Override
                    public void handleMessage(Message msg) {
                        current++;

                        pd.setMessage(getString(R.string.downloadAllImage) + current + "/" + total);

                        if (msg.arg2 > 0) {
                            size += msg.arg2;
                        }

                        if (current >= total) {
                            if (size > 0) {
                                getService().addUserConsumedKbytes(size);
                            }
                            pd.dismiss();
                        }
                    }
                };
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        for (ImageModel im : imgList) {
                            String imgUrl = im.getUrl();
                            String path = Utils.convertUrl2Path(ImageDetailActivity.this, imgUrl);
                            util.runSaveUrl(path, imgUrl, handler);
                        }

                    }
                }).start();
            }
        }
    });

}

From source file:com.ccxt.whl.activity.LoginActivity.java

/**
 * //  ww w .  j  ava2s.c om
 * 
 * @param view
 */
public void login(View view) {
    if (!CommonUtils.isNetWorkConnected(this)) {
        Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;
    }
    final String email = usernameEditText.getText().toString();
    final String password = passwordEditText.getText().toString();
    if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
        progressShow = true;
        final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
        pd.setCanceledOnTouchOutside(false);
        pd.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                progressShow = false;
            }
        });
        pd.setMessage("...");
        pd.show();
        // sdk??
        RequestParams params = new RequestParams();
        params.add("tel_email", email);
        params.add("pwd", MD5.MD5Hash(password));
        params.add("uid", uid);
        HttpRestClient.get(Constant.LOGIN_URL, params, new BaseJsonHttpResponseHandler() {

            @Override
            public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) {
                Log.d("login_res_json" + rawJsonResponse);
                pd.dismiss();
                if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                    Toast.makeText(getApplicationContext(), "?,?", 0)
                            .show();
                    return;
                }
                Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);

                if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) {
                    Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                    String resultStr = "status:" + lm.get("status") + "\n" + "message:" + lm.get("message")
                            + "\n" + "result:" + lm.get("result") + "\n" + "uid:" + result.get("uid") + "\n"
                            + "umd5:" + result.get("umd5") + "\n" + "is_res:" + result.get("is_res") + "\n"
                            + "headurl:" + result.get("headurl") + "\n" + "name:" + result.get("name") + "\n"
                            + "sex:" + result.get("sex") + "\n" + "age:" + result.get("age") + "\n"
                            + "province:" + result.get("province") + "\n" + "city:" + result.get("city") + "\n"
                            + "pwd:" + result.get("pwd") + "\n";
                    Log.d("login_res_obj" + resultStr);
                    //???id nullsaveinfo Preference
                    //DemoApplication.getInstance().setUser(result.get("umd5").toString());
                    //System.out.println("========================"+result.get("umd5").toString());
                    /********/
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserPic(result.get("headurl").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserNickName(result.get("name").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserSex(result.get("sex").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserAge(result.get("age").toString());
                    PreferenceUtils.getInstance(getBaseContext()).setSettingUserArea(
                            result.get("province").toString() + " " + result.get("city").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserZhiye(result.get("zhiye").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserQianming(result.get("qianming").toString());

                    String huanxin_username = result.get("umd5").toString();
                    String huanxin_pwd = result.get("pwd").toString();
                    Log.d("log huanxin_username:" + huanxin_username + "|huanxin_pwd:" + huanxin_pwd);

                    //?? 
                    login(huanxin_username, huanxin_pwd);

                    /*???
                    progressShow = false;
                    pd.dismiss();*/

                } else {
                    Toast.makeText(getApplicationContext(), lm.get("message").toString(), 0).show();
                }

            }

            @Override
            public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                    Object errorResponse) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "?,?", 0).show();
            }

            @Override
            protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
                // TODO Auto-generated method stub
                return null;
            }

        });
    }
}

From source file:net.vexelon.myglob.fragments.InvoiceFragment.java

@SuppressWarnings("unchecked")
public void update() {
    if (Defs.LOG_ENABLED)
        Log.d(Defs.LOG_TAG, "Updating invoice ...");

    final FragmentActivity activity = getActivity();

    if (UsersManager.getInstance().size() > 0) {

        // show progress
        final ProgressDialog myProgress = ProgressDialog.show(activity,
                getResString(R.string.dlg_progress_title), getResString(R.string.dlg_progress_message), true);

        new Thread() {
            public void run() {
                try {
                    final User user = UsersManager.getInstance()
                            .getUserByPhoneNumber(GlobalSettings.getInstance().getLastSelectedPhoneNumber());

                    final ActionResult actionResult = new InvoiceUpdateAction(activity, user).execute();

                    // update text field
                    activity.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            updateInvoiceView(user, (List<Map<String, String>>) actionResult.getListResult());
                            // notify listeners that invoice was updated
                            for (IFragmentEvents listener : listeners) {
                                listener.onFEvent_InvoiceUpdated(user);
                            }/* w ww  .j a v  a  2  s. c om*/
                        }
                    });

                    // close progress bar dialog
                    activity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            myProgress.dismiss();
                        }
                    });

                } catch (ActionExecuteException e) {
                    Log.e(Defs.LOG_TAG, "Error updating invoice!", e);

                    // close progress bar dialog
                    activity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            myProgress.dismiss();
                        }
                    });

                    // Show error dialog
                    if (e.isErrorResIdAvailable()) {
                        Utils.showAlertDialog(activity, e.getErrorResId(), e.getErrorTitleResId());
                    } else {
                        Utils.showAlertDialog(activity, e.getMessage(), getResString(e.getErrorTitleResId()));
                    }
                }
            };
        }.start();
    } else {
        // show add user screen
        Toast.makeText(this.getActivity().getApplicationContext(), R.string.text_account_add_new,
                Toast.LENGTH_SHORT).show();

    }
}

From source file:com.piggate.sdk.Piggate.java

public boolean validateCard(String cardNumber, int cardExpMonth, int cardExpYear, String cardCVC, String token,
        Context context) {//w  w w .jav  a2  s. com

    final PiggateCard creditCard = new PiggateCard(cardNumber, cardCVC, cardExpMonth, cardExpYear);
    Card card = new Card(cardNumber, cardExpMonth, cardExpYear, cardCVC); //Create the Card object for Stripe validator
    if (card.validateCard()) { //Validate the credit card
        final ProgressDialog loadingDialog = ProgressDialog.show(context, "Validating", "Creating token...",
                true);
        //Create the Stripe token
        new Stripe().createToken(card, token, new TokenCallback() {
            public void onSuccess(Token token) { //If create the token successfully
                creditCard.setTokenID(token.getId()); //Set the token ID in the PiggateCard object
                addCreditCard(creditCard); //Add the credit card to the ArrayList
                loadingDialog.dismiss();
            }

            public void onError(Exception error) { //If there's an error creating the token
                //Handle the error
                loadingDialog.dismiss();
            }
        });
        return true; //Return true if card is validated
    } else
        return false; //Return false if card is not validated
}