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();
    }
  }
Example #2
0
 private void setBubbleAndHandlePosition(float y) {
   int bubbleHeight = bubble.getHeight();
   int handleHeight = handle.getHeight();
   handle.setY(getValueInRange(0, height - handleHeight, (int) (y - handleHeight / 2)));
   bubble.setY(
       getValueInRange(0, height - bubbleHeight - handleHeight / 2, (int) (y - bubbleHeight)));
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mLinearLayout = (LinearLayout) inflater.inflate(R.layout.fragment_user_login, container, false);

    // add onClick listeners
    mLinearLayout.findViewById(R.id.btnGoogleSignIn).setOnClickListener(this);
    mLinearLayout.findViewById(R.id.btnLoginSubmit).setOnClickListener(this);
    mLinearLayout.findViewById(R.id.btnLoginRegister).setOnClickListener(this);

    // set quote
    Resources res = getResources();
    String[] quotes = res.getStringArray(R.array.quotes);
    int index = (int) (Math.random() * quotes.length);

    TextView quoteTxt = (TextView) mLinearLayout.findViewById(R.id.quoteTxt);
    quoteTxt.setText(quotes[index]);
    quoteTxt.invalidate();

    if (quoteTxt.getTop() + quoteTxt.getHeight()
        > mLinearLayout.findViewById(R.id.contentContainer).getHeight()) {
      quoteTxt.setVisibility(View.INVISIBLE);
    }

    return mLinearLayout;
  }
  @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);
  }
  @Override
  public void onTextSizeChanged(final TextView textView, float oldSize) {
    if (mCurrentState != CalculatorState.INPUT) { // TODO dont animate when showing graph
      // Only animate text changes that occur from user input.
      return;
    }

    // Calculate the values needed to perform the scale and translation animations,
    // maintaining the same apparent baseline for the displayed text.
    final float textScale = oldSize / textView.getTextSize();
    final float translationX;
    if (android.os.Build.VERSION.SDK_INT >= 17) {
      translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingEnd());
    } else {
      translationX = (1.0f - textScale) * (textView.getWidth() / 2.0f - textView.getPaddingRight());
    }
    final float translationY =
        (1.0f - textScale) * (textView.getHeight() / 2.0f - textView.getPaddingBottom());
    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
        ObjectAnimator.ofFloat(textView, View.SCALE_X, textScale, 1.0f),
        ObjectAnimator.ofFloat(textView, View.SCALE_Y, textScale, 1.0f),
        ObjectAnimator.ofFloat(textView, View.TRANSLATION_X, translationX, 0.0f),
        ObjectAnimator.ofFloat(textView, View.TRANSLATION_Y, translationY, 0.0f));
    animatorSet.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.start();
  }
