private void setShowHint(final boolean show) {
    AnimatorSet animation = null;
    if ((hintTextView.getVisibility() == VISIBLE) && !show) {
      animation = new AnimatorSet();
      ObjectAnimator move =
          ObjectAnimator.ofFloat(hintTextView, "translationY", 0, hintTextView.getHeight() / 8);
      ObjectAnimator fade = ObjectAnimator.ofFloat(hintTextView, "alpha", 1, 0);
      animation.playTogether(move, fade);
    } else if ((hintTextView.getVisibility() != VISIBLE) && show) {
      animation = new AnimatorSet();
      ObjectAnimator move =
          ObjectAnimator.ofFloat(hintTextView, "translationY", hintTextView.getHeight() / 8, 0);
      ObjectAnimator fade = ObjectAnimator.ofFloat(hintTextView, "alpha", 0, 1);
      animation.playTogether(move, fade);
    }

    if (animation != null) {
      animation.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
              super.onAnimationStart(animation);
              hintTextView.setVisibility(VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              super.onAnimationEnd(animation);
              hintTextView.setVisibility(show ? VISIBLE : INVISIBLE);
            }
          });
      animation.start();
    }
  }
Exemplo n.º 2
0
  protected void updateMargins() {
    //noinspection ConstantConditions
    final int margin = getResources().getDimensionPixelSize(R.dimen.space_normal);

    final boolean titleVisible = title_TV.getVisibility() == VISIBLE;
    final boolean secondaryTitleVisible = secondaryTitle_TV.getVisibility() == VISIBLE;
    final boolean subTitleVisible = subTitle_TV.getVisibility() == VISIBLE;
    final boolean contentVisible = content_FL.getVisibility() == VISIBLE;
    final boolean iconVisible = icon_IV.getVisibility() == VISIBLE;

    MarginLayoutParams lp = (MarginLayoutParams) subTitle_TV.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) content_FL.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible || subTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) icon_IV.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible || subTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) listContainer_LL.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin =
        titleVisible || secondaryTitleVisible || subTitleVisible || contentVisible || iconVisible
            ? margin
            : 0;
  }
