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.gikoo5.hyphenate.ui.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*from  w w w. ja  v a 2  s  . c o m*/
    EMHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}

From source file:cn.ucai.chatuidemo.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();//from  w  ww  .j  a  v  a2  s  .c o  m
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}

From source file:com.eason.marker.emchat.chatuidemo.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();//from   ww  w .  j  av  a2 s.  c  o  m
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((EMChatMainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), EMChatLoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}

From source file:com.mobility.android.ui.vehicle.AddVehicleActivity.java

private void uploadVehicle() {
    ProgressDialog dialog = new ProgressDialog(this, R.style.DialogStyle);
    dialog.setMessage("Adding vehicle...");
    dialog.setIndeterminate(true);// w ww . j a  va2s .c  o m
    dialog.setCancelable(false);
    dialog.show();

    vehicle.lat = (float) place.getLatLng().latitude;
    vehicle.lng = (float) place.getLatLng().longitude;
    vehicle.address = place.getAddress().toString();
    vehicle.country = "IT";

    vehicle.name = name.getText().toString();
    vehicle.availability = availability.getText().toString();
    vehicle.licencePlate = isCar ? licencePlate.getText().toString() : null;
    vehicle.description = description.getText().toString();
    vehicle.pricePerHour = Float.parseFloat(price.getText().toString());
    vehicle.currency = "EUR";

    vehicle.type = isCar ? "car" : "bike";

    Timber.e("Uploading vehicle: %s", vehicle);

    VehicleApi api = RestClient.ADAPTER.create(VehicleApi.class);
    api.addVehicle(vehicle).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<VehicleObject>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    e.printStackTrace();
                    dialog.dismiss();
                    UIUtils.okDialog(AddVehicleActivity.this, "Error", "Couldn't add vehicle.");
                }

                @Override
                public void onNext(VehicleObject object) {
                    Timber.w("Added vehicle");
                    dialog.dismiss();

                    Intent intent = new Intent(AddVehicleActivity.this, VehicleDetailsActivity.class);
                    intent.putExtra(Config.EXTRA_VEHICLE, object);
                    startActivity(intent);
                    finish();
                }
            });
}

From source file:org.telegram.ui.ChangeUsernameActivity.java

private void saveName() {
    if (!checkUserName(firstNameField.getText().toString(), true)) {
        return;//from  w  ww.j  a v a2  s .c om
    }
    TLRPC.User user = UserConfig.getCurrentUser();
    if (getParentActivity() == null || user == null) {
        return;
    }
    String currentName = user.username;
    if (currentName == null) {
        currentName = "";
    }
    String newName = firstNameField.getText().toString();
    if (currentName.equals(newName)) {
        finishFragment();
        return;
    }

    final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setCancelable(false);

    TLRPC.TL_account_updateUsername req = new TLRPC.TL_account_updateUsername();
    req.username = newName;

    NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces,
            MessagesController.UPDATE_MASK_NAME);
    final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
        @Override
        public void run(TLObject response, final TLRPC.TL_error error) {
            if (error == null) {
                final TLRPC.User user = (TLRPC.User) response;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        ArrayList<TLRPC.User> users = new ArrayList<>();
                        users.add(user);
                        MessagesController.getInstance().putUsers(users, false);
                        MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
                        UserConfig.saveConfig(true);
                        finishFragment();
                    }
                });
            } else {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        showErrorAlert(error.text);
                    }
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
    ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);

    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
            LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ConnectionsManager.getInstance().cancelRequest(reqId, true);
                    try {
                        dialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            });
    progressDialog.show();
}

From source file:com.lykj.weixun.ui.chat.ui.ContactListFragment.java

/**
 * delete contact//from  w  ww .  j  a va  2  s .  c  om
 *
 * @param
 */
public void deleteContact(final EaseUser 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 {
                EMClient.getInstance().contactManager().deleteContact(tobeDeleteUser.getUsername());
                // remove user from memory and database
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoHelper.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        contactList.remove(tobeDeleteUser);
                        contactListLayout.refresh();

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

            }

        }
    }).start();

}

From source file:fm.smart.r1.activity.CreateItemActivity.java

