Example usage for android.app Dialog setOnDismissListener

List of usage examples for android.app Dialog setOnDismissListener

Introduction

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

Prototype

public void setOnDismissListener(@Nullable OnDismissListener listener) 

Source Link

Document

Set a listener to be invoked when the dialog is dismissed.

Usage

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display introduction to the user for first time launch
 * /*from w  w w . j av  a 2  s  . com*/
 * @param context
 */
public static void displayIntroduction(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.introduction);

    Typeface lightTypeface = ((LauncherApplication) context.getApplicationContext()).getLightTypeface(context);

    TextView titleTextView = (TextView) dialog.findViewById(R.id.intro_title);
    titleTextView.setTypeface(lightTypeface);
    TextView textView1 = (TextView) dialog.findViewById(R.id.intro_text1);
    textView1.setTypeface(lightTypeface);
    TextView textView2 = (TextView) dialog.findViewById(R.id.intro_text2);
    textView2.setTypeface(lightTypeface);

    ((Button) dialog.findViewById(R.id.intro_button)).setOnClickListener(new OnClickListener() {

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

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_INTRODUCTION);
}

From source file:com.adithya321.sharesanalysis.fragments.FundFlowFragment.java

@Nullable
@Override//from   w  w  w  .  ja  va  2s .  c o  m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_fund_flow, container, false);

    Window window = getActivity().getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    ((AppCompatActivity) getActivity()).getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));

    databaseHandler = new DatabaseHandler(getContext());
    fundIn = (TextView) root.findViewById(R.id.fund_in);
    fundOut = (TextView) root.findViewById(R.id.fund_out);
    fundsListView = (ListView) root.findViewById(R.id.funds_list_view);
    setViews();

    FloatingActionButton addFundFab = (FloatingActionButton) root.findViewById(R.id.add_fund_fab);
    addFundFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Fund Flow");
            dialog.setContentView(R.layout.dialog_add_fund);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            final EditText amount = (EditText) dialog.findViewById(R.id.amount);
            Button addFundBtn = (Button) dialog.findViewById(R.id.add_fund_btn);
            addFundBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Fund fund = new Fund();
                    fund.setId(databaseHandler.getNextKey("fund"));

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        fund.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {
                        fund.setAmount(Double.parseDouble(amount.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Amount", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_in)).isChecked())
                        fund.setType("in");
                    else if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_out)).isChecked())
                        fund.setType("out");
                    else {
                        Toast.makeText(getActivity(), "Invalid Fund Type", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    databaseHandler.addFund(fund);
                    setViews();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display the list of Spotlight web apps:
 * https://www.google.com/tv/spotlight-gallery.html Allow the user to launch
 * a web app in the browser./*from w  w w . j a  v a  2 s.  c o  m*/
 * 
 * @param context
 */
public static void displayAllSpotlight(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.spotlight_grid);

    final GridView gridView = (GridView) dialog.findViewById(R.id.grid);
    final ArrayList<SpotlightInfo> spotlights = SpotlightTable.getAllSpotlights(context);
    gridView.setAdapter(new AllSpotlightAdapter(context, spotlights));
    gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SpotlightInfo spotlightInfo = (SpotlightInfo) parent.getAdapter().getItem(position);
            spotlightInfo.invoke(context);
            context.showCover(false);
            dialog.dismiss();
            Analytics.logEvent(Analytics.INVOKE_SPOTLIGHT_WEB_APP);
        }

    });
    gridView.setDrawingCacheEnabled(true);
    gridView.setOnKeyListener(onKeyListener);
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_SPOTLIGHT_WEB_APPS);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display the list of browser history./*from   w  ww. j a v  a2s.co  m*/
 * 
 * @param context
 */
