private void initDeleteIcons() {
   int deleteIconViews[] = {
     R.id.deleteIcon1,
     R.id.deleteIcon2,
     R.id.deleteIcon3,
     R.id.deleteIcon4,
     R.id.deleteIcon5,
     R.id.deleteIcon6,
     R.id.deleteIcon7,
     R.id.deleteIcon8,
     R.id.deleteIcon9,
     R.id.deleteIcon10
   };
   RelativeLayout.LayoutParams deleteIconParams =
       new RelativeLayout.LayoutParams(screenHeight / 20, screenHeight / 20);
   deleteIconParams.alignWithParent = true;
   deleteIconParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
   deleteIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
   deleteIconParams.bottomMargin = 3;
   deleteIconParams.rightMargin = 3;
   for (int i = 0; i < deleteIconViews.length; i++) {
     ImageView deleteIcon = (ImageView) findViewById(deleteIconViews[i]);
     deleteIcon.setLayoutParams(deleteIconParams);
     deleteIcon.setOnClickListener(deleteIconClickListener);
     deleteIcon.setVisibility(View.GONE);
     deleteIcons.add(deleteIcon);
   }
 }
 private void a(int paramInt1, int paramInt2, int paramInt3)
 {
   float f1 = q().getDisplayMetrics().density;
   RelativeLayout.LayoutParams localLayoutParams = (RelativeLayout.LayoutParams)this.as.getLayoutParams();
   localLayoutParams.topMargin = (int)(0.5F + f1 * paramInt1);
   localLayoutParams.bottomMargin = (int)(0.5F + f1 * paramInt2);
   localLayoutParams.leftMargin = (int)(0.5F + f1 * paramInt3);
   localLayoutParams.rightMargin = localLayoutParams.leftMargin;
   this.as.setLayoutParams(localLayoutParams);
   this.as.requestLayout();
 }
Example #3
0
  /**
   * Moves a view to a screen position. Position is from 0 to 1 and converted to screen pixel.
   * Alignment is top right.
   *
   * @param view View to move
   * @param x X position from 0 to 1
   * @param y Y position from 0 to 1
   */
  public static void setLayoutPositionRight(Activity a, View view, double x, double y) {
    DisplayMetrics displayMetrics = a.getResources().getDisplayMetrics();
    float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density;
    float screenHeightDp = displayMetrics.heightPixels / displayMetrics.density;

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
    params.rightMargin = Helper.getPixels(a, screenWidthDp * x);
    params.topMargin = Helper.getPixels(a, screenHeightDp * y);
    view.setLayoutParams(params);
  }
  /**
   * Show this SnackBar. Make sure it already attached to a parent view or this method will do
   * nothing.
   */
  public void show() {
    ViewGroup parent = (ViewGroup) getParent();
    if (parent == null || mState == STATE_SHOWING || mState == STATE_DISMISSING) return;

    if (parent instanceof FrameLayout) {
      LayoutParams params = (LayoutParams) getLayoutParams();

      params.width = mWidth;
      params.height = mHeight;
      params.gravity = Gravity.START | Gravity.BOTTOM;
      if (mIsRtl) params.rightMargin = mMarginStart;
      else params.leftMargin = mMarginStart;
      params.bottomMargin = mMarginBottom;
    } else if (parent instanceof RelativeLayout) {
      RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();

      params.width = mWidth;
      params.height = mHeight;
      params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      params.addRule(RelativeLayout.ALIGN_PARENT_START);
      if (mIsRtl) params.rightMargin = mMarginStart;
      else params.leftMargin = mMarginStart;
      params.bottomMargin = mMarginBottom;
    }

    if (mInAnimationId != 0 && mState != STATE_SHOWN) {
      Animation anim = AnimationUtils.loadAnimation(getContext(), mInAnimationId);
      anim.setAnimationListener(
          new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
              setState(STATE_SHOWING);
              setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              setState(STATE_SHOWN);
              startTimer();
            }
          });
      startAnimation(anim);
    } else {
      setVisibility(View.VISIBLE);
      setState(STATE_SHOWN);
      startTimer();
    }
  }
Example #5
0
 public static void resetRL(View... view) {
   float rote = Handler_System.getWidthRoate(ApplicationBean.getApplication().getMode_w());
   if (view == null || rote == 1) {
     return;
   }
   for (View view2 : view) {
     RelativeLayout.LayoutParams layoutParams =
         (RelativeLayout.LayoutParams) view2.getLayoutParams();
     layoutParams.leftMargin = (int) (layoutParams.leftMargin * rote);
     layoutParams.rightMargin = (int) (layoutParams.rightMargin * rote);
     layoutParams.topMargin = (int) (layoutParams.topMargin * rote);
     layoutParams.bottomMargin = (int) (layoutParams.bottomMargin * rote);
     view2.setLayoutParams(layoutParams);
   }
 }
  public void setProgressViewHidden(boolean hidden) {
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(mTextView.getLayoutParams());
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(
        RelativeLayout.LEFT_OF, hidden ? mLearningStatisticImageView.getId() : mImageView.getId());
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.leftMargin = (int) (10 * mScale);
    layoutParams.rightMargin = (int) (20 * mScale);
    layoutParams.bottomMargin = (int) (20 * mScale);
    layoutParams.topMargin = (int) (20 * mScale);
    mWrapper.setLayoutParams(layoutParams);

    mProgressBar.setVisibility(hidden ? View.GONE : View.VISIBLE);
  }
Example #7
0
  /** 测量Layout的宽和高,以及设置Item的宽和高,这里忽略wrap_content 以宽、高之中的最小值绘制正方形 */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    // 获得正方形的边长
    int length = Math.min(getMeasuredHeight(), getMeasuredWidth());
    // 获得Item的宽度
    int childWidth = (length - mPadding * 2 - mMargin * (mColumn - 1)) / mColumn;

    if (!once) {
      if (mGame2048Items == null) {
        mGame2048Items = new Game2048Item[mColumn * mColumn];
      }
      // 放置Item
      for (int i = 0; i < mGame2048Items.length; i++) {
        Game2048Item item = new Game2048Item(getContext());

        mGame2048Items[i] = item;
        item.setId(i + 1);
        RelativeLayout.LayoutParams lp = new LayoutParams(childWidth, childWidth);
        // 设置横向边距,不是最后一列
        if ((i + 1) % mColumn != 0) {
          lp.rightMargin = mMargin;
        }
        // 如果不是第一列
        if (i % mColumn != 0) {
          lp.addRule(
              RelativeLayout.RIGHT_OF, //
              mGame2048Items[i - 1].getId());
        }
        // 如果不是第一行,//设置纵向边距,非最后一行
        if ((i + 1) > mColumn) {
          lp.topMargin = mMargin;
          lp.addRule(
              RelativeLayout.BELOW, //
              mGame2048Items[i - mColumn].getId());
        }
        addView(item, lp);
      }
      generateNum();
    }
    once = true;

    setMeasuredDimension(length, length);
  }
Example #8
0
  @Override
  public boolean onTouch(View view, MotionEvent event) {
    if (detectors != null) detectors.onTouchEvent(event);

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        mSurfaceSizes.dx = event.getX();
        mSurfaceSizes.dy = event.getY();
        break;

      case MotionEvent.ACTION_MOVE:
        float x = event.getX();
        float y = event.getY();
        RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
        float left = lp.leftMargin + (x - mSurfaceSizes.dx);
        float top = lp.topMargin + (y - mSurfaceSizes.dy);
        if (mSurfaceSizes.listnrr != null && mSurfaceSizes.listnrr.zoom) {
          int srcw = lp.width;
          int srch = lp.height;

          int left_offset =
              (int)
                  (mSurfaceSizes.orig_width
                      - (mSurfaceSizes.orig_width * mSurfaceSizes.listnrr.scaleFactor));
          int top_offset =
              (int)
                  (mSurfaceSizes.orig_height
                      - (mSurfaceSizes.orig_height * mSurfaceSizes.listnrr.scaleFactor));
          Log.e("Player", "ACTION_MOVE2 " + left_offset + "," + top_offset);

          lp.leftMargin = left_offset;
          lp.topMargin = top_offset;
          lp.rightMargin = left_offset;
          lp.bottomMargin = top_offset;
        }
        view.setLayoutParams(lp);
        break;
    }
    return true;
  }
Example #9
0
  public boolean onTouch(View view, MotionEvent event) {
    float scale;
    final int X = (int) event.getRawX();
    final int Y = (int) event.getRawY();
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        view.setBackgroundResource(R.drawable.border);
        garbage.setVisibility(View.VISIBLE);
        RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
        _xDelta = X - lParams.leftMargin;
        _yDelta = Y - lParams.topMargin;

        start.set(event.getX(), event.getY());
        mode = DRAG;
        break;
      case MotionEvent.ACTION_UP:
        Iterator<View> iterator;
        mode = NONE;
        garbage.setVisibility(View.INVISIBLE);
        view.setBackgroundResource(R.color.none);
        if (event.getRawY() > 1530) {
          if (position_status == FRONT) {
            iterator = ViewList.iterator();
          } else {
            iterator = ViewListBack.iterator();
          }
          view.setVisibility(View.GONE);

          while (iterator.hasNext()) {
            View i = iterator.next();
            if (i == view) {
              iterator.remove();
            }
          }
        }
        break;
      case MotionEvent.ACTION_POINTER_DOWN:
        oldDist = spacing(event);
        if (oldDist > 8f) {
          RelativeLayout.LayoutParams zParams =
              (RelativeLayout.LayoutParams) view.getLayoutParams();
          midPoint(mid, event);
          _xDelta = (int) mid.x - zParams.leftMargin;
          _yDelta = (int) mid.y - zParams.topMargin;
          mode = ZOOM;
        }
        break;
      case MotionEvent.ACTION_POINTER_UP:
        mode = NONE;
        break;
      case MotionEvent.ACTION_MOVE:
        RelativeLayout.LayoutParams layoutParams =
            (RelativeLayout.LayoutParams) view.getLayoutParams();
        if (mode == DRAG) {
          layoutParams.leftMargin = X - _xDelta;
          layoutParams.topMargin = Y - _yDelta;
          layoutParams.rightMargin = -250;
          layoutParams.bottomMargin = -250;
          view.setLayoutParams(layoutParams);
          rectView = new Rect();
          view.getDrawingRect(rectView);
          if (event.getRawY() > 1530) {
            view.setBackgroundResource(R.color.deletecolor);
          } else view.setBackgroundResource(R.drawable.border);

        } else if (mode == ZOOM) {
          // pinch zooming
          float newDist = spacing(event);
          if (newDist > 8f) {
            // setting the scaling of the
            scale = newDist / oldDist;

            if (view instanceof ImageView) {
              int imgSizeH = view.getHeight();
              int imgSizeW = view.getWidth();
              imgSizeH = (int) (imgSizeH * scale);
              imgSizeW = (int) (imgSizeW * scale);
              layoutParams.width = imgSizeW;
              layoutParams.height = imgSizeH;
              layoutParams.leftMargin = (int) mid.x - _xDelta;
              layoutParams.topMargin = (int) mid.y - _yDelta;
              layoutParams.rightMargin = -250;
              layoutParams.bottomMargin = -250;
              view.setLayoutParams(layoutParams);

            } else if (view instanceof TextView) {
              // textSize = ((TextView) view).getTextSize();
              textSize = textSize * scale;
              ((TextView) view).setTextSize(textSize);
            }
            oldDist = newDist;
          }
        }
        break;
    }
    mRrootLayout.invalidate();
    return true;
  }