Example #6
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case BluetoothConnection.MESSAGE_READ:
              byte[] readBuf = (byte[]) msg.obj;
              // construct a string from the valid bytes in the buffer
              String readMessage = new String(readBuf, 0, msg.arg1);
              //                mConversationArrayAdapter.add(mConnectedDeviceName+":  " +
              // readMessage);
              //                debug(readMessage);
              // Indicate scanning in the title
              TextView displayedTextBox = (TextView) findViewById(R.id.recieved_text);
              displayedTextBox.append(readMessage);

              final int scrollAmount =
                  displayedTextBox.getLayout().getLineTop(displayedTextBox.getLineCount())
                      - displayedTextBox.getHeight();

              // if there is no need to scroll, scrollAmount will be <=0
              if (scrollAmount > 0) {
                displayedTextBox.scrollTo(0, scrollAmount);
              }
              // else {
              //                  displayedTextBox.scrollTo(0,0);
              //                }
          }
        }
  private void rotate(int degree) {
    ImageButton[] btns = {mButton, mMaskButton, mFocusButton};

    int target = 0;
    // TODO:for tablet
    if (degree == 0) {
      target = 0;
    } else if (degree == 90) {
      target = -90;
    } else if (degree == 180) {
      target = 180;
    } else if (degree == 270) {
      target = 90;
    }

    for (ImageButton btn : btns) {
      if (btn.equals(mMaskButton) && mMode == 1) {
        continue;
      }
      RotateAnimation rotate =
          new RotateAnimation(mPrevTarget, target, btn.getWidth() / 2, btn.getHeight() / 2);
      rotate.setDuration(500);
      rotate.setFillAfter(true);
      btn.startAnimation(rotate);
    }

    RotateAnimation rotate =
        new RotateAnimation(mPrevTarget, target, mText.getWidth() / 2, mText.getHeight() / 2);
    rotate.setDuration(500);
    rotate.setFillAfter(true);
    mText.startAnimation(rotate);

    RotateAnimation rotateZoomIn =
        new RotateAnimation(mPrevTarget, target, mZoomIn.getWidth() / 2, mZoomIn.getHeight() / 2);
    rotateZoomIn.setDuration(500);
    rotateZoomIn.setFillAfter(true);
    mZoomIn.startAnimation(rotateZoomIn);

    RotateAnimation rotateZoomOut =
        new RotateAnimation(mPrevTarget, target, mZoomOut.getWidth() / 2, mZoomOut.getHeight() / 2);
    rotateZoomOut.setDuration(500);
    rotateZoomOut.setFillAfter(true);
    mZoomOut.startAnimation(rotateZoomOut);

    // 回転時、表示がズレるので、断念
    /*
    if(mWebView != null){
        int x = mWebView.getWidth()/2;
        int y = mWebView.getHeight()/2;
        Log.d(TAG, "x,y = " + x + "," + y);
        RotateAnimation rotateWeb = new RotateAnimation(mPrevTarget, target, 100, 100);
        rotateWeb.setDuration(0);
        rotateWeb.setFillAfter(true);
        mWebView.startAnimation(rotate);
    }
    */

    mPrevTarget = target;
  }
 protected void configureTextView(TextView view) {
   textLP = new LayoutParams(LayoutParams.MATCH_PARENT, DisplayUtil.dip2px(context, 50));
   view.setTextColor(textColor);
   view.setGravity(Gravity.CENTER);
   view.setTextSize(textSize);
   view.setLines(1);
   view.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
   view.setLayoutParams(textLP);
   view.getHeight();
 }
  /** Redraws default text with circle animation. */
  private void reDrawDefaultLayout() {
    int cx = mDefaultText.getMeasuredWidth() / 2;
    int cy = mDefaultText.getMeasuredHeight() / 2;

    int finalRadius = Math.max(mDefaultText.getWidth(), mDefaultText.getHeight()) / 2;

    Animator anim = ViewAnimationUtils.createCircularReveal(mDefaultText, cx, cy, 0, finalRadius);

    mDefaultText.setVisibility(View.VISIBLE);
    anim.start();
  }
Example #10
0
  @Override
  public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
    // Translate overlay and image
    float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize;
    int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight();
    ViewHelper.setTranslationY(
        mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0));
    ViewHelper.setTranslationY(
        mImageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0));

    // Change alpha of overlay
    ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1));

    // Scale title text
    float scale =
        1
            + ScrollUtils.getFloat(
                (flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA);
    ViewHelper.setPivotX(mTitleView, 0);
    ViewHelper.setPivotY(mTitleView, 0);
    ViewHelper.setScaleX(mTitleView, scale);
    ViewHelper.setScaleY(mTitleView, scale);

    // Translate title text
    int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale);
    int titleTranslationY = maxTitleTranslationY - scrollY;
    ViewHelper.setTranslationY(mTitleView, titleTranslationY);

    // Translate FAB
    int maxFabTranslationY = mFlexibleSpaceImageHeight - mFab.getHeight() / 2;
    float fabTranslationY =
        ScrollUtils.getFloat(
            -scrollY + mFlexibleSpaceImageHeight - mFab.getHeight() / 2,
            mActionBarSize - mFab.getHeight() / 2,
            maxFabTranslationY);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin,
      // which causes FAB's OnClickListener not working.
      FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams();
      lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth();
      lp.topMargin = (int) fabTranslationY;
      mFab.requestLayout();
    } else {
      ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth());
      ViewHelper.setTranslationY(mFab, fabTranslationY);
    }

    // Show/hide FAB
    if (fabTranslationY < mFlexibleSpaceShowFabOffset) {
      hideFab();
    } else {
      showFab();
    }
  }
