Example usage for android.app AlertDialog setOnDismissListener

List of usage examples for android.app AlertDialog setOnDismissListener

Introduction

In this page you can find the example usage for android.app AlertDialog 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:eu.funceptionapps.convertitall.ui.ConverterInterface.java

public void makeFavoriteDialog() {

    int selectedConverterId = 0;
    boolean[] selectedUnities = null;

    switch (currentPageId) {
    case Converter.CURRENCY:
        selectedConverterId = R.array.currencies;
        selectedUnities = Unit.selectedCurrencies;
        break;/* ww w . j ava  2  s  .  com*/
    case Converter.LENGTH:
        selectedConverterId = R.array.lengths;
        selectedUnities = Unit.selectedLengths;
        break;
    case Converter.TEMPERATURE:
        selectedConverterId = R.array.temperatures;
        selectedUnities = Unit.selectedTemperatures;
        break;
    case Converter.BYTE:
        selectedConverterId = R.array.bytes;
        selectedUnities = Unit.selectedBytes;
        break;
    case Converter.NUMSYS:
        Unit.loadSelectedNumSys(prefs);
        selectedConverterId = R.array.numerical_systems;
        selectedUnities = Unit.selectedNumSys;
        break;
    case Converter.FORCE:
        Unit.loadSelectedForces(prefs);
        selectedConverterId = R.array.forces;
        selectedUnities = Unit.selectedForces;
        break;
    }

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(thisContext);
    dialogBuilder.setCancelable(true).setTitle(thisContext.getString(R.string.title_favorites_dialog))
            .setMultiChoiceItems(selectedConverterId, selectedUnities, new OnMultiChoiceClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    switch (currentPageId) {
                    case Converter.CURRENCY:
                        Unit.changeSelectedCurrency(which, isChecked);
                        break;
                    case Converter.LENGTH:
                        Unit.changeSelectedLength(which, isChecked);
                        break;
                    case Converter.TEMPERATURE:
                        Unit.changeSelectedTemperature(which, isChecked);
                        break;
                    case Converter.BYTE:
                        Unit.changeSelectedBytes(which, isChecked);
                        break;
                    case Converter.NUMSYS:
                        Unit.changeSelectedNumSys(which, isChecked);
                        break;
                    case Converter.FORCE:
                        Unit.changeSelectedForce(which, isChecked);
                        break;
                    }

                }
            });

    dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    AlertDialog favoriteUnitDialog = dialogBuilder.create();
    favoriteUnitDialog.show();
    favoriteUnitDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            selectItem(currentPageId);
        }
    });
}

From source file:com.otaupdater.SettingsActivity.java

@Override
@SuppressWarnings("deprecation")
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference == accountPref) {
        showAccountDialog();/*from  w  w  w  .  j a va  2 s.  c om*/
    } else if (preference == notifPref) {
        cfg.setShowNotif(notifPref.isChecked());
    } else if (preference == wifidlPref) {
        cfg.setWifiOnlyDl(wifidlPref.isChecked());
    } else if (preference == autodlPref) {
        if (cfg.hasProKey()) {
            cfg.setAutoDlState(autodlPref.isChecked());
        } else {
            Utils.showProKeyOnlyFeatureDialog(this, this);
            cfg.setAutoDlState(false);
            autodlPref.setChecked(false);
        }
    } else if (preference == resetWarnPref) {
        cfg.clearIgnored();
    } else if (preference == prokeyPref) {
        if (cfg.hasProKey()) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            if (cfg.isKeyRedeemCode()) {
                builder.setMessage(R.string.prokey_redeemed_thanks);
            } else {
                builder.setMessage(R.string.prokey_thanks);
            }

            builder.setNeutralButton(R.string.close, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();
            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        } else {
            showGetProKeyDialog();
        }
    } else if (preference == donatePref) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.SITE_BASE_URL + Config.DONATE_URL)));
    } else {
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

    return true;
}

From source file:com.nks.nksmod.otaupdater.OTAUpdaterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);//  w  ww . ja v  a 2s  . c  o m
    final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 0;

    if (ContextCompat.checkSelfPermission(OTAUpdaterActivity.this,
            android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

        if (ActivityCompat.shouldShowRequestPermissionRationale(OTAUpdaterActivity.this,
                android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.alert_permission_storage);
            builder.setMessage(R.string.alert_permission_storage_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.enable_permission, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    ActivityCompat.requestPermissions(OTAUpdaterActivity.this,
                            new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
                            MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();

        } else {
            ActivityCompat.requestPermissions(OTAUpdaterActivity.this,
                    new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
                    MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);

            if (ActivityCompat.shouldShowRequestPermissionRationale(OTAUpdaterActivity.this,
                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) {

                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle(R.string.alert_permission_storage);
                builder.setMessage(R.string.alert_permission_storage_message);
                builder.setCancelable(false);
                builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                });

                final AlertDialog dlg = builder.create();

                dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                    @Override
                    public void onShow(DialogInterface dialog) {
                        onDialogShown(dlg);
                    }
                });
                dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        onDialogClosed(dlg);
                    }
                });
                dlg.show();

            }
        }
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    setContentView(R.layout.main);
    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    /* ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate()) kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class); */

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        /* if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
        cfg.getStoredKernelUpdate().showUpdateNotif(this);
        } */

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}

