Esempio n. 1
1
 public static Bitmap convertViewToBitmap(View paramView) {
   paramView.measure(
       View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
   paramView.layout(0, 0, paramView.getMeasuredWidth(), paramView.getMeasuredHeight());
   paramView.buildDrawingCache();
   return paramView.getDrawingCache();
 }
Esempio n. 2
1
 public static Bitmap convertViewToBitmap(View view) {
   view.measure(
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
   view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
   view.buildDrawingCache();
   return view.getDrawingCache();
 }
Esempio n. 3
0
 protected void onMeasure(int paramInt1, int paramInt2)
 {
   int i = View.MeasureSpec.getSize(paramInt1);
   int j = View.MeasureSpec.getSize(paramInt2);
   this.standardLayout.scaleToBounds(i, j);
   this.bottomLayout.scaleToBounds(this.standardLayout);
   this.checkinLayout.scaleToBounds(this.standardLayout);
   this.headerLayout.scaleToBounds(this.standardLayout);
   this.headerLayout.measureView(this.mHeadView);
   this.bottomLayout.measureView(this.mInputView);
   this.bottomLayout.measureView(this.mJoinView);
   int k = this.standardLayout.height;
   if (k > this.normalLayoutHeight)
   {
     this.specialLayoutHeight = k;
     if (this.normalLayoutHeight == 0)
       this.normalLayoutHeight = k;
   }
   if (k < this.normalLayoutHeight);
   for (this.isInputShowing = true; ; this.isInputShowing = false)
   {
     this.chatMemberLayout.scaleToBounds(this.standardLayout);
     this.chatMemberLayout.measureView(this.mExpressionView);
     this.chatMemberLayout.measureView(this.mActionsView);
     this.chatMemberLayout.measureView(this.mInviteView);
     int m = getInputOffset();
     this.mListContainer.measure(this.standardLayout.getWidthMeasureSpec(), View.MeasureSpec.makeMeasureSpec(k - this.mHeadView.getMeasuredHeight() - this.mInputView.getMeasuredHeight() - m, 1073741824));
     this.checkinLayout.measureView(this.mCheckinButton);
     this.mCheckinButton.setPadding((int)(0.3F * this.checkinLayout.width), 0, 0, 0);
     this.mCheckinButton.setTextSize(0, SkinManager.getInstance().getSubTextSize());
     setMeasuredDimension(this.standardLayout.width, k);
     return;
   }
 }
  public static void bound(Context context, View view, boolean isFullScreen) { // Don't need this?!
    if (!disableAdjusting) {
      int windowWidth = getWindowWidth(context);
      int windowHeight = getWindowHeight(context);
      int adjustHeight = 0;
      if (!isFullScreen && respectAdjustHeight)
        adjustHeight += getStatusBarHeight(context) * adjustHeightMultiplier;

      int widthSpec = View.MeasureSpec.makeMeasureSpec(windowWidth, View.MeasureSpec.EXACTLY);
      int heightSpec =
          View.MeasureSpec.makeMeasureSpec(windowHeight - adjustHeight, View.MeasureSpec.EXACTLY);
      int heightC = windowHeight - adjustHeight;

      Logging.logt(
          String.format(
              "Window height: %s; Window width: %s; "
                  + "Adjust height: %s; status bar height: %s;"
                  + "widthSpec: %s; heightSpec: %s",
              windowHeight,
              windowWidth,
              adjustHeight,
              getStatusBarHeight(context),
              widthSpec,
              heightSpec));

      view.measure(widthSpec, heightSpec);
      view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
    }
  }
Esempio n. 5
0
 public UpDownLayout(Context context, AttributeSet attrs, myThread arg0) {
   super(context, attrs);
   th = arg0;
   LayoutInflater.from(context).inflate(R.layout.fragment_3_item, this);
   upTv = (TextView) findViewById(R.id.title_tv);
   downTv = (TextView) findViewById(R.id.desc_tv);
   handler = new myHandler();
   int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
   int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
   downTv.measure(w, h);
   int height = downTv.getMeasuredHeight();
   downTv.setPadding(0, -1 * height, 0, 0);
   //        upTv.setOnClickListener(new listener(handler,height));
   upTv.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View view) {
           /* Log.i("TAG","flag"+flag);
           if(!flag){
               click();
               flag=true;
           }*/
           TextView listener_tv = (TextView) view;
           if (listener_tv.getPaddingTop() == 0) th.getRunnable().setMotion(UP);
           else th.getRunnable().setMotion(DOWN);
           th.getRunnable().setTv(listener_tv);
         }
       });
 }