Example #11
0
 @MediumTest
 public void testPreconditions() {
   assertTrue(
       "top text should be larger than screen", mTopText.getHeight() > mScrollView.getHeight());
   assertTrue(
       "scroll view should have focus (because nothing else focusable "
           + "is on screen), but "
           + getActivity().getScrollView().findFocus()
           + " does instead",
       getActivity().getScrollView().isFocused());
 }
 /** Show the label using an animation */
 private void showLabel() {
   mLabel.setVisibility(View.VISIBLE);
   mLabel.setAlpha(0f);
   mLabel.setTranslationY(mLabel.getHeight());
   mLabel
       .animate()
       .alpha(1f)
       .translationY(0f)
       .setDuration(ANIMATION_DURATION)
       .setListener(null)
       .start();
 }
 private void setContent(final TextView view, final String prefix, final String text) {
   if (view != null) {
     if (this.itemHight == 0) {
       this.itemHight = view.getHeight();
     }
     if ((text != null) && (text.length() > 0)) {
       view.setText(prefix + text);
       if (this.itemHight == 0) {
         this.itemHight = view.getHeight();
       }
       if ((this.itemHight > 0) && (view.getHeight() == 0)) {
         // Workaround for recycled Items:
         // Sometimes Text is not visible because previous
         // ItemHeight==0 is sometimes remembered.
         view.setHeight(this.itemHight);
       }
     } else {
       view.setHeight(0);
     }
   }
 }
