Example usage for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener

List of usage examples for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener

Introduction

In this page you can find the example usage for android.content DialogInterface.OnClickListener DialogInterface.OnClickListener.

Prototype

DialogInterface.OnClickListener

Source Link

Usage

From source file:com.vuze.android.remote.AndroidUtilsUI.java

public static AlertDialog.Builder createTextBoxDialog(Context context, int newtag_title, int newtag_hint,
        final OnTextBoxDialogClick onClickListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    FrameLayout container = new FrameLayout(context);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.CENTER_VERTICAL;
    container.setMinimumHeight(AndroidUtilsUI.dpToPx(100));
    int padding = AndroidUtilsUI.dpToPx(20);
    params.leftMargin = padding;//  ww w  .  j a v  a 2s  .  c  o  m
    params.rightMargin = padding;

    final MaterialEditText textView = AndroidUtilsUI.createFancyTextView(context);
    textView.setHint(newtag_hint);
    textView.setFloatingLabelText(context.getResources().getString(newtag_hint));
    textView.setSingleLine();
    textView.setLayoutParams(params);

    container.addView(textView);

    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
        builder.setInverseBackgroundForced(true);
    }

    builder.setView(container);
    builder.setTitle(newtag_title);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            onClickListener.onClick(dialog, which, textView);
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    return builder;
}

From source file:uk.ac.hutton.ics.buntata.activity.LogDetailsActivity.java

@Override
public void onBackPressed() {
    latitude.clearFocus();//from   w w w. j ava2  s . c om
    longitude.clearFocus();
    note.clearFocus();

    if (unsavedChanges) {
        DialogUtils.showDialog(this, R.string.dialog_save_title, R.string.dialog_save_message,
                R.string.generic_yes, R.string.generic_no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        /* It's a new item */
                        if (log.getId() == -1)
                            logManager.add(log);
                        /* It's an existing item */
                        else
                            logManager.update(log);

                        /* Update the images, i.e. set the log entry id */
                        for (LogEntryImage image : newlyCreatedImages) {
                            image.setLogEntry(log);
                            imageManager.update(image);
                        }

                        close();
                    }
                }, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        /* Delete them again */
                        for (LogEntryImage image : newlyCreatedImages)
                            imageManager.delete(image);

                        close();
                    }
                });
    } else {
        close();
    }

    if (imagePagerAdapter != null)
        imagePagerAdapter.cleanup();
}

From source file:uk.ac.hutton.ics.buntata.adapter.DatasourceAdapter.java

