Example usage for android.app ProgressDialog setCanceledOnTouchOutside

List of usage examples for android.app ProgressDialog setCanceledOnTouchOutside

Introduction

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

Prototype

public void setCanceledOnTouchOutside(boolean cancel) 

Source Link

Document

Sets whether this dialog is canceled when touched outside the window's bounds.

Usage

From source file:com.esri.arcgisruntime.generateofflinemapoverrides.MainActivity.java

/**
 * Shows a progress dialog for the given job.
 *
 * @param job to track progress from/* ww w .j av a2  s  .co m*/
 */
private void showProgressDialog(Job job) {
    // 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);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> job.cancel());
    progressDialog.show();

    // show the job's progress with the progress dialog
    job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress()));

    // dismiss dialog when job is done
    job.addJobDoneListener(progressDialog::dismiss);
}

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

private void applyCurrentPrivacySettings() {
    TLRPC.TL_account_setPrivacy req = new TLRPC.TL_account_setPrivacy();
    if (isGroup) {
        req.key = new TLRPC.TL_inputPrivacyKeyChatInvite();
    } else {/*from  w w w.  j  a v a2 s.c om*/
        req.key = new TLRPC.TL_inputPrivacyKeyStatusTimestamp();
    }
    if (currentType != 0 && currentPlus.size() > 0) {
        TLRPC.TL_inputPrivacyValueAllowUsers rule = new TLRPC.TL_inputPrivacyValueAllowUsers();
        for (int a = 0; a < currentPlus.size(); a++) {
            TLRPC.User user = MessagesController.getInstance().getUser(currentPlus.get(a));
            if (user != null) {
                TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
                if (inputUser != null) {
                    rule.users.add(inputUser);
                }
            }
        }
        req.rules.add(rule);
    }
    if (currentType != 1 && currentMinus.size() > 0) {
        TLRPC.TL_inputPrivacyValueDisallowUsers rule = new TLRPC.TL_inputPrivacyValueDisallowUsers();
        for (int a = 0; a < currentMinus.size(); a++) {
            TLRPC.User user = MessagesController.getInstance().getUser(currentMinus.get(a));
            if (user != null) {
                TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
                if (inputUser != null) {
                    rule.users.add(inputUser);
                }
            }
        }
        req.rules.add(rule);
    }
    if (currentType == 0) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueAllowAll());
    } else if (currentType == 1) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueDisallowAll());
    } else if (currentType == 2) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueAllowContacts());
    }
    ProgressDialog progressDialog = null;
    if (getParentActivity() != null) {
        progressDialog = new ProgressDialog(getParentActivity());
        progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(false);
        progressDialog.show();
    }
    final ProgressDialog progressDialogFinal = progressDialog;
    ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (progressDialogFinal != null) {
                            progressDialogFinal.dismiss();
                        }
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                    if (error == null) {
                        finishFragment();
                        TLRPC.TL_account_privacyRules rules = (TLRPC.TL_account_privacyRules) response;
                        MessagesController.getInstance().putUsers(rules.users, false);
                        ContactsController.getInstance().setPrivacyRules(rules.rules, isGroup);
                    } else {
                        showErrorAlert();
                    }
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}

From source file:cn.ucai.foraging.activity.ContactlistFragment.java

