Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

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

Prototype

public Dialog(@NonNull Context context, @StyleRes int themeResId) 

Source Link

Document

Creates a dialog window that uses a custom dialog style.

Usage

From source file:com.fibrobook.viewpager.custom.CardFragment.java

public void symphtomsView(LinearLayout l) {

    LayoutParams params = new LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            android.view.ViewGroup.LayoutParams.MATCH_PARENT, Gravity.TOP);

    ListView symphtomList = new ListView(getActivity());
    symphtomList.setLayoutParams(params);

    ArrayAdapter<Disease> adapter = new ArrayAdapter<Disease>(getActivity(),
            android.R.layout.simple_list_item_1, symphtoms);
    symphtomList.setAdapter(adapter);/*  w w  w .ja  va2s . c  o m*/
    symphtomList.setClickable(true);

    symphtomList.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
            ratingDialog = new Dialog(getActivity(), com.fibrobook.R.style.FullHeightDialog);
            ratingDialog.setContentView(com.fibrobook.R.layout.rating_dialog);
            ratingDialog.setCancelable(true);
            RatingBar ratingBar = (RatingBar) ratingDialog.findViewById(com.fibrobook.R.id.dialog_ratingbar);

            int i = 0;
            boolean exists = false;
            while (i < ds.size()) {
                if (symphtoms.get(position).getId() == ds.get(i).getDisease().getId()) {
                    ads = ds.get(i);
                    ratingBar.setRating(ads.getIntensity());
                    exists = true;
                    break;
                }
                i++;
            }
            if (!exists)
                ads = new SymphtomSummary(MainActivity.user, symphtoms.get(position), MainActivity.date);

            Button updateButton = (Button) ratingDialog.findViewById(com.fibrobook.R.id.rank_dialog_button);
            updateButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    RatingBar ratingBar = (RatingBar) ratingDialog
                            .findViewById(com.fibrobook.R.id.dialog_ratingbar);
                    ads.setIntensity(ratingBar.getRating());
                    SymphtomSummaryDAO dao = new SymphtomSummaryDAO(getActivity());
                    dao.save(ads);
                    ds = dao.getSymphtomSummary(MainActivity.date);
                    dao.close();
                    ratingDialog.dismiss();
                }
            });
            ratingDialog.show();
        }

    });

    l.addView(symphtomList);
}

From source file:com.haibison.android.anhuu.utils.ui.bookmark.BookmarkFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(CLASSNAME, "onCreateDialog()");

    Dialog dialog = new Dialog(getActivity(),
            UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog));
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON);
    dialog.setTitle(R.string.anhuu_f5be488d_title_bookmark_manager);
    dialog.setContentView(initContentView(dialog.getLayoutInflater(), null));
    dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.anhuu_f5be488d_bookmarks_dark);

    return dialog;
}

From source file:com.example.deii.trustone.SignUpActivity.java

private void showPicSelectDialog(final Context ctx) {

    dialog = new Dialog(ctx, R.style.DialogSlideAnim1);
    dialog.setContentView(R.layout.dialog_select_image);
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    Window window = dialog.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.gravity = Gravity.BOTTOM;/* w ww.j  a  v  a 2s  . c  o  m*/
    wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    window.setAttributes(wlp);

    TextView chooseFromGallery = (TextView) dialog.findViewById(R.id.text_fromGallery);
    chooseFromGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                loadPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, GALLERY_REQUEST);
            } else
                startGallery();
        }
    });

    TextView takeFromCamera = (TextView) dialog.findViewById(R.id.text_fromCamera);
    takeFromCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
                loadPermissions(Manifest.permission.CAMERA, CAMERA_REQUEST);
            else
                startCamera();

        }
    });

    TextView imgCancel = (TextView) dialog.findViewById(R.id.text_dialogClose);
    imgCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:edu.cscie71.imm.slacker.plugin.Slacker.java