From source file:com.otaupdater.OTAUpdaterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);/*from   w  ww . j  a  v  a2  s. c o  m*/

    if (!cfg.hasProKey()) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                billingSrvConn = new ServiceConnection() {
                    @Override
                    public void onServiceDisconnected(ComponentName name) {
                        billingSrvConn = null;
                    }

                    @Override
                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder);

                        try {
                            Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null);
                            ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                            ArrayList<String> ownedItemData = owned
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                            if (ownedItems != null && ownedItemData != null) {
                                for (int q = 0; q < ownedItems.size(); q++) {
                                    if (ownedItems.get(q).equals(Config.PROKEY_SKU)) {
                                        JSONObject itemData = new JSONObject(ownedItemData.get(q));
                                        cfg.setKeyPurchaseToken(itemData.getString("purchaseToken"));
                                        break;
                                    }
                                }
                            }
                        } catch (RemoteException ignored) {
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        unbindService(this);
                        billingSrvConn = null;
                    }
                }, Context.BIND_AUTO_CREATE);
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.alert_unsupported_title);
        builder.setMessage(R.string.alert_unsupported_message);
        builder.setCancelable(false);
        builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cfg.setIgnoredUnsupportedWarn(true);
                dialog.dismiss();
            }
        });

        final AlertDialog dlg = builder.create();

        dlg.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                onDialogShown(dlg);
            }
        });
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                onDialogClosed(dlg);
            }
        });
        dlg.show();
    }

    setContentView(R.layout.main);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate())
        kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class);

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
            cfg.getStoredKernelUpdate().showUpdateNotif(this);
        }

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}

From source file:com.com2us.module.inapp.DefaultBilling.java

protected void showPreviousProgressInfoDialog(Activity activity, Runnable runnable) {
    String message;//from w  w  w  . j av  a 2s.c o m
    String okay;
    String language = this.moduleData.getLanguage();
    String country = this.moduleData.getCountry();
    if (TextUtils.equals("ko", language)) {
        message = "\uc9c0\uae09\ub418\uc9c0 \uc54a\uc740 \uc0c1\ud488\uc774 \uc788\uc2b5\ub2c8\ub2e4. \n\uc7ac \uc9c0\uae09\uc744 \uc2dc\ub3c4\ud569\ub2c8\ub2e4.";
        okay = "\ud655\uc778";
    } else if (TextUtils.equals("fr", language)) {
        message = "Echec de lattribution de certains objets. \nLe processus va recommencer.";
        okay = "OK";
    } else if (TextUtils.equals("de", language)) {
        message = "Nicht erhaltene Items vorhanden. \nVorgang wird wiederholt.";
        okay = "OK";
    } else if (TextUtils.equals("ja", language)) {
        message = "\u652f\u7d66\u3055\u308c\u3066\u306a\u3044\u30a2\u30a4\u30c6\u30e0\u304c\u3042\u308a\u307e\u3059\u3002 \n\u518d\u652f\u7d66\u3044\u305f\u3057\u307e\u3059\u3002";
        okay = "OK";
    } else if (TextUtils.equals("ru", language)) {
        message = "\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b. \n\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437.";
        okay = "OK";
    } else if (TextUtils.equals("tw", country)) {
        message = "\u5546\u54c1\u672a\u6210\u529f\u7d66\u4ed8\uff0c \n\u5c07\u5617\u8a66\u91cd\u65b0\u9818\u53d6\u3002";
        okay = "\u78ba\u8a8d";
    } else if (TextUtils.equals("cn", country)) {
        message = "\u5b58\u5728\u672a\u80fd\u652f\u4ed8\u7684\u5546\u54c1\u3002 \n\u5c06\u5c1d\u8bd5\u91cd\u65b0\u652f\u4ed8\u3002";
        okay = "\u786e\u8ba4";
    } else {
        message = "Failed to grant some items. \nThe process will restart.";
        okay = "OK";
    }
    final Activity activity2 = activity;
    final Runnable runnable2 = runnable;
    activity.runOnUiThread(new Runnable() {
        public void run() {
            AlertDialog dialog = new Builder(activity2).setIcon(17301659).setMessage(message)
                    .setPositiveButton(okay, new OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                        }
                    }).create();
            final Activity activity = activity2;
            final Runnable runnable = runnable2;
            dialog.setOnDismissListener(new OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    activity.runOnUiThread(runnable);
                }
            });
            dialog.show();
        }
    });
}