Esempio n. 6
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
    int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
    int tmpHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);

    int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
    int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
    int tmpWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize, widthMode);

    // fixed scrollview height problems
    if (heightMode == MeasureSpec.UNSPECIFIED
        && getParent() != null
        && (getParent() instanceof ScrollView)) {
      int baseHeight = 0;
      Context context = getContext();
      if (context instanceof Activity) {
        Activity act = (Activity) context;
        int measuredHeight = act.findViewById(android.R.id.content).getMeasuredHeight();
        baseHeight = measuredHeight;
      } else {
        baseHeight = getScreenHeight();
      }
      tmpHeightMeasureSpec = MeasureSpec.makeMeasureSpec(baseHeight, heightMode);
    }

    mPercentLayoutHelper.adjustChildren(tmpWidthMeasureSpec, tmpHeightMeasureSpec);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (mPercentLayoutHelper.handleMeasuredStateTooSmall()) {
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
  }
  public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    if (this.mTarget == null) {
      ensureTarget();
    }
    if (this.mTarget == null) {
      return;
    }
    this.mTarget.measure(
        View.MeasureSpec.makeMeasureSpec(
            getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), 1073741824),
        View.MeasureSpec.makeMeasureSpec(
            getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), 1073741824));

    this.mCircleView.measure(
        View.MeasureSpec.makeMeasureSpec(this.mCircleWidth, 1073741824),
        View.MeasureSpec.makeMeasureSpec(this.mCircleHeight, 1073741824));

    if ((!this.mUsingCustomStart) && (!this.mOriginalOffsetCalculated)) {
      this.mOriginalOffsetCalculated = true;
      this.mCurrentTargetOffsetTop =
          (this.mOriginalOffsetTop = -this.mCircleView.getMeasuredHeight());
    }
    this.mCircleViewIndex = -1;

    for (int index = 0; index < getChildCount(); index++)
      if (getChildAt(index) == this.mCircleView) {
        this.mCircleViewIndex = index;
        break;
      }
  }
 public HeaderDecoration(final Context context, RecyclerView parent, @LayoutRes int resId) {
   // inflate and measure the layout
   mLayout = LayoutInflater.from(context).inflate(resId, parent, false);
   mLayout.measure(
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
 }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    int itemType = this.getItemViewType(position);
    switch (itemType) {
      case ITEM_TYPE:
        // Get the data item for this position
        WakelockStats wakelock = (WakelockStats) getItem(position);

        // Check if an existing view is being reused, otherwise inflate the view
        WakelockViewHolder viewHolder; // view lookup cache stored in tag
        if (convertView == null) {
          viewHolder = new WakelockViewHolder();

          LayoutInflater inflater = LayoutInflater.from(getContext());
          convertView = inflater.inflate(R.layout.fragment_wakelocks_listitem, parent, false);
          viewHolder.name = (TextView) convertView.findViewById(R.id.textviewWakelockName);
          if (mTruncateEnd) {
            viewHolder.name.setEllipsize(TextUtils.TruncateAt.END);
          }
          viewHolder.wakeTime = (TextView) convertView.findViewById(R.id.textviewWakelockTime);
          viewHolder.wakeCount = (TextView) convertView.findViewById(R.id.textViewWakelockCount);

          convertView.setTag(viewHolder);
        } else {
          viewHolder = (WakelockViewHolder) convertView.getTag();
        }

        // Populate the data into the template view using the data object
        viewHolder.name.setText(wakelock.getName());
        viewHolder.name.setSelected(true);

        viewHolder.wakeTime.setText(String.valueOf(wakelock.getDurationAllowedFormatted()));
        viewHolder.wakeCount.setText(String.valueOf(wakelock.getAllowedCount()));

        // Size the count box width to at least the height.
        viewHolder.wakeCount.measure(
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
        int height = viewHolder.wakeCount.getMeasuredHeight();
        int width = viewHolder.wakeCount.getMeasuredWidth();
        if (height > width) {
          viewHolder.wakeCount.setLayoutParams(new LinearLayout.LayoutParams(height, height));
        } else {
          viewHolder.wakeCount.setLayoutParams(new LinearLayout.LayoutParams(width, width));
        }
        float[] hsv = getBackColorFromSpectrum(wakelock);
        viewHolder.wakeCount.setBackgroundColor(Color.HSVToColor(hsv));

        hsv = getForeColorFromBack(hsv);
        viewHolder.wakeCount.setTextColor(Color.HSVToColor(hsv));
        break;

      case CATEGORY_TYPE:
        convertView = getCategoryView(position, convertView, parent);
        break;
    }

    return convertView;
  }
Esempio n. 10
0
 protected void onMeasure(int paramInt1, int paramInt2) {
   int i = View.MeasureSpec.getSize(paramInt1);
   int j = View.MeasureSpec.getSize(paramInt2);
   this.standardLayout.scaleToBounds(i, j);
   this.dotsLayout.scaleToBounds(this.standardLayout);
   this.standardLayout.measureView(this.viewPager);
   setMeasuredDimension(i, this.standardLayout.height);
 }
Esempio n. 11
0
 /**
  * 获取视图的长宽,用于视图未显示之前
  *
  * @param view
  * @return [长,宽]
  */
 public static int[] getViewSize(View view) {
   int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
   int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
   view.measure(w, h);
   int height = view.getMeasuredHeight();
   int width = view.getMeasuredHeight();
   return new int[] {height, width};
 }
 private void measureHeader(View view) {
   if (view != null) {
     measureChild(
         view,
         android.view.View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(), 0x40000000),
         android.view.View.MeasureSpec.makeMeasureSpec(mPinnedHeaderHeight, 0x40000000));
   }
 }
  private void configHeaderView(int firstVisibleItem) {
    int firstVisibleItemType = getPackedPositionType(getExpandableListPosition(firstVisibleItem));
    if (firstVisibleItemType != PACKED_POSITION_TYPE_NULL) {
      mAdapter.configHeaderView(
          mHeaderView, getPackedPositionGroup(getExpandableListPosition(firstVisibleItem)));
      if (firstVisibleItemType == PACKED_POSITION_TYPE_GROUP) {
        if (getPackedPositionType(getExpandableListPosition(firstVisibleItem + 1))
                == PACKED_POSITION_TYPE_GROUP
            || getPackedPositionType(getExpandableListPosition(firstVisibleItem + 1))
                == PACKED_POSITION_TYPE_NULL) {
          mCurHeaderViewState = PINNED_HEADER_STATE_INVISIBLE;
        } else {
          mCurHeaderViewState = PINNED_HEADER_STATE_PINNED;
        }
      } else {
        View v = getChildAt(0);
        if (v.getBottom() > mHeaderView.getMeasuredHeight()) {
          mCurHeaderViewState = PINNED_HEADER_STATE_PINNED;
        } else {
          if (getPackedPositionType(getExpandableListPosition(firstVisibleItem + 1))
              == PACKED_POSITION_TYPE_GROUP) {
            mCurHeaderViewState = PINNED_HEADER_STATE_PUSHING_UP;
          } else {
            mCurHeaderViewState = PINNED_HEADER_STATE_PINNED;
          }
        }
      }
    } else {
      mCurHeaderViewState = PINNED_HEADER_STATE_INVISIBLE;
    }
    if (mCurHeaderViewState != PINNED_HEADER_STATE_INVISIBLE) {
      if (mCurHeaderViewState == PINNED_HEADER_STATE_PUSHING_UP) {
        View childAtOne = getChildAt(1);
        mCurHeaderViewPushUpDistance =
            mHeaderView.getMeasuredHeight() - (childAtOne != null ? childAtOne.getTop() : 0);

      } else {
        mCurHeaderViewPushUpDistance = 0;
      }
      mHeaderView.setVisibility(View.VISIBLE);
      int widthSpec =
          View.MeasureSpec.makeMeasureSpec(
              mHeaderView.getMeasuredWidth(), View.MeasureSpec.EXACTLY);
      int heightSpec =
          View.MeasureSpec.makeMeasureSpec(
              mHeaderView.getMeasuredHeight(), View.MeasureSpec.EXACTLY);
      mHeaderView.measure(widthSpec, heightSpec);
      mHeaderView.layout(
          0,
          -mCurHeaderViewPushUpDistance,
          mHeaderView.getMeasuredWidth(),
          mHeaderView.getMeasuredHeight() - mCurHeaderViewPushUpDistance);
    } else {
      mHeaderView.setVisibility(INVISIBLE);
    }
  }
