List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:bikebadger.RideFragment.java
public void SaveGPXFileOnNewThreadWithDialog(final String path) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); final File gpxFile = new File(path); pd.setMessage("Saving \"" + gpxFile.getName() + "\""); pd.setIndeterminate(true);// w ww . ja v a 2 s . c om pd.setCancelable(false); pd.show(); Thread mThread = new Thread() { @Override public void run() { mRideManager.ExportWaypointsTrack(); pd.dismiss(); if (mRideManager.mWaypoints != null) { getActivity().runOnUiThread(new Runnable() { public void run() { //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show(); MyToast.Show(getActivity(), "\"" + gpxFile.getName() + "\" saved", Color.BLACK); } }); } } }; mThread.start(); }
From source file:cn.ucai.foraging.activity.ContactlistFragment.java
/** * user???// w w w. j a v a2s .c o m */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(cn.ucai.foraging.R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(cn.ucai.foraging.R.string.Move_into_blacklist_success); final String st3 = getResources().getString(cn.ucai.foraging.R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, 0).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, 0).show(); } }); } } }).start(); }
From source file:cn.ucai.foraging.activity.ContactlistFragment.java
/** * ?/* w ww . j a v a2 s .com*/ * * @param toDeleteUser */ public void deleteContact(final User tobeDeleteUser) { String st1 = getResources().getString(cn.ucai.foraging.R.string.deleting); final String st2 = getResources().getString(cn.ucai.foraging.R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show(); } }); } } }).start(); }
From source file:com.imalu.alyou.activity.LoginActivity.java
/** * /*www . j a va 2 s . com*/ * * @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 username = usernameEditText.getText().toString(); final String password = passwordEditText.getText().toString(); //AlUApplication.currentUserNick = usernameEditText.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(); LoginRequest loginReq = new LoginRequest(); loginReq.setUsername(username); loginReq.setPassword(password); NetManager.execute(NetManager.LOGIN_REQUEST_OPERATION, loginReq, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { pd.dismiss(); Log.e("login_check", " response:" + response.toString()); UserInfo userInfo = new UserInfo(); userInfo.setJsonObject(response); AlUApplication.getMyInfo().setPhoneNum(username); AlUApplication.getMyInfo().setPassword(password); AlUApplication.getMyInfo().setHxname(userInfo.getHXName()); AlUApplication.getMyInfo().setId(userInfo.getID()); AlUApplication.getMyInfo().setUsername(userInfo.getUserName()); AlUApplication.getMyInfo().setKey(userInfo.getKey()); AlUApplication.getMyInfo().setJifen(userInfo.getJifen()); AlUApplication.getMyInfo().setAge(userInfo.getAge()); AlUApplication.getMyInfo().setLocus(userInfo.getLocus()); AlUApplication.getMyInfo().setRealname(userInfo.getRealName()); AlUApplication.getMyInfo().setSex(userInfo.getSex()); AlUApplication.getMyInfo().setSocietykey(userInfo.getSocietyKey()); AlUApplication.getMyInfo().setJiarugonghuikey(userInfo.getJiaruGonghuiKey()); AlUApplication.getMyInfo().setSocietyName(userInfo.getSocietyName()); PersonalInfoResponse personal = new PersonalInfoResponse(); personal.setJsonObject(response); AlUApplication.getUserfans().setId(personal.getId()); AlUApplication.getUserfans().setJifen(personal.getJifen()); AlUApplication.getUserfans().setUserName(personal.getUserName()); AlUApplication.getUserfans().setSocietyName(personal.getSocietyName()); // ????? AlUApplication.getInstance().setUserName(username); AlUApplication.getInstance().setPassword(password); User user = new User(); user.setId((long) userInfo.getID()); user.setUsername(username); user.setPassword(password); user.setChatuser(userInfo.getHXName()); saveUserToDB(user); /* runOnUiThread(new Runnable() { public void run() { pd.setMessage("..."); } }); */ EMChatManager.getInstance().login(userInfo.getHXName(), userInfo.getHXPwd(), new EMCallBack() { @Override public void onSuccess() { EMChatManager.getInstance().loadAllConversations(); } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub } @Override public void onError(int code, String message) { // TODO Auto-generated method stub } }); // ** ?logout?? // ** manually load all local groups and // conversations in case we are auto login //EMGroupManager.getInstance().loadAllGroups(); // demo??????username?? /*List<String> usernames = EMContactManager.getInstance().getContactUserNames(); EMLog.d("roster", "contacts size: " + usernames.size()); for (String username : usernames) { User user = new User(); user.setUsername(username); setUserHearder(username, user); userlist.put(username, user); }*/ /*Map<String, User> userlist = new HashMap<String, 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);*/ // //AlUApplication.getInstance().setContactList(userlist); // db //UserDao dao = new UserDao(LoginActivity.this); //List<User> users = new ArrayList<User>(userlist.values()); //dao.saveContactList(users); // ??(??groupidgroupname????members),sdkdb //EMGroupManager.getInstance().getGroupsFromServer();*/ } catch (Exception e) { e.printStackTrace(); } //?nickname ios?nick //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick); //if (!updatenick) { // EMLog.e("LoginActivity", "update current user nick fail"); //} //if (!LoginActivity.this.isFinishing()) //pd.dismiss(); // ? startActivity(new Intent(LoginActivity.this, MainActivity.class)); finish(); } @Override public void onFailure(int statusCode, Header[] headers, final String responseString, Throwable throwable) { if (!progressShow) { return; } pd.dismiss(); runOnUiThread(new Runnable() { public void run() { //pd.dismiss(); //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show(); } }); } }); } }
From source file:fm.smart.r1.activity.CreateSoundActivity.java
public void onClick(View v) { String threegpfile_name = "test.3gp_amr"; String amrfile_name = "test.amr"; File dir = this.getDir("sounds", MODE_WORLD_READABLE); final File threegpfile = new File(dir, threegpfile_name); File amrfile = new File(dir, amrfile_name); String path = threegpfile.getAbsolutePath(); Log.d("CreateSoundActivity", path); Log.d("CreateSoundActivity", (String) button.getText()); if (button.getText().equals("Start")) { try {/* w ww . j a v a 2 s.com*/ recorder = new MediaRecorder(); // ContentValues values = new ContentValues(3); // // values.put(MediaStore.MediaColumns.TITLE, "test"); // values.put(MediaStore.MediaColumns.DATE_ADDED, // System.currentTimeMillis()); // values.put(MediaStore.MediaColumns.MIME_TYPE, // MediaRecorder.OutputFormat.THREE_GPP); // // ContentResolver contentResolver = new ContentResolver(this); // // Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI; // Uri newUri = contentResolver.insert(base, values); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); button.setText("Stop"); recorder.start(); } catch (Exception e) { Log.w(TAG, e); } } else { FileOutputStream os = null; FileInputStream is = null; try { recorder.stop(); recorder.release(); // Now the object cannot be reused button.setEnabled(false); // ThreegpReader tr = new ThreegpReader(threegpfile); // os = new FileOutputStream(amrfile); // tr.extractAmr(os); is = new FileInputStream(threegpfile); playSound(is.getFD()); final String media_entity = "http://test.com/test.mp3"; final String author = "tansaku"; final String author_url = "http://smart.fm/users/tansaku"; if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); LoginActivity.return_to = CreateSoundActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", item_id); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("id", id); LoginActivity.params.put("to_record", to_record); LoginActivity.params.put("sound_type", sound_type); startActivity(intent); } else { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Sound ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_sound = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ CreateSoundActivity.create_sound_result = createSound(threegpfile, media_entity, author, author_url, "1", id); myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_sound.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_sound.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_sound.start(); } } catch (Exception e) { Log.w(TAG, e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (is != null) { try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
From source file:org.alfresco.mobile.android.application.fragments.operations.OperationWaitingDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { setRetainInstance(true);/*from ww w. j av a 2 s . com*/ if (getArguments() != null) { operationType = getArguments().getInt(PARAM_TYPEID); intentId = getArguments().getString(PARAM_INTENTID); iconId = getArguments().getInt(PARAM_ICONID); title = getArguments().getString(PARAM_TITLEID); message = getArguments().getString(PARAM_MESSAGEID); parent = getArguments().getParcelable(PARAM_NODEID); nbItems = getArguments().getInt(PARAM_SIZE); } ProgressDialog dialog = new ProgressDialog(getActivity()); if (iconId == 0) { iconId = R.drawable.ic_alfresco_logo; } dialog.setIcon(iconId); dialog.setTitle(title); if (message == null) { message = getString(R.string.waiting_operations); } dialog.setMessage(message); boolean indeterminate = true; if (nbItems > 0) { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(nbItems); indeterminate = false; } else { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this); return dialog; }
From source file:com.eason.marker.emchat.chatuidemo.activity.ContactlistFragment.java
/** * ?/*from ww w. j a va 2 s. com*/ */ public void deleteContact(final EMUser tobeDeleteEMUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteEMUser.getUsername()); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteEMUser.getUsername()); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .remove(tobeDeleteEMUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteEMUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); GreenToast.makeText(getActivity(), st2 + e.getMessage(), 1).show(); } }); } } }).start(); }
From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java
/** * user???//from w w w . j a v a 2 s . c o m */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show(); } }); } } }).start(); }
From source file:com.dlam.fragment.ContactlistFragment.java
/** * ?//w w w. java 2 s . c om * * @param toDeleteUser */ public void deleteContact(final User tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show(); } }); } } }).start(); }
From source file:com.easemob.chatuidemo.activity.NewGroupActivity.java
public void setGroup(final String groupName, final String groupIntroduce, final String open, final String number, final String allow_invite) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage(""); pd.setCanceledOnTouchOutside(false); pd.show();/*from w w w. jav a 2 s .c o m*/ Log.i("FriMsg", groupName + groupIntroduce + open + number + allow_invite); RequestQueue requestQueue = Volley.newRequestQueue(this); requestQueue.start(); requestQueue.add(new AutoLoginRequest(this, Request.Method.POST, Model.PathLoad, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.i("FriMsg", response.toString()); try { if (response.getString("status").equals("0")) { Toast.makeText(NewGroupActivity.this, "?", 0).show(); NewGroupActivity.this.finish(); } } catch (Exception e) { Log.e("Activity_boshu_FriMsg", "?"); } pd.dismiss(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.i("FriMsg", error.getMessage()); pd.dismiss(); } }) { @Override protected void setParams(Map<String, String> params) { params.put("sys", "msg"); params.put("ctrl", "msger"); params.put("action", "crt_group"); params.put("group_name", groupName); params.put("introduce", groupIntroduce); params.put("maxusers", "5000"); params.put("public", open); params.put("approval", "1"); params.put("members", number); params.put("allow_invite", allow_invite); } }); }