Example #14
0
 protected void printPage() {
   TextView title = (TextView) findViewById(R.id.textView10);
   TextView body = (TextView) findViewById(R.id.textView3);
   TextView status = (TextView) findViewById(R.id.textView11);
   title.setText(Titles[CurrentPage]);
   body.setText(BodyTexts[CurrentPage]);
   status.setText(
       "Page: " + String.valueOf(CurrentPage + 1) + "/" + String.valueOf(Titles.length));
   tvPos0.set(0, 0);
   tvPos1.set(0, 0);
   scrWidth = textView.getWidth();
   scrHeight = textView.getHeight();
 }
  private void writeLog(String s) {
    TextView loginfo = (TextView) findViewById(R.id.info_area);
    loginfo.append(s + "\n");

    // find the amount we need to scroll. This works by
    // asking the TextView's internal layout for the position
    // of the final line and then subtracting the TextView's height
    final int scrollAmount =
        loginfo.getLayout().getLineTop(loginfo.getLineCount()) - loginfo.getHeight();
    // if there is no need to scroll, scrollAmount will be <=0
    if (scrollAmount > 0) loginfo.scrollTo(0, scrollAmount);
    else loginfo.scrollTo(0, 0);
  }
  /**
   * 显示弹出窗口
   *
   * @param which 显示哪个弹出窗口
   */
  private void showPopwindow(int which) {
    switch (which) {
      case CLASSFICATION_POP:
        {
          int[] location = new int[2];
          classificationTextView.getLocationOnScreen(location);
          if (choose_classfication_popupWindow == null) {
            initPopwindow(CLASSFICATION_POP);
          }
          Log.i("classificationTextView", classificationTextView.toString());
          Log.i("choose_classfication_popupWindow", choose_classfication_popupWindow.toString());
          choose_classfication_popupWindow.showAtLocation(
              addClassification,
              Gravity.NO_GRAVITY,
              location[0],
              location[1] + classificationTextView.getHeight());
        }
        break;
      case ChooseGroup_POP:
        {
          int[] location = new int[2];
          addShareGroupTextView.getLocationOnScreen(location);
          if (choose_group_popWindow == null) {
            initPopwindow(ChooseGroup_POP);
          }

          choose_group_popWindow.showAtLocation(
              chooseGroup,
              Gravity.NO_GRAVITY,
              location[0],
              location[1] + addShareGroupTextView.getHeight());
        }

      default:
        break;
    }
  }
 /** Hide the label using an animation */
 private void hideLabel() {
   mLabel.setAlpha(1f);
   mLabel.setTranslationY(0f);
   mLabel
       .animate()
       .alpha(0f)
       .translationY(mLabel.getHeight())
       .setDuration(ANIMATION_DURATION)
       .setListener(
           new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
               mLabel.setVisibility(View.GONE);
             }
           })
       .start();
 }
  /** 对TextView进行伸缩处理 */
  private void flexibleHeight() {
    isExpand = !isExpand;
    int textHeight = 0;
    float startDegree = 0.0f;
    float endDegree = 180.0f;
    if (isExpand) {
      // 如果是展开模式,那么取消最大行为maxLine的限制
      textHeight = contentLine * mTextView.getLineHeight();
      mTextView.setMaxLines(contentLine);
    } else {
      textHeight = mTextView.getLineHeight() * maxLine;
      endDegree = 0.0f;
      startDegree = 180.0f;
    }
    final LayoutParams mParam = (LayoutParams) mTextView.getLayoutParams();
    // TextView的平移动画
    ValueAnimator animator_textView = ValueAnimator.ofInt(mTextView.getHeight(), textHeight);
    animator_textView.addUpdateListener(
        new AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mParam.height = (Integer) animation.getAnimatedValue();
            mTextView.setLayoutParams(mParam);
          }
        });
    // imageView的旋转动画
    ObjectAnimator animator_img =
        ObjectAnimator.ofFloat(mImageView, "rotation", startDegree, endDegree);

    AnimatorSet mAnimatorSets = new AnimatorSet();
    mAnimatorSets.setDuration(500);
    mAnimatorSets.play(animator_img).with(animator_textView);
    mAnimatorSets.start();
    mAnimatorSets.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            // 动画结束之后,如果是非展开模式,则设置最大行数为maxLine
            if (!isExpand) {
              mTextView.setMaxLines(maxLine);
            }
          }
        });
  }
 private static int getLineAtCoordinate(float y, TextView tv, Layout layout) {
   if (tv.getLayout() == null) {
     y -= tv.getCompoundPaddingTop();
   } else {
     y -= tv.getTotalPaddingTop();
   }
   // Clamp the position to inside of the view.
   y = Math.max(0.0f, y);
   float bottom = tv.getHeight() - 1;
   if (tv.getLayout() == null) {
     bottom -= tv.getCompoundPaddingBottom();
   } else {
     bottom -= tv.getTotalPaddingBottom();
   }
   y = Math.min(bottom, y);
   y += tv.getScrollY();
   return layout.getLineForVertical((int) y);
 }
  private void updateBlur() {
    if (!(mDrawable instanceof BitmapDrawable)) {
      return;
    }
    final int textViewHeight = mTextView.getHeight();
    if (textViewHeight == 0) {
      return;
    }

    // Determine the size of the TextView compared to the height of the ImageView
    final float ratio = (float) textViewHeight / mImageView.getHeight();

    // Get the Bitmap
    final BitmapDrawable bitmapDrawable = (BitmapDrawable) mDrawable;
    final Bitmap originalBitmap = bitmapDrawable.getBitmap();

    // Calculate the height as a ratio of the Bitmap
    int height = (int) (ratio * originalBitmap.getHeight());

    // The y position is the number of pixels height represents from the bottom of the Bitmap
    final int y = originalBitmap.getHeight() - height;

    final Bitmap portionToBlur =
        Bitmap.createBitmap(originalBitmap, 0, y, originalBitmap.getWidth(), height);
    final Bitmap blurredBitmap = portionToBlur.copy(Bitmap.Config.ARGB_8888, true);

    // Use RenderScript to blur the pixels
    RenderScript rs = RenderScript.create(getContext());
    ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    Allocation tmpIn = Allocation.createFromBitmap(rs, portionToBlur);
    Allocation tmpOut = Allocation.createFromBitmap(rs, blurredBitmap);
    theIntrinsic.setRadius(25f);
    theIntrinsic.setInput(tmpIn);
    theIntrinsic.forEach(tmpOut);
    tmpOut.copyTo(blurredBitmap);
    new Canvas(blurredBitmap).drawColor(mScrimColor);

    // Create the new bitmap using the old plus the blurred portion and display it
    final Bitmap newBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
    final Canvas canvas = new Canvas(newBitmap);
    canvas.drawBitmap(blurredBitmap, 0, y, new Paint());
    mImageView.setImageBitmap(newBitmap);
  }
  /**
   * Helper method to pretty print object in the result_text field
   *
   * @param object
   */
  private void println(Object object) {
    if (resultText == null) return;

    StringBuffer sb = new StringBuffer(resultText.getText());
    String text;
    if (object == null) {
      text = "null";
    } else {
      text = object.toString();
    }
    sb.append(text).append("\n");
    resultText.setText(sb);

    // Auto scroll to bottom if needed
    if (resultText.getLayout() != null) {
      int scroll =
          resultText.getLayout().getLineTop(resultText.getLineCount()) - resultText.getHeight();
      resultText.scrollTo(0, scroll > 0 ? scroll : 0);
    }
  }
  public void statusUpdate(String msg) {
    TextView tv = (TextView) MyApp.context.findViewById(R.id.textview);
    tv.append(msg);

    try {
      int lineTop = 0;
      try {
        lineTop = tv.getLayout().getLineTop(tv.getLineCount());
      } catch (Throwable e) {
        lineTop = 0;
      }

      final int scrollAmount = lineTop - tv.getHeight();

      if (scrollAmount > 0) {
        tv.scrollTo(0, scrollAmount);
      } else {
        tv.scrollTo(0, 0);
      }

    } catch (Throwable e) {
      Log.i(MyApp.TAG, e.getMessage().toString());
    }
  }
