List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:edu.sfsu.csc780.chathub.ui.ChannelActivity.java
public void openBottomSheet() { View view = getLayoutInflater().inflate(R.layout.bottom_sheet_modal, null); final Dialog mBottomSheetDialog = new Dialog(ChannelActivity.this, R.style.MaterialDialogSheet); mBottomSheetDialog.setContentView(view); mBottomSheetDialog.setCancelable(true); mBottomSheetDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mBottomSheetDialog.getWindow().setGravity(Gravity.BOTTOM); mBottomSheetDialog.show();/*w w w. j a v a 2 s .c om*/ mImageButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.shareImageButton); mImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pickImage(); mBottomSheetDialog.hide(); } }); mPhotoButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.cameraButton); mPhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dispatchTakePhotoIntent(); mBottomSheetDialog.hide(); } }); mLocationButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.locationButton); mLocationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { loadMap(); mBottomSheetDialog.hide(); } }); mProgress = new ProgressDialog(this); mStorage = FirebaseStorage.getInstance().getReference(); mAudioButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.voiceButton); mAudioButton.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { startRecording(); Context context = getApplicationContext(); CharSequence text = "Recording Started!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { stopRecording(); mBottomSheetDialog.hide(); Context context = getApplicationContext(); CharSequence text = "Recording Stopped!"; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } return false; } }); mFileName = Environment.getExternalStorageDirectory().getAbsolutePath(); mFileName += "/recorded_audio.3gp"; mStickerButton = (BadgedStickersButton) mBottomSheetDialog.findViewById(R.id.stickerButton); StickersFragment stickersFragment = (StickersFragment) getSupportFragmentManager() .findFragmentById(R.id.frame); if (stickersFragment == null) { stickersFragment = new StickersFragment(); getSupportFragmentManager().beginTransaction().replace(R.id.frame, stickersFragment).commit(); } stickersFragment.setOnStickerSelectedListener(stickerSelectedListener); View stickersFrame = findViewById(R.id.frame); View chatContentGroup = findViewById(R.id.chat_content); StickersKeyboardLayout stickersLayout = (StickersKeyboardLayout) findViewById(R.id.sizeNotifierLayout); stickersKeyboardController = new StickersKeyboardController.Builder(this) .setStickersKeyboardLayout(stickersLayout).setStickersFragment(stickersFragment) .setStickersFrame(stickersFrame).setContentContainer(chatContentGroup) .setStickersButton(mStickerButton).setChatEdit(mMessageEditText).build(); mDrawButton = (ImageButton) mBottomSheetDialog.findViewById(R.id.drawButton); mDrawButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(ChannelActivity.this, DrawingActivity.class)); mBottomSheetDialog.hide(); } }); }
From source file:com.actionbarsherlock.internal.app.ActionBarImpl.java
public ActionBarImpl(Dialog dialog) { //UNUSED mDialog = dialog; init(dialog.getWindow().getDecorView()); }
From source file:com.example.android.navigationdrawer.QRCode.java
public void onQR(View v) { switch (v.getId()) { case R.id.button1: String qrInputText = MidiFile.readString; //Find screen size WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point);//from w ww . jav a 2s. c om int width = point.x; int height = point.y; int smallerDimension = width < height ? width : height; smallerDimension = smallerDimension * 3 / 4; //Encode with a QR Code image QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrInputText, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), smallerDimension); try { Bitmap bitmap = qrCodeEncoder.encodeAsBitmap(); ImageView myImage = (ImageView) findViewById(R.id.imageView1); myImage.setImageBitmap(bitmap); // Get screen size Display display1 = this.getWindowManager().getDefaultDisplay(); Point size = new Point(); display1.getSize(size); int screenWidth = size.x; int screenHeight = size.y; // Get target image size Bitmap bitmap1 = qrCodeEncoder.encodeAsBitmap(); int bitmapHeight = bitmap1.getHeight(); int bitmapWidth = bitmap1.getWidth(); // Scale the image down to fit perfectly into the screen // The value (250 in this case) must be adjusted for phone/tables displays while (bitmapHeight > (screenHeight - 250) || bitmapWidth > (screenWidth - 250)) { bitmapHeight = bitmapHeight / 2; bitmapWidth = bitmapWidth / 2; } // Create resized bitmap image BitmapDrawable resizedBitmap = new BitmapDrawable(this.getResources(), Bitmap.createScaledBitmap(bitmap, bitmapWidth, bitmapHeight, false)); // Create dialog Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.thumbnail); ImageView image = (ImageView) dialog.findViewById(R.id.imageview); // !!! Do here setBackground() instead of setImageDrawable() !!! // image.setBackground(resizedBitmap); // Without this line there is a very small border around the image (1px) // In my opinion it looks much better without it, so the choice is up to you. dialog.getWindow().setBackgroundDrawable(null); dialog.show(); } catch (WriterException e) { e.printStackTrace(); } break; } }
From source file:org.catrobat.catroid.ui.dialogs.UploadProjectDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_upload_project, null); projectRename = (TextView) dialogView.findViewById(R.id.tv_project_rename); projectDescriptionField = (EditText) dialogView.findViewById(R.id.project_description_upload); projectUploadName = (EditText) dialogView.findViewById(R.id.project_upload_name); sizeOfProject = (TextView) dialogView.findViewById(R.id.dialog_upload_size_of_project); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(R.string.upload_project_dialog_title) .setPositiveButton(R.string.upload_button, new DialogInterface.OnClickListener() { @Override/*from w w w . java2 s . com*/ public void onClick(DialogInterface dialog, int which) { handleUploadButtonClick(); } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleCancelButtonClick(); } }).create(); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { initListeners(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT); } }); initControls(); return dialog; }
From source file:com.tandong.sa.sherlock.internal.app.ActionBarImpl.java
public ActionBarImpl(Dialog dialog) { // UNUSED mDialog = dialog; init(dialog.getWindow().getDecorView()); }
From source file:com.aware.ui.ESM_UI.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // getActivity().getWindow().setType(WindowManager.LayoutParams.TYPE_PRIORITY_PHONE); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); builder = new AlertDialog.Builder(getActivity()); inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); TAG = Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(getActivity().getApplicationContext(), Aware_Preferences.DEBUG_TAG) : TAG;//ww w. jav a 2 s. c o m Cursor visible_esm = getActivity().getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1"); if (visible_esm != null && visible_esm.moveToFirst()) { esm_id = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data._ID)); //Fixed: set the esm as not new anymore, to avoid displaying the same ESM twice due to changes in orientation ContentValues update_state = new ContentValues(); update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE); getActivity().getContentResolver().update(ESM_Data.CONTENT_URI, update_state, ESM_Data._ID + "=" + esm_id, null); esm_type = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.TYPE)); expires_seconds = visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.EXPIRATION_THREASHOLD)); builder.setTitle(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.TITLE))); View ui = null; switch (esm_type) { case ESM.TYPE_ESM_TEXT: ui = inflater.inflate(R.layout.esm_text, null); break; case ESM.TYPE_ESM_RADIO: ui = inflater.inflate(R.layout.esm_radio, null); break; case ESM.TYPE_ESM_CHECKBOX: ui = inflater.inflate(R.layout.esm_checkbox, null); break; case ESM.TYPE_ESM_LIKERT: ui = inflater.inflate(R.layout.esm_likert, null); break; case ESM.TYPE_ESM_QUICK_ANSWERS: ui = inflater.inflate(R.layout.esm_quick, null); break; } final View layout = ui; builder.setView(layout); current_dialog = builder.create(); sContext = current_dialog.getContext(); TextView esm_instructions = (TextView) layout.findViewById(R.id.esm_instructions); esm_instructions.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.INSTRUCTIONS))); switch (esm_type) { case ESM.TYPE_ESM_TEXT: final EditText feedback = (EditText) layout.findViewById(R.id.esm_feedback); Button cancel_text = (Button) layout.findViewById(R.id.esm_cancel); cancel_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); current_dialog.cancel(); } }); Button submit_text = (Button) layout.findViewById(R.id.esm_submit); submit_text.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { inputManager.hideSoftInputFromWindow(feedback.getWindowToken(), 0); if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, feedback.getText().toString()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_RADIO: try { final RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); final JSONArray radios = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.RADIOS))); for (int i = 0; i < radios.length(); i++) { final RadioButton radioOption = new RadioButton(getActivity()); radioOption.setId(i); radioOption.setText(radios.getString(i)); radioOptions.addView(radioOption); if (radios.getString(i).equals("Other")) { radioOption.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) radioOption.setText(otherText.getText()); inputManager.hideSoftInputFromWindow(otherText.getWindowToken(), 0); editOther.dismiss(); } }); editor.addView(confirm); } }); } } Button cancel_radio = (Button) layout.findViewById(R.id.esm_cancel); cancel_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_radio = (Button) layout.findViewById(R.id.esm_submit); submit_radio.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_radio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); RadioGroup radioOptions = (RadioGroup) layout.findViewById(R.id.esm_radio); if (radioOptions.getCheckedRadioButtonId() != -1) { RadioButton selected = (RadioButton) radioOptions .getChildAt(radioOptions.getCheckedRadioButtonId()); rowData.put(ESM_Data.ANSWER, selected.getText().toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_CHECKBOX: try { final LinearLayout checkboxes = (LinearLayout) layout.findViewById(R.id.esm_checkboxes); final JSONArray checks = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.CHECKBOXES))); for (int i = 0; i < checks.length(); i++) { final CheckBox checked = new CheckBox(getActivity()); checked.setText(checks.getString(i)); checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (buttonView.getText().equals("Other")) { checked.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog editOther = new Dialog(getActivity()); editOther.setTitle("Can you be more specific, please?"); editOther.getWindow() .setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); editOther.getWindow().setGravity(Gravity.TOP); editOther.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout editor = new LinearLayout(getActivity()); editor.setOrientation(LinearLayout.VERTICAL); editOther.setContentView(editor); editOther.show(); final EditText otherText = new EditText(getActivity()); editor.addView(otherText); Button confirm = new Button(getActivity()); confirm.setText("OK"); confirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (otherText.length() > 0) { inputManager.hideSoftInputFromWindow( otherText.getWindowToken(), 0); selected_options .remove(buttonView.getText().toString()); checked.setText(otherText.getText()); selected_options.add(otherText.getText().toString()); } editOther.dismiss(); } }); editor.addView(confirm); } }); } else { selected_options.add(buttonView.getText().toString()); } } else { selected_options.remove(buttonView.getText().toString()); } } }); checkboxes.addView(checked); } Button cancel_checkbox = (Button) layout.findViewById(R.id.esm_cancel); cancel_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit_checkbox = (Button) layout.findViewById(R.id.esm_submit); submit_checkbox.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit_checkbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); if (selected_options.size() > 0) { rowData.put(ESM_Data.ANSWER, selected_options.toString()); } rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); } catch (JSONException e) { e.printStackTrace(); } break; case ESM.TYPE_ESM_LIKERT: final RatingBar ratingBar = (RatingBar) layout.findViewById(R.id.esm_likert); ratingBar.setMax(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); ratingBar.setStepSize( (float) visible_esm.getDouble(visible_esm.getColumnIndex(ESM_Data.LIKERT_STEP))); ratingBar.setNumStars(visible_esm.getInt(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX))); TextView min_label = (TextView) layout.findViewById(R.id.esm_min); min_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MIN_LABEL))); TextView max_label = (TextView) layout.findViewById(R.id.esm_max); max_label.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.LIKERT_MAX_LABEL))); Button cancel = (Button) layout.findViewById(R.id.esm_cancel); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { current_dialog.cancel(); } }); Button submit = (Button) layout.findViewById(R.id.esm_submit); submit.setText(visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.SUBMIT))); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.ANSWER, ratingBar.getRating()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); break; case ESM.TYPE_ESM_QUICK_ANSWERS: try { final JSONArray answers = new JSONArray( visible_esm.getString(visible_esm.getColumnIndex(ESM_Data.QUICK_ANSWERS))); final LinearLayout answersHolder = (LinearLayout) layout.findViewById(R.id.esm_answers); //If we have more than 3 possibilities, better that the UI is vertical for UX if (answers.length() > 3) { answersHolder.setOrientation(LinearLayout.VERTICAL); } for (int i = 0; i < answers.length(); i++) { final Button answer = new Button(getActivity()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1.0f); answer.setLayoutParams(params); answer.setText(answers.getString(i)); answer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (expires_seconds > 0 && expire_monitor != null) expire_monitor.cancel(true); ContentValues rowData = new ContentValues(); rowData.put(ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis()); rowData.put(ESM_Data.STATUS, ESM.STATUS_ANSWERED); rowData.put(ESM_Data.ANSWER, (String) answer.getText()); sContext.getContentResolver().update(ESM_Data.CONTENT_URI, rowData, ESM_Data._ID + "=" + esm_id, null); Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED); getActivity().sendBroadcast(answer); if (Aware.DEBUG) Log.d(TAG, "Answer:" + rowData.toString()); current_dialog.dismiss(); } }); answersHolder.addView(answer); } } catch (JSONException e) { e.printStackTrace(); } break; } } if (visible_esm != null && !visible_esm.isClosed()) visible_esm.close(); //Start dialog visibility threshold if (expires_seconds > 0) { expire_monitor = new ESMExpireMonitor(System.currentTimeMillis(), expires_seconds, esm_id); expire_monitor.execute(); } //Fixed: doesn't dismiss the dialog if touched outside or ghost touches current_dialog.setCanceledOnTouchOutside(false); return current_dialog; }
From source file:com.birdeye.MainActivity.java
private void removeAdsDialog() { final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.progress_pre); TextView tv_pay15 = (TextView) dialog.findViewById(R.id.tv_pay15); tv_pay15.setOnClickListener(new View.OnClickListener() { @Override/*from w w w.java 2 s . c om*/ public void onClick(View v) { if (!BillingProcessor.isIabServiceAvailable(MainActivity.this)) { showToast( "In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16"); } else { // asdasd // onFuturePaymentPressed(v); bp.subscribe(MainActivity.this, SUBSCRIPTION_ID); } dialog.dismiss(); } }); dialog.setCancelable(true); dialog.show(); }
From source file:org.smilec.smile.ui.GeneralActivity.java
@SuppressWarnings("deprecation") @Override/*from w ww .j a v a 2s . c o m*/ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.bt_restart: AlertDialog.Builder builderRestart = new AlertDialog.Builder(this); builderRestart.setMessage(R.string.restart_game).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { //new SmilePlugServerManager().connect(ip, GeneralActivity.this); new SmilePlugServerManager().resetGame(ip, GeneralActivity.this); // QuestionsManager.resetListOfDeletedQuestions(GeneralActivity.this); GeneralActivity.this.finish(); } catch (NetworkErrorException e) { ActivityUtil.showLongToast(GeneralActivity.this, R.string.toast_down_or_unavailable); Log.e(Constants.LOG_CATEGORY, "Error: ", e); } } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertRestart = builderRestart.create(); alertRestart.show(); break; case R.id.bt_retake: AlertDialog.Builder builderRetake = new AlertDialog.Builder(this); builderRetake.setMessage(R.string.retake_game).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { new SmilePlugServerManager().startRetakeQuestions(ip, GeneralActivity.this, board); ActivityUtil.showLongToast(GeneralActivity.this, R.string.toast_retaking); Intent intent = new Intent(GeneralActivity.this, org.smilec.smile.ui.UsePreparedQuestionsActivity.class); intent.putExtra(GeneralActivity.PARAM_IP, ip); status = CurrentMessageStatus.RE_TAKE.name(); intent.putExtra(GeneralActivity.PARAM_STATUS, status); startActivity(intent); } catch (NetworkErrorException e) { Log.e(Constants.LOG_CATEGORY, "Error: ", e); } } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertRetake = builderRetake.create(); alertRetake.show(); break; case R.id.bt_about: Dialog aboutDialog = new Dialog(this, R.style.Dialog); aboutDialog.setContentView(R.layout.about); Display displaySize = ActivityUtil.getDisplaySize(getApplicationContext()); aboutDialog.getWindow().setLayout(displaySize.getWidth(), displaySize.getHeight()); aboutDialog.show(); break; case R.id.bt_exit: AlertDialog.Builder builderExit = new AlertDialog.Builder(this); builderExit.setMessage(R.string.exit).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); try { new SmilePlugServerManager().resetGame(ip, GeneralActivity.this); } catch (NetworkErrorException e) { Log.e(Constants.LOG_CATEGORY, "Error: ", e); } // QuestionsManager.resetListOfDeletedQuestions(GeneralActivity.this); GeneralActivity.this.finish(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertExit = builderExit.create(); alertExit.show(); break; } return true; }
From source file:Steps.StepsFragment.java
private void showStickerMoreInfo(final Sticker clickedSticker) { // custom dialog clickedSticker.getName();//from ww w.j av a 2s .c om Log.d("NAMe", clickedSticker.getName()); final Dialog dialog = new Dialog(getActivity()); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK)); dialog.setContentView(R.layout.sticker_dialog); ImageView image = (ImageView) (dialog).findViewById(R.id.image); //get the correct image String file = clickedSticker.getImagesrc(); file = file.substring(0, file.lastIndexOf(".")); //trim the extension Resources resources = getActivity().getResources(); int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName()); image.setImageBitmap(SampleImage.decodeSampledBitmapFromResource(getResources(), resourceId, 250, 250)); //load the additional details and information TextView id = (TextView) (dialog).findViewById(R.id.sticker_id); id.setText("#" + Integer.toString(clickedSticker.getId())); TextView status = (TextView) (dialog).findViewById(R.id.sticker_status); //at this poinrt only glued and notSticker available glued=1 notGlued=0 String statuss = clickedSticker.getStatus().equals(2) ? "1" : "0"; Integer count = clickedSticker.getCount(); status.setText("(" + statuss + " glued, " + count + " left)"); TextView title = (TextView) (dialog).findViewById(R.id.sticker_title); title.setText(clickedSticker.getName()); TextView rarity = (TextView) (dialog).findViewById(R.id.rarity); rarity.setText(clickedSticker.getPopularity()); TextView movie = (TextView) (dialog).findViewById(R.id.sticker_movie); movie.setText(clickedSticker.getMovie()); //set the layout to have the same widh and height as the windows screen Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = width; lp.height = height; dialog.getWindow().setAttributes(lp); RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout); dialog.show(); // if button is clicked, close the custom dialog mainLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); //listen for the inf tab ImageView info = (ImageView) (dialog).findViewById(R.id.info_image); info.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showInfoDialog(clickedSticker); } }); }
From source file:com.cloverstudio.spika.GroupProfileActivity.java
private void getImageDialog() { final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme); imageDialog.getWindow().setGravity(Gravity.BOTTOM); imageDialog.setContentView(R.layout.dialog_get_image); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); Window window = imageDialog.getWindow(); layoutParams.copyFrom(window.getAttributes()); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(layoutParams);/* w w w . java 2 s .c om*/ final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery); btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class); galleryIntent.putExtra("type", "gallery"); galleryIntent.putExtra("groupUpdate", true); GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE); imageDialog.dismiss(); } }); final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera); btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnCamera.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class); cameraIntent.putExtra("type", "camera"); cameraIntent.putExtra("groupUpdate", true); GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE); imageDialog.dismiss(); } }); final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto); btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnRemovePhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { mGroupAvatarId = ""; gGroupImage = null; Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE, R.drawable.group_stub_large, false); imageDialog.dismiss(); } }); imageDialog.show(); }