public void onClick(View v) {
    EditText cueInput = (EditText) findViewById(R.id.cue);
    EditText responseInput = (EditText) findViewById(R.id.response);
    Spinner posInput = (Spinner) findViewById(R.id.pos);
    EditText characterResponseInput = (EditText) findViewById(R.id.response_character);
    EditText characterCueInput = (EditText) findViewById(R.id.cue_character);
    final String cue = cueInput.getText().toString();
    final String response = responseInput.getText().toString();
    final String pos = posInput.getSelectedItem().toString();
    final String character_cue = characterCueInput.getText().toString();
    final String character_response = characterResponseInput.getText().toString();
    String pos_code = Utils.POS_MAP.get(pos);
    if (TextUtils.isEmpty(pos_code)) {
        pos_code = "NONE";
    }/*from   w  ww.  ja  va  2 s .  c o  m*/
    final String final_pos_code = pos_code;

    if (Main.isNotLoggedIn(this)) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClassName(this, LoginActivity.class.getName());
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
        // navigation
        // back to this?
        LoginActivity.return_to = CreateItemActivity.class.getName();
        LoginActivity.params = new HashMap<String, String>();
        LoginActivity.params.put("list_id", list_id);
        LoginActivity.params.put("cue", cue);
        LoginActivity.params.put("response", response);
        LoginActivity.params.put("cue_language", cue_language);
        LoginActivity.params.put("response_language", response_language);
        LoginActivity.params.put("pos", pos);
        LoginActivity.params.put("character_cue", character_cue);
        LoginActivity.params.put("character_response", character_response);
        startActivity(intent);
    } else {
        // TODO cue and response languages need to be inferred from list we are
        // adding to ... Might want to fix those, i.e. not allow variation
        // on
        // search ...
        // TODO wondering whether there is some way to edit existing items
        // ...

        final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
        myOtherProgressDialog.setTitle("Please Wait ...");
        myOtherProgressDialog.setMessage("Creating Item ...");
        myOtherProgressDialog.setIndeterminate(true);
        myOtherProgressDialog.setCancelable(true);

        final Thread create_item = new Thread() {
            public void run() {
                // TODO make this interruptable .../*if
                // (!this.isInterrupted())*/
                CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue,
                        final_pos_code, response, response_language, character_response, list_id);

                myOtherProgressDialog.dismiss();

            }
        };
        myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                create_item.interrupt();
            }
        });
        OnCancelListener ocl = new OnCancelListener() {
            public void onCancel(DialogInterface arg0) {
                create_item.interrupt();
            }
        };
        myOtherProgressDialog.setOnCancelListener(ocl);
        myOtherProgressDialog.show();
        create_item.start();
    }
}

From source file:com.easemob.qixin.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();//from  w w  w . ja v a  2 s  . c om
    DemoApplication.getInstance().logout(new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

        @Override
        public void onProgress(int progress, String status) {

        }

        @Override
        public void onError(int code, String message) {

        }
    });
}