From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SEARCH:
        mBottomBarControls.showSearch(true);
        return true;
    case MENU_PLAYBACK:
        openPlaybackActivity();//from  w  ww.j av a  2 s  . com
        return true;
    case MENU_SORT: {
        MediaAdapter adapter = (MediaAdapter) mCurrentAdapter;
        LinearLayout header = (LinearLayout) getLayoutInflater().inflate(R.layout.sort_dialog, null);
        CheckBox reverseSort = (CheckBox) header.findViewById(R.id.reverse_sort);

        int[] itemIds = adapter.getSortEntries();
        String[] items = new String[itemIds.length];
        Resources res = getResources();
        for (int i = itemIds.length; --i != -1;) {
            items[i] = res.getString(itemIds[i]);
        }

        int mode = adapter.getSortMode();
        if (mode < 0) {
            mode = ~mode;
            reverseSort.setChecked(true);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.sort_by);
        builder.setSingleChoiceItems(items, mode + 1, this); // add 1 for header
        builder.setNeutralButton(R.string.done, null);

        AlertDialog dialog = builder.create();
        dialog.getListView().addHeaderView(header);
        dialog.setOnDismissListener(this);
        dialog.show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SEARCH:
        mBottomBarControls.showSearch(true);
        break;//from w w  w .ja v  a 2 s.co m
    case MENU_PLAYBACK:
        openPlaybackActivity();
        break;
    case MENU_GO_HOME:
        mPagerAdapter.setLimiter(FileSystemAdapter.buildHomeLimiter(getApplicationContext()));
        updateLimiterViews();
        break;
    case MENU_SORT: {
        SortableAdapter adapter = (SortableAdapter) mCurrentAdapter;
        LinearLayout list = (LinearLayout) getLayoutInflater().inflate(R.layout.sort_dialog, null);
        CheckBox reverseSort = (CheckBox) list.findViewById(R.id.reverse_sort);

        int[] itemIds = adapter.getSortEntries();
        String[] items = new String[itemIds.length];
        Resources res = getResources();
        for (int i = 0; i < itemIds.length; i++) {
            items[i] = res.getString(itemIds[i]);
        }

        int mode = adapter.getSortModeIndex();
        reverseSort.setChecked(adapter.isSortDescending());

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.sort_by);
        builder.setSingleChoiceItems(items, mode, this);
        builder.setPositiveButton(R.string.done, null);

        AlertDialog dialog = builder.create();
        dialog.getListView().addFooterView(list);
        dialog.setOnDismissListener(this);
        dialog.show();
        break;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:id.ridon.keude.views.ManageReposActivity.java

private void scanForRepos() {
    final RepoScanListAdapter adapter = new RepoScanListAdapter(this);
    final MDnsHelper mDnsHelper = new MDnsHelper(this, adapter);

    final View view = getLayoutInflater().inflate(R.layout.repodiscoverylist, null);
    final ListView repoScanList = (ListView) view.findViewById(R.id.reposcanlist);

    final AlertDialog alrt = new AlertDialog.Builder(this).setView(view)
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override/*w  w  w  . j  av  a 2s . c  om*/
                public void onClick(DialogInterface dialog, int which) {
                    mDnsHelper.stopDiscovery();
                    dialog.dismiss();
                }
            }).create();

    alrt.setTitle(R.string.local_repos_title);
    alrt.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mDnsHelper.stopDiscovery();
        }
    });

    repoScanList.setAdapter(adapter);
    repoScanList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {

            final DiscoveredRepo discoveredService = (DiscoveredRepo) parent.getItemAtPosition(position);

            final ServiceInfo serviceInfo = discoveredService.getServiceInfo();
            String type = serviceInfo.getPropertyString("type");
            String protocol = type.contains("fdroidrepos") ? "https:/" : "http:/";
            String path = serviceInfo.getPropertyString("path");
            if (TextUtils.isEmpty(path))
                path = "/fdroid/repo";
            String serviceUrl = protocol + serviceInfo.getInetAddresses()[0] + ":" + serviceInfo.getPort()
                    + path;
            showAddRepo(serviceUrl, serviceInfo.getPropertyString("fingerprint"));
        }
    });

    alrt.show();
    mDnsHelper.discoverServices();
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * /*from   w  ww . ja  va  2s.  com*/
 * @return
 */
@Override
protected Dialog createCPUDialog() {
    AlertDialog.Builder builder;
    AlertDialog alertDialog;

    builder = new AlertDialog.Builder(this);
    builder.setView(createCPUListDialog());

    builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            removeDialog(CPU_DIALOG);
        }
    });
    if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) {
        builder.setMessage("CPU usages");
    }
    alertDialog = builder.create();
    alertDialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface arg0) {
            // TODO Auto-generated method stub
            currentDialogId = -1;
        }
    });
    return alertDialog;
}

From source file:com.appfirst.activities.details.AFServerDetail.java

/**
 * Draw a view to display disk status./*from   ww  w . j a  v  a  2  s .c  o  m*/
 * 
 * @return a AlertDialog containing the view.
 */
@Override
protected Dialog createDiskDialog() {
    AlertDialog.Builder builder;
    AlertDialog alertDialog;

    builder = new AlertDialog.Builder(this);
    builder.setView(createDiskListDialog());

    builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            removeDialog(DISK_DIALOG);
        }
    });
    if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) {
        builder.setMessage("Disk usage");
    }
    alertDialog = builder.create();
    alertDialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface arg0) {
            // TODO Auto-generated method stub
            currentDialogId = -1;
        }
    });
    return alertDialog;
}