List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.hughes.android.dictionary.DictionaryActivity.java
void onSearchTextChange(final String text) { if ("thadolina".equals(text)) { final Dialog dialog = new Dialog(getListView().getContext()); dialog.setContentView(R.layout.thadolina_dialog); dialog.setTitle("Ti amo, amore mio!"); final ImageView imageView = (ImageView) dialog.findViewById(R.id.thadolina_image); imageView.setOnClickListener(new OnClickListener() { @Override/*from w w w.ja v a 2s . com*/ public void onClick(View v) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://sites.google.com/site/cfoxroxvday/vday2012")); startActivity(intent); } }); dialog.show(); } if (dictRaf == null) { Log.d(LOG, "searchText changed during shutdown, doing nothing."); return; } // if (!searchView.hasFocus()) { // Log.d(LOG, "searchText changed without focus, doing nothing."); // return; // } Log.d(LOG, "onSearchTextChange: " + text); if (currentSearchOperation != null) { Log.d(LOG, "Interrupting currentSearchOperation."); currentSearchOperation.interrupted.set(true); } currentSearchOperation = new SearchOperation(text, index); searchExecutor.execute(currentSearchOperation); }
From source file:de.mkrtchyan.recoverytools.RecoveryTools.java
private void showFlashRecoveryDialog() { final Dialog FlashRecoveryDialog = new Dialog(mContext); LayoutInflater inflater = getLayoutInflater(); FlashRecoveryDialog.setTitle(R.string.flash_options); try {//from w ww . j av a 2 s . c o m final ScrollView RecoveryLayout = (ScrollView) inflater.inflate(R.layout.recovery_dialog, null); LinearLayout layout = (LinearLayout) RecoveryLayout.getChildAt(0); FlashRecoveryDialog.setContentView(RecoveryLayout); if (!mDevice.isCwmSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bCWM)); } if (!mDevice.isTwrpSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bTWRP)); } if (!mDevice.isPhilzSupported()) { layout.removeView(FlashRecoveryDialog.findViewById(R.id.bPHILZ)); } FlashRecoveryDialog.show(); } catch (NullPointerException e) { Notifyer.showExceptionToast(mContext, TAG, e); } }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getString(R.string.showPrevNextButtonsKey), true)) { // Next word. nextWordMenuItem = menu.add(getString(R.string.nextWord)).setIcon(R.drawable.arrow_down_float); MenuItemCompat.setShowAsAction(nextWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); nextWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override//from ww w. j a v a 2s .c om public boolean onMenuItemClick(MenuItem item) { onUpDownButton(false); return true; } }); // Previous word. previousWordMenuItem = menu.add(getString(R.string.previousWord)).setIcon(R.drawable.arrow_up_float); MenuItemCompat.setShowAsAction(previousWordMenuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM); previousWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onUpDownButton(true); return true; } }); } randomWordMenuItem = menu.add(getString(R.string.randomWord)); randomWordMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { onRandomWordButton(); return true; } }); application.onCreateGlobalOptionsMenu(this, menu); { final MenuItem dictionaryManager = menu.add(getString(R.string.dictionaryManager)); MenuItemCompat.setShowAsAction(dictionaryManager, MenuItem.SHOW_AS_ACTION_NEVER); dictionaryManager.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return false; } }); } { final MenuItem aboutDictionary = menu.add(getString(R.string.aboutDictionary)); MenuItemCompat.setShowAsAction(aboutDictionary, MenuItem.SHOW_AS_ACTION_NEVER); aboutDictionary.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { final Context context = getListView().getContext(); final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.about_dictionary_dialog); final TextView textView = (TextView) dialog.findViewById(R.id.text); final String name = application.getDictionaryName(dictFile.getName()); dialog.setTitle(name); final StringBuilder builder = new StringBuilder(); final DictionaryInfo dictionaryInfo = dictionary.getDictionaryInfo(); dictionaryInfo.uncompressedBytes = dictFile.length(); if (dictionaryInfo != null) { builder.append(dictionaryInfo.dictInfo).append("\n\n"); builder.append(getString(R.string.dictionaryPath, dictFile.getPath())).append("\n"); builder.append(getString(R.string.dictionarySize, dictionaryInfo.uncompressedBytes)) .append("\n"); builder.append(getString(R.string.dictionaryCreationTime, dictionaryInfo.creationMillis)) .append("\n"); for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) { builder.append("\n"); builder.append(getString(R.string.indexName, indexInfo.shortName)).append("\n"); builder.append(getString(R.string.mainTokenCount, indexInfo.mainTokenCount)) .append("\n"); } builder.append("\n"); builder.append(getString(R.string.sources)).append("\n"); for (final EntrySource source : dictionary.sources) { builder.append(getString(R.string.sourceInfo, source.getName(), source.getNumEntries())) .append("\n"); } } textView.setText(builder.toString()); dialog.show(); final WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(layoutParams); return false; } }); } return true; }
From source file:com.speed.traquer.app.TraqComplaintTaxi.java
private void PromptCustomDialog() { // Create custom dialog object final Dialog dialog = new Dialog(TraqComplaintTaxi.this); // Include dialog.xml file dialog.setContentView(R.layout.activity_submit_social); // Set dialog title dialog.setTitle("Submit via"); // set values for custom dialog components - text, image and button final TextView twitterText = (TextView) dialog.findViewById(R.id.textTwitterDialog); twitterText.setText("Twitter"); final TextView facebookText = (TextView) dialog.findViewById(R.id.textFacebookDialog); facebookText.setText("Facebook"); final TextView defaultText = (TextView) dialog.findViewById(R.id.textDefaultDialog); defaultText.setText("Default"); defaultText.setTextColor(getResources().getColor(R.color.Orange)); final TextView smsText = (TextView) dialog.findViewById(R.id.textSMSDialog); smsText.setText("SMS"); final ImageView image = (ImageView) dialog.findViewById(R.id.imageDialog); image.setImageResource(R.drawable.icon_twitter); final ImageView imageFb = (ImageView) dialog.findViewById(R.id.imageDialogFb); imageFb.setImageResource(R.drawable.ic_fb_grey); final ImageView imageDefault = (ImageView) dialog.findViewById(R.id.imageDialogDefault); imageDefault.setImageResource(R.drawable.icon_traquer_color); isDefaultSelected = true;// w ww.ja v a 2 s . c o m final ImageView imageSMS = (ImageView) dialog.findViewById(R.id.imageDialogSMS); imageSMS.setImageResource(R.drawable.icon_sms); dialog.show(); //Retrieve form info taxi_id = inputTaxi.getText().toString().toUpperCase(); taxi_id = taxi_id.replace(" ", ""); taxi_comp = actv_comp_taxi.getText().toString(); taxi_driver = taxiDriver.getText().toString(); taxi_license = taxiLic.getText().toString(); loc_frm = actv_from.getText().toString(); loc_to = actv_to.getText().toString(); dateBus = editDate.getText().toString(); timeBus = editTime.getText().toString(); curr_time = editCurrTime.getText().toString(); user_name = SaveSharedPreference.getUserName(TraqComplaintTaxi.this); //Twitter Button final RelativeLayout twitterLogin = (RelativeLayout) dialog.findViewById(R.id.twitterImageButton); twitterLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTwitterSelected) { image.setImageResource(R.drawable.icon_twitter); twitterText.setTextColor(getResources().getColor(R.color.DarkGray)); isTwitterSelected = false; } else { loginToTwitter(); image.setImageResource(R.drawable.icon_twitter_blue); twitterText.setTextColor(getResources().getColor(R.color.TwitterBlue)); isTwitterSelected = true; } } }); //facebook Button final RelativeLayout facebookLogin = (RelativeLayout) dialog.findViewById(R.id.facebookImageButton); facebookLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isFacebookSelected) { imageFb.setImageResource(R.drawable.ic_fb_grey); if (fbUserName != null) facebookText.setText("Facebook"); facebookText.setTextColor(getResources().getColor(R.color.DarkGray)); isFacebookSelected = false; } else { //loginToTwitter(); // start Facebook Login loginToFacebook(); if (fbUserName != null) facebookText.setText(fbUserName); imageFb.setImageResource(R.drawable.ic_fb_blue); facebookText.setTextColor(getResources().getColor(R.color.TwitterBlue)); isFacebookSelected = true; } } }); //SMS Button final RelativeLayout SMSLogin = (RelativeLayout) dialog.findViewById(R.id.smsImageButton); SMSLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isSmsSelected) { imageSMS.setImageResource(R.drawable.icon_sms); smsText.setTextColor(getResources().getColor(R.color.DarkGray)); isSmsSelected = false; } else { imageSMS.setImageResource(R.drawable.icon_sms_color); smsText.setTextColor(getResources().getColor(R.color.Orange)); isSmsSelected = true; } } }); /*/Default Button final RelativeLayout defaultLogin = (RelativeLayout)dialog.findViewById(R.id.defaultImageButton); defaultLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(isDefaultSelected) { imageDefault.setImageResource(R.drawable.icon_traquer_color); defaultText.setTextColor(getResources().getColor(R.color.Orange)); isDefaultSelected = false; } else { imageDefault.setImageResource(R.drawable.icon_traquer_color); defaultText.setTextColor(getResources().getColor(R.color.Orange)); isDefaultSelected = true; } } });*/ //Submit Button Button declineButton = (Button) dialog.findViewById(R.id.submitButton); // if decline button is clicked, close the custom dialog declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //submit complaint isSubmitButtonClicked = true; if (isNetworkConnected() == true) { Toast.makeText(TraqComplaintTaxi.this, "Complaint sent. Thank you for taking action!", Toast.LENGTH_SHORT).show(); //Combine Strings for Twitter Status String status = taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude) + "E, " + curr_time + " @aduanSPAD @MyTraquer #Traquer"; finalStatus = status; if (isFacebookSelected) { //share to facebook ShareToFacebook(status); //publishFeedDialog(); } if (isTwitterSelected) { //Toast.makeText(TraqComplaintTaxi.this, Long.toString(twitterID) + userName, Toast.LENGTH_SHORT).show(); // Check for blank text if (status.trim().length() > 0) { // update status if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) { new updateTwitterStatus().execute(status); } else new updateTwitterStatus().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, status); } else { // EditText is empty Toast.makeText(getApplicationContext(), "Please enter status message", Toast.LENGTH_SHORT).show(); } } else { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB_MR1) new InsertForm().execute(); else new InsertForm().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } // Close dialog dialog.dismiss(); } else { if (isSmsSelected) { Log.i("Clicks", "You clicked sent."); Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("address", "15888"); sendIntent.putExtra("sms_body", "SPAD Aduan " + taxi_id + ", " + taxi_comp + " taxi is speeding with " + speedTaxiExceed + "km/h at " + Double.toString(gLatitude) + "N, " + Double.toString(gLongitude) + "E, " + curr_time + " - Traquer"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent); //1800-88-7723 } else { Toast.makeText(TraqComplaintTaxi.this, "Failed to send. Please check your network connection.", Toast.LENGTH_SHORT).show(); } } } }); //TraqComplaintTaxi.this.showDialog(ALERT_DIALOG); }
From source file:in.shick.diode.threads.ThreadsListActivity.java
@Override protected void onPrepareDialog(int id, Dialog dialog) { super.onPrepareDialog(id, dialog); switch (id) { case Constants.DIALOG_LOGIN: if (mSettings.getUsername() != null) { final TextView loginUsernameInput = (TextView) dialog.findViewById(R.id.login_username_input); loginUsernameInput.setText(mSettings.getUsername()); }//from w w w . j a va 2s. c om final TextView loginPasswordInput = (TextView) dialog.findViewById(R.id.login_password_input); loginPasswordInput.setText(""); break; case Constants.DIALOG_THREAD_CLICK: if (mVoteTargetThing == null) break; fillThreadClickDialog(dialog, mVoteTargetThing, mThreadClickDialogOnClickListenerFactory); break; case Constants.DIALOG_SORT_BY: ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortBy(), true); break; case Constants.DIALOG_SORT_BY_NEW: ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortByNew(), true); break; case Constants.DIALOG_SORT_BY_CONTROVERSIAL: ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortByControversial(), true); break; case Constants.DIALOG_SORT_BY_TOP: ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortByTop(), true); break; default: // No preparation based on app state is required. break; } }
From source file:com.andrewshu.android.reddit.mail.InboxListActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog; ProgressDialog pdialog;/*from ww w .j a v a 2 s . co m*/ AlertDialog.Builder builder; LayoutInflater inflater; View layout; // used for inflated views for AlertDialog.Builder.setView() switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, true) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_REPLY: dialog = new Dialog(this, mSettings.getDialogTheme()); dialog.setContentView(R.layout.compose_reply_dialog); final EditText replyBody = (EditText) dialog.findViewById(R.id.body); final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button); final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button); replySaveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mReplyTargetName != null) { new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString()); removeDialog(Constants.DIALOG_REPLY); } else { Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT, InboxListActivity.this); } } }); replyCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_REPLY); } }); break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_REPLYING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Sending reply..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }
From source file:org.rm3l.maoni.ui.MaoniActivity.java
private void initScreenCaptureView(@NonNull final Intent intent) { final ImageButton screenshotThumb = (ImageButton) findViewById(R.id.maoni_screenshot); final TextView touchToPreviewTextView = (TextView) findViewById(R.id.maoni_screenshot_touch_to_preview); if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) { touchToPreviewTextView.setText(intent.getCharSequenceExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)); }/*w ww . j av a 2 s.co m*/ final View screenshotContentView = findViewById(R.id.maoni_include_screenshot_content); if (!TextUtils.isEmpty(mScreenshotFilePath)) { final File file = new File(mScreenshotFilePath.toString()); if (file.exists()) { if (mIncludeScreenshot != null) { mIncludeScreenshot.setVisibility(View.VISIBLE); } if (screenshotContentView != null) { screenshotContentView.setVisibility(View.VISIBLE); } if (screenshotThumb != null) { //Thumbnail - load with smaller resolution so as to reduce memory footprint screenshotThumb.setImageBitmap( ViewUtils.decodeSampledBitmapFromFilePath(file.getAbsolutePath(), 100, 100)); } // Hook up clicks on the thumbnail views. if (screenshotThumb != null) { screenshotThumb.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog imagePreviewDialog = new Dialog(MaoniActivity.this); imagePreviewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); imagePreviewDialog.getWindow() .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); imagePreviewDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { //nothing; } }); imagePreviewDialog.setContentView(R.layout.maoni_screenshot_preview); final View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View v) { imagePreviewDialog.dismiss(); } }; final ImageView imageView = (ImageView) imagePreviewDialog .findViewById(R.id.maoni_screenshot_preview_image); imageView.setImageURI(Uri.fromFile(file)); final DrawableView drawableView = (DrawableView) imagePreviewDialog .findViewById(R.id.maoni_screenshot_preview_image_drawable_view); final DrawableViewConfig config = new DrawableViewConfig(); // If the view is bigger than canvas, with this the user will see the bounds config.setShowCanvasBounds(true); config.setStrokeWidth(57.0f); config.setMinZoom(1.0f); config.setMaxZoom(1.0f); config.setStrokeColor(mHighlightColor); final View decorView = getWindow().getDecorView(); config.setCanvasWidth(decorView.getWidth()); config.setCanvasHeight(decorView.getHeight()); drawableView.setConfig(config); drawableView.bringToFront(); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_highlight_color) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { config.setStrokeColor(mHighlightColor); } }); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_blackout_color) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { config.setStrokeColor(mBlackoutColor); } }); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_close) .setOnClickListener(clickListener); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_undo) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { drawableView.undo(); } }); imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_save) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ViewUtils.exportViewToFile(MaoniActivity.this, imagePreviewDialog.findViewById( R.id.maoni_screenshot_preview_image_view_updated), new File(mScreenshotFilePath.toString())); initScreenCaptureView(intent); imagePreviewDialog.dismiss(); } }); imagePreviewDialog.setCancelable(true); imagePreviewDialog.setCanceledOnTouchOutside(false); imagePreviewDialog.show(); } }); } } else { if (mIncludeScreenshot != null) { mIncludeScreenshot.setVisibility(View.GONE); } if (screenshotContentView != null) { screenshotContentView.setVisibility(View.GONE); } } } else { if (mIncludeScreenshot != null) { mIncludeScreenshot.setVisibility(View.GONE); } if (screenshotContentView != null) { screenshotContentView.setVisibility(View.GONE); } } }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void setProfileActionTimeListener(final GlobalParameters mGlblParms, final Dialog dialog, final AdapterProfileList pfla, final String curr_grp) { final Spinner spinnerTimeType = (Spinner) dialog.findViewById(R.id.edit_profile_action_time_type); spinnerTimeType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override// w ww. j a v a 2 s .c om final public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) { } @Override final public void onNothingSelected(AdapterView<?> arg0) { } }); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private boolean auditActivityExtraData(GlobalParameters mGlblParms, Dialog dialog, Spinner spinnerExtraDataType, Spinner spinnerExtraDataBoolean) { final TextView dlg_msg = (TextView) dialog.findViewById(R.id.edit_activity_extra_data_item_msg); // final EditText et_key=(EditText)dialog.findViewById(R.id.edit_activity_extra_data_item_key); // final EditText et_string=(EditText)dialog.findViewById(R.id.edit_activity_extra_data_item_data_string); final EditText et_int = (EditText) dialog.findViewById(R.id.edit_activity_extra_data_item_data_int); if (spinnerExtraDataType.getSelectedItem().toString() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_STRING)) { // if (et_string.getText().toString().equals("")) { // dlg_msg.setText("Specify String value"); // return false; // } } else if (spinnerExtraDataType.getSelectedItem().toString() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_INT)) { if (et_int.getText().toString().equals("")) { dlg_msg.setText(mGlblParms.context .getString(R.string.msgs_edit_profile_action_activity_extra_data_int_data_missing)); return false; }/*from ww w . j a va2 s. c o m*/ } else if (spinnerExtraDataType.getSelectedItem().toString() .equals(PROFILE_ACTION_TYPE_ACTIVITY_EXTRA_DATA_VALUE_BOOLEAN)) { } return true; }
From source file:com.gpsmobitrack.gpstracker.MenuItems.SettingsPage.java
/** * Show frequency dialog// w ww.ja va2s. c o m */ private void showFrequencyPurchaseDialog(final int value) { final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false); dialog.setContentView(R.layout.alert_dialog_main); final TextView alertTitle = (TextView) dialog.findViewById(R.id.alert_title); final TextView alertMsg = (TextView) dialog.findViewById(R.id.alert_msg); final EditText alertEditTxt = (EditText) dialog.findViewById(R.id.alert_edit_txt); Button okBtn = (Button) dialog.findViewById(R.id.alert_ok_btn); Button cancelBtn = (Button) dialog.findViewById(R.id.alert_cancel_btn); final RadioGroup radioGroup = (RadioGroup) dialog.findViewById(R.id.myRadioGroup); final RadioButton radioOneMonth = (RadioButton) dialog.findViewById(R.id.oneMonth); final RadioButton radioThreeMonth = (RadioButton) dialog.findViewById(R.id.threeMonth); final RadioButton radioSixMonth = (RadioButton) dialog.findViewById(R.id.sixMonth); final RadioButton radioOneYear = (RadioButton) dialog.findViewById(R.id.oneYear); //long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL); radioGroup.setVisibility(View.VISIBLE); alertTitle.setText("Purchase Product"); if (value == updateDurationValue[0]) { alertMsg.setText("Buy Update Frequency for 1 Minutes"); //radioOneMonth.setChecked(true); if (userType == PurchaseStatus.FULL_ACCESS_USER) { if (duration.equalsIgnoreCase("OneMonth")) { radioOneMonth.setChecked(true); } else { radioOneMonth.setChecked(false); ; } if (duration.equalsIgnoreCase("ThreeMonth")) { radioThreeMonth.setChecked(true); } else { radioThreeMonth.setChecked(false); } if (duration.equalsIgnoreCase("SixMonth")) { radioSixMonth.setChecked(true); } else { radioSixMonth.setChecked(false); } if (duration.equalsIgnoreCase("OneYear")) { radioOneYear.setChecked(true); } else { radioOneYear.setChecked(false); } } } else if (value == updateDurationValue[1]) { alertMsg.setText("Buy Update Frequency for 2 Minutes"); if (userType == PurchaseStatus.SEMI_FULL_ACCESS_USER) { if (duration.equalsIgnoreCase("OneMonth")) { radioOneMonth.setChecked(true); } else { radioOneMonth.setChecked(false); ; } if (duration.equalsIgnoreCase("ThreeMonth")) { radioThreeMonth.setChecked(true); } else { radioThreeMonth.setChecked(false); } if (duration.equalsIgnoreCase("SixMonth")) { radioSixMonth.setChecked(true); } else { radioSixMonth.setChecked(false); } if (duration.equalsIgnoreCase("OneYear")) { radioOneYear.setChecked(true); } else { radioOneYear.setChecked(false); } } } else if (value == updateDurationValue[2]) { alertMsg.setText("Buy Update Frequency for 3 Minutes"); if (userType == PurchaseStatus.PARTIAL_ACCESS_USER) { if (duration.equalsIgnoreCase("OneMonth")) { radioOneMonth.setChecked(true); } else { radioOneMonth.setChecked(false); ; } if (duration.equalsIgnoreCase("ThreeMonth")) { radioThreeMonth.setChecked(true); } else { radioThreeMonth.setChecked(false); } if (duration.equalsIgnoreCase("SixMonth")) { radioSixMonth.setChecked(true); } else { radioSixMonth.setChecked(false); } if (duration.equalsIgnoreCase("OneYear")) { radioOneYear.setChecked(true); } else { radioOneYear.setChecked(false); } } } alertEditTxt.setVisibility(View.GONE); radioOneMonth.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (value == updateDurationValue[0]) { purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH; } else if (value == updateDurationValue[1]) { purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH; } else if (value == updateDurationValue[2]) { purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH; } } }); radioThreeMonth.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (value == updateDurationValue[0]) { purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH; } else if (value == updateDurationValue[1]) { purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH; } else if (value == updateDurationValue[2]) { purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH; } } }); radioSixMonth.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (value == updateDurationValue[0]) { purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH; } else if (value == updateDurationValue[1]) { purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH; } else if (value == updateDurationValue[2]) { purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH; } } }); radioOneYear.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (value == updateDurationValue[0]) { purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR; } else if (value == updateDurationValue[1]) { purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR; } else if (value == updateDurationValue[2]) { purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR; } } }); cancelBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL); // Set Spinner setSpinnerUpdateTime(updateTime); firstSelect = false; } }); okBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (radioOneMonth.isChecked() || radioThreeMonth.isChecked() || radioSixMonth.isChecked() || radioOneYear.isChecked()) { // One min update if (value == updateDurationValue[0] && radioOneMonth.isChecked()) { fullPurchaseOneMonth(); purchaseClicked = PurchaseClicked.ONE_MIN_ONE_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[0] && radioThreeMonth.isChecked()) { fullPurchaseThreeMonth(); purchaseClicked = PurchaseClicked.ONE_MIN_THREE_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[0] && radioSixMonth.isChecked()) { fullPurchaseSixMonth(); purchaseClicked = PurchaseClicked.ONE_MIN_SIX_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[0] && radioOneYear.isChecked()) { fullPurchaseOneYear(); purchaseClicked = PurchaseClicked.ONE_MIN_ONE_YEAR; //startUpdatePurchaseStatus(); } // Two min update else if (value == updateDurationValue[1] && radioOneMonth.isChecked()) { semiparticalPurchaseOneMonth(); purchaseClicked = PurchaseClicked.TWO_MIN_ONE_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[1] && radioThreeMonth.isChecked()) { semiparticalPurchaseThreeMonth(); purchaseClicked = PurchaseClicked.TWO_MIN_THREE_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[1] && radioSixMonth.isChecked()) { semiparticalPurchaseSixMonth(); purchaseClicked = PurchaseClicked.TWO_MIN_SIX_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[1] && radioOneYear.isChecked()) { semiparticalPurchaseOneYear(); purchaseClicked = PurchaseClicked.TWO_MIN_ONE_YEAR; //startUpdatePurchaseStatus(); } // Three min update else if (value == updateDurationValue[2] && radioOneMonth.isChecked()) { particalPurchaseOneMonth(); purchaseClicked = PurchaseClicked.THREE_MIN_ONE_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[2] && radioThreeMonth.isChecked()) { particalPurchaseThreeMonth(); purchaseClicked = PurchaseClicked.THREE_MIN_THREE_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[2] && radioSixMonth.isChecked()) { particalPurchaseSixMonth(); purchaseClicked = PurchaseClicked.THREE_MIN_SIX_MONTH; //startUpdatePurchaseStatus(); } else if (value == updateDurationValue[2] && radioOneYear.isChecked()) { particalPurchaseOneYear(); purchaseClicked = PurchaseClicked.THREE_MIN_ONE_YEAR; //startUpdatePurchaseStatus(); } long updateTime = pref.getLong(AppConstants.FREQ_UPDATE_PREF, AppConstants.DEFAULT_TIME_INTERVAL); // Set Spinner setSpinnerUpdateTime(updateTime); firstSelect = false; dialog.dismiss(); } else { dialog.show(); Utils.showToast("Select durations"); //Toast.makeText(getActivity(), "Select durations", Toast.LENGTH_LONG).show(); } } }); dialog.show(); }