Example usage for android.app Dialog hide

List of usage examples for android.app Dialog hide

Introduction

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

Prototype

public void hide() 

Source Link

Document

Hide the dialog, but do not dismiss it.

Usage

From source file:com.filelocker.andy.MainActivity.java

public void browseButton_Click(View view) {
    final TextView vFileChooserText = (TextView) findViewById(R.id.fileChooserText);
    final FileChooserDialog dialog = new FileChooserDialog(this);
    dialog.show();/*w w w .j  a va2s .co  m*/
    dialog.addListener(new FileChooserDialog.OnFileSelectedListener() {
        public void onFileSelected(Dialog source, File file) {
            source.hide();
            Toast toast = Toast.makeText(source.getContext(), "File selected: " + file.getName(),
                    Toast.LENGTH_LONG);
            toast.show();
            vFileChooserText.setText(file.getAbsolutePath());
            dialog.hide();
        }

        public void onFileSelected(Dialog source, File folder, String name) {
            source.hide();
            Toast toast = Toast.makeText(source.getContext(), "File created: " + folder.getName() + "/" + name,
                    Toast.LENGTH_LONG);
            toast.show();
            dialog.hide();
        }
    });
}

From source file:it.unicaradio.android.activities.MainActivity.java

private void showUpdatesDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.popup);
    dialog.setTitle(R.string.application_updated);
    dialog.setCancelable(true);/* ww  w  .  ja  va2s.  c o m*/

    TextView textView = (TextView) dialog.findViewById(R.id.updatesText);
    textView.setText(R.string.updates);

    Button button = (Button) dialog.findViewById(R.id.updatesButton);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.hide();
        }
    });
    dialog.show();
}

From source file:onion.chat.MainActivity.java

void contactLongPress(final String address, final String name) {
    View v = getLayoutInflater().inflate(R.layout.dialog_contact, null);
    ((TextView) v.findViewById(R.id.name)).setText(name);
    ((TextView) v.findViewById(R.id.address)).setText(address);
    final Dialog dlg = new AlertDialog.Builder(MainActivity.this).setView(v).create();

    v.findViewById(R.id.openchat).setOnClickListener(new View.OnClickListener() {
        @Override/*  w  w w .j  ava  2  s  . c  o  m*/
        public void onClick(View v) {
            dlg.hide();
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("chat:" + address), getApplicationContext(),
                    ChatActivity.class));
        }
    });
    v.findViewById(R.id.changename).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dlg.hide();
            changeContactName(address, name);
        }
    });
    v.findViewById(R.id.copyid).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dlg.hide();
            ((android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE)).setText(address);
            snack(getString(R.string.id_copied_to_clipboard) + address);
        }
    });
    v.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dlg.hide();
            new AlertDialog.Builder(MainActivity.this).setTitle(R.string.delete_contact_q)
                    .setMessage(String.format(getString(R.string.really_delete_contact), address))
                    .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            db.removeContact(address);
                            updateContactList();
                        }
                    }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    }).show();
            //db.removeContact(address);
            //updateContactList();
        }
    });

    dlg.show();
    // inform();
}

From source file:edu.sfsu.csc780.chathub.ui.ChannelActivity.java

