|
|
@@ -242,8 +242,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
private TextView doIt;
|
|
|
private TextView willStart;
|
|
|
private TextView promote_goods_tv;
|
|
|
- private View doItLine;
|
|
|
- private FrameLayout lines;
|
|
|
+ private View do_it_every_day_line;
|
|
|
|
|
|
/**
|
|
|
* @return 是否显示兑换邀请码红包
|
|
|
@@ -483,13 +482,8 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
doIt = titleCardLayout.findViewById(R.id.do_it_text);
|
|
|
willStart = titleCardLayout.findViewById(R.id.will_start_text);
|
|
|
promote_goods_tv = titleCardLayout.findViewById(R.id.promote_goods_tv);
|
|
|
- doItLine = titleCardLayout.findViewById(R.id.do_it_every_day_line);
|
|
|
- int lineWidth = (int) doIt.getPaint().measureText(doIt.getText().toString());
|
|
|
- lines = titleCardLayout.findViewById(R.id.but_will_start);
|
|
|
- LayoutParamsUtil.resetLayoutParams(lines, new Lp().setWidth(lineWidth));
|
|
|
- int lineX = (G.WIDTH / 3 - lineWidth) / 2;
|
|
|
- LayoutParamsUtil.resetLayoutParams(doItLine, new Lp().setWidth(G.WIDTH - lineX * 2));
|
|
|
- lines.setX(lineX);
|
|
|
+ do_it_every_day_line = titleCardLayout.findViewById(R.id.do_it_every_day_line);
|
|
|
+ setTitleCardLayout(doIt.getText().toString(), 3, curPosition);
|
|
|
doIt.setOnClickListener(v -> {
|
|
|
if (mViewPager != null) {
|
|
|
mViewPager.setCurrentItem(0);
|
|
|
@@ -512,6 +506,12 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
ViewUtil.setVisibility(titleCardLayout, false);
|
|
|
}
|
|
|
|
|
|
+ private void setTitleCardLayout(String text, int n, int curPosition) {
|
|
|
+ int lineWidth = (int) doIt.getPaint().measureText(text);
|
|
|
+ int leftMargin = (G.WIDTH / n - lineWidth) / 2 + G.WIDTH * curPosition / n;
|
|
|
+ LayoutParamsUtil.resetLayoutParams(do_it_every_day_line, new Lp().setWidth(lineWidth).setLeftMargin(leftMargin));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 每日必做按钮事件回调
|
|
|
*/
|
|
|
@@ -522,7 +522,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
|
|
|
}
|
|
|
- LayoutParamsUtil.resetLayoutParams(doItLine, new Lp().setGravity(Gravity.START));
|
|
|
+ setTitleCardLayout(doIt.getText().toString(), 3, curPosition);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -535,7 +535,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
|
|
|
}
|
|
|
- LayoutParamsUtil.resetLayoutParams(doItLine, new Lp().setGravity(Gravity.CENTER));
|
|
|
+ setTitleCardLayout(doIt.getText().toString(), 3, curPosition);
|
|
|
}
|
|
|
/**
|
|
|
* 点击限时抢购
|
|
|
@@ -547,7 +547,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
|
|
|
}
|
|
|
- LayoutParamsUtil.resetLayoutParams(doItLine, new Lp().setGravity(Gravity.END));
|
|
|
+ setTitleCardLayout(doIt.getText().toString(), 3, curPosition);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -650,6 +650,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
|
|
|
@Override
|
|
|
public void onPageSelected(int position) {
|
|
|
+ curPosition = position;
|
|
|
switch (position) {
|
|
|
case 0:
|
|
|
toDayClick();
|
|
|
@@ -661,7 +662,6 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
|
|
|
clickPromoteGoods();
|
|
|
break;
|
|
|
}
|
|
|
- curPosition = position;
|
|
|
}
|
|
|
|
|
|
@Override
|