/**
 * user???/*from ww  w. j  a  v  a  2  s  .c  o m*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(cn.ucai.foraging.R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(cn.ucai.foraging.R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(cn.ucai.foraging.R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, 0).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, 0).show();
                    }
                });
            }
        }
    }).start();

}

From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java

/**
 * user???/*from w w  w .j  a  v a2 s. c o  m*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

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

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("SessionsTitle", R.string.SessionsTitle));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/*  w w  w.ja v a2  s  .  c om*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    emptyLayout = new LinearLayout(context);
    emptyLayout.setOrientation(LinearLayout.VERTICAL);
    emptyLayout.setGravity(Gravity.CENTER);
    //emptyLayout.setBackgroundResource(R.drawable.greydivider_bottom);
    emptyLayout.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
            AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()));

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.devices);
    emptyLayout.addView(imageView);
    LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    imageView.setLayoutParams(layoutParams2);

    TextView textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setText(LocaleController.getString("NoOtherSessions", R.string.NoOtherSessions));
    emptyLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.topMargin = AndroidUtilities.dp(16);
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER;
    textView.setLayoutParams(layoutParams2);

    textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.disabled_text) /*0xff8a8a8a*/);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    textView.setPadding(AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20), 0);
    textView.setText(LocaleController.getString("NoOtherSessionsInfo", R.string.NoOtherSessionsInfo));
    emptyLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.topMargin = AndroidUtilities.dp(14);
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER;
    textView.setLayoutParams(layoutParams2);

    FrameLayout progressView = new FrameLayout(context);
    frameLayout.addView(progressView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    progressView.setLayoutParams(layoutParams);
    progressView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    listView.setEmptyView(progressView);
    frameLayout.addView(listView);
    layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP;
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i == terminateAllSessionsRow) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setMessage(
                        LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions));
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                TLRPC.TL_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations();
                                ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                    @Override
                                    public void run(final TLObject response, final TLRPC.TL_error error) {
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                if (getParentActivity() == null) {
                                                    return;
                                                }
                                                if (error == null && response instanceof TLRPC.TL_boolTrue) {
                                                    Toast toast = Toast.makeText(getParentActivity(),
                                                            LocaleController.getString("TerminateAllSessions",
                                                                    R.string.TerminateAllSessions),
                                                            Toast.LENGTH_SHORT);
                                                    toast.show();
                                                } else {
                                                    Toast toast = Toast
                                                            .makeText(getParentActivity(),
                                                                    LocaleController.getString("UnknownError",
                                                                            R.string.UnknownError),
                                                                    Toast.LENGTH_SHORT);
                                                    toast.show();
                                                }
                                                finishFragment();
                                            }
                                        });
                                        UserConfig.registeredForPush = false;
                                        UserConfig.saveConfig(false);
                                        MessagesController.getInstance().registerForPush(UserConfig.pushString);
                                        ConnectionsManager.getInstance()
                                                .setUserId(UserConfig.getClientUserId());
                                    }
                                });
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i >= otherSessionsStartRow && i < otherSessionsEndRow) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setMessage(LocaleController.getString("TerminateSessionQuestion",
                        R.string.TerminateSessionQuestion));
                builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int option) {
                                final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
                                progressDialog
                                        .setMessage(LocaleController.getString("Loading", R.string.Loading));
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog.setCancelable(false);
                                progressDialog.show();

                                final TLRPC.TL_authorization authorization = sessions
                                        .get(i - otherSessionsStartRow);
                                TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
                                req.hash = authorization.hash;
                                ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
                                    @Override
                                    public void run(final TLObject response, final TLRPC.TL_error error) {
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                try {
                                                    progressDialog.dismiss();
                                                } catch (Exception e) {
                                                    FileLog.e("tmessages", e);
                                                }
                                                if (error == null) {
                                                    sessions.remove(authorization);
                                                    updateRows();
                                                    if (listAdapter != null) {
                                                        listAdapter.notifyDataSetChanged();
                                                    }
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            }
        }
    });

    return fragmentView;
}

From source file:com.easemob.chatuidemo.activity.LoginFragment.java

public void login(final String currentUsername, final String currentPassword, final ProgressDialog pd) {
    if (!CommonUtils.isNetWorkConnected(getActivity())) {
        Toast.makeText(getActivity(), R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;/*  w w  w  . j  av  a  2s  .  c  om*/
    }
    if (TextUtils.isEmpty(currentUsername)) {
        Toast.makeText(getActivity(), R.string.User_name_cannot_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }
    if (TextUtils.isEmpty(currentPassword)) {
        Toast.makeText(getActivity(), R.string.Password_cannot_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }

    progressShow = true;
    pd.setCanceledOnTouchOutside(false);
    pd.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            progressShow = false;
        }
    });
    pd.setMessage(getString(R.string.Is_landing));
    pd.show();

    final long start = System.currentTimeMillis();
    // sdk??
    EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() {

        @Override
        public void onSuccess() {
            if (!progressShow) {
                return;
            }
            // ?????
            HXApplication.getInstance().setUserName(currentUsername);
            HXApplication.getInstance().setPassword(currentPassword);

            try {
                // ** ?logout???
                // ** manually load all local groups and
                EMGroupManager.getInstance().loadAllGroups();
                EMChatManager.getInstance().loadAllConversations();
                // ??
                initializeContacts();
            } catch (Exception e) {
                e.printStackTrace();
                // ?????
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        HXApplication.getInstance().logout(null);
                        Toast.makeText(getActivity().getApplicationContext(), R.string.login_failure_failed, 1)
                                .show();
                    }
                });
                return;
            }
            // ?nickname ios?nick
            boolean updatenick = EMChatManager.getInstance()
                    .updateCurrentUserNick(HXApplication.currentUserNick.trim());
            if (!updatenick) {
                Log.e("LoginActivity", "update current user nick fail");
            }
            if (!getActivity().isFinishing() && pd.isShowing()) {
                pd.dismiss();
            }
            // ?
            startMainActivity();
        }

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

        @Override
        public void onError(final int code, final String message) {
            if (!progressShow) {
                return;
            }
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    Toast.makeText(getActivity().getApplicationContext(),
                            getString(R.string.Login_failed) + message, Toast.LENGTH_SHORT).show();
                }
            });
        }
    });
}