private void openAuthScreen() {
    Runnable runnable = new Runnable() {
        @SuppressLint("NewApi")
        public void run() {
            dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);//from  ww  w. j  av a2  s .  c o m

            LinearLayout mainLayout = new LinearLayout(cordova.getActivity());
            mainLayout.setOrientation(LinearLayout.VERTICAL);

            inAppWebView = new WebView(cordova.getActivity());
            inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new WebChromeClient());
            WebViewClient client = new AuthBrowser();
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);

            inAppWebView.loadUrl(authURL + "?client_id=" + slackClientID + "&scope=" + scope);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            mainLayout.addView(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(mainLayout);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:org.flakor.androidtool.net.net.HistoryTask.java

private void showDialog(String text) {
    dialog = new Dialog(context, R.style.dialogStyle);
    View view = LayoutInflater.from(context).inflate(R.layout.progress_dialog, null);
    TextView textView = (TextView) view.findViewById(R.id.progress_text);
    textView.setText(text);/*from w  w w. j a  v a 2 s .  c o  m*/

    dialog.setContentView(view);
    dialog.show();
}

From source file:com.example.deii.Fragments.UpdateProfileFragment.java

private void showPicSelectDialog(final Context ctx) {

    dialog = new Dialog(ctx, R.style.DialogSlideAnim1);
    dialog.setContentView(R.layout.dialog_select_image);
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    Window window = dialog.getWindow();
    WindowManager.LayoutParams wlp = window.getAttributes();
    wlp.gravity = Gravity.BOTTOM;// w w w .j a va2s . c  om
    wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    window.setAttributes(wlp);

    TextView chooseFromGallery = (TextView) dialog.findViewById(R.id.text_fromGallery);
    chooseFromGallery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                loadPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, GALLERY_REQUEST);
            } else
                startGallery();
        }
    });

    TextView takeFromCamera = (TextView) dialog.findViewById(R.id.text_fromCamera);
    takeFromCamera.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
                loadPermissions(Manifest.permission.CAMERA, CAMERA_REQUEST);
            else
                startCamera();
        }
    });

    TextView imgCancel = (TextView) dialog.findViewById(R.id.text_dialogClose);
    imgCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:au.org.ala.fielddata.mobile.MobileFieldDataDashboard.java

protected void showSplashScreen(int duration) {

    splashDialog = new Dialog(this, R.style.SplashScreen) {
        @Override/*  w  w w  .j a  va  2 s  .co m*/
        public void onBackPressed() {
            removeSplashScreen();
            MobileFieldDataDashboard.this.onBackPressed();
        }
    };
    splashDialog.setContentView(R.layout.splash_screen);
    splashDialog.setCancelable(false);
    splashDialog.show();

    // Set Runnable to remove splash screen
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            removeSplashScreen();
        }
    }, duration);
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * ???//from w  w w  . ja v a 2  s .  com
 * @param theme 
 * @param animation 
 * @param windowFeature ?
 * @return dialog
 */
protected Dialog createDialog(int theme, int animation, int windowFeature) {
    Dialog dialog = new Dialog(mContext, theme);
    dialog.getWindow().getAttributes().windowAnimations = animation;
    dialog.requestWindowFeature(windowFeature);
    dialog.setCancelable(true);
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            mBrowserListener.onDismiss(mWebContext);
        }
    });
    return dialog;
}

From source file:com.mk4droid.IMC_Activities.Fragment_Issue_Details.java