public void openBottomSheet() {
    View view = getLayoutInflater().inflate(R.layout.bottom_sheet_modal, null);
    final Dialog mBottomSheetDialog = new Dialog(ChannelActivity.this, R.style.MaterialDialogSheet);
    mBottomSheetDialog.setContentView(view);
    mBottomSheetDialog.setCancelable(true);
    mBottomSheetDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM);
    mBottomSheetDialog.show();//from   w  w w  .ja v  a 2 s .co m

    mImageButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.shareImageButton);
    mImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            pickImage();
            mBottomSheetDialog.hide();
        }
    });

    mPhotoButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.cameraButton);
    mPhotoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dispatchTakePhotoIntent();
            mBottomSheetDialog.hide();
        }
    });

    mLocationButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.locationButton);
    mLocationButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadMap();
            mBottomSheetDialog.hide();
        }
    });

    mProgress = new ProgressDialog(this);
    mStorage = FirebaseStorage.getInstance().getReference();
    mAudioButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.voiceButton);
    mAudioButton.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent motionEvent) {

            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {

                startRecording();

                Context context = getApplicationContext();
                CharSequence text = "Recording Started!";
                int duration = Toast.LENGTH_SHORT;

                Toast toast = Toast.makeText(context, text, duration);
                toast.show();

            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {

                stopRecording();
                mBottomSheetDialog.hide();

                Context context = getApplicationContext();
                CharSequence text = "Recording Stopped!";
                int duration = Toast.LENGTH_SHORT;

                Toast toast = Toast.makeText(context, text, duration);
                toast.show();

            }

            return false;
        }
    });
    mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
    mFileName += "/recorded_audio.3gp";

    mStickerButton = (BadgedStickersButton) mBottomSheetDialog.findViewById(R.id.stickerButton);
    StickersFragment stickersFragment = (StickersFragment) getSupportFragmentManager()
            .findFragmentById(R.id.frame);
    if (stickersFragment == null) {
        stickersFragment = new StickersFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.frame, stickersFragment).commit();
    }
    stickersFragment.setOnStickerSelectedListener(stickerSelectedListener);
    View stickersFrame = findViewById(R.id.frame);
    View chatContentGroup = findViewById(R.id.chat_content);
    StickersKeyboardLayout stickersLayout = (StickersKeyboardLayout) findViewById(R.id.sizeNotifierLayout);
    stickersKeyboardController = new StickersKeyboardController.Builder(this)
            .setStickersKeyboardLayout(stickersLayout).setStickersFragment(stickersFragment)
            .setStickersFrame(stickersFrame).setContentContainer(chatContentGroup)
            .setStickersButton(mStickerButton).setChatEdit(mMessageEditText).build();

    mDrawButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.drawButton);
    mDrawButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(ChannelActivity.this, DrawingActivity.class));
            mBottomSheetDialog.hide();
        }
    });
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

private void openReferencesList(final String from) {
    final List<Integer> positions = new ArrayList<>();
    int position = -1;
    for (int i = 0; i < presentationModel.presentationList.size(); ++i) {
        if (presentationModel.presentationList.get(i).sourceModel.number.equals(from)) {
            position = i;//from w ww.java  2 s  .  c  o  m
            break;
        }
    }
    if (position != -1) {
        Spanned referencesString = presentationModel.presentationList.get(position).referencesString;
        if (referencesString == null) {
            Logger.e(TAG, "null referencesString");
            return;
        }
        ClickableURLSpan[] spans = referencesString.getSpans(0, referencesString.length(),
                ClickableURLSpan.class);
        for (ClickableURLSpan span : spans) {
            String url = span.getURL();
            try {
                //url    , .. ???  PresentationItemModel ( )
                UrlPageModel model = UrlHandler.getPageModel(url);
                for (; position < presentationModel.presentationList.size(); ++position) {
                    if (presentationModel.presentationList.get(position).sourceModel.number
                            .equals(model.postNumber)) {
                        break;
                    }
                }
                if (position < presentationModel.presentationList.size())
                    positions.add(position);
            } catch (Exception e) {
                Logger.e(TAG, e);
            }
        }
    }

    if (positions.size() == 0) {
        Logger.e(TAG, "no references");
        return;
    }

    final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow);
    final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground,
            Color.BLACK);
    final View tmpV = new View(activity);
    final Dialog tmpDlg = new Dialog(activity);
    tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource);
    tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
    tmpDlg.setCanceledOnTouchOutside(true);
    tmpDlg.setContentView(tmpV);
    tmpDlg.show();
    Runnable next = new Runnable() {
        @Override
        public void run() {
            final int dlgWidth = tmpV.getWidth();
            tmpDlg.hide();
            tmpDlg.cancel();

            ListView dlgList = new ListView(activity);
            dlgList.setAdapter(new ArrayAdapter<Integer>(activity, 0, positions) {
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    try {
                        int adapterPositon = getItem(position);
                        View view = adapter.getView(adapterPositon, convertView, parent, dlgWidth,
                                adapter.getItem(adapterPositon), from);
                        view.setBackgroundColor(bgColor);
                        return view;
                    } catch (Exception e) {
                        Logger.e(TAG, e);
                        Toast.makeText(activity, R.string.error_unknown, Toast.LENGTH_LONG).show();
                        return new View(activity);
                    }
                }
            });

            Dialog dialog = new Dialog(activity);
            dialog.getWindow().setBackgroundDrawableResource(bgShadowResource);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setContentView(dlgList);
            dialog.show();
            dialogs.add(dialog);
        }
    };
    if (tmpV.getWidth() != 0) {
        next.run();
    } else {
        AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next);
    }
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

