Example usage for android.app ProgressDialog setMessage

List of usage examples for android.app ProgressDialog setMessage

Introduction

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

Prototype

@Override
    public void setMessage(CharSequence message) 

Source Link

Usage

From source file:com.koushikdutta.superuser.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Settings.applyDarkThemeSetting(this, R.style.SuperuserDarkActivity);
    super.onCreate(savedInstanceState);

    if (Settings.getBoolean(this, "first_run", true)) {
        saveWhatsNew();/* w  w  w . j a va2 s. co  m*/
        Settings.setBoolean(this, "first_run", false);
    }

    final ProgressDialog dlg = new ProgressDialog(this);
    dlg.setTitle(R.string.superuser);
    dlg.setMessage(getString(R.string.checking_superuser));
    dlg.setIndeterminate(true);
    dlg.show();
    new Thread() {
        public void run() {
            boolean _error = false;
            try {
                SuHelper.checkSu(MainActivity.this);
            } catch (Exception e) {
                e.printStackTrace();
                _error = true;
            }
            final boolean error = _error;
            dlg.dismiss();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (error) {
                        doInstall();
                    } else {
                        doWhatsNew();
                    }
                }
            });
        };
    }.start();
}

From source file:com.artur.softwareproject.BluetoothConnectionListAdapter.java

@Override
@NonNull//from w w  w.  jav a2s  .  c  o m
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    ViewHolder mViewHolder;

    if (convertView == null) {
        mViewHolder = new ViewHolder();

        LayoutInflater ListInflater = LayoutInflater.from(getContext());

        convertView = ListInflater.inflate(R.layout.bluetooth_list_pattern, parent, false);

        mViewHolder.bluetoothConnectionName = (TextView) convertView
                .findViewById(R.id.bluetooth_connection_name);

        mViewHolder.bluetoothConnectionStatus = (TextView) convertView
                .findViewById(R.id.bluetooth_connection_status);

        convertView.setTag(mViewHolder);

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //What happens if you press on the list items at the bluetooth activity.
                Animation animation = new AlphaAnimation(0.3f, 1.0f);

                animation.setDuration(1000);

                v.startAnimation(animation);

                intent = new Intent(contextActivity, BluetoothService.class);
                intent.putExtra("device", bDevices.get(position));
                intent.putExtra("deviceList", bDevices);

                contextActivity.startService(intent);

                final ProgressDialog connectingDialog = new ProgressDialog(contextActivity);

                connectDialog = connectingDialog;

                connectingDialog.setMessage("Connecting...");
                connectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                connectingDialog.setCancelable(false);
                connectingDialog.show();

                final ConnectionHandlerClass connectHandler = new ConnectionHandlerClass(bclaReference);

                connectThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        int stop = 0;
                        int counter = 0;

                        //Timeout after 10 seconds.
                        while (stop == 0 && counter < 5) {
                            stop = getConnected();
                            counter++;
                            sleep(2000);
                        }

                        //Timeout occurred after 10s of waiting and stop is still 0.
                        if (stop == 0 && counter == 4) {
                            timeout = true;
                        }

                        connectHandler.sendEmptyMessage(0);
                    }
                });

                connectThread.start();
            }
        });
    } else {
        mViewHolder = (ViewHolder) convertView.getTag();
    }

    mViewHolder.bluetoothConnectionName.setText(bluetoothAddress.get(position));
    mViewHolder.bluetoothConnectionStatus.setText(bluetoothName.get(position));

    return convertView;
}

From source file:com.cuddlesoft.nori.APISettingsActivity.java

@Override
public void editService(final long rowId, final String name, final String url, final String username,
        final String passphrase) {
    // Show progress dialog during the service type detection process.
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);/*from  w w  w. j a v a  2  s .c om*/
    dialog.setCancelable(false);
    dialog.setMessage(getString(R.string.dialog_message_detectingApiType));
    dialog.show();

    // Register broadcast receiver to get results from the background service type detection service.
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // Get result code from received intent.
            int resultCode = intent.getIntExtra(ServiceTypeDetectionService.RESULT_CODE, -1);
            if (resultCode == ServiceTypeDetectionService.RESULT_OK) {
                // Add a new service to the database on a background thread.
                // This is so database I/O doesn't block the UI thread.
                SearchClient.Settings.APIType apiType = SearchClient.Settings.APIType.values()[intent
                        .getIntExtra(ServiceTypeDetectionService.API_TYPE, 0)];
                final SearchClient.Settings settings = new SearchClient.Settings(apiType, name, url, username,
                        passphrase);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        APISettingsDatabase database = new APISettingsDatabase(APISettingsActivity.this);
                        if (rowId == ROW_ID_INSERT) {
                            database.insert(settings);
                        } else {
                            database.update(rowId, settings);
                        }
                        database.close();
                    }
                }).run();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_INVALID_URL) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_serviceUriInvalid,
                        Toast.LENGTH_LONG).show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NETWORK) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noNetwork, Toast.LENGTH_LONG)
                        .show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NO_API) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noServiceAtGivenUri,
                        Toast.LENGTH_LONG).show();
            }

            // Unregister the broadcast receiver.
            unregisterReceiver(this);
            // Dismiss progress dialog.
            dialog.dismiss();
        }
    }, new IntentFilter(ServiceTypeDetectionService.ACTION_DONE));

    // Start the background service type detection service.
    Intent serviceIntent = new Intent(this, ServiceTypeDetectionService.class);
    serviceIntent.putExtra(ServiceTypeDetectionService.ENDPOINT_URL, url);
    startService(serviceIntent);
}

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