/**
 *    OnCreateView// w  w w  . ja va2s . co m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    isVisible = true;

    vfrag_issue_details = inflater.inflate(R.layout.fragment_issue_details, container, false);
    ctx = vfrag_issue_details.getContext();
    resources = setResources();
    mfrag_issue_details = this;

    //========= Image =================
    dbHandler = new DatabaseHandler(ctx);
    imvFull = (ImageView) vfrag_issue_details.findViewById(R.id.imvIssue_Full);

    IssuePic issuepic = dbHandler.getIssuePic(mIssue._id);

    if (issuepic._IssuePicData != null) {
        bmI = My_System_Utils.LowMemBitmapDecoder(issuepic._IssuePicData);
    } else {
        //------- Try to download from internet --------------  
        if (InternetConnCheck.getInstance(ctx).isOnline(ctx) && !mIssue._urlphoto.equals("null")
                && !mIssue._urlphoto.equals("") && mIssue._urlphoto.length() > 0) {

            mIssue._urlphoto = mIssue._urlphoto.replaceFirst("/thumbs", "");
            new ThumbnailTask_IssDetails(mIssue._urlphoto, mIssue._id).execute();
        }
    }

    dbHandler.db.close();

    imvFull.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialogZoomIm = null;

            if (FActivity_TabHost.IndexGroup == 0)
                dialogZoomIm = new Dialog(ctx, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
            else if (FActivity_TabHost.IndexGroup == 1)
                dialogZoomIm = new Dialog(FActivity_TabHost.ctx,
                        android.R.style.Theme_Black_NoTitleBar_Fullscreen);

            dialogZoomIm.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialogZoomIm.setContentView(R.layout.custom_dialog);
            dialogZoomIm.show();
        }
    });

    // ============ Title and id =========
    tv_id = (TextView) vfrag_issue_details.findViewById(R.id.tv_issuenumber);
    TextView tvTitB = (TextView) vfrag_issue_details.findViewById(R.id.tvTitleIssDetB);

    tv_id.setText(Html.fromHtml("<b><big>#</big></b> " + issueId));
    tv_id.setMovementMethod(new ScrollingMovementMethod());

    tvTitB.setText(mIssue._title);

    //=============== Description ======================
    tvDescription = (TextView) vfrag_issue_details.findViewById(R.id.textViewDescription);
    if (!mIssue._description.equals(""))
        tvDescription.setText(mIssue._description);
    else {
        tvDescription.setVisibility(View.GONE);
    }

    // ============== CATEGORY ===============================
    TextView tvCateg = (TextView) vfrag_issue_details.findViewById(R.id.textViewCategContent);

    int iCateg = 0;
    for (int i = 0; i < Service_Data.mCategL.size(); i++)
        if (Service_Data.mCategL.get(i)._id == mIssue._catid) {
            iCateg = i;
            break;
        }

    tvCateg.setText(Service_Data.mCategL.get(iCateg)._name);

    try {
        bmCateg = My_System_Utils.LowMemBitmapDecoder(Service_Data.mCategL.get(iCateg)._icon);
        BitmapDrawable drCateg = new BitmapDrawable(bmCateg);

        tvCateg.setCompoundDrawablesWithIntrinsicBounds(drCateg, null, null, null);
        tvCateg.setCompoundDrawablePadding(10);
        tvCateg.postInvalidate();
    } catch (Exception e) {

    }

    markerOptions = new MarkerOptions().position(new LatLng(mIssue._latitude, mIssue._longitude))
            .title(mIssue._title).icon(BitmapDescriptorFactory.fromBitmap(bmCateg));

    //================  STATUS ================      
    tvStatus_ack = (TextView) vfrag_issue_details.findViewById(R.id.tv_Status_issuedetails_ack);
    tvStatus_cl = (TextView) vfrag_issue_details.findViewById(R.id.tv_Status_issuedetails_cl);

    vStatus_ack = vfrag_issue_details.findViewById(R.id.v_Status_issuedetails_acknow);
    vStatus_cl = vfrag_issue_details.findViewById(R.id.v_Status_issuedetails_cl);

    int CurrStat = mIssue._currentstatus;

    Colora(CurrStat);

    // ============== Time and Author ================
    TextView tvSubmitted = (TextView) vfrag_issue_details.findViewById(R.id.tvSubmitted);

    String TimeStampRep = mIssue._reported.replace("-", "/");

    tvSubmitted.setText(resources.getString(R.string.Submitted) + " "
            + My_Date_Utils.SubtractDate(TimeStampRep, LangSTR) + " " + resources.getString(R.string.ago) + " "
            + resources.getString(R.string.by) + " " + mIssue._username);

    //============== Votes========================
    TextView tvVotes = (TextView) vfrag_issue_details.findViewById(R.id.textViewVotes);
    tvVotes.setText(Integer.toString(mIssue._votes) + " " + resources.getString(R.string.peoplevoted));

    Button btVote = (Button) vfrag_issue_details.findViewById(R.id.buttonVote);
    //-------- Check if state is Ack or Closed then can not vote ----
    if (CurrStat == 2 || CurrStat == 3)
        btVote.setEnabled(false);

    //-------- Check if Has Voted ----------
    DatabaseHandler dbHandler = new DatabaseHandler(ctx);
    HasVotedSW = dbHandler.CheckIfHasVoted(issueId);

    OwnIssue = false;
    if (UserID_STR.length() > 0)
        OwnIssue = dbHandler.checkIfOwnIssue(Integer.toString(issueId), UserID_STR);

    dbHandler.db.close();

    // if has not voted, it is not his issue, and authenticated then able to vote 
    if (!OwnIssue && !HasVotedSW && AuthFlag) {
        btVote.setEnabled(true);
    }

    if (OwnIssue || HasVotedSW) {
        btVote.setEnabled(false);
        btVote.setText(resources.getString(R.string.AlreadyVoted));
    }

    if (!AuthFlag) {
        btVote.setText(resources.getString(R.string.Vote));
    }

    btVote.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            if (InternetConnCheck.getInstance(ctx).isOnline(ctx) && AuthFlag) {
                new AsynchTaskVote().execute();
            } else if (!InternetConnCheck.getInstance(ctx).isOnline(ctx)) {
                Toast.makeText(ctx, resources.getString(R.string.NoInternet), Toast.LENGTH_SHORT).show();
            } else if (!AuthFlag) {
                Toast.makeText(ctx, resources.getString(R.string.OnlyRegistered), Toast.LENGTH_SHORT).show();
            }
        }
    });

    //============ Address - MapStatic - Button Map dynamic ========================
    TextView tvAddr = (TextView) vfrag_issue_details.findViewById(R.id.textViewAddressContent);
    tvAddr.setText(mIssue._address);

    fmap_issdet = SupportMapFragment.newInstance();

    FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
    fragmentTransaction.add(R.id.lliss_det_map, fmap_issdet);
    fragmentTransaction.commit();

    // ============ COMMENTS ===========================
    Button btCommentsSW = (Button) vfrag_issue_details.findViewById(R.id.btCommentsSW);

    btCommentsSW.setText(resources.getString(R.string.ViewComments));

    btCommentsSW.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (InternetConnCheck.getInstance(ctx).isOnline(ctx)) {
                FragmentTransaction ft2 = getFragmentManager().beginTransaction();

                Fragment_Comments newfrag_comments = new Fragment_Comments(); // Instantiate a new fragment.
                Bundle args = new Bundle();
                args.putInt("issueId", issueId);
                args.putString("issueTitle", mIssue._title);
                newfrag_comments.setArguments(args); // Add the fragment to the activity, pushing this transaction on to the back stack.

                if (FActivity_TabHost.IndexGroup == 0)
                    ft2.add(R.id.flmain, newfrag_comments, "FTAG_COMMENTS");
                else if (FActivity_TabHost.IndexGroup == 1) {
                    ft2.add(R.id.fl_IssuesList_container, newfrag_comments, "FTAG_COMMENTS");
                }

                ft2.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                ft2.addToBackStack(null);
                ft2.commit();
            } else {
                Toast.makeText(ctx, resources.getString(R.string.NoInternet), Toast.LENGTH_SHORT).show();
            }
        }
    });

    return vfrag_issue_details;
}

From source file:com.gumgoose.app.quakebuddy.EarthquakeActivity.java

private void showWhatsNewDialog() {
    // Display the change log for QuakeBuddy on-screen
    Dialog dialog = new Dialog(this, android.R.style.Theme_Dialog);
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(R.layout.dialog_change_log);
    dialog.show();/*  www  .  j ava  2 s.c o m*/
}