List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:dentex.youtube.downloader.DashboardActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BugSenseHandler.leaveBreadcrumb("DashboardActivity_onCreate"); //Utils.logger("v", "TotalRxBeforeTest: " + TotalRxBeforeTest, DEBUG_TAG); // Theme init Utils.themeInit(this); setContentView(R.layout.activity_dashboard); // Language init Utils.langInit(this); // Detect screen orientation int or = this.getResources().getConfiguration().orientation; isLandscape = (or == 2) ? true : false; sDashboard = DashboardActivity.this; if (da != null) { clearAdapterAndLists();/*from w ww .ja v a2s .c o m*/ } countdown = 10; parseJson(this); updateProgressBars(); buildList(); lv = (ListView) findViewById(R.id.dashboard_list); da = new DashboardAdapter(itemsList, this); if (da.isEmpty()) { showEmptyListInfo(this); } else { lv.setAdapter(da); } /*Log.i(DEBUG_TAG, "ADML Maps:" + "\ndtMap: " + Maps.dtMap + "\nmDownloadPercentMap: " + Maps.mDownloadPercentMap + "\nmDownloadSizeMap: " + Maps.mDownloadSizeMap + "\nmTotalSizeMap: " + Maps.mTotalSizeMap);*/ lv.setTextFilterEnabled(true); lv.setClickable(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!isAnyAsyncInProgress) { currentItem = da.getItem(position); // in order to refer to the filtered item newClick = true; final boolean ffmpegEnabled = YTD.settings.getBoolean("enable_advanced_features", false); AlertDialog.Builder builder = new AlertDialog.Builder(boxThemeContextWrapper); builder.setTitle(currentItem.getFilename()); if (currentItem.getStatus().equals(getString(R.string.json_status_completed)) || currentItem.getStatus().equals(getString(R.string.json_status_imported))) { final boolean audioIsSupported = !currentItem.getAudioExt().equals("unsupported"); final File in = new File(currentItem.getPath(), currentItem.getFilename()); if (currentItem.getType().equals(YTD.JSON_DATA_TYPE_V)) { // handle click on a **VIDEO** file entry builder.setItems(R.array.dashboard_click_entries, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: // open BugSenseHandler.leaveBreadcrumb("video_open"); Intent openIntent = new Intent(Intent.ACTION_VIEW); openIntent.setDataAndType(Uri.fromFile(in), "video/*"); startActivity(Intent.createChooser(openIntent, getString(R.string.open_chooser_title))); break; case 1: // extract audio only if (!isFfmpegRunning) { BugSenseHandler.leaveBreadcrumb("video_ffmpeg_extract"); if (audioIsSupported) { if (ffmpegEnabled) { AlertDialog.Builder builder0 = new AlertDialog.Builder( boxThemeContextWrapper); LayoutInflater inflater0 = getLayoutInflater(); final View view0 = inflater0 .inflate(R.layout.dialog_audio_extr_only, null); String type = null; if (currentItem.getAudioExt().equals(".aac")) type = aac; if (currentItem.getAudioExt().equals(".ogg")) type = ogg; if (currentItem.getAudioExt().equals(".mp3")) type = mp3; //if (currentItem.getAudioExt().equals(".auto")) type = aac_mp3; TextView info = (TextView) view0 .findViewById(R.id.audio_extr_info); info.setText(getString(R.string.audio_extr_info) + "\n\n" + type); builder0.setView(view0).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { CheckBox cb0 = (CheckBox) view0 .findViewById(R.id.rem_video_0); removeVideo = cb0.isChecked(); Utils.logger("v", "Launching FFmpeg on: " + in + "\n-> mode: extraction only" + "\n-> remove video: " + removeVideo, DEBUG_TAG); ffmpegJob(in, null, null); } }).setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int id) { // cancel } }); secureShowDialog(builder0); } else { notifyFfmpegNotInstalled(); } } else { notifyOpsNotSupported(); } } else { notifyFfmpegIsAlreadyRunning(); } break; case 2: // extract audio and convert to mp3 if (!isFfmpegRunning) { BugSenseHandler.leaveBreadcrumb("video_ffmpeg_mp3"); if (audioIsSupported) { if (ffmpegEnabled) { AlertDialog.Builder builder1 = new AlertDialog.Builder( boxThemeContextWrapper); LayoutInflater inflater1 = getLayoutInflater(); final View view1 = inflater1.inflate( R.layout.dialog_audio_extr_mp3_conv, null); builder1.setView(view1).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { final Spinner sp = (Spinner) view1 .findViewById(R.id.mp3_spinner); String[] bitrateData = retrieveBitrateValueFromSpinner( sp); CheckBox cb1 = (CheckBox) view1 .findViewById(R.id.rem_video_1); removeVideo = cb1.isChecked(); Utils.logger("v", "Launching FFmpeg on: " + in + "\n-> mode: conversion to mp3 from video file" + "\n-> remove video: " + removeVideo, DEBUG_TAG); ffmpegJob(in, bitrateData[0], bitrateData[1]); } }).setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int id) { // } }); secureShowDialog(builder1); } else { notifyFfmpegNotInstalled(); } } else { notifyOpsNotSupported(); } } else { notifyFfmpegIsAlreadyRunning(); } } } }); secureShowDialog(builder); } else if (currentItem.getType().equals(YTD.JSON_DATA_TYPE_A_E) || currentItem.getType().equals(YTD.JSON_DATA_TYPE_A_M)) { // handle click on a **AUDIO** file entry builder.setItems(R.array.dashboard_click_entries_audio, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: // open BugSenseHandler.leaveBreadcrumb("audio_open"); Intent openIntent = new Intent(Intent.ACTION_VIEW); openIntent.setDataAndType(Uri.fromFile(in), "audio/*"); startActivity(Intent.createChooser(openIntent, getString(R.string.open_chooser_title))); break; case 1: // convert to mp3 if (!isFfmpegRunning) { if (ffmpegEnabled) { BugSenseHandler.leaveBreadcrumb("audio_ffmpeg_mp3"); AlertDialog.Builder builder0 = new AlertDialog.Builder( boxThemeContextWrapper); LayoutInflater inflater0 = getLayoutInflater(); final View view2 = inflater0 .inflate(R.layout.dialog_audio_mp3_conv, null); builder0.setView(view2).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { final Spinner sp = (Spinner) view2 .findViewById(R.id.mp3_spinner_a); String[] bitrateData = retrieveBitrateValueFromSpinner( sp); CheckBox cb2 = (CheckBox) view2 .findViewById( R.id.rem_original_audio); removeAudio = cb2.isChecked(); Utils.logger("v", "Launching FFmpeg on: " + in + "\n-> mode: conversion to mp3 from audio file" + "\n-> remove audio: " + removeAudio, DEBUG_TAG); ffmpegJob(in, bitrateData[0], bitrateData[1]); } }).setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick( DialogInterface dialog, int id) { // } }); secureShowDialog(builder0); } else { notifyFfmpegNotInstalled(); } } else { notifyFfmpegIsAlreadyRunning(); } } } }); secureShowDialog(builder); } } /*else if (currentItem.getStatus().equals(getString(R.string.json_status_imported))) { Utils.logger("v", "IMPORTED video clicked", DEBUG_TAG); // handle click on an **IMPORTED VIDEO** entry builder.setItems(R.array.dashboard_click_entries_imported, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { final File in = new File (currentItem.getPath(), currentItem.getFilename()); switch (which) { case 0: // open Intent openIntent = new Intent(Intent.ACTION_VIEW); openIntent.setDataAndType(Uri.fromFile(in), "video/*"); startActivity(Intent.createChooser(openIntent, getString(R.string.open_chooser_title))); break; } } }); secureShowDialog(builder); }*/ } } }); lv.setLongClickable(true); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { if (!isAnyAsyncInProgress) { currentItem = da.getItem(position); // in order to refer to the filtered item int COPY = 0; int MOVE = 1; int RENAME = 2; int REDOWNLOAD = 3; int REMOVE = 4; int DELETE = 5; int PAUSERESUME = 6; int[] disabledItems = null; if (currentItem.getStatus().equals(getString(R.string.json_status_in_progress)) || currentItem.getStatus().equals(getString(R.string.json_status_paused))) { // show: DELETE and PAUSERESUME disabledItems = new int[] { COPY, MOVE, RENAME, REDOWNLOAD, REMOVE }; } else if (currentItem.getStatus().equals(getString(R.string.json_status_failed))) { // check if the item has a real YouTube ID, otherwise it's an imported video. if (currentItem.getYtId().length() == 11) { // show: REMOVE and REDOWNLOAD disabledItems = new int[] { COPY, MOVE, RENAME, DELETE, PAUSERESUME }; } else { // show: REMOVE only disabledItems = new int[] { COPY, MOVE, RENAME, REDOWNLOAD, DELETE, PAUSERESUME }; } } else if (currentItem.getStatus().equals(getString(R.string.json_status_imported)) || //case for audio entries _completed but from _imported (currentItem.getStatus().equals(getString(R.string.json_status_completed)) && !(currentItem.getYtId().length() == 11))) { // show: COPY, MOVE, RENAME, REMOVE and DELETE disabledItems = new int[] { REDOWNLOAD, PAUSERESUME }; } else if (currentItem.getStatus().equals(getString(R.string.json_status_completed))) { // show: all items except PAUSERESUME disabledItems = new int[] { PAUSERESUME }; } AlertDialog.Builder builder = new AlertDialog.Builder(boxThemeContextWrapper); builder.setTitle(currentItem.getFilename()); final ArrayAdapter<CharSequence> cla = DashboardLongClickAdapter.createFromResource( boxThemeContextWrapper, R.array.dashboard_long_click_entries, android.R.layout.simple_list_item_1, disabledItems); builder.setAdapter(cla, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: BugSenseHandler.leaveBreadcrumb("copy"); copy(currentItem); break; case 1: BugSenseHandler.leaveBreadcrumb("move"); move(currentItem); break; case 2: BugSenseHandler.leaveBreadcrumb("rename"); rename(currentItem); break; case 3: if (currentItem.getStatus().equals(getString(R.string.json_status_failed))) { BugSenseHandler.leaveBreadcrumb("reDownload_RESTART"); reDownload(currentItem, "RESTART"); } else { BugSenseHandler.leaveBreadcrumb("reDownload"); reDownload(currentItem, "-"); } break; case 4: BugSenseHandler.leaveBreadcrumb("removeFromDashboard"); removeFromDashboard(currentItem); break; case 5: BugSenseHandler.leaveBreadcrumb("delete"); delete(currentItem); break; case 6: BugSenseHandler.leaveBreadcrumb("pauseresume"); pauseresume(currentItem); } } }); secureShowDialog(builder); } return true; } }); }
From source file:com.rsltc.profiledata.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button loginButton = (Button) findViewById(R.id.button); loginButton.setOnClickListener(new View.OnClickListener() { @Override//from ww w . j a va 2 s. com public void onClick(View v) { try { AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity); alert.setTitle("Title here"); StringBuilder query = new StringBuilder(); query.append("redirect_uri=" + URLEncoder.encode(redirectUri, "utf-8")); query.append("&client_id=" + URLEncoder.encode(clientId, "utf-8")); query.append("&scope=" + URLEncoder.encode(scopes, "utf-8")); query.append("&response_type=code"); URI uri = new URI("https://login.live.com/oauth20_authorize.srf?" + query.toString()); URL url = uri.toURL(); final WebView wv = new WebView(thisActivity); WebSettings webSettings = wv.getSettings(); webSettings.setJavaScriptEnabled(true); wv.loadUrl(url.toString()); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String location) { Log.e(TAG, location); // TODO: extract to method try { URL url = new URL(location); if (url.getPath().equalsIgnoreCase("/oauth20_desktop.srf")) { System.out.println("Dit werkt al!"); System.out.println(url.getQuery()); Map<String, List<String>> result = splitQuery(url); if (result.containsKey("code")) { System.out.println("bevat code"); if (result.containsKey("error")) { System.out.println(String.format("{0}\r\n{1}", result.get("error"), result.get("errorDesc"))); } System.out.println(result.get("code").get(0)); String tokenError = GetToken(result.get("code").get(0), false); if (tokenError == null || "".equals(tokenError)) { System.out.println("Successful sign-in!"); Log.e(TAG, "Successful sign-in!"); } else { Log.e(TAG, "tokenError: " + tokenError); } } else { System.out.println("Successful sign-out!"); } } } catch (IOException | URISyntaxException e) { e.printStackTrace(); } view.loadUrl(location); return true; } }); LinearLayout linearLayout = new LinearLayout(thisActivity); linearLayout.setMinimumHeight(500); ArrayList<View> views = new ArrayList<View>(); views.add(wv); linearLayout.addView(wv); EditText text = new EditText(thisActivity); text.setVisibility(View.GONE); linearLayout.addView(text); alert.setView(linearLayout); alert.setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); alert.show(); } catch (Exception e) { Log.e(TAG, "dd"); } } }); Button showProfile = (Button) findViewById(R.id.button2); showProfile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showProfile(); } }); Button showSummmary = (Button) findViewById(R.id.button3); showSummmary.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showSummaries(); } }); if (savedInstanceState != null) { authInProgress = savedInstanceState.getBoolean(AUTH_PENDING); } buildFitnessClient(); }
From source file:edu.mit.viral.shen.DroidFish.java
private final void initUI() { leftHanded = leftHandedView();/* www . j av a 2s. c o m*/ setContentView(leftHanded ? R.layout.main_left_handed : R.layout.main); Util.overrideFonts(findViewById(android.R.id.content)); // title lines need to be regenerated every time due to layout changes (rotations) secondTitleLine = findViewById(R.id.second_title_line); // whiteTitleText = (TextView)findViewById(R.id.white_clock); // whiteTitleText.setSelected(true); // blackTitleText = (TextView)findViewById(R.id.black_clock); // blackTitleText.setSelected(true); engineTitleText = (TextView) findViewById(R.id.title_text); whiteFigText = (TextView) findViewById(R.id.white_pieces); whiteFigText.setTypeface(figNotation); whiteFigText.setSelected(true); // whiteFigText.setTextColor(whiteTitleText.getTextColors()); blackFigText = (TextView) findViewById(R.id.black_pieces); blackFigText.setTypeface(figNotation); blackFigText.setSelected(true); // blackFigText.setTextColor(blackTitleText.getTextColors()); summaryTitleText = (TextView) findViewById(R.id.title_text_summary); status = (TextView) findViewById(R.id.status); // server = (TextView)findViewById(R.id.server); moveListScroll = (ScrollView) findViewById(R.id.scrollView); moveList = (TextView) findViewById(R.id.moveList); defaultMoveListTypeFace = moveList.getTypeface(); thinking = (TextView) findViewById(R.id.thinking); defaultThinkingListTypeFace = thinking.getTypeface(); status.setFocusable(false); moveListScroll.setFocusable(false); moveList.setFocusable(false); moveList.setMovementMethod(LinkMovementMethod.getInstance()); thinking.setFocusable(false); cb = (ChessBoardPlay) findViewById(R.id.chessboard); cb.setFocusable(true); cb.requestFocus(); cb.setClickable(true); cb.setPgnOptions(pgnOptions); final GestureDetector gd = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { private float scrollX = 0; private float scrollY = 0; @Override public boolean onDown(MotionEvent e) { if (!boardGestures) { handleClick(e); return true; } scrollX = 0; scrollY = 0; return false; } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (!boardGestures) return false; cb.cancelLongPress(); if (invertScrollDirection) { distanceX = -distanceX; distanceY = -distanceY; } if ((scrollSensitivity > 0) && (cb.sqSize > 0)) { scrollX += distanceX; scrollY += distanceY; float scrollUnit = cb.sqSize * scrollSensitivity; if (Math.abs(scrollX) >= Math.abs(scrollY)) { // Undo/redo int nRedo = 0, nUndo = 0; while (scrollX > scrollUnit) { nRedo++; scrollX -= scrollUnit; } while (scrollX < -scrollUnit) { nUndo++; scrollX += scrollUnit; } if (nUndo + nRedo > 0) scrollY = 0; if (nRedo + nUndo > 1) { boolean analysis = gameMode.analysisMode(); boolean human = gameMode.playerWhite() || gameMode.playerBlack(); if (analysis || !human) ctrl.setGameMode(new GameMode(GameMode.TWO_PLAYERS)); } for (int i = 0; i < nRedo; i++) ctrl.redoMove(); for (int i = 0; i < nUndo; i++) ctrl.undoMove(); ctrl.setGameMode(gameMode); } else { // Next/previous variation int varDelta = 0; while (scrollY > scrollUnit) { varDelta++; scrollY -= scrollUnit; } while (scrollY < -scrollUnit) { varDelta--; scrollY += scrollUnit; } if (varDelta != 0) scrollX = 0; ctrl.changeVariation(varDelta); } } return true; } @Override public boolean onSingleTapUp(MotionEvent e) { if (!boardGestures) return false; cb.cancelLongPress(); handleClick(e); return true; } @Override public boolean onDoubleTapEvent(MotionEvent e) { if (!boardGestures) return false; if (e.getAction() == MotionEvent.ACTION_UP) handleClick(e); return true; } private final void handleClick(MotionEvent e) { if (ctrl.humansTurn()) { int sq = cb.eventToSquare(e); Move m = cb.mousePressed(sq); if (m != null) { ctrl.makeHumanMove(m); String longfen = TextIO.toFEN(cb.pos); String sentout = utils.getSendMessageJSON(longfen); sendJSON(sentout); // String fen1=longfen.replaceAll("D","1");] // commented out 04/12/15 // sendDataone(longfen, 1); } setEgtbHints(cb.getSelectedSquare()); } } @Override public void onLongPress(MotionEvent e) { if (!boardGestures) return; ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(20); removeDialog(BOARD_MENU_DIALOG); showDialog(BOARD_MENU_DIALOG); } }); cb.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return gd.onTouchEvent(event); } }); cb.setOnTrackballListener(new ChessBoard.OnTrackballListener() { public void onTrackballEvent(MotionEvent event) { if (ctrl.humansTurn()) { Move m = cb.handleTrackballEvent(event); if (m != null) ctrl.makeHumanMove(m); setEgtbHints(cb.getSelectedSquare()); } } }); moveList.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { removeDialog(MOVELIST_MENU_DIALOG); showDialog(MOVELIST_MENU_DIALOG); return true; } }); thinking.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { if (mShowThinking || gameMode.analysisMode()) { if (!pvMoves.isEmpty()) { removeDialog(THINKING_MENU_DIALOG); showDialog(THINKING_MENU_DIALOG); } } return true; } }); custom1Button = (ImageButton) findViewById(R.id.custom1Button); custom1ButtonActions.setImageButton(custom1Button, this); custom2Button = (ImageButton) findViewById(R.id.custom2Button); custom2ButtonActions.setImageButton(custom2Button, this); custom3Button = (ImageButton) findViewById(R.id.custom3Button); custom3ButtonActions.setImageButton(custom3Button, this); /* modeButton = (ImageButton)findViewById(R.id.modeButton); modeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDialog(GAME_MODE_DIALOG); } }); */ undoButton = (ImageButton) findViewById(R.id.undoButton); undoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctrl.undoMove(); sendDataone(TextIO.toFEN(cb.pos), 1); } }); undoButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { removeDialog(GO_BACK_MENU_DIALOG); showDialog(GO_BACK_MENU_DIALOG); return true; } }); commentButton = (ImageButton) findViewById(R.id.commentbutton); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this); builder.setTitle(R.string.edit_comments); View content = View.inflate(DroidFish.this, R.layout.edit_comments, null); builder.setView(content); DroidChessController.CommentInfo commInfo = ctrl.getComments(); final TextView preComment, moveView, nag, postComment; preComment = (TextView) content.findViewById(R.id.ed_comments_pre); moveView = (TextView) content.findViewById(R.id.ed_comments_move); nag = (TextView) content.findViewById(R.id.ed_comments_nag); postComment = (TextView) content.findViewById(R.id.ed_comments_post); preComment.setText(commInfo.preComment); postComment.setText(commInfo.postComment); moveView.setText(commInfo.move); String nagStr = Node.nagStr(commInfo.nag).trim(); if ((nagStr.length() == 0) && (commInfo.nag > 0)) nagStr = String.format(Locale.US, "%d", commInfo.nag); nag.setText(nagStr); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String pre = preComment.getText().toString().trim(); String post = postComment.getText().toString().trim(); sendComment(post); int nagVal = Node.strToNag(nag.getText().toString()); DroidChessController.CommentInfo commInfo = new DroidChessController.CommentInfo(); commInfo.preComment = pre; commInfo.postComment = post; commInfo.nag = nagVal; ctrl.setComments(commInfo); } }); builder.show(); } }); commentButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { removeDialog(GO_FORWARD_MENU_DIALOG); showDialog(GO_FORWARD_MENU_DIALOG); return true; } }); redoButton = (ImageButton) findViewById(R.id.redoButton); redoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctrl.redoMove(); //startNewGame(2); } }); redoButton.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { removeDialog(GO_FORWARD_MENU_DIALOG); showDialog(GO_FORWARD_MENU_DIALOG); return true; } }); }
From source file:com.citrus.sample.WalletPaymentFragment.java
private void showUpdateSubscriptionPrompt(final boolean isUpdateToHigherValue) { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); // final String message = "Update Subscription to Lowe Amount"; String positiveButtonText = "Update Subscription "; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final TextView labelsubscriptionID = new TextView(getActivity()); final EditText edtAmount = new EditText(getActivity()); final TextView labelAmount = new TextView(getActivity()); final EditText editLoadAmount = new EditText(getActivity()); final TextView labelMobileNo = new TextView(getActivity()); final EditText editThresholdAmount = new EditText(getActivity()); editLoadAmount.setSingleLine(true);//from ww w. j a v a 2 s . c o m editThresholdAmount.setSingleLine(true); edtAmount.setSingleLine(true); edtAmount.setInputType(InputType.TYPE_NULL); labelsubscriptionID.setText("Load Money Amount"); labelAmount.setText("Current Auto Load Amount"); editLoadAmount.setText(String.valueOf(activeSubscription.getLoadAmount())); labelMobileNo.setText("Current Threshold Amount"); editThresholdAmount.setText(String.valueOf(activeSubscription.getThresholdAmount())); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelsubscriptionID.setLayoutParams(layoutParams); edtAmount.setLayoutParams(layoutParams); labelAmount.setLayoutParams(layoutParams); labelMobileNo.setLayoutParams(layoutParams); editLoadAmount.setLayoutParams(layoutParams); editThresholdAmount.setLayoutParams(layoutParams); linearLayout.addView(labelAmount); linearLayout.addView(editLoadAmount); linearLayout.addView(labelMobileNo); linearLayout.addView(editThresholdAmount); linearLayout.addView(labelsubscriptionID); linearLayout.addView(edtAmount); edtAmount.setText("1.00"); int paddingPx = Utils.getSizeInPx(getActivity(), 32); linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); edtAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editLoadAmount.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { /* if (!hasFocus) { if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { labelsubscriptionID.setVisibility(View.VISIBLE); edtAmount.setVisibility(View.VISIBLE); edtAmount.setText("1.00"); } else { labelsubscriptionID.setVisibility(View.INVISIBLE); edtAmount.setVisibility(View.INVISIBLE); } }*/ } }); editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setTitle("Update Subscription "); alert.setMessage("Updating Load amount to higher will require Load Money transactions."); alert.setView(linearLayout); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String trAmount = edtAmount.getText().toString(); final String loadAmount = editLoadAmount.getText().toString(); final String thresHoldAmount = editThresholdAmount.getText().toString(); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edtAmount.getWindowToken(), 0); if (TextUtils.isEmpty(trAmount) && edtAmount.getVisibility() == View.VISIBLE) { Toast.makeText(getActivity(), " load amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(loadAmount)) { Toast.makeText(getActivity(), "Auto Load Amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(thresHoldAmount)) { Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(thresHoldAmount) < new Double("500")) { Toast.makeText(getActivity(), "thresHoldAmount should not be less than 500", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) { Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(editLoadAmount.getText().toString()) > activeSubscription.getLoadAmount()) { //update to higher value mListener.onAutoLoadSelected(AUTO_LOAD_MONEY, new Amount(trAmount), editLoadAmount.getText().toString(), editThresholdAmount.getText().toString(), true); } else { //update to lower value mCitrusClient.updateSubScriptiontoLoweValue(new Amount(thresHoldAmount), new Amount(loadAmount), new Callback<SubscriptionResponse>() { @Override public void success(SubscriptionResponse subscriptionResponse) { Toast.makeText(getActivity(), subscriptionResponse.toString(), Toast.LENGTH_SHORT).show(); Logger.d("updateSubscription response **" + subscriptionResponse.toString()); activeSubscription = subscriptionResponse;//update the active subscription Object } @Override public void error(CitrusError error) { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); Logger.d("ERROR ***updateSubscription" + error.getMessage()); } }); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); editLoadAmount.requestFocus(); alert.show(); }
From source file:com.android.launcher3.Utilities.java
public static void showEditMode(final Activity activity, final ShortcutInfo shortcutInfo) { ContextThemeWrapper theme;//w w w .j a v a2 s .c o m final Set<String> setString = new HashSet<String>(); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { theme = new ContextThemeWrapper(activity, R.style.AlertDialogCustomAPI23); } else { theme = new ContextThemeWrapper(activity, R.style.AlertDialogCustom); } AlertDialog.Builder alert = new AlertDialog.Builder(theme); LinearLayout layout = new LinearLayout(activity.getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(100, 0, 100, 100); final ImageView img = new ImageView(activity.getApplicationContext()); Drawable icon = null; if (Utilities.getAppIconPackageNamePrefEnabled(activity.getApplicationContext()) != null) { if (Utilities.getAppIconPackageNamePrefEnabled(activity.getApplicationContext()).equals("NULL")) { if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcutInfo.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), shortcutInfo.getIcon(new IconCache(activity.getApplicationContext(), Launcher.getLauncher(activity).getDeviceProfile().inv))); } } else { if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcutInfo.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), Launcher.getIcons().get(shortcutInfo.getTargetComponent().getPackageName())); } } } else { if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcutInfo.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcutInfo.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), shortcutInfo.getIcon(new IconCache(activity.getApplicationContext(), Launcher.getLauncher(Launcher.getLauncherActivity()).getDeviceProfile().inv))); } } img.setImageDrawable(icon); img.setPadding(0, 100, 0, 0); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showIconPack(activity, shortcutInfo); } }); final EditText titleBox = new EditText(activity.getApplicationContext()); try { Set<String> title = new HashSet<>( Utilities.getTitle(activity, shortcutInfo.getTargetComponent().getPackageName())); for (Iterator<String> it = title.iterator(); it.hasNext();) { String titleApp = it.next(); titleBox.setText(titleApp); } } catch (Exception e) { titleBox.setText(shortcutInfo.title); } titleBox.getBackground().mutate().setColorFilter( ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP); layout.addView(img); layout.addView(titleBox); alert.setTitle(activity.getApplicationContext().getResources().getString(R.string.edit_label)); alert.setView(layout); alert.setPositiveButton(activity.getApplicationContext().getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { for (ItemInfo itemInfo : AllAppsList.data) { if (shortcutInfo.getTargetComponent().getPackageName() .equals(itemInfo.getTargetComponent().getPackageName())) { setString.add(titleBox.getText().toString()); getPrefs(activity.getApplicationContext()).edit() .putStringSet(itemInfo.getTargetComponent().getPackageName(), setString) .apply(); Launcher.getShortcutsCreation().clearAllLayout(); applyChange(activity); } } } }); alert.setNegativeButton(activity.getApplicationContext().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Launcher.getShortcutsCreation().clearAllLayout(); } }); alert.show(); }
From source file:cat.wuyingren.rorhelper.fragments.dialogs.ManageSenatorDialogFragment.java
@NonNull @Override/* w w w. jav a2 s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); final View v = inflater.inflate(R.layout.dialog_managesenator, null); final TextView randomKillTitle = (TextView) v.findViewById(R.id.managesenator_randomTitle); final ToggleButton randomKillButton = (ToggleButton) v.findViewById(R.id.managesenator_randomToggle); final LinearLayout selectors = (LinearLayout) v.findViewById(R.id.managesenator_selectors); dataSource = MainActivity.getDataSource(); context = MainActivity.getContext(); currentGameId = getArguments().getLong(ARG_GAMEID); killMode = getArguments().getBoolean(ARG_MODE); statesman = getArguments().getBoolean(ARG_TYPE); result.setKill(killMode); result.setStatesman(statesman); final Spinner senatorSpinner = (Spinner) v.findViewById(R.id.managesenator_senatorSpinner); randomKillButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { result.setRandomKill(isChecked); if (isChecked) { selectors.setVisibility(View.GONE); } else { selectors.setVisibility(View.VISIBLE); } } }); if (!killMode) { randomKillTitle.setVisibility(View.GONE); randomKillButton.setVisibility(View.GONE); String[] keys = getArguments().getStringArray(ARG_ARRAY); ArrayList<String> values = getArguments().getStringArrayList(ARG_VALUES); /*ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(MainActivity.getContext(), android.R.layout.simple_spinner_item, keys);*/ SenatorAdapter adapter = new SenatorAdapter(MainActivity.getContext(), android.R.layout.simple_spinner_item, keys, values); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); senatorSpinner.setAdapter(adapter); } else { randomKillTitle.setVisibility(View.VISIBLE); randomKillButton.setVisibility(View.VISIBLE); } senatorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { result.setSenatorID(parent.getSelectedItem().toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final Spinner factionSpinner = SystemUtils.configureSpinner(v, R.id.managesenator_factionSpinner, R.array.faction_nameID); factionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { long factionID = dataSource.getFactionId(currentGameId, getResources().getStringArray(R.array.faction_nameID)[position]); result.setFactionID(factionID); if (killMode) { ArrayList<Senator> senators = dataSource.getAllSenatorsOfFaction(factionID); Iterator<Senator> ite = senators.iterator(); ArrayList<CharSequence> array = new ArrayList<CharSequence>(); ArrayList<String> values = new ArrayList<String>(); while (ite.hasNext()) { Senator s = ite.next(); array.add(String.valueOf(s.getId())); values.add(String.valueOf(s.getName())); } String[] keys = new String[array.size()]; keys = array.toArray(keys); //ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(context, android.R.layout.simple_spinner_item, array); SenatorAdapter adapter = new SenatorAdapter(context, android.R.layout.simple_spinner_item, keys, values); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); senatorSpinner.setAdapter(adapter); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setView(v).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onManageSenatorDialogPositiveClick(result); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }); String stringA, stringB; if (killMode) { stringA = getString(R.string.dialog_managesenator_kill_title); } else { stringA = getString(R.string.dialog_managesenator_title); } if (statesman) { stringB = getString(R.string.statesman); } else { stringB = getString(R.string.senator); } builder.setTitle(stringA + " " + stringB); return builder.create(); }
From source file:edu.mit.viral.shen.DroidFish.java
private final Dialog moveListMenuDialog() { final int EDIT_HEADERS = 0; final int EDIT_COMMENTS = 1; final int REMOVE_SUBTREE = 2; final int MOVE_VAR_UP = 3; final int MOVE_VAR_DOWN = 4; final int ADD_NULL_MOVE = 5; List<CharSequence> lst = new ArrayList<CharSequence>(); List<Integer> actions = new ArrayList<Integer>(); // lst.add(getString(R.string.edit_headers)); actions.add(EDIT_HEADERS); // if (ctrl.humansTurn()) { lst.add(getString(R.string.edit_comments)); actions.add(EDIT_COMMENTS);// w w w .j a v a2s. co m // } // lst.add(getString(R.string.truncate_gametree)); actions.add(REMOVE_SUBTREE); // if (ctrl.numVariations() > 1) { // lst.add(getString(R.string.move_var_up)); actions.add(MOVE_VAR_UP); // lst.add(getString(R.string.move_var_down)); actions.add(MOVE_VAR_DOWN); // } boolean allowNullMove = gameMode.analysisMode() || (gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive()); if (allowNullMove) { lst.add(getString(R.string.add_null_move)); actions.add(ADD_NULL_MOVE); } final List<Integer> finalActions = actions; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.edit_game); builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (finalActions.get(item)) { case EDIT_HEADERS: { final TreeMap<String, String> headers = new TreeMap<String, String>(); ctrl.getHeaders(headers); AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this); builder.setTitle(R.string.edit_headers); View content = View.inflate(DroidFish.this, R.layout.edit_headers, null); builder.setView(content); final TextView event, site, date, round, white, black; event = (TextView) content.findViewById(R.id.ed_header_event); site = (TextView) content.findViewById(R.id.ed_header_site); date = (TextView) content.findViewById(R.id.ed_header_date); round = (TextView) content.findViewById(R.id.ed_header_round); white = (TextView) content.findViewById(R.id.ed_header_white); black = (TextView) content.findViewById(R.id.ed_header_black); event.setText(headers.get("Event")); site.setText(headers.get("Site")); date.setText(headers.get("Date")); round.setText(headers.get("Round")); white.setText(headers.get("White")); black.setText(headers.get("Black")); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { headers.put("Event", event.getText().toString().trim()); headers.put("Site", site.getText().toString().trim()); headers.put("Date", date.getText().toString().trim()); headers.put("Round", round.getText().toString().trim()); headers.put("White", white.getText().toString().trim()); headers.put("Black", black.getText().toString().trim()); ctrl.setHeaders(headers); setBoardFlip(true); } }); builder.show(); break; } case EDIT_COMMENTS: { AlertDialog.Builder builder = new AlertDialog.Builder(DroidFish.this); builder.setTitle(R.string.edit_comments); View content = View.inflate(DroidFish.this, R.layout.edit_comments, null); builder.setView(content); DroidChessController.CommentInfo commInfo = ctrl.getComments(); final TextView preComment, moveView, nag, postComment; preComment = (TextView) content.findViewById(R.id.ed_comments_pre); moveView = (TextView) content.findViewById(R.id.ed_comments_move); nag = (TextView) content.findViewById(R.id.ed_comments_nag); postComment = (TextView) content.findViewById(R.id.ed_comments_post); preComment.setText(commInfo.preComment); postComment.setText(commInfo.postComment); moveView.setText(commInfo.move); String nagStr = Node.nagStr(commInfo.nag).trim(); if ((nagStr.length() == 0) && (commInfo.nag > 0)) nagStr = String.format(Locale.US, "%d", commInfo.nag); nag.setText(nagStr); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String pre = preComment.getText().toString().trim(); String post = postComment.getText().toString().trim(); int nagVal = Node.strToNag(nag.getText().toString()); DroidChessController.CommentInfo commInfo = new DroidChessController.CommentInfo(); commInfo.preComment = pre; commInfo.postComment = post; commInfo.nag = nagVal; ctrl.setComments(commInfo); } }); builder.show(); break; } case REMOVE_SUBTREE: ctrl.removeSubTree(); break; case MOVE_VAR_UP: ctrl.moveVariation(-1); break; case MOVE_VAR_DOWN: ctrl.moveVariation(1); break; case ADD_NULL_MOVE: ctrl.makeHumanNullMove(); break; } moveListMenuDlg = null; } }); AlertDialog alert = builder.create(); moveListMenuDlg = alert; return alert; }
From source file:com.citrus.sample.WalletPaymentFragment.java
void showTokenizedPrompt() { final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); final String message = "Auto Load Money with Saved Card"; String positiveButtonText = "Auto Load"; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); final TextView labelamt = new TextView(getActivity()); final EditText editAmount = new EditText(getActivity()); final TextView labelAmount = new TextView(getActivity()); final EditText editLoadAmount = new EditText(getActivity()); final TextView labelMobileNo = new TextView(getActivity()); final EditText editThresholdAmount = new EditText(getActivity()); final Button btnSelectSavedCards = new Button(getActivity()); btnSelectSavedCards.setText("Select Saved Card"); editLoadAmount.setSingleLine(true);//from w ww . j a va 2s . c o m editThresholdAmount.setSingleLine(true); editAmount.setSingleLine(true); labelamt.setText("Load Amount"); labelAmount.setText("Auto Load Amount"); labelMobileNo.setText("Threshold Amount"); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); labelamt.setLayoutParams(layoutParams); editAmount.setLayoutParams(layoutParams); labelAmount.setLayoutParams(layoutParams); labelMobileNo.setLayoutParams(layoutParams); editLoadAmount.setLayoutParams(layoutParams); editThresholdAmount.setLayoutParams(layoutParams); btnSelectSavedCards.setLayoutParams(layoutParams); btnSelectSavedCards.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCitrusClient.getWallet(new Callback<List<PaymentOption>>() { @Override public void success(List<PaymentOption> paymentOptions) { walletList.clear(); for (PaymentOption paymentOption : paymentOptions) { if (paymentOption instanceof CreditCardOption) { if (Arrays.asList(AUTO_LOAD_CARD_SCHEMS) .contains(((CardOption) paymentOption).getCardScheme().toString())) walletList.add(paymentOption); //only available for Master and Visa Credit Card.... } } savedOptionsAdapter = new SavedOptionsAdapter(getActivity(), walletList); showSavedAccountsDialog(); } @Override public void error(CitrusError error) { Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); } }); } }); linearLayout.addView(labelamt); linearLayout.addView(editAmount); linearLayout.addView(labelAmount); linearLayout.addView(editLoadAmount); linearLayout.addView(labelMobileNo); linearLayout.addView(editThresholdAmount); linearLayout.addView(btnSelectSavedCards); int paddingPx = Utils.getSizeInPx(getActivity(), 32); linearLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); editLoadAmount.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editThresholdAmount.setInputType(InputType.TYPE_CLASS_NUMBER); alert.setTitle("Auto Load Money with Saved Card"); alert.setMessage(message); alert.setView(linearLayout); alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { final String amount = editAmount.getText().toString(); final String loadAmount = editLoadAmount.getText().toString(); final String thresHoldAmount = editThresholdAmount.getText().toString(); // Hide the keyboard. InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editAmount.getWindowToken(), 0); if (TextUtils.isEmpty(amount)) { Toast.makeText(getActivity(), "Amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(loadAmount)) { Toast.makeText(getActivity(), "Load Amount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(thresHoldAmount)) { Toast.makeText(getActivity(), "thresHoldAmount cant be blank", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(thresHoldAmount) < new Double("500")) { Toast.makeText(getActivity(), "thresHoldAmount should not be less than 500", Toast.LENGTH_SHORT).show(); return; } if (Double.valueOf(loadAmount) < new Double(thresHoldAmount)) { Toast.makeText(getActivity(), "Load Amount should not be less than thresHoldAmount", Toast.LENGTH_SHORT).show(); return; } if (otherPaymentOption == null) { Toast.makeText(getActivity(), "Saved Card Option is null.", Toast.LENGTH_SHORT).show(); } try { PaymentType paymentType = new PaymentType.LoadMoney(new Amount(amount), otherPaymentOption); mCitrusClient.autoLoadMoney((PaymentType.LoadMoney) paymentType, new Amount(thresHoldAmount), new Amount(loadAmount), new Callback<SubscriptionResponse>() { @Override public void success(SubscriptionResponse subscriptionResponse) { Logger.d("AUTO LOAD RESPONSE ***" + subscriptionResponse.getSubscriptionResponseMessage()); Toast.makeText(getActivity(), subscriptionResponse.getSubscriptionResponseMessage(), Toast.LENGTH_SHORT).show(); } @Override public void error(CitrusError error) { Logger.d("AUTO LOAD ERROR ***" + error.getMessage()); Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_SHORT).show(); } }); } catch (CitrusException e) { e.printStackTrace(); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); editLoadAmount.requestFocus(); alert.show(); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void LaunchMsimDialog(final boolean bCheckEcmMode) { AlertDialog.Builder builder = new AlertDialog.Builder(ComposeMessageActivity.this); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.multi_sim_sms_sender, (ViewGroup) findViewById(R.id.layout_root)); builder.setView(layout); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: { dismissMsimDialog();/* w w w . j a va 2s . co m*/ return true; } case KeyEvent.KEYCODE_SEARCH: { return true; } } return false; } }); builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dismissMsimDialog(); } }); ContactList recipients = isRecipientsEditorVisible() ? mRecipientsEditor.constructContactsFromInput(false) : getRecipients(); builder.setTitle( getResources().getString(R.string.to_address_label) + recipients.formatNamesAndNumbers(",")); mMsimDialog = builder.create(); mMsimDialog.setCanceledOnTouchOutside(true); int[] smsBtnIds = { R.id.BtnSubOne, R.id.BtnSubTwo, R.id.BtnSubThree }; int phoneCount = MSimTelephonyManager.getDefault().getPhoneCount(); Button[] smsBtns = new Button[phoneCount]; for (int i = 0; i < phoneCount; i++) { final int subscription = i; int subID = i + 1; smsBtns[i] = (Button) layout.findViewById(smsBtnIds[i]); smsBtns[i].setVisibility(View.VISIBLE); smsBtns[i].setText(MSimTelephonyManager.getDefault().getSimOperatorName(i) + "-" + subID); smsBtns[i].setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.d(TAG, "Sub slected " + subscription); processMsimSendMessage(subscription, bCheckEcmMode); } }); } mMsimDialog.show(); }
From source file:com.code.android.vibevault.SearchScreen.java
private void launchSettingsDialog() { final SeekBar seek; final Spinner sortSpin; final Spinner searchSpin; final TextView seekValue; // Make the settings dialog. AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Search Settings"); View v = LayoutInflater.from(this).inflate(R.layout.scrollable_settings_dialog, null); ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { }// w w w . j av a 2s.c o m }); // Grab all the GUI widgets. seek = (SeekBar) v.findViewById(R.id.NumResultsSeekBar); seek.setProgress(Integer.valueOf(VibeVault.db.getPref("numResults")) - 10); sortSpin = (Spinner) v.findViewById(R.id.SortSpinner); searchSpin = (Spinner) v.findViewById(R.id.SearchSpinner); seekValue = (TextView) v.findViewById(R.id.SeekBarValue); seekValue.setText(VibeVault.db.getPref("numResults")); // Set the seek bar to its current value, and set up a Listener. seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { seekValue.setText(String.valueOf(progress + 10)); VibeVault.db.updatePref("numResults", String.valueOf(progress + 10)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // Set up the spinner, and set up it's OnItemSelectedListener. ArrayAdapter<String> sortAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, VibeVault.sortChoices); sortAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sortSpin.setAdapter(sortAdapter); int sortPos = 1; String sortOrder = VibeVault.db.getPref("sortOrder"); for (int i = 0; i < VibeVault.sortChoices.length; i++) { if (VibeVault.sortChoices[i].equals(sortOrder)) sortPos = i; } sortSpin.setSelection(sortPos); sortSpin.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View view, int arg2, long arg3) { int selected = arg0.getSelectedItemPosition(); VibeVault.db.updatePref("sortOrder", VibeVault.sortChoices[selected]); } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); ArrayAdapter<String> searchAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, VibeVault.searchChoices); searchAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); searchSpin.setAdapter(searchAdapter); int searchPos = 1; String searchOrder = VibeVault.searchPref; for (int i = 0; i < VibeVault.searchChoices.length; i++) { if (VibeVault.searchChoices[i].equals(searchOrder)) searchPos = i; } searchSpin.setSelection(searchPos); searchSpin.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View view, int arg2, long arg3) { int selected = arg0.getSelectedItemPosition(); VibeVault.searchPref = VibeVault.searchChoices[selected]; if (VibeVault.searchPref.equals("Artist") && artistSearchInput.getText().equals("")) { artistSearchInput.setHint("Search Artists..."); } else if (VibeVault.searchPref.equals("Show/Artist Description") && artistSearchInput.getText().equals("")) { artistSearchInput.setHint("Search Descriptions..."); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); // Show the settings screen. ad.setView(v); ad.show(); }