中建365-二期开发-健康医典/电子围栏
parent
dd733d9367
commit
ca2dfddaa7
@ -0,0 +1,14 @@
|
||||
package com.xty.common.weight;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public interface AdapterStick <T extends RecyclerView.ViewHolder> extends Stick{
|
||||
void onBindViewHolder(T holder, int position);
|
||||
RecyclerView.ViewHolder createViewHolder(ViewGroup parent, int viewType);
|
||||
int getItemViewType(int position);
|
||||
int getItemCount();
|
||||
void bindViewHolder(T holder, int position);
|
||||
int getHeaderCount();
|
||||
}
|
@ -0,0 +1,246 @@
|
||||
package com.xty.common.weight;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PinnedHeaderItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final static String TAG = PinnedHeaderItemDecoration.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 当前绘制的pinnedheaderview
|
||||
*/
|
||||
View mPinnedHeaderView = null;
|
||||
|
||||
/**
|
||||
* pinnedheaderview的位置
|
||||
*/
|
||||
int mHeaderPosition = -1;
|
||||
|
||||
/**
|
||||
* 装载所有的viewtype
|
||||
*/
|
||||
Map<Integer, Boolean> mPinnedViewTypes = new HashMap<Integer, Boolean>();
|
||||
|
||||
/**
|
||||
* pinnedheaderview的上边距
|
||||
*/
|
||||
private int mPinnedHeaderTop;
|
||||
|
||||
/**
|
||||
* pinnedheaderview的裁剪区域
|
||||
*/
|
||||
private Rect mClipBounds;
|
||||
private Builder mBuilder;
|
||||
private int mFirstVisiblePosition;
|
||||
|
||||
private PinnedHeaderItemDecoration(Builder builder) {
|
||||
|
||||
mBuilder = builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param c
|
||||
* @param parent
|
||||
* @param state
|
||||
*/
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
createPinnedHeader(parent);
|
||||
|
||||
if (mPinnedHeaderView != null) {
|
||||
// check overlap section view.
|
||||
//TODO support only vertical header currently.
|
||||
final int headerEndAt = mPinnedHeaderView.getTop() + mPinnedHeaderView.getHeight() + 1;
|
||||
final View v = parent.findChildViewUnder(c.getWidth() / 2, headerEndAt);
|
||||
if (isPinnedView(parent, v)) {
|
||||
mPinnedHeaderTop = v.getTop() - mPinnedHeaderView.getHeight();
|
||||
} else {
|
||||
mPinnedHeaderTop = 0;
|
||||
}
|
||||
|
||||
if (isHeaderView(mFirstVisiblePosition)) {
|
||||
return;
|
||||
}
|
||||
mClipBounds = c.getClipBounds();
|
||||
mClipBounds.top = mPinnedHeaderTop + mPinnedHeaderView.getHeight();
|
||||
c.clipRect(mClipBounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param c
|
||||
* @param parent
|
||||
* @param state
|
||||
*/
|
||||
@Override
|
||||
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
if (mPinnedHeaderView != null && !isHeaderView(mFirstVisiblePosition)) {
|
||||
c.save();
|
||||
|
||||
mClipBounds.top = 0;
|
||||
c.clipRect(mClipBounds, Region.Op.UNION);
|
||||
c.translate(0, mPinnedHeaderTop);
|
||||
mPinnedHeaderView.draw(c);
|
||||
|
||||
c.restore();
|
||||
}
|
||||
}
|
||||
|
||||
private void createPinnedHeader(RecyclerView parent) {
|
||||
checkCache(parent);
|
||||
|
||||
// get LinearLayoutManager.
|
||||
//final LinearLayoutManager linearLayoutManager = getLayoutManager(parent);
|
||||
final RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
mFirstVisiblePosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
|
||||
} else if (layoutManager instanceof GridLayoutManager) {
|
||||
mFirstVisiblePosition = ((GridLayoutManager) layoutManager).findFirstVisibleItemPosition();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// mFirstVisiblePosition = gridLayoutManager.findFirstVisibleItemPosition();
|
||||
|
||||
final int headerPosition = findPinnedHeaderPosition(mFirstVisiblePosition);
|
||||
|
||||
if (isHeaderView(mFirstVisiblePosition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (headerPosition >= 0 && mHeaderPosition != headerPosition) {
|
||||
mHeaderPosition = headerPosition;
|
||||
final int viewType = mBuilder.mStickProvider.getItemViewType(headerPosition);
|
||||
|
||||
final RecyclerView.ViewHolder pinnedViewHolder = mBuilder.mStickProvider.createViewHolder(parent, viewType);
|
||||
mBuilder.mStickProvider.bindViewHolder(pinnedViewHolder, headerPosition);
|
||||
mPinnedHeaderView = pinnedViewHolder.itemView;
|
||||
|
||||
// read layout parameters
|
||||
ViewGroup.LayoutParams layoutParams = mPinnedHeaderView.getLayoutParams();
|
||||
if (layoutParams == null) {
|
||||
layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
mPinnedHeaderView
|
||||
.setLayoutParams(layoutParams);
|
||||
}
|
||||
|
||||
|
||||
int heightMode = View.MeasureSpec.getMode(layoutParams.height);
|
||||
int heightSize = View.MeasureSpec.getSize(layoutParams.height);
|
||||
|
||||
if (heightMode == View.MeasureSpec.UNSPECIFIED) {
|
||||
heightMode = View.MeasureSpec.EXACTLY;
|
||||
}
|
||||
|
||||
final int maxHeight = parent.getHeight() - parent.getPaddingTop() - parent.getPaddingBottom();
|
||||
if (heightSize > maxHeight) {
|
||||
heightSize = maxHeight;
|
||||
}
|
||||
|
||||
// measure & layout
|
||||
final int ws = View.MeasureSpec.makeMeasureSpec(parent.getWidth() - parent.getPaddingLeft() - parent.getPaddingRight(), View.MeasureSpec.EXACTLY);
|
||||
final int hs = View.MeasureSpec.makeMeasureSpec(heightSize, heightMode);
|
||||
mPinnedHeaderView.measure(ws, hs);
|
||||
|
||||
mPinnedHeaderView.layout(0, 0, mPinnedHeaderView.getMeasuredWidth(), mPinnedHeaderView.getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return the first visible view position is headerview
|
||||
*
|
||||
* @param firstVisiblePosition first visible view position
|
||||
*/
|
||||
private boolean isHeaderView(int firstVisiblePosition) {
|
||||
final int position = firstVisiblePosition - mBuilder.mStickProvider.getHeaderCount();
|
||||
if (position < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private int findPinnedHeaderPosition(int fromPosition) {
|
||||
if (fromPosition > mBuilder.mStickProvider.getItemCount()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int position = fromPosition; position >= 0; position--) {
|
||||
final int viewType = mBuilder.mStickProvider.getItemViewType(position);
|
||||
if (isPinnedViewType(viewType)) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private boolean isPinnedViewType(int viewType) {
|
||||
if (!mPinnedViewTypes.containsKey(viewType)) {
|
||||
mPinnedViewTypes.put(viewType, mBuilder.mStickProvider.isPinnedViewType(viewType));
|
||||
}
|
||||
return mPinnedViewTypes.get(viewType);
|
||||
}
|
||||
|
||||
private boolean isPinnedView(RecyclerView parent, View v) {
|
||||
final int position = parent.getChildAdapterPosition(v) /*- mBuilder.mStickProvider.getHeaderCount()*/;
|
||||
if (position == RecyclerView.NO_POSITION) {
|
||||
return false;
|
||||
}
|
||||
final int viewType = mBuilder.mStickProvider.getItemViewType(position);
|
||||
|
||||
return isPinnedViewType(viewType);
|
||||
}
|
||||
|
||||
private void checkCache(RecyclerView parent) {
|
||||
RecyclerView.Adapter adapter = parent.getAdapter();
|
||||
if (mBuilder.mStickProvider != adapter) {
|
||||
disableCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void disableCache() {
|
||||
mPinnedHeaderView = null;
|
||||
mHeaderPosition = -1;
|
||||
mPinnedViewTypes.clear();
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private AdapterStick mStickProvider;
|
||||
private PinnedHeaderItemDecoration mPinnedHeaderItemDecoration;
|
||||
|
||||
|
||||
public Builder adapterProvider(AdapterStick stickProvider) {
|
||||
mStickProvider = stickProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PinnedHeaderItemDecoration build() {
|
||||
if (mPinnedHeaderItemDecoration == null) {
|
||||
mPinnedHeaderItemDecoration = new PinnedHeaderItemDecoration(this);
|
||||
}
|
||||
return mPinnedHeaderItemDecoration;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package com.xty.common.weight;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.xty.common.R;
|
||||
|
||||
public class SideBar extends View {
|
||||
// 触摸事件
|
||||
private OnTouchingLetterChangedListener onTouchingLetterChangedListener;
|
||||
// 26个字母
|
||||
public static String[] b = {"A", "B", "C", "D", "E", "F", "G", "H", "I",
|
||||
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
|
||||
"W", "X", "Y", "Z", "#"};
|
||||
|
||||
/**
|
||||
* 过滤
|
||||
*
|
||||
* @param filterData
|
||||
*/
|
||||
public void setFilterData(String[] filterData) {
|
||||
b = filterData;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
private int choose = -1;// 选中
|
||||
private Paint paint = new Paint();
|
||||
|
||||
private TextView mTextDialog;
|
||||
|
||||
public void setTextView(TextView mTextDialog) {
|
||||
this.mTextDialog = mTextDialog;
|
||||
}
|
||||
|
||||
|
||||
public SideBar(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public SideBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public SideBar(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写这个方法
|
||||
*/
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
// 获取焦点改变背景颜色.
|
||||
int height = getHeight();// 获取对应高度
|
||||
int width = getWidth(); // 获取对应宽度
|
||||
if (b.length > 0) {
|
||||
int singleHeight = height / b.length;// 获取每一个字母的高度
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
paint.setColor(Color.rgb(85, 100, 129));
|
||||
paint.setTextSize(15);
|
||||
paint.setAntiAlias(true);
|
||||
// 选中的状态
|
||||
if (i == choose) {
|
||||
paint.setColor(Color.parseColor("#8200FF"));
|
||||
paint.setFakeBoldText(true);
|
||||
}
|
||||
// x坐标等于中间-字符串宽度的一半.
|
||||
float xPos = width / 2 - paint.measureText(b[i]) / 2;
|
||||
float yPos = singleHeight * i + singleHeight / 2;
|
||||
canvas.drawText(b[i], xPos, yPos, paint);
|
||||
paint.reset();// 重置画笔
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新当前选中的字体颜色
|
||||
* @param text 当前字体文本
|
||||
*/
|
||||
public void changeCurrentTextColor(String text){
|
||||
for(int i=0;i<b.length;i++){
|
||||
if(b[i].equals(text)){
|
||||
choose = i;
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||
final int action = event.getAction();
|
||||
final float y = event.getY();// 点击y坐标
|
||||
final int oldChoose = choose;
|
||||
final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener;
|
||||
final int c = (int) (y / getHeight() * b.length);// 点击y坐标所占总高度的比例*b数组的长度就等于点击b中的个数.
|
||||
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
// setBackgroundResource(R.drawable.sidebar_background);
|
||||
if (oldChoose != c) {
|
||||
if (c >= 0 && c < b.length) {
|
||||
if (listener != null) {
|
||||
listener.onTouchingLetterChanged(b[c]);
|
||||
}
|
||||
if (mTextDialog != null) {
|
||||
mTextDialog.setText(b[c]);
|
||||
mTextDialog.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
choose = c;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//noinspection deprecation
|
||||
setBackgroundDrawable(new ColorDrawable(0x00000000));
|
||||
choose = -1;//
|
||||
if (mTextDialog != null) {
|
||||
mTextDialog.setVisibility(View.GONE);
|
||||
}
|
||||
invalidate();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向外公开的方法
|
||||
*
|
||||
* @param onTouchingLetterChangedListener 触摸事件
|
||||
*/
|
||||
public void setOnTouchingLetterChangedListener(
|
||||
OnTouchingLetterChangedListener onTouchingLetterChangedListener) {
|
||||
this.onTouchingLetterChangedListener = onTouchingLetterChangedListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口
|
||||
*
|
||||
* @author coder
|
||||
*/
|
||||
public interface OnTouchingLetterChangedListener {
|
||||
void onTouchingLetterChanged(String s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.xty.common.weight;
|
||||
|
||||
public interface Stick {
|
||||
boolean isPinnedViewType(int viewType);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
<solid
|
||||
android:color="@color/white"/>
|
||||
<stroke android:color="@color/col_02c"
|
||||
android:width="@dimen/dp_0_5"/>
|
||||
</shape>
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,94 @@
|
||||
package com.zj365.health.act.healthcode
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.xty.base.act.BaseVmAct
|
||||
import com.xty.base.vm.BaseVm
|
||||
import com.xty.common.arouter.ARouterUrl
|
||||
import com.xty.common.arouter.RouteManager
|
||||
import com.xty.common.weight.PinnedHeaderItemDecoration
|
||||
import com.xty.common.weight.SideBar
|
||||
import com.xty.network.model.HealthBodyPartBean
|
||||
import com.xty.network.model.HealthHeaderEntity
|
||||
import com.zj365.health.R
|
||||
import com.zj365.health.adapter.healthcode.HealthBodyPartAdapter
|
||||
import com.zj365.health.databinding.ActHealthCodeBodyPartBinding
|
||||
import com.zj365.health.vm.HealthBodyPartVm
|
||||
import retrofit2.http.Path
|
||||
|
||||
@Route(path = ARouterUrl.HEALTH_BODY_PART_ACT)
|
||||
class HealthBodyPartAct : BaseVmAct<HealthBodyPartVm>() {
|
||||
|
||||
var mTitle:String =""
|
||||
var id:Long = 0
|
||||
val binding by lazy { ActHealthCodeBodyPartBinding.inflate(layoutInflater) }
|
||||
|
||||
val adapter by lazy { HealthBodyPartAdapter() }
|
||||
|
||||
var mList = ArrayList<HealthHeaderEntity<HealthBodyPartBean.HealthBodyPartChildBean>>()
|
||||
|
||||
private var filterSlideList = ArrayList<String>()
|
||||
|
||||
override fun liveObserver() {
|
||||
mViewModel.refiningNameLiveData.observe(this){
|
||||
if (it.data != null){
|
||||
it.data.forEachIndexed { index, healthBodyPartBean ->
|
||||
filterSlideList.add(healthBodyPartBean.first)
|
||||
mList.add(HealthHeaderEntity(healthBodyPartBean.first,HealthBodyPartAdapter.TYPE_HEADER,HealthBodyPartBean.HealthBodyPartChildBean(0L,"",0)))
|
||||
healthBodyPartBean.list.forEachIndexed { index, healthBodyPartChildBean ->
|
||||
mList.add(HealthHeaderEntity(healthBodyPartBean.first,HealthBodyPartAdapter.TYPE_DATA,healthBodyPartChildBean))
|
||||
|
||||
}
|
||||
}
|
||||
// binding.sideBar.setFilterData(filterSlideList.toArray(arrayOf()))
|
||||
adapter.setNewInstance(mList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
super.initView()
|
||||
statusBar(binding.title.mView)
|
||||
|
||||
mTitle = intent.extras!!.getString("title","")
|
||||
id = intent.extras!!.getLong("id",0)
|
||||
binding.title.mTvTitle.text = "${mTitle}"
|
||||
binding.title.mIvBack.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
mViewModel.getBodyPart(id)
|
||||
|
||||
/* val phid = PinnedHeaderItemDecoration.Builder(HealthBodyPartAdapter.TYPE_HEADER)
|
||||
.enableDivider(false)
|
||||
.create()
|
||||
phid.setOnScrollToHeaderListener {
|
||||
binding.sideBar.changeCurrentTextColor(it)
|
||||
}
|
||||
binding.recycler!!!!.addItemDecoration(
|
||||
phid)*/
|
||||
binding.sideBar.setOnTouchingLetterChangedListener(SideBar.OnTouchingLetterChangedListener { s: String ->
|
||||
val position: Int = adapter!!.getPositionForSection(s.get(0))
|
||||
if (position != -1) {
|
||||
binding.recycler!!.layoutManager!!.scrollToPosition(position)
|
||||
}
|
||||
})
|
||||
|
||||
binding.recycler.adapter = adapter
|
||||
binding.recycler.layoutManager = LinearLayoutManager(this)
|
||||
|
||||
adapter.setOnItemChildClickListener { adapter, view, position ->
|
||||
when(view.id){
|
||||
R.id.rx_child ->{
|
||||
bundle.clear()
|
||||
bundle.putLong("id",mList[position].data.ref_id)
|
||||
RouteManager.goAct(ARouterUrl.HEALTH_BODY_INQUIRY_ACT,bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun setLayout() = binding.root
|
||||
}
|
@ -1,13 +1,91 @@
|
||||
package com.zj365.health.act.healthcode
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.TextView
|
||||
import android.widget.TextView.OnEditorActionListener
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.tamsiree.rxkit.RxKeyboardTool
|
||||
import com.xty.base.act.BaseVmAct
|
||||
import com.xty.base.vm.BaseVm
|
||||
import com.xty.common.arouter.ARouterUrl
|
||||
import com.xty.common.arouter.RouteManager
|
||||
import com.xty.common.util.CommonToastUtils
|
||||
import com.xty.network.model.HealthBodyBean
|
||||
import com.zj365.health.adapter.healthcode.HealthCodeMainAdapter
|
||||
import com.zj365.health.databinding.ActHealthCodeMainBinding
|
||||
import com.zj365.health.vm.HealthCodeMainVm
|
||||
|
||||
class HealthCodeMainAct : BaseVmAct<BaseVm>() {
|
||||
@Route(path = ARouterUrl.HEALTH_CODE_MAIN_ACT)
|
||||
class HealthCodeMainAct : BaseVmAct<HealthCodeMainVm>() {
|
||||
val binding by lazy { ActHealthCodeMainBinding.inflate(layoutInflater) }
|
||||
|
||||
var searchStr:String? = null
|
||||
|
||||
val leftAdapter by lazy { HealthCodeMainAdapter() }
|
||||
|
||||
val rightAdapter by lazy { HealthCodeMainAdapter() }
|
||||
|
||||
override fun liveObserver() {
|
||||
mViewModel.allBodyLiveData.observe(this){
|
||||
leftAdapter.setNewInstance(it.data.subList(0,6))
|
||||
rightAdapter.setNewInstance(it.data.subList(6,it.data.size))
|
||||
}
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
super.initView()
|
||||
statusBar(binding.title.mView)
|
||||
binding.title.mTvTitle.text = "健康医典"
|
||||
binding.title.mIvBack.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
binding.etSearch.setOnEditorActionListener(object : OnEditorActionListener{
|
||||
override fun onEditorAction(p0: TextView?, p1: Int, p2: KeyEvent?): Boolean {
|
||||
if(p1 == EditorInfo.IME_ACTION_SEARCH){
|
||||
searchStr = binding.etSearch.text.toString().trim()
|
||||
if(TextUtils.isEmpty(searchStr)){
|
||||
CommonToastUtils.showToast("请输入搜索内容")
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
RxKeyboardTool.hideSoftInput(this@HealthCodeMainAct)
|
||||
return true
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
mViewModel.getAllBody()
|
||||
|
||||
binding.leftRecycler.adapter = leftAdapter
|
||||
binding.leftRecycler.layoutManager = GridLayoutManager(this,6,LinearLayoutManager.HORIZONTAL,false)
|
||||
|
||||
leftAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
var healthBodyBean = adapter.data[position] as HealthBodyBean
|
||||
bundle.clear()
|
||||
bundle.putLong("id",healthBodyBean.id)
|
||||
bundle.putString("title",healthBodyBean.med_name)
|
||||
RouteManager.goAct(ARouterUrl.HEALTH_BODY_PART_ACT,bundle)
|
||||
}
|
||||
|
||||
binding.rightRecycler.adapter = rightAdapter
|
||||
binding.rightRecycler.layoutManager = GridLayoutManager(this,6,LinearLayoutManager.HORIZONTAL,false)
|
||||
rightAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
var healthBodyBean = adapter.data[position] as HealthBodyBean
|
||||
bundle.clear()
|
||||
bundle.putLong("id",healthBodyBean.id)
|
||||
bundle.putString("title",healthBodyBean.med_name)
|
||||
RouteManager.goAct(ARouterUrl.HEALTH_BODY_PART_ACT,bundle)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLayout() = binding.root
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.zj365.health.adapter.healthcode
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||
import com.xty.network.model.HealthBodyPartBean
|
||||
import com.xty.network.model.HealthHeaderEntity
|
||||
import com.zj365.health.R
|
||||
|
||||
class HealthBodyPartAdapter: BaseMultiItemQuickAdapter<HealthHeaderEntity<HealthBodyPartBean.HealthBodyPartChildBean>, BaseViewHolder>() {
|
||||
companion object{
|
||||
const val TYPE_HEADER = 1
|
||||
const val TYPE_DATA = 2
|
||||
}
|
||||
|
||||
init {
|
||||
addItemType(TYPE_HEADER, R.layout.item_health_code_body_part_header)
|
||||
addItemType(TYPE_DATA,R.layout.item_health_code_body_part_child)
|
||||
addChildClickViewIds(R.id.rx_child)
|
||||
}
|
||||
override fun convert(holder: BaseViewHolder, item: HealthHeaderEntity<HealthBodyPartBean.HealthBodyPartChildBean>) {
|
||||
|
||||
when(item.itemType){
|
||||
TYPE_HEADER ->{
|
||||
holder.setText(R.id.tv_letter,item.first)
|
||||
}
|
||||
TYPE_DATA ->{
|
||||
holder.setText(R.id.tv_name,item.data.ref_name)
|
||||
holder.setText(R.id.tv_num,"查看:${item.data.view_num}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun getPositionForSection(section: Char): Int {
|
||||
for (i in 0 until itemCount) {
|
||||
val sortStr: String = data.get(i).first
|
||||
val firstChar = sortStr.toUpperCase()[0]
|
||||
if (firstChar == section) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.zj365.health.adapter.healthcode
|
||||
|
||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||
import com.xty.base.adapter.BaseAdapter
|
||||
import com.xty.network.model.HealthBodyBean
|
||||
import com.zj365.health.R
|
||||
|
||||
class HealthCodeMainAdapter : BaseAdapter<HealthBodyBean>(R.layout.item_health_code_main) {
|
||||
override fun convert(holder: BaseViewHolder, item: HealthBodyBean) {
|
||||
holder.setText(R.id.tv_body_sort,"${item.med_code}")
|
||||
holder.setText(R.id.tv_body_name,item.med_name)
|
||||
holder.setText(R.id.tv_body_num,"查看:${item.view_num}人")
|
||||
}
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package com.zj365.health.adapter.healthrecord
|
||||
|
||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||
import com.ruffian.library.widget.RImageView
|
||||
import com.xty.base.adapter.BaseAdapter
|
||||
import com.xty.common.setImage
|
||||
import com.zj365.health.R
|
||||
|
||||
class HealthRecordsChildAdapter : BaseAdapter<Any>(R.layout.item_health_report_record_child) {
|
||||
override fun convert(holder: BaseViewHolder, item: Any) {
|
||||
class HealthRecordsChildAdapter : BaseAdapter<String>(R.layout.item_health_report_record_child) {
|
||||
override fun convert(holder: BaseViewHolder, item: String) {
|
||||
holder.getView<RImageView>(R.id.img_pic).setImage(context,item)
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.zj365.health.vm
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.xty.base.vm.BaseVm
|
||||
import com.xty.network.model.InquiryInfoDetailBean
|
||||
import com.xty.network.model.RespBody
|
||||
import com.xty.network.model.VideoDoctorBean
|
||||
|
||||
class HealthBodyInquiryVm: BaseVm() {
|
||||
|
||||
val inquiryDetailLiveData by lazy { MutableLiveData<RespBody<InquiryInfoDetailBean>>() }
|
||||
|
||||
val videoDoctorLive by lazy { MutableLiveData<RespBody<VideoDoctorBean>>() }
|
||||
fun getInquiryDetail(id:Long){
|
||||
startHttp {
|
||||
val body = apiInterface().getInquiryInfo(id)
|
||||
body.getCodeStatus(inquiryDetailLiveData, nowData)
|
||||
}
|
||||
}
|
||||
|
||||
fun getVideoDoctorType(){
|
||||
startHttp {
|
||||
var body= apiInterface().getVideoDoctorType()
|
||||
body.getCodeStatus(videoDoctorLive,nowData)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.zj365.health.vm
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.xty.base.vm.BaseVm
|
||||
import com.xty.network.model.HealthBodyPartBean
|
||||
import com.xty.network.model.RespBody
|
||||
|
||||
class HealthBodyPartVm : BaseVm() {
|
||||
|
||||
val refiningNameLiveData by lazy { MutableLiveData<RespBody<MutableList<HealthBodyPartBean>>>() }
|
||||
fun getBodyPart(id:Long){
|
||||
startHttp {
|
||||
val body = apiInterface().getRefiningName(id)
|
||||
body.getCodeStatus(refiningNameLiveData, nowData)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.zj365.health.vm
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.xty.base.vm.BaseVm
|
||||
import com.xty.network.model.HealthBodyBean
|
||||
import com.xty.network.model.RespBody
|
||||
|
||||
class HealthCodeMainVm : BaseVm() {
|
||||
|
||||
val allBodyLiveData by lazy { MutableLiveData<RespBody<MutableList<HealthBodyBean>>>() }
|
||||
fun getAllBody(){
|
||||
|
||||
startHttp {
|
||||
val body = apiInterface().getAllBody()
|
||||
body.getCodeStatus(allBodyLiveData, nowData)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/title_white_bar"
|
||||
android:id="@+id/title"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/recycler"/>
|
||||
<com.xty.common.weight.SideBar
|
||||
android:id="@+id/sideBar"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingRight="10dp"
|
||||
android:textColor="@color/col_c7c"
|
||||
android:layout_marginBottom="@dimen/dp_89"
|
||||
android:textSize="@dimen/sp_13"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
android:background="@color/white"
|
||||
android:id="@+id/rx_child">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textColor="@color/col_313"
|
||||
android:layout_marginLeft="@dimen/dp_15"
|
||||
android:text="动脉脑痛"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_num"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:textColor="@color/col_313"
|
||||
android:layout_marginRight="@dimen/dp_30"
|
||||
android:text="查看:30"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
</RelativeLayout>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_25"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@color/col_2F2">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_letter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/col_c7c"
|
||||
android:textSize="@dimen/sp_13"
|
||||
android:text="A"
|
||||
android:layout_marginLeft="@dimen/dp_18"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_body_sort"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
android:layout_height="@dimen/dp_20"
|
||||
android:gravity="center"
|
||||
android:text="12"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="@color/col_02c"
|
||||
android:background="@drawable/shape_oval_02c" />
|
||||
<TextView
|
||||
android:id="@+id/tv_body_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="头部"
|
||||
android:textSize="@dimen/sp_15"
|
||||
android:layout_marginLeft="@dimen/dp_5"
|
||||
android:textColor="@color/col_313"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_body_num"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/col_c7c"
|
||||
android:textSize="12sp"
|
||||
tools:text="查看:187人"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,31 @@
|
||||
package com.zj365.mime.adapter
|
||||
|
||||
import android.widget.TextView
|
||||
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
||||
import com.xty.base.adapter.BaseAdapter
|
||||
import com.xty.network.model.EtFenceListBean
|
||||
import com.zj365.mime.R
|
||||
|
||||
class ElectronicFenceAdapter : BaseAdapter<EtFenceListBean.EtFenceChildBean> (R.layout.item_electron_setting){
|
||||
override fun convert(holder: BaseViewHolder, item: EtFenceListBean.EtFenceChildBean) {
|
||||
holder.setText(R.id.tv_address,item.title)
|
||||
holder.setText(R.id.tv_radius,"半径:${item.radius}米")
|
||||
var tvForbid = holder.getView<TextView>(R.id.tv_forbid)
|
||||
|
||||
if (item.type == 1){
|
||||
var drawableLeft = context.getDrawable(R.mipmap.icon_forbid_enter)
|
||||
tvForbid.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,null,null,null)
|
||||
tvForbid.compoundDrawablePadding = 5
|
||||
|
||||
tvForbid.text = "禁入"
|
||||
|
||||
}else{
|
||||
var drawableLeft = context.getDrawable(R.mipmap.icon_forbid_leave)
|
||||
tvForbid.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,null,null,null)
|
||||
tvForbid.compoundDrawablePadding = 5
|
||||
tvForbid.text = "禁出"
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.zj365.mime.vm
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.xty.base.vm.BaseVm
|
||||
import com.xty.network.model.EtFenceListBean
|
||||
import com.xty.network.model.RespBody
|
||||
|
||||
class ElectronicFenceSettingVm : BaseVm() {
|
||||
|
||||
val electronicFenceListLiveDate by lazy { MutableLiveData<RespBody<EtFenceListBean>>() }
|
||||
fun getElectronicFenceList(){
|
||||
startHttp {
|
||||
var response = apiInterface().getBtFenceList()
|
||||
response.getCodeStatus(electronicFenceListLiveDate, nowData)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.xty.network.model
|
||||
|
||||
data class EtFenceListBean(var count:Int,var list:ArrayList<EtFenceChildBean>){
|
||||
data class EtFenceChildBean(
|
||||
var id:Long,
|
||||
var user_id:Long,
|
||||
var title:String,
|
||||
var radius:Int,
|
||||
var type:Int,
|
||||
var log:String,
|
||||
var lat:String
|
||||
)
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.xty.network.model
|
||||
|
||||
data class HealthBodyBean(
|
||||
var view_num:Int,
|
||||
var med_code:Int,
|
||||
var med_name:String,
|
||||
var id:Long
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
package com.xty.network.model
|
||||
|
||||
data class HealthBodyPartBean(
|
||||
|
||||
val list:ArrayList<HealthBodyPartChildBean>,
|
||||
val first:String
|
||||
) {
|
||||
data class HealthBodyPartChildBean(
|
||||
var ref_id:Long ,
|
||||
var ref_name:String ,
|
||||
var view_num:Int
|
||||
)
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.xty.network.model
|
||||
|
||||
import com.chad.library.adapter.base.entity.MultiItemEntity
|
||||
|
||||
data class HealthHeaderEntity<T>(
|
||||
val first:String,
|
||||
override val itemType: Int,
|
||||
val data:T
|
||||
): MultiItemEntity{
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.xty.network.model
|
||||
|
||||
data class InquiryInfoDetailBean(
|
||||
val ref_name:String, //详细名称
|
||||
|
||||
val view_num:Int, //浏览量
|
||||
|
||||
val prevent:String, //预后
|
||||
|
||||
val condition:String, //状况
|
||||
|
||||
val symptom:String,//症状
|
||||
val initial:String, //首字母
|
||||
|
||||
val daily:String, //日常
|
||||
val heal:String, //治疗
|
||||
val department:String, //问诊科室
|
||||
|
||||
val seek:String, //就医
|
||||
|
||||
val etiology:String //病因
|
||||
|
||||
)
|
Loading…
Reference in New Issue