Java Code Examples for android.widget.TextView#getVisibility()
The following examples show how to use
android.widget.TextView#getVisibility() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuggestionView.java From delion with Apache License 2.0 | 6 votes |
/** * Sets a description line for the omnibox suggestion. * * @param str The description text. * @param isUrl Whether this text is a URL (as opposed to a normal string). */ private void showDescriptionLine(Spannable str, boolean isUrl) { TextView textLine = mContentsView.mTextLine2; if (textLine.getVisibility() != VISIBLE) { textLine.setVisibility(VISIBLE); } textLine.setText(str, BufferType.SPANNABLE); // Force left-to-right rendering for URLs. See UrlBar constructor for details. if (isUrl) { textLine.setTextColor(URL_COLOR); ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR); } else { textLine.setTextColor(getStandardFontColor()); ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT); } }
Example 2
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 6 votes |
/** * Sets a description line for the omnibox suggestion. * * @param str The description text. * @param isUrl Whether this text is a URL (as opposed to a normal string). */ private void showDescriptionLine(Spannable str, boolean isUrl) { TextView textLine = mContentsView.mTextLine2; if (textLine.getVisibility() != VISIBLE) { textLine.setVisibility(VISIBLE); } textLine.setText(str, BufferType.SPANNABLE); // Force left-to-right rendering for URLs. See UrlBar constructor for details. if (isUrl) { textLine.setTextColor(URL_COLOR); ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR); } else { textLine.setTextColor(getStandardFontColor()); ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT); } }
Example 3
Source File: CollectionView.java From TiCollectionView with MIT License | 5 votes |
public void setFooterTitle(String title) { TextView textView = (TextView) footerView.findViewById(titleId); textView.setText(title); if (textView.getVisibility() == View.GONE) { textView.setVisibility(View.VISIBLE); } }
Example 4
Source File: PaneledChoiceDialog.java From commcare-android with Apache License 2.0 | 5 votes |
private void toggleExtraInfoVisibility() { TextView extraInfoContent = view.findViewById(R.id.extra_info_content); if (extraInfoContent.getVisibility() == View.VISIBLE) { extraInfoContent.setVisibility(View.GONE); } else { extraInfoContent.setVisibility(View.VISIBLE); } }
Example 5
Source File: Extractor.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
private void removeClickableViews(@NonNull ArrayList<TextView> textViews) { for (int i = textViews.size() - 1; i >= 0; i--) { TextView child = textViews.get(i); if (child.isClickable() || child.getVisibility() != View.VISIBLE) { textViews.remove(i); break; } } }
Example 6
Source File: RobotoCalendarView.java From roboto-calendar-view with Apache License 2.0 | 5 votes |
private void setUpDaysInCalendar() { Calendar auxCalendar = Calendar.getInstance(Locale.getDefault()); auxCalendar.setTime(currentCalendar.getTime()); auxCalendar.set(Calendar.DAY_OF_MONTH, 1); int firstDayOfMonth = auxCalendar.get(Calendar.DAY_OF_WEEK); TextView dayOfTheMonthText; ViewGroup dayOfTheMonthContainer; ViewGroup dayOfTheMonthLayout; // Calculate dayOfTheMonthIndex int dayOfTheMonthIndex = getWeekIndex(firstDayOfMonth, auxCalendar); for (int i = 1; i <= auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++, dayOfTheMonthIndex++) { dayOfTheMonthContainer = rootView.findViewWithTag(DAY_OF_THE_MONTH_LAYOUT + dayOfTheMonthIndex); dayOfTheMonthText = rootView.findViewWithTag(DAY_OF_THE_MONTH_TEXT + dayOfTheMonthIndex); if (dayOfTheMonthText == null) { break; } dayOfTheMonthContainer.setOnClickListener(onDayOfMonthClickListener); dayOfTheMonthContainer.setOnLongClickListener(onDayOfMonthLongClickListener); dayOfTheMonthText.setVisibility(View.VISIBLE); dayOfTheMonthText.setText(String.valueOf(i)); } for (int i = 36; i < 43; i++) { dayOfTheMonthText = rootView.findViewWithTag(DAY_OF_THE_MONTH_TEXT + i); dayOfTheMonthLayout = rootView.findViewWithTag(DAY_OF_THE_MONTH_LAYOUT + i); if (dayOfTheMonthText.getVisibility() == INVISIBLE) { dayOfTheMonthLayout.setVisibility(GONE); } else { dayOfTheMonthLayout.setVisibility(VISIBLE); } } }
Example 7
Source File: PickersActivity.java From android-test with Apache License 2.0 | 5 votes |
private void updateTextInUi(String text, TextView textView) { if (null == textView) { return; } if (View.INVISIBLE == textView.getVisibility()) { textView.setVisibility(View.VISIBLE); } textView.setText(text); }
Example 8
Source File: FloatingActionButton.java From FloatingActionButton with Apache License 2.0 | 5 votes |
public int getLabelVisibility() { TextView labelView = getLabelView(); if (labelView != null) { return labelView.getVisibility(); } return -1; }
Example 9
Source File: CardViewHolder.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
public static void resetHighlight(TextView textView) { if (textView != null && textView.getVisibility() == View.VISIBLE) { textView.setTypeface(Typeface.create(textView.getTypeface(), Typeface.NORMAL), Typeface.NORMAL); textView.setPaintFlags(textView.getPaintFlags() & (~Paint.UNDERLINE_TEXT_FLAG)); } }
Example 10
Source File: TabLayout.java From tns-core-modules-widgets with Apache License 2.0 | 5 votes |
private void setupItem(LinearLayout ll, TextView textView,ImageView imgView, TabItemSpec tabItem){ float density = getResources().getDisplayMetrics().density; if (tabItem.iconId != 0) { imgView.setImageResource(tabItem.iconId); imgView.setVisibility(VISIBLE); } else if (tabItem.iconDrawable != null) { imgView.setImageDrawable(tabItem.iconDrawable); imgView.setVisibility(VISIBLE); } else { imgView.setVisibility(GONE); } if (tabItem.title != null && !tabItem.title.isEmpty()) { textView.setText(tabItem.title); textView.setVisibility(VISIBLE); } else { textView.setVisibility(GONE); } if (imgView.getVisibility() == VISIBLE && textView.getVisibility() == VISIBLE) { ll.setMinimumHeight((int) (LARGE_MIN_HEIGHT * density)); } else { ll.setMinimumHeight((int) (SMALL_MIN_HEIGHT * density)); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams(); lp.width = 0; lp.weight = 1; } }
Example 11
Source File: TwoStatePreference.java From MaterialPreference with Apache License 2.0 | 5 votes |
/** * @hide */ @RestrictTo(LIBRARY_GROUP) protected void syncSummaryView(View view) { if (!(view instanceof TextView)) { return; } TextView summaryView = (TextView) view; boolean useDefaultSummary = true; if (mChecked && !TextUtils.isEmpty(mSummaryOn)) { summaryView.setText(mSummaryOn); useDefaultSummary = false; } else if (!mChecked && !TextUtils.isEmpty(mSummaryOff)) { summaryView.setText(mSummaryOff); useDefaultSummary = false; } if (useDefaultSummary) { final CharSequence summary = getSummary(); if (!TextUtils.isEmpty(summary)) { summaryView.setText(summary); useDefaultSummary = false; } } int newVisibility = View.GONE; if (!useDefaultSummary) { // Someone has written to it newVisibility = View.VISIBLE; } if (newVisibility != summaryView.getVisibility()) { summaryView.setVisibility(newVisibility); } }
Example 12
Source File: FloatingActionButton.java From ShareBox with Apache License 2.0 | 5 votes |
public int getLabelVisibility() { TextView labelView = getLabelView(); if (labelView != null) { return labelView.getVisibility(); } return -1; }
Example 13
Source File: MainActivity.java From LaunchTime with GNU General Public License v3.0 | 5 votes |
private void hideHiddenCategories() { if (isAutohide()) { return; } for (String cat : db().getCategories()) { boolean isNewCat = cat.equals(mCategoryJustCreated); final TextView cattab = mCategoryTabs.get(cat); if (cattab!=null) { if (mCategory.equals(cat)) { cattab.setVisibility(View.VISIBLE); } else if ((Categories.isHiddenCategory(cat) || db().isHiddenCategory(cat)) || (!cat.equals(Categories.CAT_SEARCH) && !mCategory.equals(cat) && db().getAppCount(cat) == 0 && !isNewCat)) { if (mAnimationDuration>0 && cattab.getVisibility() != View.GONE) { int h = cattab.getHeight(); mStyle.animateChangingSize(cattab, h, 1, null, new Runnable() { @Override public void run() { cattab.setVisibility(View.GONE); } }); } else { cattab.setVisibility(View.GONE); } } else { cattab.setVisibility(View.VISIBLE); } } } }
Example 14
Source File: MainFragment.java From GreenBits with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { Log.d(TAG, "onCreateView -> " + TAG); if (isZombieNoView()) return null; final GaService service = getGAService(); popupWaitDialog(R.string.loading_transactions); if (savedInstanceState != null) mIsExchanger = savedInstanceState.getBoolean("isExchanger", false); if (mIsExchanger) mView = inflater.inflate(R.layout.fragment_exchanger_txs, container, false); else mView = inflater.inflate(R.layout.fragment_main, container, false); final RecyclerView txView = UI.find(mView, R.id.mainTransactionList); txView.setHasFixedSize(true); txView.addItemDecoration(new DividerItem(getActivity())); final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); txView.setLayoutManager(layoutManager); mSubaccount = service.getCurrentSubAccount(); if (!mIsExchanger) { final TextView firstP = UI.find(mView, R.id.mainFirstParagraphText); final TextView secondP = UI.find(mView, R.id.mainSecondParagraphText); final TextView thirdP = UI.find(mView, R.id.mainThirdParagraphText); if (service.isElements()) UI.hide(firstP); // Don't show a Bitcoin message for elements else firstP.setMovementMethod(LinkMovementMethod.getInstance()); secondP.setMovementMethod(LinkMovementMethod.getInstance()); thirdP.setMovementMethod(LinkMovementMethod.getInstance()); } final TextView balanceText = UI.find(mView, R.id.mainBalanceText); final TextView balanceQuestionMark = UI.find(mView, R.id.mainBalanceQuestionMark); final View.OnClickListener unconfirmedClickListener = new View.OnClickListener() { @Override public void onClick(final View v) { if (mUnconfirmedDialog == null && balanceQuestionMark.getVisibility() == View.VISIBLE) { // Question mark is visible and dialog not shown, so show it mUnconfirmedDialog = UI.popup(getActivity(), R.string.unconfirmedBalanceTitle, 0) .content(R.string.unconfirmedBalanceText).build(); UI.setDialogCloseHandler(mUnconfirmedDialog, mDialogCB); mUnconfirmedDialog.show(); } } }; balanceText.setOnClickListener(unconfirmedClickListener); balanceQuestionMark.setOnClickListener(unconfirmedClickListener); makeBalanceObserver(mSubaccount); if (isPageSelected() && service.getCoinBalance(mSubaccount) != null) { updateBalance(); reloadTransactions(true); } if (!mIsExchanger) { mSwipeRefreshLayout = UI.find(mView, R.id.mainTransactionListSwipe); mSwipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getContext(), R.color.accent)); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Log.d(TAG, "onRefresh -> " + TAG); // user action to force reload balance and tx list onBalanceUpdated(); } }); } registerReceiver(); return mView; }
Example 15
Source File: QueryRetweetResponseCountTask.java From YiBo with Apache License 2.0 | 4 votes |
private void fillRetweetResponseCount(int retweetCount, int commentCount) { TextView tvRetweetText = (TextView)context.findViewById(R.id.tvRetweetText); if (tvRetweetText.getVisibility() != View.VISIBLE) { return; } RetweetClickableSpan retweetClickableSpan = new RetweetClickableSpan(status); CommentClickableSpan commentClickableSpan = new CommentClickableSpan(status); String retweetCountText = context.getString( R.string.label_blog_retweet_retweet_count, retweetCount ); String commentCountText = context.getString( R.string.label_blog_retweet_comment_count, commentCount ); SpannableStringBuilder textSpan = new SpannableStringBuilder(); User sourceUser = status.getUser(); String mentionTitleName = sourceUser != null ? sourceUser.getMentionTitleName() : "@?"; String retweetText = mentionTitleName + ": " + status.getText(); Spannable retweetTextSpan = EmotionLoader.getEmotionSpannable( status.getServiceProvider(), retweetText); textSpan.append(retweetTextSpan); SpannableStringBuilder retweetCountSpan = new SpannableStringBuilder(); retweetCountSpan.append(retweetCountText); retweetCountSpan.setSpan( retweetClickableSpan, 0, retweetCountText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textSpan.append(" ").append(retweetCountSpan); SpannableStringBuilder commentCountSpan = new SpannableStringBuilder(); commentCountSpan.append(commentCountText); commentCountSpan.setSpan( commentClickableSpan, 0, commentCountText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textSpan.append(" ").append(commentCountSpan); tvRetweetText.setText(textSpan); }
Example 16
Source File: ContinuousCaptureActivity.java From pause-resume-video-recording with Apache License 2.0 | 4 votes |
@Override public void handleMessage(Message msg) { ContinuousCaptureActivity activity = mWeakActivity.get(); if (activity == null) { Log.d(TAG, "Got message for dead activity"); return; } switch (msg.what) { case MSG_BLINK_TEXT: { TextView tv = (TextView) activity.findViewById(R.id.recording_text); // Attempting to make it blink by using setEnabled() doesn't work -- // it just changes the color. We want to change the visibility. int visibility = tv.getVisibility(); if (visibility == View.VISIBLE) { visibility = View.INVISIBLE; } else { visibility = View.VISIBLE; } tv.setVisibility(visibility); int delay = (visibility == View.VISIBLE) ? 1000 : 200; sendEmptyMessageDelayed(MSG_BLINK_TEXT, delay); break; } case MSG_FRAME_AVAILABLE: { activity.drawFrame(); break; } case MSG_FILE_SAVE_COMPLETE: { activity.fileSaveComplete(msg.arg1); break; } case MSG_BUFFER_STATUS: { long duration = (((long) msg.arg1) << 32) | (((long) msg.arg2) & 0xffffffffL); activity.updateBufferStatus(duration); break; } default: throw new RuntimeException("Unknown message " + msg.what); } }
Example 17
Source File: ConnInfoDialogFragment.java From moVirt with Apache License 2.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { ArrayList<String> names = getArguments().getStringArrayList("names"); ArrayList<String> errors = getArguments().getStringArrayList("errors"); if (names == null || errors == null || names.size() != errors.size()) { return null; } LayoutInflater inflater = getActivity().getLayoutInflater(); @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.conn_dialog_error, null); LinearLayout container = (LinearLayout) view.findViewById(R.id.conn_error_container); for (int i = 0; i < names.size(); i++) { @SuppressLint("InflateParams") View nextError = inflater.inflate(R.layout.conn_dialog_error_item, null); ImageView arrowIcon = (ImageView) nextError.findViewById(R.id.arrow_icon); TextView header = (TextView) nextError.findViewById(R.id.header); header.setText(names.get(i)); TextView content = (TextView) nextError.findViewById(R.id.content); content.setText(errors.get(i)); if (names.size() == 1) { arrowIcon.setVisibility(View.INVISIBLE); header.setVisibility(View.INVISIBLE); content.setVisibility(View.VISIBLE); } else { LinearLayout headerContainer = (LinearLayout) nextError.findViewById(R.id.headerContainer); final View.OnClickListener toggle = v -> { boolean visible = content.getVisibility() == View.GONE; // make visible now arrowIcon.setImageDrawable(getActivity().getResources().getDrawable(IconDimension.DP_24.getResource(visible))); content.setVisibility(visible ? View.VISIBLE : View.GONE); }; headerContainer.setOnClickListener(toggle); } container.addView(nextError); } return new AlertDialog.Builder(getActivity()) .setView(view) .setTitle(names.size() == 1 ? getString(R.string.dialog_one_engine_errors, names.get(0)) : getString(R.string.dialog_engine_errors)) .setPositiveButton(android.R.string.ok, null) .create(); }
Example 18
Source File: ContentItem.java From Hentoid with Apache License 2.0 | 4 votes |
public static void updateProgress(@NonNull final Content content, @NonNull View rootCardView, int position, boolean isPausedEvent) { boolean isQueueReady = ContentQueueManager.getInstance().isQueueActive() && !ContentQueueManager.getInstance().isQueuePaused() && !isPausedEvent; boolean isFirstItem = (0 == position); ProgressBar pb = rootCardView.findViewById(R.id.pbDownload); content.computeProgress(); content.computeDownloadedBytes(); if ((isFirstItem && isQueueReady) || content.getPercent() > 0) { TextView tvPages = rootCardView.findViewById(R.id.tvPages); pb.setVisibility(View.VISIBLE); if (content.getPercent() > 0) { pb.setIndeterminate(false); pb.setMax(100); pb.setProgress((int) (content.getPercent() * 100)); int color; if (isFirstItem && isQueueReady) color = ThemeHelper.getColor(pb.getContext(), R.color.secondary_light); else color = ContextCompat.getColor(pb.getContext(), R.color.medium_gray); // fixes <= Lollipop progressBar tinting if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) pb.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN); else pb.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY); if (content.getBookSizeEstimate() > 0 && tvPages != null && View.VISIBLE == tvPages.getVisibility()) { String pagesText = tvPages.getText().toString(); int separator = pagesText.indexOf(";"); if (separator > -1) pagesText = pagesText.substring(0, separator); pagesText = pagesText + String.format(Locale.US, "; %.1f MB (est.)", content.getBookSizeEstimate() / (1024 * 1024)); tvPages.setText(pagesText); } } else { if (isFirstItem && isQueueReady) { pb.setIndeterminate(true); // fixes <= Lollipop progressBar tinting if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) pb.getIndeterminateDrawable().setColorFilter(ThemeHelper.getColor(pb.getContext(), R.color.secondary_light), PorterDuff.Mode.SRC_IN); } else pb.setVisibility(View.GONE); } } else { pb.setVisibility(View.GONE); } }
Example 19
Source File: ContinuousCaptureActivity.java From grafika with Apache License 2.0 | 4 votes |
@Override public void handleMessage(Message msg) { ContinuousCaptureActivity activity = mWeakActivity.get(); if (activity == null) { Log.d(TAG, "Got message for dead activity"); return; } switch (msg.what) { case MSG_BLINK_TEXT: { TextView tv = (TextView) activity.findViewById(R.id.recording_text); // Attempting to make it blink by using setEnabled() doesn't work -- // it just changes the color. We want to change the visibility. int visibility = tv.getVisibility(); if (visibility == View.VISIBLE) { visibility = View.INVISIBLE; } else { visibility = View.VISIBLE; } tv.setVisibility(visibility); int delay = (visibility == View.VISIBLE) ? 1000 : 200; sendEmptyMessageDelayed(MSG_BLINK_TEXT, delay); break; } case MSG_FRAME_AVAILABLE: { activity.drawFrame(); break; } case MSG_FILE_SAVE_COMPLETE: { activity.fileSaveComplete(msg.arg1); break; } case MSG_BUFFER_STATUS: { long duration = (((long) msg.arg1) << 32) | (((long) msg.arg2) & 0xffffffffL); activity.updateBufferStatus(duration); break; } default: throw new RuntimeException("Unknown message " + msg.what); } }
Example 20
Source File: GuidanceNextManeuverView.java From msdkui-android with Apache License 2.0 | 4 votes |
/** * Populate the UI with {@link GuidanceNextManeuverData}. * * @param nextManeuverData {@link GuidanceNextManeuverData} */ private void populate(GuidanceNextManeuverData nextManeuverData) { if (nextManeuverData == null) { setVisibility(View.GONE); return; } setVisibility(View.VISIBLE); final ImageView iconView = findViewById(R.id.nextManeuverIconView); if (nextManeuverData.getIconId() == null) { iconView.setVisibility(View.GONE); } else { iconView.setVisibility(View.VISIBLE); iconView.setImageResource(nextManeuverData.getIconId()); } final TextView maneuverDistance = findViewById(R.id.nextManeuverDistance); if (nextManeuverData.getDistance() == null) { maneuverDistance.setVisibility(View.GONE); } else { maneuverDistance.setVisibility(View.VISIBLE); maneuverDistance.setText(DistanceFormatterUtil.format( getContext(), nextManeuverData.getDistance(), mUnitSystem)); } final TextView streetName = findViewById(R.id.afterNextManeuverStreetName); if (nextManeuverData.getStreetName() == null) { streetName.setVisibility(View.GONE); } else { streetName.setVisibility(View.VISIBLE); streetName.setText(nextManeuverData.getStreetName()); } final TextView dotView = findViewById(R.id.dot); dotView.setVisibility(nextManeuverData.getDistance() == null || nextManeuverData.getStreetName() == null ? View.GONE : View.VISIBLE); if (maneuverDistance.getVisibility() == GONE && streetName.getVisibility() == GONE) { setIconEndMargin(0); } }