List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:com.commonsware.android.EMusicDownloader.SingleBook.java
public void sampleButtonPressed(View button) { Log.d("EMD - ", "Attempting to play sample"); if (sampleURL.contains("sample")) { final ProgressDialog dialog = ProgressDialog.show(this, "", getString(R.string.getting_sample_loation), true, true);// w w w.j a v a 2s .c o m Thread t5 = new Thread() { public void run() { String addresstemp = ""; try { URL u = new URL(sampleURL); HttpURLConnection c = (HttpURLConnection) u.openConnection(); c.setRequestMethod("GET"); //c.setDoOutput(true); c.setFollowRedirects(true); c.setInstanceFollowRedirects(true); c.connect(); InputStream in = c.getInputStream(); InputStreamReader inputreader = new InputStreamReader(in); BufferedReader buffreader = new BufferedReader(inputreader); String line; // read every line of the file into the line-variable, on line at the time while ((line = buffreader.readLine()).length() > 0) { //Log.d("EMD - ","Read line"+line); if (line.contains(".mp3") || line.contains("samples.emusic") || line.contains("samples.nl.emusic")) { addresstemp = line; //Log.d("EMD - ","Found MP3 Address "+addresstemp); mp3Address = addresstemp; if (!vKilled && dialog.isShowing()) { handlerPlay.sendEmptyMessage(0); } if (dialog.isShowing()) { dialog.dismiss(); } } } in.close(); c.disconnect(); if (dialog.isShowing()) { dialog.dismiss(); } } catch (Exception ef) { Log.d("EMD - ", "Getting mp3 address failed "); if (dialog.isShowing()) { dialog.dismiss(); } } } }; t5.start(); } else { Toast.makeText(thisActivity, R.string.no_sample_available, Toast.LENGTH_SHORT).show(); } }
From source file:fm.smart.r1.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 {/*ww w . j a va2s. co m*/ 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 (LoginActivity.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("goal_id", goal_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", item_id, id, to_record); // this will also ensure item is in goal, but this // should be sentence // submission if we are handling sentence sound. if (sound_type.equals(Integer.toString(R.id.cue_sound))) { CreateSoundActivity.add_item_result = new AddItemResult( Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, CreateSoundActivity.create_sound_result.sound_id)); } else { // ensure item is in goal CreateSoundActivity.add_item_result = new AddItemResult(Main.lookup .addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null)); CreateSoundActivity.add_sentence_result = new AddSentenceResult( Main.lookup.addSentenceToGoal(Main.transport, Main.default_study_goal_id, item_id, id, CreateSoundActivity.create_sound_result.sound_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:dong.lan.tuyi.activity.ContactlistFragment.java
/** * ?/* w ww. java2 s . co m*/ * */ 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 { BmobQuery<TUser> query = new BmobQuery<TUser>(); query.addWhereEqualTo("tUser", tobeDeleteUser.getUsername()); query.findObjects(getActivity(), new FindListener<TUser>() { @Override public void onSuccess(List<TUser> list) { if (list.isEmpty()) { Config.Show(getActivity(), ""); } else { BmobRelation relation = new BmobRelation(); relation.remove(list.get(0)); Config.tUser.update(getActivity(), new UpdateListener() { @Override public void onSuccess() { try { EMContactManager.getInstance() .deleteContact(tobeDeleteUser.getUsername()); } catch (EaseMobException e) { e.printStackTrace(); } // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); TuApplication.getInstance().getContactList() .remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } @Override public void onFailure(int i, String s) { } }); } } @Override public void onError(int i, String s) { } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show(); } }); } } }).start(); }
From source file:com.shafiq.myfeedle.core.OAuthLogin.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);/*w w w.ja v a2 s .c o m*/ mHttpClient = MyfeedleHttpClient.getThreadSafeClient(getApplicationContext()); mLoadingDialog = new ProgressDialog(this); mLoadingDialog.setMessage(getString(R.string.loading)); mLoadingDialog.setCancelable(true); mLoadingDialog.setOnCancelListener(this); mLoadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), this); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { int service = extras.getInt(Myfeedle.Accounts.SERVICE, Myfeedle.INVALID_SERVICE); mServiceName = Myfeedle.getServiceName(getResources(), service); mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); mAccountId = extras.getLong(Myfeedle.EXTRA_ACCOUNT_ID, Myfeedle.INVALID_ACCOUNT_ID); mMyfeedleWebView = new MyfeedleWebView(); final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<String, Void, String> asyncTask = new AsyncTask<String, Void, String>() { @Override protected String doInBackground(String... args) { try { return mMyfeedleOAuth.getAuthUrl(args[0], args[1], args[2], args[3], Boolean.parseBoolean(args[4]), mHttpClient); } catch (OAuthMessageSignerException e) { e.printStackTrace(); } catch (OAuthNotAuthorizedException e) { e.printStackTrace(); } catch (OAuthExpectationFailedException e) { e.printStackTrace(); } catch (OAuthCommunicationException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String url) { if (loadingDialog.isShowing()) loadingDialog.dismiss(); // load the webview if (url != null) { mMyfeedleWebView.open(url); } else { (Toast.makeText(OAuthLogin.this, String.format(getString(R.string.oauth_error), mServiceName), Toast.LENGTH_LONG)).show(); OAuthLogin.this.finish(); } } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); dialog.cancel(); OAuthLogin.this.finish(); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); dialog.cancel(); OAuthLogin.this.finish(); } }); switch (service) { case TWITTER: mMyfeedleOAuth = new MyfeedleOAuth(TWITTER_KEY, TWITTER_SECRET); asyncTask.execute(String.format(TWITTER_URL_REQUEST, TWITTER_BASE_URL), String.format(TWITTER_URL_ACCESS, TWITTER_BASE_URL), String.format(TWITTER_URL_AUTHORIZE, TWITTER_BASE_URL), TWITTER_CALLBACK.toString(), Boolean.toString(true)); loadingDialog.show(); break; case FACEBOOK: mMyfeedleWebView.open(String.format(FACEBOOK_URL_AUTHORIZE, FACEBOOK_BASE_URL, FACEBOOK_ID, FACEBOOK_CALLBACK.toString())); break; // case MYSPACE: // mMyfeedleOAuth = new MyfeedleOAuth(MYSPACE_KEY, MYSPACE_SECRET); // asyncTask.execute(MYSPACE_URL_REQUEST, MYSPACE_URL_ACCESS, MYSPACE_URL_AUTHORIZE, MYSPACE_CALLBACK.toString(), Boolean.toString(true)); // loadingDialog.show(); // break; case FOURSQUARE: mMyfeedleWebView.open(String.format(FOURSQUARE_URL_AUTHORIZE, FOURSQUARE_KEY, FOURSQUARE_CALLBACK.toString())); break; case LINKEDIN: mMyfeedleOAuth = new MyfeedleOAuth(LINKEDIN_KEY, LINKEDIN_SECRET); asyncTask.execute(LINKEDIN_URL_REQUEST, LINKEDIN_URL_ACCESS, LINKEDIN_URL_AUTHORIZE, LINKEDIN_CALLBACK.toString(), Boolean.toString(true)); loadingDialog.show(); break; case SMS: Cursor c = getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID }, Accounts.SERVICE + "=?", new String[] { Integer.toString(SMS) }, null); if (c.moveToFirst()) { (Toast.makeText(OAuthLogin.this, "SMS has already been added.", Toast.LENGTH_LONG)).show(); } else { addAccount(getResources().getStringArray(R.array.service_entries)[SMS], null, null, 0, SMS, null); } c.close(); finish(); break; case RSS: // prompt for RSS url final EditText rss_url = new EditText(this); rss_url.setSingleLine(); new AlertDialog.Builder(OAuthLogin.this).setTitle(R.string.rss_url).setView(rss_url) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { // test the url and add if valid, else Toast error mLoadingDialog.show(); (new AsyncTask<String, Void, String>() { String url; @Override protected String doInBackground(String... params) { url = rss_url.getText().toString(); return MyfeedleHttpClient.httpResponse(mHttpClient, new HttpGet(url)); } @Override protected void onPostExecute(String response) { mLoadingDialog.dismiss(); if (response != null) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; try { db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(response)); Document doc = db.parse(is); // test parsing... NodeList nodes = doc.getElementsByTagName(Sitem); if (nodes.getLength() > 0) { // check for an image NodeList images = doc.getElementsByTagName(Simage); if (images.getLength() > 0) { NodeList imageChildren = images.item(0).getChildNodes(); Node n = imageChildren.item(0); if (n.getNodeName().toLowerCase().equals(Surl)) { if (n.hasChildNodes()) { n.getChildNodes().item(0).getNodeValue(); } } } NodeList children = nodes.item(0).getChildNodes(); String date = null; String title = null; String description = null; String link = null; int values_count = 0; for (int child = 0, c2 = children.getLength(); (child < c2) && (values_count < 4); child++) { Node n = children.item(child); if (n.getNodeName().toLowerCase().equals(Spubdate)) { values_count++; if (n.hasChildNodes()) { date = n.getChildNodes().item(0).getNodeValue(); } } else if (n.getNodeName().toLowerCase() .equals(Stitle)) { values_count++; if (n.hasChildNodes()) { title = n.getChildNodes().item(0) .getNodeValue(); } } else if (n.getNodeName().toLowerCase() .equals(Sdescription)) { values_count++; if (n.hasChildNodes()) { StringBuilder sb = new StringBuilder(); NodeList descNodes = n.getChildNodes(); for (int dn = 0, dn2 = descNodes .getLength(); dn < dn2; dn++) { Node descNode = descNodes.item(dn); if (descNode .getNodeType() == Node.TEXT_NODE) { sb.append(descNode.getNodeValue()); } } // strip out the html tags description = sb.toString() .replaceAll("\\<(.|\n)*?>", ""); } } else if (n.getNodeName().toLowerCase() .equals(Slink)) { values_count++; if (n.hasChildNodes()) { link = n.getChildNodes().item(0).getNodeValue(); } } } if (Myfeedle.HasValues( new String[] { title, description, link, date })) { final EditText url_name = new EditText(OAuthLogin.this); url_name.setSingleLine(); new AlertDialog.Builder(OAuthLogin.this) .setTitle(R.string.rss_channel) .setView(url_name) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog1, int which) { addAccount( url_name.getText() .toString(), null, null, 0, RSS, url); dialog1.dismiss(); dialog.dismiss(); finish(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog1, int which) { dialog1.dismiss(); dialog.dismiss(); finish(); } }) .show(); } else { (Toast.makeText(OAuthLogin.this, "Feed is missing standard fields", Toast.LENGTH_LONG)).show(); } } else { (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } } catch (ParserConfigurationException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } catch (SAXException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } catch (IOException e) { Log.e(TAG, e.toString()); (Toast.makeText(OAuthLogin.this, "Invalid feed", Toast.LENGTH_LONG)).show(); dialog.dismiss(); finish(); } } else { (Toast.makeText(OAuthLogin.this, "Invalid URL", Toast.LENGTH_LONG)) .show(); dialog.dismiss(); finish(); } } }).execute(rss_url.getText().toString()); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }).show(); break; // case IDENTICA: // mMyfeedleOAuth = new MyfeedleOAuth(IDENTICA_KEY, IDENTICA_SECRET); // asyncTask.execute(String.format(IDENTICA_URL_REQUEST, IDENTICA_BASE_URL), String.format(IDENTICA_URL_ACCESS, IDENTICA_BASE_URL), String.format(IDENTICA_URL_AUTHORIZE, IDENTICA_BASE_URL), IDENTICA_CALLBACK.toString(), Boolean.toString(true)); // loadingDialog.show(); // break; case GOOGLEPLUS: mMyfeedleWebView.open( String.format(GOOGLEPLUS_AUTHORIZE, GOOGLE_CLIENTID, "urn:ietf:wg:oauth:2.0:oob")); break; // case CHATTER: // mMyfeedleWebView.open(String.format(CHATTER_URL_AUTHORIZE, CHATTER_KEY, CHATTER_CALLBACK.toString())); // break; case PINTEREST: Cursor pinterestAccount = getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID }, Accounts.SERVICE + "=?", new String[] { Integer.toString(PINTEREST) }, null); if (pinterestAccount.moveToFirst()) { (Toast.makeText(OAuthLogin.this, "Pinterest has already been added.", Toast.LENGTH_LONG)) .show(); } else { (Toast.makeText(OAuthLogin.this, "Pinterest currently allows only public, non-authenticated viewing.", Toast.LENGTH_LONG)).show(); String[] values = getResources().getStringArray(R.array.service_values); String[] entries = getResources().getStringArray(R.array.service_entries); for (int i = 0, l = values.length; i < l; i++) { if (Integer.toString(PINTEREST).equals(values[i])) { addAccount(entries[i], null, null, 0, PINTEREST, null); break; } } } pinterestAccount.close(); finish(); break; default: this.finish(); } } } }
From source file:org.androidpn.demoapp.MessageListActivity.java
private void checkIfAnyNewData() { final ProgressDialog checkDialog = new ProgressDialog(this); checkDialog.setMessage(getString(R.string.check_new_data)); checkDialog.show();/*from ww w .j a v a 2 s .c om*/ getSupportLoaderManager().restartLoader(LOADER_ONLINE_ID, null, new LoaderManager.LoaderCallbacks<MessageListResponse>() { @Override public Loader<MessageListResponse> onCreateLoader(int id, Bundle args) { String identity = MobilePushApp.getInstance().getUserIdentity(); String url = Constants.getMessageList(identity, ""); LoadContext<MessageListResponse> loadContext = new LoadContext<MessageListResponse>(); loadContext.setFlag(LoadContext.FLAG_HTTP_ONLY); loadContext.setClazz(MessageListResponse.class); loadContext.setParam(url); return new JsonLoaderJeallyBean<MessageListResponse>(MessageListActivity.this, loadContext, new Configuration.CREATOR().setExpiration(Constants.EXPIRATION_TIME) .setCacheDir(getCacheDir().toString()).create()); } @Override public void onLoadFinished(Loader<MessageListResponse> loader, MessageListResponse data) { if (data != null && data.getResultCode().equals("1") && data.getList().size() > 0) { if (!((SingleMessage) mAdapter.getItem(0)).getId().equals(data.getList().get(0).getId()) || manualRefresh) { getContentResolver().delete(ServerMessage.CONTENT_URI, null, null); saveData(data.getList()); mAdapter = new MessageListAdapter(MessageListActivity.this, data.getList()); mListView.setAdapter(mAdapter); mAdapter.notifyDataSetChanged(); latestId = ((SingleMessage) (mAdapter.getItem(mAdapter.getCount() - 1))).getId(); } } if (checkDialog.isShowing()) checkDialog.dismiss(); manualRefresh = false; mListView.onRefreshComplete(); } @Override public void onLoaderReset(Loader<MessageListResponse> loader) { } }); }
From source file:com.cellbots.logger.LoggerActivity.java
@Override public void onPrepareDialog(int id, Dialog dialog, Bundle bundle) { super.onPrepareDialog(id, dialog, bundle); if (id != PROGRESS_ID) { return;/* www. ja va2 s. c om*/ } final ProgressDialog progressDialog = (ProgressDialog) dialog; progressDialog.setMessage("Processing..."); final Handler handler = new Handler() { @Override public void handleMessage(android.os.Message msg) { int done = msg.getData().getInt("percentageDone"); String status = msg.getData().getString("status"); progressDialog.setProgress(done); progressDialog.setMessage(status); if (mRemoteControl != null) { mRemoteControl.broadcastMessage("Zipping Progress: " + done + "%\n"); } } }; zipperThread = new Thread() { @Override public void run() { if (useZip) { ZipItUpRequest request = new ZipItUpRequest(); String directoryName = application.getLoggerPathPrefix(); request.setInputFiles(new FileListFetcher().getFilesAndDirectoriesInDir(directoryName)); request.setOutputFile(directoryName + "/logged-data.zip"); request.setMaxOutputFileSize(MAX_OUTPUT_ZIP_CHUNK_SIZE); request.setDeleteInputfiles(true); request.setCompressionLevel(Deflater.NO_COMPRESSION); try { new ZipItUpProcessor(request).chunkIt(handler); } catch (IOException e) { Log.e("Oh Crap!", "IoEx", e); } } // closing dialog progressDialog.dismiss(); application.generateNewFilePathUniqueIdentifier(); // TODO: Need to deal with empty directories that are created if // another recording // session is never started. initSensorLogFiles(); if (mCamcorderView != null) { try { mCamcorderView.startPreview(); if (mRemoteControl != null) mRemoteControl.broadcastMessage("*** Packaging Finished: OK to start ***\n"); } catch (RuntimeException e) { e.printStackTrace(); runOnUiThread(new Runnable() { // @Override @Override public void run() { Toast.makeText(getApplicationContext(), "Camera hardware error. Please restart the application.", Toast.LENGTH_LONG) .show(); } }); finish(); return; } } } }; zipperThread.start(); }
From source file:com.doplgangr.secrecy.views.FilesListFragment.java
void updateVaultInBackground(final ProgressDialog progress) { new Thread(new Runnable() { @Override/* w w w . j a v a 2 s . c o m*/ public void run() { try { if (secret.updateFromECBVault(password)) { Util.alert(context, getString(R.string.Vault__vault_updated), getString(R.string.Vault__vault_updated_message), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); } }, null); } else { secret.ecbUpdateFailed(); Util.alert(context, getString(R.string.Error__updating_vault), getString(R.string.Error__updating_vault_message), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); } }, null); } } catch (Exception e) { secret.ecbUpdateFailed(); Util.alert(context, getString(R.string.Error__updating_vault), getString(R.string.Error__updating_vault_message), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finish(); } }, null); } progress.dismiss(); } }).start(); }
From source file:net.gerosyab.dailylog.activity.MainActivity.java
private void exportCategory(final long id) { //?? ? ?? csv //? ?? ?? //from www. j a v a 2s. co m // ? ? ? ? Category category = categories.get((int) id); ProgressDialog progressDialog = new ProgressDialog(MainActivity.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setTitle("Exporting data [" + category.getName() + "]"); progressDialog.show(); String filename = category.getName() + "" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".data"; FileOutputStream outputStream = null; File resultFilePath = null; File resultFile = null; CSVWriter cw = null; try { resultFile = new File(context.getCacheDir(), filename); outputStream = new FileOutputStream(resultFile.getAbsolutePath()); // cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"),'\t', '"'); cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"), ',', '"'); // Export Data String[] metaDataStr = { "Version:" + AppDatabase.VERSION, "Name:" + category.getName(), "Unit:" + category.getUnit(), "Type:" + category.getRecordType(), "DefaultValue:" + category.getDefaultValue(), "Columns:date(yyyy-MM-dd 24HH:mm:ss)/value(boolean|numeric|string)" }; cw.writeNext(metaDataStr); List<Record> records = category.getRecordsOrderByDateAscending(realm); for (Record record : records) { String value = null; if (category.getRecordType() == StaticData.RECORD_TYPE_BOOLEAN) { value = "true"; } else if (category.getRecordType() == StaticData.RECORD_TYPE_NUMBER) { value = "" + record.getNumber(); } else if (category.getRecordType() == StaticData.RECORD_TYPE_MEMO) { value = record.getString(); } String[] s = { record.getDateString(StaticData.fmtForBackup), value }; cw.writeNext(s); } cw.close(); outputStream.close(); progressDialog.dismiss(); Uri fileUri = FileProvider.getUriForFile(context, "net.gerosyab.dailylog.fileprovider", resultFile); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri); shareIntent.setType("text/plain"); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to))); } catch (UnsupportedEncodingException e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } catch (Exception e) { Log.e("DailyLog", e.getMessage()); e.printStackTrace(); } finally { progressDialog.dismiss(); } }
From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java
/** * contact/*from ww w . j av a 2 s. c om*/ * * @param v */ public void searchContact(View v) { final String name = editText.getText().toString(); String saveText = searchBtn.getText().toString(); if (getString(R.string.button_search).equals(saveText)) { toAddUsername = name; if (TextUtils.isEmpty(name)) { startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "??")); return; } final ProgressDialog pd = new ProgressDialog(AddContactActivity.this); pd.setMessage("..."); RequestParams params = new RequestParams(); params.put("data", editText.getText().toString().trim()); params.put("flag", "1"); HttpClientRequest.post(Urls.FINDUSER, params, 3000, new AsyncHttpResponseHandler() { @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); pd.show(); } @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { // TODO Auto-generated method stub try { String res = new String(arg2); DebugLog.i(TAG, "" + res); JSONObject result = new JSONObject(res); switch (Integer.valueOf(result.getString("ret"))) { case -1: Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show(); break; case 1: searchedUserLayout.setVisibility(View.VISIBLE); nameText.setText(toAddUsername); nameText.setText(result.getString("account_name")); myUser = new MyUser(); myUser.setAccount_id(result.getString("account_id")); myUser.setAccount_image(result.getString("account_image")); myUser.setAccount_name(result.getString("account_name")); myUser.setAccount_username(result.getString("account_username")); break; case 0: Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show(); break; } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFinish() { // TODO Auto-generated method stub super.onFinish(); pd.dismiss(); } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // TODO Auto-generated method stub } }); } }
From source file:com.esri.arcgisruntime.generateofflinemap.MainActivity.java
/** * Use the generate offline map job to generate an offline map. *//*from w w w . ja v a 2 s.c o m*/ private void generateOfflineMap() { // create a progress dialog to show download progress ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle("Generate Offline Map Job"); progressDialog.setMessage("Taking map offline..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setIndeterminate(false); progressDialog.setProgress(0); // when the button is clicked, start the offline map task job mTakeMapOfflineButton.setOnClickListener(v -> { progressDialog.show(); // delete any offline map already in the cache String tempDirectoryPath = getCacheDir() + File.separator + "offlineMap"; deleteDirectory(new File(tempDirectoryPath)); // specify the extent, min scale, and max scale as parameters double minScale = mMapView.getMapScale(); double maxScale = mMapView.getMap().getMaxScale(); // minScale must always be larger than maxScale if (minScale <= maxScale) { minScale = maxScale + 1; } GenerateOfflineMapParameters generateOfflineMapParameters = new GenerateOfflineMapParameters( mDownloadArea.getGeometry(), minScale, maxScale); // create an offline map offlineMapTask with the map OfflineMapTask offlineMapTask = new OfflineMapTask(mMapView.getMap()); // create an offline map job with the download directory path and parameters and start the job GenerateOfflineMapJob job = offlineMapTask.generateOfflineMap(generateOfflineMapParameters, tempDirectoryPath); // replace the current map with the result offline map when the job finishes job.addJobDoneListener(() -> { if (job.getStatus() == Job.Status.SUCCEEDED) { GenerateOfflineMapResult result = job.getResult(); mMapView.setMap(result.getOfflineMap()); mGraphicsOverlay.getGraphics().clear(); mTakeMapOfflineButton.setEnabled(false); Toast.makeText(this, "Now displaying offline map.", Toast.LENGTH_LONG).show(); } else { String error = "Error in generate offline map job: " + job.getError().getAdditionalMessage(); Toast.makeText(this, error, Toast.LENGTH_LONG).show(); Log.e(TAG, error); } progressDialog.dismiss(); }); // show the job's progress with the progress dialog job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress())); // start the job job.start(); }); }