Esempio n. 14
0
 protected void onMeasure(int paramInt1, int paramInt2)
 {
   paramInt1 = View.MeasureSpec.getSize(paramInt1);
   paramInt2 = View.MeasureSpec.getSize(paramInt2);
   this.standardLayout.scaleToBounds(paramInt1, paramInt2);
   this.standardLayout.measureView(this.mMiniView);
   this.mListView.measure(this.standardLayout.getWidthMeasureSpec(), View.MeasureSpec.makeMeasureSpec(this.standardLayout.height, 1073741824));
   this.mLoadingView.measure(this.standardLayout.getWidthMeasureSpec(), View.MeasureSpec.makeMeasureSpec(this.standardLayout.height, 1073741824));
   setMeasuredDimension(paramInt1, paramInt2);
 }
 /** Ensure all the dependent widgets are measured. */
 public void measure(int widthMeasureSpec, int heightMeasureSpec) {
   int width = MeasureSpec.getSize(widthMeasureSpec);
   int height = MeasureSpec.getSize(heightMeasureSpec);
   tab.measure(
       View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.UNSPECIFIED));
   text.measure(
       View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.UNSPECIFIED));
 }
Esempio n. 16
0
 /**
  * 从view 得到图片
  *
  * @param view
  * @return
  */
 public static Bitmap getBitmapFromView(View view) {
   view.destroyDrawingCache();
   view.measure(
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
   view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
   view.setDrawingCacheEnabled(true);
   Bitmap bitmap = view.getDrawingCache(true);
   return bitmap;
 }
 public static Bitmap getBitmapFromView(View view, int width, int height) {
   Bitmap returnedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
   Canvas canvas = new Canvas(returnedBitmap);
   view.measure(
       View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
       View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
   view.layout(0, 0, width, height);
   view.draw(canvas);
   return returnedBitmap;
 }
    public static void animateShowing(
        final ViewHolder holder, final ListAdapter adapter, boolean isAnimate) {
      final CheckBox checkBox = holder.checkBox;
      if (checkBox.getVisibility() == View.VISIBLE) {
        return;
      }
      checkBox.setVisibility(View.VISIBLE);
      checkBox.setAlpha(0.0f);
      final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
      final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
      checkBox.measure(widthSpec, heightSpec);
      ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) checkBox.getLayoutParams();
      final long transValue = checkBox.getMeasuredWidth() + lp.leftMargin + lp.rightMargin;

      if (!isAnimate) {
        checkBox.setAlpha(1.0f);
        holder.contentLayout.setTranslationX(transValue);
        return;
      }

      final ObjectAnimator transBodyAnimator = new ObjectAnimator();
      final PropertyValuesHolder trans =
          PropertyValuesHolder.ofFloat("TranslationX", 0.0f, transValue);
      transBodyAnimator.setTarget(holder.contentLayout);
      transBodyAnimator.setValues(trans);
      transBodyAnimator.setDuration(DURATION);

      ObjectAnimator checkBoxAnim = new ObjectAnimator();
      final PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("ScaleX", 0.0f, 1.0f);
      final PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("ScaleY", 0.0f, 1.0f);
      final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("Alpha", 0.0f, 1.0f);
      checkBoxAnim.setValues(scaleX, scaleY, alpha);
      checkBoxAnim.setTarget(holder.checkBox);
      checkBoxAnim.setDuration(DURATION);
      checkBoxAnim.setInterpolator(new DecelerateInterpolator());
      checkBoxAnim.addListener(
          new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
              checkBox.setTag("animating");
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              // adapter.setCheckBoxAnimator(false);
              checkBox.setTag("animated");
            }
          });
      if (!(checkBox.getTag() != null && "animating".equals(checkBox.getTag()))) {
        // 若正在播放动画,则不继续播放动画
        transBodyAnimator.start();
        checkBoxAnim.start();
      }
    }
 protected final void onMeasure(int paramInt1, int paramInt2) {
   int i = 0;
   super.onMeasure(paramInt1, paramInt2);
   SpinnerAdapter localSpinnerAdapter;
   Drawable localDrawable;
   if ((this.x != null) && (View.MeasureSpec.getMode(paramInt1) == Integer.MIN_VALUE)) {
     int m = getMeasuredWidth();
     localSpinnerAdapter = this.a;
     localDrawable = getBackground();
     if (localSpinnerAdapter == null) {
       paramInt2 = i;
       setMeasuredDimension(
           Math.min(Math.max(m, paramInt2), View.MeasureSpec.getSize(paramInt1)),
           getMeasuredHeight());
     }
   } else {
     return;
   }
   int n = View.MeasureSpec.makeMeasureSpec(0, 0);
   int i1 = View.MeasureSpec.makeMeasureSpec(0, 0);
   paramInt2 = Math.max(0, this.n);
   int i2 = Math.min(localSpinnerAdapter.getCount(), paramInt2 + 15);
   int j = Math.max(0, paramInt2 - (15 - (i2 - paramInt2)));
   View localView = null;
   paramInt2 = 0;
   i = 0;
   label135:
   if (j < i2) {
     int k = localSpinnerAdapter.getItemViewType(j);
     if (k == i) {
       break label262;
     }
     localView = null;
     i = k;
   }
   label262:
   for (; ; ) {
     localView = localSpinnerAdapter.getView(j, localView, this);
     if (localView.getLayoutParams() == null) {
       localView.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
     }
     localView.measure(n, i1);
     paramInt2 = Math.max(paramInt2, localView.getMeasuredWidth());
     j++;
     break label135;
     if (localDrawable != null) {
       localDrawable.getPadding(this.B);
       paramInt2 = this.B.left + this.B.right + paramInt2;
       break;
     }
     break;
   }
 }