@Override
public void onBindViewHolder(final AbstractViewHolder h, final int section, final int relativePosition,
        final int absolutePosition) {
    final BuntataDatasource item;

    final boolean isExpanded = getAbsolutePosition(absolutePosition, section) == expandedPosition;

    switch (section) {
    case LOCAL://  www  . j av  a2  s  .com
        item = local.get(relativePosition);
        break;
    case REMOTE:
    default:
        item = remote.get(relativePosition);
    }

    final ItemViewHolder holder = (ItemViewHolder) h;

    holder.nameView.setText(item.getName());
    holder.descriptionView.setText(item.getDescription());
    holder.sizeView.setText(context.getString(R.string.datasource_size, (item.getSizeNoVideo() / 1024f / 1024f),
            (item.getSizeTotal() / 1024f / 1024f)));
    holder.contactView.setText(item.getContact());
    holder.contactView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ShareCompat.IntentBuilder.from(context).setType("message/rfc822").addEmailTo(item.getContact())
                    .setSubject(context.getString(R.string.contact_email_subject))
                    .setChooserTitle(R.string.contact_email_dialog_title).startChooser();
        }
    });

    holder.providerView.setText(item.getDataProvider());
    holder.versionView.setText(Integer.toString(item.getVersionNumber()));

    final BuntataDatasourceAdvanced ds = get(section, relativePosition);
    holder.progressBar.setVisibility(ds.isDownloading() ? View.VISIBLE : View.GONE);

    setState(ds, holder);
    //      holder.downloadStatus.setImageResource(resource);
    //      holder.downloadStatus.setColorFilter(ContextCompat.getColor(context, R.color.colorPrimaryDark));

    /* If there is an icon, set it */
    String iconPath = DatasourceService.getIcon(context, item);
    if (!StringUtils.isEmpty(iconPath)) {
        holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

        RequestCreator r;

        File f = new File(iconPath);
        if (f.exists())
            r = Picasso.get().load(f);
        else
            r = Picasso.get().load(iconPath);

        r.noPlaceholder().into(holder.imageView);
    }
    /* Else set a default icon */
    else {
        holder.imageView.setImageResource(R.drawable.drawer_data_source);
        holder.imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        holder.imageView.setColorFilter(ContextCompat.getColor(context, R.color.colorPrimaryDark));
    }

    holder.detailsView.setVisibility(isExpanded ? View.VISIBLE : View.GONE);

    holder.view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            expandedPosition = isExpanded ? -1 : getAbsolutePosition(absolutePosition, section);

            /* Set a new transition */
            ChangeBounds transition = new ChangeBounds();
            /* For 150 ms */
            transition.setDuration(150);
            /* And start it */
            TransitionManager.beginDelayedTransition(parent, transition);

            /* Let the parent view know that something changed and that it needs to re-layout */
            notifyDataSetChanged();
        }
    });

    /* Add a long click handler */
    holder.view.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            /* If it's not installed or if it's currently downloading, do nothing */
            if ((ds.getState() == BuntataDatasourceAdvanced.InstallState.NOT_INSTALLED) || ds.isDownloading())
                return true;

            /* Show the option do delete the data source */
            DialogUtils.showDialog(context, R.string.dialog_delete_datasource_title,
                    R.string.dialog_delete_datasource_text, R.string.generic_yes, R.string.generic_no,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            /* Reset the currently selected data source, if this was the selected item */
                            int selected = PreferenceUtils.getPreferenceAsInt(context,
                                    PreferenceUtils.PREFS_SELECTED_DATASOURCE_ID, -1);
                            if (selected == ds.getId())
                                PreferenceUtils.removePreference(context,
                                        PreferenceUtils.PREFS_SELECTED_DATASOURCE_ID);

                            /* Remember that this isn't downloaded anymore */
                            ds.setState(BuntataDatasourceAdvanced.InstallState.NOT_INSTALLED);

                            try {
                                /* Delete associated files */
                                new DatasourceManager(context, ds.getId()).remove();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }

                            int installedDatasources = new DatasourceManager(context, -1).getAll().size();

                            if (installedDatasources < 1)
                                PreferenceUtils.removePreference(context,
                                        PreferenceUtils.PREFS_AT_LEAST_ONE_DATASOURCE);

                            onDatasetChanged();
                            animate(holder);

                            GoogleAnalyticsUtils.trackEvent(context,
                                    BaseActivity.getTracker(context, BaseActivity.TrackerName.APP_TRACKER),
                                    context.getString(R.string.ga_event_category_datasource_deleted),
                                    "Datasource: " + ds.getId());
                        }
                    }, null);
            return true;
        }
    });

    /* Add a click handler */
    holder.downloadStatus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (ds.isDownloading()) {

                DialogUtils.showDialog(context, R.string.dialog_download_cancel_title,
                        R.string.dialog_download_cancel_text, R.string.generic_yes, R.string.generic_no,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                if (downloadTask != null) {
                                    downloadTask.cancel(true);
                                    holder.progressBar.setVisibility(View.GONE);
                                    ds.setDownloading(false);
                                    downloadTask = null;
                                    setState(ds, holder);
                                }
                            }
                        }, null);
                return;
            } else {
                for (BuntataDatasourceAdvanced dss : dataset) {
                    if (dss.isDownloading()) {
                        SnackbarUtils.show(v, R.string.snackbar_only_one_download,
                                ContextCompat.getColor(context, android.R.color.primary_text_dark),
                                ContextCompat.getColor(context, R.color.colorPrimaryDark),
                                Snackbar.LENGTH_LONG);
                        return;
                    }
                }
            }

            switch (ds.getState()) {
            case INSTALLED_NO_UPDATE:
                /* Just remember the selected id and close the activity to return to wherever we came from */
                PreferenceUtils.setPreferenceAsInt(context, PreferenceUtils.PREFS_SELECTED_DATASOURCE_ID,
                        ds.getId());
                context.setResult(Activity.RESULT_OK);
                context.finish();
                return;

            case INSTALLED_HAS_UPDATE:
            case NOT_INSTALLED:

                DialogUtils.showDialog(context, R.string.dialog_download_title,
                        R.string.dialog_download_message, R.string.generic_yes, R.string.generic_no,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                initDownload(true, holder, ds);
                            }
                        }, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                initDownload(false, holder, ds);
                            }
                        });
                break;
            }
        }
    });
}