Example #23
0
 private void dragView(int x, int y) {
   // Log.d(tag, "dragView: (" + x + "," + y + ")");
   mWindowParams.x = x;
   mWindowParams.y = y + (dragView.getHeight());
   mWindowManager.updateViewLayout(dragView, mWindowParams);
 }
Example #24
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_site_access);
    Bundle extras = getIntent().getExtras();
    String title = extras.getString("title");
    setTitle(title);
    new Thread(getSite).start();
    textView = (TextView) findViewById(R.id.textView3);
    // Display display = ((WindowManager) getSystemService(WINDOW_SERVICE))
    //  .getDefaultDisplay();
    scrWidth = textView.getWidth();
    scrHeight = textView.getHeight();

    // ---------
    RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.site_info_lo);
    textView.setOnTouchListener(
        new OnSwipeTouchListener(this) {
          @Override
          public void onSwipeLeft() {
            if (CurrentPage < 3) {
              CurrentPage++;
              printPage();
            }
          }

          @Override
          public void onSwipeRight() {
            if (CurrentPage > 0) {
              CurrentPage--;
              printPage();
            }
          }

          @Override
          public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction() & MotionEvent.ACTION_MASK) {
              case MotionEvent.ACTION_DOWN:
                start.set(event.getX(), event.getY());
                tvPos0.set((int) event.getX(), (int) event.getY());
                mode = Mode.DRAG;
                break;
              case MotionEvent.ACTION_POINTER_DOWN:
                oldDist = spacing(event);
                if (oldDist > 10f) {
                  mode = Mode.ZOOM;
                }
                break;
              case MotionEvent.ACTION_UP:
              case MotionEvent.ACTION_POINTER_UP:
                mode = Mode.NONE;
                tvPos1.set(tvPosSave.x, tvPosSave.y);
                break;
              case MotionEvent.ACTION_MOVE:
                if (mode == Mode.DRAG) {
                  doScroll(event);
                } else if (mode == Mode.ZOOM) {
                  doZoom(event);
                }
                break;
            }
            return super.onTouch(v, event);
          }
        });
    // text3.setMovementMethod(new ScrollingMovementMethod());
  }
  public void update(RecyclerView referenceList, float dx, float dy) {
    if (indexList != null && indexList.getChildCount() > 2) {
      show();
      updatePosBasedOnReferenceList(referenceList);

      View firstVisibleView = indexList.getChildAt(0);
      View secondVisibleView = indexList.getChildAt(1);

      TextView firstRowIndex = (TextView) firstVisibleView.findViewById(R.id.section_title);
      TextView secondRowIndex = (TextView) secondVisibleView.findViewById(R.id.section_title);

      int visibleRange = indexList.getChildCount();
      int actual = indexList.getChildPosition(firstVisibleView);
      int next = actual + 1;
      int last = actual + visibleRange;

      // RESET STICKY LETTER INDEX
      stickyIndex.setText(String.valueOf(getIndexContext(firstRowIndex)).toUpperCase());
      stickyIndex.setVisibility(TextView.VISIBLE);
      ViewCompat.setAlpha(firstRowIndex, 1);

      if (dy > 0) {
        // USER SCROLLING DOWN THE RecyclerView
        if (next <= last) {
          if (isHeader(firstRowIndex, secondRowIndex)) {
            stickyIndex.setVisibility(TextView.INVISIBLE);
            firstRowIndex.setVisibility(TextView.VISIBLE);
            ViewCompat.setAlpha(
                firstRowIndex,
                (1 - (Math.abs(ViewCompat.getY(firstVisibleView)) / firstRowIndex.getHeight())));
            secondRowIndex.setVisibility(TextView.VISIBLE);
          } else {
            firstRowIndex.setVisibility(TextView.INVISIBLE);
            stickyIndex.setVisibility(TextView.VISIBLE);
          }
        }
      } else if (dy < 0) {
        // USER IS SCROLLING UP THE RecyclerVIew
        if (next <= last) {
          // RESET FIRST ROW STATE
          firstRowIndex.setVisibility(TextView.INVISIBLE);
          if ((isHeader(firstRowIndex, secondRowIndex)
                  || (getIndexContext(firstRowIndex) != getIndexContext(secondRowIndex)))
              && isHeader(firstRowIndex, secondRowIndex)) {
            stickyIndex.setVisibility(TextView.INVISIBLE);
            firstRowIndex.setVisibility(TextView.VISIBLE);
            ViewCompat.setAlpha(
                firstRowIndex,
                1 - (Math.abs(ViewCompat.getY(firstVisibleView) / firstRowIndex.getHeight())));
            secondRowIndex.setVisibility(TextView.VISIBLE);
          } else {
            secondRowIndex.setVisibility(TextView.INVISIBLE);
          }
        }
      }

      if (stickyIndex.getVisibility() == TextView.VISIBLE) {
        firstRowIndex.setVisibility(TextView.INVISIBLE);
      }
    } else {
      hide();
    }
  }
 private void updateLog() {
   final String logContents = NativeHelper.log.toString();
   if (logContents != null && logContents.trim().length() > 0) consoleText.setText(logContents);
   consoleScroll.scrollTo(0, consoleText.getHeight());
 }
 @TargetApi(Build.VERSION_CODES.HONEYCOMB)
 public void onAnimationEnd(Animation animation) {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
     indexText.setTranslationY(indexText.getHeight());
   indexText.setVisibility(View.GONE);
 }
