Example usage for android.app ProgressDialog STYLE_SPINNER

List of usage examples for android.app ProgressDialog STYLE_SPINNER

Introduction

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

Prototype

int STYLE_SPINNER

To view the source code for android.app ProgressDialog STYLE_SPINNER.

Click Source Link

Document

Creates a ProgressDialog with a circular, spinning progress bar.

Usage

From source file:com.qddagu.app.meetreader.ui.MainActivity.java

/**
 * ?/*from  ww w. ja v a 2 s.co m*/
 * @param handler
 */
public void loadMeeting(final String url) {
    final ProgressDialog mLoadingDialog = new ProgressDialog(this);
    mLoadingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mLoadingDialog.setTitle("??");
    mLoadingDialog.setMessage("??...");
    mLoadingDialog.setCancelable(false);
    mLoadingDialog.show();
    final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            mLoadingDialog.dismiss();
            if (msg.what == 1) { //?
                Meeting meeting = ((Meeting) msg.obj);
                User user = meeting.getUser();
                if (user != null) {
                    //??
                    appContext.saveUserInfo(user);
                }
                appContext.setMeeting(meeting);//?
                appContext.saveHistory(meeting);//??

                UIHelper.showMeeting(MainActivity.this);
            } else if (msg.what == 0) { //
                UIHelper.ToastMessage(MainActivity.this, "");
            } else if (msg.what == -1 && msg.obj != null) {
                ((AppException) msg.obj).makeToast(MainActivity.this);
            }
        }
    };
    new Thread() {
        public void run() {
            Message msg = new Message();
            try {
                Meeting meeting = appContext.getMeeting(url);
                msg.what = (meeting != null && meeting.getId() > 0) ? 1 : 0;
                msg.obj = meeting;
            } catch (AppException e) {
                e.printStackTrace();
                msg.what = -1;
                msg.obj = e;
            }
            handler.sendMessage(msg);
        }
    }.start();
}

From source file:com.yattatech.dbtc.activity.GenericFragmentActivity.java

public void showSpinnerProgressBar(int titleId) {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCanceledOnTouchOutside(false);
    mProgressDialog.setTitle(titleId);/*from   w  w w . j a v  a 2s.com*/
    mProgressDialog.show();
}

From source file:org.kaaproject.kaa.demo.smarthousedemo.smarthouse.SmartHouseFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == DEVICE_QR_CODE_REQUEST) {
        if (resultCode == Activity.RESULT_OK) {
            String result = data.getStringExtra(Intents.Scan.RESULT);
            mProgress = new ProgressDialog(getActivity());
            mProgress.setTitle(getString(R.string.msg_connecting_device_title));
            mProgress.setMessage(getString(R.string.msg_connecting_device));
            mProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            mProgress.setIndeterminate(true);
            mProgress.show();/*from  w w  w.ja  va  2s. c  o m*/
            mActivity.getSmartHouseController().attachEndpoint(result, new AttachEdnpointCallback());
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:de.da_sense.moses.client.LoginActivity.java

/**
 * Handles the click on the login button.
 * Gets called on click on the login button.
 * @param v View/*from ww  w .  jav  a 2s .  com*/
 */
public void handleClick(View v) {
    String email = editTextEmail.getText().toString().trim();
    String password = editTextPassword.getText().toString();
    String deviceID = HardwareAbstraction.extractDeviceIdFromSharedPreferences();

    // validate the format of email and password before sending anything to server
    if (!validateEmail() || !validatePassword()) {
        return;
    }
    // show ProgressDialog while checking and verifying entered credentials
    loginDialog = new ProgressDialog(LoginActivity.this, ProgressDialog.STYLE_SPINNER);
    loginDialog.setTitle(getString(R.string.checking_credentials));
    loginDialog.setMessage(getString(R.string.verifying_credentials));
    loginDialog.setCanceledOnTouchOutside(false);
    loginDialog.show();
    // request a login/session from the server
    new RequestLogin(new ReqLogin(), email, password, deviceID).send();
}

From source file:ca.rmen.android.networkmonitor.app.log.LogActionsActivity.java

/**
 * Run the given file export, then bring up the chooser intent to share the exported file.
 *//*from w  ww  . ja  va2 s  . c  om*/
private void shareFile(final FileExport fileExport) {
    Log.v(TAG, "shareFile " + fileExport);
    // Use a horizontal progress bar style if we can show progress of the export.
    String dialogMessage = getString(R.string.export_progress_preparing_export);
    int dialogStyle = fileExport != null ? ProgressDialog.STYLE_HORIZONTAL : ProgressDialog.STYLE_SPINNER;
    DialogFragmentFactory.showProgressDialog(this, dialogMessage, dialogStyle, PROGRESS_DIALOG_TAG);

    AsyncTask<Void, Void, File> asyncTask = new AsyncTask<Void, Void, File>() {

        @Override
        protected File doInBackground(Void... params) {
            File file = null;
            if (fileExport != null) {
                if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
                    return null;
                try {
                    // Export the file in the background.
                    file = fileExport.export();
                } catch (Throwable t) {
                    Log.e(TAG, "Error exporting file " + fileExport + ": " + t.getMessage(), t);
                }
                if (file == null)
                    return null;
            }

            String reportSummary = SummaryExport.getSummary(LogActionsActivity.this);
            // Bring up the chooser to share the file.
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_subject_send_log));

            String dateRange = SummaryExport.getDataCollectionDateRange(LogActionsActivity.this);

            String messageBody = getString(R.string.export_message_text, dateRange);
            if (file != null) {
                sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
                sendIntent.setType("message/rfc822");
                messageBody += getString(R.string.export_message_text_file_attached);
            } else {
                sendIntent.setType("text/plain");
            }
            messageBody += reportSummary;
            sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);

            startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.action_share)));
            return file;
        }

        @Override
        protected void onPostExecute(File result) {
            super.onPostExecute(result);
            DialogFragment fragment = (DialogFragment) getSupportFragmentManager()
                    .findFragmentByTag(PROGRESS_DIALOG_TAG);
            if (fragment != null)
                fragment.dismissAllowingStateLoss();
            // Show a toast if we failed to export a file.
            if (fileExport != null && result == null)
                Toast.makeText(LogActionsActivity.this, R.string.export_error_sdcard_unmounted,
                        Toast.LENGTH_LONG).show();
            finish();
        }

    };
    asyncTask.execute();
}

From source file:dg.shenm233.mmaps.ui.OfflineMapActivity.java

private void showProgressDialog() {
    if (mProgressDialog == null) {
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setMessage("Loading...");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
    }/*from  w ww  . j  av a 2  s .c o  m*/
    mProgressDialog.show();
}

From source file:ca.rmen.android.networkmonitor.app.prefs.PreferenceFragmentActivity.java

@Override
public void onOkClicked(int actionId, Bundle extras) {
    Log.v(TAG, "onClicked, actionId=" + actionId + ", extras = " + extras);
    mUserInput = true;/*from   www .  java 2 s.  c o  m*/
    // Import the database in a background thread.
    if (actionId == ID_ACTION_IMPORT) {
        final Uri uri = extras.getParcelable(EXTRA_IMPORT_URI);
        AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {

            @Override
            protected void onPreExecute() {
                DialogFragmentFactory.showProgressDialog(PreferenceFragmentActivity.this,
                        getString(R.string.progress_dialog_message), ProgressDialog.STYLE_SPINNER,
                        PROGRESS_DIALOG_FRAGMENT_TAG);
            }

            @Override
            protected Boolean doInBackground(Void... params) {
                try {
                    Log.v(TAG, "Importing db from " + uri);
                    DBImport.importDB(PreferenceFragmentActivity.this, uri);
                    return true;
                } catch (Exception e) {
                    Log.e(TAG, "Error importing db: " + e.getMessage(), e);
                    return false;
                }
            }

            @Override
            protected void onPostExecute(Boolean result) {
                ProgressDialogFragment dialogFragment = (ProgressDialogFragment) getSupportFragmentManager()
                        .findFragmentByTag(PROGRESS_DIALOG_FRAGMENT_TAG);
                if (dialogFragment != null)
                    dialogFragment.dismissAllowingStateLoss();
                String toastText = result ? getString(R.string.import_successful, uri.getPath())
                        : getString(R.string.import_failed, uri.getPath());
                Toast.makeText(PreferenceFragmentActivity.this, toastText, Toast.LENGTH_SHORT).show();
                finish();
            }
        };
        task.execute();
    } else if (actionId == ID_ACTION_LOCATION_SETTINGS) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
        startActivity(intent);
        finish();
    }
}

