List of usage examples for android.app Dialog setContentView
public void setContentView(@NonNull View view)
From source file:com.z3r0byte.magistify.DashboardActivity.java
private void relogin() { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.fragment_login); dialog.setTitle(R.string.msg_relogin); Button button = (Button) dialog.findViewById(R.id.button_login); button.setOnClickListener(new View.OnClickListener() { @Override/* w w w .j a v a 2 s. c om*/ public void onClick(View view) { new Thread(new Runnable() { @Override public void run() { Looper.prepare(); EditText usertxt = (EditText) dialog.findViewById(R.id.edit_text_username); EditText passwordtxt = (EditText) dialog.findViewById(R.id.edit_text_password); String username = usertxt.getText().toString(); String password = passwordtxt.getText().toString(); School school = new Gson().fromJson(configUtil.getString("School"), School.class); try { Magister magister = Magister.login(school, username, password); } catch (final IOException | NullPointerException e) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DashboardActivity.this, R.string.err_no_connection, Toast.LENGTH_SHORT).show(); } }); return; } catch (ParseException e) { e.printStackTrace(); runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DashboardActivity.this, R.string.err_unknown, Toast.LENGTH_SHORT) .show(); } }); return; } catch (InvalidParameterException e) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(DashboardActivity.this, R.string.err_wrong_username_or_password, Toast.LENGTH_SHORT).show(); } }); return; } Log.d(TAG, "onClick: login succeeded!"); User user = new User(username, password, false); configUtil.setString("User", new Gson().toJson(user)); configUtil.setInteger("failed_auth", 0); GlobalAccount.USER = user; dialog.dismiss(); } }).start(); } }); dialog.show(); }
From source file:com.beza.briver.fragments.ProfileFragment.java
private void showDocumentsAttachmentCustomDialog() { final Dialog customAttachmentsDialog = new Dialog(getActivity()); customAttachmentsDialog.setContentView(R.layout.layout_custom_attachment_dialog); customAttachmentsDialog.setCancelable(false); customAttachmentsDialog.setTitle("Attach Documents"); Button buttonNo = (Button) customAttachmentsDialog.findViewById(R.id.btn_driver_hire_dialog_cancel); buttonNo.setOnClickListener(new View.OnClickListener() { @Override/*ww w . j a va 2 s .co m*/ public void onClick(View v) { customAttachmentsDialog.dismiss(); } }); Button buttonYes = (Button) customAttachmentsDialog.findViewById(R.id.btn_driver_hire_dialog_hire); buttonYes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (imageChanged) { customAttachmentsDialog.dismiss(); etProfileAttachments.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_edit_text_attachment, 0, R.mipmap.ic_edit_text_add_image, 0); File destination = new File(Environment.getExternalStorageDirectory() + File.separator + "Android/data" + File.separator + AppGlobals.getContext().getPackageName()); for (int i = 0; i < 3; i++) { if (hashMapTemp.containsKey(i)) { File file = new File(destination, i + ".jpg"); file.delete(); File from = new File(destination, i + "temp" + ".jpg"); File to = new File(destination, i + ".jpg"); from.renameTo(to); } } Log.i("images array", String.valueOf(imagePathsArray)); imageChanged = false; } else { Toast.makeText(getActivity(), "No Change to submit", Toast.LENGTH_SHORT).show(); } } }); ibPhotoOne = (ImageButton) customAttachmentsDialog.findViewById(R.id.ib_photo_one); ibPhotoTwo = (ImageButton) customAttachmentsDialog.findViewById(R.id.ib_photo_two); ibPhotoThree = (ImageButton) customAttachmentsDialog.findViewById(R.id.ib_photo_three); ibPhotoOne.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ibPosition = 0; Helpers.AlertDialogWithPositiveNegativeFunctionsNeutralButton(getActivity(), "License Front", "Select an option to add photo", "Camera", "Gallery", "Cancel", openCameraIntent, openGalleryIntent); } }); ibPhotoTwo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ibPosition = 1; Helpers.AlertDialogWithPositiveNegativeFunctionsNeutralButton(getActivity(), "License Back", "Select an option to add photo", "Camera", "Gallery", "Cancel", openCameraIntent, openGalleryIntent); } }); ibPhotoThree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ibPosition = 2; Helpers.AlertDialogWithPositiveNegativeFunctionsNeutralButton(getActivity(), "Police Verification", "Select an option to add photo", "Camera", "Gallery", "Cancel", openCameraIntent, openGalleryIntent); } }); ibPhotoOne.setBackgroundDrawable(null); ibPhotoOne.setImageBitmap(Helpers.getCroppedBitmap( Helpers.getResizedBitmapToDisplay(BitmapFactory.decodeFile(hashMap.get(0)), 120))); ibPhotoTwo.setBackgroundDrawable(null); ibPhotoTwo.setImageBitmap(Helpers.getCroppedBitmap( Helpers.getResizedBitmapToDisplay(BitmapFactory.decodeFile(hashMap.get(1)), 120))); ibPhotoThree.setBackgroundDrawable(null); ibPhotoThree.setImageBitmap(Helpers.getCroppedBitmap( Helpers.getResizedBitmapToDisplay(BitmapFactory.decodeFile(hashMap.get(2)), 120))); customAttachmentsDialog.show(); }
From source file:com.nextgis.ngm_clink_monitoring.dialogs.YesNoDialog.java
@NonNull @Override// w w w .ja va2 s .c o m public Dialog onCreateDialog(Bundle savedInstanceState) { // Idea from here // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html Dialog dialog = new Dialog(getActivity()); Window window = dialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setContentView(R.layout.dialog_yes_no); mIcon = (ImageView) dialog.findViewById(R.id.title_icon); mTitle = (TextView) dialog.findViewById(R.id.title_text); mDialogBodyScroll = (ScrollView) dialog.findViewById(R.id.dialog_body_scroll); mDialogBodyLayoutScrolled = (LinearLayout) dialog.findViewById(R.id.dialog_body_scrolled); mDialogBodyLayout = (LinearLayout) dialog.findViewById(R.id.dialog_body); mButtons = (TableLayout) dialog.findViewById(R.id.dialog_buttons_yn); mBtnPositive = (Button) dialog.findViewById(R.id.dialog_btn_positive_yn); mBtnNegative = (Button) dialog.findViewById(R.id.dialog_btn_negative_yn); if (null != mIconId) { mIcon.setVisibility(View.VISIBLE); mIcon.setImageResource(mIconId); } if (null != mTitleId) { mTitle.setText(mTitleId); } if (null != mTitleText) { mTitle.setText(mTitleText); } if (null != mMessageId) { setMessageView(); mMessage.setText(mMessageId); } if (null != mMessageText) { setMessageView(); mMessage.setText(mMessageText); } if (null != mView) { if (mAddScrollForView) { mDialogBodyScroll.setVisibility(View.VISIBLE); mDialogBodyLayoutScrolled.addView(mView); } else { mDialogBodyLayout.setVisibility(View.VISIBLE); mDialogBodyLayout.addView(mView); } } if (null != mPositiveTextId) { mButtons.setVisibility(View.VISIBLE); mBtnPositive.setVisibility(View.VISIBLE); mBtnPositive.setText(mPositiveTextId); } if (null != mPositiveText) { mButtons.setVisibility(View.VISIBLE); mBtnPositive.setVisibility(View.VISIBLE); mBtnPositive.setText(mPositiveText); } if (null != mNegativeTextId) { mButtons.setVisibility(View.VISIBLE); mBtnNegative.setVisibility(View.VISIBLE); mBtnNegative.setText(mNegativeTextId); } if (null != mNegativeText) { mButtons.setVisibility(View.VISIBLE); mBtnNegative.setVisibility(View.VISIBLE); mBtnNegative.setText(mNegativeText); } if (null != mOnPositiveClickedListener) { mButtons.setVisibility(View.VISIBLE); mBtnPositive.setVisibility(View.VISIBLE); mBtnPositive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mOnPositiveClickedListener) { mOnPositiveClickedListener.onPositiveClicked(); } dismiss(); } }); } if (null != mOnNegativeClickedListener) { mButtons.setVisibility(View.VISIBLE); mBtnNegative.setVisibility(View.VISIBLE); mBtnNegative.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mOnNegativeClickedListener) { mOnNegativeClickedListener.onNegativeClicked(); } dismiss(); } }); } return dialog; }
From source file:de.dmxcontrol.activity.ControlActivity.java
private Dialog createSplashDialog() { Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); dialog.setContentView(R.layout.dialog_splash); ImageView image = (ImageView) dialog.findViewById(R.id.image_splash); image.setImageResource(R.drawable.image_splash); AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(500);//from w ww .ja v a2s . com animation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); set.addAnimation(animation); animation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(1000); animation.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); set.addAnimation(animation); image.setAnimation(set); dismissSplashDelayed(); return dialog; }
From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java
/** * Dialog/*w w w . j a va 2s . c o m*/ * * @param mContext * @return */ private Dialog showInputPasswordDialog(final Context mContext) { View convertView = LayoutInflater.from(mContext).inflate(R.layout.fragment_right_control, null); tv_forget_psw = (TextView) convertView.findViewById(R.id.tv_forget_psw); tv_forget_psw.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mContext.startActivity(new Intent(mContext, MyModifyPasswordActivity.class)); } }); inputView = (GridPasswordView) convertView.findViewById(R.id.pswView); inputView.setOnPasswordChangedListener(new GridPasswordView.OnPasswordChangedListener() { @Override public void onChanged(String psw) { } @Override public void onMaxLength(String psw) { if (onPasswordDialogClickListener != null) { onPasswordDialogClickListener.getPassword(psw); } } }); final Dialog dialog = new Dialog(mContext, R.style.CustomDialog); // dialog.setCanceledOnTouchOutside(false);//?? dialog.setContentView(convertView); dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style); //dialog dialog.setOnShowListener(new android.content.DialogInterface.OnShowListener() { @Override public void onShow(final android.content.DialogInterface dialog) { new AsyncTask<Integer, Void, Void>() { @Override protected Void doInBackground(Integer... params) { try { Thread.sleep(params[0]); } catch (InterruptedException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void value) { super.onPostExecute(value); if (outerDialog.isShowing()) if (inputView != null) { inputView.requestFocus(); InputMethodManager imm = (InputMethodManager) inputView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED); } } }.execute(600); } }); outerDialog = dialog; return dialog; }
From source file:com.inc.playground.playgroundApp.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); globalVariables = ((GlobalVariables) getApplication()); // Set up the action bar. final ActionBar actionBar = getActionBar(); setPlayGroundActionBar();/* w ww. j a v a2 s .c om*/ //set actionBar color actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.primaryColor))); actionBar.setStackedBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.secondaryColor))); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. //actionBar.setHomeButtonEnabled(false); actionBar.setDisplayShowHomeEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab(actionBar.newTab().setTabListener(this)); } actionBar.getTabAt(0).setIcon(R.drawable.pg_list_view); actionBar.getTabAt(1).setIcon(R.drawable.pg_map_view); //NavigationDrawer handling (e.g the list from leftside): mTitle = mDrawerTitle = getTitle(); mDrawerLayout = (DrawerLayout) findViewById(R.id.menu_layout); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.pg_menu, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); getActionBar().setTitle(mTitle); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getActionBar().setTitle(mDrawerTitle); } }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.closeDrawers(); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // all linear layout from slider menu /*Home button */ LinearLayout ll_Home = (LinearLayout) findViewById(R.id.ll_home); ll_Home.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // new changes Intent iv = new Intent(MainActivity.this, MainActivity.class); startActivity(iv); finish(); } }); /*Login button */ LinearLayout ll_Login = (LinearLayout) findViewById(R.id.ll_login); ll_Login.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // new changes LinearLayout ll_Login = (LinearLayout) v; TextView loginTxt = (TextView) findViewById(R.id.login_txt); if (loginTxt.getText().equals("Login")) { Intent iv = new Intent(MainActivity.this, Login.class); startActivity(iv); finish(); } else if (loginTxt.getText().equals("Logout")) { final Dialog alertDialog = new Dialog(MainActivity.this); alertDialog.setContentView(R.layout.logout_dilaog); alertDialog.setTitle("Logout"); alertDialog.findViewById(R.id.ok_btn).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.clear(); editor.commit(); ImageView loginImg = (ImageView) findViewById(R.id.login_img); TextView loginTxt = (TextView) findViewById(R.id.login_txt); loginTxt.setText("Login"); loginImg.setImageResource(R.drawable.pg_action_lock_open); globalVariables = ((GlobalVariables) getApplication()); globalVariables.SetCurrentUser(null); globalVariables.SetUserPictureBitMap(null); globalVariables.SetUsersList(null); globalVariables.SetUsersImagesMap(null); Util.clearCookies(getApplicationContext()); Intent iv = new Intent(MainActivity.this, MainActivity.class); startActivity(iv); finish(); } }); alertDialog.findViewById(R.id.cancel_btn).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent iv = new Intent(MainActivity.this, MainActivity.class); startActivity(iv); finish(); } }); alertDialog.show(); //<-- See This! } } }); // // /*Setting button*/ // LinearLayout ll_Setting = (LinearLayout) findViewById(R.id.ll_settings); // ll_Setting.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // // TODO Auto-generated method stub // // new changes // Intent iv = new Intent(MainActivity.this, // com.inc.playground.playgroundApp.upLeft3StripesButton. // SettingsActivity.class); // startActivity(iv); // finish(); // } // }); /*My profile button*/ LinearLayout ll_my_profile = (LinearLayout) findViewById(R.id.ll_my_profile); ll_my_profile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // new changes globalVariables = ((GlobalVariables) getApplication()); User currentUser = globalVariables.GetCurrentUser(); if ((currentUser == null) || (currentUser != null && currentUser.GetUserId() == null)) { Toast.makeText(MainActivity.this, "You are not logged in", Toast.LENGTH_LONG).show(); } else { Intent iv = new Intent(MainActivity.this, com.inc.playground.playgroundApp.upLeft3StripesButton.MyProfile.class); //for my profile iv.putExtra("name", currentUser.getName()); iv.putExtra("createdNumOfEvents", currentUser.getCreatedNumOfEvents()); //pass events iv.putExtra("events", currentUser.getEvents()); iv.putExtra("events_wait4approval", currentUser.getEvents_wait4approval()); iv.putExtra("events_decline", currentUser.getEvents_decline()); iv.putExtra("photoUrl", currentUser.getPhotoUrl()); startActivity(iv); // } } }); LinearLayout ll_aboutUs = (LinearLayout) findViewById(R.id.ll_about); ll_aboutUs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // new changes Intent iv = new Intent(MainActivity.this, AboutUs.class); startActivity(iv); finish(); } }); }
From source file:com.vkassin.mtrade.Common.java
public static void login(final Context ctx) { // ctx = Common.app_ctx; Common.connected = false;// ww w.jav a2s . c o m if (inLogin) return; inLogin = true; if (Common.mainActivity != null) Common.mainActivity.handler.sendMessage( Message.obtain(Common.mainActivity.handler, Common.mainActivity.DISMISS_PROGRESS_DIALOG)); // while(true) { final Dialog dialog = new Dialog(ctx); dialog.setContentView(R.layout.login_dialog); dialog.setTitle(R.string.LoginDialogTitle); dialog.setCancelable(false); final EditText nametxt = (EditText) dialog.findViewById(R.id.loginnameedit); final EditText passtxt = (EditText) dialog.findViewById(R.id.passwordedit); final EditText passtxt1 = (EditText) dialog.findViewById(R.id.passwordedit1); final EditText passtxt2 = (EditText) dialog.findViewById(R.id.passwordedit2); final EditText mailtxt = (EditText) dialog.findViewById(R.id.emailedit2); String nam = myaccount.get("name"); Common.oldName = nam; if (nam != null) { nametxt.setText(nam); passtxt.requestFocus(); } Button customDialog_Register = (Button) dialog.findViewById(R.id.goregister); customDialog_Register.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { dialog.setTitle(R.string.LoginDialogTitle1); final LinearLayout layreg = (LinearLayout) dialog.findViewById(R.id.reglayout354); layreg.setVisibility(View.VISIBLE); final LinearLayout laylog = (LinearLayout) dialog.findViewById(R.id.loginlayout543); laylog.setVisibility(View.GONE); } }); Button customDialog_Register1 = (Button) dialog.findViewById(R.id.goregister1); customDialog_Register1.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { if (mailtxt.getText().length() < 1) { Toast toast = Toast.makeText(mainActivity, R.string.CorrectEmail, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); return; } if (passtxt1.getText().length() < 1) { Toast toast = Toast.makeText(mainActivity, R.string.CorrectPassword, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); return; } if (!passtxt2.getText().toString().equals(passtxt1.getText().toString())) { Toast toast = Toast.makeText(mainActivity, R.string.CorrectPassword1, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); return; } try { Socket sock = new Socket(ip_addr, port_register); JSONObject msg = new JSONObject(); msg.put("objType", Common.MSG_REGISTER); msg.put("time", Calendar.getInstance().getTimeInMillis()); msg.put("user", mailtxt.getText().toString()); msg.put("passwd", passtxt1.getText().toString()); msg.put("version", Common.PROTOCOL_VERSION); msg.put("sign", sign(mailtxt.getText().toString(), passtxt1.getText().toString())); byte[] array = msg.toString().getBytes(); ByteBuffer buff = ByteBuffer.allocate(array.length + 4); buff.putInt(array.length); buff.put(array); sock.getOutputStream().write(buff.array()); ByteBuffer buff1 = ByteBuffer.allocate(4); buff1.put(readMsg(sock.getInputStream(), 4)); buff1.position(0); int pkgSize = buff1.getInt(); // Log.i(TAG, "size = "+pkgSize); String s = new String(readMsg(sock.getInputStream(), pkgSize)); sock.close(); JSONObject jo = new JSONObject(s); Log.i(TAG, "register answer = " + jo); int t = jo.getInt("status"); switch (t) { case 1: Toast toast = Toast.makeText(mainActivity, R.string.RegisterStatus1, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); dialog.setTitle(R.string.LoginDialogTitle); final LinearLayout layreg = (LinearLayout) dialog.findViewById(R.id.reglayout354); layreg.setVisibility(View.GONE); final LinearLayout laylog = (LinearLayout) dialog.findViewById(R.id.loginlayout543); laylog.setVisibility(View.VISIBLE); nametxt.setText(mailtxt.getText()); break; case -2: Toast toast1 = Toast.makeText(mainActivity, R.string.RegisterStatus3, Toast.LENGTH_LONG); toast1.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast1.show(); break; default: Toast toast2 = Toast.makeText(mainActivity, R.string.RegisterStatus2, Toast.LENGTH_LONG); toast2.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast2.show(); break; } } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "Error in registration process!!", e); Toast toast = Toast.makeText(mainActivity, R.string.ConnectError, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show(); } } }); Button customDialog_CancelReg = (Button) dialog.findViewById(R.id.cancelreg); customDialog_CancelReg.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { dialog.setTitle(R.string.LoginDialogTitle); final LinearLayout layreg = (LinearLayout) dialog.findViewById(R.id.reglayout354); layreg.setVisibility(View.GONE); final LinearLayout laylog = (LinearLayout) dialog.findViewById(R.id.loginlayout543); laylog.setVisibility(View.VISIBLE); } }); Button customDialog_Dismiss = (Button) dialog.findViewById(R.id.gologin); customDialog_Dismiss.setOnClickListener(new Button.OnClickListener() { public void onClick(View arg0) { final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.lradio0); Common.isSSL = bu0.isChecked(); inLogin = false; JSONObject msg = new JSONObject(); try { msg.put("objType", Common.LOGOUT); msg.put("time", Calendar.getInstance().getTimeInMillis()); msg.put("version", Common.PROTOCOL_VERSION); msg.put("status", 1); mainActivity.writeJSONMsg(msg); } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "Error! Cannot create JSON logout object", e); } myaccount.put("name", nametxt.getText().toString()); myaccount.put("password", passtxt.getText().toString()); Log.i(TAG, "myaccount username: " + myaccount.get("name") + " password: " + myaccount.get("password")); dialog.dismiss(); mainActivity.stop(); // saveAccountDetails(); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } loginFromDialog = true; // mainActivity.refresh(); Common.keypassword(ctx); } }); dialog.show(); // Common.confChanged = false; // }//while(true); }
From source file:no.barentswatch.fiskinfo.MapActivity.java
/** * /* ww w. j av a 2s. co m*/ */ public void showMapLayersDialog() { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); dialog.setContentView(R.layout.dialog_select_map_layers); final LinearLayout mapLayerLayout = (LinearLayout) dialog.findViewById(R.id.map_layers_checkbox_layout); Button okButton = (Button) dialog.findViewById(R.id.dismiss_dialog_button); Button cancelButton = (Button) dialog.findViewById(R.id.go_to_map_button); for (int i = 0; i < 5; i++) { View mapLayerRow = getMapLayerCheckBoxRow(getContext(), Integer.toString(i)); mapLayerLayout.addView(mapLayerRow); } okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < mapLayerLayout.getChildCount(); i++) { if (((CheckBox) ((TableRow) mapLayerLayout.getChildAt(i)).getChildAt(0)).isChecked()) { // TODO: Add layer to list } } // TODO: Implement logic for adding map layers here. dialog.dismiss(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.setTitle(R.string.choose_map_layers); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
From source file:com.popdeem.sdk.uikit.fragment.PDUIRewardsFragment.java
private void performRewardClick(View view) { final int position = recyclerView.getChildAdapterPosition(view); if (position == RecyclerView.NO_POSITION) { return;/* ww w . j av a2 s .c om*/ } final PDReward reward = mRewards.get(position); // if(BuildConfig.DEBUG){ // showDebugGratitude(reward.getId()); // return; // } if (reward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_NONE)) { final Dialog dialog = new Dialog(getActivity()); PDUIDialogUtils.setMargins(dialog, 25, 100, 25, 100); dialog.setContentView(R.layout.claim_alert_dialog); Button claim = (Button) dialog.findViewById(R.id.button_claim); Button cancel = (Button) dialog.findViewById(R.id.button_cancel); ImageView icon = (ImageView) dialog.findViewById(R.id.icon); String imageUrl = reward.getCoverImage(); if (imageUrl == null || imageUrl.isEmpty() || imageUrl.contains("default")) { Glide.with(getActivity()).load(R.drawable.pd_ui_star_icon).dontAnimate() .error(R.drawable.pd_ui_star_icon).dontAnimate().placeholder(R.drawable.pd_ui_star_icon) .into(icon); } else { Glide.with(getActivity()).load(imageUrl).dontAnimate().error(R.drawable.pd_ui_star_icon) .dontAnimate().placeholder(R.drawable.pd_ui_star_icon).into(icon); } claim.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); claimNoActionReward(position, reward); } }); cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); } }); TextView tvTitle = dialog.findViewById(R.id.alertTitle); tvTitle.setText(reward.getDescription()); TextView message = dialog.findViewById(R.id.message); message.setText(reward.getRules()); dialog.show(); } else if (!reward.getAction().equalsIgnoreCase(PDReward.PD_REWARD_ACTION_SOCIAL_LOGIN)) { Intent intent = new Intent(getActivity(), PDUIClaimActivity.class); intent.putExtra("reward", new Gson().toJson(reward, PDReward.class)); startActivityForResult(intent, PD_CLAIM_REWARD_REQUEST_CODE); } }