From source file:com.happysanta.vkspy.Fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = getActivity();/*ww w  .j  av a  2 s  .c o m*/

    if (savedInstanceState != null && UberFunktion.loading) {
        ProgressDialog dialog = new ProgressDialog(context);
        dialog.setMessage(context.getString(R.string.durov_function_activating_message));
        UberFunktion.putNewDialogWindow(dialog);
        dialog.show();
    }

    View rootView = inflater.inflate(R.layout.fragment_main, null);

    View happySanta = inflater.inflate(R.layout.main_santa, null);

    TextView happySantaText = (TextView) happySanta.findViewById(R.id.happySantaText);
    happySantaText.setText(Html.fromHtml(context.getString(R.string.app_description)));
    TextView happySantaLink = (TextView) happySanta.findViewById(R.id.happySantaLink);
    happySantaLink.setText(Html.fromHtml("vk.com/<b>happysanta</b>"));
    happySantaLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vk.com/happysanta"));
            startActivity(browserIntent);
        }
    });
    happySanta.setOnClickListener(new View.OnClickListener() {
        int i = 1;

        @Override
        public void onClick(View v) {
            if (i < 10)
                i++;
            else {
                i = 0;
                File F = Logs.getFile();
                Uri U = Uri.fromFile(F);
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("text/plain");
                i.putExtra(Intent.EXTRA_STREAM, U);
                startActivity(Intent.createChooser(i, "What should we do with logs?"));
            }
        }
    });

    SharedPreferences longpollPreferences = context.getSharedPreferences("longpoll",
            Context.MODE_MULTI_PROCESS);
    boolean longpollStatus = longpollPreferences.getBoolean("status", true);

    /*Bitmap tile = BitmapFactory.decodeResource(context.getResources(), R.drawable.underline);
    BitmapDrawable tiledBitmapDrawable = new BitmapDrawable(context.getResources(), tile);
    tiledBitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
    //tiledBitmapDrawable.setTileModeY(Shader.TileMode.REPEAT);
            
    santaGroundView.setBackgroundDrawable(tiledBitmapDrawable);
            
    BitmapDrawable bitmap = new BitmapDrawable(BitmapFactory.decodeResource(
        getResources(), R.drawable.underline2));
    bitmap.setTileModeX(Shader.TileMode.REPEAT);
    */
    LinearLayout layout = (LinearLayout) happySanta.findViewById(R.id.line);
    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int width = display.getWidth(); // deprecated

    for (int i = 0; width % (341 * i + 1) < width; i++) {
        layout.addView(new ImageView(context) {
            {
                setImageResource(R.drawable.underline2);
                setLayoutParams(new ViewGroup.LayoutParams(341, Helper.convertToDp(4)));
                setScaleType(ScaleType.CENTER_CROP);
            }
        });
    }

    ListView preferencesView = (ListView) rootView.findViewById(R.id.preference);
    preferencesView.addHeaderView(happySanta, null, false);
    ArrayList<PreferenceItem> preferences = new ArrayList<PreferenceItem>();
    /*
    preferences.add(new PreferenceItem(getUberfunction(), getUberfunctionDescription()) {
    @Override
    public void onClick() {
            
        if(UberFunktion.loading) {
            ProgressDialog dialog = new ProgressDialog(context);
            dialog.setMessage(context.getString(R.string.durov_function_activating_message));
            UberFunktion.putNewDialogWindow(dialog);
            dialog.show();
            return;
        }
            
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        final AlertDialog selector;
        View durov = getActivity().getLayoutInflater().inflate(R.layout.durov, null);
        SharedPreferences durovPreferences = context.getSharedPreferences("durov", Context.MODE_MULTI_PROCESS);
        boolean updateOnly = durovPreferences.getBoolean("loaded", false);
        if(updateOnly)
            ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_function_activated);
            
            
        if(Memory.users.getById(1)!=null && !updateOnly) {
            builder.setTitle(R.string.durov_joke_title);
            ((TextView)durov.findViewById(R.id.description)).setText(R.string.durov_joke_message);
            ( durov.findViewById(R.id.cat)).setVisibility(View.VISIBLE);
            
            builder.setNegativeButton(R.string.durov_joke_button, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
            
                    BugSenseHandler.sendEvent("? ?  ");
                }
            });
            BugSenseHandler.sendEvent("DUROV FRIEND CATCHED!!1");
        }else{
            builder.setTitle(R.string.durov_start_title);
            
            ( durov.findViewById(R.id.photo)).setVisibility(View.VISIBLE);
            ImageLoader.getInstance().displayImage("http://cs9591.vk.me/v9591001/70/VPSmUR954fQ.jpg",(ImageView) durov.findViewById(R.id.photo));
            builder.
                    setPositiveButton(updateOnly ? R.string.durov_start_update : R.string.durov_start_ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
            
                            BugSenseHandler.sendEvent("  ");
                            ProgressDialog uberfunctionDialog = ProgressDialog.show(getActivity(),
                                    context.getString(R.string.durov_function_activating_title),
                                    context.getString(R.string.durov_function_activating_message),
                                    true,
                                    false);
                            UberFunktion.initialize(uberfunctionDialog);
            
                        }
                    });
            builder.setNegativeButton(R.string.durov_start_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
            
                    try {
                        Intent browserIntent = new Intent(
                                Intent.ACTION_VIEW,
                                Uri.parse("https://vk.com/id1")
                        );
                        startActivity(browserIntent);
            
                    }catch(Exception exp){
                        AlertDialog.Builder errorShower = new AlertDialog.Builder(getActivity());
                        if (exp instanceof ActivityNotFoundException) {
                            errorShower.setTitle(R.string.error);
                            errorShower.setMessage(R.string.no_browser);
            
                        } else {
                            errorShower.setTitle(R.string.error);
                            errorShower.setMessage(R.string.unknown_error);
                        }
                        errorShower.show();
                    }
                    BugSenseHandler.sendEvent("? ?  ");
                }
            });
        }
            
        builder.setView(durov);
        selector = builder.create();
        selector.show();
    }
    });
    */

    preferences.add(new ToggleablePreferenceItem(getEnableSpy(), null, longpollStatus) {

        @Override
        public void onToggle(Boolean isChecked) {
            longpollToggle(isChecked);
        }
    });

    preferences.add(new PreferenceItem(getAdvancedSettings()) {
        @Override
        public void onClick() {
            startActivity(new Intent(context, SettingsActivity.class));
        }
    });

    preferences.add(new PreferenceItem(getAbout()) {
        @Override
        public void onClick() {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            final AlertDialog aboutDialog;
            builder.setTitle(R.string.app_about).setCancelable(true)
                    .setPositiveButton(R.string.app_about_button, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });

            View aboutView = getActivity().getLayoutInflater().inflate(R.layout.about, null);

            TextView aboutDescription = (TextView) aboutView.findViewById(R.id.description);
            aboutDescription.setText(Html.fromHtml(getResources().getString(R.string.app_about_description)));
            aboutDescription.setMovementMethod(LinkMovementMethod.getInstance());

            aboutView.findViewById(R.id.license).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent browserIntent = new Intent(context, InfoActivity.class);
                    startActivity(browserIntent);
                }
            });

            builder.setView(aboutView);
            aboutDialog = builder.create();
            aboutDialog.setCanceledOnTouchOutside(true);
            aboutDialog.show();
        }
    });
    preferencesView.setAdapter(new PreferenceAdapter(context, preferences));

    return rootView;

}