Example #10
0
  private void createTopBanner(Context context) {
    int smallMargin = LayoutUtil.getSmallMargin();
    int midMargin = LayoutUtil.getMediumMargin();

    mTopBanner = new RelativeLayout(context);
    mTopBanner.setBackgroundResource(R.drawable.stone_bg);
    RelativeLayout.LayoutParams topViewLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    topViewLP.width = LayoutUtil.getNavigationPanelWidth();
    topViewLP.height = LayoutUtil.getGalleryTopPanelHeight();
    mTopBanner.setLayoutParams(topViewLP);
    this.addView(mTopBanner, topViewLP);

    mAvatarBtn = new HaloButton(context, R.drawable.avatar_2);
    RelativeLayout.LayoutParams avatarLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    avatarLP.leftMargin = smallMargin;
    avatarLP.width = DensityAdaptor.getDensityIndependentValue(32);
    avatarLP.height = DensityAdaptor.getDensityIndependentValue(32);
    avatarLP.addRule(RelativeLayout.CENTER_VERTICAL);
    mAvatarBtn.setLayoutParams(avatarLP);
    mTopBanner.addView(mAvatarBtn);

    mNameTextView = new TextView(context);
    mNameTextView.setText("Tom");
    mNameTextView.setTextSize(UIConfig.getUserLabelTextSize());
    mNameTextView.setTextColor(UIConfig.getLightTextColor());
    RelativeLayout.LayoutParams nameTextLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    nameTextLP.leftMargin = DensityAdaptor.getDensityIndependentValue(36);
    nameTextLP.addRule(RelativeLayout.CENTER_VERTICAL);
    mNameTextView.setLayoutParams(nameTextLP);
    mTopBanner.addView(mNameTextView);

    View separator = ControlFactory.createVertSeparatorForRelativeLayout(context);
    RelativeLayout.LayoutParams separatorLP = (LayoutParams) separator.getLayoutParams();
    separatorLP.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    separatorLP.rightMargin = DensityAdaptor.getDensityIndependentValue(48);
    separator.setLayoutParams(separatorLP);
    mTopBanner.addView(separator);

    mLogoutBtn = new HaloButton(context, R.drawable.logout);
    RelativeLayout.LayoutParams logoutLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    logoutLP.rightMargin = midMargin;
    logoutLP.width = DensityAdaptor.getDensityIndependentValue(32);
    logoutLP.height = DensityAdaptor.getDensityIndependentValue(32);
    logoutLP.addRule(RelativeLayout.CENTER_VERTICAL);
    logoutLP.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mLogoutBtn.setLayoutParams(logoutLP);
    mTopBanner.addView(mLogoutBtn);

    mLoginBtn = new HaloButton(context, R.drawable.login);
    RelativeLayout.LayoutParams loginLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    loginLP.rightMargin = midMargin;
    loginLP.width = DensityAdaptor.getDensityIndependentValue(32);
    loginLP.height = DensityAdaptor.getDensityIndependentValue(32);
    loginLP.addRule(RelativeLayout.CENTER_VERTICAL);
    loginLP.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mLoginBtn.setLayoutParams(loginLP);
    mTopBanner.addView(mLoginBtn);
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ChildHolder childHolder = null;
      if (convertView == null) {
        childHolder = new ChildHolder();
        convertView = mInflater.inflate(R.layout.mianlist_item_layout, null);

        childHolder.time = (TextView) convertView.findViewById(R.id.time);
        childHolder.content = (TextView) convertView.findViewById(R.id.content);
        childHolder.img = (ImageView) convertView.findViewById(R.id.imageView1);
        childHolder.img_juan = (ImageView) convertView.findViewById(R.id.imageView2);
        childHolder.contentView = (RelativeLayout) convertView.findViewById(R.id.main_itemview1212);
        childHolder.fontView = (RelativeLayout) convertView.findViewById(R.id.main_itemview);
        convertView.setTag(childHolder);
      } else {
        childHolder = (ChildHolder) convertView.getTag();
      }
      RelativeLayout.LayoutParams rl;
      if (APPConfigure.Screen_Width > 720) {
        rl = new RelativeLayout.LayoutParams(80, 80);
      } else {
        rl = new RelativeLayout.LayoutParams(50, 50);
      }
      RelativeLayout.LayoutParams rlweek =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      RelativeLayout.LayoutParams rlcontentView =
          new RelativeLayout.LayoutParams(
              APPConfigure.Screen_Width * 3 / 4, LayoutParams.WRAP_CONTENT);

      rl.addRule(RelativeLayout.ALIGN_PARENT_TOP);

      childHolder.content.setText(list.get(position).content.trim());
      if (!list.get(position).isLocal) {
        String phone = "        发给:" + list.get(position).FormPhone;

        childHolder.time.setText(list.get(position).date + phone);

        if (position % 2 == 0) {
          rl.leftMargin = 10;
          rl.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
          rlcontentView.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
          rlweek.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
          rlweek.leftMargin = 10;
          childHolder.content.setGravity(Gravity.LEFT);
          rlweek.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
          MemoBgset.setBg(
              childHolder.fontView, list.get(position).bgcolor, childHolder.img_juan, true);
        } else {
          rl.rightMargin = 0;
          rl.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
          rlcontentView.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
          rlweek.rightMargin = 10;
          rlweek.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
          rlweek.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
          childHolder.content.setGravity(Gravity.RIGHT);
          MemoBgset.setBg(
              childHolder.fontView, list.get(position).bgcolor, childHolder.img_juan, false);
        }
      }
      childHolder.img.setLayoutParams(rl);
      childHolder.time.setLayoutParams(rlweek);
      // childHolder.contentView.setLayoutParams(rlcontentView);
      childHolder.content.setTextSize(APPConfigure.APP_Memo_FontSize);
      return convertView;
    }
  private void initRight(Context context) {
    RelativeLayout layout_right = new RelativeLayout(context);
    LinearLayout.LayoutParams param_layout_right =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    int margin = 35;
    param_layout_right.setMargins(margin, margin, margin, margin);
    layout_right.setLayoutParams(param_layout_right);

    text_filmName = new AlwaysMarqueeTextView(context);
    text_filmName.setId(text_filmName_id);
    text_filmName.setMarquee(true);
    text_filmName.setTextColor(Color.WHITE);
    text_filmName.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 8);
    RelativeLayout.LayoutParams param_text_filmName =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_text_filmName.addRule(RelativeLayout.CENTER_HORIZONTAL);
    param_text_filmName.bottomMargin = 5;
    text_filmName.setLayoutParams(param_text_filmName);
    layout_right.addView(text_filmName);

    text_year_mins_area_type = new TextView(context);
    text_year_mins_area_type.setId(text_year_mins_area_type_id);
    text_year_mins_area_type.setTextColor(Color.WHITE);
    text_year_mins_area_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_text_year_mins_area_type =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_year_mins_area_type.addRule(RelativeLayout.BELOW, text_filmName_id);
    param_text_year_mins_area_type.bottomMargin = 5;
    text_year_mins_area_type.setLayoutParams(param_text_year_mins_area_type);
    layout_right.addView(text_year_mins_area_type);

    TextView text_movie_class = new TextView(context); // 电影分类
    text_movie_class.setId(text_movie_class_id);

    barginPrice = new TextView(context);
    barginPrice.append("¥0");
    barginPrice.setTextColor(Color.parseColor("#00c1ea"));
    barginPrice.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 5);
    RelativeLayout.LayoutParams barginPriceParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    barginPriceParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    barginPriceParams.addRule(RelativeLayout.ALIGN_BOTTOM, text_year_mins_area_type_id);
    barginPrice.setLayoutParams(barginPriceParams);
    barginPrice.setId(price_id);
    layout_right.addView(barginPrice);

    TextView barginPriceTextView = new TextView(context);
    barginPriceTextView.setText(" 促销价: ");
    barginPriceTextView.setTextColor(Color.GRAY);
    barginPriceTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_price =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_price.addRule(RelativeLayout.LEFT_OF, price_id);
    param_price.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    barginPriceTextView.setLayoutParams(param_price);
    barginPriceTextView.setId(price_tv_id);
    layout_right.addView(barginPriceTextView);

    price = new TextView(context);
    price.setText("¥0 ");
    price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    price.setId(10012);
    price.setTextColor(Color.GRAY);
    price.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    price.setId(bargin_id);
    RelativeLayout.LayoutParams priceParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    priceParams.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    priceParams.addRule(RelativeLayout.LEFT_OF, price_tv_id);
    price.setLayoutParams(priceParams);
    layout_right.addView(price);

    TextView priceTextView = new TextView(context);
    priceTextView.setText("原价:");
    priceTextView.setId(10012);
    priceTextView.setTextColor(Color.GRAY);
    priceTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_barginPrice =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    //		param_barginPrice.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    param_barginPrice.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    param_barginPrice.addRule(RelativeLayout.LEFT_OF, bargin_id);
    priceTextView.setLayoutParams(param_barginPrice);
    layout_right.addView(priceTextView);

    text_introduce = new TextView(context);
    text_introduce.setTextColor(Color.WHITE);
    text_introduce.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_introduce.setEllipsize(TruncateAt.END);
    text_introduce.setId(text_introduce_id);
    text_introduce.setMaxLines(3);
    text_introduce.setLineSpacing(3f, 1f);
    RelativeLayout.LayoutParams param_text_introduce =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_introduce.addRule(RelativeLayout.BELOW, text_year_mins_area_type_id);
    text_introduce.setLayoutParams(param_text_introduce);
    layout_right.addView(text_introduce);

    text_director = new AlwaysMarqueeTextView(context);
    text_director.setId(text_director_id);
    text_director.setTextColor(Color.WHITE);
    text_director.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_director.setMarquee(false);
    RelativeLayout.LayoutParams param_text_director =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_director.addRule(RelativeLayout.BELOW, text_introduce_id);
    param_text_director.topMargin = 4;
    text_director.setLayoutParams(param_text_director);
    layout_right.addView(text_director);

    text_actor = new AlwaysMarqueeTextView(context);
    text_actor.setId(text_actor_id);
    text_actor.setTextColor(Color.WHITE);
    text_actor.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_director.setMarquee(false);
    RelativeLayout.LayoutParams param_text_actor =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_actor.addRule(RelativeLayout.BELOW, text_director_id);
    param_text_actor.topMargin = 4;
    text_actor.setLayoutParams(param_text_actor);
    layout_right.addView(text_actor);

    text_dl_info = new TextView(context);
    text_dl_info.setText(R.string.watch_worning_for4k);
    text_dl_info.setTextColor(Color.parseColor("#FFC125"));
    text_dl_info.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 2);
    RelativeLayout.LayoutParams param_text_dl_info =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_dl_info.addRule(RelativeLayout.BELOW, text_actor_id);
    param_text_dl_info.topMargin = textSize - 10;
    text_dl_info.setLayoutParams(param_text_dl_info);
    layout_right.addView(text_dl_info);
    if (F4kDownResourceUtils.getDownLoadFlag() == null
        || !F4kDownResourceUtils.getDownLoadFlag().equals("1")) {
      text_dl_info.setVisibility(View.INVISIBLE);
    }

    layout_btn = new RelativeLayout(context);
    layout_btn.setId(layout_btn_id);
    RelativeLayout.LayoutParams param_layout_btn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_layout_btn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    //		param_layout_btn.addRule(RelativeLayout.CENTER_HORIZONTAL);
    param_layout_btn.bottomMargin = 10;
    layout_btn.setLayoutParams(param_layout_btn);

    leftBtn = new FocusAbleButton(context);
    leftBtn.setTextSize(textSize);
    leftBtn.setTextColor(Color.WHITE);
    leftBtn.setGravity(Gravity.CENTER);
    leftBtn.setTextSize(textSize);
    leftBtn.setId(detail_left_btn_id);

    leftBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null) {
              listener.onPlay(film);
            }
          }
        });
    RelativeLayout.LayoutParams param_leftBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_leftBtn.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    param_leftBtn.rightMargin = 45;
    leftBtn.setLayoutParams(param_leftBtn);
    layout_btn.addView(leftBtn);

    leftBtn_playlow = new FocusAbleButton(context);
    leftBtn_playlow.setTextSize(textSize);
    leftBtn_playlow.setTextColor(Color.WHITE);
    leftBtn_playlow.setGravity(Gravity.CENTER);
    leftBtn_playlow.setTextSize(textSize);
    leftBtn_playlow.setId(ID.MovieDetaiView.DETAIL_LEFT_BTN_ID);

    leftBtn_playlow.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null) {
              if (info instanceof F4kFilmAndPageInfo) {
                F4kFilmAndPageInfo info4k = (F4kFilmAndPageInfo) info;
                if (info4k.getFilmListLowRate().size() > index) {
                  listener.onPlay(((F4kFilmAndPageInfo) info).getFilmListLowRate().get(index));
                } else {
                  Log.d("can not play l080p case no fid for it");
                }
              }
            }
          }
        });
    RelativeLayout.LayoutParams leftBtn_playlowBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    leftBtn_playlowBtn.addRule(RelativeLayout.RIGHT_OF, detail_left_btn_id);
    leftBtn_playlowBtn.rightMargin = 45;
    leftBtn_playlow.setLayoutParams(leftBtn_playlowBtn);
    layout_btn.addView(leftBtn_playlow);

    middleBtn = new FocusAbleButton(context);
    middleBtn.setTextColor(Color.WHITE);
    middleBtn.setGravity(Gravity.CENTER);
    middleBtn.setTextSize(textSize);
    middleBtn.setId(middleBtn_id);
    middleBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null && film != null) {
              listener.onDwonload(film);
            }
          }
        });
    RelativeLayout.LayoutParams param_middleBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_middleBtn.addRule(RelativeLayout.RIGHT_OF, ID.MovieDetaiView.DETAIL_LEFT_BTN_ID);
    middleBtn.setLayoutParams(param_middleBtn);
    layout_btn.addView(middleBtn);

    rightBtn = new FocusAbleButton(context);
    rightBtn.setTextColor(Color.WHITE);
    rightBtn.setGravity(Gravity.CENTER);
    rightBtn.setTextSize(textSize);
    rightBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (listener != null && film != null) {
              listener.onCancel(film);
            }
          }
        });
    rightBtn.setId(rightBtn_id);
    RelativeLayout.LayoutParams param_rightBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_rightBtn.leftMargin = 45;
    param_rightBtn.addRule(RelativeLayout.RIGHT_OF, middleBtn_id);
    rightBtn.setLayoutParams(param_rightBtn);
    layout_btn.addView(rightBtn);
    layout_right.addView(layout_btn);

    RelativeLayout layout_love = new RelativeLayout(context);
    layout_love.setId(layout_love_id);
    RelativeLayout.LayoutParams param_layout_lov =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_layout_lov.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    layout_love.setLayoutParams(param_layout_lov);
    layout_right.addView(layout_love);

    addView(layout_right);
    leftBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    leftBtn_playlow.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    middleBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    rightBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
  }
  private void initMainGroupCellView(Context context) {
    setOrientation(LinearLayout.VERTICAL);

    mCell = new RelativeLayout(context);
    mCell.setBackgroundResource(R.drawable.list_selector);

    mWrapper = new LinearLayout(context);
    mWrapper.setOrientation(LinearLayout.HORIZONTAL);
    mWrapper.setGravity(Gravity.CENTER_VERTICAL);

    mSectionTextView = new TextView(context);
    mSectionTextView.setTextColor(context.getResources().getColor(R.color.header_section));
    mSectionTextView.setGravity(Gravity.CENTER);
    mSectionTextView.setTypeface(null, Typeface.BOLD);
    mSectionTextView.setBackgroundColor(
        Color.WHITE); // setBackgroundResource(R.drawable.bg_section_header);
    addView(mSectionTextView);
    mSectionTextView.getLayoutParams().width = LinearLayout.LayoutParams.MATCH_PARENT;

    mImageView = new ImageView(context);
    mImageView.setId(R.id.imageView1);
    mLearningStatisticImageView = new ImageView(context);
    mLearningStatisticImageView.setId(R.id.imageView4);
    mLearningStatisticImageView.setVisibility(View.GONE);

    mTextView = new TextView(context);
    try {
      mTextView.setTextColor(
          ColorStateList.createFromXml(
              getResources(), getResources().getXml(R.color.textcolor_black_white)));
    } catch (NotFoundException e) {
    } catch (XmlPullParserException e) {
    } catch (IOException e) {
    }
    mTextView.setTextSize(14.0f);
    mTextView.setTypeface(null, Typeface.BOLD);
    mTextView.setGravity(Gravity.CENTER_VERTICAL);

    mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    try {
      mProgressBar.setProgressDrawable(
          Drawable.createFromXml(
              getResources(), getResources().getXml(R.drawable.learning_progress_bar)));
    } catch (NotFoundException e) {
    } catch (XmlPullParserException e) {
    } catch (IOException e) {
    }
    mProgressBar.setId(android.R.id.progress);
    mProgressBar.setMax(100);

    mScale = context.getResources().getDisplayMetrics().density;

    LinearLayout.LayoutParams linearParams =
        new LinearLayout.LayoutParams((int) (30 * mScale), (int) (30 * mScale));
    linearParams.rightMargin = (int) (20 * mScale);
    mWrapper.addView(mImageView, linearParams);

    linearParams =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    mWrapper.addView(mTextView, linearParams);

    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams((int) (70 * mScale), (int) (20 * mScale));
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    layoutParams.rightMargin = (int) (10 * mScale);
    mCell.addView(mProgressBar, layoutParams);

    layoutParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    layoutParams.rightMargin = (int) (10 * mScale);
    mCell.addView(mLearningStatisticImageView, layoutParams);

    layoutParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    layoutParams.addRule(RelativeLayout.LEFT_OF, mProgressBar.getId());
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    layoutParams.leftMargin = (int) (6 * mScale);
    layoutParams.rightMargin = (int) (10 * mScale);
    mCell.addView(mWrapper, layoutParams);

    addView(
        mCell,
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    classGuid = ConnectionsManager.getInstance().generateClassGuid();
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
    NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);

    typingDotsDrawable = new TypingDotsDrawable();
    recordStatusDrawable = new RecordStatusDrawable();

    SizeNotifierRelativeLayout contentView = new SizeNotifierRelativeLayout(this);
    setContentView(contentView);
    contentView.setBackgroundColor(0x99000000);

    RelativeLayout relativeLayout = new RelativeLayout(this);
    contentView.addView(relativeLayout);
    RelativeLayout.LayoutParams layoutParams3 =
        (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.MATCH_PARENT;
    relativeLayout.setLayoutParams(layoutParams3);

    RelativeLayout popupContainer = new RelativeLayout(this);
    popupContainer.setBackgroundColor(0xffffffff);
    relativeLayout.addView(popupContainer);
    layoutParams3 = (RelativeLayout.LayoutParams) popupContainer.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = AndroidUtilities.dp(240);
    layoutParams3.leftMargin = AndroidUtilities.dp(12);
    layoutParams3.rightMargin = AndroidUtilities.dp(12);
    layoutParams3.addRule(RelativeLayout.CENTER_IN_PARENT);
    popupContainer.setLayoutParams(layoutParams3);

    if (chatActivityEnterView != null) {
      chatActivityEnterView.onDestroy();
    }
    chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
    popupContainer.addView(chatActivityEnterView);
    layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    chatActivityEnterView.setLayoutParams(layoutParams3);
    chatActivityEnterView.setDelegate(
        new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
          @Override
          public void onMessageSend(String message) {
            if (currentMessageObject == null) {
              return;
            }
            if (currentMessageNum >= 0
                && currentMessageNum < NotificationsController.getInstance().popupMessages.size()) {
              NotificationsController.getInstance().popupMessages.remove(currentMessageNum);
            }
            MessagesController.getInstance()
                .markDialogAsRead(
                    currentMessageObject.getDialogId(),
                    currentMessageObject.getId(),
                    Math.max(0, currentMessageObject.getId()),
                    0,
                    currentMessageObject.messageOwner.date,
                    true,
                    true);
            currentMessageObject = null;
            getNewMessage();
          }

          @Override
          public void onTextChanged(CharSequence text, boolean big) {}

          @Override
          public void needSendTyping() {
            if (currentMessageObject != null) {
              MessagesController.getInstance()
                  .sendTyping(currentMessageObject.getDialogId(), 0, classGuid);
            }
          }

          @Override
          public void onAttachButtonHidden() {}

          @Override
          public void onAttachButtonShow() {}

          @Override
          public void onWindowSizeChanged(int size) {}
        });

    messageContainer = new FrameLayoutTouch(this);
    popupContainer.addView(messageContainer, 0);

    actionBar = new ActionBar(this);
    actionBar.setOccupyStatusBar(false);
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackgroundColor(0xff54759e);
    actionBar.setItemsBackground(R.drawable.bar_selector);
    popupContainer.addView(actionBar);
    ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
    layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    actionBar.setLayoutParams(layoutParams);

    ActionBarMenu menu = actionBar.createMenu();
    View view = menu.addItemResource(2, R.layout.popup_count_layout);
    countText = (TextView) view.findViewById(R.id.count_text);

    avatarContainer = new FrameLayoutFixed(this);
    avatarContainer.setBackgroundResource(R.drawable.bar_selector);
    avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
    actionBar.addView(avatarContainer);
    FrameLayout.LayoutParams layoutParams2 =
        (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
    layoutParams2.height = LayoutHelper.MATCH_PARENT;
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.rightMargin = AndroidUtilities.dp(48);
    layoutParams2.leftMargin = AndroidUtilities.dp(60);
    layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
    avatarContainer.setLayoutParams(layoutParams2);

    avatarImageView = new BackupImageView(this);
    avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
    avatarContainer.addView(avatarImageView);
    layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
    layoutParams2.width = AndroidUtilities.dp(42);
    layoutParams2.height = AndroidUtilities.dp(42);
    layoutParams2.topMargin = AndroidUtilities.dp(3);
    avatarImageView.setLayoutParams(layoutParams2);

    nameTextView = new TextView(this);
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    nameTextView.setLines(1);
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    avatarContainer.addView(nameTextView);
    layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(22);
    layoutParams2.gravity = Gravity.BOTTOM;
    nameTextView.setLayoutParams(layoutParams2);

    onlineTextView = new TextView(this);
    onlineTextView.setTextColor(0xffd7e8f7);
    onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    onlineTextView.setLines(1);
    onlineTextView.setMaxLines(1);
    onlineTextView.setSingleLine(true);
    onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
    onlineTextView.setGravity(Gravity.LEFT);
    avatarContainer.addView(onlineTextView);
    layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.leftMargin = AndroidUtilities.dp(54);
    layoutParams2.bottomMargin = AndroidUtilities.dp(4);
    layoutParams2.gravity = Gravity.BOTTOM;
    onlineTextView.setLayoutParams(layoutParams2);

    actionBar.setActionBarMenuOnItemClick(
        new ActionBar.ActionBarMenuOnItemClick() {
          @Override
          public void onItemClick(int id) {
            if (id == -1) {
              onFinish();
              finish();
            } else if (id == 1) {
              openCurrentMessage();
            } else if (id == 2) {
              switchToNextMessage();
            }
          }
        });

    PowerManager pm =
        (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
    wakeLock =
        pm.newWakeLock(
            PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
    wakeLock.setReferenceCounted(false);

    handleIntent(getIntent());
  }
Example #15
0
  @SuppressWarnings("deprecation")
  private void initUIComponents() {
    // 设置Fragment
    addFragment(ResFinder.getId("umeng_comm_user_info_fragment_container"), mPostedFragment);

    // 选中的某个tab时的文字颜色
    mSelectedColor = ResFinder.getColor("umeng_comm_text_topic_light_color");

    // 初始化feed、好友、粉丝、back、设置的listener
    findViewById(ResFinder.getId("umeng_comm_posted_layout")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_follow_user_layout")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_my_fans_layout")).setOnClickListener(this);
    findViewById(ResFinder.getId("umeng_comm_setting_back")).setOnClickListener(this);

    // 举报用户的Dialog
    mReportDialog = new UserReportDialog(this);
    mReportDialog.setTargetUid(mUser.id);

    Button settingButton = (Button) findViewById(ResFinder.getId("umeng_comm_save_bt"));
    settingButton.setBackgroundDrawable(ResFinder.getDrawable("umeng_comm_more"));
    RelativeLayout.LayoutParams params =
        (RelativeLayout.LayoutParams) settingButton.getLayoutParams();
    params.width = DeviceUtils.dp2px(this, 20);
    params.height = DeviceUtils.dp2px(this, 20);
    params.rightMargin = DeviceUtils.dp2px(getApplicationContext(), 10);
    settingButton.setLayoutParams(params);
    settingButton.setOnClickListener(
        new LoginOnViewClickListener() {

          @Override
          protected void doAfterLogin(View v) {
            mReportDialog.show();
          }
        });
    // 如果是用户自己,则不显示设置菜单按钮【目前菜单只有举报功能,即自己不能举报自己】
    if (mUser.id.equals(CommConfig.getConfig().loginedUser.id)
        || mUser.permisson == Permisson.SUPPER_ADMIN) {
      settingButton.setVisibility(View.GONE);
    }

    TextView titleTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_setting_title"));
    titleTextView.setText(ResFinder.getString("umeng_comm_user_center"));
    //
    mPostedTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_posted_msg_tv"));
    mPostedTv.setTextColor(mSelectedColor);

    //
    mPostedCountTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_posted_count_tv"));
    mPostedCountTv.setTextColor(mSelectedColor);

    mFollowedUserTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_followed_user_tv"));
    mFollowedUserCountTv =
        mViewFinder.findViewById(ResFinder.getId("umeng_comm_follow_user_count_tv"));

    mFansTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_my_fans_tv"));
    mFansCountTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_fans_count_tv"));
    // 昵称
    mUserNameTv = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_name_tv"));
    mUserNameTv.setText(mUser.name);

    mHeaderImageView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_header"));

    ImgDisplayOption option = ImgDisplayOption.getOptionByGender(mUser.gender);
    mHeaderImageView.setImageUrl(mUser.iconUrl, option);

    // 用户性别
    mGenderImageView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_gender"));

    // 关注按钮
    mFollowToggleButton = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_follow"));
    mFollowToggleButton.setOnClickListener(
        new Listeners.LoginOnViewClickListener() {

          @Override
          protected void doAfterLogin(View v) {
            mFollowToggleButton.setClickable(false);
            // true为选中状态为已关注,此时显示文本为“取消关注”;false代表未关注,此时显示文本为“关注”
            if (mFollowToggleButton.isChecked()) {
              mPresenter.followUser(mResultListener);
            } else {
              mPresenter.cancelFollowUser(mResultListener);
            }
          }
        });

    mAlbumTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_albums_tv"));
    mAlbumTextView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            jumpToActivityWithUid(AlbumActivity.class);
          }
        });
    mTopicTextView = mViewFinder.findViewById(ResFinder.getId("umeng_comm_user_topic_tv"));
    mTopicTextView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            jumpToActivityWithUid(FollowedTopicActivity.class);
          }
        });

    // 用户自己(在未登录的情况下,点击设置跳转到登录,此时传递进来的uid是空的情况),隐藏关注按钮,显示设置按钮
    // // 如果是超级管理员且已经关注,则隐藏取消关注按钮
    if (isHideFollowStatus()) {
      mFollowToggleButton.setVisibility(View.GONE);
    }
    initCommentView();
  }