/**
 * ?//from   ww  w  .  ja  v  a  2s .  c  o  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:cn.kangeqiu.kq.activity.ContactlistFragment.java

/**
 * ?/*from   w w w  .  j  ava  2s.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());
                BaseApplication.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.nxt.njitong.ContactlistActivity.java

/**
 * ?/*from  w  w w  .j av  a2 s. c o  m*/
 *
 * @param
 */
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(context);
    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(context);
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

                    }
                });
            } catch (final Exception e) {
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, st2 + e.getMessage(), Toast.LENGTH_LONG).show();
                    }
                });

            }

        }
    }).start();

}

From source file:org.klnusbaum.udj.auth.AuthActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage(getText(R.string.authenticating));
    dialog.setIndeterminate(true);//from w w w . j ava  2  s .  com
    dialog.setCancelable(true);
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            Log.i(TAG, "user cancelling authentication");
            if (mAuthTask != null) {
                mAuthTask.cancel(true);
            }
        }
    });
    // We save off the progress dialog in a field so that we can dismiss
    // it later. We can't just call dismissDialog(0) because the system
    // can lose track of our dialog if there's an orientation change.
    mProgressDialog = dialog;
    return dialog;
}

From source file:com.android.messaging.ui.appsettings.ApnSettingsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id == DIALOG_RESTORE_DEFAULTAPN) {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage(getResources().getString(R.string.restore_default_apn));
        dialog.setCancelable(false);//from   ww  w.  ja  v  a 2 s . c  om
        return dialog;
    }
    return null;
}

From source file:io.github.tjg1.nori.APISettingsActivity.java

@Override
public void editService(final long rowId, final String name, final String url, final String username,
        final String passphrase) {
    // Show progress dialog during the service type detection process.
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIndeterminate(true);/*from www. j a v a  2  s .  co m*/
    dialog.setCancelable(false);
    dialog.setMessage(getString(R.string.dialog_message_detectingApiType));
    dialog.show();

    // Register broadcast receiver to get results from the background service type detection service.
    registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // Get result code from received intent.
            int resultCode = intent.getIntExtra(ServiceTypeDetectionService.RESULT_CODE, -1);
            if (resultCode == ServiceTypeDetectionService.RESULT_OK) {
                // Add a new service to the database on a background thread.
                // This is so database I/O doesn't block the UI thread.
                SearchClient.Settings.APIType apiType = SearchClient.Settings.APIType.values()[intent
                        .getIntExtra(ServiceTypeDetectionService.API_TYPE, 0)];
                final SearchClient.Settings settings = new SearchClient.Settings(apiType, name, url, username,
                        passphrase);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        APISettingsDatabase database = new APISettingsDatabase(APISettingsActivity.this);
                        if (rowId == ROW_ID_INSERT) {
                            database.insert(settings);
                        } else {
                            database.update(rowId, settings);
                        }
                        database.close();
                    }
                }).start();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_INVALID_URL) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_serviceUriInvalid,
                        Toast.LENGTH_LONG).show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NETWORK) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noNetwork, Toast.LENGTH_LONG)
                        .show();
            } else if (resultCode == ServiceTypeDetectionService.RESULT_FAIL_NO_API) {
                Toast.makeText(APISettingsActivity.this, R.string.toast_error_noServiceAtGivenUri,
                        Toast.LENGTH_LONG).show();
            }

            // Unregister the broadcast receiver.
            unregisterReceiver(this);
            // Dismiss progress dialog.
            dialog.dismiss();
        }
    }, new IntentFilter(ServiceTypeDetectionService.ACTION_DONE));

    // Start the background service type detection service.
    Intent serviceIntent = new Intent(this, ServiceTypeDetectionService.class);
    serviceIntent.putExtra(ServiceTypeDetectionService.ENDPOINT_URL, url);
    startService(serviceIntent);
}

From source file:com.pansapiens.occyd.Search.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_SEARCHING: {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setTitle("Searching ...");
        dialog.setMessage("Searching ...");
        dialog.setIndeterminate(true);//w w w . ja  v  a 2 s  .c  om
        dialog.setCancelable(false);
        return dialog;
    }
    }
    return null;
}