private void showThreadPreviewDialog(final int position) {
    final List<PresentationItemModel> items = new ArrayList<>();
    final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow);
    final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground,
            Color.BLACK);//  w  w w. ja  va2s.com
    final View tmpV = new View(activity);
    final Dialog tmpDlg = new Dialog(activity);
    tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource);
    tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
    tmpDlg.setCanceledOnTouchOutside(true);
    tmpDlg.setContentView(tmpV);
    tmpDlg.show();
    Runnable next = new Runnable() {
        @Override
        public void run() {
            final int dlgWidth = tmpV.getWidth();
            tmpDlg.hide();
            tmpDlg.cancel();
            final Dialog dialog = new Dialog(activity);

            if (presentationModel.source != null && presentationModel.source.threads != null
                    && presentationModel.source.threads.length > position
                    && presentationModel.source.threads[position].posts != null
                    && presentationModel.source.threads[position].posts.length > 0) {

                final String threadNumber = presentationModel.source.threads[position].posts[0].number;

                ClickableURLSpan.URLSpanClickListener spanClickListener = new ClickableURLSpan.URLSpanClickListener() {
                    @Override
                    public void onClick(View v, ClickableURLSpan span, String url, String referer) {
                        if (url.startsWith("#")) {
                            try {
                                UrlPageModel threadPageModel = new UrlPageModel();
                                threadPageModel.chanName = chan.getChanName();
                                threadPageModel.type = UrlPageModel.TYPE_THREADPAGE;
                                threadPageModel.boardName = tabModel.pageModel.boardName;
                                threadPageModel.threadNumber = threadNumber;
                                url = chan.buildUrl(threadPageModel) + url;
                                dialog.dismiss();
                                UrlHandler.open(chan.fixRelativeUrl(url), activity);
                            } catch (Exception e) {
                                Logger.e(TAG, e);
                            }
                        } else {
                            dialog.dismiss();
                            UrlHandler.open(chan.fixRelativeUrl(url), activity);
                        }
                    }
                };

                AndroidDateFormat.initPattern();
                String datePattern = AndroidDateFormat.getPattern();
                DateFormat dateFormat = datePattern == null
                        ? DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                        : new SimpleDateFormat(datePattern, Locale.US);
                dateFormat.setTimeZone(settings.isLocalTime() ? TimeZone.getDefault()
                        : TimeZone.getTimeZone(presentationModel.source.boardModel.timeZoneId));

                int postsCount = presentationModel.source.threads[position].postsCount;
                boolean showIndex = presentationModel.source.threads[position].posts.length <= postsCount;
                int curPostIndex = postsCount - presentationModel.source.threads[position].posts.length + 1;

                boolean openSpoilers = settings.openSpoilers();

                for (int i = 0; i < presentationModel.source.threads[position].posts.length; ++i) {
                    PresentationItemModel model = new PresentationItemModel(
                            presentationModel.source.threads[position].posts[i], chan.getChanName(),
                            presentationModel.source.pageModel.boardName,
                            presentationModel.source.pageModel.threadNumber, dateFormat, spanClickListener,
                            imageGetter, ThemeUtils.ThemeColors.getInstance(activity.getTheme()), openSpoilers,
                            floatingModels, null);
                    model.buildSpannedHeader(showIndex ? (i == 0 ? 1 : ++curPostIndex) : -1,
                            presentationModel.source.boardModel.bumpLimit,
                            presentationModel.source.boardModel.defaultUserName, null, false);
                    items.add(model);
                }
            } else {
                items.add(presentationModel.presentationList.get(position));
            }
            ListView dlgList = new ListView(activity);
            dlgList.setAdapter(new ArrayAdapter<PresentationItemModel>(activity, 0, items) {
                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    View view = adapter.getView(position, convertView, parent, dlgWidth, getItem(position));
                    view.setBackgroundColor(bgColor);
                    return view;
                }
            });
            dialog.getWindow().setBackgroundDrawableResource(bgShadowResource);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setContentView(dlgList);
            dialog.show();
            dialogs.add(dialog);
        }
    };
    if (tmpV.getWidth() != 0) {
        next.run();
    } else {
        AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next);
    }
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

