List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:com.iskrembilen.quasseldroid.gui.LoginActivity.java
@Override protected Dialog onCreateDialog(int id) { final Dialog dialog; switch (id) { case R.id.DIALOG_EDIT_CORE: //fallthrough case R.id.DIALOG_ADD_CORE: dialog = new Dialog(this); dialog.setContentView(R.layout.dialog_add_core); dialog.setTitle("Add new core"); OnClickListener buttonListener = new OnClickListener() { @Override//from w w w. j a va 2 s .com public void onClick(View v) { EditText nameField = (EditText) dialog.findViewById(R.id.dialog_name_field); EditText addressField = (EditText) dialog.findViewById(R.id.dialog_address_field); EditText portField = (EditText) dialog.findViewById(R.id.dialog_port_field); CheckBox sslBox = (CheckBox) dialog.findViewById(R.id.dialog_usessl_checkbox); if (v.getId() == R.id.cancel_button) { nameField.setText(""); addressField.setText(""); portField.setText(""); sslBox.setChecked(false); dialog.dismiss(); } else if (v.getId() == R.id.save_button && !nameField.getText().toString().equals("") && !addressField.getText().toString().equals("") && !portField.getText().toString().equals("")) { String name = nameField.getText().toString().trim(); String address = addressField.getText().toString().trim(); int port = Integer.parseInt(portField.getText().toString().trim()); boolean useSSL = sslBox.isChecked(); //TODO: Ken: mabye add some better check on what state the dialog is used for, edit/add. Atleast use a string from the resources so its the same if you change it. if ((String) dialog.getWindow().getAttributes().getTitle() == "Add new core") { dbHelper.addCore(name, address, port, useSSL); } else if ((String) dialog.getWindow().getAttributes().getTitle() == "Edit core") { dbHelper.updateCore(core.getSelectedItemId(), name, address, port, useSSL); } LoginActivity.this.updateCoreSpinner(); nameField.setText(""); addressField.setText(""); portField.setText(""); sslBox.setChecked(false); dialog.dismiss(); if ((String) dialog.getWindow().getAttributes().getTitle() == "Add new core") { Toast.makeText(LoginActivity.this, "Added core", Toast.LENGTH_LONG).show(); } else if ((String) dialog.getWindow().getAttributes().getTitle() == "Edit core") { Toast.makeText(LoginActivity.this, "Edited core", Toast.LENGTH_LONG).show(); } } } }; dialog.findViewById(R.id.cancel_button).setOnClickListener(buttonListener); dialog.findViewById(R.id.save_button).setOnClickListener(buttonListener); break; case R.id.DIALOG_NEW_CERTIFICATE: AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this); final SharedPreferences certPrefs = getSharedPreferences("CertificateStorage", Context.MODE_PRIVATE); builder.setMessage("Received a new certificate, do you trust it?\n" + hashedCert).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { certPrefs.edit().putString("certificate", hashedCert).commit(); onConnect.onClick(null); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); dialog = builder.create(); break; default: dialog = null; break; } return dialog; }
From source file:dev.datvt.cloudtracks.sound_cloud.LocalTracksFragment.java
public void showChangeLangDialog() { final Dialog dialog = new Dialog(ctx); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false);//w w w . j a v a 2 s . c om dialog.setContentView(R.layout.dialog_create_playlist); final EditText edt = (EditText) dialog.findViewById(R.id.edtInput); final TextView btnCreate = (TextView) dialog.findViewById(R.id.btnCreate); final TextView btnCancel = (TextView) dialog.findViewById(R.id.btnCancel); final ImageView btnDel = (ImageView) dialog.findViewById(R.id.btnDel); btnCreate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ret = edt.getText().toString(); if (ret != null && !ret.isEmpty()) { try { ToolsHelper.createPlaylist(ctx, ret); setUpListPlaylist(); Log.d("CREATE_2", "COMPLETE"); } catch (Exception e) { e.printStackTrace(); } } else { ToolsHelper.toast(ctx, getString(R.string.info_not_name_playlist)); showChangeLangDialog(); } dialog.dismiss(); } }); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ret = null; dialog.cancel(); } }); btnDel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { edt.setText(""); } }); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.show(); }
From source file:com.android.calendar.EventInfoFragment.java
private void applyDialogParams() { Dialog dialog = getDialog(); dialog.setCanceledOnTouchOutside(true); Window window = dialog.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); WindowManager.LayoutParams a = window.getAttributes(); a.dimAmount = .4f;/*from ww w . ja va 2 s . c o m*/ a.width = mDialogWidth; a.height = mDialogHeight; // On tablets , do smart positioning of dialog // On phones , use the whole screen if (mX != -1 || mY != -1) { a.x = mX - mDialogWidth / 2; a.y = mY - mDialogHeight / 2; if (a.y < mMinTop) { a.y = mMinTop + DIALOG_TOP_MARGIN; } a.gravity = Gravity.LEFT | Gravity.TOP; } window.setAttributes(a); }
From source file:com.fitme.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.options, menu); MenuItem mi = menu.findItem(R.id.menu_spinner_active_program); final TextView tv = (TextView) mi.getActionView(); ActiveProgramDAO apd = new ActiveProgramDAO(MainActivity.this); activeProgram = apd.getActiveProgramName(); tv.setText(activeProgram);/* w w w . ja v a 2 s . c o m*/ tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { final Dialog dialog = new Dialog(MainActivity.this); dialog.setTitle(getText(R.string.title_select_prog_dialog)); View programView = getLayoutInflater().inflate(R.layout.programs_list, null); ExpandableListView elv = (ExpandableListView) programView.findViewById(R.id.list_programs); final ProgramListAdapter pda = new ProgramListAdapter(MainActivity.this); elv.setAdapter(pda); // Setting listener for Add Program button Button addProgram = (Button) programView.findViewById(R.id.button_add_program); addProgram.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { onAddProgramRequested(pda); } }); elv.setGroupIndicator(null); elv.setOnGroupClickListener(null); elv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) { pda.setProgramSelected(groupPosition, childPosition); onNewProgramSelected(pda.getSelectedProgramName()); // Refresh trainings section list TrainingsSectionFragment tsf = (TrainingsSectionFragment) mAppSectionsPagerAdapter .getItem(AppSectionsPagerAdapter.SECTION_TRAININGS); tsf.onNewProgramSelected(); dialog.dismiss(); return false; } }); dialog.setContentView(programView); dialog.show(); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); } }); return true; }
From source file:com.example.yudiandrean.socioblood.FeedActivity.java
@SuppressLint("NewApi") @Override/* w w w . j ava2 s .c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Dialog d = new Dialog(context); setContentView(R.layout.feed_activity); postrequest = (TextView) findViewById(R.id.editText); WindowManager manager = (WindowManager) getSystemService(Activity.WINDOW_SERVICE); final int width, height; ActionBar.LayoutParams params; if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { width = manager.getDefaultDisplay().getWidth(); height = manager.getDefaultDisplay().getHeight(); } else { Point point = new Point(); manager.getDefaultDisplay().getSize(point); width = point.x; height = point.y; } session = new SessionManager(getApplicationContext()); // Check if user is already logged in or not if (!session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(FeedActivity.this, LoginActivity.class); startActivity(intent); finish(); } listView = (ListView) findViewById(R.id.list); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeContainer); feedItems = new ArrayList<FeedItem>(); listAdapter = new FeedListAdapter(this, feedItems); listView.setAdapter(listAdapter); swipeRefreshLayout.setOnRefreshListener(this); // add button listener postrequest.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { try { d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setContentView(R.layout.post_request); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(d.getWindow().getAttributes()); lp.width = width; lp.height = height; d.getWindow().setAttributes(lp); } catch (AndroidRuntimeException e) { } catch (Exception e) { } final Spinner rhesusspinner = (Spinner) d.findViewById(R.id.rhesus_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(FeedActivity.this, android.R.layout.simple_spinner_dropdown_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView) v.findViewById(android.R.id.text1)).setText(""); ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount() - 1; // you dont display last item. It is used as hint. } }; adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.add("+"); adapter.add("-"); adapter.add("Rhesus"); rhesusspinner.setAdapter(adapter); rhesusspinner.setSelection(adapter.getCount()); //display hint final Spinner bloodspinner = (Spinner) d.findViewById(R.id.bloodtype_spinner); ArrayAdapter<String> bloodadapter = new ArrayAdapter<String>(FeedActivity.this, android.R.layout.simple_spinner_dropdown_item) { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); if (position == getCount()) { ((TextView) v.findViewById(android.R.id.text1)).setText(""); ((TextView) v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed" } return v; } @Override public int getCount() { return super.getCount() - 1; // you dont display last item. It is used as hint. } }; bloodadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); bloodadapter.add("O"); bloodadapter.add("A"); bloodadapter.add("B"); bloodadapter.add("AB"); bloodadapter.add("Desired Type"); bloodspinner.setAdapter(bloodadapter); bloodspinner.setSelection(bloodadapter.getCount()); //display hint //Buttons-Editexts Button btnpost = (Button) d.findViewById(R.id.post); final EditText userInput = (EditText) d.findViewById(R.id.editTextDialogUserInput); d.show(); btnpost.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (bloodspinner.getSelectedItem().toString().equals("Desired Type")) { Toast.makeText(getApplicationContext(), "Input Blood Type!", Toast.LENGTH_SHORT).show(); } else if (rhesusspinner.getSelectedItem().toString().equals("Rhesus")) { Toast.makeText(getApplicationContext(), "Input Rhesus!", Toast.LENGTH_SHORT).show(); } else if (userInput.getText().toString().equals("")) { Toast.makeText(getApplicationContext(), "Input your request message!", Toast.LENGTH_SHORT).show(); } else { int uid = session.currentUID(); String message = userInput.getText().toString(); String post_bloodtype = bloodspinner.getSelectedItem().toString(); String post_rhesus = rhesusspinner.getSelectedItem().toString(); NetAsync(d, view, uid, message, post_bloodtype, post_rhesus); } } }); } }); // // We first check for cached request // Cache cache = FeedController.getInstance().getRequestQueue().getCache(); // Entry entry = cache.get(URL_FEED); // if (entry != null) { // // fetch the data from cache // try { // String data = new String(entry.data, "UTF-8"); // try { // parseJsonFeed(new JSONObject(data)); // } catch (JSONException e) { // e.printStackTrace(); // } // } catch (UnsupportedEncodingException e) { // e.printStackTrace(); // } // // } else { // making fresh volley request and getting json /** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */ swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(true); getTimelineAsync(); } }); }
From source file:com.gelakinetic.mtgfam.fragments.GatheringCreateFragment.java
protected void showDialog(final int id) { // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here. FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(DIALOG_TAG); if (prev != null) { ft.remove(prev);// w w w. j ava 2s .co m } // Create and show the dialog. FamiliarDialogFragment newFragment = new FamiliarDialogFragment() { public Dialog onCreateDialog(Bundle savedInstanceState) { switch (id) { case DIALOG_SET_NAME: { LayoutInflater factory = LayoutInflater.from(this.getActivity()); final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null); final EditText nameInput = (EditText) textEntryView.findViewById(R.id.player_name); nameInput.setText(proposedGathering); Dialog dialog = new AlertDialog.Builder(this.getActivity()) .setTitle(R.string.gathering_enter_name).setView(textEntryView) .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String gatheringName = nameInput.getText().toString().trim(); if (gatheringName.length() <= 0) { Toast.makeText(mCtx, R.string.gathering_toast_no_name, Toast.LENGTH_LONG) .show(); return; } ArrayList<String> existingGatheringsFiles = gIO.getGatheringFileList(); boolean existing = false; for (String existingGatheringFile : existingGatheringsFiles) { String givenName = gIO.ReadGatheringNameFromXML(existingGatheringFile); if (gatheringName.equals(givenName)) { // throw existing dialog existing = true; proposedGathering = gatheringName; showDialog(DIALOG_GATHERING_EXIST); break; } } if (existingGatheringsFiles.size() <= 0 || existing == false) { SaveGathering(gatheringName); } } }).setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).create(); dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); return dialog; } case DIALOG_GATHERING_EXIST: { LayoutInflater factory2 = LayoutInflater.from(this.getActivity()); final View textEntryView2 = factory2.inflate(R.layout.simple_message_layout, null); final TextView text = (TextView) textEntryView2.findViewById(R.id.message); text.setText(R.string.gathering_dialog_overwrite_text); Dialog dialog = new AlertDialog.Builder(this.getActivity()) .setTitle(R.string.gathering_dialog_overwrite_title).setView(textEntryView2) .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { gIO.DeleteGatheringByName(proposedGathering); SaveGathering(proposedGathering); } }).setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }).create(); return dialog; } default: { savedInstanceState.putInt("id", id); return super.onCreateDialog(savedInstanceState); } } } }; newFragment.show(ft, DIALOG_TAG); }
From source file:com.thingsee.tracker.MainActivity.java
@Override public void onMapReady(GoogleMap map) { mMap = map;// w ww. j a v a 2 s . c o m TileProvider wmsTileProvider = TileProviderFactory.getKapsiWmsTileProvider(); mMap.addTileOverlay(new TileOverlayOptions().tileProvider(wmsTileProvider).fadeIn(true)); initGoogleMap(); trackerList = (HorizontalScrollView) this.findViewById(R.id.tracker_scroll_area); mTrackerItemLayout = (LinearLayout) findViewById(R.id.trackers); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mainari, 16)); Marker mark = mMap.addMarker(new MarkerOptions().position(mainari)); ImageView locateButton = (ImageView) findViewById(R.id.app_icon); //set the ontouch listener locateButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: if (onChildOnMapView) { onUpPressed(); } else { userZoomAndPanOnMap = false; zoomToBoundingBox(); } case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); ImageView settingsButton = (ImageView) findViewById(R.id.header_settings_icon); //set the ontouch listener settingsButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { ImageView view = (ImageView) v; //overlay is black with transparency of 0x77 (119) view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } case MotionEvent.ACTION_UP: final Dialog verificationQuery = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar); verificationQuery.requestWindowFeature(Window.FEATURE_NO_TITLE); verificationQuery.setCancelable(false); verificationQuery.setContentView(R.layout.request_admin_code); ClearTextView ok = (ClearTextView) verificationQuery.findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); EditText code = (EditText) verificationQuery.findViewById(R.id.verification_code); if (code.getText().toString().equalsIgnoreCase("password")) { Intent intent = new Intent(MainActivity.this, MenuActivity.class); startActivity(intent); } } }); ClearTextView cancel = (ClearTextView) verificationQuery.findViewById(R.id.cancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { verificationQuery.dismiss(); } }); verificationQuery.show(); verificationQuery.getWindow().setDimAmount(0.5f); verificationQuery.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); case MotionEvent.ACTION_CANCEL: { ImageView view = (ImageView) v; //clear the overlay view.getDrawable().setColorFilter(mResources.getColor(R.color.white_effect), PorterDuff.Mode.SRC_ATOP); view.invalidate(); break; } } return true; } }); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng position) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } }); mMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { if (trackersActive) { LatLng latlng = marker.getPosition(); userZoomAndPanOnMap = false; if ((latlng.latitude == mainari.latitude) && (latlng.longitude == mainari.longitude)) { if (onChildOnMapView) { if (trackerModelWithMarker != null) { trackerModelWithMarker.getMarker().showInfoWindow(); } } } else { if (!onChildOnMapView) { trackerModelWithMarker = null; // Zoom to marker tapped zoomToMarker(latlng); //Remove other markers for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { focusOnChildOnMap(trackerModel.getSerialNumber()); trackerModelWithMarker = trackerModel; trackerModelWithMarker.getMarker().showInfoWindow(); } } } } else { trackerModelWithMarker.getMarker().showInfoWindow(); for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == latlng.latitude) && (trackerModel.getLatestLatLng().longitude == latlng.longitude)) { onBackPressed(); } } } } } } return true; } }); mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { // Use default InfoWindow frame @Override public View getInfoWindow(Marker arg0) { return null; } // Defines the contents of the InfoWindow @Override public View getInfoContents(Marker arg0) { // Getting view from the layout file info_window_layout View v = null; for (String key : trackers.keySet()) { TrackerModel trackerModel = trackers.get(key); if (trackerModel.getLatestLatLng() != null) { if ((trackerModel.getLatestLatLng().latitude == arg0.getPosition().latitude) && (trackerModel.getLatestLatLng().longitude == arg0.getPosition().longitude)) { v = getLayoutInflater().inflate(R.layout.info_window, null); trackerModelWithMarker = trackerModel; TextView trackerAccuracy = (TextView) v .findViewById(R.id.tracker_marker_popup_accuracy); if (trackerModelWithMarker.getAccuracy() != -1) { trackerAccuracy .setText(String.format(mResources.getString(R.string.tracker_accuracy), trackerModelWithMarker.getAccuracy())); } else { trackerAccuracy.setText( String.format(mResources.getString(R.string.tracker_accuracy), 0.0f)); } TextView trackerDistanceTs = (TextView) v .findViewById(R.id.tracker_marker_popup_update_timestamp); if (trackerModelWithMarker.getLastLocationUpdate() != 0) { String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, trackerModelWithMarker.getLastLocationUpdate()); trackerDistanceTs.setText( mResources.getString(R.string.tracker_timestamp) + " " + timeStampText); } else { trackerDistanceTs.setText(mResources.getString(R.string.tracker_timestamp) + " - "); } trackerInfoWindow = v; } } } // Returning the view containing InfoWindow contents return v; } }); IntentFilter statusIntentFilter = new IntentFilter(CommonConstants.BROADCAST_ACTION); statusIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); mFetchCloudDataStateReceiver = new FetchCloudDataStateReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(mFetchCloudDataStateReceiver, statusIntentFilter); mapLoaded = true; if (splashReady) { mSplashHandler.postDelayed(splashScreenOffFromDisplay, 0); } }
From source file:ua.mkh.settings.full.MainActivity.java
public void update() { final Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); dialog.setContentView(R.layout.activity_update); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; Button ButtonInfo = (Button) dialog.getWindow().findViewById(R.id.button1); TextView time = (TextView) dialog.getWindow().findViewById(R.id.textView1); TextView data = (TextView) dialog.getWindow().findViewById(R.id.textView2); TextView textView3 = (TextView) dialog.getWindow().findViewById(R.id.textView3); TextView textView4 = (TextView) dialog.getWindow().findViewById(R.id.textView4); time.setTypeface(typefaceThin);/* w w w . ja v a 2 s .co m*/ data.setTypeface(typefaceRoman); textView3.setTypeface(typefaceRoman); textView4.setTypeface(typefaceRoman); ButtonInfo.setTypeface(typefaceRoman); ButtonInfo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.bitants.wally.fragments.ImageZoomFragment.java
private void animateIn(final Dialog dialog) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) zoomableImageView.getLayoutParams(); params.width = rect.right;//from ww w.j a v a2 s .c o m params.height = rect.bottom; zoomableImageView.setLayoutParams(params); zoomableImageView.setX(rect.left); zoomableImageView.setY(rect.top - statusBarHeightCorrection); zoomableImageView.setAlpha(0.0f); zoomableImageView.setImageBitmap(bitmap); WindowManager win = getActivity().getWindowManager(); Display d = win.getDefaultDisplay(); int displayWidth = d.getWidth(); // Width of the actual device int displayHeight = d.getHeight() + statusBarHeightCorrection; ValueAnimator animWidth = ValueAnimator.ofInt(rect.right, displayWidth); animWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams(); layoutParams.width = val; zoomableImageView.setLayoutParams(layoutParams); } }); animWidth.setDuration(500); animWidth.setInterpolator(new LinearOutSlowInInterpolator()); animWidth.start(); ValueAnimator animHeight = ValueAnimator.ofInt(rect.bottom, displayHeight); animHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams(); layoutParams.height = val; zoomableImageView.setLayoutParams(layoutParams); } }); animHeight.setDuration(500); animHeight.setInterpolator(new LinearOutSlowInInterpolator()); animHeight.start(); if (statusBarHeightCorrection > 0) { zoomableImageView.animate().y(0.0f).setDuration(300).start(); } ValueAnimator animDim = ValueAnimator.ofFloat(0.0f, 0.5f); animDim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); layoutParams.copyFrom(dialog.getWindow().getAttributes()); layoutParams.dimAmount = (Float) valueAnimator.getAnimatedValue(); dialog.getWindow().setAttributes(layoutParams); } }); animDim.setDuration(300); animDim.setStartDelay(300); animDim.start(); zoomableImageView.animate().alpha(1.0f).setDuration(300).start(); }
From source file:ua.mkh.settings.full.MainActivity.java
private void openDialog() { final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_menu); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; Button ButtonInfo = (Button) dialog.getWindow().findViewById(R.id.button1); ButtonMenuCancel = (Button) dialog.getWindow().findViewById(R.id.ButtonMenuCancel); ButtonMenuSettings = (Button) dialog.getWindow().findViewById(R.id.ButtonMenuSettings); ButtonMenuSettings.setTypeface(typefaceRoman); ButtonMenuCancel.setTypeface(typefaceMedium); ButtonInfo.setTypeface(typefaceRoman); ButtonInfo.setText(R.string.menu_info_main); ButtonMenuCancel.setOnClickListener(new OnClickListener() { @Override/*from w w w . j a v a 2s .c o m*/ public void onClick(View v) { dialog.dismiss(); } }); ButtonMenuSettings.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchIntent(); } }); dialog.show(); }