List of usage examples for android.app ProgressDialog ProgressDialog
public ProgressDialog(Context context)
From source file:me.kartikarora.transfersh.activities.TransferActivity.java
private void uploadFile(Uri uri) throws IOException { final ProgressDialog dialog = new ProgressDialog(TransferActivity.this); dialog.setMessage(getString(R.string.uploading_file)); dialog.setCancelable(false);/*from ww w. j av a 2 s. c o m*/ dialog.show(); Cursor cursor = getContentResolver().query(uri, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); final String name = cursor.getString(nameIndex); final String mimeType = getContentResolver().getType(uri); Log.d(this.getClass().getSimpleName(), cursor.getString(0)); Log.d(this.getClass().getSimpleName(), name); Log.d(this.getClass().getSimpleName(), mimeType); InputStream inputStream = getContentResolver().openInputStream(uri); OutputStream outputStream = openFileOutput(name, MODE_PRIVATE); if (inputStream != null) { IOUtils.copy(inputStream, outputStream); final File file = new File(getFilesDir(), name); TypedFile typedFile = new TypedFile(mimeType, file); TransferClient.getInterface().uploadFile(typedFile, name, new ResponseCallback() { @Override public void success(Response response) { BufferedReader reader; StringBuilder sb = new StringBuilder(); try { reader = new BufferedReader(new InputStreamReader(response.getBody().in())); String line; try { while ((line = reader.readLine()) != null) { sb.append(line); } } catch (IOException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } String result = sb.toString(); Snackbar.make(mCoordinatorLayout, name + " " + getString(R.string.uploaded), Snackbar.LENGTH_SHORT).show(); ContentValues values = new ContentValues(); values.put(FilesContract.FilesEntry.COLUMN_NAME, name); values.put(FilesContract.FilesEntry.COLUMN_TYPE, mimeType); values.put(FilesContract.FilesEntry.COLUMN_URL, result); values.put(FilesContract.FilesEntry.COLUMN_SIZE, String.valueOf(file.getTotalSpace())); getContentResolver().insert(FilesContract.BASE_CONTENT_URI, values); getSupportLoaderManager().restartLoader(BuildConfig.VERSION_CODE, null, TransferActivity.this); FileUtils.deleteQuietly(file); if (dialog.isShowing()) dialog.hide(); } @Override public void failure(RetrofitError error) { error.printStackTrace(); if (dialog.isShowing()) dialog.hide(); Snackbar.make(mCoordinatorLayout, R.string.something_went_wrong, Snackbar.LENGTH_INDEFINITE) .setAction(R.string.report, new View.OnClickListener() { @Override public void onClick(View view) { // TODO add feedback code } }).show(); } }); } else Snackbar.make(mCoordinatorLayout, R.string.unable_to_read, Snackbar.LENGTH_SHORT).show(); } }
From source file:com.soomla.example.ExampleSocialActivity.java
/** * {@inheritDoc}/*from www . j ava2 s . com*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_social); // SoomlaConfig.logDebug = true; mProgressDialog = new ProgressDialog(this); final Bundle extras = getIntent().getExtras(); if (extras != null) { final String provider = extras.getString("provider"); mProvider = IProvider.Provider.getEnum(provider); mItemId = extras.getString("id"); mItemAmount = extras.getInt("amount", 1); mItemName = extras.getString("name"); mItemResId = extras.getInt("iconResId", R.drawable.ic_launcher); // set the social provider logo if possible final int resourceId = getResources().getIdentifier(provider, "drawable", getPackageName()); Drawable drawableLogo = getResources().getDrawable(resourceId); if (drawableLogo != null) { final TextView topBarTextView = (TextView) findViewById(R.id.textview); if (topBarTextView != null) { topBarTextView.setCompoundDrawablesWithIntrinsicBounds(drawableLogo, null, null, null); } } } final TextView vItemDisplay = (TextView) findViewById(R.id.vItem); if (vItemDisplay != null) { vItemDisplay.setText(mItemName); vItemDisplay.setCompoundDrawablesWithIntrinsicBounds(null, getResources().getDrawable(mItemResId), null, null); } mProfileBar = (ViewGroup) findViewById(R.id.profile_bar); mProfileAvatar = (ImageView) findViewById(R.id.prof_avatar); mProfileName = (TextView) findViewById(R.id.prof_name); mPnlStatusUpdate = (ViewGroup) findViewById(R.id.pnlStatusUpdate); mEdtStatusText = (EditText) findViewById(R.id.edtStatusText); mEdtStatusText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_SEND) { doUpdateStatus(); handled = true; } return handled; } }); mBtnUpdateStatus = (Button) findViewById(R.id.btnStatusUpdate); mBtnUpdateStatus.setEnabled(false); mBtnUpdateStatus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doUpdateStatus(); } }); mPnlUploadImage = (ViewGroup) findViewById(R.id.pnlUploadImage); mImagePreview = (ImageView) findViewById(R.id.imagePreview); mEdtImageText = (EditText) findViewById(R.id.edtImageText); mEdtImageText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_SEND) { doUpdateStatus(); handled = true; } return handled; } }); mBtnChooseImage = (ImageView) findViewById(R.id.btnChooseImage); mBtnChooseImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { chooseImageFile(); } }); mBtnUploadImage = (Button) findViewById(R.id.btnUploadImage); mBtnUploadImage.setEnabled(false); mBtnUploadImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doUploadImage(); } }); mPnlStoryUpdate = (ViewGroup) findViewById(R.id.pnlStoryUpdate); mEdtStoryText = (EditText) findViewById(R.id.edtStoryText); mEdtStoryText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_SEND) { doUpdateStory(); handled = true; } return handled; } }); mBtnUpdateStory = (Button) findViewById(R.id.btnStoryUpdate); mBtnUpdateStory.setEnabled(false); mBtnUpdateStory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doUpdateStory(); } }); mBtnShare = (Button) findViewById(R.id.btnShare); if (!SoomlaProfile.getInstance().isLoggedIn(this, mProvider)) { SoomlaProfile.getInstance().login(this, mProvider, gameLoginReward); mProgressDialog.setMessage("logging in..."); mProgressDialog.show(); } else { applyLoggedInUser(mProvider); } }
From source file:com.wenwen.chatuidemo.activity.LoginActivity.java
/** * /*from ww w.j a va 2 s. 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; } pd = new ProgressDialog(LoginActivity.this); pd.setMessage("..."); RequestParams params = new RequestParams(); params.put("username", usernameEditText.getText().toString().trim()); params.put("password", MD5.md5("ys_" + passwordEditText.getText().toString().trim()).toUpperCase()); params.put("type", "1"); HttpClientRequest.post(Urls.LOGIG, 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("res", res); final JSONObject result = new JSONObject(res); switch (Integer.valueOf(result.getString("ret"))) { case -1: Toast.makeText(LoginActivity.this, "?,", Toast.LENGTH_SHORT).show(); break; case 1: DemoApplication.getInstance().setUserUid(result.getString("uid")); DemoApplication.getInstance().setAccout_name(result.getString("uname")); // sdk?? loginhandler.sendEmptyMessage(1); break; case -2: Toast.makeText(LoginActivity.this, "??", Toast.LENGTH_SHORT).show(); break; case -3: case 0: Toast.makeText(LoginActivity.this, "", Toast.LENGTH_SHORT).show(); break; default: break; } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFinish() { // TODO Auto-generated method stub super.onFinish(); } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // TODO Auto-generated method stub } }); }
From source file:org.pixmob.appengine.client.demo.DemoActivity.java
@Override protected Dialog onCreateDialog(int id) { if (NO_ACCOUNT_DIALOG == id) { final AlertDialog d = new AlertDialog.Builder(this).setTitle(R.string.error).setCancelable(false) .setMessage(R.string.no_account_error).setPositiveButton(R.string.quit, new OnClickListener() { @Override// w w w. j ava 2 s .c o m public void onClick(DialogInterface dialog, int which) { finish(); } }).create(); return d; } if (PROGRESS_DIALOG == id) { final ProgressDialog d = new ProgressDialog(this); d.setMessage(getString(R.string.connecting_to_appengine)); d.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { loginTask.cancel(true); // release resources when the task is canceled loginTask = null; } }); return d; } if (MODIFY_APPSPOT_BASE_DIALOG == id) { final EditText input = new EditText(this); input.setSelectAllOnFocus(true); input.setText(prefs.getString(APPSPOT_BASE_PREF, defaultAppspotBase)); final AlertDialog d = new AlertDialog.Builder(this).setView(input) .setTitle(R.string.enter_appspot_instance_name) .setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { appspotBase = trimToNull(input.getText().toString()); if (appspotBase == null) { appspotBase = defaultAppspotBase; } appspotBaseView.setText(appspotBase); storeFields(); } }).create(); return d; } return super.onCreateDialog(id); }
From source file:com.manning.androidhacks.hack023.authenticator.AuthenticatorActivity.java
@Override protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage("Login in"); dialog.setIndeterminate(true);//from w ww .java 2 s .co m dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { if (mAuthThread != null) { mAuthThread.interrupt(); finish(); } } }); return dialog; }
From source file:org.projecthdata.hhub.ui.HDataWebOauthActivity.java
public void showProgressDialog(CharSequence message) { if (progressDialog == null) { progressDialog = new ProgressDialog(this); progressDialog.setIndeterminate(true); }/*from ww w . j a v a2 s. c o m*/ progressDialog.setMessage(message); progressDialog.show(); }
From source file:com.securekey.sdk.sample.VerifyQuickCodeActivity.java
/** * Starts quickcode verification. Expects the results in JWS format. * <p>//w w w. j a v a 2s .c o m * Gets {@link Briidge} object and calls {@link Briidge#verifyQuickCodeReturnJWS} */ private void verifyQuickCodeReturnJWS(final String passcode) { mProgressDialog = new ProgressDialog(this); updateProgressDialog("Verifying"); this.jwsExpected = true; BriidgePlatformFactory.getBriidgePlatform(VerifyQuickCodeActivity.this).verifyQuickCodeReturnJWS(passcode, SDKSampleApp.getInstance().retrieveUserId(), VerifyQuickCodeActivity.this); }
From source file:edu.mit.mobile.android.locast.accounts.AuthenticatorActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS: final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.login_message_authenticating)); dialog.setIndeterminate(true);/*w w w . java 2s. com*/ dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "dialog cancel has been invoked"); if (mAuthenticationTask != null) { mAuthenticationTask.cancel(true); mAuthenticationTask = null; finish(); } } }); return dialog; case DIALOG_SET_BASE_URL: final EditText baseUrl = new EditText(this); baseUrl.setText(getString(R.string.default_api_url)); final AlertDialog.Builder db = new AlertDialog.Builder(this); return db.create(); default: return null; } }
From source file:net.net76.lifeiq.TaskiQ.RegisterActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); inputFirstname = (EditText) findViewById(R.id.firstname); inputSurname = (EditText) findViewById(R.id.surname); inputUserID = (EditText) findViewById(R.id.userID); inputEmail = (EditText) findViewById(R.id.email); //1 inputPassword = (EditText) findViewById(R.id.password); //1inputPassword2 = (EditText) findViewById(R.id.password2); Spinner spinner = (Spinner) findViewById(R.id.spinner); EULA = (TextView) findViewById(R.id.EULA); SpannableString content = new SpannableString(EULA.getText().toString()); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); EULA.setText(content);/*w ww . j a va 2s . c o m*/ EULA.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PackageInfo versionInfo = getPackageInfo(); // EULA title String title = RegisterActivity.this.getString(R.string.app_name) + " v " + versionInfo.versionName; // EULA text String message = RegisterActivity.this.getString(R.string.eula_string); android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegisterActivity.this) .setTitle(title).setMessage(message).setCancelable(false) .setPositiveButton(R.string.accept, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { EULAAccept = true; // Close dialog dialogInterface.dismiss(); } }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EULAAccept = false; } }); builder.create().show(); } }); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.Country_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Log.v("item", (String) parent.getItemAtPosition(position)); countryString = (String) parent.getItemAtPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); btnRegister = (Button) findViewById(R.id.btnRegister); btnLinkToLogin = (Button) findViewById(R.id.btnLinkToLoginScreen); // Progress dialog pDialog = new ProgressDialog(this); //pDialog.setCancelable(false); pDialog.setCanceledOnTouchOutside(false); // Session manager session = new SessionManager(getApplicationContext()); // SQLite database handler db = new SQLiteHandler(getApplicationContext()); // Check if user is already logged in or not if (session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(RegisterActivity.this, MainActivity.class); startActivity(intent); finish(); } // Register Button Click event btnRegister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String Firstname = inputFirstname.getText().toString(); String Surname = inputSurname.getText().toString(); String UserID = inputUserID.getText().toString(); String email = inputEmail.getText().toString(); //1 String password = inputPassword.getText().toString(); //1 String password2 = inputPassword2.getText().toString(); if (!Firstname.isEmpty() && !Surname.isEmpty() && !email.isEmpty() && !UserID.isEmpty()) { if (isEmailValid(email)) { if (!UserID.contains(" ")) { if (!countryString.equals("Select country of residence")) { if (EULAAccept.equals(true)) { if (isNetworkAvaliable(getApplicationContext())) { registerUser(Firstname, Surname, UserID, email, countryString); } else { Toast.makeText(getApplicationContext(), "Currently there is no network. Please try later.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please read and accept End User License Agreement.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please select a country of residence.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "In the User ID no spaces are allowed.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please enter a valid email address!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please enter your details!", Toast.LENGTH_SHORT) .show(); } } }); // Link to Login Screen btnLinkToLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(getApplicationContext(), LoginActivity.class); startActivity(i); finish(); } }); }
From source file:com.citrus.sdk.CitrusActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mPaymentType = getIntent().getParcelableExtra(Constants.INTENT_EXTRA_PAYMENT_TYPE); if (!(mPaymentType instanceof PaymentType.CitrusCash)) { setTheme(R.style.Base_Theme_AppCompat_Light_DarkActionBar); }/*from ww w . j av a 2s . c om*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_citrus); mPaymentParams = getIntent().getParcelableExtra(Constants.INTENT_EXTRA_PAYMENT_PARAMS); mCitrusConfig = CitrusConfig.getInstance(); mActivityTitle = mCitrusConfig.getCitrusActivityTitle(); mCitrusClient = CitrusClient.getInstance(mContext); // Set payment Params if (mPaymentParams != null) { mPaymentType = mPaymentParams.getPaymentType(); mPaymentOption = mPaymentParams.getPaymentOption(); mCitrusUser = mPaymentParams.getUser(); mColorPrimary = mPaymentParams.getColorPrimary(); mColorPrimaryDark = mPaymentParams.getColorPrimaryDark(); mTextColorPrimary = mPaymentParams.getTextColorPrimary(); } else if (mPaymentType != null) { mPaymentOption = mPaymentType.getPaymentOption(); mCitrusUser = mPaymentType.getCitrusUser(); mColorPrimary = mCitrusConfig.getColorPrimary(); mColorPrimaryDark = mCitrusConfig.getColorPrimaryDark(); mTextColorPrimary = mCitrusConfig.getTextColorPrimary(); } else { throw new IllegalArgumentException("Payment Type Should not be null"); } mActionBar = getSupportActionBar(); mProgressDialog = new ProgressDialog(mContext); mPaymentWebview = (WebView) findViewById(R.id.payment_webview); mPaymentWebview.getSettings().setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { /* This setting is required to enable redirection of urls from https to http or vice-versa. This redirection is blocked by default from Lollipop (Android 21). */ mPaymentWebview.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } mPaymentWebview.addJavascriptInterface(new JsInterface(), Constants.JS_INTERFACE_NAME); mPaymentWebview.setWebChromeClient(new WebChromeClient()); mPaymentWebview.setWebViewClient(new CitrusWebClient()); // Make the webview visible only in case of PGPayment or LoadMoney. if (mPaymentType instanceof PaymentType.CitrusCash) { mPaymentWebview.setVisibility(View.GONE); } if (mPaymentType instanceof PaymentType.PGPayment || mPaymentType instanceof PaymentType.CitrusCash) { if (mPaymentType.getPaymentBill() != null) { // TODO Need to refactor the code. if (PaymentBill.toJSONObject(mPaymentType.getPaymentBill()) != null) { proceedToPayment(PaymentBill.toJSONObject(mPaymentType.getPaymentBill()).toString()); } } else { fetchBill(); } } else { //load cash does not requires Bill Generator Amount amount = mPaymentType.getAmount(); LoadMoney loadMoney = new LoadMoney(amount.getValue(), mPaymentType.getUrl()); PG paymentgateway = new PG(mPaymentOption, loadMoney, new UserDetails(CitrusUser.toJSONObject(mCitrusUser))); paymentgateway.load(CitrusActivity.this, new Callback() { @Override public void onTaskexecuted(String success, String error) { processresponse(success, error); } }); } if (TextUtils.isEmpty(mActivityTitle)) { mActivityTitle = "Processing..."; } setTitle(Html.fromHtml("<font color=\"" + mTextColorPrimary + "\">" + mActivityTitle + "</font>")); setActionBarBackground(); }