Example usage for android.app Dialog isShowing

List of usage examples for android.app Dialog isShowing

Introduction

In this page you can find the example usage for android.app Dialog isShowing.

Prototype

public boolean isShowing() 

Source Link

Usage

From source file:com.owncloud.android.authentication.AuthenticatorActivity.java

@Override
public void onSsoFinished(String sessionCookies) {
    // Toast.makeText(this, "got cookies: " + sessionCookie,
    // Toast.LENGTH_LONG).show();

    if (sessionCookies != null && sessionCookies.length() > 0) {
        Log_OC.d(TAG, "Successful SSO - time to save the account");
        onSamlDialogSuccess(sessionCookies);
        Fragment fd = getSupportFragmentManager().findFragmentByTag(TAG_SAML_DIALOG);
        if (fd != null && fd instanceof SherlockDialogFragment) {
            Dialog d = ((SherlockDialogFragment) fd).getDialog();
            if (d != null && d.isShowing()) {
                d.dismiss();/*w ww  .j a  v  a 2  s  .c o m*/
            }
        }

    } else {
        // TODO - show fail
        Log_OC.d(TAG, "SSO failed");
    }

}

From source file:com.aegiswallet.actions.MainActivity.java

private void doBackupReminder() {

    if (System.currentTimeMillis() - application.lastReminderTime < 60000)
        return;/* w  w w .j  a  va2  s  . co  m*/

    String lastBackupString = prefs.getString(Constants.LAST_BACKUP_DATE, null);
    int lastBackupNumAddresses = prefs.getInt(Constants.LAST_BACKUP_NUM_ADDRESSES, 0);

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.backup_reminder_prompt);

    TextView backupText = (TextView) dialog.findViewById(R.id.backup_reminder_prompt_text);

    Button cancelButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_cancel_button);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    final Button okayButton = (Button) dialog.findViewById(R.id.backup_reminder_prompt_ok_button);

    okayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();

            if (nfcEnabled) {
                Intent intent = new Intent(context, NFCActivity.class);
                intent.putExtra("nfc_action", "backup");
                startActivity(intent);
            } else
                application.showPasswordPrompt(context, Constants.ACTION_BACKUP);
        }
    });

    try {

        if (dialog.isShowing())
            return;

        if (lastBackupString != null) {
            Date lastBackupDate = Constants.backupDateFormat.parse(lastBackupString);
            long currentDate = System.currentTimeMillis();
            long difference = currentDate - lastBackupDate.getTime();

            long days = TimeUnit.MILLISECONDS.toDays(difference);
            int keyChainSize = wallet.getKeychainSize();

            if (days > 6) {
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();
            } else if (!prefs.contains(Constants.LAST_BACKUP_NUM_ADDRESSES)) {
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();

            } else if (keyChainSize > lastBackupNumAddresses) {
                backupText.setText(getString(R.string.backup_reminder_new_address));
                dialog.show();
                application.lastReminderTime = System.currentTimeMillis();
            }

        } else {
            application.lastReminderTime = System.currentTimeMillis();
            dialog.show();
        }

    } catch (ParseException e) {
        Log.d(TAG, e.getMessage());
    }
}

From source file:org.anurag.file.quest.TaskerActivity.java

/**
 * FUNCTION MAKE 3d LIST VIEW VISIBLE OR GONE AS PER REQUIREMENT
 * @param mode/*  ww  w.  j ava 2  s.com*/
 * @param con
 */
public static void load_FIle_Gallery(final int mode) {
    final Dialog pDialog = new Dialog(mContext, R.style.custom_dialog_theme);
    final Handler handle = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:
                try {
                    pDialog.setContentView(R.layout.p_dialog);
                    pDialog.setCancelable(false);
                    pDialog.getWindow().getAttributes().width = size.x * 4 / 5;
                    WebView web = (WebView) pDialog.findViewById(R.id.p_Web_View);
                    web.loadUrl("file:///android_asset/Progress_Bar_HTML/index.html");
                    web.setEnabled(false);
                    pDialog.show();
                } catch (InflateException e) {
                    error = true;
                    Toast.makeText(mContext,
                            "An exception encountered please wait while loading" + " file list",
                            Toast.LENGTH_SHORT).show();
                }
                break;
            case 1:
                if (pDialog != null)
                    if (pDialog.isShowing())
                        pDialog.dismiss();

                if (mediaFileList.size() > 0) {
                    FILE_GALLEY.setVisibility(View.GONE);
                    LIST_VIEW_3D.setVisibility(View.VISIBLE);
                    element = new MediaElementAdapter(mContext, R.layout.row_list_1, mediaFileList);
                    //AT THE PLACE OF ELEMENT YOU CAN USE MUSIC ADAPTER....
                    // AND SEE WHAT HAPPENS
                    if (mediaFileList.size() > 0) {
                        LIST_VIEW_3D.setAdapter(element);
                        LIST_VIEW_3D.setEnabled(true);
                    } else if (mediaFileList.size() == 0) {
                        LIST_VIEW_3D.setAdapter(new EmptyAdapter(mContext, R.layout.row_list_3, EMPTY));
                        LIST_VIEW_3D.setEnabled(false);
                    }
                    LIST_VIEW_3D.setDynamics(new SimpleDynamics(0.7f, 0.6f));
                    if (!elementInFocus) {
                        mFlipperBottom.showPrevious();
                        mFlipperBottom.setAnimation(prevAnim());
                        elementInFocus = true;
                    }
                    if (SEARCH_FLAG) {
                        mVFlipper.showPrevious();
                        mVFlipper.setAnimation(nextAnim());
                    }
                } else {
                    LIST_VIEW_3D.setVisibility(View.GONE);
                    FILE_GALLEY.setVisibility(View.VISIBLE);
                    Toast.makeText(mContext, R.string.empty, Toast.LENGTH_SHORT).show();
                    if (elementInFocus) {
                        mFlipperBottom.showNext();
                        mFlipperBottom.setAnimation(nextAnim());
                    }
                    elementInFocus = false;
                }
                break;
            }
        }
    };
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            handle.sendEmptyMessage(0);
            while (!Utils.loaded) {
                //STOPPING HERE WHILE FILES ARE BEING LOADED IN BACKGROUND....
            }
            if (mode == 0)
                mediaFileList = Utils.music;
            else if (mode == 1)
                mediaFileList = Utils.apps;
            else if (mode == 2)
                mediaFileList = Utils.doc;
            else if (mode == 3)
                mediaFileList = Utils.img;
            else if (mode == 4)
                mediaFileList = Utils.vids;
            else if (mode == 5)
                mediaFileList = Utils.zip;
            else if (mode == 6)
                mediaFileList = Utils.mis;
            handle.sendEmptyMessage(1);
        }
    });
    thread.start();
}