List of usage examples for android.widget LinearLayout setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.android.nsboc.ComposeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mItem != null) { switch (mItem.id + "") { case "1": mRootView = inflater.inflate(R.layout.form_unlicensed, container, false); break; case "2": mRootView = inflater.inflate(R.layout.form_salon, container, false); break; }/*from w w w . j a v a2s . co m*/ } showCurrentDateInEditText(); ToggleButton complianceToggle = (ToggleButton) mRootView.findViewById(R.id.compliance_toggle); if (complianceToggle != null) { final LinearLayout complianceContainer = (LinearLayout) mRootView .findViewById(R.id.compliance_container); complianceToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (!isChecked) { complianceContainer.setVisibility(View.VISIBLE); final LinearLayout complianceLayout = (LinearLayout) View.inflate(getActivity(), R.layout.compliance_layout, null); Spinner violationTypeSpinner = (Spinner) complianceLayout .findViewById(R.id.violation_type_spinner); violationTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.VISIBLE); break; case 1: complianceLayout.findViewById(R.id.type_citation_container) .setVisibility(View.GONE); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); ToggleButton anotherToggle = (ToggleButton) complianceLayout .findViewById(R.id.compliance_toggle); anotherToggle.setOnCheckedChangeListener(getNextToggleListener(complianceLayout)); complianceContainer.addView(complianceLayout); } else { complianceContainer.setVisibility(View.GONE); } } }); } ToggleButton emailToggle = (ToggleButton) mRootView.findViewById(R.id.emailTo_toggle); if (emailToggle != null) { final LinearLayout emailLayout = (LinearLayout) mRootView.findViewById(R.id.emailTo_layout); emailToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { emailLayout.setVisibility(View.VISIBLE); } else { emailLayout.setVisibility(View.GONE); } } }); } final TextView noticeTextView = (TextView) mRootView.findViewById(R.id.notice_textview); if (noticeTextView != null) { noticeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (noticeTextView.getCurrentTextColor() == Color.BLACK) { noticeTextView.setText(R.string.civil_citation_header); noticeTextView.setTextColor(Color.parseColor("#17405e")); noticeTextView.setText(Html.fromHtml("<u>" + noticeTextView.getText() + "</u>")); mRootView.findViewById(R.id.civil_citation).requestFocus(); } else { noticeTextView.setText(R.string.civil_citation_notice); noticeTextView.setMaxLines(Integer.MAX_VALUE); noticeTextView.setTextColor(Color.BLACK); noticeTextView.setText( noticeTextView.getText().toString().replace("<u>", "").replace("</u>", "")); } } }); } Spinner stateSpinner = (Spinner) mRootView.findViewById(R.id.state); if (stateSpinner != null) { stateSpinner.setSelection(27); } return mRootView; }
From source file:org.openhab.habdroid.ui.OpenHABWidgetSettingsAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { /* TODO: This definitely needs some huge refactoring *///from www . ja v a 2s. c om final int pos = position; RelativeLayout widgetView; TextView labelTextView; ImageView roomEditView; int widgetLayout = 0; OpenHABWidget openHABWidget = getItem(position); switch (this.getItemViewType(position)) { case TYPE_FRAME: widgetLayout = R.layout.openhabwidgetlist_frameitem; break; case TYPE_GROUP: widgetLayout = R.layout.openhabwidget_settings_item; break; case TYPE_IMAGE: widgetLayout = R.layout.openhabwidgetlist_imageitem; break; case TYPE_CHART: widgetLayout = R.layout.openhabwidgetlist_chartitem; break; case TYPE_VIDEO: widgetLayout = R.layout.openhabwidgetlist_videoitem; break; case TYPE_WEB: widgetLayout = R.layout.openhabwidgetlist_webitem; break; default: widgetLayout = R.layout.openhabwidget_settings_item; break; } if (convertView == null) { widgetView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater) getContext().getSystemService(inflater); vi.inflate(widgetLayout, widgetView, true); } else { widgetView = (RelativeLayout) convertView; } switch (getItemViewType(position)) { case TYPE_FRAME: labelTextView = (TextView) widgetView.findViewById(R.id.framelabel); if (labelTextView != null) labelTextView.setText(openHABWidget.getLabel()); widgetView.setClickable(false); if (openHABWidget.getLabel().length() > 0) { // hide empty frames widgetView.setVisibility(View.VISIBLE); labelTextView.setVisibility(View.VISIBLE); } else { widgetView.setVisibility(View.GONE); labelTextView.setVisibility(View.GONE); } break; case TYPE_IMAGE: MySmartImageView imageImage = (MySmartImageView) widgetView.findViewById(R.id.imageimage); imageImage.setImageUrl(ensureAbsoluteURL(openHABBaseUrl, openHABWidget.getUrl()), false); if (openHABWidget.getRefresh() > 0) { imageImage.setRefreshRate(openHABWidget.getRefresh()); refreshImageList.add(imageImage); } break; case TYPE_CHART: MySmartImageView chartImage = (MySmartImageView) widgetView.findViewById(R.id.chartimage); OpenHABItem chartItem = openHABWidget.getItem(); Random random = new Random(); String chartUrl = ""; if (chartItem.getType().equals("GroupItem")) { chartUrl = openHABBaseUrl + "rrdchart.png?groups=" + chartItem.getName() + "&period=" + openHABWidget.getPeriod() + "&random=" + String.valueOf(random.nextInt()); } Log.i("OpenHABWidgetAdapter", "Chart url = " + chartUrl); chartImage.setImageUrl(chartUrl, false); // TODO: This is quite dirty fix to make charts look full screen width on all displays ViewGroup.LayoutParams chartLayoutParams = chartImage.getLayoutParams(); int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getWidth(); chartLayoutParams.height = (int) (screenWidth / 1.88); chartImage.setLayoutParams(chartLayoutParams); if (openHABWidget.getRefresh() > 0) { chartImage.setRefreshRate(openHABWidget.getRefresh()); refreshImageList.add(chartImage); } Log.i("OpenHABWidgetAdapter", "chart size = " + chartLayoutParams.width + " " + chartLayoutParams.height); break; case TYPE_VIDEO: VideoView videoVideo = (VideoView) widgetView.findViewById(R.id.videovideo); Log.i("OpenHABWidgetAdapter", "Opening video at " + openHABWidget.getUrl()); // TODO: This is quite dirty fix to make video look maximum available size on all screens WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); ViewGroup.LayoutParams videoLayoutParams = videoVideo.getLayoutParams(); videoLayoutParams.height = (int) (wm.getDefaultDisplay().getWidth() / 1.77); videoVideo.setLayoutParams(videoLayoutParams); // We don't have any event handler to know if the VideoView is on the screen // so we manage an array of all videos to stop them when user leaves the page if (!videoWidgetList.contains(videoVideo)) videoWidgetList.add(videoVideo); // Start video if (!videoVideo.isPlaying()) { videoVideo.setVideoURI(Uri.parse(openHABWidget.getUrl())); videoVideo.start(); } Log.i("OpenHABWidgetAdapter", "Video height is " + videoVideo.getHeight()); break; case TYPE_WEB: WebView webWeb = (WebView) widgetView.findViewById(R.id.webweb); if (openHABWidget.getHeight() > 0) { ViewGroup.LayoutParams webLayoutParams = webWeb.getLayoutParams(); webLayoutParams.height = openHABWidget.getHeight() * 80; webWeb.setLayoutParams(webLayoutParams); } webWeb.setWebViewClient(new WebViewClient()); webWeb.loadUrl(openHABWidget.getUrl()); break; default: labelTextView = (TextView) widgetView.findViewById(R.id.itemlabel); roomEditView = (ImageView) widgetView.findViewById(R.id.editimg); if (null != roomEditView) { roomEditView.setVisibility(View.VISIBLE); roomEditView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (null != listItemListener) listItemListener.onEditClickListener(pos); } }); } if (labelTextView != null) labelTextView.setText(openHABWidget.getLabel()); MySmartImageView sliderImage = (MySmartImageView) widgetView.findViewById(R.id.itemimage); sliderImage.setImageUrl(openHABBaseUrl + "images/" + openHABWidget.getIcon() + ".png"); break; } LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider); if (dividerLayout != null) { if (position < this.getCount() - 1) { if (this.getItemViewType(position + 1) == TYPE_FRAME) { dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets } else { dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others } } else { // last widget in the list, hide divider dividerLayout.setVisibility(View.GONE); } } return widgetView; }
From source file:com.zhengde163.netguard.ActivityLog.java
@Override public void onSharedPreferenceChanged(SharedPreferences prefs, String name) { Log.i(TAG, "Preference " + name + "=" + prefs.getAll().get(name)); if ("log".equals(name)) { // Get enabled boolean log = prefs.getBoolean(name, false); // Display disabled warning // TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); // tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE); LinearLayout ly = (LinearLayout) findViewById(R.id.lldisable); ly.setVisibility(log ? View.GONE : View.VISIBLE); // Check switch state // SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView().findViewById(R.id.swEnabled); ImageView ivEnabled = (ImageView) findViewById(R.id.ivEnabled); if (ivEnabled != null) { if (log) { ivEnabled.setImageResource(R.drawable.on); } else { ivEnabled.setImageResource(R.drawable.off); }//ww w . java2 s. c o m } // if (swEnabled.isChecked() != log) // swEnabled.setChecked(log); ServiceSinkhole.reload("changed " + name, ActivityLog.this); } }
From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_explain_moshaver); Fabric.with(this, new Crashlytics()); alagestarmoshaver = (ImageView) findViewById(R.id.alagestarmoshaver); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { placeid = ""; } else {//from w w w .j a v a 2 s .com placeid = extras.getString("placeid"); } } else { placeid = (String) savedInstanceState.getSerializable("placeid"); } ImageView imageView1 = (ImageView) findViewById(R.id.backButton); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ExplainMoshaver.this, PageMoshaverin.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } }); final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); ImageView imageView = (ImageView) findViewById(R.id.menuButton); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { drawer.openDrawer(Gravity.END); } }); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(true); nav_Menu.findItem(R.id.nav_login).setVisible(false); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(true); } else { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(false); nav_Menu.findItem(R.id.nav_login).setVisible(true); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(false); } userimg = (ImageView) findViewById(R.id.adviser_image); name_moshaver_textview = (TextView) findViewById(R.id.name_moshaver_textview); //taxassose_moshaver_textview =(TextView) findViewById(R.id.taxassose_moshaver_textview); code_moshaver_textview = (TextView) findViewById(R.id.code_moshaver_textview); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { adviseridm = "0"; } else { adviseridm = extras.getString("adviserid"); } } else { adviseridm = (String) savedInstanceState.getSerializable("adviserid"); } //Toast.makeText(getApplicationContext(), "+"+adviseridm+"+", Toast.LENGTH_LONG).show(); if (isOnline()) { //requestData(); postgetData(); //Log.i("Lieseesene",License); ImageView imageView2 = (ImageView) findViewById(R.id.adviser_about_img); imageView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //requestDataa(); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Intent intent3 = new Intent(ExplainMoshaver.this, PageRezerv.class); intent3.putExtra("adviseridm", adviseridm); intent3.putExtra("placeid", placeid); intent3.putExtra("namemoshaver", namemoshaver); startActivity(intent3); } else { Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_LONG).show(); } } }); // // final ImageView alagestarmarkaz = (ImageView)findViewById(R.id.alagestarmarkaz); alagestarmoshaver.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcpsdcpsdcpsdc"+alagestarmarkaz.getResources()); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { setAlage(); //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcp2sdcpsdcpsdc"+hanyayo); } else { Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_LONG).show(); } } }); ImageView adviser_reserve_img = (ImageView) findViewById(R.id.adviser_reserve_img); adviser_reserve_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final LinearLayout darbareyehuseyin = (LinearLayout) findViewById(R.id.darbareyehuseyin); darbareyehuseyin.setVisibility(View.VISIBLE); TextView textTagsHusseyin = (TextView) findViewById(R.id.textTagsHusseyin); try { textTagsHusseyin.setText(Tagggggggs); ImageView closeafzundanejavab = (ImageView) findViewById(R.id.closeinvisibleimag); closeafzundanejavab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { darbareyehuseyin.setVisibility(View.GONE); } }); } catch (Exception e) { textTagsHusseyin.setText(""); } } }); } else { Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show(); } }
From source file:re.serialout.MainScreen.java
public void resetID(View view) { idSet = false;/* w ww . j a v a2s . c o m*/ LinearLayout linearLayout = (LinearLayout) findViewById(R.id.id_layout); linearLayout.setVisibility(View.VISIBLE); linearLayout = (LinearLayout) findViewById(R.id.options_layout); linearLayout.setVisibility(View.GONE); findViewById(R.id.surveyButton).setVisibility(View.GONE); TextView mainText = (TextView) findViewById(R.id.mainText); mainText.setText("Welcome\nPlease enter your patient ID:"); settings = null; Button activate = (Button) findViewById(R.id.seqButton); if (activate.getVisibility() == View.VISIBLE) { playSine.stop(); mainText.setText("\nPlease Plug in pH Sensor\n"); } activate.setVisibility(View.GONE); }
From source file:re.serialout.MainScreen.java
public void hideIDViews() { //Used to swap out the patient log in screens. LinearLayout linearLayout = (LinearLayout) findViewById(R.id.id_layout); linearLayout.setVisibility(View.GONE); LinearLayout idLayout = (LinearLayout) findViewById(R.id.options_layout); idLayout.setVisibility(View.VISIBLE); findViewById(R.id.surveyButton).setVisibility(View.VISIBLE); TextView mainText = (TextView) findViewById(R.id.mainText); mainText.setText("Hello, Patient: " + idText + "!\nPlease plug in your sensor or take a survey."); Button activate = (Button) findViewById(R.id.seqButton); if (deviceConnected) { playSine.start();//www .ja v a 2 s .co m System.out.println("Play Sine told to start"); if (!commandInterface.setUp) new LongOperation().execute(); else { activate.setVisibility(View.VISIBLE); findViewById(R.id.progressBar).setVisibility(View.GONE); mainText.setText("\nSensor Ready!\n"); activate.setText("Activate Device"); } } // } }
From source file:org.openhab.habdroid.ui.OpenHABWidgetArrayAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewData preparedViewData = new ViewData(); int widgetLayout; preparedViewData.openHABWidget = getItem(position); switch (mWidgetLayoutType) { case IconTextControlList: widgetLayout = mWidgetTypeLayoutProvider.getRowLayoutId(preparedViewData.openHABWidget.getType()); break;//from w ww . ja va 2 s . c o m default: widgetLayout = R.layout.openhabwidgetlist_generic_controlless_item; break; } if (convertView == null) { preparedViewData.widgetView = new RelativeLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi; vi = (LayoutInflater) getContext().getSystemService(inflater); try { vi.inflate(widgetLayout, preparedViewData.widgetView, true); } catch (Exception ex) { Log.w("OpenHABWidgetArrayAdapt", String.format("'%s' of type '%s' cannot get inflated in widget list", preparedViewData.openHABWidget, preparedViewData.openHABWidget.getType()), ex); } } else { preparedViewData.widgetView = (RelativeLayout) convertView; } processIconImage(preparedViewData.widgetView, preparedViewData.openHABWidget); preparedViewData.labelTextView = getLabelTextView(preparedViewData.widgetView, preparedViewData.openHABWidget); preparedViewData.valueTextView = getValueTextView(preparedViewData.widgetView, preparedViewData.openHABWidget); View widgetView = null; if (mWidgetLayoutType == WidgetLayoutType.IconTextList) { widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget(); preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel()); return widgetView; } switch (preparedViewData.openHABWidget.getType()) { case Frame: widgetView = new OpenHABFrameWidget(this, preparedViewData).getWidget(); break; case Group: widgetView = new OpenHABGroupWidget(this, preparedViewData).getWidget(); break; case SelectionSwitch: widgetView = new OpenHABSelectionSwitchWidget(this, preparedViewData).getWidget(); break; case Switch: widgetView = new OpenHABSwitchWidget(this, preparedViewData).getWidget(); break; case Color: widgetView = new OpenHABColorWidget(this, preparedViewData).getWidget(); break; case RollerShutter: widgetView = new OpenHABRollerShutterWidget(this, preparedViewData).getWidget(); break; case ItemText: case SitemapText: widgetView = new OpenHABTextWidget(this, preparedViewData).getWidget(); break; case Slider: widgetView = new OpenHABSliderWidget(this, preparedViewData).getWidget(); break; case Image: widgetView = new OpenHABImageWidget(refreshImageList, this, preparedViewData).getWidget(); break; case Chart: int screenWidth = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getWidth(); widgetView = new OpenHABChartWidget(screenWidth, refreshImageList, this, preparedViewData).getWidget(); break; case Video: widgetView = new OpenHABVideoWidget(this.getContext(), videoWidgetList, this, preparedViewData) .getWidget(); break; case Web: widgetView = new OpenHABWebWidget(this, preparedViewData).getWidget(); break; case Selection: widgetView = new OpenHABSelectionWidget(this.getContext(), this, preparedViewData).getWidget(); break; case Setpoint: widgetView = new OpenHABSetpointWidget(this.getContext(), this, preparedViewData).getWidget(); break; default: if (preparedViewData.labelTextView != null) preparedViewData.labelTextView.setText(preparedViewData.openHABWidget.getLabel()); break; } LinearLayout dividerLayout = (LinearLayout) widgetView.findViewById(R.id.listdivider); if (dividerLayout != null) { if (position < this.getCount() - 1/* || !mWidgetLayoutType.equals(WidgetLayoutType.IconTextList)*/) { if (getItem(position + 1).getType() == OpenHABWidgetType.Frame) { dividerLayout.setVisibility(View.GONE); // hide dividers before frame widgets } else { dividerLayout.setVisibility(View.VISIBLE); // show dividers for all others } } else { // last widget in the list, hide divider dividerLayout.setVisibility(View.GONE); } } return widgetView; }
From source file:org.egov.android.view.activity.RegisterActivity.java
/** * It is used to initialize an activity. An Activity is an application component that provides a * screen with which users can interact in order to do something, To initialize the * RegisterActivity.Set click listener to the save button. *///from w w w.ja v a 2 s . c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); ((Button) findViewById(R.id.register_doRegister)).setOnClickListener(this); ((Button) findViewById(R.id.btngotit)).setOnClickListener(this); sharedpreferences = getApplicationContext().getSharedPreferences(getString(R.string.app_name), 0); // 0 - for private mode if (AndroidLibrary.getInstance().getConfig().get("api.multicities", "false").equals("true")) { isMulticity = true; Spinner citydropdown = (Spinner) findViewById(R.id.citydropdown); if (isInternetAvailable()) { new getCitiesFromURL(RegisterActivity.this, citydropdown) .execute(AndroidLibrary.getInstance().getConfig().getString("app.citiesJsonUrl")); } else { Toast.makeText(getApplicationContext(), "No Internet Connection!", Toast.LENGTH_LONG).show(); this.finish(); } } else { ((LinearLayout) findViewById(R.id.citydropdowncontainer)).setVisibility(View.GONE); baseServerURL = sharedpreferences.getString("api.baseUrl", null); } LinearLayout viewpwd = (LinearLayout) findViewById(R.id.passwordmsgcontainer); if (!sharedpreferences.getBoolean("register.pwdinfo", false)) { ((TextView) findViewById(R.id.passwordmsg)).setText(getPasswordConstraintInformation()); viewpwd.setVisibility(View.VISIBLE); } else { viewpwd.setVisibility(View.GONE); } //name validation ((EditText) findViewById(R.id.register_name)).setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence src, int start, int end, Spanned dst, int dstart, int dend) { if (src.equals("")) { // for backspace return src; } if (src.toString().matches("[a-zA-Z ]+")) { return src; } return ""; } } }); }
From source file:com.mischivous.wormysharpyloggy.wsl.GameScreen.java
/** * Handles pause and unpause game logic, largely blanking the screen. * @param v The pause button, ignorable// w w w . j av a2s .c o m */ public void PauseAndUnpause(@Nullable View v) { Button b = (Button) findViewById(R.id.gamePause); LinearLayout l = (LinearLayout) findViewById(R.id.Board); int viz; // Common operations for pause/unpause between modes - blank and unblank board, // start and stop timer, change text on button if (game.IsPaused()) { viz = View.VISIBLE; game.UnpauseTimer(); l.setVisibility(viz); b.setText(R.string.pause); } else { viz = View.INVISIBLE; l.setVisibility(View.INVISIBLE); game.PauseTimer(); b.setText(R.string.unpause); } // Blank and unblank the found sets for normal/Time Attack modes, // blank and unblank the join for PowerSet mode if (game.GetGameType() == GameType.Normal || game.GetGameType() == GameType.TimeAttack) { for (int set = 1; set <= game.GetFullSetCount(); set++) { for (int tile = 1; tile <= 3; tile++) { int id = getResources().getIdentifier(String.format("FoundSet%d_%d", set, tile), "id", getPackageName()); findViewById(id).setVisibility(viz); } } } else { findViewById(R.id.joinImage).setVisibility(viz); } }
From source file:com.vkassin.mtrade.Common.java
public static void login(final Context ctx) { // ctx = Common.app_ctx; Common.connected = false;/*from ww w. java2 s .c om*/ 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); }