From source file:com.denel.facepatrol.MainActivity.java

public void ContactEdit(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Contact Information Feedback")
            .setMessage("You're about to edit and send personal information. "
                    + "Please note that the current database will only reflect your modification"
                    + " once the IT department verifies the change and the updated database"
                    + " is synced to your device. \n \n Do you want to continue?")
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                    emailIntent.setData(Uri.parse("mailto:"));
                    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "pkantue@gmail.com" }); // this email address will change
                    emailIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, feedback_subject);
                    emailIntent.putExtra(Intent.EXTRA_TEXT, feedback_body);
                    startActivity(Intent.createChooser(emailIntent, "Send Email..."));
                }//from  w  w w.  j  av a2  s  . c  om
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // User cancelled the dialog 
                }
            });
    builder.show();
    // exit the application
    //finish();      
}

From source file:de.NeonSoft.neopowermenu.Preferences.PreferencesPartFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO: Implement this method
    MainActivity.visibleFragment = "Main";

    mContext = getActivity();/*from  w  w  w. j a  v a  2  s.co  m*/

    ActiveStyle = MainActivity.preferences.getString("DialogTheme", "Material");
    hideicon = MainActivity.preferences.getBoolean("HideLauncherIcon", false);
    DeepXposedLogging = MainActivity.preferences.getBoolean("DeepXposedLogging", false);

    InflatedView = inflater.inflate(R.layout.activity_preferences, container, false);

    TextView_ModuleStateTitle = (TextView) InflatedView
            .findViewById(R.id.activitypreferencesTextView_ModuleStateTitle);
    TextView_ModuleStateDesc = (TextView) InflatedView
            .findViewById(R.id.activitypreferencesTextView_ModuleStateDesc);

    LinearLayout_Style = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Style);
    TextView_StyleTitle = (TextView) InflatedView.findViewById(R.id.activitypreferencesTextView_StyleTitle);
    TextView_StyleDesc = (TextView) InflatedView.findViewById(R.id.activitypreferencesTextView_StyleDesc);
    TextView_StyleDesc.setText(getString(R.string.preferencesDesc_Style).replace("[STYLENAME]", ActiveStyle));

    LinearLayout_Theme = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Theme);

    LinearLayout_VisibilityOrder = (LinearLayout) InflatedView
            .findViewById(R.id.activitypreferencesLinearLayout_VisibilityOrder);

    LinearLayout_Advanced = (LinearLayout) InflatedView
            .findViewById(R.id.activitypreferencesLinearLayout_Advanced);

    LinearLayout_HideLauncherIcon = (LinearLayout) InflatedView
            .findViewById(R.id.activitypreferencesLinearLayout_HideLauncherIcon);
    Switch_HideLauncherIcon = (Switch) InflatedView
            .findViewById(R.id.activitypreferencesSwitch_HideLauncherIcon);
    Switch_HideLauncherIcon.setChecked(hideicon);
    Switch_HideLauncherIcon.setClickable(false);
    Switch_HideLauncherIcon.setFocusable(false);

    LinearLayout_DeepXposedLogging = (LinearLayout) InflatedView
            .findViewById(R.id.activitypreferencesLinearLayout_DeepXposedLogging);
    Switch_DeepXposedLogging = (Switch) InflatedView
            .findViewById(R.id.activitypreferencesSwitch_DeepXposedLogging);
    Switch_DeepXposedLogging.setChecked(DeepXposedLogging);
    Switch_DeepXposedLogging.setClickable(false);
    Switch_DeepXposedLogging.setFocusable(false);

    LinearLayout_Source = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Source);
    LinearLayout_OrigSource = (LinearLayout) InflatedView
            .findViewById(R.id.activitypreferencesLinearLayout_OrigSource);

    LinearLayout_Share = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_Share);

    LinearLayout_Translator = (LinearLayout) InflatedView
            .findViewById(R.id.activitypreferencesLinearLayout_Translator);

    LinearLayout_About = (LinearLayout) InflatedView.findViewById(R.id.activitypreferencesLinearLayout_About);

    LinearLayout_Style.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            // TODO: Implement this method
            AlertDialog.Builder alertdb = new AlertDialog.Builder(getActivity());
            alertdb.setTitle(R.string.preferencesTitle_Style);
            String[] styleList = new String[1];
            styleList[0] = "Material";
            for (int i = 0; i < styleList.length; i++) {
                if (styleList[i].equalsIgnoreCase(ActiveStyle)) {
                    ActiveStyleId = i;
                    //presetsList[i] = "(Active) "+ presetsFiles[i].getName().split(".nps")[0];
                }
            }
            alertdb.setSingleChoiceItems(styleList, ActiveStyleId, null);
            alertdb.setNegativeButton(R.string.Dialog_Cancel, new AlertDialog.OnClickListener() {

                @Override
                public void onClick(DialogInterface p1, int p2) {
                    // TODO: Implement this method
                }
            });
            alertdb.setPositiveButton(R.string.Dialog_Ok, new AlertDialog.OnClickListener() {

                @Override
                public void onClick(DialogInterface p1, int p2) {
                    // TODO: Implement this method
                    try {
                        int selectedPosition = (ad).getListView().getCheckedItemPosition();
                        String selectedName = (ad).getListView().getItemAtPosition(selectedPosition).toString();
                        MainActivity.preferences.edit().putString("DialogTheme", selectedName).commit();
                        ActiveStyle = selectedName;
                        TextView_StyleDesc.setText(
                                getString(R.string.preferencesDesc_Style).replace("[STYLENAME]", ActiveStyle));
                    } catch (Throwable t) {
                    }
                }
            });
            ad = alertdb.create();
            ad.show();
        }
    });

    LinearLayout_Theme.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            MainActivity.fragmentManager.beginTransaction()
                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                    .replace(R.id.pref_container, new PreferencesColorFragment()).commit();
        }
    });

    LinearLayout_VisibilityOrder.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            MainActivity.fragmentManager.beginTransaction()
                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                    .replace(R.id.pref_container, new PreferencesVisibilityOrderFragment()).commit();
        }
    });

    LinearLayout_Advanced.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            MainActivity.fragmentManager.beginTransaction()
                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                    .replace(R.id.pref_container, new PreferencesAdvancedFragment()).commit();
        }
    });

    LinearLayout_HideLauncherIcon.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            hideicon = !hideicon;
            String packageName = getActivity().getPackageName();
            ComponentName componentSettings = new ComponentName(packageName, packageName + ".SettingsActivity");
            if (hideicon) {
                getActivity().getPackageManager().setComponentEnabledSetting(componentSettings,
                        PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
            } else {
                getActivity().getPackageManager().setComponentEnabledSetting(componentSettings,
                        PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
            }
            Switch_HideLauncherIcon.setChecked(hideicon);
            MainActivity.preferences.edit().putBoolean("HideLauncherIcon", hideicon).commit();
        }
    });

    LinearLayout_DeepXposedLogging.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            DeepXposedLogging = !DeepXposedLogging;
            Switch_DeepXposedLogging.setChecked(DeepXposedLogging);
            MainActivity.preferences.edit().putBoolean("DeepXposedLogging", DeepXposedLogging).commit();
        }
    });

    LinearLayout_Source.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            // TODO: Implement this method
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(Urlgithub));
            startActivity(i);
        }
    });

    LinearLayout_OrigSource.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            // TODO: Implement this method
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(Urloriggithub));
            startActivity(i);
        }
    });

    LinearLayout_Share.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            // TODO: Implement this method
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
            String sAux = getString(R.string.ShareMessage);
            sAux = sAux + "repo.xposed.info/module/de.NeonSoft.neopowermenu \n\n";
            i.putExtra(Intent.EXTRA_TEXT, sAux);
            startActivity(Intent.createChooser(i, getString(R.string.preferencesTitle_Share)));
        }
    });

    LinearLayout_About.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View p1) {
            // TODO: Implement this method
            adb = new AlertDialog.Builder(getActivity());
            adb.setTitle("About");

            adb.setMessage("NeoPowerMenu by Neon-Soft / DrAcHe981\n"
                    + "based on a Source from Naman Dwivedi (naman14)\n\n" + "< Used Librarys >\n"
                    + "> HoloColorPicker from Lars Werkman\n"
                    + "An Android Holo themed colorpicker designed by Marie Schweiz\n\n"
                    + "Licensed under the Apache License, Version 2.0\n\n" + "> DragSortListView from Bauerca\n"
                    + "DragSortListView (DSLV) is an extension of the Android ListView that enables drag-and-drop reordering of list items.\n\n"
                    + "Licensed under the Apache License, Version 2.0\n\n"
                    + "> libsuperuser from Chainfire / ChainsDD\n\n"
                    + "Licensed under the Apache License, Version 2.0\n\n" + "");

            adb.setPositiveButton(R.string.Dialog_Ok, null);

            ad = adb.create();
            ad.show();
        }
    });

    checkState();
    if (!MainActivity.RootAvailable) {
        pd = new ProgressDialog(getActivity());
        pd.setMessage(getString(R.string.Dialog_WaitForRoot));
        pd.setIndeterminate(true);
        pd.setCancelable(false);
        pd.setCanceledOnTouchOutside(false);
        pd.setButton(pd.BUTTON_NEGATIVE, getString(R.string.Dialog_Cancel),
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface p1, int p2) {
                        pd.dismiss();
                        getActivity().finish();
                    }
                });
        pd.setButton(pd.BUTTON_NEUTRAL, getString(R.string.Dialog_Ignore),
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface p1, int p2) {
                        pd.dismiss();
                    }
                });
        pd.show();
    } else if (MainActivity.RootAvailable) {
        rootAvailable();
    }

    getPermissions();
    return InflatedView;
}

