Sfoglia il codice sorgente

模拟更新

茶饮配方(竖屏)
fyf 9 mesi fa
parent
commit
d2caf5fbbf
4 ha cambiato i file con 45 aggiunte e 30 eliminazioni
  1. +38
    -28
      app/src/main/java/com/bonait/bnframework/common/linktab/TopItemDecoration.java
  2. +6
    -1
      app/src/main/java/com/bonait/bnframework/common/linktab/makegood/MakeGoodLeftAdapter.java
  3. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  4. BIN
     

+ 38
- 28
app/src/main/java/com/bonait/bnframework/common/linktab/TopItemDecoration.java Vedi File

@@ -6,6 +6,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
@@ -22,7 +23,7 @@ public class TopItemDecoration extends RecyclerView.ItemDecoration{

public Context mContext;
//间隔高度
private int mHeight = 60;
private int mHeight = 50;
//矩形画笔
private Paint mPaint=new Paint();
//标签画笔
@@ -46,20 +47,29 @@ public class TopItemDecoration extends RecyclerView.ItemDecoration{
int left = parent.getPaddingLeft();
int right =parent.getWidth() - parent.getPaddingLeft();
int childCount = parent.getChildCount();
for(int i=0;i<childCount;i++)
try
{
View childView = parent.getChildAt(i);
int bottom = childView.getTop();
int top = bottom - mHeight;

//绘制矩形间隔
c.drawRect(left, top, right, bottom, mPaint);
//根据位置获取当前item的标签
String tag =typeListener.get(parent.getChildAdapterPosition(childView));

//绘制标签文本内容
textPaint.getTextBounds(tag, 0, tag.length(), mRound);
c.drawText(tag, left + textPaint.getTextSize(), bottom - mHeight / 2 + mRound.height() / 2, textPaint);
for(int i=0;i<childCount;i++)
{
View childView = parent.getChildAt(i);
int bottom = childView.getTop();
int top = bottom - mHeight;

//绘制矩形间隔
c.drawRect(left, top, right, bottom, mPaint);
//根据位置获取当前item的标签
int index= parent.getChildAdapterPosition(childView);
if(index<typeListener.size())
{
String tag =typeListener.get(index);
//绘制标签文本内容
textPaint.getTextBounds(tag, 0, tag.length(), mRound);
c.drawText(tag, left + textPaint.getTextSize(), bottom - mHeight / 2 + mRound.height() / 2, textPaint);
}
}
}catch (Exception ex)
{
Log.e("异常", "onDraw: "+ex.getMessage());
}
}

@@ -78,19 +88,19 @@ public class TopItemDecoration extends RecyclerView.ItemDecoration{
int right =parent.getWidth() - parent.getPaddingLeft();

LinearLayoutManager manager = (LinearLayoutManager)parent.getLayoutManager();
//第一个可见item位置
int index = manager.findFirstVisibleItemPosition();
if (index != -1) {
//获取指定位置item的View信息
View childView = parent.findViewHolderForLayoutPosition(index).itemView;
int top = parent.getPaddingTop();
String tag = typeListener.get(index);
int bottom = parent.getPaddingTop() + mHeight;
//悬浮置顶判断,其实也就是一直在绘制一个矩形加文本内容(上滑时取值bottom,下滑时取值childView.bottom.toFloat())
bottom = min(childView.getBottom(), bottom);
c.drawRect(0f, top, right, bottom, mPaint);
textPaint.getTextBounds(tag, 0, tag.length(), mRound);
c.drawText(tag, left + textPaint.getTextSize(), bottom - mHeight / 2 + mRound.height() / 2, textPaint);
}
// //第一个可见item位置
// int index = manager.findFirstVisibleItemPosition();
// if (index != -1) {
// //获取指定位置item的View信息
// View childView = parent.findViewHolderForLayoutPosition(index).itemView;
// int top = parent.getPaddingTop();
// String tag = typeListener.get(index);
// int bottom = parent.getPaddingTop() + mHeight;
// //悬浮置顶判断,其实也就是一直在绘制一个矩形加文本内容(上滑时取值bottom,下滑时取值childView.bottom.toFloat())
// bottom = min(childView.getBottom(), bottom);
// c.drawRect(0f, top, right, bottom, mPaint);
// textPaint.getTextBounds(tag, 0, tag.length(), mRound);
// c.drawText(tag, left + textPaint.getTextSize(), bottom - mHeight / 2 + mRound.height() / 2, textPaint);
// }
}
}

+ 6
- 1
app/src/main/java/com/bonait/bnframework/common/linktab/makegood/MakeGoodLeftAdapter.java Vedi File

@@ -81,7 +81,12 @@ public class MakeGoodLeftAdapter extends BaseQuickAdapter<LinkMode, BaseViewHold
for (LinkMode it : Fdata) {
it.isChoose = false;
}
Fdata.get(position).isChoose = true;

if(position<Fdata.size())
{
Fdata.get(position).isChoose = true;
}

notifyDataSetChanged();
}
}


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java Vedi File

@@ -326,7 +326,7 @@ public class MakeGoodFragment extends BaseFragment {

mTopBar.setTitle("智慧菠萝点餐系统"+ConfigName.getInstance().Version);

mTopBar.addLeftImageButton(R.mipmap.silos11,1).setOnClickListener(new View.OnClickListener() {
mTopBar.addLeftImageButton(R.mipmap.silos22,1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
add_manguan.SetData();


BIN
Vedi File


Caricamento…
Annulla
Salva