public static void displayBrowserHistory(final Launcher context) {
    final ArrayList<BookmarkInfo> bookmarks = loadBrowserHistory(context);
    if (bookmarks.size() > 0) {
        final Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.bookmarks_list);

        ListView listView = (ListView) dialog.findViewById(R.id.list);
        listView.setAdapter(new BookmarkAdapter(context, bookmarks));
        listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                BookmarkInfo bookmark = (BookmarkInfo) parent.getAdapter().getItem(position);
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bookmark.getUrl()));
                context.startActivity(browserIntent);
                context.showCover(false);
                dialog.dismiss();
                Analytics.logEvent(Analytics.INVOKE_BOOKMARK);
            }

        });
        listView.setDrawingCacheEnabled(true);
        listView.setOnKeyListener(onKeyListener);
        dialog.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                context.showCover(false);
            }

        });
        context.showCover(true);
        dialog.show();
        Analytics.logEvent(Analytics.DIALOG_BOOKMARKS);
    } else {
        displayAlert(context, context.getString(R.string.dialog_no_browser_history));
    }
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a dialog to confirm that a user wants to delete a row.
 * /* ww  w .j  a v a 2 s  .c om*/
 * @param context
 */
public static void displayDeleteRow(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.confirmation);

    TextView confirmationTextView = (TextView) dialog.findViewById(R.id.confirmationText);
    confirmationTextView.setText(context.getString(R.string.dialog_delete_row_message));
    Button buttonYes = (Button) dialog.findViewById(R.id.button1);
    buttonYes.setText(context.getString(R.string.dialog_yes));
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.deleteCurrentRow();
            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.button2);
    buttonNo.setText(context.getString(R.string.dialog_no));
    buttonNo.setOnClickListener(new OnClickListener() {

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

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_DELETE_ROW);
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a dialog to confirm that the user wants to delete an item.
 * /*w w  w  . j  a v a2s .com*/
 * @param context
 */
public static void displayDeleteItem(final Launcher context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.confirmation);

    TextView confirmationTextView = (TextView) dialog.findViewById(R.id.confirmationText);
    confirmationTextView.setText(context.getString(R.string.dialog_delete_item_message));
    Button buttonYes = (Button) dialog.findViewById(R.id.button1);
    buttonYes.setText(context.getString(R.string.dialog_yes));
    buttonYes.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.deleteCurrentItem();
            context.showCover(false);
            dialog.dismiss();
        }

    });
    Button buttonNo = (Button) dialog.findViewById(R.id.button2);
    buttonNo.setText(context.getString(R.string.dialog_no));
    buttonNo.setOnClickListener(new OnClickListener() {

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

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_DELETE_ITEM);
}

