List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:com.microsoft.windowsazure.mobileservices.zumoe2etestapp.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(this, ZumoPreferenceActivity.class)); return true; case R.id.menu_run_tests: if (getMobileServiceKey().trim() == "" || getMobileServiceURL().trim() == "") { startActivity(new Intent(this, ZumoPreferenceActivity.class)); } else {//from w w w . java 2 s .c om runTests(); } return true; case R.id.menu_check_all: changeCheckAllTests(true); return true; case R.id.menu_uncheck_all: changeCheckAllTests(false); return true; case R.id.menu_reset: refreshTestGroupsAndLog(); return true; case R.id.menu_view_log: AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this); logDialogBuilder.setTitle("Log"); final WebView webView = new WebView(this); String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />"); String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>"; webView.loadData(logHtml, "text/html", "utf-8"); logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboardManager.setText(mLog.toString()); } }); logDialogBuilder.setView(webView); logDialogBuilder.create().show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java
private Dialog assignConfirmDialog(final Context context, String str, boolean startNewWeek) { LayoutInflater inflater = LayoutInflater.from(context); final View textEntryView = inflater.inflate(R.layout.remove_id, null); final CheckBox rm_check = (CheckBox) textEntryView.findViewById(R.id.rm_local); rm_check.setText(R.string.assign_new_week); AlertDialog.Builder builder = new AlertDialog.Builder(context); if (startNewWeek) { builder.setView(textEntryView);/*from www. j a va 2s. co m*/ } builder.setCancelable(false); builder.setTitle(R.string.assign_confirm_title); builder.setMessage(str); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { editor.putString(Util.SP_LOGIN_KEY_USERID, asID.getText().toString()); Log.d("here!!!", "id is " + asID.getText().toString()); //format check editor.putString(Util.SP_LOGIN_KEY_USERPWD, ""); editor.putString(Util.SP_LOGIN_KEY_STUDY_STARTTIME, "" + Calendar.getInstance().getTimeInMillis()); editor.commit(); //start new study week, if checked if (rm_check.isChecked()) { String UID = null; try { UID = Util.encryption(context, asID.getText().toString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } ChangeStudyWeek changeStudyWeek = new ChangeStudyWeek(); changeStudyWeek.execute(UID); } setHints(); //continue with set user pin (8) setResult(Activity.RESULT_OK); finish(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub setHints(); } }); return builder.create(); }
From source file:com.github.socialc0de.gsw.android.MainActivity.java
/** * Handles the results from activities launched to select an account and to install Google Play * Services./*from w w w . jav a 2 s . c om*/ */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_ACCOUNT_PICKER: if (data != null && data.getExtras() != null) { String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { onSignedIn(accountName); } } else if (!SIGN_IN_REQUIRED) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.are_you_sure); alert.setMessage(R.string.not_all_features); alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startMainActivity(); } }); alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); } }); alert.show(); } break; case REQUEST_GOOGLE_PLAY_SERVICES: if (resultCode != Activity.RESULT_OK) { checkGooglePlayServicesAvailable(); } break; } if (requestCode == REQUEST_CODE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION); if (confirm != null) { try { Log.i(TAG, confirm.toJSONObject().toString(4)); Log.i(TAG, confirm.getPayment().toJSONObject().toString(4)); /** * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e(TAG, "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG, "The user canceled."); } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) { Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { if (resultCode == Activity.RESULT_OK) { PayPalAuthorization auth = data .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION); if (auth != null) { try { Log.i("FuturePaymentExample", auth.toJSONObject().toString(4)); String authorization_code = auth.getAuthorizationCode(); Log.i("FuturePaymentExample", authorization_code); Toast.makeText(getApplicationContext(), "Future Payment code received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i("FuturePaymentExample", "The user canceled."); } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { Log.i("FuturePaymentExample", "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { if (resultCode == Activity.RESULT_OK) { PayPalAuthorization auth = data .getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION); if (auth != null) { try { Log.i("ProfileSharingExample", auth.toJSONObject().toString(4)); String authorization_code = auth.getAuthorizationCode(); Log.i("ProfileSharingExample", authorization_code); Toast.makeText(getApplicationContext(), "Profile Sharing code received from PayPal", Toast.LENGTH_LONG).show(); } catch (JSONException e) { Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i("ProfileSharingExample", "The user canceled."); } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) { Log.i("ProfileSharingExample", "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } }
From source file:pl.bcichecki.rms.client.android.activities.LoginActivity.java
protected void performLogin() { Log.d(TAG, "Performing login... [username=" + username + ", password=" + password + "]"); profileRestClient = new ProfileRestClient(CONTEXT, username, password, SharedPreferencesWrapper.getServerRealm(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); profileRestClient.getProfile(new GsonHttpResponseHandler<User>(new TypeToken<User>() { }.getType(), true) {/*w w w . jav a2s . c om*/ @Override public void onFailure(Throwable error, String content) { Log.d(TAG, "Getting profile failed! [error=" + error + ", content=" + content + "]"); AlertDialog.Builder errorDialog = new AlertDialog.Builder(CONTEXT); errorDialog.setIcon(android.R.drawable.ic_dialog_alert); if (error instanceof HttpResponseException) { if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { errorDialog.setTitle(R.string.activity_login_unsuccessful_login_message_title); errorDialog.setMessage(R.string.activity_login_unsuccessful_login_message_content); } else { errorDialog.setTitle(R.string.general_unknown_error_message_title); errorDialog .setMessage(String.format(getString(R.string.general_unknown_error_message_content), (HttpResponseException) error)); } } else { errorDialog.setTitle(R.string.general_unknown_error_message_title); errorDialog.setMessage( String.format(getString(R.string.general_unknown_error_message_content), error)); } errorDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = errorDialog.show(); TextView messageText = (TextView) dialog.findViewById(android.R.id.message); messageText.setGravity(Gravity.CENTER); } @Override public void onFinish() { showProgress(false); Log.d(TAG, "Getting profile finished."); } @Override public void onStart() { Log.d(TAG, "Getting profile started."); showProgress(true); } @Override public void onSuccess(int statusCode, User user) { Log.d(TAG, "Success [statusCode=" + statusCode + ", jsonObject=" + user.toString() + "]"); UserProfileHolder.setUserProfile(user); UserProfileHolder.setUsername(username); UserProfileHolder.setPassword(password); AppUtils.showCenteredToast(CONTEXT, R.string.activity_login_login_successful, Toast.LENGTH_SHORT); Intent mainActivityIntent = new Intent(CONTEXT, MainActivity.class); startActivity(mainActivityIntent); } }); }
From source file:com.spoiledmilk.ibikecph.map.MapActivity.java
private void launchLoginDialog() { if (loginDlg == null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(IbikeApplication.getString("login")); builder.setMessage(IbikeApplication.getString("error_not_logged_in")); builder.setPositiveButton(IbikeApplication.getString("login"), new DialogInterface.OnClickListener() { @Override//from w w w. ja v a 2 s . c om public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(MapActivity.this, LoginActivity.class); startActivity(i); } }); builder.setNegativeButton(IbikeApplication.getString("close"), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); loginDlg = builder.create(); } loginDlg.show(); }
From source file:net.fred.feedex.activity.EditFeedActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish();/*from w w w. java 2 s. co m*/ return true; case R.id.menu_validate: // only in insert mode final String name = mNameEditText.getText().toString().trim(); final String urlOrSearch = mUrlEditText.getText().toString().trim(); if (urlOrSearch.isEmpty()) { UiUtils.showMessage(EditFeedActivity.this, R.string.error_feed_error); } if (!urlOrSearch.contains(".") || !urlOrSearch.contains("/") || urlOrSearch.contains(" ")) { final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this); pd.setMessage(getString(R.string.loading)); pd.setCancelable(true); pd.setIndeterminate(true); pd.show(); getLoaderManager().restartLoader(1, null, new LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() { @Override public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) { String encodedSearchText = urlOrSearch; try { encodedSearchText = URLEncoder.encode(urlOrSearch, Constants.UTF8); } catch (UnsupportedEncodingException ignored) { } return new GetFeedSearchResultsLoader(EditFeedActivity.this, encodedSearchText); } @Override public void onLoadFinished(Loader<ArrayList<HashMap<String, String>>> loader, final ArrayList<HashMap<String, String>> data) { pd.cancel(); if (data == null) { UiUtils.showMessage(EditFeedActivity.this, R.string.error); } else if (data.isEmpty()) { UiUtils.showMessage(EditFeedActivity.this, R.string.no_result); } else { AlertDialog.Builder builder = new AlertDialog.Builder(EditFeedActivity.this); builder.setTitle(R.string.feed_search); // create the grid item mapping String[] from = new String[] { FEED_SEARCH_TITLE, FEED_SEARCH_DESC }; int[] to = new int[] { android.R.id.text1, android.R.id.text2 }; // fill in the grid_item layout SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this, data, R.layout.item_search_result, from, to); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { FeedDataContentProvider.addFeed(EditFeedActivity.this, data.get(which).get(FEED_SEARCH_URL), name.isEmpty() ? data.get(which).get(FEED_SEARCH_TITLE) : name, mRetrieveFulltextCb.isChecked()); setResult(RESULT_OK); finish(); } }); builder.show(); } } @Override public void onLoaderReset(Loader<ArrayList<HashMap<String, String>>> loader) { } }); } else { FeedDataContentProvider.addFeed(EditFeedActivity.this, urlOrSearch, name, mRetrieveFulltextCb.isChecked()); setResult(RESULT_OK); finish(); } return true; case R.id.menu_add_filter: { final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null); new AlertDialog.Builder(this) // .setTitle(R.string.filter_add_title) // .setView(dialogView) // .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText() .toString(); if (filterText.length() != 0) { String feedId = getIntent().getData().getLastPathSegment(); ContentValues values = new ContentValues(); values.put(FilterColumns.FILTER_TEXT, filterText); values.put(FilterColumns.IS_REGEX, ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked()); values.put(FilterColumns.IS_APPLIED_TO_TITLE, ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked()); values.put(FilterColumns.IS_ACCEPT_RULE, ((RadioButton) dialogView.findViewById(R.id.acceptRadio)).isChecked()); ContentResolver cr = getContentResolver(); cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }).show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android prompt dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The following results are returned to the JavaScript callback identified by callbackId: * buttonIndex Index number of the button selected * input1 The text entered in the prompt dialog box * * @param message The message the dialog should display * @param title The title of the dialog * @param buttonLabels A comma separated list of button labels (Up to 3 buttons) * @param callbackContext The callback context. *///from w w w . j a v a2 s . c o m public synchronized void prompt(final String message, final String title, final JSONArray buttonLabels, final String defaultText, final String dialogType, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { final EditText promptInput = new EditText(cordova.getActivity()); promptInput.setHint(defaultText); Log.d("DialogPlugin", dialogType); if (dialogType.equals(INPUT_SECURE)) { promptInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setView(promptInput); final JSONObject result = new JSONObject(); // First button if (buttonLabels.length() > 0) { try { dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 1); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Second button if (buttonLabels.length() > 1) { try { dlg.setNeutralButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 2); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } // Third button if (buttonLabels.length() > 2) { try { dlg.setPositiveButton(buttonLabels.getString(2), new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); try { result.put("buttonIndex", 3); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); } catch (JSONException e) { } } dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); try { result.put("buttonIndex", 0); result.put("input1", promptInput.getText().toString().trim().length() == 0 ? defaultText : promptInput.getText()); } catch (JSONException e) { e.printStackTrace(); } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.mobicage.rogerthat.plugins.messaging.AttachmentViewerActivity.java
@SuppressLint({ "SetJavaScriptEnabled" }) protected void updateView(boolean isUpdate) { T.UI();/*w ww. j a v a 2s . co m*/ if (!isUpdate && mGenerateThumbnail) { File thumbnail = new File(mFile.getAbsolutePath() + ".thumb"); if (!thumbnail.exists()) { boolean isImage = mContentType.toLowerCase(Locale.US).startsWith("image/"); boolean isVideo = !isImage && mContentType.toLowerCase(Locale.US).startsWith("video/"); try { // Try to generate a thumbnail mMessagingPlugin.createAttachmentThumbnail(mFile.getAbsolutePath(), isImage, isVideo); } catch (Exception e) { L.e("Failed to generate attachment thumbnail", e); } } } final String fileOnDisk = "file://" + mFile.getAbsolutePath(); if (mContentType.toLowerCase(Locale.US).startsWith("video/")) { MediaController mediacontroller = new MediaController(this); mediacontroller.setAnchorView(mVideoview); Uri video = Uri.parse(fileOnDisk); mVideoview.setMediaController(mediacontroller); mVideoview.setVideoURI(video); mVideoview.requestFocus(); mVideoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mVideoview.start(); } }); mVideoview.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override public boolean onError(MediaPlayer mp, int what, int extra) { L.e("Could not play video, what " + what + ", extra " + extra + ", content_type " + mContentType + ", and url " + mDownloadUrl); AlertDialog.Builder builder = new AlertDialog.Builder(AttachmentViewerActivity.this); builder.setMessage(R.string.error_please_try_again); builder.setCancelable(true); builder.setTitle(null); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { dialog.dismiss(); finish(); } }); builder.setPositiveButton(R.string.rogerthat, new SafeDialogInterfaceOnClickListener() { @Override public void safeOnClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); builder.create().show(); return true; } }); } else if (CONTENT_TYPE_PDF.equalsIgnoreCase(mContentType)) { WebSettings settings = mWebview.getSettings(); settings.setJavaScriptEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { settings.setAllowUniversalAccessFromFileURLs(true); } mWebview.setWebViewClient(new WebViewClient() { @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { if (fileOnDisk.equals(url)) { return null; } L.d("404: Expected: '" + fileOnDisk + "'\n Received: '" + url + "'"); return new WebResourceResponse("text/plain", "UTF-8", null); } }); try { mWebview.loadUrl("file:///android_asset/pdfjs/web/viewer.html?file=" + URLEncoder.encode(fileOnDisk, "UTF-8")); } catch (UnsupportedEncodingException uee) { L.bug(uee); } } else { WebSettings settings = mWebview.getSettings(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { settings.setAllowFileAccessFromFileURLs(true); } settings.setBuiltInZoomControls(true); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); if (mContentType.toLowerCase(Locale.US).startsWith("image/")) { String html = "<html><head></head><body><img style=\"width: 100%;\" src=\"" + fileOnDisk + "\"></body></html>"; mWebview.loadDataWithBaseURL("", html, "text/html", "utf-8", ""); } else { mWebview.loadUrl(fileOnDisk); } } L.d("File on disk: " + fileOnDisk); }
From source file:mp.paschalis.WatchBookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (App) getApplication();// w w w . j a v a 2 s . co m setContentView(R.layout.activity_watch_book); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get arguments, to determine who opened this activity final Bundle extras = getIntent().getExtras(); try { isAvailable = extras.getBoolean(App.ExtrasForWatchBookActivityFromBookSearch); } catch (Exception e) { isAvailable = false; } // Set the layout's data // Get layout's Data bookISBN = (TextView) findViewById(R.id.textViewBookISBN); bookTitle = (TextView) findViewById(R.id.textViewBookTitle); bookAuthors = (TextView) findViewById(R.id.textViewBookAuthors); bookPublishedYear = (TextView) findViewById(R.id.textViewBookPublishedYear); bookPageCount = (TextView) findViewById(R.id.textViewBookPageCount); bookDateOfInsert = (TextView) findViewById(R.id.textViewBookDateOfInsert); bookCoverImage = (ImageView) findViewById(R.id.imageViewBookCover); bookLanguage = (TextView) findViewById(R.id.textViewBookLanguage); textViewWatchBookAvailable = (TextView) findViewById(R.id.textViewWatchBookAvailable); buttonRequestBook = (Button) findViewById(R.id.buttonRequestBook); buttonSendMessage = (Button) findViewById(R.id.buttonSendMessage); progressBarSendMessage = (ProgressBar) findViewById(R.id.progressBarSendMessage); buttonSendMessage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final DataClassRequestABook dataClassRequestABook = new DataClassRequestABook(); dataClassRequestABook.username = app.user.username; dataClassRequestABook.isbn = app.selectedBook.isbn; ArrayList<String> userWhoLent = new ArrayList<String>(); // Find all users who lent this book for (Book.DataClassUser u : app.selectedBook.owners) { if (u.status == 0) { userWhoLent.add(u.username); } } final CharSequence[] owners = userWhoLent.toArray(new CharSequence[userWhoLent.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(WatchBookActivity.this); builder.setTitle(R.string.msgPickBookOwner_); builder.setItems(owners, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dataClassRequestABook.owner = (String) owners[item]; // Send message to owner Intent intent = new Intent(WatchBookActivity.this, SendMessageActivity.class); intent.putExtra(App.ExtrasForSendMessage_DestinationUser, dataClassRequestABook.owner); startActivity(intent); } }); AlertDialog alert = builder.create(); alert.show(); } }); if (!isAvailable) { textViewWatchBookAvailable.setText(R.string.no); App.setStyleErrorDirection(textViewWatchBookAvailable); buttonRequestBook.setEnabled(false); } else { textViewWatchBookAvailable.setText(R.string.yes); App.setStyleSuccessDirection(textViewWatchBookAvailable); // Requests a book buttonRequestBook.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { final DataClassRequestABook dataClassRequestABook = new DataClassRequestABook(); dataClassRequestABook.username = app.user.username; dataClassRequestABook.isbn = app.selectedBook.isbn; ArrayList<String> userWhoLent = new ArrayList<String>(); // Find all users who lent this book for (Book.DataClassUser u : app.selectedBook.owners) { if (u.status == 0) { userWhoLent.add(u.username); } } final CharSequence[] owners = userWhoLent.toArray(new CharSequence[userWhoLent.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(WatchBookActivity.this); builder.setTitle(R.string.msgPickBookOwner_); builder.setItems(owners, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dataClassRequestABook.owner = (String) owners[item]; // Request the book new AsyncTaskRequestABook().execute(dataClassRequestABook); } }); AlertDialog alert = builder.create(); alert.show(); } } });// End of Req Button! } TextView tvnc = (TextView) findViewById(R.id.textViewNoCover); ProgressBar pb = (ProgressBar) findViewById(R.id.progressBarLoadCover); // show The Image and save it to Library ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover(); bk.iv = bookCoverImage; bk.isCover = true; bk.tv = tvnc; bk.pb = pb; bk.book = app.selectedBook; App.imageLoader.DisplayCover(bk); bitmapBookCover = ((BitmapDrawable) bookCoverImage.getDrawable()).getBitmap(); // new DownloadImageTask(bookCoverImage, bookInfo) // .execute(bookInfo.imgURL); // Assign the appropriate data from our alert object above bookISBN.setText(app.selectedBook.isbn); bookTitle.setText(app.selectedBook.title); bookAuthors.setText(app.selectedBook.authors); bookPublishedYear.setText(Integer.valueOf(app.selectedBook.publishedYear).toString()); bookPageCount.setText(Integer.valueOf(app.selectedBook.pageCount).toString()); bookDateOfInsert .setText(App.makeTimeStampHumanReadble(getApplicationContext(), app.selectedBook.dateOfInsert)); bookLanguage.setText(app.selectedBook.lang); progressBarRequestBook = (ProgressBar) findViewById(R.id.progressBarRequestBook); buttonRequestBook = (Button) findViewById(R.id.buttonRequestBook); }
From source file:net.evecom.android.log.DailyLogLookActivity.java
/** * //ww w. jav a 2s . com */ private String submit() { /** */ if (btEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (gzsjButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (rzlxButton.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (rznrEditText.getText().toString().trim().length() < 1) { DialogToast(""); return ""; } else if (years > calendar.get(Calendar.YEAR)) { DialogToast(""); return ""; } else if (years == calendar.get(Calendar.YEAR)) { if (month > calendar.get(Calendar.MONTH) + 1) { DialogToast(""); return ""; } else if (month == calendar.get(Calendar.MONTH) + 1) { if (day > calendar.get(Calendar.DAY_OF_MONTH)) { DialogToast(""); return ""; } } } final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogLookActivity.this); builder.setTitle(""); builder.setIcon(R.drawable.qq_dialog_default_icon);// builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { progressDialog = ProgressDialog.show(DailyLogLookActivity.this, "", "..."); formSubmit(); } }); builder.setNegativeButton("", new DialogInterface.OnClickListener() { // @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); return "1"; }