List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:com.untie.daywal.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); thisMonthTv = (TextView) findViewById(R.id.this_month_tv); Calendar now = Calendar.getInstance(); Intent intent = getIntent();/*from ww w. ja v a 2 s . c o m*/ year = intent.getIntExtra("year", now.get(Calendar.YEAR)); month = intent.getIntExtra("month", now.get(Calendar.MONTH)); order = intent.getIntExtra("order", 0); if (order == 0) { mf = MonthlyFragment.newInstance(year, month); getSupportFragmentManager().beginTransaction().add(R.id.monthly, mf).commit(); } else if (order == 1) { mf = MonthlyFragment.newInstance(year, month - 1); getSupportFragmentManager().beginTransaction().replace(R.id.monthly, mf).commit(); } mf.setOnMonthChangeListener(new MonthlyFragment.OnMonthChangeListener() { @Override public void onChange(int year, int month) { HLog.d(TAG, CLASS, "onChange " + year + "." + month); thisMonthTv.setText(year + " " + (month + 1) + ""); } @Override public void onDayClick(OneDayView dayView) { int year = dayView.get(Calendar.YEAR); int month = dayView.get(Calendar.MONTH); int day = dayView.get(Calendar.DAY_OF_MONTH); int week = dayView.get(Calendar.DAY_OF_WEEK); Intent intent = new Intent(MainActivity.this, PopupActivity.class); intent.putExtra("year", year); intent.putExtra("month", month); intent.putExtra("day", day); intent.putExtra("week", week); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); startActivity(intent); //overridePendingTransition(0, 0); } @Override public void onDayLongClick(OneDayView dayView) { if (dayView.getImage() != null) { final Dialog dayPickerDialog = new Dialog(MainActivity.this); dayPickerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dayPickerDialog.setContentView(R.layout.dialog_image); dayPickerDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); dayPickerDialog.getWindow().setBackgroundDrawable((new ColorDrawable(0x7000000))); ImageView imageView = (ImageView) dayPickerDialog.findViewById(R.id.image_popup); Uri uri = dayView.getImage(); Glide.with(MainActivity.this).load(uri).centerCrop().into(imageView); dayPickerDialog.show(); //dayPickerDialog.dismiss(); } } }); thisMonthTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showDayPicker(); } }); }
From source file:ca.rmen.android.poetassistant.main.dictionaries.FilterDialogFragment.java
/** * @return a Dialog with a title, message, an edit text, and ok/cancel buttons. */// ww w .j a v a 2 s.co m @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState); Context context = getActivity(); LayoutInflater themedLayoutInflater = LayoutInflater .from(new ContextThemeWrapper(getActivity(), R.style.AppAlertDialog)); final InputDialogEditTextBinding binding = DataBindingUtil.inflate(themedLayoutInflater, R.layout.input_dialog_edit_text, null, false); Bundle arguments = getArguments(); binding.edit.setText(arguments.getString(EXTRA_TEXT)); OnClickListener positiveListener = (dialog, which) -> { FilterDialogListener listener; Fragment parentFragment = getParentFragment(); if (parentFragment instanceof FilterDialogListener) listener = (FilterDialogListener) parentFragment; else listener = (FilterDialogListener) getActivity(); listener.onFilterSubmitted(binding.edit.getText().toString()); }; final Dialog dialog = new AlertDialog.Builder(context).setView(binding.getRoot()) .setTitle(R.string.filter_title).setMessage(arguments.getString(EXTRA_MESSAGE)) .setPositiveButton(android.R.string.ok, positiveListener) .setNegativeButton(android.R.string.cancel, null).create(); binding.edit.setOnFocusChangeListener((v, hasFocus) -> { Window window = dialog.getWindow(); if (window != null) { if (hasFocus) { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } else { window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); } } }); return dialog; }
From source file:com.granita.tasks.QuickAddDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); // hide the actual dialog title, we have our own... dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); return dialog; }
From source file:com.irccloud.android.fragment.LinksListFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context ctx = getActivity();/* w w w .j a v a 2 s .c om*/ if (ctx == null) return null; if (savedInstanceState != null && savedInstanceState.containsKey("event")) { try { event = mapper.readValue(savedInstanceState.getString("event"), JsonNode.class); } catch (IOException e) { e.printStackTrace(); } } LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.recyclerview, null); recyclerView = v.findViewById(R.id.recycler); recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext())); recyclerView.setVisibility(View.VISIBLE); adapter = new LinksAdapter(); recyclerView.setAdapter(adapter); v.findViewById(android.R.id.empty).setVisibility(View.GONE); Dialog d = new AlertDialog.Builder(ctx).setTitle("Servers linked to " + event.get("server").asText()) .setView(v).setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); return d; }
From source file:com.pileproject.drive.setting.app.ProgramListFragment.java
/** * This function should be called in {@link DialogFragment#onActivityCreated(Bundle)}. * Otherwise, the dialog size will never be changed. *//* ww w . j ava2 s .c o m*/ private void resizeDialog() { Dialog dialog = getDialog(); DisplayMetrics metrics = getResources().getDisplayMetrics(); // resize window large enough to display list views int dialogWidth = (int) (metrics.widthPixels * 0.8); int dialogHeight = (int) (metrics.heightPixels * 0.6); WindowManager.LayoutParams lp = dialog.getWindow().getAttributes(); lp.width = dialogWidth; lp.height = dialogHeight; dialog.getWindow().setAttributes(lp); }
From source file:com.adithya321.sharesanalysis.fragments.SalesShareFragment.java
private void setRecyclerViewAdapter() { sharesList = databaseHandler.getShares(); final List<Purchase> salesList = databaseHandler.getSales(); PurchaseShareAdapter purchaseAdapter = new PurchaseShareAdapter(getContext(), salesList); purchaseAdapter.setOnItemClickListener(new PurchaseShareAdapter.OnItemClickListener() { @Override/* w w w .j a v a2s. com*/ public void onItemClick(View itemView, int position) { final Purchase purchase = salesList.get(position); final Dialog dialog = new Dialog(getActivity()); dialog.setTitle("Edit Share Sale"); dialog.setContentView(R.layout.dialog_sell_share_holdings); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); int pos = 0; for (int i = 0; i < sharesList.size(); i++) { shares.add(sharesList.get(i).getName()); if (sharesList.get(i).getName().equals(purchase.getName())) pos = i; } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); spinner.setSelection(pos); spinner.setVisibility(View.VISIBLE); final EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); final EditText price = (EditText) dialog.findViewById(R.id.selling_price); quantity.setText(String.valueOf(purchase.getQuantity())); price.setText(String.valueOf(purchase.getPrice())); Calendar calendar = Calendar.getInstance(); calendar.setTime(purchase.getDate()); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(SalesShareFragment.this); Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn); sellShareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Purchase p = new Purchase(); p.setId(purchase.getId()); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); p.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } try { p.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } try { p.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show(); return; } p.setType("sell"); p.setName(spinner.getSelectedItem().toString()); databaseHandler.updatePurchase(p); setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); salesRecyclerView.setHasFixedSize(true); salesRecyclerView.setAdapter(purchaseAdapter); salesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); }
From source file:com.adithya321.sharesanalysis.fragments.SalesShareFragment.java
@Nullable @Override//w w w . j a v a 2 s . com public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_sales, container, false); databaseHandler = new DatabaseHandler(getContext()); salesRecyclerView = (RecyclerView) root.findViewById(R.id.sales_recycler_view); setRecyclerViewAdapter(); FloatingActionButton sellShareFab = (FloatingActionButton) root.findViewById(R.id.sell_share_fab); sellShareFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Sell Share Holdings"); dialog.setContentView(R.layout.dialog_sell_share_holdings); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner); ArrayList<String> shares = new ArrayList<>(); for (Share share : sharesList) { shares.add(share.getName()); } ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, shares); spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(spinnerAdapter); Calendar calendar = Calendar.getInstance(); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start, month_start - 1, day_start); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectDate.setText(new StringBuilder().append(day_start).append("/") .append(month_start).append("/").append(year_start)); } }); dialog.show(); } }); Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn); sellShareBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Purchase purchase = new Purchase(); purchase.setId(databaseHandler.getNextKey("purchase")); purchase.setName(spinner.getSelectedItem().toString()); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); purchase.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares); try { purchase.setQuantity(Integer.parseInt(quantity.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show(); return; } EditText price = (EditText) dialog.findViewById(R.id.selling_price); try { purchase.setPrice(Double.parseDouble(price.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Selling Price", Toast.LENGTH_SHORT).show(); return; } purchase.setType("sell"); databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase); setRecyclerViewAdapter(); dialog.dismiss(); } }); } }); return root; }
From source file:com.peppermint.peppermint.ui.CallFragment.java
public void onPrepareDialog(int id, Dialog dialog) { switch (id) { case R.id.CALL_ADDRESS: //force keyboard dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); break;/* w w w . j a v a2s . c o m*/ } }
From source file:piuk.blockchain.android.ui.dialogs.RequestForgotPasswordDialog.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final FragmentActivity activity = (FragmentActivity) getActivity(); final WalletApplication application = (WalletApplication) activity.getApplication(); final LayoutInflater inflater = LayoutInflater.from(activity); final Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.Theme_Dialog)); dialog.setTitle(R.string.main_password_title); final View view = inflater.inflate(R.layout.forgot_password_dialog, null); dialog.setView(view);/*from ww w . j a va 2 s . c om*/ final TextView passwordField = (TextView) view.findViewById(R.id.password_field); final TextView titleTextView = (TextView) view.findViewById(R.id.title_text_view); titleTextView.setText(R.string.main_password_text); final Button continueButton = (Button) view.findViewById(R.id.password_continue); final Button cancelButton = (Button) view.findViewById(R.id.cancel); continueButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { if (passwordField.getText().toString().trim() == null || passwordField.getText().toString().trim().length() < 1) { callback.onFail(); } String localWallet = application.readLocalWallet(); if (!application.decryptLocalWallet(localWallet, passwordField.getText().toString().trim())) { callback.onFail(); return; } String password = passwordField.getText().toString().trim(); application.checkIfWalletHasUpdatedAndFetchTransactions(password, new SuccessCallback() { @Override public void onSuccess() { dismiss(); callback.onSuccess(); } @Override public void onFail() { dismiss(); callback.onFail(); } }); } catch (Exception e) { e.printStackTrace(); } } }); cancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { dismiss(); } }); Dialog d = dialog.create(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.dimAmount = 0; lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; // lp.gravity = Gravity.BOTTOM; d.show(); d.getWindow().setAttributes(lp); d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); return d; }
From source file:com.forrestguice.suntimeswidget.TimeZoneDialog.java
/** * trigger the time zone ActionMode//from w w w. ja v a2 s . c o m * @param view the view that is triggering the ActionMode * @return true ActionMode started, false otherwise */ private boolean triggerTimeZoneActionMode(View view) { if (this.actionMode != null) return false; // ActionMode for HONEYCOMB (11) and above if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { Dialog dialog = getDialog(); if (dialog == null) return false; View v = dialog.getWindow().getDecorView(); if (v == null) return false; ActionMode actionMode = v .startActionMode(new WidgetTimezones.TimeZoneSpinnerSortAction(getContext(), spinner_timezone) { @Override public void onSortTimeZones(WidgetTimezones.TimeZoneItemAdapter result, WidgetTimezones.TimeZoneSort sortMode) { super.onSortTimeZones(result, sortMode); spinner_timezone_adapter = result; WidgetTimezones.selectTimeZone(spinner_timezone, spinner_timezone_adapter, customTimezoneID); } @Override public void onSaveSortMode(WidgetTimezones.TimeZoneSort sortMode) { super.onSaveSortMode(sortMode); AppSettings.setTimeZoneSortPref(getContext(), sortMode); } @Override public void onDestroyActionMode(ActionMode mode) { super.onDestroyActionMode(mode); TimeZoneDialog.this.actionMode = null; } }); this.actionMode = actionMode; actionMode.setTitle(getString(R.string.timezone_sort_contextAction)); } else { // LEGACY; ActionMode for pre HONEYCOMB AppCompatActivity activity = (AppCompatActivity) getActivity(); android.support.v7.view.ActionMode actionMode = activity.startSupportActionMode( new WidgetTimezones.TimeZoneSpinnerSortActionCompat(getContext(), spinner_timezone) { @Override public void onSortTimeZones(WidgetTimezones.TimeZoneItemAdapter result, WidgetTimezones.TimeZoneSort sortMode) { super.onSortTimeZones(result, sortMode); spinner_timezone_adapter = result; WidgetTimezones.selectTimeZone(spinner_timezone, spinner_timezone_adapter, customTimezoneID); } @Override public void onSaveSortMode(WidgetTimezones.TimeZoneSort sortMode) { super.onSaveSortMode(sortMode); AppSettings.setTimeZoneSortPref(context, sortMode); } @Override public void onDestroyActionMode(android.support.v7.view.ActionMode mode) { super.onDestroyActionMode(mode); TimeZoneDialog.this.actionMode = null; } }); if (actionMode != null) { this.actionMode = actionMode; actionMode.setTitle(getString(R.string.timezone_sort_contextAction)); } } view.setSelected(true); return true; }