From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_pay_google"));

    myHandler = new MyHandler(this);

    /* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
     * (that you got from the Google Play developer console). This is not your
     * developer public key, it's the *app-specific* public key.
     *//from ww w  .  ja  v a  2 s  . c o  m
     * Instead of just storing the entire literal string here embedded in the
     * program,  construct the key at runtime from pieces or
     * use bit manipulation (for example, XOR with some other string) to hide
     * the actual key.  The key itself is not secret information, but we don't
     * want to make it easy for an attacker to replace the public key with one
     * of their own and then fake messages from the server.
     */
    //        String base64EncodedPublicKey = "CONSTRUCT_YOUR_KEY_AND_PLACE_IT_HERE";

    if (TextUtils.isEmpty(base64EncodedPublicKey)) {
        ApplicationInfo appInfo;
        try {
            appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
            base64EncodedPublicKey = appInfo.metaData.getString("com.googleplay.ApplicationId");
        } catch (NameNotFoundException e) {
            BaseUtils.logDebug(TAG, "Please put your app's public key in AndroidManifest.xml.");
        }
    }
    if (TextUtils.isEmpty(base64EncodedPublicKey)) {
        BaseUtils.logError(TAG, "Please put your app's public key in AndroidManifest.xml.");
        complain("Please put your app's public key in AndroidManifest.xml.");
        return;
    }

    productID = getIntent().getStringExtra("inAppProductID");
    ext = getIntent().getStringExtra("ext");
    oasOrderid = getIntent().getStringExtra("oasOrderid");
    if (TextUtils.isEmpty(productID)) {
        BaseUtils.logError(TAG, "Please put product id.");
        complain("Please put product id.");
        return;
    }

    if (SystemCache.userInfo == null || TextUtils.isEmpty(SystemCache.userInfo.serverID)
            || TextUtils.isEmpty(SystemCache.userInfo.roleID)) {
        BaseUtils.logError(TAG, "Please put game serverid or roleid.");
        complain("Please put game server id.");
        return;
    }

    //        revenue = getRevenueAndCurrency();// ?productid?????
    //        if(TextUtils.isEmpty(revenue)){
    //           BaseUtils.logError(TAG, "This product id does not exist, please contact customer support");
    //           setResult(OASISPlatformConstant.RESULT_EXCEPTION);
    //           Message msg = new Message();
    //           msg.what = 0;
    //           msg.obj = getResources().getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_2")); 
    //            myHandler.sendMessage(msg);
    //           return;
    //        }
    setWaitScreen(true);

    if (SystemCache.OASISSDK_ENVIRONMENT_SANDBOX) {
        initSandBox();
        //1  ? ??
        //2 ???
        //3 ??
        return;
    }
    // Create the helper, passing it our context and the public key to verify signatures with
    BaseUtils.logDebug(TAG, "Creating IAB helper.");
    mHelper = new IabHelper(this.getApplicationContext(), base64EncodedPublicKey);

    // enable debug logging (for a production application, you should set this to false).
    mHelper.enableDebugLogging(SystemCache.OASISSDK_ENVIRONMENT_SANDBOX);

    int isGoolgePlayAvail = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this.getApplicationContext());
    if (isGoolgePlayAvail == ConnectionResult.SUCCESS) {
        // Start setup. This is asynchronous and the specified listener
        // will be called once setup completes.
        BaseUtils.logDebug(TAG, "Starting setup.");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (isPageClose()) {
                    isPageCloseHandler();
                    return;
                }
                BaseUtils.logDebug(TAG, "Setup finished.");

                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    BaseUtils.logError(TAG, "Problem setting up in-app billing: "
                            + IabHelper.getResponseDesc(result.getResponse()));
                    Message msg = new Message();
                    msg.what = 0;
                    msg.obj = getResources().getString(
                            BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_1"));
                    myHandler.sendMessage(msg);
                    return;
                }

                // Have we been disposed of in the meantime? If so, quit.
                if (mHelper == null)
                    return;

                // IAB is fully set up. Now, Start purchase.
                try {
                    oldOrderList = GoogleBillingUtils.getPurchasedList();
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                //                queryInventory();
                checkALLOrder(0);
            }
        });
    } else {

        Dialog d = GooglePlayServicesUtil.getErrorDialog(isGoolgePlayAvail, this, RC_VERIFYGOOGLEPLAY);
        d.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface arg0) {
                BaseUtils.logError(TAG, "GooglePlayServicesUtil.showErrorDialogFragment");
                arg0.dismiss();

                myHandler.sendEmptyMessageDelayed(-1, 500);
            }
        });
        d.show();

    }
}

From source file:de.bogutzky.psychophysiocollector.app.MainActivity.java