Esempio n. 20
0
 public static com.amap.api.maps2d.model.BitmapDescriptor getBitmapFromViewGaode(View view) {
   view.destroyDrawingCache();
   view.measure(
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
       View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
   view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
   view.setDrawingCacheEnabled(true);
   Bitmap bitmap = view.getDrawingCache(true);
   com.amap.api.maps2d.model.BitmapDescriptor bd =
       com.amap.api.maps2d.model.BitmapDescriptorFactory.fromBitmap(bitmap);
   return bd;
 }
Esempio n. 21
0
  public static Bitmap getBitmapFromView(View view, int width, int height) {

    view.measure(
        View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
        View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY));
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.translate(-view.getScrollX(), -view.getScrollY());
    view.draw(canvas);
    return bitmap;
  }
 private int b(int paramInt) {
   int i1 = View.MeasureSpec.getMode(paramInt);
   paramInt = View.MeasureSpec.getSize(paramInt);
   if (i1 == 1073741824) {
     return paramInt;
   }
   int i2 = (int) (2.0F * e + getPaddingTop() + getPaddingBottom() + 1.0F);
   if (i1 == Integer.MIN_VALUE) {
     return Math.min(i2, paramInt);
   }
   return i2;
 }
Esempio n. 23
0
  public void expand(View v) {

    // set Visible
    v.setVisibility(View.VISIBLE);

    final int widthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    final int heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    v.measure(widthSpec, heightSpec);

    ValueAnimator mAnimator = slideAnimator(0, v.getMeasuredHeight(), v);
    mAnimator.start();
  }