Exemplo n.º 3
0
  public void setTitle(CharSequence title) {
    if (title != null) {
      mTitleView.setText(title);

      if (mTitleView.getVisibility() != VISIBLE) mTitleView.setVisibility(VISIBLE);
    } else {
      if (mTitleView.getVisibility() != GONE) mTitleView.setVisibility(GONE);
    }
  }
 @Override
 public void onClick(View v) {
   assistanceButton.setText(
       assistanceWordsView.getVisibility() == View.VISIBLE
           ? R.string.rate_showassistance
           : R.string.rate_hideassistance);
   assistanceWordsView.setVisibility(
       assistanceWordsView.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
 }
 @Override
 public void onFocusChange(View view, boolean gotFocus) {
   if (mFocusListener != null)
     mFocusListener.onFocusChange(FloatLabeledEditText.this, gotFocus);
   if (gotFocus && hintTextView.getVisibility() == VISIBLE) {
     ObjectAnimator.ofFloat(hintTextView, "alpha", 0.33f, 1f).start();
   } else if (hintTextView.getVisibility() == VISIBLE) {
     AnimatorProxy.wrap(hintTextView).setAlpha(1f); // Need this for compat reasons
     ObjectAnimator.ofFloat(hintTextView, "alpha", 1f, 0.33f).start();
   }
 }
Exemplo n.º 6
0
 public final void showInvisibleViews() {
   if (View.INVISIBLE == mHeaderText.getVisibility()) {
     mHeaderText.setVisibility(View.VISIBLE);
   }
   if (View.INVISIBLE == mHeaderProgress.getVisibility()) {
     mHeaderProgress.setVisibility(View.VISIBLE);
   }
   if (View.INVISIBLE == mHeaderImage.getVisibility()) {
     mHeaderImage.setVisibility(View.VISIBLE);
   }
   if (View.INVISIBLE == mSubHeaderText.getVisibility()) {
     mSubHeaderText.setVisibility(View.VISIBLE);
   }
 }
 @Test
 public void testTextViewMessage() {
   textView = (TextView) activity.findViewById(R.id.section_label);
   assertNotNull("textview is null", textView);
   assertEquals(textView.getVisibility(), View.VISIBLE);
   assertEquals("Fragment 1", textView.getText().toString());
 }
  @Override
  protected void dispatchDraw(Canvas canvas) {
    View childView = getChildAt(mCurrentSelection);
    TextView childTextView = null;
    if (childView instanceof TextView) {
      childTextView = (TextView) childView;
    }

    if (childTextView != null
        && !TextUtils.isEmpty(childTextView.getText())
        && getVisibility() == View.VISIBLE
        && childTextView.getVisibility() == View.VISIBLE) {
      Rect childRect = new Rect();
      childTextView.getLocalVisibleRect(childRect);

      float childViewX = childTextView.getX() + childTextView.getWidth() / 2;
      float childViewY = childTextView.getY() + childTextView.getHeight() / 2;

      int top = (int) (childViewY - mSelectedRect.height() / 2);
      int left = (int) (childViewX - mSelectedRect.width() / 2);

      mSelectedRect.set(left, top, left + mSelectedRect.width(), top + mSelectedRect.height());

      if (isShowSelected && !mSelectedRect.isEmpty()) {
        final Drawable selectedBg = mSelectedBg;
        selectedBg.setBounds(mSelectedRect);
        selectedBg.draw(canvas);
      }
    }

    super.dispatchDraw(canvas);
  }
Exemplo n.º 9
0
 public void setFooterTitle(String title) {
   TextView textView = (TextView) footerView.findViewById(titleId);
   textView.setText(title);
   if (textView.getVisibility() == View.GONE) {
     textView.setVisibility(View.VISIBLE);
   }
 }
  /**
   * Sync a summary view contained within view's subhierarchy with the correct summary text.
   *
   * @param view View where a summary should be located
   */
  void syncSummaryView(View view) {
    // Sync the summary view
    TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
    if (summaryView != null) {
      boolean useDefaultSummary = true;
      if (mChecked && mSummaryOn != null) {
        summaryView.setText(mSummaryOn);
        useDefaultSummary = false;
      } else if (!mChecked && mSummaryOff != null) {
        summaryView.setText(mSummaryOff);
        useDefaultSummary = false;
      }

      if (useDefaultSummary) {
        final CharSequence summary = getSummary();
        if (summary != null) {
          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);
      }
    }
  }
Exemplo n.º 11
0
 // Toggle visibility of the heads-up display.
 private void toggleHUD() {
   if (hudView.getVisibility() == View.VISIBLE) {
     hudView.setVisibility(View.INVISIBLE);
   } else {
     hudView.setVisibility(View.VISIBLE);
   }
 }
Exemplo n.º 12
0
  private void fadeOutBadge(final Runnable onAnimationComplete) {
    synchronized (lock) {
      if (!animationRunning // animation is already running, so shouldn't
          // start a new one
          && lastIncremented.get() != 0 // counter was reset, in which
          // case it would be
          // unintuitive for the badge
          // to fade
          && badgeTextView.getVisibility() == View.VISIBLE) {
        // animation isn't already showing, and the badge is visible
        animationRunning = true;

        badgeLinearLayout.setVisibility(View.VISIBLE);
        // show an animation for the badge with the textview and the
        // background linearlayout fading out
        Animation fadeOutAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);
        fadeOutAnimation.setDuration(ANIMATION_TIME);
        fadeOutAnimation.setAnimationListener(
            new AnimationListener() {

              @Override
              public void onAnimationStart(Animation animation) {}

              @Override
              public void onAnimationRepeat(Animation animation) {}

              @Override
              public void onAnimationEnd(Animation animation) {
                synchronized (lock) {
                  badgeTextView.setVisibility(View.INVISIBLE);

                  // necessary to update again to set the history text
                  // view correctly
                  onAnimationComplete.run();
                  animationRunning = false;
                }
              }
            });
        badgeTextView.setAnimation(fadeOutAnimation);
        fadeOutAnimation.start();
        TransitionDrawable transitionDrawable =
            (TransitionDrawable) badgeLinearLayout.getBackground();
        transitionDrawable.setCrossFadeEnabled(true);
        transitionDrawable.startTransition(ANIMATION_TIME);
      } else {
        // just don't show it - the animation might already be showing,
        // or maybe the badge is
        // already invisible
        badgeLinearLayout.setVisibility(View.INVISIBLE);
        badgeTextView.setVisibility(View.INVISIBLE);

        // this ensures that the history text view gets updated
        // properly, even if the user
        // exits the activity while the animation is in progress (e.g.
        // by going to the Settings)
        onAnimationComplete.run();
      }
    }
  }
Exemplo n.º 13
0
 @UiThread
 void updateLoading(int length) {
   tv_connecting.setText(
       getResources().getString(R.string.link) + length + getString(R.string.signal));
   if (tv_connecting.getVisibility() == View.GONE) {
     tv_connecting.setVisibility(View.VISIBLE);
   }
 }