private void showGraph(String bluetoothDeviceAddress, int requestCode, int which) {
    int beginAtField = 0;
    GraphView graphView = null;//from   w w w . j  a  v  a  2 s .  c o  m
    Dialog dialog = null;
    switch (requestCode) {
    case REQUEST_MAIN_COMMAND_SHIMMER:
        beginAtField = 1;
        switch (which) {
        case 1:
            beginAtField = 4;
            break;
        }

        graphView = new GraphView(this, beginAtField);
        if (this.shimmerImuService != null) {
            if (!isSessionStarted)
                this.startStreamingOfAllShimmerImus(false);
            this.shimmerImuService.startDataVisualization(bluetoothDeviceAddress, graphView);
        }
        dialog = new Dialog(this);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (shimmerImuService != null) {
                    shimmerImuService.stopDataVisualization();
                }
                if (!isSessionStarted) {
                    stopAllStreamingOfAllShimmerImus();
                }
            }
        });
        break;
    case REQUEST_MAIN_COMMAND_BIOHARNESS:
        graphView = new GraphView(this, beginAtField);
        if (this.bioHarnessService != null) {
            this.bioHarnessService.startDataVisualization(graphView);
        }
        dialog = new Dialog(this);
        dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                if (bioHarnessService != null) {
                    bioHarnessService.stopDataVisualization();
                }
            }
        });
        break;
    }

    assert dialog != null;
    dialog.setContentView(graphView);
    dialog.setTitle(getString(R.string.graph));
    dialog.setCancelable(true);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.MATCH_PARENT;
    dialog.getWindow().setAttributes(lp);

    dialog.show();
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display the list of browser bookmarks. Allow user to load bookmarked web
 * site.//from   w ww. ja  v a 2s . c o m
 * 
 * @param context
 */
public static void displayBookmarks(final Launcher context) {
    final ArrayList<BookmarkInfo> bookmarks = loadBookmarks(context);
    if (bookmarks.size() > 0) {
        final Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.bookmarks_list);

        ListView listView = (ListView) dialog.findViewById(R.id.list);
        Collections.sort(bookmarks, new Comparator<BookmarkInfo>() {

            @Override
            public int compare(BookmarkInfo lhs, BookmarkInfo rhs) {
                return lhs.getTitle().toLowerCase().compareTo(rhs.getTitle().toLowerCase());
            }

        });
        listView.setAdapter(new BookmarkAdapter(context, bookmarks));
        listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                BookmarkInfo bookmark = (BookmarkInfo) parent.getAdapter().getItem(position);
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(bookmark.getUrl()));
                context.startActivity(browserIntent);
                context.showCover(false);
                dialog.dismiss();
                Analytics.logEvent(Analytics.INVOKE_BOOKMARK);
            }

        });
        listView.setDrawingCacheEnabled(true);
        listView.setOnKeyListener(onKeyListener);
        dialog.setOnDismissListener(new OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                context.showCover(false);
            }

        });
        context.showCover(true);
        dialog.show();
        Analytics.logEvent(Analytics.DIALOG_BOOKMARKS);
    } else {
        displayAlert(context, context.getString(R.string.dialog_no_browser_bookmarks));
    }
}

From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case R.string.QueryDeleteAugment: {
        Dialog dialog;
        AlertDialog.Builder builder;/*from w  w w  .  ja v a2 s .c o m*/

        builder = new AlertDialog.Builder(this);
        builder.setCancelable(true);
        builder.setMessage(getString(R.string.QueryDeleteAugment));
        builder.setTitle(getString(R.string.app_name));
        builder.setPositiveButton(R.string.DeleteOK, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                ((FFXIDatabase) getDAO()).deleteAugment(mLongClickingItemId);

                AugmentListView lv = (AugmentListView) findViewById(R.id.ListView);
                if (lv != null)
                    lv.setParam(getDAO(), mPart, mRace, mJob, mLevel);
                dismissDialog(R.string.QueryDeleteAugment);
            }
        });
        builder.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dismissDialog(R.string.QueryDeleteAugment);
            }
        });
        dialog = builder.create();
        return dialog;
    }
    default: {
        FilterSelectorDialog dialog = new FilterSelectorDialog(this);

        dialog.setOnDismissListener(new OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                FilterSelectorDialog fsd = (FilterSelectorDialog) dialog;
                String filter = fsd.getFilterString();
                mFilterID = fsd.getFilterID();

                if (filter.length() > 0) {
                    AugmentListView lv = (AugmentListView) findViewById(R.id.ListView);
                    if (lv != null) {
                        lv.setFilter(filter);
                    }
                }

            }

        });
        return dialog;
    }
    }
}