Esempio n. 24
0
 private int measureSize(int wanting, int mspec) {
   int size = android.view.View.MeasureSpec.getSize(mspec);
   switch (android.view.View.MeasureSpec.getMode(mspec)) {
     case android.view.View.MeasureSpec.AT_MOST:
       return size > wanting ? wanting : size;
     case android.view.View.MeasureSpec.EXACTLY:
       return size;
     case android.view.View.MeasureSpec.UNSPECIFIED:
       return wanting;
   }
   return wanting;
 }
 private int b(int paramInt)
 {
   int i1 = View.MeasureSpec.getMode(paramInt);
   int i2 = View.MeasureSpec.getSize(paramInt);
   if (i1 == 1073741824) {
     return i2;
   }
   int i3 = (int)(1.0F + (2.0F * this.a + getPaddingTop() + getPaddingBottom()));
   if (i1 == -2147483648) {
     return Math.min(i3, i2);
   }
   return i3;
 }
Esempio n. 26
0
 protected void onMeasure(int paramInt1, int paramInt2)
 {
   paramInt1 = View.MeasureSpec.getSize(paramInt1);
   paramInt2 = View.MeasureSpec.getSize(paramInt2);
   this.itemLayout.scaleToBounds(paramInt1, paramInt2);
   this.channelLayout.scaleToBounds(this.itemLayout);
   this.infoLayout.scaleToBounds(this.itemLayout);
   this.lineLayout.scaleToBounds(this.itemLayout);
   this.arrowLayout.scaleToBounds(this.itemLayout);
   this.livingLayout.scaleToBounds(this.itemLayout);
   this.livePaint.setTextSize(this.channelLayout.height * 0.5F);
   generateRect();
   setMeasuredDimension(this.itemLayout.width, this.itemLayout.height);
 }
