List of usage examples for android.app Dialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.tgaubert.blefinder.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_reset) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.activity_main_reset_title); builder.setMessage(R.string.activity_main_reset_text); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override//from www . j av a2 s . co m public void onClick(DialogInterface dialog, int which) { BeaconIO.getSeenBeacons().clear(); Snackbar.make(findViewById(R.id.floating_btn), R.string.activity_main_reset_done, Snackbar.LENGTH_LONG).show(); } }); builder.setNegativeButton(R.string.no, null); builder.show(); } if (id == R.id.action_about) { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_about); WindowManager.LayoutParams params = dialog.getWindow().getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; dialog.getWindow().setAttributes(params); dialog.show(); PackageInfo pInfo = null; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } if (pInfo != null) ((TextView) dialog.findViewById(R.id.appVersion)).setText(pInfo.versionName); dialog.findViewById(R.id.dialogLicenses).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); final Dialog licenseDialog = new Dialog(v.getContext()); licenseDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); licenseDialog.setContentView(R.layout.dialog_licenses); WindowManager.LayoutParams licenseParams = licenseDialog.getWindow().getAttributes(); licenseParams.width = WindowManager.LayoutParams.MATCH_PARENT; licenseDialog.getWindow().setAttributes(licenseParams); licenseDialog.show(); String licenses = "<h3>android-beacon-library</h3>" + "<p>Copyright 2014 Radius Networks</p>\n" + "\n" + " <p>Licensed under the Apache License, Version 2.0 (the \"License\");\n" + " you may not use this file except in compliance with the License.\n" + " You may obtain a copy of the License at</p>\n" + "\n" + " <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n" + " <p>Unless required by applicable law or agreed to in writing, software\n" + " distributed under the License is distributed on an \"AS IS\" BASIS,\n" + " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + " See the License for the specific language governing permissions and\n" + " limitations under the License.</p>" + "<h3>BottomSheet</h3>" + "<p>Copyright 2011, 2015 Kai Liao</p>\n" + "\n" + "<p>Licensed under the Apache License, Version 2.0 (the \"License\");\n" + "you may not use this file except in compliance with the License.\n" + "You may obtain a copy of the License at</p>\n" + "\n" + " <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n" + "<p>Unless required by applicable law or agreed to in writing, software\n" + "distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "See the License for the specific language governing permissions and\n" + "limitations under the License.</p>"; ((TextView) licenseDialog.findViewById(R.id.dialogText)).setText(Html.fromHtml(licenses)); licenseDialog.findViewById(R.id.licenseOk).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { licenseDialog.dismiss(); } }); } }); return true; } return super.onOptionsItemSelected(item); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
@SuppressLint("NewApi") final private void aboutTaskAutomation() { // common ??// www .ja va 2 s . c om final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); ((TextView) dialog.findViewById(R.id.about_dialog_title)) .setText(getString(R.string.msgs_about_dlg_title) + " Ver " + getApplVersionName()); final WebView func_view = (WebView) dialog.findViewById(R.id.about_dialog_function); // func_view.setWebViewClient(new WebViewClient()); // func_view.getSettings().setJavaScriptEnabled(true); func_view.getSettings().setSupportZoom(true); // func_view.setVerticalScrollbarOverlay(true); func_view.setBackgroundColor(Color.LTGRAY); // func_view.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); func_view.setVerticalScrollBarEnabled(true); func_view.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT > 10) { func_view.getSettings().setDisplayZoomControls(true); func_view.getSettings().setBuiltInZoomControls(true); } else { func_view.getSettings().setBuiltInZoomControls(true); } func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_about_dlg_func_html)); final WebView change_view = (WebView) dialog.findViewById(R.id.about_dialog_change_history); if (Build.VERSION.SDK_INT > 10) { func_view.getSettings().setDisplayZoomControls(true); func_view.getSettings().setBuiltInZoomControls(true); } else { func_view.getSettings().setBuiltInZoomControls(true); } change_view.loadDataWithBaseURL("file:///android_asset/", getString(R.string.msgs_about_dlg_change_desc), "text/html", "UTF-8", ""); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setSupportZoom(true); if (Build.VERSION.SDK_INT > 10) { change_view.getSettings().setDisplayZoomControls(true); change_view.getSettings().setBuiltInZoomControls(true); } else { change_view.getSettings().setBuiltInZoomControls(true); } final Button btnFunc = (Button) dialog.findViewById(R.id.about_dialog_btn_show_func); final Button btnChange = (Button) dialog.findViewById(R.id.about_dialog_btn_show_change); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); func_view.setVisibility(TextView.VISIBLE); change_view.setVisibility(TextView.GONE); btnChange.setBackgroundResource(R.drawable.button_back_ground_color_selector); btnFunc.setBackgroundResource(R.drawable.button_back_ground_color_selector); btnChange.setTextColor(Color.DKGRAY); btnFunc.setTextColor(Color.GREEN); btnFunc.setEnabled(false); CommonDialog.setDlgBoxSizeLimit(dialog, true); // func? btnFunc.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.GONE); func_view.setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); btnFunc.setTextColor(Color.GREEN); btnChange.setTextColor(Color.DKGRAY); btnChange.setEnabled(true); btnFunc.setEnabled(false); } }); // change? btnChange.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.VISIBLE); func_view.setVisibility(TextView.GONE); CommonDialog.setDlgBoxSizeLimit(dialog, true); btnChange.setTextColor(Color.GREEN); btnFunc.setTextColor(Color.DKGRAY); btnChange.setEnabled(false); btnFunc.setEnabled(true); } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.updetector.MainActivity.java
/** * Handle Performance Tuning Click// w ww. j ava 2 s.co m */ private void handleAdvancedSetting() { final Dialog dialog = new Dialog(this); dialog.setTitle(R.string.menu_item_advanced_settings); dialog.setContentView(R.layout.advanced_setting); final SharedPreferences mPrefs = getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE); final Editor editor = mPrefs.edit(); final ToggleButton classifierForCIVOnButton = (ToggleButton) dialog.findViewById(R.id.civ_classifier_on); classifierForCIVOnButton.setChecked(mPrefs.getBoolean(Constants.PREFERENCE_KEY_CIV_CLASSIFIER_ON, false)); final ToggleButton isOutdoorButton = (ToggleButton) dialog.findViewById(R.id.is_outdoor); isOutdoorButton.setChecked(mPrefs.getBoolean(Constants.PREFERENCE_KEY_IS_OUTDOOR, false)); final EditText notificationTresholdText = (EditText) dialog.findViewById(R.id.notification_threshold); notificationTresholdText .setText(String.format("%.2f", mPrefs.getFloat(Constants.PREFERENCE_KEY_NOTIFICATION_THRESHOLD, (float) Constants.DEFAULT_DETECTION_THRESHOLD))); //final EditText detectionIntervalText=(EditText)dialog.findViewById(R.id.detection_interval); //detectionIntervalText.setText(String.valueOf(mPrefs.getInt(Constants.PREFERENCE_KEY_DETECTION_INTERVAL, Constants.DETECTION_INTERVAL_DEFAULT_VALUE) )); final EditText googleActivityUpdateIntervalText = (EditText) dialog .findViewById(R.id.google_activity_update_interval); googleActivityUpdateIntervalText .setText(String.valueOf(mPrefs.getInt(Constants.PREFERENCE_KEY_GOOGLE_ACTIVITY_UPDATE_INTERVAL, Constants.GOOGLE_ACTIVITY_UPDATE_INTERVAL_DEFAULT_VALUE))); //final ToggleButton useGoogleActivityInFusion=(ToggleButton)dialog.findViewById(R.id.use_google_for_motion_state_in_fusion); //useGoogleActivityInFusion.setChecked(mPrefs.getBoolean(Constants.PREFERENCE_KEY_USE_GOOGLE_ACTIVITY_IN_FUSION, false)); final ToggleButton logAcclRawButton = (ToggleButton) dialog.findViewById(R.id.log_raw_switch); logAcclRawButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_ACCL_RAW_SWITCH, false)); final ToggleButton logGoogleActUpdatesButton = (ToggleButton) dialog .findViewById(R.id.log_google_updates_switch); logGoogleActUpdatesButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_GOOGLE_ACTIVITY_UPDATE, false)); final ToggleButton logDetectionButton = (ToggleButton) dialog.findViewById(R.id.log_report_switch); logDetectionButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_DETECTION_SWITCH, false)); final ToggleButton logErrorButton = (ToggleButton) dialog.findViewById(R.id.log_error_switch); logErrorButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_ERROR_SWITCH, true)); //final EditText deltaForConditionalProb=(EditText)dialog.findViewById(R.id.normal_dist_delta); //deltaForConditionalProb.setText(String.valueOf(mPrefs.getFloat(Constants.CIV_DELTA_CONDITIONAL_PROBABILITY, 2)) ); final Button applyButton = (Button) dialog.findViewById(R.id.performance_apply_button); final Button cancelButton = (Button) dialog.findViewById(R.id.peformance_cancel_button); applyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (classifierForCIVOnButton.isChecked()) editor.putBoolean(Constants.PREFERENCE_KEY_CIV_CLASSIFIER_ON, true); else editor.putBoolean(Constants.PREFERENCE_KEY_CIV_CLASSIFIER_ON, false); if (isOutdoorButton.isChecked()) editor.putBoolean(Constants.PREFERENCE_KEY_IS_OUTDOOR, true); else editor.putBoolean(Constants.PREFERENCE_KEY_IS_OUTDOOR, false); if (logAcclRawButton.isChecked()) editor.putBoolean(Constants.LOGGING_ACCL_RAW_SWITCH, true); else editor.putBoolean(Constants.LOGGING_ACCL_RAW_SWITCH, false); if (logGoogleActUpdatesButton.isChecked()) editor.putBoolean(Constants.LOGGING_GOOGLE_ACTIVITY_UPDATE, true); else editor.putBoolean(Constants.LOGGING_GOOGLE_ACTIVITY_UPDATE, false); if (logDetectionButton.isChecked()) editor.putBoolean(Constants.LOGGING_DETECTION_SWITCH, true); else editor.putBoolean(Constants.LOGGING_DETECTION_SWITCH, false); if (logErrorButton.isChecked()) editor.putBoolean(Constants.LOGGING_ERROR_SWITCH, true); else editor.putBoolean(Constants.LOGGING_ERROR_SWITCH, false); float notificationTreshold; try { notificationTreshold = Float.parseFloat(notificationTresholdText.getText().toString()); } catch (Exception ex) { notificationTreshold = (float) Constants.DEFAULT_DETECTION_THRESHOLD; } editor.putFloat(Constants.PREFERENCE_KEY_NOTIFICATION_THRESHOLD, notificationTreshold); /*int detectionInterval; try{ detectionInterval=Integer.parseInt( detectionIntervalText.getText().toString()); }catch(Exception ex){ detectionInterval=Constants.DETECTION_INTERVAL_DEFAULT_VALUE; } editor.putInt(Constants.PREFERENCE_KEY_DETECTION_INTERVAL, detectionInterval);*/ /*if (useGoogleActivityInFusion.isChecked()) editor.putBoolean(Constants.PREFERENCE_KEY_USE_GOOGLE_ACTIVITY_IN_FUSION, true); else editor.putBoolean(Constants.PREFERENCE_KEY_USE_GOOGLE_ACTIVITY_IN_FUSION, false);*/ int googleActivityUpdateInterval; try { googleActivityUpdateInterval = Integer .parseInt(googleActivityUpdateIntervalText.getText().toString()); } catch (Exception ex) { googleActivityUpdateInterval = Constants.GOOGLE_ACTIVITY_UPDATE_INTERVAL_DEFAULT_VALUE; } editor.putInt(Constants.PREFERENCE_KEY_GOOGLE_ACTIVITY_UPDATE_INTERVAL, googleActivityUpdateInterval); /*try{ Float delta=Float.parseFloat(deltaForConditionalProb.getText().toString()); editor.putFloat(Constants.CIV_DELTA_CONDITIONAL_PROBABILITY, delta); }catch(Exception ex){ Toast.makeText(getApplicationContext(), "Input must be a float number", Toast.LENGTH_SHORT).show(); }*/ editor.commit(); dialog.cancel(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dialog.cancel(); } }); dialog.show(); }
From source file:xj.property.activity.HXBaseActivity.MainActivity.java
/** * ??dialog/*from w w w .j av a 2s . c o m*/ */ private void showConflictDialog() { isConflictDialogShow = true; final UserInfoDetailBean detailBean = PreferencesUtil.getLoginInfo(getApplication()); username = detailBean.getUsername(); password = detailBean.getPassword(); final XJUserInfoBean bean = new XJUserInfoBean(); bean.setInfo(detailBean); if (xjpushManager != null) { xjpushManager.unregisterLoginedPushService(); } else { xjpushManager = new XJPushManager(this); xjpushManager.unregisterLoginedPushService(); } // boolean flag= PushManager.getInstance().unBindAlias(MainActivity.this, PreferencesUtil.getLoginInfo(MainActivity.this).getEmobId()); // Log.i("onion","flag"+flag); XjApplication.getInstance().logout(new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { @Override public void run() { refreshUI(); refreshNewBangBiUI(); } }); } @Override public void onError(int i, String s) { } @Override public void onProgress(int i, String s) { } }); PreferencesUtil.Logout(MainActivity.this); if (!MainActivity.this.isFinishing()) { // clear up global variables try { final Dialog dialog = new Dialog(MainActivity.this, R.style.MyDialogStyle); dialog.setContentView(R.layout.dialog_conflict); TextView tv_cancle = (TextView) dialog.findViewById(R.id.tv_cancle); TextView tv_relogin = (TextView) dialog.findViewById(R.id.tv_relogin); tv_cancle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { conflictBuilder = null; dialog.dismiss(); index = 0; updateUnreadLabel(); startActivity(new Intent(MainActivity.this, MainActivity.class)); // finish(); } }); tv_relogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final ProgressDialog pd = new ProgressDialog(MainActivity.this, ProgressDialog.THEME_HOLO_LIGHT); pd.setCanceledOnTouchOutside(false); pd.setCancelable(false); pd.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); progressShow = true; pd.setMessage("..."); if (pd != null && !MainActivity.this.isFinishing()) pd.show(); //??? // getuser((int) detailBean.getCommunityId(),detailBean.getEmobId()); UserUtils.reLoginUser(MainActivity.this, username, password, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case Config.LoginUserComplete: if (progressShow) pd.dismiss(); dialog.dismiss(); startActivity(new Intent(MainActivity.this, MainActivity.class)); isConflict = false; // boolean flag = PushManager.getInstance().bindAlias(MainActivity.this, PreferencesUtil.getLoginInfo(MainActivity.this).getEmobId()); PushManager.getInstance().turnOnPush(MainActivity.this); if (xjpushManager == null) { xjpushManager = new XJPushManager(getmContext()); } xjpushManager.registerLoginedPushService(); break; case Config.LoginUserFailure: if (progressShow && !MainActivity.this.isFinishing()) { pd.dismiss(); Toast.makeText(MainActivity.this, "?", Toast.LENGTH_SHORT) .show(); } break; default: pd.setMessage(".."); break; } } }); /* UserUtils.loginEMChat(MainActivity.this, username, bean, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case Config.LoginUserComplete: if (progressShow) pd.dismiss(); dialog.dismiss(); UserUtils.appLogin(MainActivity.this,PushManager.getInstance().getClientid(MainActivity.this), PreferencesUtil.getLoginInfo(MainActivity.this).getUsername()); startActivity(new Intent(MainActivity.this, MainActivity.class)); isConflict=false; boolean flag= PushManager.getInstance().bindAlias(MainActivity.this, PreferencesUtil.getLoginInfo(MainActivity.this).getEmobId()); PushManager.getInstance().turnOnPush(MainActivity.this); break; case Config.LoginUserFailure: if (progressShow && !MainActivity.this.isFinishing()) { pd.dismiss(); Toast.makeText(MainActivity.this, "?", Toast.LENGTH_SHORT).show(); } break; default: pd.setMessage(".."); break; } } });*/ } }); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); dialog.setCancelable(false); dialog.show(); isConflict = true; } catch (Exception e) { EMLog.e(TAG, "---------color conflictBuilder error" + e.getMessage()); } } }
From source file:com.example.yudiandrean.socioblood.FeedActivity.java
@SuppressLint("NewApi") @Override//from w w w . j a v a 2s . c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Dialog d = new Dialog(context); setContentView(R.layout.feed_activity); postrequest = (TextView) findViewById(R.id.editText); WindowManager manager = (WindowManager) getSystemService(Activity.WINDOW_SERVICE); final int width, height; ActionBar.LayoutParams params; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { width = manager.getDefaultDisplay().getWidth(); height = manager.getDefaultDisplay().getHeight(); } else { Point point = new Point(); manager.getDefaultDisplay().getSize(point); width = point.x; height = point.y; } session = new SessionManager(getApplicationContext()); // Check if user is already logged in or not if (!session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(FeedActivity.this, LoginActivity.class); startActivity(intent); finish(); } listView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); feedItems = new ArrayList<FeedItem>(); listAdapter = new FeedListAdapter(this, feedItems); listView.setAdapter(listAdapter); swipeRefreshLayout.setOnRefreshListener(this); // add button listener postrequest.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { try { d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.post_request); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(d.getWindow().getAttributes()); lp.width = width; lp.height = height; d.getWindow().setAttributes(lp); } catch (AndroidRuntimeException e) { } catch (Exception e) { } final Spinner rhesusspinner = (Spinner) d.findViewById(R.id.rhesus_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(FeedActivity.this, android.R.layout.simple_spinner_dropdown_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView) v.findViewById(android.R.id.text1)).setText(""); ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount() - 1; // you dont display last item. It is used as hint. } }; adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.add("+"); adapter.add("-"); adapter.add("Rhesus"); rhesusspinner.setAdapter(adapter); rhesusspinner.setSelection(adapter.getCount()); //display hint final Spinner bloodspinner = (Spinner) d.findViewById(R.id.bloodtype_spinner); ArrayAdapter<String> bloodadapter = new ArrayAdapter<String>(FeedActivity.this, android.R.layout.simple_spinner_dropdown_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView) v.findViewById(android.R.id.text1)).setText(""); ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount() - 1; // you dont display last item. It is used as hint. } }; bloodadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bloodadapter.add("O"); bloodadapter.add("A"); bloodadapter.add("B"); bloodadapter.add("AB"); bloodadapter.add("Desired Type"); bloodspinner.setAdapter(bloodadapter); bloodspinner.setSelection(bloodadapter.getCount()); //display hint //Buttons-Editexts Button btnpost = (Button) d.findViewById(R.id.post); final EditText userInput = (EditText) d.findViewById(R.id.editTextDialogUserInput); d.show(); btnpost.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (bloodspinner.getSelectedItem().toString().equals("Desired Type")) { Toast.makeText(getApplicationContext(), "Input Blood Type!", Toast.LENGTH_SHORT).show(); } else if (rhesusspinner.getSelectedItem().toString().equals("Rhesus")) { Toast.makeText(getApplicationContext(), "Input Rhesus!", Toast.LENGTH_SHORT).show(); } else if (userInput.getText().toString().equals("")) { Toast.makeText(getApplicationContext(), "Input your request message!", Toast.LENGTH_SHORT).show(); } else { int uid = session.currentUID(); String message = userInput.getText().toString(); String post_bloodtype = bloodspinner.getSelectedItem().toString(); String post_rhesus = rhesusspinner.getSelectedItem().toString(); NetAsync(d, view, uid, message, post_bloodtype, post_rhesus); } } }); } }); // // We first check for cached request // Cache cache = FeedController.getInstance().getRequestQueue().getCache(); // Entry entry = cache.get(URL_FEED); // if (entry != null) { // // fetch the data from cache // try { // String data = new String(entry.data, "UTF-8"); // try { // parseJsonFeed(new JSONObject(data)); // } catch (JSONException e) { // e.printStackTrace(); // } // } catch (UnsupportedEncodingException e) { // e.printStackTrace(); // } // // } else { // making fresh volley request and getting json /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); getTimelineAsync(); } }); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void renameProfileGroupDlg(final String old_loc) { // ??//w ww .j ava 2 s. c om final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // dialog.getWindow().setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.setContentView(R.layout.single_item_input_dlg); final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title); final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir); // final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg); final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn); final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn); btnOK.setEnabled(false); dlg_title.setText(mContext.getString(R.string.msgs_profile_group_rename_profile_group)); CommonDialog.setDlgBoxSizeCompact(dialog); dlg_et_name.setText(old_loc); dlg_et_name.addTextChangedListener(new TextWatcher() { @Override final public void afterTextChanged(Editable s) { if (s.length() != 0) { // dlg_et_name.selectAll(); String newgrp = dlg_et_name.getText().toString(); if (!newgrp.startsWith("*")) { btnOK.setEnabled(true); for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) { if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) { btnOK.setEnabled(false); break; } } } else btnOK.setEnabled(false); } else btnOK.setEnabled(false); } @Override final public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override final public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override final public void positiveResponse(Context c, Object[] o) { dlg_et_name.selectAll(); String new_loc = dlg_et_name.getText().toString(); renameProfileGroup(true, old_loc, new_loc); } @Override final public void negativeResponse(Context c, Object[] o) { } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { dialog.dismiss(); } }); // OK? btnOK.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { ntfy.notifyToListener(POSITIVE, null); dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void copyProfileGroupDlg(final String old_loc) { // ??/*from w w w . j a va 2 s .c o m*/ final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // dialog.getWindow().setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.setContentView(R.layout.single_item_input_dlg); final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title); final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir); // final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg); final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn); final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn); btnOK.setEnabled(false); dlg_title.setText(mContext.getString(R.string.msgs_profile_group_copy_profile_group)); CommonDialog.setDlgBoxSizeCompact(dialog); dlg_et_name.setText(old_loc); dlg_et_name.addTextChangedListener(new TextWatcher() { @Override final public void afterTextChanged(Editable s) { if (s.length() != 0) { // dlg_et_name.selectAll(); String newgrp = dlg_et_name.getText().toString(); if (!newgrp.startsWith("*")) { btnOK.setEnabled(true); for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) { if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) { btnOK.setEnabled(false); break; } } } else btnOK.setEnabled(false); } else btnOK.setEnabled(false); } @Override final public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override final public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override final public void positiveResponse(Context c, Object[] o) { dlg_et_name.selectAll(); String new_loc = dlg_et_name.getText().toString(); copyProfileGroup(true, old_loc, new_loc); } @Override final public void negativeResponse(Context c, Object[] o) { } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { dialog.dismiss(); } }); // OK? btnOK.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { ntfy.notifyToListener(POSITIVE, null); dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void createNewProfileGroup() { // ??//from w ww . ja v a 2 s . c o m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // dialog.getWindow().setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.setContentView(R.layout.single_item_input_dlg); final TextView dlg_title = (TextView) dialog.findViewById(R.id.single_item_input_title); final EditText dlg_et_name = (EditText) dialog.findViewById(R.id.single_item_input_dir); // final TextView dlg_msg = (TextView) dialog.findViewById(R.id.single_item_input_msg); final Button btnCancel = (Button) dialog.findViewById(R.id.single_item_input_cancel_btn); final Button btnOK = (Button) dialog.findViewById(R.id.single_item_input_ok_btn); btnOK.setEnabled(false); dlg_title.setText(mContext.getString(R.string.msgs_profile_group_create_new_profile_group)); CommonDialog.setDlgBoxSizeCompact(dialog); dlg_et_name.addTextChangedListener(new TextWatcher() { @Override final public void afterTextChanged(Editable s) { if (s.length() != 0) { // dlg_et_name.selectAll(); String newgrp = dlg_et_name.getText().toString(); if (!newgrp.startsWith("*")) { btnOK.setEnabled(true); for (int i = 0; i < mGlblParms.profileGroupAdapter.getCount(); i++) { if (mGlblParms.profileGroupAdapter.getItem(i).getProfileGroupName().equals(newgrp)) { btnOK.setEnabled(false); break; } } } else btnOK.setEnabled(false); } else btnOK.setEnabled(false); } @Override final public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override final public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override final public void positiveResponse(Context c, Object[] o) { dlg_et_name.selectAll(); String newloc = dlg_et_name.getText().toString(); mGlblParms.profileGroupAdapter.add(new ProfileGroupListItem(newloc, false, 0, 0, 0)); mGlblParms.profileGroupAdapter.sort(); mGlblParms.profileGroupAdapter.notifyDataSetChanged(); ProfileListItem tpli = new ProfileListItem(); tpli.setTaskEntry(PROFILE_VERSION_CURRENT, newloc, false, System.currentTimeMillis(), "", mContext.getString(R.string.msgs_no_profile_entry), "", "", "", "", null, null); mGlblParms.profileAdapter.addDataListItem(tpli); mGlblParms.profileAdapter.updateShowList(); setProfileGroupSelectorListener(); } @Override final public void negativeResponse(Context c, Object[] o) { } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { dialog.dismiss(); } }); // OK? btnOK.setOnClickListener(new View.OnClickListener() { final public void onClick(View v) { ntfy.notifyToListener(POSITIVE, null); dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java
final static private void initProfileActionWidget(GlobalParameters mGlblParms, Dialog dialog, ProfileListItem tpli, ArrayList<DataArrayEditListItem> comp_data_list, ArrayList<ActivityExtraDataItem> aed_edit_list, String curr_grp, AdapterProfileList pfla, CustomSpinnerAdapter adapterActionType, CustomSpinnerAdapter adapterActivityName, CustomSpinnerAdapter adapterActivityDataType, CustomSpinnerAdapter adapterRingtoneType, CustomSpinnerAdapter adapterRingtoneName, CustomSpinnerAdapter adapterCompareType, CustomSpinnerAdapter adapterCompareResult, CustomSpinnerAdapter adapterCompareTarget, CustomSpinnerAdapter adapterMessageType, CustomSpinnerAdapter adapterTimeType, CustomSpinnerAdapter adapterTimeTarget, CustomSpinnerAdapter adapterTaskType, CustomSpinnerAdapter adapterTaskTarget, CustomSpinnerAdapter adapterWaitTarget, CustomSpinnerAdapter adapterWaitTimeoutType, CustomSpinnerAdapter adapterWaitTimeoutValue, CustomSpinnerAdapter adapterWaitTimeoutUnits) { final CheckBox cb_active = (CheckBox) dialog.findViewById(R.id.edit_profile_action_enabled); final TextView tv_sound_filename = (TextView) dialog .findViewById(R.id.edit_profile_action_exec_sound_file_name); final CheckBox cb_music_vol = (CheckBox) dialog .findViewById(R.id.edit_profile_action_profile_sound_use_volume); final SeekBar sb_music_vol = (SeekBar) dialog.findViewById(R.id.edit_profile_action_profile_sound_volume); // final Button playBtnMusic = (Button)dialog.findViewById(R.id.edit_profile_action_profile_sound_play_back); // final Button playBtnRingtone = (Button)dialog.findViewById(R.id.edit_profile_action_profile_ringtone_play_back); final CheckBox cb_ringtone_vol = (CheckBox) dialog .findViewById(R.id.edit_profile_action_profile_ringtone_use_volume); final SeekBar sb_ringtone_vol = (SeekBar) dialog .findViewById(R.id.edit_profile_action_profile_ringtone_volume); final Spinner spinnerActionType = (Spinner) dialog.findViewById(R.id.edit_profile_action_action_type); final Spinner spinnerActivityName = (Spinner) dialog .findViewById(R.id.edit_profile_action_exec_activity_name); final Spinner spinnerActivityDataType = (Spinner) dialog .findViewById(R.id.edit_profile_action_exec_activity_data_type); final Spinner spinnerRingtoneType = (Spinner) dialog .findViewById(R.id.edit_profile_action_exec_ringtone_type); final Spinner spinnerRingtoneName = (Spinner) dialog .findViewById(R.id.edit_profile_action_exec_ringtone_name); final Spinner spinnerCompareType = (Spinner) dialog.findViewById(R.id.edit_profile_action_compare_type); final EditText et_comp_value1 = (EditText) dialog.findViewById(R.id.edit_profile_action_compare_value1); final EditText et_comp_value2 = (EditText) dialog.findViewById(R.id.edit_profile_action_compare_value2); final ListView lv_comp_data = (ListView) dialog .findViewById(R.id.edit_profile_action_compare_value_listview); final Spinner spinnerCompareResult = (Spinner) dialog.findViewById(R.id.edit_profile_action_compare_result); final Spinner spinnerCompareTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_compare_target); final Spinner spinnerMessageType = (Spinner) dialog.findViewById(R.id.edit_profile_action_message_type); final EditText et_msg_text = (EditText) dialog.findViewById(R.id.edit_profile_action_message_message); final CheckBox cb_vib_used = (CheckBox) dialog.findViewById(R.id.edit_profile_action_message_vibration); final CheckBox cb_led_used = (CheckBox) dialog.findViewById(R.id.edit_profile_action_message_led); final RadioButton rb_msg_blue = (RadioButton) dialog .findViewById(R.id.edit_profile_action_message_led_blue); final RadioButton rb_msg_red = (RadioButton) dialog.findViewById(R.id.edit_profile_action_message_led_red); final RadioButton rb_msg_green = (RadioButton) dialog .findViewById(R.id.edit_profile_action_message_led_green); final Spinner spinnerTimeType = (Spinner) dialog.findViewById(R.id.edit_profile_action_time_type); final Spinner spinnerTimeTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_time_target); final Spinner spinnerTaskType = (Spinner) dialog.findViewById(R.id.edit_profile_action_task_type); final Spinner spinnerTaskTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_task_target); final Spinner spinnerWaitTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_wait_target); final Spinner spinnerWaitTimeoutType = (Spinner) dialog.findViewById(R.id.edit_profile_action_wait_timeout); final Spinner spinnerWaitTimeoutValue = (Spinner) dialog .findViewById(R.id.edit_profile_action_wait_timeout_value); final Spinner spinnerWaitTimeoutUnits = (Spinner) dialog .findViewById(R.id.edit_profile_action_wait_timeout_units); // final EditText et_bsh_script=(EditText) dialog.findViewById(R.id.edit_profile_action_dlg_bsh_script_text); if (tpli == null || tpli.getActionSoundVolLeft().equals("-1") || tpli.getActionSoundVolLeft().equals("")) { cb_music_vol.setChecked(false);/*from w w w. j a va2 s.c o m*/ sb_music_vol.setProgress(100); sb_music_vol.setEnabled(false); } else { cb_music_vol.setChecked(true); sb_music_vol.setProgress(Integer.valueOf(tpli.getActionSoundVolLeft())); sb_music_vol.setEnabled(true); } if (tpli == null || tpli.getActionRingtoneVolLeft().equals("-1") || tpli.getActionRingtoneVolLeft().equals("")) { cb_ringtone_vol.setChecked(false); sb_ringtone_vol.setProgress(100); sb_ringtone_vol.setEnabled(false); } else { cb_ringtone_vol.setChecked(true); sb_ringtone_vol.setProgress(Integer.valueOf(tpli.getActionRingtoneVolLeft())); sb_ringtone_vol.setEnabled(true); } if (tpli == null || tpli.isProfileEnabled()) cb_active.setChecked(true); else cb_active.setChecked(false); if (tpli != null && tpli.getActionType().equals(PROFILE_ACTION_TYPE_MUSIC)) { if (tpli.getActionSoundFileName().equals("")) tv_sound_filename.setText("Not specified"); else tv_sound_filename.setText(tpli.getActionSoundFileName()); } else tv_sound_filename.setText("Not specified"); if (tpli != null && tpli.getActionCompareValue() != null) { String[] c_data_array = tpli.getActionCompareValue(); for (int i = 0; i < c_data_array.length; i++) { if (c_data_array[i] != null && !c_data_array[i].equals("")) { DataArrayEditListItem daeli = new DataArrayEditListItem(); daeli.data_value = c_data_array[i]; comp_data_list.add(daeli); } } } if (comp_data_list.size() == 0) { DataArrayEditListItem daeli = new DataArrayEditListItem(); daeli.data_value = ""; daeli.dummy_data = true; comp_data_list.add(daeli); } if (tpli != null && tpli.getActionActivityExtraData() != null) { for (int i = 0; i < tpli.getActionActivityExtraData().size(); i++) aed_edit_list.add(tpli.getActionActivityExtraData().get(i).clone()); } String action_type = ""; if (tpli != null) action_type = tpli.getActionType(); adapterActionType.setTextColor(Color.BLACK); setSpinnerActionType(mGlblParms, dialog, spinnerActionType, adapterActionType, action_type); String action_activity_name = ""; if (tpli != null) action_activity_name = tpli.getActionActivityName(); adapterActivityName.setTextColor(Color.BLACK); ProfileMaintenance.setSpinnerActivityName(mGlblParms, dialog, spinnerActivityName, adapterActivityName, action_activity_name); String action_activity_data_type = ""; if (tpli != null) action_activity_data_type = tpli.getActionActivityDataType(); adapterActivityDataType.setTextColor(Color.BLACK); setSpinnerActivityDataType(mGlblParms, dialog, spinnerActivityDataType, adapterActivityDataType, action_activity_data_type); adapterRingtoneType.setTextColor(Color.BLACK); String action_ringtone_type = ""; if (tpli != null) action_ringtone_type = tpli.getActionRingtoneType(); setSpinnerRingtoneType(mGlblParms, dialog, spinnerRingtoneType, adapterRingtoneType, action_ringtone_type); adapterRingtoneName.setTextColor(Color.BLACK); String action_ringtone_name = ""; int action_ringtone_type_int = 0; if (tpli != null) action_ringtone_name = tpli.getActionRingtoneName(); if (tpli != null) action_ringtone_type_int = tpli.getActionRingtoneTypeInt(); ProfileMaintenance.setSpinnerRingtoneName(mGlblParms, dialog, spinnerRingtoneName, adapterRingtoneName, action_ringtone_name, action_ringtone_type_int); adapterCompareType.setTextColor(Color.BLACK); String action_compare_type = ""; if (tpli != null) action_compare_type = tpli.getActionCompareType(); setSpinnerCompareType(mGlblParms, dialog, spinnerCompareType, adapterCompareType, action_compare_type, true, true, true, true, true); lv_comp_data.setAdapter(mGlblParms.actionCompareDataAdapter); adapterCompareResult.setTextColor(Color.BLACK); et_comp_value2.setVisibility(EditText.GONE); String action_compare_result = ""; if (tpli != null && tpli.getActionCompareValue() != null) { action_compare_result = tpli.getActionCompareResultAction(); et_comp_value1.setText(tpli.getActionCompareValue(0)); et_comp_value2.setText(tpli.getActionCompareValue(1)); } else { et_comp_value1.setText(""); et_comp_value2.setText(""); } setSpinnerCompareResult(mGlblParms, dialog, spinnerCompareResult, adapterCompareResult, action_compare_result); adapterCompareTarget.setTextColor(Color.BLACK); String action_compare_target = ""; if (tpli != null) action_compare_target = tpli.getActionCompareTarget(); setSpinnerCompareTarget(mGlblParms, dialog, spinnerCompareTarget, adapterCompareTarget, action_compare_target); setCompareEditTextAttr(mGlblParms, action_compare_target, et_comp_value1, et_comp_value1); adapterMessageType.setTextColor(Color.BLACK); String action_message_type = ""; if (tpli != null) action_message_type = tpli.getActionMessageType(); setSpinnerMessageType(mGlblParms, dialog, spinnerMessageType, adapterMessageType, action_message_type); et_msg_text.setText(""); rb_msg_blue.setChecked(true); cb_vib_used.setChecked(false); cb_led_used.setChecked(false); if (tpli != null) { et_msg_text.setText(tpli.getActionMessageText()); rb_msg_blue.setChecked(true); if (tpli.getActionMessageLedColor().equals(PROFILE_ACTION_TYPE_MESSAGE_LED_RED)) rb_msg_red.setChecked(true); else if (tpli.getActionMessageLedColor().equals(PROFILE_ACTION_TYPE_MESSAGE_LED_GREEN)) rb_msg_green.setChecked(true); cb_vib_used.setChecked(tpli.isActionMessageUseVibration()); cb_led_used.setChecked(tpli.isActionMessageUseLed()); } adapterTimeType.setTextColor(Color.BLACK); String action_time_type = ""; if (tpli != null) action_time_type = tpli.getActionTimeType(); ProfileMaintenance.setSpinnerTimeType(mGlblParms, dialog, spinnerTimeType, adapterTimeType, action_time_type); adapterTimeTarget.setTextColor(Color.BLACK); String action_time_target = ""; if (tpli != null) action_time_target = tpli.getActionTimeTarget(); ProfileMaintenance.setSpinnerTimeTarget(mGlblParms, dialog, spinnerTimeTarget, adapterTimeTarget, pfla, curr_grp, action_time_target); adapterTaskType.setTextColor(Color.BLACK); adapterTaskTarget.setTextColor(Color.BLACK); String action_task_type = ""; if (tpli != null) action_task_type = tpli.getActionTaskType(); ProfileMaintenance.setSpinnerTaskType(mGlblParms, dialog, spinnerTaskType, adapterTaskType, action_task_type); String action_task_target = ""; if (tpli != null) action_task_target = tpli.getActionTaskTarget(); ProfileMaintenance.setSpinnerTaskTarget(mGlblParms, true, dialog, spinnerTaskTarget, adapterTaskTarget, pfla, curr_grp, action_task_target); adapterWaitTarget.setTextColor(Color.BLACK); String action_wait_target = ""; if (tpli != null) action_wait_target = tpli.getActionWaitTarget(); ProfileMaintenance.setSpinnerWaitTarget(mGlblParms, dialog, spinnerWaitTarget, adapterWaitTarget, pfla, curr_grp, action_wait_target); adapterWaitTimeoutType.setTextColor(Color.BLACK); String to_sel = PROFILE_ACTION_TYPE_WAIT_TIMEOUT_TYPE_NOTIMEOUT; if (tpli != null && !tpli.getActionWaitTimeoutValue().equals("")) to_sel = PROFILE_ACTION_TYPE_WAIT_TIMEOUT_TYPE_TIMEOUTIS; ProfileMaintenance.setSpinnerWaitTimeoutType(mGlblParms, dialog, spinnerWaitTimeoutType, adapterWaitTimeoutType, pfla, curr_grp, to_sel); adapterWaitTimeoutValue.setTextColor(Color.BLACK); String action_wait_timeout_value = ""; if (tpli != null) action_wait_timeout_value = tpli.getActionWaitTimeoutValue(); ProfileMaintenance.setSpinnerWaitTimeoutValue(mGlblParms, dialog, spinnerWaitTimeoutValue, adapterWaitTimeoutValue, pfla, curr_grp, action_wait_timeout_value); adapterWaitTimeoutUnits.setTextColor(Color.BLACK); String action_wait_timeout_units = ""; if (tpli != null) action_wait_timeout_units = tpli.getActionWaitTimeoutUnits(); ProfileMaintenance.setSpinnerWaitTimeoutUnits(mGlblParms, dialog, spinnerWaitTimeoutUnits, adapterWaitTimeoutUnits, pfla, curr_grp, action_wait_timeout_units); // CommonDialog.setDlgBoxSizeLimit(dialog,true); }
From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java
@Override protected Dialog onCreateDialog(int id) { final Dialog dialog; ProgressDialog pdialog;//from w w w . ja v a 2 s .c o m AlertDialog.Builder builder; LayoutInflater inflater; switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, false) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_COMMENT_CLICK: dialog = new CommentClickDialog(this, mSettings); 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() { @Override public void onClick(View v) { if (mReplyTargetName != null) { new CommentReplyTask(mReplyTargetName).execute(replyBody.getText().toString()); dialog.dismiss(); } else { Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT, CommentsListActivity.this); } } }); replyCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mVoteTargetThing.setReplyDraft(replyBody.getText().toString()); dialog.cancel(); } }); dialog.setCancelable(false); // disallow the BACK key dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { replyBody.setText(""); } }); break; } case Constants.DIALOG_EDIT: { 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); replyBody.setText(mEditTargetBody); replySaveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (mReplyTargetName != null) { new EditTask(mReplyTargetName).execute(replyBody.getText().toString()); dialog.dismiss(); } else { Common.showErrorToast("Error editing. Please try again.", Toast.LENGTH_SHORT, CommentsListActivity.this); } } }); replyCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { dialog.cancel(); } }); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { replyBody.setText(""); } }); break; } case Constants.DIALOG_DELETE: builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme())); builder.setTitle("Really delete this?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { removeDialog(Constants.DIALOG_DELETE); new DeleteTask(mDeleteTargetKind).execute(mReplyTargetName); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); dialog = builder.create(); break; case Constants.DIALOG_SORT_BY: builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme())); builder.setTitle("Sort by:"); int selectedSortBy = -1; for (int i = 0; i < Constants.CommentsSort.SORT_BY_URL_CHOICES.length; i++) { if (Constants.CommentsSort.SORT_BY_URL_CHOICES[i].equals(mSettings.getCommentsSortByUrl())) { selectedSortBy = i; break; } } builder.setSingleChoiceItems(Constants.CommentsSort.SORT_BY_CHOICES, selectedSortBy, sortByOnClickListener); dialog = builder.create(); break; case Constants.DIALOG_REPORT: builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme())); builder.setTitle("Really report this?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { removeDialog(Constants.DIALOG_REPORT); new ReportTask(mReportTargetName.toString()).execute(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); dialog = builder.create(); break; // "Please wait" case Constants.DIALOG_DELETING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Deleting..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_EDITING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Submitting edit..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; 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; case Constants.DIALOG_FIND: inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View content = inflater.inflate(R.layout.dialog_find, null); final EditText find_box = (EditText) content.findViewById(R.id.input_find_box); // final CheckBox wrap_box = (CheckBox) content.findViewById(R.id.find_wrap_checkbox); builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme())); builder.setView(content); builder.setTitle(R.string.find).setPositiveButton(R.string.find, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String search_text = find_box.getText().toString().toLowerCase(); // findCommentText(search_text, wrap_box.isChecked(), false); findCommentText(search_text, true, false); } }).setNegativeButton("Cancel", null); dialog = builder.create(); break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }