Commit 757c9eef authored by hywang's avatar hywang

1.重新做配种页面逻辑,增加冻精选择搜索页面。

parent 055bbf52
......@@ -9,8 +9,8 @@ android {
applicationId "com.phlx.anchorcollect"
minSdkVersion 21
targetSdkVersion 29
versionCode 20
versionName "2.2.1"
versionCode 21
versionName "2.3.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
......@@ -50,7 +50,7 @@ android {
}
greendao {
schemaVersion 7 //数据库版本号
schemaVersion 8 //数据库版本号
daoPackage 'com.phlx.anchorcollect.db.gen'
targetGenDir 'src/main/java'
}
......
......@@ -14,10 +14,10 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* Master of DAO (schema version 7): knows all DAOs.
* Master of DAO (schema version 8): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
public static final int SCHEMA_VERSION = 7;
public static final int SCHEMA_VERSION = 8;
/** Creates underlying database table using DAOs. */
public static void createAllTables(Database db, boolean ifNotExists) {
......
......@@ -37,15 +37,20 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
private String matingStyle;
/**
* 本交公牛种畜主键
* 冻精注册
*/
private Long cattleresumeId;
private String cattleresumeId;
/**
* 冻精批次号
*/
private String frozenSemenBatch;
/**
* 其它
*/
private String other;
/**
* 配种日期
*/
......@@ -87,7 +92,7 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
private Long deptId;
/**
* 部门id
* 临时属性 和主表 移动端上传所需(验证数据使用)
*/
private Long caId;
......@@ -128,12 +133,9 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
fUnid = in.readLong();
}
matingStyle = in.readString();
if (in.readByte() == 0) {
cattleresumeId = null;
} else {
cattleresumeId = in.readLong();
}
cattleresumeId = in.readString();
frozenSemenBatch = in.readString();
other = in.readString();
matingDate = in.readString();
isReturn = in.readString();
backLoveDate = in.readString();
......@@ -160,17 +162,18 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
remark = in.readString();
}
@Generated(hash = 1766058193)
public BreedingRecordDetailEntity(Long unid, Long fUnid, String matingStyle, Long cattleresumeId,
String frozenSemenBatch, String matingDate, String isReturn, String backLoveDate, String dueDate,
String pregnancy, String raiseVarieties, String breedingPlantId, Long deptId, Long caId,
String uploadStatus, String searchValue, String createBy, String createTime, String updateBy,
String updateTime, String remark) {
@Generated(hash = 2018405645)
public BreedingRecordDetailEntity(Long unid, Long fUnid, String matingStyle, String cattleresumeId,
String frozenSemenBatch, String other, String matingDate, String isReturn, String backLoveDate,
String dueDate, String pregnancy, String raiseVarieties, String breedingPlantId, Long deptId,
Long caId, String uploadStatus, String searchValue, String createBy, String createTime,
String updateBy, String updateTime, String remark) {
this.unid = unid;
this.fUnid = fUnid;
this.matingStyle = matingStyle;
this.cattleresumeId = cattleresumeId;
this.frozenSemenBatch = frozenSemenBatch;
this.other = other;
this.matingDate = matingDate;
this.isReturn = isReturn;
this.backLoveDate = backLoveDate;
......@@ -204,13 +207,9 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
dest.writeLong(fUnid);
}
dest.writeString(matingStyle);
if (cattleresumeId == null) {
dest.writeByte((byte) 0);
} else {
dest.writeByte((byte) 1);
dest.writeLong(cattleresumeId);
}
dest.writeString(cattleresumeId);
dest.writeString(frozenSemenBatch);
dest.writeString(other);
dest.writeString(matingDate);
dest.writeString(isReturn);
dest.writeString(backLoveDate);
......@@ -280,11 +279,11 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
this.matingStyle = matingStyle;
}
public Long getCattleresumeId() {
public String getCattleresumeId() {
return cattleresumeId;
}
public void setCattleresumeId(Long cattleresumeId) {
public void setCattleresumeId(String cattleresumeId) {
this.cattleresumeId = cattleresumeId;
}
......@@ -296,6 +295,14 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
this.frozenSemenBatch = frozenSemenBatch;
}
public String getOther() {
return other;
}
public void setOther(String other) {
this.other = other;
}
public String getMatingDate() {
return matingDate;
}
......@@ -430,8 +437,9 @@ public class BreedingRecordDetailEntity extends BaseObservable implements Parcel
"unid=" + unid +
", fUnid=" + fUnid +
", matingStyle='" + matingStyle + '\'' +
", cattleresumeId=" + cattleresumeId +
", cattleresumeId='" + cattleresumeId + '\'' +
", frozenSemenBatch='" + frozenSemenBatch + '\'' +
", other='" + other + '\'' +
", matingDate='" + matingDate + '\'' +
", isReturn='" + isReturn + '\'' +
", backLoveDate='" + backLoveDate + '\'' +
......
......@@ -38,6 +38,8 @@ import com.phlx.anchorcollect.databinding.FragmentBreedingRecordBinding;
import com.phlx.anchorcollect.entity.BreedingRecordDetailEntity;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenTableColumn;
import com.phlx.anchorcollect.ui.fragment.search.SearchFrozenSemenFragment;
import com.phlx.anchorcollect.ui.fragment.search.interf.IOnSearchFrozenSemenClickListener;
import com.phlx.anchorcollect.ui.fragment.vm.BreedingRecordVM;
import com.phlx.anchorcollect.util.LoginInfoUtils;
import com.phlx.anchorcollect.util.ImagePicker;
......@@ -45,8 +47,10 @@ import com.phlx.anchorcollect.util.StringUtil;
import com.phlx.anchorcollect.widget.SpaceItemDecoration;
import com.tbruyelle.rxpermissions2.RxPermissions;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
......@@ -54,7 +58,7 @@ import io.reactivex.functions.Consumer;
import me.goldze.mvvmhabit.base.BaseFragment;
import me.goldze.mvvmhabit.utils.ToastUtils;
public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordBinding, BreedingRecordVM> {
public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordBinding, BreedingRecordVM> implements IOnSearchFrozenSemenClickListener {
private TimePickerView pvTime;
......@@ -62,6 +66,8 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
private DataGridView mDataGridView;
private SearchFrozenSemenFragment searchFrozenSemenFragment;
private static class SingletonClassInstance {
private static final BreedingRecordFragment instance = new BreedingRecordFragment();
}
......@@ -98,6 +104,9 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
public void initData() {
super.initData();
searchFrozenSemenFragment = SearchFrozenSemenFragment.newInstance();
searchFrozenSemenFragment.setIOnSearchVeterinaryClickListener(this);
viewModel.initGen();
// binding.rvCollect.addItemDecoration(new SpaceItemDecoration(10));
......@@ -132,6 +141,9 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
case "radio":
showSpinnerDialog(viewModel.currentParamEntity);
break;
case "search":
showSearchDialog(viewModel.currentParamEntity);
break;
case "photo":
if (viewModel.tag.get().equals("")) {
ToastUtils.showShort("请先输入可视耳标号");
......@@ -236,6 +248,14 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
}).show();
}
//跳转搜索关键字页面
private void showSearchDialog(GenTableColumn uiParamEntity) {
assert getParentFragment() != null;
searchFrozenSemenFragment.showFragment(requireActivity().getSupportFragmentManager(), SearchFrozenSemenFragment.TAG);
}
//输入框
private void showInputDialog(GenTableColumn uiParamEntity) {
......@@ -303,7 +323,7 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
if (uiParamEntity.getJavaType().equals("BigDecimal") || uiParamEntity.getJavaType().equals("Duoble")) {
if (!inputStr.matches(
"^\\d{1," + (finalColumnSize - finalColumnPointSize - 1) + "}(\\.\\d{1," + (finalColumnPointSize<1?1:finalColumnPointSize) + "})?$"
"^\\d{1," + (finalColumnSize - finalColumnPointSize - 1) + "}(\\.\\d{1," + (finalColumnPointSize < 1 ? 1 : finalColumnPointSize) + "})?$"
)) {
ToastUtils.showShort("输入异常,整数最大" + (finalColumnSize - finalColumnPointSize - 1) + "位,小数最大" + finalColumnPointSize + "位");
return true;
......@@ -390,6 +410,31 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
viewModel.currentParamEntity.setContent(dateFormat.format(date));
viewModel.currentParamEntity.setShowName(dateFormat.format(date));
viewModel.currentParamEntity.notifyChange();
if("matingDate".equals(viewModel.currentParamEntity.getJavaField())) {
/**
计算预产期280天
*/
String str = "yyyy-MM-dd";
SimpleDateFormat format2 = new SimpleDateFormat(str);
Date dueDate = null;
try {
dueDate = format2.parse(dateFormat.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(dueDate);
calendar.add(Calendar.DATE, 280);
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
if("dueDate".equals(gtc.getJavaField())){
gtc.setContent(format2.format(calendar.getTime()));
gtc.setShowName(format2.format(calendar.getTime()));
gtc.notifyChange();
break;
}
}
}
}
})
.setTimeSelectChangeListener(new OnTimeSelectChangeListener() {
......@@ -528,4 +573,44 @@ public class BreedingRecordFragment extends BaseFragment<FragmentBreedingRecordB
viewModel.rfid.set("");
}
}
@Override
public void OnSelectedClick(DictEntity dictEntity) {
for (GenTableColumn gtc : Configs.cattlematingDetaill) {
switch (gtc.getJavaField()) {
case "frozenSemenBatch"://冻精信息
gtc.setContent(dictEntity.getDictValue());
gtc.setShowName(dictEntity.getDictLabel());
break;
case "cattleresumeId"://冻精注册号
if ("其它".equals(dictEntity.getDictLabel())) {
gtc.setContent("");
gtc.setShowName("");
} else {
String labelStr = "";
if(dictEntity.getDictLabel().lastIndexOf("/")>-1) {
labelStr = dictEntity.getDictLabel().substring(
dictEntity.getDictLabel().lastIndexOf("/") + 1, dictEntity.getDictLabel().length());
}else{
labelStr = dictEntity.getDictLabel();
}
gtc.setContent(labelStr);
gtc.setShowName(labelStr);
}
gtc.notifyChange();
break;
case "other"://其它
if ("其他".equals(dictEntity.getDictLabel())) {
} else {
gtc.setContent("");
gtc.setShowName("");
}
gtc.notifyChange();
break;
}
}
viewModel.currentParamEntity.notifyChange();
}
}
......@@ -42,6 +42,7 @@ public class CollectGridItem extends ItemViewModel<BaseViewModel> {
switch (fragmentType) {
case Configs.BASE_ARCHIVES:
case Configs.WEIGHTING_MANAGE:
case Configs.BREEDING_RECORD_DETAIL:
if ("1".equals(entity.get().getIsEdit())) {
titleGrayVisiable.set(View.GONE);
......
package com.phlx.anchorcollect.ui.fragment.search.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.phlx.anchorcollect.R;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.ui.fragment.search.interf.IOnFrozenSemenItemClickListener;
import java.util.ArrayList;
public class FrozenSemenAdapter extends RecyclerView.Adapter<FrozenSemenAdapter.MyViewHolder> implements View.OnClickListener{
private Context context;
private ArrayList<DictEntity> frozenSemens = new ArrayList<>();
public FrozenSemenAdapter(Context context, ArrayList<DictEntity> list) {
this.context = context;
this.frozenSemens = list;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).
inflate(R.layout.item_search, parent, false);
MyViewHolder holder = new MyViewHolder(view);
view.setOnClickListener(this);
return holder;
}
@Override
public void onBindViewHolder(final MyViewHolder holder, final int position) {
holder.name.setText(frozenSemens.get(position).getDictLabel());
// holder.phone.setText(frozenSemens.get(position).getVeterinaryPhone());
holder.itemView.setTag(position);
}
@Override
public int getItemCount() {
return frozenSemens.size();
}
@Override
public void onClick(View v) {
if (onFrozenSemenItemClickListener != null && frozenSemens.size() > 0) {
onFrozenSemenItemClickListener.onItemClick(frozenSemens.get((Integer) v.getTag()));
}
}
class MyViewHolder extends RecyclerView.ViewHolder {
TextView name;
// TextView phone;
public MyViewHolder(View view) {
super(view);
name = (TextView) view.findViewById(R.id.name_tv);
// phone = (TextView) view.findViewById(R.id.phone_tv);
}
}
private IOnFrozenSemenItemClickListener onFrozenSemenItemClickListener;
public void setOnItemClickListener(IOnFrozenSemenItemClickListener onFrozenSemenItemClickListener) {
this.onFrozenSemenItemClickListener = onFrozenSemenItemClickListener;
}
}
package com.phlx.anchorcollect.ui.fragment.search.anim;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.DecelerateInterpolator;
public class CircularRevealAnim {
public static final long DURATION = 200;
private AnimListener mListener;
public interface AnimListener {
void onHideAnimationEnd();
void onShowAnimationEnd();
}
@SuppressLint("NewApi")
private void actionOtherVisible(final boolean isShow, final View triggerView, final View animView) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
if (isShow) {
animView.setVisibility(View.VISIBLE);
if (mListener != null) mListener.onShowAnimationEnd();
} else {
animView.setVisibility(View.GONE);
if (mListener != null) mListener.onHideAnimationEnd();
}
return;
}
/**
* 计算 triggerView 的中心位置
*/
int[] tvLocation = new int[2];
triggerView.getLocationInWindow(tvLocation);
int tvX = tvLocation[0] + triggerView.getWidth() / 2;
int tvY = tvLocation[1] + triggerView.getHeight() / 2;
/**
* 计算 animView 的中心位置
*/
int[] avLocation = new int[2];
animView.getLocationInWindow(avLocation);
int avX = avLocation[0] + animView.getWidth() / 2;
int avY = avLocation[1] + animView.getHeight() / 2;
int rippleW = tvX < avX ? animView.getWidth() - tvX : tvX - avLocation[0];
int rippleH = tvY < avY ? animView.getHeight() - tvY : tvY - avLocation[1];
float maxRadius = (float) Math.sqrt(rippleW * rippleW + rippleH * rippleH);
float startRadius;
float endRadius;
if (isShow) {
startRadius = 0;
endRadius = maxRadius;
} else {
startRadius = maxRadius;
endRadius = 0;
}
Animator anim = ViewAnimationUtils.createCircularReveal(animView, tvX, tvY, startRadius, endRadius);
animView.setVisibility(View.VISIBLE);
anim.setDuration(DURATION);
anim.setInterpolator(new DecelerateInterpolator());
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (isShow) {
animView.setVisibility(View.VISIBLE);
if (mListener != null) mListener.onShowAnimationEnd();
} else {
animView.setVisibility(View.GONE);
if (mListener != null) mListener.onHideAnimationEnd();
}
}
});
anim.start();
}
public void show(View triggerView, View showView) {
actionOtherVisible(true, triggerView, showView);
}
public void hide(View triggerView, View hideView) {
actionOtherVisible(false, triggerView, hideView);
}
public void setAnimListener(AnimListener listener) {
mListener = listener;
}
}
\ No newline at end of file
package com.phlx.anchorcollect.ui.fragment.search.interf;
import com.phlx.anchorcollect.entity.DictEntity;
/**
* Created by Won on 2016/4/22.
*/
public interface IOnFrozenSemenItemClickListener {
void onItemClick(DictEntity dictEntity);
}
package com.phlx.anchorcollect.ui.fragment.search.interf;
import com.phlx.anchorcollect.entity.DictEntity;
/**
* Created by Won on 2017/1/13.
*/
public interface IOnSearchFrozenSemenClickListener {
void OnSelectedClick(DictEntity dictEntity);
}
......@@ -557,18 +557,18 @@ public class BreedingRecordVM extends BaseViewModel<Repository> {
/**
计算预产期280天
*/
String str = "yyyy-MM-dd";
SimpleDateFormat format2 = new SimpleDateFormat(str);
Date date = null;
try {
date = format2.parse(breedingRecordDetailEntity.getMatingDate());
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, 280);
breedingRecordDetailEntity.setDueDate(format2.format(calendar.getTime()));
// String str = "yyyy-MM-dd";
// SimpleDateFormat format2 = new SimpleDateFormat(str);
// Date date = null;
// try {
// date = format2.parse(breedingRecordDetailEntity.getMatingDate());
// } catch (ParseException e) {
// e.printStackTrace();
// }
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// calendar.add(Calendar.DATE, 280);
// breedingRecordDetailEntity.setDueDate(format2.format(calendar.getTime()));
detailUploadData = new ArrayList<>();
detailUploadData.add(breedingRecordDetailEntity);
......
......@@ -81,8 +81,8 @@ public class LoginVM extends BaseViewModel<Repository> {
userName.set(model.getUserName());
password.set(model.getPassword());
// userName.set("13664793087");
// password.set("Abgq3087@");
userName.set("13664793087");
password.set("Abgq3087@");
// userName.set("15047962756");
// password.set("Tpsq2756*");
// userName.set("13847913985");
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_corner_white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="6dp">
<ImageView
android:id="@+id/iv_search_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:src="@drawable/ic_back_24dp" />
<EditText
android:id="@+id/et_search_keyword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:hint="搜索关键字"
android:imeOptions="actionSearch"
android:padding="6dp"
android:singleLine="true"
android:textSize="14sp" />
<!-- android:focusable="true"-->
<!-- android:focusableInTouchMode="true"-->
<ImageView
android:id="@+id/iv_search_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dp"
android:src="@drawable/ic_search_bg_24dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/line_bg" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search"
android:layout_width="match_parent"
android:layout_margin="@dimen/dp_15"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/sp_13"
android:layout_marginStart="@dimen/dp_20"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/phone_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/sp_13"
android:layout_marginEnd="@dimen/dp_20"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment