List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.arantius.tivocommander.Explore.java
public void doRecord(View v) { ArrayAdapter<String> choicesAdapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item, mChoices);/*w ww .j a v a 2 s . com*/ Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle("Operation?"); dialogBuilder.setAdapter(choicesAdapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { setRefreshResult(); String label = mChoices.get(position); if (RecordActions.DONT_RECORD.toString().equals(label)) { getParent().setProgressBarIndeterminateVisibility(true); MindRpc.addRequest(new RecordingUpdate(mRecordingId, "cancelled"), new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { getParent().setProgressBarIndeterminateVisibility(false); ImageView iconSubType = (ImageView) findViewById(R.id.icon_sub_type); TextView textSubType = (TextView) findViewById(R.id.text_sub_type); iconSubType.setVisibility(View.GONE); textSubType.setVisibility(View.GONE); } }); } else if (RecordActions.RECORD.toString().equals(label)) { Intent intent = new Intent(getBaseContext(), SubscribeOffer.class); intent.putExtra("contentId", mContentId); intent.putExtra("offerId", mOfferId); startActivity(intent); } else if (RecordActions.RECORD_STOP.toString().equals(label)) { getParent().setProgressBarIndeterminateVisibility(true); MindRpc.addRequest(new RecordingUpdate(mRecordingId, "complete"), new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { getParent().setProgressBarIndeterminateVisibility(false); mRecordingId = null; } }); } else if (RecordActions.SP_ADD.toString().equals(label)) { Intent intent = new Intent(getBaseContext(), SubscribeCollection.class); intent.putExtra("collectionId", mCollectionId); startActivity(intent); // TODO: Start for result, get subscription ID. } else if (RecordActions.SP_CANCEL.toString().equals(label)) { getParent().setProgressBarIndeterminateVisibility(true); MindRpc.addRequest(new Unsubscribe(mSubscriptionId), new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { getParent().setProgressBarIndeterminateVisibility(false); mSubscriptionId = null; } }); } else if (RecordActions.SP_MODIFY.toString().equals(label)) { Intent intent = new Intent(getBaseContext(), SubscribeCollection.class); intent.putExtra("collectionId", mCollectionId); intent.putExtra("subscriptionId", mSubscriptionId); intent.putExtra("subscriptionJson", Utils.stringifyToJson(mSubscription)); startActivity(intent); } } }); AlertDialog dialog = dialogBuilder.create(); dialog.show(); }
From source file:semanticweb.hws14.movapp.activities.MovieDetail.java
private void manageEmptyTextfields(TextView tvHc, TextView tv, String text, boolean doColorIt) { if (!text.equals("") && !text.equals("N/A") && !text.equals("0")) { tv.setVisibility(View.VISIBLE); tvHc.setVisibility(View.VISIBLE); if (doColorIt) { colorIt(tvHc);/*ww w. j a v a 2 s. c om*/ } } }
From source file:com.android.mail.browse.MessageHeaderView.java
/** * Render an email list for the expanded message details view. *//*from ww w. j av a 2 s .co m*/ private static void renderEmailList(Resources res, int headerId, int detailsId, String[] emails, String viaDomain, View rootView, Map<String, Address> addressCache, Account account, VeiledAddressMatcher veiledMatcher, BidiFormatter bidiFormatter) { if (emails == null || emails.length == 0) { return; } final String[] formattedEmails = new String[emails.length]; for (int i = 0; i < emails.length; i++) { final Address email = Utils.getAddress(addressCache, emails[i]); String name = email.getPersonal(); final String address = email.getAddress(); // Check if the address here is a veiled address. If it is, we need to display an // alternate layout final boolean isVeiledAddress = veiledMatcher != null && veiledMatcher.isVeiledAddress(address); final String addressShown; if (isVeiledAddress) { // Add the warning at the end of the name, and remove the address. The alternate // text cannot be put in the address part, because the address is made into a link, // and the alternate human-readable text is not a link. addressShown = ""; if (TextUtils.isEmpty(name)) { // Empty name and we will block out the address. Let's write something more // readable. name = res.getString(VeiledAddressMatcher.VEILED_ALTERNATE_TEXT_UNKNOWN_PERSON); } else { name = name + res.getString(VeiledAddressMatcher.VEILED_ALTERNATE_TEXT); } } else { addressShown = address; } if (name == null || name.length() == 0 || name.equalsIgnoreCase(addressShown)) { formattedEmails[i] = bidiFormatter.unicodeWrap(addressShown); } else { // The one downside to having the showViaDomain here is that // if the sender does not have a name, it will not show the via info if (viaDomain != null) { formattedEmails[i] = res.getString(R.string.address_display_format_with_via_domain, bidiFormatter.unicodeWrap(name), bidiFormatter.unicodeWrap(addressShown), bidiFormatter.unicodeWrap(viaDomain)); } else { formattedEmails[i] = res.getString(R.string.address_display_format, bidiFormatter.unicodeWrap(name), bidiFormatter.unicodeWrap(addressShown)); } } } rootView.findViewById(headerId).setVisibility(VISIBLE); final TextView detailsText = (TextView) rootView.findViewById(detailsId); detailsText.setText(TextUtils.join("\n", formattedEmails)); stripUnderlines(detailsText, account); detailsText.setVisibility(VISIBLE); }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break;/*from w w w . j a v a 2 s . c o m*/ } case PREDICTION_ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break; } case EMPTY_SEARCH_VIEW_TYPE: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case SEARCH_MARKET_VIEW_TYPE: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); searchView.setContentDescription(mMarketSearchMessage); searchView.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); searchView.setText(mMarketSearchMessage); } else { searchView.setVisibility(View.GONE); } break; } }
From source file:com.arantius.tivocommander.NowShowing.java
private void setTitleFromContent(JsonNode content) { String title, movieYear, subtitle; if (mContentType == ContentType.TBA) { title = "To Be Announced"; subtitle = "No Information Available"; } else {//from www .j a v a 2 s. co m title = content.path("title").asText(); movieYear = content.path("movieYear").asText(); if (movieYear != null && !"".equals(movieYear)) { title += " (" + movieYear + ")"; } subtitle = content.path("subtitle").textValue(); } TextView titleView = (TextView) findViewById(R.id.content_title); TextView subtitleView = (TextView) findViewById(R.id.content_subtitle); titleView.setText(title); if (null == subtitle) { subtitleView.setVisibility(View.GONE); } else { subtitleView.setVisibility(View.VISIBLE); subtitleView.setText(subtitle); } }
From source file:com.chatwing.whitelabel.fragments.CommunicationDrawerFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { TextView unreadCountView = getUnreadCountView(loader); if (unreadCountView == null) return;//from ww w.jav a2 s . co m if (data == null || !data.moveToFirst() || data.getCount() == 0) { unreadCountView.setVisibility(View.GONE); return; } int columnIndex = data.getColumnIndexOrThrow(COLUMN_NAME_SUM_UNREAD_COUNT); int unreadCount = data.getInt(columnIndex); if (unreadCount == 0) { unreadCountView.setVisibility(View.GONE); } else { unreadCountView.setText(Integer.toString(unreadCount)); unreadCountView.setVisibility(View.VISIBLE); } }
From source file:com.example.research.whatis.MainActivity.java
public String invokeSynonymsAPI() throws IOException, JSONException { if (OCRedText.length() > 0) { final ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "Loading ...", "Fetching synonym for " + OCRedText, true, false); final Thread thread = new Thread(new Runnable() { @Override//from www.j a v a 2 s . c o m public void run() { String synonymURL = "http://words.bighugelabs.com/api/2/4bbcc4ae52f1e82bd08e683a72665f7b/"; synonymURL += OCRedText.toString() + "/json"; synonymURL = synonymURL.replaceAll("\\s", ""); Log.d("API", "Invokes Synonyms" + synonymURL); URL url = null; try { url = new URL(synonymURL); connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "application/json"); //connection.setRequestProperty("Content-Length", Integer.toString(OCRedText.length())); OutputStream stream = connection.getOutputStream(); stream.close(); //fabulous/json httpCode = connection.getResponseCode(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ProtocolException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Doing UI related code in UI thread runOnUiThread(new Runnable() { @Override public void run() { dialog.dismiss(); // Success request try { if (httpCode == HttpURLConnection.HTTP_OK) { // Get response stream String jsonResponse = GetResponseToString(connection.getInputStream()); JSONObject reader = new JSONObject(jsonResponse); Log.d("Synonyms JSONResp ", jsonResponse.toString()); Log.d("Synonyms Reader", reader.toString()); JSONArray text = null; try { JSONObject obj = reader.getJSONObject("adjective"); text = obj.getJSONArray("syn"); } catch (JSONException e) { e.printStackTrace(); try { JSONObject obj = reader.getJSONObject("noun"); text = obj.getJSONArray("syn"); } catch (JSONException e1) { JSONObject obj = reader.getJSONObject("verb"); text = obj.getJSONArray("syn"); } } if (text != null) { synonym = text.get(0).toString(); } else { synonym = "<ERROR IN API>"; } FileOutputStream fos = openFileOutput("synonym.txt", Context.MODE_APPEND); fos.write(synonym.getBytes()); fos.close(); } else { // Error occurred String jsonResponse = GetResponseToString(connection.getErrorStream()); JSONObject reader = new JSONObject(jsonResponse); JSONArray text = reader.getJSONArray("ErrorMessage"); synonym = text.get(0).toString(); // Error message // Toast.makeText(MainActivity.this, "Error Message: " + synonym, Toast.LENGTH_LONG).show(); System.out.println(); } connection.disconnect(); TextView view = (TextView) findViewById(R.id.textView); view.setVisibility(View.VISIBLE); ListView lView = (ListView) findViewById(R.id.listView); lView.setVisibility(View.GONE); view.setText(OCRedText + ":" + synonym); dbHelper.insertWord(OCRedText, synonym, "", "http://words.bighugelabs.com"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); } }); thread.start(); } else { synonym = ""; } return synonym; }
From source file:com.example.milos.msattackczm.ui.ProcedureDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.procedure_codes, container, false); context = getActivity();//from w ww . j ava 2s .c om mPathView = (PathView) rootView.findViewById(R.id.pathView); mPathView.setOnTouchListener(MyOnTouchListener); TextView primaryCodeTextView = (TextView) rootView.findViewById(R.id.primary_code_textView); TextView secondaryCodeTextView = (TextView) rootView.findViewById(R.id.secondary_code_textView); TextView CodeTextView = (TextView) rootView.findViewById(R.id.code_textView); loadSettings(); switch (mItem) { case 0: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_vision_loss); break; case 1: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_double_vision); break; case 2: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_weakness); break; case 3: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_walking); break; case 4: mPathView.setVisibility(View.INVISIBLE); secondaryCodeTextView.setVisibility(View.INVISIBLE); CodeTextView.setVisibility(View.INVISIBLE); primaryCodeTextView.setText(R.string.code_vertigo); break; case 5: primaryCodeTextView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault_Medium); //primaryCodeTextView.textAppearance secondaryCodeTextView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault); CodeTextView.setTextAppearance(getActivity(), android.R.style.TextAppearance_DeviceDefault); primaryCodeTextView.setText(R.string.code_attack1); secondaryCodeTextView.setText(R.string.code_attack2); CodeTextView.setText(R.string.code_attack3); primaryCodeTextView.setTextColor(Color.MAGENTA); break; default: break; } // set up buttons return rootView; }
From source file:com.gh4a.fragment.UserFragment.java
private void fillData() { ImageView gravatar = (ImageView) mContentView.findViewById(R.id.iv_gravatar); AvatarHandler.assignAvatar(gravatar, mUser); TextView tvFollowersCount = (TextView) mContentView.findViewById(R.id.tv_followers_count); tvFollowersCount.setText(String.valueOf(mUser.getFollowers())); View llOrgMembers = mContentView.findViewById(R.id.cell_org_members); View llFollowers = mContentView.findViewById(R.id.cell_followers); if (Constants.User.TYPE_USER.equals(mUser.getType())) { llFollowers.setOnClickListener(this); llOrgMembers.setVisibility(View.GONE); } else {//from ww w .j a v a2 s . c o m llOrgMembers.setOnClickListener(this); llFollowers.setVisibility(View.GONE); } mContentView.findViewById(R.id.cell_repos).setOnClickListener(this); TextView tvReposCount = (TextView) mContentView.findViewById(R.id.tv_repos_count); if (ApiHelpers.loginEquals(mUserLogin, Gh4Application.get().getAuthLogin())) { tvReposCount.setText(String.valueOf(mUser.getTotalPrivateRepos() + mUser.getPublicRepos())); } else { tvReposCount.setText(String.valueOf(mUser.getPublicRepos())); } //hide gists repos if organization fillCountIfUser(R.id.cell_gists, R.id.tv_gists_count, mUser.getPublicGists() + mUser.getPrivateGists()); //hide following if organization fillCountIfUser(R.id.cell_following, R.id.tv_following_count, mUser.getFollowing()); TextView tvName = (TextView) mContentView.findViewById(R.id.tv_name); tvName.setText(StringUtils.isBlank(mUser.getName()) ? mUser.getLogin() : mUser.getName()); if (Constants.User.TYPE_ORG.equals(mUser.getType())) { tvName.append(" ("); tvName.append(Constants.User.TYPE_ORG); // FIXME tvName.append(")"); } TextView tvCreated = (TextView) mContentView.findViewById(R.id.tv_created_at); if (mUser.getCreatedAt() != null) { tvCreated.setText(getString(R.string.user_created_at, DateFormat.getMediumDateFormat(getActivity()).format(mUser.getCreatedAt()))); tvCreated.setVisibility(View.VISIBLE); } else { tvCreated.setVisibility(View.GONE); } fillTextView(R.id.tv_email, mUser.getEmail()); fillTextView(R.id.tv_website, mUser.getBlog()); fillTextView(R.id.tv_company, mUser.getCompany()); fillTextView(R.id.tv_location, mUser.getLocation()); getLoaderManager().initLoader(1, null, mRepoListCallback); getLoaderManager().initLoader(2, null, mOrganizationCallback); }
From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFilteredFragment.java
@Override public void bindCollectionItemView(Context context, View view, int groupId, int indexInGroup, int dataIndex, Object tag) {/* w ww .j av a 2 s. c om*/ final VideoLibraryModel.Video video = (VideoLibraryModel.Video) tag; if (video == null) { return; } ImageView thumbnailView = (ImageView) view.findViewById(R.id.thumbnail); TextView titleView = (TextView) view.findViewById(R.id.title); TextView speakersView = (TextView) view.findViewById(R.id.speakers); TextView descriptionView = (TextView) view.findViewById(R.id.description); titleView.setText(video.getTitle()); speakersView.setText(video.getSpeakers()); speakersView.setVisibility(TextUtils.isEmpty(video.getSpeakers()) ? View.GONE : View.VISIBLE); descriptionView.setText(video.getDesc()); descriptionView.setVisibility( TextUtils.isEmpty(video.getDesc()) || video.getTitle().equals(video.getDesc()) ? View.GONE : View.VISIBLE); String thumbUrl = video.getThumbnailUrl(); if (TextUtils.isEmpty(thumbUrl)) { thumbnailView.setImageResource(android.R.color.transparent); } else { mImageLoader.loadImage(thumbUrl, thumbnailView); } // Display the overlay if the video has already been played. if (video.getAlreadyPlayed()) { styleVideoAsViewed(view); } final String videoId = video.getId(); final String youtubeLink = TextUtils.isEmpty(videoId) ? "" : videoId.contains("://") ? videoId : String.format(Locale.US, Config.VIDEO_LIBRARY_URL_FMT, videoId); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!TextUtils.isEmpty(youtubeLink)) { LOGD(TAG, "Launching Youtube video: " + youtubeLink); // ANALYTICS EVENT: Click on a video on the Filtered Video Library screen // Contains: video's YouTube URL, http://www.youtube.com/... AnalyticsHelper.sendEvent(FILTERED_VIDEO_LIBRARY_ANALYTICS_CATEGORY, "selectvideo", youtubeLink); Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(youtubeLink)); UIUtils.preferPackageForIntent(getActivity(), i, UIUtils.YOUTUBE_PACKAGE_NAME); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(i); // Mark the video as played. fireVideoPlayedEvent(video); // Display the overlay for videos that has already been played. styleVideoAsViewed(view); } } }); }