Ejemplo 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();
 }
Ejemplo 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();
 }
Ejemplo n.º 3
0
  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;
      }
  }
  @Override
  public void onMeasure(
      RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {

    final int widthMode = View.MeasureSpec.getMode(widthSpec);
    final int heightMode = View.MeasureSpec.getMode(heightSpec);
    final int widthSize = View.MeasureSpec.getSize(widthSpec);
    final int heightSize = View.MeasureSpec.getSize(heightSpec);

    Log.i(
        TAG,
        "onMeasure called. \nwidthMode "
            + widthMode
            + " \nheightMode "
            + heightSpec
            + " \nwidthSize "
            + widthSize
            + " \nheightSize "
            + heightSize
            + " \ngetItemCount() "
            + getItemCount());

    int width = 0;
    int height = 0;
    for (int i = 0; i < getItemCount(); i++) {
      measureScrapChild(
          recycler,
          i,
          View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
          View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
          mMeasuredDimension);

      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:
        width = widthSize;
      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(width, height);
  }
Ejemplo 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);
         }
       });
 }
 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));
 }
  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());
    }
  }
  @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;
  }
Ejemplo n.º 9
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);
    }
  }
 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;
 }
Ejemplo n.º 13
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;
 }
 /** 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));
 }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
    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();
      }
    }
Ejemplo n.º 17
0
  @Override
  public void onMeasure(
      RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) {
    final int widthMode = View.MeasureSpec.getMode(widthSpec);
    final int heightMode = View.MeasureSpec.getMode(heightSpec);
    final int widthSize = View.MeasureSpec.getSize(widthSpec);
    final int heightSize = View.MeasureSpec.getSize(heightSpec);

    int width = 0;
    int height = 0;
    int count = getItemCount();
    int span = getSpanCount();
    for (int i = 0; i < count; i++) {
      measureScrapChild(
          recycler,
          i,
          View.MeasureSpec.makeMeasureSpec(widthSize, widthMode),
          View.MeasureSpec.makeMeasureSpec(heightSize, heightMode),
          mMeasuredDimension);

      if (getOrientation() == HORIZONTAL) {
        if (i % span == 0) {
          width = width + mMeasuredDimension[0];
        }
        if (i == 0) {
          height = mMeasuredDimension[1];
        }
      } else {
        if (i % span == 0) {
          height = height + mMeasuredDimension[1];
        }
        if (i == 0) {
          width = mMeasuredDimension[0];
        }
      }
    }

    switch (widthMode) {
      case View.MeasureSpec.EXACTLY:
        width = widthSize;
      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(width, height);
  }
Ejemplo n.º 18
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();
  }
Ejemplo n.º 19
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;
  }
 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;
   }
 }
Ejemplo n.º 21
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;
 }
Ejemplo n.º 22
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));
  }
Ejemplo n.º 23
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);
  }
Ejemplo n.º 24
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 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);
  }
  private static int measureViewHeight(View view2Expand, View view2Measure) {
    try {
      Method m = view2Measure.getClass().getDeclaredMethod("onMeasure", int.class, int.class);
      m.setAccessible(true);

      m.invoke(
          view2Measure,
          View.MeasureSpec.makeMeasureSpec(view2Expand.getWidth(), View.MeasureSpec.AT_MOST),
          View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    } catch (Exception e) {
      return -1;
    }

    int measuredHeight = view2Measure.getMeasuredHeight();
    return measuredHeight;
  }
  private void setListViewHeight(ExpandableListView listView, int group) {
    ExpandableListAdapter listAdapter = (ExpandableListAdapter) listView.getExpandableListAdapter();
    int totalHeight = 0;
    int desiredWidth =
        View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.EXACTLY);
    for (int i = 0; i < listAdapter.getGroupCount(); i++) {
      View groupItem = listAdapter.getGroupView(i, false, null, listView);
      groupItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);

      totalHeight += groupItem.getMeasuredHeight();

      if (((listView.isGroupExpanded(i)) && (i != group))
          || ((!listView.isGroupExpanded(i)) && (i == group))) {
        for (int j = 0; j < listAdapter.getChildrenCount(i); j++) {
          View listItem = listAdapter.getChildView(i, j, false, null, listView);
          listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);

          totalHeight += listItem.getMeasuredHeight();
        }
      }
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    int height = totalHeight + (listView.getDividerHeight() * (listAdapter.getGroupCount() - 1));
    if (height < 10) height = 200;
    params.height = height;
    listView.setLayoutParams(params);
    listView.requestLayout();
  }
Ejemplo n.º 28
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(
       View.MeasureSpec.makeMeasureSpec(
           measureWidth() + getPaddingLeft() + getPaddingRight(), View.MeasureSpec.EXACTLY),
       heightMeasureSpec);
 }
  private void dismissAbove(List<DeleteItemWrapper> position) {
    View view =
        AdapterViewUtil.getViewForPosition(
            getListViewWrapper(), getListViewWrapper().getFirstVisiblePosition());

    if (view != null) {
      view.measure(
          View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
          View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
      int scrollDistance = view.getMeasuredHeight() * position.size();

      getListViewWrapper().smoothScrollBy(scrollDistance, (int) mDismissAnimationTime);
      mHandler.postDelayed(
          new RestoreScrollRunnable(scrollDistance, position), mDismissAnimationTime);
    }
  }
Ejemplo n.º 30
0
  public static void setListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null) {
      ViewGroup.LayoutParams params = listView.getLayoutParams();
      params.height = 0;
      listView.setLayoutParams(params);
      listView.requestLayout();
      return;
    }

    int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom();
    int desiredWidth =
        View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST);
    for (int i = 0; i < listAdapter.getCount(); i++) {
      View listItem = listAdapter.getView(i, null, listView);

      if (listItem != null) {
        listItem.setLayoutParams(
            new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT));
        listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
        totalHeight += listItem.getMeasuredHeight();
      }
    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
    listView.setLayoutParams(params);
    listView.requestLayout();
  }