From source file:com.einzig.ipst2.activities.MainActivity.java

/**
 * Wrapper function for parseEmailWork./*from w  w w. j  a  v a2  s.  c  o  m*/
 * <p>
 * Builds the progress dialog for, then calls parseEmailWork
 * </p>
 *
 * @see MainActivity#parseEmailWork(Account, ProgressDialog)
 */
private void parseEmail() {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        Logger.d("IS MAIN THREAD?!");
    }
    final Account account = getAccount();
    if (account != null) {
        final ProgressDialog dialog = new ProgressDialog(this, ThemeHelper.getDialogTheme(this));
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setIndeterminate(true);
        dialog.setTitle(getString(R.string.searching_email));
        dialog.setCanceledOnTouchOutside(false);
        dialog.setCancelable(false);
        dialog.show();
        new Thread() {
            public void run() {
                parseEmailWork(account, dialog);
            }
        }.start();
        //getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        //getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}

From source file:cn.ucai.superwechat.fragment.ContactlistFragment.java

/**
 * user???// w  ww  .  j av  a 2s.c o  m
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(cn.ucai.superwechat.R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(cn.ucai.superwechat.R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(cn.ucai.superwechat.R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

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

private void cleanupFolders() {
    final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setCancelable(false);
    progressDialog.show();/*from   w ww . j  av a 2s. co m*/
    Utilities.globalQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            boolean imagesCleared = false;
            for (int a = 0; a < 6; a++) {
                if (!clear[a]) {
                    continue;
                }
                int type = -1;
                int documentsMusicType = 0;
                if (a == 0) {
                    type = FileLoader.MEDIA_DIR_IMAGE;
                } else if (a == 1) {
                    type = FileLoader.MEDIA_DIR_VIDEO;
                } else if (a == 2) {
                    type = FileLoader.MEDIA_DIR_DOCUMENT;
                    documentsMusicType = 1;
                } else if (a == 3) {
                    type = FileLoader.MEDIA_DIR_DOCUMENT;
                    documentsMusicType = 2;
                } else if (a == 4) {
                    type = FileLoader.MEDIA_DIR_AUDIO;
                } else if (a == 5) {
                    type = FileLoader.MEDIA_DIR_CACHE;
                }
                if (type == -1) {
                    continue;
                }
                File file = FileLoader.getInstance().checkDirectory(type);
                if (file != null) {
                    try {
                        File[] array = file.listFiles();
                        if (array != null) {
                            for (int b = 0; b < array.length; b++) {
                                String name = array[b].getName().toLowerCase();
                                if (documentsMusicType == 1 || documentsMusicType == 2) {
                                    if (name.endsWith(".mp3") || name.endsWith(".m4a")) {
                                        if (documentsMusicType == 1) {
                                            continue;
                                        }
                                    } else if (documentsMusicType == 2) {
                                        continue;
                                    }
                                }
                                if (name.equals(".nomedia")) {
                                    continue;
                                }
                                if (array[b].isFile()) {
                                    array[b].delete();
                                }
                            }
                        }
                    } catch (Throwable e) {
                        FileLog.e("tmessages", e);
                    }
                }
                if (type == FileLoader.MEDIA_DIR_CACHE) {
                    cacheSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_CACHE),
                            documentsMusicType);
                    imagesCleared = true;
                } else if (type == FileLoader.MEDIA_DIR_AUDIO) {
                    audioSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_AUDIO),
                            documentsMusicType);
                } else if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
                    if (documentsMusicType == 1) {
                        documentsSize = getDirectorySize(
                                FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT),
                                documentsMusicType);
                    } else {
                        musicSize = getDirectorySize(
                                FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT),
                                documentsMusicType);
                    }
                } else if (type == FileLoader.MEDIA_DIR_IMAGE) {
                    imagesCleared = true;
                    photoSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_IMAGE),
                            documentsMusicType);
                } else if (type == FileLoader.MEDIA_DIR_VIDEO) {
                    videoSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_VIDEO),
                            documentsMusicType);
                }
            }
            final boolean imagesClearedFinal = imagesCleared;
            totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (imagesClearedFinal) {
                        ImageLoader.getInstance().clearMemory();
                    }
                    if (listAdapter != null) {
                        listAdapter.notifyDataSetChanged();
                    }
                    try {
                        progressDialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            });
        }
    });
}

From source file:com.app.khclub.base.easeim.activity.ContactlistFragment.java

/**
 * user???/* w w  w  .j  a  v  a  2 s . com*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                // ???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, 0).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, 0).show();
                    }
                });
            }
        }
    }).start();

}