List of usage examples for android.app ProgressDialog setMessage
@Override public void setMessage(CharSequence message)
From source file:org.runnerup.export.UploadManager.java
protected void doListWorkout(final Uploader uploader) { final ProgressDialog copySpinner = mSpinner; copySpinner.setMessage("Listing from " + uploader.getName()); final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>(); new AsyncTask<Uploader, String, Uploader.Status>() { @Override/*www . j a v a 2 s .c om*/ protected Uploader.Status doInBackground(Uploader... params) { try { return params[0].listWorkouts(list); } catch (Exception ex) { ex.printStackTrace(); return Uploader.Status.ERROR; } } @Override protected void onPostExecute(Uploader.Status result) { switch (result) { case CANCEL: case ERROR: case INCORRECT_USAGE: case SKIP: break; case OK: for (Pair<String, String> w : list) { workoutRef.add(new WorkoutRef(uploader.getName(), w.first, w.second)); } break; case NEED_AUTH: handleAuth(new Callback() { @Override public void run(String uploaderName, org.runnerup.export.Uploader.Status status) { switch (status) { case CANCEL: case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" nextListWorkout(); break; case OK: doListWorkout(uploader); break; } } }, uploader, result.authMethod); return; } nextListWorkout(); } }.execute(uploader); }
From source file:com.ccxt.whl.activity.LoginActivity.java
/** * /*from w ww . ja va 2s .c o m*/ * * @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:com.synox.android.ui.activity.Uploader.java
@Override protected Dialog onCreateDialog(final int id) { final AlertDialog.Builder builder = new Builder(this); switch (id) { case DIALOG_WAITING: final ProgressDialog pDialog = new ProgressDialog(this, R.style.ProgressDialogTheme); pDialog.setIndeterminate(false); pDialog.setCancelable(false);/* w w w. j ava2s . com*/ pDialog.setMessage(getResources().getString(R.string.uploader_info_uploading)); pDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ProgressBar v = (ProgressBar) pDialog.findViewById(android.R.id.progress); v.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.accent), android.graphics.PorterDuff.Mode.MULTIPLY); } }); return pDialog; case DIALOG_NO_ACCOUNT: builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.uploader_wrn_no_account_title); builder.setMessage( String.format(getString(R.string.uploader_wrn_no_account_text), getString(R.string.app_name))); builder.setCancelable(false); builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) { // using string value since in API7 this // constatn is not defined // in API7 < this constatant is defined in // Settings.ADD_ACCOUNT_SETTINGS // and Settings.EXTRA_AUTHORITIES Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT); intent.putExtra("authorities", new String[] { MainApp.getAuthTokenType() }); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } else { // since in API7 there is no direct call for // account setup, so we need to // show our own AccountSetupAcricity, get // desired results and setup // everything for ourself Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class); startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT); } } }); builder.setNegativeButton(R.string.uploader_wrn_no_account_quit_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); case DIALOG_MULTIPLE_ACCOUNT: CharSequence ac[] = new CharSequence[mAccountManager .getAccountsByType(MainApp.getAccountType()).length]; for (int i = 0; i < ac.length; ++i) { ac[i] = DisplayUtils.convertIdn(mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false); } builder.setTitle(R.string.common_choose_account); builder.setItems(ac, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setAccount(mAccountManager.getAccountsByType(MainApp.getAccountType())[which]); onAccountSet(mAccountWasRestored); dialog.dismiss(); mAccountSelected = true; mAccountSelectionShowing = false; } }); builder.setCancelable(true); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mAccountSelectionShowing = false; dialog.cancel(); finish(); } }); return builder.create(); case DIALOG_NO_STREAM: builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.uploader_wrn_no_content_title); builder.setMessage(R.string.uploader_wrn_no_content_text); builder.setCancelable(false); builder.setNegativeButton(R.string.common_cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); return builder.create(); default: throw new IllegalArgumentException("Unknown dialog id: " + id); } }
From source file:com.ccxt.whl.activity.LoginActivity.java
/** * ?/*from w ww. jav a2 s. co m*/ * * @param view */ public void login(final String username, final String password) { if (!CommonUtils.isNetWorkConnected(this)) { Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show(); return; } //final String username = usernameEditText.getText().toString(); //final String password = passwordEditText.getText().toString(); if (!TextUtils.isEmpty(username) && !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?? EMChatManager.getInstance().login(username, password, new EMCallBack() { @Override public void onSuccess() { /***************** * ? *****************/ if (!progressShow) { return; } // ????? // DemoApplication.getInstance().setUserName(username); DemoApplication.getInstance().setUser(username); DemoApplication.getInstance().setPassword(password); DemoApplication.getInstance().setUserNickName(name); runOnUiThread(new Runnable() { public void run() { pd.setMessage("???..."); } }); try { // demo??????username?? List<String> usernames = EMChatManager.getInstance().getContactUserNames(); Map<String, User> userlist = new HashMap<String, User>(); for (String username : usernames) { User user = new User(); user.setUsername(username); setUserHearder(username, user); userlist.put(username, user); } // user"" User newFriends = new User(); newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME); newFriends.setNick(""); newFriends.setHeader(""); userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends); // "?" User groupUser = new User(); groupUser.setUsername(Constant.GROUP_USERNAME); groupUser.setNick("?"); groupUser.setHeader(""); userlist.put(Constant.GROUP_USERNAME, groupUser); // DemoApplication.getInstance().setContactList(userlist); /***?MainActivity?db* / // db UserDao dao = new UserDao(LoginActivity.this); List<User> users = new ArrayList<User>(userlist.values()); dao.saveContactList(users);/**/ // ??,sdkEMGroupManagerdb EMGroupManager.getInstance().getGroupsFromServer(); // after login, we join groups in separate threads; EMGroupManager.getInstance().joinGroupsAfterLogin(); } catch (Exception e) { e.printStackTrace(); } if (!LoginActivity.this.isFinishing()) pd.dismiss(); // ? startActivity(new Intent(LoginActivity.this, MainActivity.class)); finish(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, final String message) { if (!progressShow) { return; } //Log.d("log","code"+code); runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getApplicationContext(), ": " + message, 0).show(); } }); } }); } }
From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java
public void tryConnect(final ProgressDialog pd, final int attempt, final String statusMessage, final RegistrationInfo info) { T.UI();//from w w w .j a va 2 s . c o m final Pausable pausable = this; if (attempt > XMPP_MAX_NUM_ATTEMPTS) { pd.dismiss(); String message = getString(R.string.registration_error); UIUtils.showDialog(mActivity, null, message, getString(R.string.try_again), null, null, null); mWizard.reInit(); mWizard.goBackToPrevious(); return; } pd.setMessage(statusMessage + attempt); if (!pd.isShowing()) pd.show(); L.d("Registration attempt #" + attempt); final String xmppServiceName = info.mCredentials.getXmppServiceName(); final String xmppAccount = info.mCredentials.getXmppAccount(); final String xmppPassword = info.mCredentials.getPassword(); final ConfigurationProvider cp = mService.getConfigurationProvider(); Configuration cfg = cp.getConfiguration(RegistrationWizard2.CONFIGKEY); final String invitorCode = (cfg == null) ? null : cfg.get(INVITOR_CODE_CONFIGKEY, null); final String invitorSecret = (cfg == null) ? null : cfg.get(INVITOR_SECRET_CONFIGKEY, null); Runnable runnable = new SafeRunnable() { @Override public void safeRun() { T.REGISTRATION(); try { if (CloudConstants.USE_XMPP_KICK_CHANNEL) { final ConnectionConfiguration xmppConfig = new XMPPConfigurationFactory(cp, mService.getNetworkConnectivityManager(), null) .getSafeXmppConnectionConfiguration(xmppServiceName); final XMPPConnection xmppCon = new XMPPConnection(xmppConfig); xmppCon.setLogger(new Logger() { @Override public void log(String message) { L.d(message); } }); xmppCon.connect(); xmppCon.login(xmppAccount, xmppPassword); final Thread t2 = new Thread(new SafeRunnable() { @Override protected void safeRun() throws Exception { L.d("REG Before disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); xmppCon.disconnect(); L.d("REG After disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); } }); t2.setDaemon(true); t2.start(); } postFinishRegistration(info.mCredentials.getUsername(), info.mCredentials.getPassword(), invitorCode, invitorSecret); runOnUI(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); mWizard.setCredentials(info.mCredentials); if (CloudConstants.USE_GCM_KICK_CHANNEL && !"".equals(mGCMRegistrationId)) { GoogleServicesUtils.saveGCMRegistrationId(mService, mGCMRegistrationId); } mService.setCredentials(mWizard.getCredentials()); mService.setRegisteredInConfig(true); final Intent launchServiceIntent = new Intent(mActivity, MainService.class); launchServiceIntent.putExtra(MainService.START_INTENT_JUST_REGISTERED, true); launchServiceIntent.putExtra(MainService.START_INTENT_MY_EMAIL, mWizard.getEmail()); mActivity.startService(launchServiceIntent); stopRegistrationService(); pd.dismiss(); mWizard.finish(); // finish } }); } catch (Exception e) { L.d("Exception while trying to end the registration process", e); runOnUI(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); tryConnect(pd, attempt + 1, statusMessage, info); } }); } } }; if (attempt == 1) { runOnWorker(runnable); } else { runDelayedOnWorker(runnable, XMPP_CHECK_DELAY_MILLIS); } }
From source file:com.example.innf.newchangtu.Map.view.activity.MainActivity.java
private void uploadImage() { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage("..."); progressDialog.show();// w w w .j av a2 s . c o m progressDialog.setCancelable(false); final BmobFile photo = new BmobFile(getTrackPhotoFile(mTrack)); photo.upload(new UploadFileListener() { @Override public void done(BmobException e) { if (null == e) { showToast("?"); mTrack.setPhoto(photo); mTrack.update(mTrack.getObjectId(), new UpdateListener() { @Override public void done(BmobException e) { if (null == e) { showToast("??"); } else { showToast("?" + e.getMessage()); } } }); } else { showToast("" + e.getMessage()); } progressDialog.cancel(); } }); }
From source file:export.UploadManager.java
private void doUploadMulti(final Uploader uploader, final long id) { final ProgressDialog copySpinner = mSpinner; final SQLiteDatabase copyDB = mDBHelper.getWritableDatabase(); copySpinner.setMessage(Long.toString(1 + uploadActivities.size()) + " remaining"); new AsyncTask<Uploader, String, Uploader.Status>() { @Override/*from w w w . ja v a 2 s .co m*/ protected Uploader.Status doInBackground(Uploader... params) { try { return uploader.upload(copyDB, id); } catch (Exception ex) { ex.printStackTrace(); return Uploader.Status.ERROR; } } @Override protected void onPostExecute(Uploader.Status result) { switch (result) { case CANCEL: case ERROR: case INCORRECT_USAGE: case SKIP: break; case OK: uploadOK(uploader, copySpinner, copyDB, id); break; case NEED_AUTH: handleAuth(new Callback() { @Override public void run(String uploaderName, export.Uploader.Status status) { switch (status) { case CANCEL: case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" uploadActivities.clear(); uploadNextActivity(uploader); break; case OK: doUploadMulti(uploader, id); break; } } }, uploader, result.authMethod); break; } uploadNextActivity(uploader); } }.execute(uploader); }
From source file:de.mkrtchyan.recoverytools.FlashFragment.java
public void showUnifiedBuildsDialog() { final AppCompatDialog UnifiedBuildsDialog = new AppCompatDialog(mContext); UnifiedBuildsDialog.setTitle(R.string.make_choice); final ArrayList<String> DevName = new ArrayList<>(); ArrayList<String> DevNamesCarriers = new ArrayList<>(); UnifiedBuildsDialog.setContentView(R.layout.dialog_unified_build); ListView UnifiedList = (ListView) UnifiedBuildsDialog.findViewById(R.id.lvUnifiedList); ArrayAdapter<String> UnifiedAdapter = new ArrayAdapter<>(mContext, android.R.layout.simple_list_item_1, DevNamesCarriers);/*from w ww . ja v a 2 s .c o m*/ UnifiedList.setAdapter(UnifiedAdapter); if (mDevice.getManufacture().equals("samsung")) { String[] unifiedGalaxyS3 = { "d2lte", "d2att", "d2cri", "d2mtr", "d2spr", "d2tmo", "d2usc", "d2vzw" }; String[] unifiedGalaxyNote3 = { "hlte", "hltespr", "hltetmo", "hltevzw", "htlexx" }; String[] unifiedGalaxyS4 = { "jflte", "jflteatt", "jfltecan", "jfltecri", "jfltecsp", "jfltespr", "jfltetmo", "jflteusc", "jfltevzw", "jfltexx", "jgedlte" }; if (Common.stringEndsWithArray(mDevice.getName(), unifiedGalaxyS3)) { DevName.addAll(Arrays.asList(unifiedGalaxyS3)); } else if (Common.stringEndsWithArray(mDevice.getName(), unifiedGalaxyS3)) { DevName.addAll(Arrays.asList(unifiedGalaxyNote3)); } else if (Common.stringEndsWithArray(mDevice.getName(), unifiedGalaxyS4)) { DevName.addAll(Arrays.asList(unifiedGalaxyS4)); } } if (mDevice.getManufacture().equals("motorola")) { String[] unifiedMsm8960 = { "moto_msm8960" }; if (mDevice.getBOARD().equals("msm8960")) { DevName.addAll(Arrays.asList(unifiedMsm8960)); } } for (String i : DevName) { if (i.contains("att")) { DevNamesCarriers.add(i + " (AT&T Mobility)"); } else if (i.contains("can")) { DevNamesCarriers.add(i + " (Canada)"); } else if (i.contains("cri")) { DevNamesCarriers.add(i + " (Cricket Wireless)"); } else if (i.contains("csp")) { DevNamesCarriers.add(i + " (C Spire Wireless)"); } else if (i.contains("mtr")) { DevNamesCarriers.add(i + " (MetroPCS)"); } else if (i.contains("spr")) { DevNamesCarriers.add(i + " (Sprint Corporation)"); } else if (i.contains("tmo")) { DevNamesCarriers.add(i + " (T-Mobile US)"); } else if (i.contains("usc")) { DevNamesCarriers.add(i + " (U.S. Cellular)"); } else if (i.contains("vzw")) { DevNamesCarriers.add(i + " (Verizon Wireless)"); } else if (i.contains("xx")) { DevNamesCarriers.add(i + " (International)"); } else if (i.contains("ged")) { DevNamesCarriers.add(i + " (Google Play Edition)"); } else { DevNamesCarriers.add(i + " (Unified)"); } } UnifiedList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int position, long id) { UnifiedBuildsDialog.dismiss(); final ProgressDialog reloading = new ProgressDialog(mContext); reloading.setMessage(mContext.getString(R.string.reloading)); reloading.setCancelable(false); reloading.show(); new Thread(new Runnable() { @Override public void run() { Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, false); mDevice.setName(DevName.get(position)); mDevice.loadRecoveryList(); mActivity.runOnUiThread(new Runnable() { @Override public void run() { reloading.dismiss(); mActivity.switchTo(FlashFragment.newInstance(mActivity)); } }); } }).start(); } }); AppCompatButton KeepCurrent = (AppCompatButton) UnifiedBuildsDialog.findViewById(R.id.bKeepCurrent); KeepCurrent.setText(String.format(getString(R.string.keep_current_name), mDevice.getName())); KeepCurrent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, false); UnifiedBuildsDialog.dismiss(); } }); if (DevName.size() > 0) { UnifiedBuildsDialog.show(); UnifiedBuildsDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, false); } }); } }
From source file:export.UploadManager.java
private void doUpload(final Uploader uploader) { final ProgressDialog copySpinner = mSpinner; final SQLiteDatabase copyDB = mDBHelper.getWritableDatabase(); copySpinner.setMessage("Uploading " + uploader.getName()); new AsyncTask<Uploader, String, Uploader.Status>() { @Override//w w w . java 2 s . co m protected Uploader.Status doInBackground(Uploader... params) { try { return params[0].upload(copyDB, mID); } catch (Exception ex) { ex.printStackTrace(); return Uploader.Status.ERROR; } } @Override protected void onPostExecute(Uploader.Status result) { switch (result) { case CANCEL: disableUploader(disableUploaderCallback, uploader, false); return; case SKIP: case ERROR: case INCORRECT_USAGE: nextUploader(); return; case OK: uploadOK(uploader, copySpinner, copyDB, mID); nextUploader(); return; case NEED_AUTH: // should be handled inside connect "loop" handleAuth(new Callback() { @Override public void run(String uploaderName, Uploader.Status status) { switch (status) { case CANCEL: disableUploader(disableUploaderCallback, uploader, false); return; case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" nextUploader(); return; case OK: doUpload(uploader); return; } } }, uploader, result.authMethod); return; } } }.execute(uploader); }
From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java
/** * Copies an item onto the current destination in the copy preferences * @param item The item to copy//from w ww. j av a 2 s . c o m */ private void copy(final Item item) { final BaseApplication app = (BaseApplication) getActivity().getApplication(); final IOneDriveClient oneDriveClient = app.getOneDriveClient(); final ItemReference parentReference = new ItemReference(); parentReference.id = getCopyPrefs().getString(COPY_DESTINATION_PREF_KEY, null); final ProgressDialog dialog = new ProgressDialog(getActivity(), ProgressDialog.STYLE_HORIZONTAL); dialog.setTitle("Copying item"); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setMessage("Waiting for copy to complete"); final IProgressCallback<Item> progressCallback = new IProgressCallback<Item>() { @Override public void progress(final long current, final long max) { dialog.setMax((int) current); dialog.setMax((int) max); } @Override public void success(final Item item) { dialog.dismiss(); final String string = getString(R.string.copy_success_message, item.name, item.parentReference.path); Toast.makeText(getActivity(), string, Toast.LENGTH_LONG).show(); } @Override public void failure(final ClientException error) { dialog.dismiss(); new AlertDialog.Builder(getActivity()).setTitle(R.string.error_title).setMessage(error.getMessage()) .setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); } }).create().show(); } }; final DefaultCallback<AsyncMonitor<Item>> callback = new DefaultCallback<AsyncMonitor<Item>>( getActivity()) { @Override public void success(final AsyncMonitor<Item> itemAsyncMonitor) { final int millisBetweenPoll = 1000; itemAsyncMonitor.pollForResult(millisBetweenPoll, progressCallback); } }; oneDriveClient.getDrive().getItems(item.id).getCopy(item.name, parentReference).buildRequest() .create(callback); dialog.show(); }