From source file:it.sasabz.android.sasabus.fragments.OnlineSelectFragment.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (!XMLRequest.haveNetworkConnection()) {
        Toast.makeText(getContext(), R.string.no_network_connection, Toast.LENGTH_LONG).show();
        getFragmentManager().popBackStack();
        return null;
    }//from  w  w  w  .  ja v a 2  s.c o m

    String lang = "it";
    if ((Locale.getDefault().getLanguage()).indexOf(Locale.GERMAN.toString()) != -1)
        lang = "de";
    fromPalina = PalinaList.getTranslation(from, lang);
    toPalina = PalinaList.getTranslation(to, lang);
    SimpleDateFormat simple = new SimpleDateFormat("dd.MM.yyyy HH:mm");
    boolean plus12 = false;
    if (date.contains("PM")) {
        plus12 = true;
    }
    try {
        datum = simple.parse(date);
        if (plus12)
            datum.setHours(datum.getHours() + 12);
    } catch (Exception e) {
        Log.v("Datumsfehler", "Das Datum hat eine falsche Formatierung angenommen!!!");
        Toast.makeText(getContext(), "ERROR", Toast.LENGTH_LONG).show();
        getFragmentManager().popBackStack();
        return null;
    }

    if (from == "" || to == "") {
        Toast.makeText(getContext(), "ERROR", Toast.LENGTH_LONG).show();
        Log.v("SELECT STOP ERROR", "From: " + from + " | To: " + to);
        getFragmentManager().popBackStack();
        return null;
    }

    progress = new ProgressDialog(getContext());
    progress.setMessage(getResources().getText(R.string.waiting));
    progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progress.setCancelable(false);
    progress.show();

    statlist = new XMLStationList(this);
    if (toPalina != null) {
        to = toPalina.getHaltestelle();
        Log.v("ONLINE-SELECT-TO", to);
    }
    if (fromPalina != null) {
        from = fromPalina.getHaltestelle();
        Log.v("ONLINE-SELECT-FROM", from);
    }
    statlist.execute(from, to);
    result = inflater.inflate(R.layout.online_select_layout, container, false);
    result.setVisibility(View.INVISIBLE);
    return result;
}