From source file:app.view.main.MainActivity.java

/**
 * ??dialog//from ww  w  .ja  v a  2s.  c o  m
 */
private void showConflictDialog() {
    isConflictDialogShow = true;
    DemoApplication.getInstance().logout();

    if (!MainActivity.this.isFinishing()) {
        // clear up global variables
        try {
            if (conflictBuilder == null)
                conflictBuilder = new android.app.AlertDialog.Builder(MainActivity.this);
            conflictBuilder.setTitle("");
            conflictBuilder.setMessage(R.string.connect_conflict);
            conflictBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    conflictBuilder = null;
                    finish();
                    startActivity(new Intent(MainActivity.this, LoginActivity.class));
                }
            });
            conflictBuilder.setCancelable(false);
            conflictBuilder.create().show();
            isConflict = true;
        } catch (Exception e) {
            Log.e("###", "---------color conflictBuilder error" + e.getMessage());
        }

    }

}

From source file:com.ibuildapp.romanblack.FanWallPlugin.FanWallPlugin.java

private void initializeUI() {
    setContentView(R.layout.romanblack_fanwall_main);

    mainlLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_main);
    mainlLayout.setBackgroundColor(Statics.color1);

    // less then android L
    if (android.os.Build.VERSION.SDK_INT <= 20) {
        InputMethodManager im = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);
        SoftKeyboard softKeyboard;/*  w w w . ja  v a 2 s .  co  m*/
        softKeyboard = new SoftKeyboard(mainlLayout, im);
        softKeyboard.setSoftKeyboardCallback(new SoftKeyboard.SoftKeyboardChanged() {

            @Override
            public void onSoftKeyboardHide() {
                Message msg = handler.obtainMessage(HANDLE_TAP_BAR, 1, 0);
                handler.sendMessage(msg);
            }

            @Override
            public void onSoftKeyboardShow() {
                Message msg = handler.obtainMessage(HANDLE_TAP_BAR, 0, 0);
                handler.sendMessage(msg);
            }
        });
    }

    bottomBarHodler = (LinearLayout) findViewById(R.id.romanblack_fanwall_main_bottom_bar);

    TextView noMsgText = (TextView) findViewById(R.id.romanblack_fanwall_nomessages_text);

    // top bar
    setTopBarLeftButtonText(getResources().getString(R.string.common_home_upper), true,
            new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    finish();
                }
            });

    // set title
    if (TextUtils.isEmpty(widget.getTitle()))
        setTopBarTitle(getString(R.string.fanwall_talks));
    else
        setTopBarTitle(widget.getTitle());

    imageHolder = (LinearLayout) findViewById(R.id.fanwall_image_holder);
    userImage = (ImageView) findViewById(R.id.fanwall_user_image);
    closeBtn = (ImageView) findViewById(R.id.fanwall_close_image);
    closeBtn.setOnClickListener(this);

    chooserHolder = (LinearLayout) findViewById(R.id.fanwall_chooser_holder);
    openBottom = (LinearLayout) findViewById(R.id.romanblack_fanwall_open_bottom);
    openBottom.setOnClickListener(this);

    enableGpsCheckbox = (CheckBox) findViewById(R.id.romanblack_fanwall_enable_gps_checkbox);
    enableGpsCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                    final AlertDialog.Builder builder = new AlertDialog.Builder(FanWallPlugin.this);
                    builder.setMessage(getString(R.string.enable_gps_msg)).setCancelable(false)
                            .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                                public void onClick(@SuppressWarnings("unused") final DialogInterface dialog,
                                        @SuppressWarnings("unused") final int id) {
                                    startActivityForResult(
                                            new Intent(
                                                    android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS),
                                            GPS_SETTINGS_ACTIVITY);
                                }
                            }).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
                                public void onClick(final DialogInterface dialog,
                                        @SuppressWarnings("unused") final int id) {
                                    enableGpsCheckbox.setChecked(false);
                                    dialog.dismiss();
                                }
                            });
                    final AlertDialog alert = builder.create();
                    alert.show();
                } else {
                    Prefs.with(FanWallPlugin.this).save(Prefs.KEY_GPS, true);
                }
            } else
                Prefs.with(FanWallPlugin.this).save(Prefs.KEY_GPS, false);

        }
    });
    enableGpsCheckbox.setChecked(Prefs.with(FanWallPlugin.this).getBoolean(Prefs.KEY_GPS, false));

    galleryChooser = (LinearLayout) findViewById(R.id.romanblack_fanwall_gallery);
    galleryChooser.setOnClickListener(this);
    photoChooser = (LinearLayout) findViewById(R.id.romanblack_fanwall_make_photo);
    photoChooser.setOnClickListener(this);

    postMsg = (LinearLayout) findViewById(R.id.romanblack_fanwall_send_post);
    postMsg.setOnClickListener(this);
    editMsg = (EditText) findViewById(R.id.romanblack_fanwall_edit_msg);
    editMsg.addTextChangedListener(FanWallPlugin.this);

    tabHolder = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder);
    tabHolder.setBackgroundColor(res.getColor(R.color.black_50_trans));
    LinearLayout separator = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder_separator);
    separator.setBackgroundColor(res.getColor(R.color.white_30_trans));
    LinearLayout separatorUp = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder_up);
    LinearLayout separatorDown = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_holder_down);

    tabMapLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_map_layout);
    tabMapLayout.setOnClickListener(this);

    tabPhotosLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_tab_photos_layout);
    tabPhotosLayout.setOnClickListener(this);

    if (Statics.isSchemaDark) {
        separatorUp.setBackgroundColor(res.getColor(R.color.white_20_trans));
        separatorDown.setBackgroundColor(res.getColor(R.color.white_20_trans));
        int temp = Color.WHITE & 0x00ffffff;
        int result = temp | 0x80000000;
        noMsgText.setTextColor(result);
    } else {
        separatorUp.setBackgroundColor(res.getColor(R.color.black_20_trans));
        separatorDown.setBackgroundColor(res.getColor(R.color.black_20_trans));
        int temp = Color.BLACK & 0x00ffffff;
        int result = temp | 0x80000000;
        noMsgText.setTextColor(result);
    }

    noMessagesLayout = (LinearLayout) findViewById(R.id.romanblack_fanwall_main_nomessages_layout);

    messageListLayoutRoot = (FrameLayout) findViewById(R.id.romanblack_fanwall_messagelist_list_layout);
    messageList = (PullToRefreshListView) findViewById(R.id.romanblack_fanwall_messagelist_pulltorefresh);
    messageList.setDivider(null);
    messageList.setBackgroundColor(Color.TRANSPARENT);
    messageList.setDrawingCacheBackgroundColor(Color.TRANSPARENT);

    ILoadingLayout loadingLayout = messageList.getLoadingLayoutProxy();
    if (Statics.isSchemaDark) {
        loadingLayout.setHeaderColor(Color.WHITE);
    } else {
        loadingLayout.setHeaderColor(Color.BLACK);
    }

    //messageList.set
    adapter = new MainLayoutMessagesAdapter(FanWallPlugin.this, messageList, messages, widget);
    adapter.setInnerInterface(new MainLayoutMessagesAdapter.onEndReached() {
        @Override
        public void endReached() {
            if (!refreshingBottom)
                refreshBottom();
        }
    });

    messageList.setAdapter(adapter);
    messageList.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {
        @Override
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            refreshTop();
        }
    });

    if (Statics.canEdit.compareToIgnoreCase("all") == 0) {
        bottomBarHodler.setVisibility(View.VISIBLE);
    } else {
        bottomBarHodler.setVisibility(View.GONE);
    }

    // start downloading messages
    // exactly in create() method!!!
    handler.sendEmptyMessage(SHOW_PROGRESS_DIALOG);
    refreshMessages();
}