Example #28
0
    public boolean updateInfo(DrawSettings d) {
      String text = null;
      TurnType[] type = new TurnType[1];
      boolean showNextTurn = false;
      if (routingHelper != null && routingHelper.isRouteCalculated()) {
        if (routingHelper.isFollowingMode()) {
          if (settings.SHOW_STREET_NAME.get()) {
            text = routingHelper.getCurrentName(type);
            if (text == null) {
              text = "";
            }
          }
        } else {
          int di = MapRouteInfoMenu.getDirectionInfo();
          if (di >= 0
              && MapRouteInfoMenu.isControlVisible()
              && di < routingHelper.getRouteDirections().size()) {
            showNextTurn = true;
            RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
            type[0] = next.getTurnType();
            text =
                RoutingHelper.formatStreetName(
                    next.getStreetName(), next.getRef(), next.getDestinationName());
            //						if(next.distance > 0) {
            //							text += " " + OsmAndFormatter.getFormattedDistance(next.distance,
            // map.getMyApplication());
            //						}
            if (text == null) {
              text = "";
            }
          }
        }
      } else if (settings.getApplicationMode() != ApplicationMode.DEFAULT
          && map.getMapViewTrackingUtilities().isMapLinkedToLocation()
          && settings.SHOW_STREET_NAME.get()) {
        RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
        if (rt != null) {
          text =
              RoutingHelper.formatStreetName(
                  rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
                  rt.getRef(),
                  rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()));
        }
        if (text == null) {
          text = "";
        }
      }
      if (!showNextTurn && updateWaypoint()) {
        updateVisibility(true);
        updateVisibility(addressText, false);
        updateVisibility(addressTextShadow, false);
      } else if (text == null) {
        updateVisibility(false);
      } else {
        updateVisibility(true);
        updateVisibility(waypointInfoBar, false);
        updateVisibility(addressText, true);
        updateVisibility(addressTextShadow, shadowRad > 0);
        boolean update = turnDrawable.setTurnType(type[0]);

        int h = addressText.getHeight() / 4 * 3;
        if (h != turnDrawable.getBounds().bottom) {
          turnDrawable.setBounds(0, 0, h, h);
        }
        if (update) {
          if (type[0] != null) {
            addressTextShadow.setCompoundDrawables(turnDrawable, null, null, null);
            addressTextShadow.setCompoundDrawablePadding(4);
            addressText.setCompoundDrawables(turnDrawable, null, null, null);
            addressText.setCompoundDrawablePadding(4);
          } else {
            addressTextShadow.setCompoundDrawables(null, null, null, null);
            addressText.setCompoundDrawables(null, null, null, null);
          }
        }
        if (!text.equals(addressText.getText().toString())) {
          if (!text.equals("")) {
            topBar.setContentDescription(text);
          } else {
            topBar.setContentDescription(
                map.getResources().getString(R.string.map_widget_top_text));
          }
          addressTextShadow.setText(text);
          addressText.setText(text);
          return true;
        }
      }
      return false;
    }