Exemplo n.º 14
0
 @Override
 protected Parcelable onSaveInstanceState() {
   Bundle bundle = new Bundle();
   bundle.putParcelable(SAVED_SUPER_STATE, super.onSaveInstanceState());
   bundle.putInt(SAVED_LABEL_VISIBILITY, mLabel.getVisibility());
   bundle.putCharSequence(SAVED_HINT, mHint);
   return bundle;
 }
 public void testSetCallDetailsHeader_VoicemailNumber() {
   PhoneCallDetails details =
       getPhoneCallDetails(
           TEST_VOICEMAIL_NUMBER, Calls.PRESENTATION_ALLOWED, TEST_FORMATTED_NUMBER);
   mHelper.setCallDetailsHeader(mNameView, details);
   assertEquals(View.VISIBLE, mNameView.getVisibility());
   assertEquals("Voicemail", mNameView.getText().toString());
 }
  public int getLabelVisibility() {
    TextView labelView = getLabelView();
    if (labelView != null) {
      return labelView.getVisibility();
    }

    return -1;
  }
Exemplo n.º 17
0
 @Override
 public void onBackPressed() {
   if (tv_permit.getVisibility() == View.VISIBLE
   //                && progressBar.getVisibility() == View.VISIBLE
   ) {
     finishAll();
   }
   webView.loadUrl("javascript:G_jsCallBack.QueuedoBackFN();");
 }
Exemplo n.º 18
0
  @Test
  public void testNavigationDrawer() {

    activity.onNavigationDrawerItemSelected(0);
    textView = (TextView) activity.findViewById(R.id.section_label);
    assertEquals(textView.getVisibility(), View.VISIBLE);
    assertEquals("Fragment 1", textView.getText().toString());

    activity.onNavigationDrawerItemSelected(1);
    textView = (TextView) activity.findViewById(R.id.section_label);
    assertEquals(textView.getVisibility(), View.VISIBLE);
    assertEquals("Fragment 2", textView.getText().toString());

    activity.onNavigationDrawerItemSelected(2);
    textView = (TextView) activity.findViewById(R.id.section_label);
    assertEquals(textView.getVisibility(), View.VISIBLE);
    assertEquals("Fragment 3", textView.getText().toString());
  }
 private void showNewPostsBar(int numNewPosts) {
   if (mNewPostsBar == null || mNewPostsBar.getVisibility() == View.VISIBLE) return;
   if (numNewPosts == 1) {
     mNewPostsBar.setText(R.string.reader_label_new_posts_one);
   } else {
     mNewPostsBar.setText(getString(R.string.reader_label_new_posts_multi, numNewPosts));
   }
   AniUtils.startAnimation(mNewPostsBar, R.anim.reader_top_bar_in);
   mNewPostsBar.setVisibility(View.VISIBLE);
 }
Exemplo n.º 20
0
  @Test
  public void testButtonAction() {
    Button button = (Button) activity.findViewById(R.id.button);
    assertEquals(button.getVisibility(), View.VISIBLE);
    assertNotNull("button is null", button);
    button.performClick();

    textView = (TextView) activity.findViewById(R.id.section_label);
    assertEquals(textView.getVisibility(), View.VISIBLE);
    assertEquals("Fragment 3", textView.getText().toString());
  }
Exemplo n.º 21
0
 private void calculateCharactersRemaining() {
   int charactersSpent = composeText.getText().toString().length();
   CharacterCalculator.CharacterState characterState =
       characterCalculator.calculateCharacters(charactersSpent);
   if (characterState.charactersRemaining <= 15
       && charactersLeft.getVisibility() != View.VISIBLE
       && isCharactersLeftViewEnabled) {
     charactersLeft.setVisibility(View.VISIBLE);
   } else if (characterState.charactersRemaining > 15
       && charactersLeft.getVisibility() != View.GONE) {
     charactersLeft.setVisibility(View.GONE);
   }
   charactersLeft.setText(
       characterState.charactersRemaining
           + "/"
           + characterState.maxMessageSize
           + " ("
           + characterState.messagesSpent
           + ")");
 }
Exemplo n.º 22
0
  public void setShortcut(boolean showShortcut, char shortcutKey) {
    final int newVisibility = (showShortcut && mItemData.shouldShowShortcut()) ? VISIBLE : GONE;

    if (newVisibility == VISIBLE) {
      mShortcutView.setText(mItemData.getShortcutLabel());
    }

    if (mShortcutView.getVisibility() != newVisibility) {
      mShortcutView.setVisibility(newVisibility);
    }
  }