From source file:com.vuze.android.remote.AppPreferences.java

public void showRateDialog(final Activity mContext) {

    if (!shouldShowRatingReminder()) {
        return;//w w  w  .ja v a 2s  .  co m
    }

    // skip showing if they are adding a torrent (or anything else)
    Intent intent = mContext.getIntent();
    if (intent != null) {
        Uri data = intent.getData();
        if (data != null) {
            return;
        }
    }

    // even if something goes wrong, we want to set that we asked, so
    // it doesn't continue to pop up
    setAskedRating();

    Dialog dialog = new Dialog(mContext);

    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
    builder.setMessage(R.string.ask_rating_message).setCancelable(false)
            .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String appPackageName = mContext.getPackageName();
                    try {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=" + appPackageName)));
                    } catch (android.content.ActivityNotFoundException anfe) {
                        mContext.startActivity(new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
                    }
                    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskStoreClick",
                            null);
                }
            }).setNeutralButton(R.string.later, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    setNeverAskRatingAgain();
                }
            });
    dialog = builder.create();

    VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskShown", null);
    dialog.show();
}

From source file:de.NeonSoft.neopowermenu.Preferences.PreferencesPartFragment.java

public void showPermissionDialog(int permission) {
    switch (permission) {
    case MY_PERMISSIONS_REQUEST:
        adb = new AlertDialog.Builder(getActivity());
        adb.setTitle(R.string.permissionRequestTitle);
        adb.setMessage(R.string.permissionRequestMsg);
        adb.setPositiveButton(R.string.Dialog_Ok, new DialogInterface.OnClickListener() {

            @Override/* w  ww .j av a  2s  .c o  m*/
            public void onClick(DialogInterface p1, int p2) {
                // TODO: Implement this method
                adb = null;
                requestPermissions(
                        new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA },
                        MY_PERMISSIONS_REQUEST);
            }
        });
        adb.setNegativeButton(R.string.Dialog_Cancel, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface p1, int p2) {
                // TODO: Implement this method
                getActivity().finish();
            }
        });
        adb.show();
        break;
    }
}

From source file:devcoin.wallet.ui.SendCoinsFragment.java

private void initStateFromBitcoinUri(@Nonnull final Uri bitcoinUri) {
    final String input = bitcoinUri.toString();

    new StringInputParser(input) {
        @Override//  w  ww  .java 2s. c  om
        protected void bitcoinRequest(final Address address, final String addressLabel, final BigInteger amount,
                final String bluetoothMac) {
            update(address.toString(), addressLabel, amount, bluetoothMac);
        }

        @Override
        protected void directTransaction(final Transaction transaction) {
            cannotClassify(input);
        }

        @Override
        protected void error(final int messageResId, final Object... messageArgs) {
            dialog(activity, dismissListener, 0, messageResId, messageArgs);
        }

        private final DialogInterface.OnClickListener dismissListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                activity.finish();
            }
        };
    }.parse();
}