/**
 *  ?  ? ?/* www.j av a  2 s .c o  m*/
 * @param itemPosition ? ? (?)   listView
 * @param isTablet true, ?   (??   ? ??)
 * @param coordinates   ??
 */
private void showPostPopupDialog(final int itemPosition, final boolean isTablet, final Point coordinates,
        final String refererPost) {
    final int bgShadowResource = ThemeUtils.getThemeResId(activity.getTheme(), R.attr.dialogBackgroundShadow);
    final int bgColor = ThemeUtils.getThemeColor(activity.getTheme(), R.attr.activityRootBackground,
            Color.BLACK);
    final int measuredWidth = isTablet ? adapter.measureViewWidth(itemPosition) : -1; //? ??  ? 
    final View tmpV = new View(activity);
    final Dialog tmpDlg = new Dialog(activity);
    tmpDlg.getWindow().setBackgroundDrawableResource(bgShadowResource);
    tmpDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
    tmpDlg.setCanceledOnTouchOutside(true);
    tmpDlg.setContentView(tmpV);
    final Rect activityWindowRect;
    final int dlgWindowWidth;
    final int dlgWindowHeight;
    if (isTablet) {
        activityWindowRect = new Rect();
        activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(activityWindowRect);
        dlgWindowWidth = Math.max(coordinates.x, activityWindowRect.width() - coordinates.x);
        dlgWindowHeight = Math.max(coordinates.y, activityWindowRect.height() - coordinates.y);
        tmpDlg.getWindow().setLayout(dlgWindowWidth, dlgWindowHeight);
    } else {
        activityWindowRect = null;
        dlgWindowWidth = -1;
        dlgWindowHeight = -1;
    }
    tmpDlg.show();

    Runnable next = new Runnable() {
        @SuppressLint("RtlHardcoded")
        @Override
        public void run() {
            int dlgWidth = tmpV.getWidth();
            int dlgHeight = tmpV.getHeight();
            tmpDlg.hide();
            tmpDlg.cancel();
            int newWidth = isTablet ? Math.min(measuredWidth, dlgWidth) : dlgWidth;

            View view = adapter.getView(itemPosition, null, null, newWidth, refererPost);
            view.setBackgroundColor(bgColor);
            //Logger.d(TAG, "measured: "+view.findViewById(R.id.post_frame_main).getMeasuredWidth()+
            //        "x"+view.findViewById(R.id.post_frame_main).getMeasuredHeight());

            Dialog dialog = new Dialog(activity);
            dialog.getWindow().setBackgroundDrawableResource(bgShadowResource);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCanceledOnTouchOutside(true);
            dialog.setContentView(view);
            if (isTablet) {
                view.findViewById(R.id.post_frame_main).measure(
                        MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY),
                        MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
                int newWindowWidth = dlgWindowWidth - dlgWidth + newWidth;
                int newWindowHeight = dlgWindowHeight - dlgHeight
                        + Math.min(view.findViewById(R.id.post_frame_main).getMeasuredHeight(), dlgHeight);
                dialog.getWindow().setLayout(newWindowWidth, newWindowHeight);
                WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
                if (coordinates.x > activityWindowRect.width() - coordinates.x
                        && coordinates.x + newWindowWidth > activityWindowRect.width()) {
                    params.x = activityWindowRect.width() - coordinates.x;
                    params.gravity = Gravity.RIGHT;
                } else {
                    params.x = coordinates.x;
                    params.gravity = Gravity.LEFT;
                }
                if (coordinates.y > activityWindowRect.height() - coordinates.y
                        && coordinates.y + newWindowHeight > activityWindowRect.height()) {
                    params.y = activityWindowRect.height() - coordinates.y;
                    params.gravity |= Gravity.BOTTOM;
                } else {
                    params.y = coordinates.y;
                    params.gravity |= Gravity.TOP;
                }
                dialog.getWindow().setAttributes(params);

                //     
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    CompatibilityImpl.setDimAmount(dialog.getWindow(), 0.1f);
                } else {
                    dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                }
            }
            dialog.show();
            dialogs.add(dialog);
        }
    };

    if (tmpV.getWidth() != 0) {
        next.run();
    } else {
        AppearanceUtils.callWhenLoaded(tmpDlg.getWindow().getDecorView(), next);
    }
}