Esempio n. 27
0
  private void measureCroutonView() {
    View view = getView();
    int widthSpec;
    if (null != viewGroup) {
      widthSpec =
          View.MeasureSpec.makeMeasureSpec(viewGroup.getMeasuredWidth(), View.MeasureSpec.AT_MOST);
    } else {
      widthSpec =
          View.MeasureSpec.makeMeasureSpec(
              activity.getWindow().getDecorView().getMeasuredWidth(), View.MeasureSpec.AT_MOST);
    }

    view.measure(widthSpec, View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
  }
Esempio n. 28
0
  @Override
  public void onCreate() {
    super.onCreate();
    Display display =
        ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    display.getSize(displaySize);
    wakeLock =
        ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");

    specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY);
    specH = View.MeasureSpec.makeMeasureSpec(displaySize.y, View.MeasureSpec.EXACTLY);
    sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPrefs.registerOnSharedPreferenceChangeListener(this);
  }
Esempio n. 29
0
    @Override
    public void onMeasure(
        RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
      int[] mMeasuredDimension = new int[2];
      final int widthMode = View.MeasureSpec.getMode(widthSpec);
      final int heightMode = View.MeasureSpec.getMode(heightSpec);
      final int heightSize = View.MeasureSpec.getSize(heightSpec);
      int width = 0;
      int height = 0;
      LogUtils.d("state:" + state.toString());
      for (int i = 0; i < getItemCount(); i++) {
        try {
          measureScrapChild(
              recycler,
              i,
              widthSpec,
              View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
              mMeasuredDimension);
        } catch (IndexOutOfBoundsException e) {
          e.printStackTrace();
        }
        if (getOrientation() == HORIZONTAL) {
          width = width + mMeasuredDimension[0];
          if (i == 0) {
            height = mMeasuredDimension[1];
          }
        } else {
          height = height + mMeasuredDimension[1];
          if (i == 0) {
            width = mMeasuredDimension[0];
          }
        }
      }

      switch (widthMode) {
        case View.MeasureSpec.EXACTLY:
        case View.MeasureSpec.AT_MOST:
        case View.MeasureSpec.UNSPECIFIED:
      }

      switch (heightMode) {
        case View.MeasureSpec.EXACTLY:
          height = heightSize;
        case View.MeasureSpec.AT_MOST:
        case View.MeasureSpec.UNSPECIFIED:
      }
      setMeasuredDimension(widthSpec, height);
    }
  public static void setListViewHeightBasedOnChildren(ListView listView) {

    ListAdapter listAdapter = listView.getAdapter();

    if (listAdapter == null) return;

    int desiredWidth =
        View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);

    int totalHeight = 0;

    View view = null;

    for (int i = 0; i < listAdapter.getCount(); i++) {

      view = listAdapter.getView(i, view, listView);

      if (i == 0)
        view.setLayoutParams(
            new ViewGroup.LayoutParams(desiredWidth, AbsListView.LayoutParams.MATCH_PARENT));

      view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);

      totalHeight += view.getMeasuredHeight() + 20;
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();

    params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));

    listView.setLayoutParams(params);
  }