From source file:org.travey.travey.SettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_settings, container, false);
    manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    //load properties from config resource file
    dataConnection.delegate = this;
    Log.i("**************", "Creating Main Activity");
    load();//from  w w w.j a v  a2  s . co  m
    SharedPreferences.Editor editor = myPrefs.edit();
    editor.putBoolean("isNotified", false);
    editor.commit();
    CheckBox checkBox = (CheckBox) rootView.findViewById(R.id.checkBox);
    checkBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Do something in response to checkbox
            final CheckBox checkBox = (CheckBox) rootView.findViewById(R.id.checkBox);
            if (checkBox.isChecked()) {
                if (!mRequestingLocationUpdates) {
                    if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                        buildAlertMessageNoGps();
                    }
                    mRequestingLocationUpdates = true;
                    mActiveCheckboxChecked = true;
                    startLocationUpdates();
                }
            } else {
                if (mRequestingLocationUpdates) {
                    mRequestingLocationUpdates = false;
                    mActiveCheckboxChecked = false;
                    stopLocationUpdates();
                }
            }
        }
    });
    EditText editText = (EditText) rootView.findViewById(R.id.editText);
    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    Button button = (Button) rootView.findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            /** Called when the user clicks the register button */
            load();
            EditText editText = (EditText) rootView.findViewById(R.id.editText);
            if (mRegistered && !isRegistering) {
                //user is deregistering
                CheckBox checkBox = (CheckBox) rootView.findViewById(R.id.checkBox);
                Button button = (Button) rootView.findViewById(R.id.button);
                TextView textView4 = (TextView) rootView.findViewById(R.id.textView4);
                TextView textView5 = (TextView) rootView.findViewById(R.id.textView5);
                button.setText(R.string.check_button);
                editText.setEnabled(true);
                editText.setText("");
                textView4.setEnabled(true);
                mActiveCheckboxChecked = false;
                stopLocationUpdates();
                checkBox.setChecked(false);
                checkBox.setEnabled(false);
                textView5.setEnabled(false);
                participantID = "";
                myPrefs = getActivity().getSharedPreferences("myPrefs", getActivity().MODE_PRIVATE);
                SharedPreferences.Editor editor = myPrefs.edit();
                editor.putString("participantID", participantID);
                editor.commit();
                mRegistered = false;
                save(mActiveCheckboxChecked, mRequestingLocationUpdates, mRegistered);
                isRegistering = true;
                EventBus bus = EventBus.getDefault();
                bus.post(new RegistrationStatusChanged("0"));
            } else {
                isRegistering = false;
                participantID = editText.getText().toString();
                dialog = new ProgressDialog(getActivity());
                dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                dialog.setMessage("Registering you as a participant");
                dialog.setIndeterminate(true);
                dialog.setCanceledOnTouchOutside(false);
                dialog.show();
                Log.i("**************", "Checking participant ID");
                Resources res = getResources();
                String RESTFUL_URL = res.getString(R.string.restful_url);
                String url = RESTFUL_URL + "?method=reg&format=json&pid=" + participantID;
                dataConnection.connect(getActivity(), url);
            }
        }
    });

    if (mActiveCheckboxChecked) {
        checkBox.setChecked(true);
    }
    if (mRegistered) {
        editText.setText(participantID);
        checkBox.setEnabled(true);
        editText.setEnabled(false);
        TextView textView4 = (TextView) rootView.findViewById(R.id.textView4);
        TextView textView5 = (TextView) rootView.findViewById(R.id.textView5);
        textView4.setEnabled(false);
        textView5.setEnabled(true);
        button.setText(R.string.reset_button);
    } else {
        checkBox.setEnabled(false);
    }
    return rootView;
}

From source file:com.raza.betternts.activities.MainActivity.java

private void doInBG() {
    new AsyncTask<Void, Void, String>() {
        Parser nts = new Parser(getApplicationContext());
        ProgressDialog progressDialog;//from  w ww.  j a v a 2 s .  c  o  m

        @Override
        protected void onPreExecute() {
            progressDialog = new ProgressDialog(MainActivity.this);
            progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            progressDialog.setMessage("Reading NTS website");
            progressDialog.setCancelable(false);
            progressDialog.show();
        }

        @Override
        protected String doInBackground(Void... params) {
            return nts.readWeb();
        }

        @Override
        protected void onPostExecute(String s) {
            progressDialog.dismiss();
            s = s.replaceAll("[^0-9]", "");
            int i = Integer.parseInt(s);
            if (i == 200) {
                nts.saveToDB();
            } else {
                new AlertDialog.Builder(MainActivity.this).setTitle("Error!")
                        .setMessage("Failed to read NTS website. Error code: " + i)
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }).show();
            }
        }
    }.execute();
}