List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); context = getApplicationContext();//from w w w.ja v a 2 s. c om checkUpdate(); Request.client.setUserAgent("Dodo Shoutboxapp"); myCookieStore = new PersistentCookieStore(this); Request.client.setCookieStore(myCookieStore); Usernamefield = (TextView) findViewById(R.id.txtUsername); Sendbutton = (Button) findViewById(R.id.cmdSend); Refreshbutton = (Button) findViewById(R.id.cmdRefresh); pbReadChat = (ProgressBar) findViewById(R.id.pbReadChat); lblVerlauf = (TextView) findViewById(R.id.lblVerlauf); lblAutoRefresh = (TextView) findViewById(R.id.lblAutorefresh); if (UserData.readPref("textsize", this).equals("")) { UserData.writePref("textsize", "10", this); } if (UserData.readPref("refreshcircle", this).equals("")) { UserData.writePref("refreshcircle", "1", this); refreshanimation = 1; } else if (UserData.readPref("refreshcircle", this).equals("1")) { refreshanimation = 1; } /* * if(UserData.readPref("changechatdirection", this).equals("")) { * UserData.writePref("changechatdirection", "0", this); } else * if(UserData.readPref("changechatdirection", this).equals("1")) { * changechatdirection = 1; } */ if (UserData.readPref("showtime", this).equals("")) { UserData.writePref("showtime", "1", this); } else { showTime = Integer.valueOf(UserData.readPref("showtime", this)); } if (!UserData.readPref("username", this).equals("")) { Usernamefield.setText(UserData.readPref("username", this)); } if (!UserData.readPref("autorefresh", this).equals("")) { Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh); TextView lblARefresh = (TextView) findViewById(R.id.lblAutorefresh); cmdRefresh.setVisibility(Button.INVISIBLE); lblARefresh.setVisibility(TextView.VISIBLE); Toast.makeText(this, "Automatisches Laden aktiviert!", Toast.LENGTH_SHORT).show(); autorefresh = 1; } if (UserData.readPref("ar_intervall", this).equals("")) { UserData.writePref("ar_intervall", "30000", this); } setTextSize(); setCookies(); final Button cmdSend = (Button) findViewById(R.id.cmdSend); if (requireLogin == 1 && loggedIn == 0) { cmdSend.setEnabled(false); cmdSend.setText("Zuerst einloggen!"); } cmdSend.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); send(); } }); final Button cmdRefresh = (Button) findViewById(R.id.cmdRefresh); cmdRefresh.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { getRequest(baseUrl + "index.php?page=ShoutboxEntryXMLList"); } }); final Button cmdMenu = (Button) findViewById(R.id.cmdMenu); cmdMenu.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager inputManager = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // openOptionsMenu(); Intent myIntent2 = new Intent(getApplicationContext(), Settings2.class); startActivityForResult(myIntent2, 0); } }); TextView lblVerlauf = (TextView) findViewById(R.id.lblVerlauf); lblVerlauf.setMovementMethod(LinkMovementMethod.getInstance()); lblVerlauf.setMovementMethod(new ScrollingMovementMethod()); }
From source file:com.amrutpatil.makeanote.NotesActivity.java
private void changeNoItemTag() { TextView mItemTextView = (TextView) findViewById(R.id.no_item_textview); //if there are items to show if (mNotesAdapter.getItemCount() != 0) { mItemTextView.setVisibility(View.GONE); mRecyclerView.setVisibility(View.VISIBLE); } else {//from w ww .j ava 2 s . c o m mItemTextView.setText(AppConstant.EMPTY); mItemTextView.setVisibility(View.VISIBLE); mRecyclerView.setVisibility(View.GONE); } }
From source file:com.brewcrewfoo.performance.activities.PCSettings.java
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { String key = preference.getKey(); if (key.equals("use_light_theme")) { mPreferences.edit().putBoolean("theme_changed", true).commit(); finish();//www. j a v a2 s. co m return true; } else if (key.equals("visible_tabs")) { startActivity(new Intent(this, HideTabs.class)); return true; } else if (key.equals("boot_mode")) { if (mInitd.isChecked()) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.prop_edit_dialog, null); final EditText tv = (EditText) editDialog.findViewById(R.id.vprop); final TextView tn = (TextView) editDialog.findViewById(R.id.nprop); tv.setText(mPreferences.getString("script_name", "99PC")); tn.setText(""); tn.setVisibility(TextView.GONE); new AlertDialog.Builder(this).setTitle(getString(R.string.pt_script_name)).setView(editDialog) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = tv.getText().toString(); if ((s != null) && (s.length() > 0)) { mPreferences.edit().putString("script_name", s).apply(); } mInitd.setSummary(INIT_D + mPreferences.getString("script_name", "99PC")); new BootClass(c, mPreferences).writeScript(); } }).create().show(); } else { final StringBuilder sb = new StringBuilder(); sb.append("mount -o rw,remount /system;\n"); sb.append("busybox rm ").append(INIT_D).append(mPreferences.getString("script_name", "99PC")) .append(";\n"); sb.append("mount -o ro,remount /system;\n"); Helpers.shExec(sb, c, true); } return true; } else if (key.equals("int_sd")) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.prop_edit_dialog, null); final EditText tv = (EditText) editDialog.findViewById(R.id.vprop); final TextView tn = (TextView) editDialog.findViewById(R.id.nprop); tv.setText(""); tn.setText(getString(R.string.info_auto_sd)); new AlertDialog.Builder(this).setTitle(getString(R.string.pt_int_sd)).setView(editDialog) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = tv.getText().toString(); if ((s != null) && (s.length() > 0)) { if (s.endsWith("/")) { s = s.substring(0, s.length() - 1); } if (!s.startsWith("/")) { s = "/" + s; } final File dir = new File(s); if (dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite()) mPreferences.edit().putString("int_sd_path", s).apply(); } else { mPreferences.edit().remove("int_sd_path").apply(); } mIntSD.setSummary(mPreferences.getString("int_sd_path", Environment.getExternalStorageDirectory().getAbsolutePath())); } }).create().show(); } else if (key.equals("ext_sd")) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.prop_edit_dialog, null); final EditText tv = (EditText) editDialog.findViewById(R.id.vprop); final TextView tn = (TextView) editDialog.findViewById(R.id.nprop); tv.setText(""); tn.setText(getString(R.string.info_auto_sd)); new AlertDialog.Builder(this).setTitle(getString(R.string.pt_ext_sd)).setView(editDialog) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = tv.getText().toString(); if ((s != null) && (s.length() > 0)) { if (s.endsWith("/")) { s = s.substring(0, s.length() - 1); } if (!s.startsWith("/")) { s = "/" + s; } final File dir = new File(s); if (dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite()) mPreferences.edit().putString("ext_sd_path", s).apply(); } else { mPreferences.edit().remove("ext_sd_path").apply(); } mExtSD.setSummary(mPreferences.getString("ext_sd_path", Helpers.extSD())); } }).create().show(); } else if (key.equals("br_op")) { startActivity(new Intent(this, BackupRestore.class)); } else if (key.equals("version_info")) { if (isupdate && !NO_UPDATE) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.ver_dialog, null); final TextView msg = (TextView) editDialog.findViewById(R.id.msg); msg.setText(det); new AlertDialog.Builder(c).setView(editDialog).setTitle(getString(R.string.pt_update)) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .setPositiveButton(getString(R.string.btn_download), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (isDownloadManagerAvailable(c)) { String url = URL + TAG + ".apk"; DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); //request.setDescription(""); request.setTitle(TAG + " " + ver); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, TAG + "-" + ver + ".apk"); DownloadManager manager = (DownloadManager) getSystemService( Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { Toast.makeText(c, getString(R.string.no_download_manager), Toast.LENGTH_LONG) .show(); } } }).create().show(); } return true; } else if (key.equals("pref_donate")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PAYPAL + PAYPAL_BTN))); } return false; }
From source file:com.mobicage.rogerthat.plugins.messaging.AttachmentViewerActivity.java
@Override protected void onServiceBound() { T.UI();/*from w ww . j av a2s . c o m*/ mProgressDialog = new ProgressDialog(AttachmentViewerActivity.this); mProgressDialog.setMessage(mService.getString(R.string.downloading)); mProgressDialog.setIndeterminate(true); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(true); mMessagingPlugin = mService.getPlugin(MessagingPlugin.class); final Intent intent = getIntent(); mThreadKey = intent.getStringExtra("thread_key"); mMessageKey = intent.getStringExtra("message"); mContentType = intent.getStringExtra("content_type"); mDownloadUrl = intent.getStringExtra("download_url"); mName = intent.getStringExtra("name"); mDownloadUrlHash = intent.getStringExtra("download_url_hash"); mGenerateThumbnail = intent.getBooleanExtra("generate_thumbnail", false); if (mContentType.toLowerCase(Locale.US).startsWith("video/")) { setContentView(R.layout.file_viewer_video); mVideoview = (VideoView) findViewById(R.id.videoView); } else { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); setContentView(R.layout.file_viewer); mWebview = (WebView) findViewById(R.id.webview); mWebview.setWebChromeClient(new WebChromeClient() { @Override public void onConsoleMessage(String message, int lineNumber, String sourceID) { if (sourceID != null) { try { sourceID = new File(sourceID).getName(); } catch (Exception e) { L.d("Could not get fileName of sourceID: " + sourceID, e); } } L.d(sourceID + ":" + lineNumber + " | " + message); } }); mWebview.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { L.d(failingUrl + ":" + errorCode + " | " + description); } }); final TextView titleTextView = (TextView) findViewById(R.id.title); if (TextUtils.isEmptyOrWhitespace(mName)) { titleTextView.setVisibility(View.GONE); findViewById(R.id.divider).setVisibility(View.GONE); } else { titleTextView.setVisibility(View.VISIBLE); titleTextView.setText(mName); findViewById(R.id.divider).setVisibility(View.VISIBLE); } } try { mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, null); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card); return; } mFile = new File(mAttachmentsDir, mDownloadUrlHash); if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) { updateView(false); } else { try { mAttachmentsDir = mMessagingPlugin.attachmentsDir(mThreadKey, mMessageKey); } catch (IOException e) { L.d("Unable to create attachment directory", e); UIUtils.showAlertDialog(this, "", R.string.unable_to_read_write_sd_card); return; } mFile = new File(mAttachmentsDir, mDownloadUrlHash); if (mMessagingPlugin.attachmentExists(mAttachmentsDir, mDownloadUrlHash)) { updateView(false); } else { downloadAttachment(); } } }
From source file:com.android.ex.chips.RecipientAlternatesAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { int position = cursor.getPosition(); TextView display = (TextView) view.findViewById(android.R.id.title); ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); RecipientEntry entry = getRecipientEntry(position); if (position == 0) { display.setText(cursor.getString(Queries.Query.NAME)); display.setVisibility(View.VISIBLE); byte[] photoBytes = mPhotoCacheMap.get(entry.getPhotoThumbnailUri()); if (photoBytes != null && imageView != null) { Bitmap photo = BitmapFactory.decodeByteArray(photoBytes, 0, photoBytes.length); imageView.setImageBitmap(photo); } else {/*www .j av a 2 s .c om*/ imageView.setImageResource(R.drawable.ic_contact_picture); if (entry.getPhotoThumbnailUri() != null) fetchPhotoAsync(entry, entry.getPhotoThumbnailUri()); } imageView.setVisibility(View.VISIBLE); } else { display.setVisibility(View.GONE); imageView.setVisibility(View.GONE); } TextView destination = (TextView) view.findViewById(android.R.id.text1); destination.setText(cursor.getString(Queries.Query.DESTINATION)); TextView destinationType = (TextView) view.findViewById(android.R.id.text2); if (destinationType != null) { destinationType.setText( mQuery.getTypeLabel(context.getResources(), cursor.getInt(Queries.Query.DESTINATION_TYPE), cursor.getString(Queries.Query.DESTINATION_LABEL)).toString().toUpperCase()); } }
From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_event_details, container, false); holder = new ViewHolder(); holder.inflater = inflater;/*w ww. j av a 2s.c o m*/ ((TextView) view.findViewById(R.id.title)).setText(event.getTitle()); TextView textView = (TextView) view.findViewById(R.id.subtitle); String text = event.getSubtitle(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { textView.setText(text); } MovementMethod linkMovementMethod = LinkMovementMethod.getInstance(); // Set the persons summary text first; replace it with the clickable text when the loader completes holder.personsTextView = (TextView) view.findViewById(R.id.persons); String personsSummary = ""; if (CollectionUtils.isEmpty(event.getPeople())) { holder.personsTextView.setVisibility(View.GONE); } else { personsSummary = StringUtils.join(event.getPeople(), ", "); holder.personsTextView.setText(personsSummary); holder.personsTextView.setMovementMethod(linkMovementMethod); holder.personsTextView.setVisibility(View.VISIBLE); } ((TextView) view.findViewById(R.id.track)).setText(event.getTrack().getTitle()); Date startTime = event.getStartDate(); Date endTime = event.getEndDate(); text = String.format("%1$s, %2$s %3$s", event.getTrack().getDay().getName(), (startTime != null) ? TIME_DATE_FORMAT.format(startTime) : "?", (endTime != null) ? TIME_DATE_FORMAT.format(endTime) : "?"); ((TextView) view.findViewById(R.id.time)).setText(text); final String roomName = event.getTrack().getRoom().getName(); TextView roomTextView = (TextView) view.findViewById(R.id.room); Spannable roomText = new SpannableString(String.format("%1$s", roomName)); // final int roomImageResId = getResources() // .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", // getActivity().getPackageName()); // // If the room image exists, make the room text clickable to display it // if(roomImageResId != 0) { // roomText.setSpan(new UnderlineSpan(), 0, roomText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // roomTextView.setOnClickListener(new View.OnClickListener() // { // // @Override // public void onClick(View view) // { // RoomImageDialogFragment.newInstance(roomName, roomImageResId).show(getFragmentManager()); // } // }); // roomTextView.setFocusable(true); // } roomTextView.setText(roomText); textView = (TextView) view.findViewById(R.id.abstract_text); text = event.getEventAbstract(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n"); textView.setText(strippedText); textView.setMovementMethod(linkMovementMethod); } textView = (TextView) view.findViewById(R.id.description); text = event.getDescription(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n"); textView.setText(strippedText); textView.setMovementMethod(linkMovementMethod); } holder.linksContainer = (ViewGroup) view.findViewById(R.id.links_container); return view; }
From source file:com.android.mail.browse.ConversationItemViewCoordinates.java
private ConversationItemViewCoordinates(final Context context, final Config config, final CoordinatesCache cache) { Utils.traceBeginSection("CIV coordinates constructor"); final Resources res = context.getResources(); final int layoutId = R.layout.conversation_item_view; ViewGroup view = (ViewGroup) cache.getView(layoutId); if (view == null) { view = (ViewGroup) LayoutInflater.from(context).inflate(layoutId, null); cache.put(layoutId, view);/* w ww. j av a 2 s .c om*/ } // Show/hide optional views before measure/layout call final TextView folders = (TextView) view.findViewById(R.id.folders); folders.setVisibility(config.areFoldersVisible() ? View.VISIBLE : View.GONE); View contactImagesView = view.findViewById(R.id.contact_image); switch (config.getGadgetMode()) { case GADGET_CONTACT_PHOTO: contactImagesView.setVisibility(View.VISIBLE); break; case GADGET_CHECKBOX: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; default: contactImagesView.setVisibility(View.GONE); contactImagesView = null; break; } final View replyState = view.findViewById(R.id.reply_state); replyState.setVisibility(config.isReplyStateVisible() ? View.VISIBLE : View.GONE); final View personalIndicator = view.findViewById(R.id.personal_indicator); personalIndicator.setVisibility(config.isPersonalIndicatorVisible() ? View.VISIBLE : View.GONE); setFramePadding(context, view, config.useFullPadding()); // Layout the appropriate view. ViewCompat.setLayoutDirection(view, config.getLayoutDirection()); final int widthSpec = MeasureSpec.makeMeasureSpec(config.getWidth(), MeasureSpec.EXACTLY); final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); view.measure(widthSpec, heightSpec); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); // Once the view is measured, let's calculate the dynamic width variables. folderLayoutWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_max_width_proportion) / 100.0); folderCellWidth = (int) (view.getWidth() * res.getInteger(R.integer.folder_cell_max_width_proportion) / 100.0); // Utils.dumpViewTree((ViewGroup) view); // Records coordinates. // Contact images view if (contactImagesView != null) { contactImagesWidth = contactImagesView.getWidth(); contactImagesHeight = contactImagesView.getHeight(); contactImagesX = getX(contactImagesView); contactImagesY = getY(contactImagesView); } else { contactImagesX = contactImagesY = contactImagesWidth = contactImagesHeight = 0; } final boolean isRtl = ViewUtils.isViewRtl(view); final View star = view.findViewById(R.id.star); final int starPadding = res.getDimensionPixelSize(R.dimen.conv_list_star_padding_start); starX = getX(star) + (isRtl ? 0 : starPadding); starY = getY(star); starWidth = star.getWidth(); final TextView senders = (TextView) view.findViewById(R.id.senders); final int sendersTopAdjust = getLatinTopAdjustment(senders); sendersX = getX(senders); sendersY = getY(senders) + sendersTopAdjust; sendersWidth = senders.getWidth(); sendersHeight = senders.getHeight(); sendersLineCount = SINGLE_LINE; sendersFontSize = senders.getTextSize(); final TextView subject = (TextView) view.findViewById(R.id.subject); final int subjectTopAdjust = getLatinTopAdjustment(subject); subjectX = getX(subject); subjectY = getY(subject) + subjectTopAdjust; subjectWidth = subject.getWidth(); subjectHeight = subject.getHeight(); subjectFontSize = subject.getTextSize(); final TextView snippet = (TextView) view.findViewById(R.id.snippet); final int snippetTopAdjust = getLatinTopAdjustment(snippet); snippetX = getX(snippet); snippetY = getY(snippet) + snippetTopAdjust; maxSnippetWidth = snippet.getWidth(); snippetHeight = snippet.getHeight(); snippetFontSize = snippet.getTextSize(); if (config.areFoldersVisible()) { foldersLeft = getX(folders); foldersRight = foldersLeft + folders.getWidth(); foldersY = getY(folders); foldersTypeface = folders.getTypeface(); foldersFontSize = folders.getTextSize(); } else { foldersLeft = 0; foldersRight = 0; foldersY = 0; foldersTypeface = null; foldersFontSize = 0; } final View colorBlock = view.findViewById(R.id.color_block); if (config.isColorBlockVisible() && colorBlock != null) { colorBlockX = getX(colorBlock); colorBlockY = getY(colorBlock); colorBlockWidth = colorBlock.getWidth(); colorBlockHeight = colorBlock.getHeight(); } else { colorBlockX = colorBlockY = colorBlockWidth = colorBlockHeight = 0; } if (config.isReplyStateVisible()) { replyStateX = getX(replyState); replyStateY = getY(replyState); } else { replyStateX = replyStateY = 0; } if (config.isPersonalIndicatorVisible()) { personalIndicatorX = getX(personalIndicator); personalIndicatorY = getY(personalIndicator); } else { personalIndicatorX = personalIndicatorY = 0; } final View infoIcon = view.findViewById(R.id.info_icon); infoIconX = getX(infoIcon); infoIconXRight = infoIconX + infoIcon.getWidth(); infoIconY = getY(infoIcon); final TextView date = (TextView) view.findViewById(R.id.date); dateX = getX(date); dateXRight = dateX + date.getWidth(); dateY = getY(date); datePaddingStart = ViewUtils.getPaddingStart(date); dateFontSize = date.getTextSize(); dateYBaseline = dateY + getLatinTopAdjustment(date) + date.getBaseline(); final View paperclip = view.findViewById(R.id.paperclip); paperclipY = getY(paperclip); paperclipPaddingStart = ViewUtils.getPaddingStart(paperclip); height = view.getHeight() + sendersTopAdjust; Utils.traceEndSection(); }
From source file:android_network.hetnet.vpn_service.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); // Check switch state SwitchCompat swEnabled = (SwitchCompat) getSupportActionBar().getCustomView() .findViewById(R.id.swEnabled); if (swEnabled.isChecked() != log) swEnabled.setChecked(log);//w ww . j a va 2 s .c om ServiceSinkhole.reload("changed " + name, ActivityLog.this); } }
From source file:fm.smart.r1.activity.CreateExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExceptionHandler.register(this); setContentView(R.layout.create_example); final Intent queryIntent = getIntent(); Bundle extras = queryIntent.getExtras(); item_id = (String) extras.get("item_id"); list_id = (String) extras.get("list_id"); if (list_id == null || list_id.equals("")) { list_id = Main.default_study_list_id; }// w w w . j a v a 2s . co m cue = (String) extras.get("cue"); example = (String) extras.get("example"); translation = (String) extras.get("translation"); example_language = (String) extras.get("example_language"); translation_language = (String) extras.get("translation_language"); example_transliteration = (String) extras.get("example_transliteration"); translation_transliteration = (String) extras.get("translation_transliteration"); TextView example_text = (TextView) findViewById(R.id.create_example_sentence); if (!TextUtils.isEmpty(example)) { example_text.setText(example); } example_text.setHint(example_language + " sentence with " + cue); TextView translation_text = (TextView) findViewById(R.id.create_example_translation); if (!TextUtils.isEmpty(translation)) { translation_text.setText(translation); } translation_text.setHint(translation_language + " translation of example sentence"); Button button = (Button) findViewById(R.id.create_example_submit); button.setOnClickListener(this); TextView translation_text_legend = (TextView) findViewById(R.id.create_example_translation_legend); TextView sentence_transliteration_textView = (TextView) findViewById( R.id.create_example_sentence_transliteration); EditText sentence_transliteration_input_textView = (EditText) findViewById(R.id.sentence_transliteration); if (!Utils.isIdeographicLanguage(Main.search_lang)) { sentence_transliteration_textView.setVisibility(View.GONE); sentence_transliteration_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(example_transliteration)) { sentence_transliteration_input_textView.setText(example_transliteration); } TextView translation_transliteration_textView = (TextView) findViewById( R.id.create_example_translation_transliteration); EditText translation_transliteration_input_textView = (EditText) findViewById( R.id.translation_transliteration); if (!Utils.isIdeographicLanguage(Main.result_lang)) { translation_transliteration_textView.setVisibility(View.GONE); translation_transliteration_input_textView.setVisibility(View.GONE); } else if (!TextUtils.isEmpty(translation_transliteration)) { translation_transliteration_input_textView.setText(translation_transliteration); } }
From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java
/** * Refresh the UI with data from the product *//* w ww. j a va 2 s . c om*/ public void updateUI() { // Title this.setTitle(mProduct.getName()); // Images if (mProduct.getGalleryImageURLs() != null) { GalleryAdapter adapter = new GalleryAdapter(this, mProduct.getGalleryImageURLs()); Gallery gallery = (Gallery) findViewById(R.id.galleryImages); gallery.setAdapter(adapter); // Set the onClick listener for the gallery gallery.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) { viewImage(position); } }); } // Reviews TextView reviewTextView = (TextView) findViewById(R.id.textViewReviews); reviewTextView.setText(this.getResources().getString(R.string.show_reviews, mProduct.getReviews().size())); // Rating (stars) RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBarRating); if (mProduct.getAverageRating() != null) { ratingBar.setRating(mProduct.getAverageRating().floatValue()); } // Promotions TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion); if (mProduct.getPotentialPromotions().size() == 0) { promotionsTextView.setVisibility(View.GONE); } else { if (mProduct.getPotentialPromotions() != null && !mProduct.getPotentialPromotions().isEmpty()) { promotionsTextView.setText( Html.fromHtml(Product.generatePromotionString(mProduct.getPotentialPromotions().get(0)))); StringUtil.removeUnderlines((Spannable) promotionsTextView.getText()); } } TextView priceTextView = (TextView) findViewById(R.id.textViewPrice); priceTextView.setText(mProduct.getPrice().getFormattedValue()); // Description TextView descriptionTextView = (TextView) findViewById(R.id.textViewDescription); descriptionTextView.setText(mProduct.getDescription()); // Stock level TextView stockLevelTextView = (TextView) findViewById(R.id.textViewStockLevel); String stockLevelText = mProduct.getStockLevelText(Hybris.getAppContext()); if (mProduct.getStock().getStockLevel() > 0) { stockLevelText = mProduct.getStock().getStockLevel() + " " + mProduct.getStockLevelText(Hybris.getAppContext()).toLowerCase(); } stockLevelTextView.setText(stockLevelText); // Disable / Enable the add to cart button Button addToCartButton = (Button) findViewById(R.id.buttonAddToCart); Button quantityButton = (Button) findViewById(R.id.quantityButton); quantityButton.setText(getString(R.string.quantity_button, quantityToAddToCart)); try { if (mProduct.getStock().getStockLevelStatus() != null && StringUtils.equalsIgnoreCase(mProduct.getStock().getStockLevelStatus().getCode(), ProductStockLevelStatus.CODE_OUT_OF_STOCK)) { addToCartButton.setEnabled(false); quantityButton.setEnabled(false); quantityButton.setText(R.string.quantity); } else { addToCartButton.setEnabled(true); quantityButton.setEnabled(true); } } catch (Exception e) { } invalidateOptionsMenu(); }