Exemplo n.º 23
0
  @Override
  protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int childRight = right - left;
    int childBottom = bottom - top;
    int childLeft = 0;
    int childTop = 0;

    int y = (childBottom - mAvatarSize) / 2;
    childLeft += mSpacing;
    mAvatarDrawable.setBounds(childLeft, y, childLeft + mAvatarSize, y + mAvatarSize);

    childLeft += mAvatarSize + mSpacing;

    if (mButton != null) {
      mButton.layout(childRight - mButtonSize, childTop, childRight, childBottom);
      childRight -= mButtonSize;
    }

    if (mNameView.getVisibility() == View.VISIBLE) {
      if (mAddressView.getVisibility() == View.VISIBLE) {
        childTop =
            (childBottom - mNameView.getMeasuredHeight() - mAddressView.getMeasuredHeight()) / 2;
        mNameView.layout(
            childLeft, childTop, childRight - mSpacing, childTop + mNameView.getMeasuredHeight());
        childTop += mNameView.getMeasuredHeight();
        mAddressView.layout(
            childLeft,
            childTop,
            childRight - mSpacing,
            childTop + mAddressView.getMeasuredHeight());
      } else {
        childTop = (childBottom - mNameView.getMeasuredHeight()) / 2;
        mNameView.layout(
            childLeft, childTop, childRight - mSpacing, childTop + mNameView.getMeasuredHeight());
      }
    } else if (mAddressView.getVisibility() == View.VISIBLE) {
      childTop = (childBottom - mAddressView.getMeasuredHeight()) / 2;
      mAddressView.layout(
          childLeft, childTop, childRight - mSpacing, childTop + mAddressView.getMeasuredHeight());
    }
  }
Exemplo n.º 24
0
 @Override
 public void setPrimaryCallElapsedTime(boolean show, String callTimeElapsed) {
   if (show) {
     if (mElapsedTime.getVisibility() != View.VISIBLE) {
       AnimationUtils.Fade.show(mElapsedTime);
     }
     mElapsedTime.setText(callTimeElapsed);
   } else {
     // hide() animation has no effect if it is already hidden.
     AnimationUtils.Fade.hide(mElapsedTime, View.INVISIBLE);
   }
 }
Exemplo n.º 25
0
 private void checkSingleMessage(
     int messageResource, int messageVisibility, int progressBarvisibility) {
   assertEquals("message is not visible.", messageVisibility, message.getVisibility());
   assertEquals(
       "Message text is incorrect.",
       getActivity().getResources().getText(messageResource),
       message.getText());
   assertEquals(
       "ProgressBar visibility is not correct.",
       progressBarvisibility,
       progressBar.getVisibility());
 }
Exemplo n.º 26
0
 @Override
 public void onFinish() {
   if (listener != null) {
     listener.onEnd();
   }
   if (textView != null
       && textView.getVisibility() != View.INVISIBLE
       && textView.getVisibility() != View.GONE) {
     textView.getCompoundDrawables()[0].setVisible(false, true);
     textView.setText(GoodsHelper.END_HOT);
   }
 }
Exemplo n.º 27
0
 public void onShowAdditionalHeaders() {
   int currentVisibility = mAdditionalHeadersView.getVisibility();
   if (currentVisibility == View.VISIBLE) {
     hideAdditionalHeaders();
     expand(mToView, false);
     expand(mCcView, false);
   } else {
     showAdditionalHeaders();
     expand(mToView, true);
     expand(mCcView, true);
   }
   layoutChanged();
 }
Exemplo n.º 28
0
 private void hideOrDisplayAudioRoutes() {
   if (routeSpeaker.getVisibility() == View.VISIBLE) {
     routeSpeaker.setVisibility(View.GONE);
     routeBluetooth.setVisibility(View.GONE);
     routeReceiver.setVisibility(View.GONE);
     audioRoute.setSelected(false);
   } else {
     routeSpeaker.setVisibility(View.VISIBLE);
     routeBluetooth.setVisibility(View.VISIBLE);
     routeReceiver.setVisibility(View.VISIBLE);
     audioRoute.setSelected(true);
   }
 }
Exemplo n.º 29
0
 /** Show the label using an animation */
 protected void showLabel() {
   if (mLabel.getVisibility() != View.VISIBLE) {
     mLabel.setVisibility(View.VISIBLE);
     mLabel.setAlpha(0f);
     mLabel.setTranslationY(mLabel.getHeight());
     mLabel
         .animate()
         .alpha(1f)
         .translationY(0f)
         .setDuration(ANIMATION_DURATION)
         .setListener(null)
         .start();
   }
 }
Exemplo n.º 30
0
  private void setSubHeaderText(CharSequence label) {
    if (null != mSubHeaderText) {
      if (TextUtils.isEmpty(label)) {
        mSubHeaderText.setVisibility(View.GONE);
      } else {
        mSubHeaderText.setText(label);

        // Only set it to Visible if we're GONE, otherwise VISIBLE will
        // be set soon
        if (View.GONE == mSubHeaderText.getVisibility()) {
          mSubHeaderText.setVisibility(View.VISIBLE);
        }
      }
    }
  }