From source file:com.easemob.chatuidemo.adapter.NewFriendsMsgAdapter.java

/**
 * ???/* w w  w  .  j  av  a2  s. com*/
 *
 * @param button
 * @param username
 */
public void acceptInvitation(final Button button, final InviteMessage msg) {
    final ProgressDialog pd = new ProgressDialog(context);
    String str1 = context.getResources().getString(R.string.Are_agree_with);
    final String str2 = context.getResources().getString(R.string.Has_agreed_to);
    final String str3 = context.getResources().getString(R.string.Agree_with_failure);
    pd.setMessage(str1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();

    RequestQueue requestQueue = Volley.newRequestQueue(context);

    requestQueue.start();

    requestQueue.add(new AutoLoginRequest(context, Request.Method.POST, Model.PathLoad,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    pd.dismiss();
                    button.setText(str2);
                    msg.setStatus(InviteMesageStatus.AGREED);
                    // db
                    ContentValues values = new ContentValues();
                    values.put(InviteMessgeDao.COLUMN_NAME_STATUS, msg.getStatus().ordinal());
                    messgeDao.updateMessage(msg.getId(), values);
                    button.setBackgroundDrawable(null);
                    button.setEnabled(false);

                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(context, str3 + error.getMessage(), 1).show();

                }
            }) {
        @Override
        protected void setParams(Map<String, String> params) {
            if (msg.getGroupId() == null) {//???
                params.put("sys", "msg");
                params.put("ctrl", "msger");
                params.put("action", "add_friend");
                params.put("friend_name", msg.getFrom());
            } else //??
            {
                params.put("sys", "msg");
                params.put("ctrl", "msger");
                params.put("action", "agree_group");
                params.put("stranger", msg.getFrom());
                params.put("group_sn", msg.getGroupId());
            }

        }
    });
}