Example #16
0
  @SuppressWarnings("static-access")
  private void init() {

    this.setBackgroundResource(R.drawable.cs_recommend_bg);
    this.setOrientation(LinearLayout.VERTICAL);
    RelativeLayout contentLayout = new RelativeLayout(context);
    LayoutParams layoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    contentLayout.setLayoutParams(layoutParams);
    this.addView(contentLayout);

    TextView titleTextView = new TextView(context);
    titleTextView.setText(R.string.download_manager);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 3);
    titleTextView.setTextColor(Color.WHITE);
    int titleMargin = 20;
    RelativeLayout.LayoutParams titleParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    titleParams.leftMargin = titleMargin;
    titleParams.rightMargin = titleMargin;
    titleParams.topMargin = titleMargin;
    titleParams.bottomMargin = titleMargin;
    titleTextView.setLayoutParams(titleParams);
    contentLayout.addView(titleTextView);

    LinearLayout managerLayout = new LinearLayout(context);
    managerLayout.setId(MANAGERLAYOUT_ID);
    managerLayout.setOrientation(LinearLayout.VERTICAL);
    int managerPad = 10;
    managerLayout.setPadding(managerPad, managerPad, managerPad, managerPad);
    int height = DisplayManager.getInstance(context).getScreenHeight() - 150;
    int width = DisplayManager.getInstance(context).getScreenWidth() - 200;
    RelativeLayout.LayoutParams managerLayoutParams =
        new RelativeLayout.LayoutParams(width, height);
    managerLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    managerLayout.setLayoutParams(managerLayoutParams);
    managerLayout.setBackgroundResource(R.drawable.bg_downmanger_content);
    // managerLayout.setBackgroundColor(Color.parseColor("#99000000"));
    contentLayout.addView(managerLayout);

    LinearLayout managerPathLayout = new LinearLayout(context);
    managerPathLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams managerPathParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50);
    managerPathLayout.setLayoutParams(managerPathParams);
    managerPathLayout.setPadding(managerPad, 0, managerPad, managerPad);

    TextView pathText = new TextView(context);
    pathText.setText(R.string.present_path);
    pathText.setGravity(Gravity.CENTER);
    pathText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3);
    pathText.setTextColor(Color.parseColor("#ffffff"));
    pathTextParams.setMargins(0, 0, 0, 0);
    pathTextParams.gravity = Gravity.CENTER;
    pathText.setLayoutParams(pathTextParams);
    managerPathLayout.addView(pathText);

    final CheckDownDialogView checkDialog = new CheckDownDialogView(context);
    String present_edit = "";
    if (checkDialog.DetectionDisk() != null) {
      present_edit = checkDialog.getDownPathname();
    }
    pathEdit = new EditText(context);
    pathEdit.setText(present_edit);
    pathEdit.setFocusable(false);
    pathEdit.setGravity(Gravity.CENTER_VERTICAL);
    pathEdit.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathEditParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 12);
    pathEdit.setTextColor(Color.parseColor("#ffffff"));
    pathEdit.setBackgroundResource(R.drawable.present_path);
    pathEditParams.gravity = Gravity.CENTER_VERTICAL;
    pathEdit.setLayoutParams(pathEditParams);
    managerPathLayout.addView(pathEdit);

    Button pathButton = new FocusAbleButton(context);
    pathButton.setText(R.string.present_sele);
    pathButton.setTextColor(Color.parseColor("#ffffff"));
    pathButton.setGravity(Gravity.CENTER);
    pathButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathButtonViewParams =
        new LinearLayout.LayoutParams(0, layoutParams.WRAP_CONTENT, 2);
    pathButtonViewParams.gravity = Gravity.CENTER;
    pathButtonViewParams.setMargins(35, 0, 0, 0);
    pathButton.setLayoutParams(pathButtonViewParams);
    managerPathLayout.addView(pathButton);
    pathButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            //				Map<String, String> labMap = checkDialog.DetectionDisk();
            List<String> pathsStr = DownloadResourceManager.getInstance().getFileDir();
            if (pathsStr != null) {
              checkDialog.choiceUsbDialog();
              checkDialog.setListener(
                  new PathChoiceClickListener() {
                    @Override
                    public void onClick(View v) {
                      // 下载进度保存
                      LinkedHashMap<String, FilmDownLoad4k> downStatus =
                          DownloadResourceManager.getInstance().getDLStatus();
                      if (downStatus != null) {
                        DownloadResourceManager.getInstance().writeDownStatus(downStatus);
                      }
                      DownloadResourceManager.getInstance().clearDLData();
                      String path = (String) v.getTag();
                      DownloadResourceManager.getInstance().initDownPath(path);
                      // Log.e(dlStatus +" "+dlStatus.size());
                      if (context instanceof DownManagerActivity) {
                        ((DownManagerActivity) context).setData(true);
                      }

                      String present_edit = checkDialog.getDownPathname();
                      pathEdit.setText(present_edit);

                      // 初始化新路径后  检测U盘下载 更新UI
                      //							LinkedHashMap<String, FilmDownLoad4k> downStatu =
                      // DownloadResourceManager.getInstance().getDLStatus();
                      //							String path_dir =
                      // DownloadResourceManager.getInstance().getDownLoadPath();
                      //							if(downStatu != null){
                      //								if((path+"/voole_video").equalsIgnoreCase(path_dir)){

                      //									File downPath = new File(path_dir);
                      //									if (TextUtils.isEmpty(DownloadResourceManager.getInstance()
                      //											.getDownLoadPath())
                      //									|| !downPath.getParentFile().exists() || !downPath.exists()){
                      //										if(clickNum == 0){
                      //											managerAct.updateDownItem();
                      //										}
                      //										clickNum ++;
                      //									}
                      if (context instanceof DownManagerActivity) {
                        if (!((DownManagerActivity) context).isAlive) { // 如果下载线程停止
                          ((DownManagerActivity) context).setData(true); // 存放数据
                          ((DownManagerActivity) context).updateDownItem(); // 启动下载线程
                        }
                      }
                    }
                  });

            } else {
              // 没插入U盘
              TVAlertDialog tvDialog = new TVAlertDialog(context);
              tvDialog.showInspectDialog(context);
            }
          }
        });

    LayoutParams parmsPath = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    parmsPath.weight = 1;
    parmsPath.topMargin = 20;
    parmsPath.leftMargin = 40;
    parmsPath.rightMargin = 90;
    managerLayout.addView(managerPathLayout, parmsPath);

    LinearLayout managerTitleLayout = new LinearLayout(context);
    managerTitleLayout.setOrientation(LinearLayout.HORIZONTAL);
    managerTitleLayout.setBackgroundResource(R.drawable.bg_down_title);
    LayoutParams managerTitleLayoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50);
    managerTitleLayout.setLayoutParams(managerTitleLayoutParams);
    managerTitleLayout.setPadding(managerPad, managerPad - 4, managerPad, managerPad + 4);

    TextView nameText = new TextView(context);
    nameText.setText(R.string.filename);
    nameText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams nameTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3);
    nameText.setTextColor(Color.parseColor("#d5ac84"));
    nameText.setGravity(Gravity.CENTER);
    nameText.setLayoutParams(nameTextParams);
    managerTitleLayout.addView(nameText);

    TextView progressText = new TextView(context);
    LayoutParams progressTextParams =
        new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4);
    progressText.setText(R.string.progress);
    progressText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    progressText.setTextColor(Color.parseColor("#d5ac84"));
    progressText.setGravity(Gravity.CENTER);
    progressText.setLayoutParams(progressTextParams);
    managerTitleLayout.addView(progressText);

    TextView speedText = new TextView(context);
    speedText.setText(R.string.speed);
    speedText.setTextColor(Color.parseColor("#d5ac84"));
    speedText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams speedTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2);
    speedText.setGravity(Gravity.CENTER);
    speedText.setLayoutParams(speedTextParams);
    managerTitleLayout.addView(speedText);

    TextView sizeText = new TextView(context);
    sizeText.setText(R.string.size);
    sizeText.setTextColor(Color.parseColor("#d5ac84"));
    sizeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams sizeTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
    sizeText.setGravity(Gravity.CENTER);
    sizeText.setLayoutParams(sizeTextParams);
    managerTitleLayout.addView(sizeText);

    TextView handleText = new TextView(context);
    handleText.setText(R.string.operation);
    handleText.setTextColor(Color.parseColor("#d5ac84"));
    handleText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams handleTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2);
    handleText.setGravity(Gravity.CENTER);
    handleText.setLayoutParams(handleTextParams);
    managerTitleLayout.addView(handleText);
    LayoutParams parms = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    parms.weight = 1;
    parms.leftMargin = 30;
    parms.rightMargin = 30;
    parms.topMargin = managerPad - 5;
    managerLayout.addView(managerTitleLayout, parms);

    adapterLinearLayout = new FilmLinearLayout(context);
    LayoutParams adapterLinearLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    adapterLinearLayoutParams.weight = 6;
    managerLayout.addView(adapterLinearLayout, adapterLinearLayoutParams);
    adapterLinearLayout.setId(FilmLinearLayout.ADAPTERLINEARLAYOUT_ID);

    int pading = 20;
    LinearLayout pageIndexLayout = new LinearLayout(context);
    pageIndexLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams pageIndexLayoutLayoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    pageIndexLayout.setLayoutParams(pageIndexLayoutLayoutParams);
    pageIndexLayoutLayoutParams.setMargins(0, pading, 0, 0);
    pageIndexLayout.setGravity(Gravity.CENTER);

    Button preButton = new FocusAbleButton(context);
    preButton.setText(R.string.pre_page);
    preButton.setTextColor(Color.WHITE);
    preButton.setGravity(Gravity.CENTER);
    preButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams preButtonViewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    preButton.setLayoutParams(preButtonViewParams);
    pageIndexLayout.addView(preButton);
    preButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            adapterLinearLayout.showPrePage();
            pageIndexTextview.setText(
                adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
          }
        });
    preButton.setPadding(pading, 0, pading, 0);

    Button nextButton = new FocusAbleButton(context);
    nextButton.setText(R.string.next_page);
    nextButton.setTextColor(Color.WHITE);
    nextButton.setGravity(Gravity.CENTER);
    nextButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams nextButtonViewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    nextButtonViewParams.leftMargin = textSize - 5;
    nextButton.setLayoutParams(nextButtonViewParams);
    pageIndexLayout.addView(nextButton);
    nextButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            adapterLinearLayout.showNextPage();
            pageIndexTextview.setText(
                adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
          }
        });
    nextButton.setPadding(pading, 0, pading, 0);

    pageIndexTextview = new TextView(context);
    pageIndexTextview.setText(
        adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
    pageIndexTextview.setTextColor(Color.WHITE);
    pageIndexTextview.setGravity(Gravity.CENTER);
    pageIndexTextview.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams pageIndexTextviewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pageIndexTextviewParams.leftMargin = textSize - 5;
    pageIndexTextview.setLayoutParams(pageIndexTextviewParams);
    pageIndexLayout.addView(pageIndexTextview);
    LayoutParams pageIndexLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    pageIndexLayoutParams.weight = 1;
    managerLayout.addView(pageIndexLayout, pageIndexLayoutParams);

    TextView warnInfoTextView = new TextView(getContext());
    warnInfoTextView.setText(R.string.down_manager_warn_info);
    warnInfoTextView.setTextColor(Color.WHITE);
    warnInfoTextView.setGravity(Gravity.CENTER);
    warnInfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    android.widget.RelativeLayout.LayoutParams warnInfoLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    warnInfoLayoutParams.addRule(RelativeLayout.BELOW, MANAGERLAYOUT_ID);
    warnInfoLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, MANAGERLAYOUT_ID);
    warnInfoLayoutParams.topMargin = textSize - 10;
    contentLayout.addView(warnInfoTextView, warnInfoLayoutParams);
  }