diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 53bc35e..ce7b22a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -169,6 +169,8 @@ android:screenOrientation="portrait" /> + adapterView, View view, int i, long l) { - System.out.println("aaa+++id+++"+l); +// System.out.println("aaa+++id+++"+l); + Intent intent = new Intent(HatcheryActivity.this,HatcheryReportActivity.class); + intent.putExtra("hatchingStoreID",l); + startActivity(intent); } }); } diff --git a/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportActivity.java b/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportActivity.java new file mode 100644 index 0000000..05acff7 --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportActivity.java @@ -0,0 +1,154 @@ +package com.qhclh.ytzh.work.Hatchery; + +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.widget.AbsListView; +import android.widget.HorizontalScrollView; +import android.widget.ListView; + +import com.qhclh.ytzh.R; +import com.qhclh.ytzh.base.BaseActivity; +import com.qhclh.ytzh.bean.ReportString; +import com.qhclh.ytzh.ui.LinkedHorizontalScrollView; +import com.qhclh.ytzh.ui.NoScrollHorizontalScrollView; +import com.qhclh.ytzh.work.tablepoultry.LvBuildhousenaneAdapter; + +import java.util.ArrayList; +import java.util.List; + +import butterknife.BindView; + +/** + * Created by 青花瓷 on 2018/4/2. + */ + +public class HatcheryReportActivity extends BaseActivity { + @BindView(R.id.toolbar) + Toolbar mToolbar; + @BindView(R.id.sv_title_hatchery) + NoScrollHorizontalScrollView sv_title;//不可滑动的顶部左侧的ScrollView + @BindView(R.id.sv_report_detail_hatchery) + LinkedHorizontalScrollView sv_report_detail;//底部左侧的ScrollView + @BindView(R.id.lv_left) + ListView lv_buildhousename;//底部左侧的ListView + @BindView(R.id.lv_report_info_right) + ListView lv_report_info;//底部右侧的ListView + + private boolean isLeftListEnabled = false; + private boolean isRightListEnabled = false; + + private LvBuildhousenaneAdapter lvBuildhousenaneAdapter; + private HatcheryReportInfoAdapter adapter; + + private List buildhouseList; + private List reportBeanList; + + private long hatchingStoreID; + @Override + protected int setLayoutId() { + return R.layout.act_hatchery_report; + } + + @Override + protected void initView() { + initToolbar(mToolbar, "报表指数", new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + combination(lv_buildhousename, lv_report_info, sv_title, sv_report_detail); + } + + @Override + protected void initData() { + hatchingStoreID= getIntent().getLongExtra("hatchingStoreID",0); + buildhouseList = new ArrayList<>(); + reportBeanList = new ArrayList<>(); + + for (int i =0;i<20;i++){ + buildhouseList.add(new ReportString(i,"")); + reportBeanList.add(new HatcheryReportBean(i,i+1+"",i+2+"",i+3+"",i+4+"",i+5+"",i+6+"",i+7+"",i+8+"",i+9+"")); + } + lvBuildhousenaneAdapter = new LvBuildhousenaneAdapter(HatcheryReportActivity.this,buildhouseList); + adapter = new HatcheryReportInfoAdapter(HatcheryReportActivity.this,reportBeanList); + lv_buildhousename.setAdapter(lvBuildhousenaneAdapter); + lv_report_info.setAdapter(adapter); + } + + @Override + protected void initOper() { + + } + + @Override + protected void onResume() { + super.onResume(); + + } + + private void combination(final ListView lvName, final ListView lvDetail, final HorizontalScrollView title, LinkedHorizontalScrollView content) { + /** + * 左右滑动同步 + */ + content.setMyScrollChangeListener(new LinkedHorizontalScrollView.LinkScrollChangeListener() { + @Override + public void onscroll(LinkedHorizontalScrollView view, int x, int y, int oldx, int oldy) { + title.scrollTo(x, y); + } + }); + + /** + * 上下滑动同步 + */ + // 禁止快速滑动 + lvName.setOverScrollMode(ListView.OVER_SCROLL_NEVER); + lvDetail.setOverScrollMode(ListView.OVER_SCROLL_NEVER); + //左侧ListView滚动时,控制右侧ListView滚动 + lvName.setOnScrollListener(new AbsListView.OnScrollListener() { + + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + //这两个enable标志位是为了避免死循环 + if (scrollState == SCROLL_STATE_TOUCH_SCROLL) { + isRightListEnabled = false; + isLeftListEnabled = true; + } else if (scrollState == SCROLL_STATE_IDLE) { + isRightListEnabled = true; + } + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, + int totalItemCount) { + View child = view.getChildAt(0); + if (child != null && isLeftListEnabled) { + lvDetail.setSelectionFromTop(firstVisibleItem, child.getTop()); + } + } + }); + + //右侧ListView滚动时,控制左侧ListView滚动 + lvDetail.setOnScrollListener(new AbsListView.OnScrollListener() { + @Override + public void onScrollStateChanged(AbsListView view, int scrollState) { + if (scrollState == SCROLL_STATE_TOUCH_SCROLL) { + isLeftListEnabled = false; + isRightListEnabled = true; + } else if (scrollState == SCROLL_STATE_IDLE) { + isLeftListEnabled = true; + } + } + + @Override + public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, + int totalItemCount) { + View c = view.getChildAt(0); + if (c != null && isRightListEnabled) { + lvName.setSelectionFromTop(firstVisibleItem, c.getTop()); + } + } + }); + } +} diff --git a/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportBean.java b/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportBean.java new file mode 100644 index 0000000..5969860 --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportBean.java @@ -0,0 +1,127 @@ +package com.qhclh.ytzh.work.Hatchery; + +/** + * Created by 青花瓷 on 2018/3/23. + */ + +public class HatcheryReportBean { + private long ID; + private String HatchIncubateDate ; + private String BreedFactory_Name; + private String WeekAge; + private String HatchIncubateNumber; + private String NumberSurvival_HatchDownTray; + private String NumberDead_HatchDownTray; + private String Number_HatchChickOut_Estimated; + private String SurvivalyRate; + private String DeadRate; + + public HatcheryReportBean(long ID, String hatchIncubateDate, String breedFactory_Name, String weekAge, String hatchIncubateNumber, String numberSurvival_HatchDownTray, String numberDead_HatchDownTray, String number_HatchChickOut_Estimated, String survivalyRate, String deadRate) { + this.ID = ID; + HatchIncubateDate = hatchIncubateDate; + BreedFactory_Name = breedFactory_Name; + WeekAge = weekAge; + HatchIncubateNumber = hatchIncubateNumber; + NumberSurvival_HatchDownTray = numberSurvival_HatchDownTray; + NumberDead_HatchDownTray = numberDead_HatchDownTray; + Number_HatchChickOut_Estimated = number_HatchChickOut_Estimated; + SurvivalyRate = survivalyRate; + DeadRate = deadRate; + } + + public long getID() { + return ID; + } + + public void setID(long ID) { + this.ID = ID; + } + + public String getHatchIncubateDate() { + return HatchIncubateDate; + } + + public void setHatchIncubateDate(String hatchIncubateDate) { + HatchIncubateDate = hatchIncubateDate; + } + + public String getBreedFactory_Name() { + return BreedFactory_Name; + } + + public void setBreedFactory_Name(String breedFactory_Name) { + BreedFactory_Name = breedFactory_Name; + } + + public String getWeekAge() { + return WeekAge; + } + + public void setWeekAge(String weekAge) { + WeekAge = weekAge; + } + + public String getHatchIncubateNumber() { + return HatchIncubateNumber; + } + + public void setHatchIncubateNumber(String hatchIncubateNumber) { + HatchIncubateNumber = hatchIncubateNumber; + } + + public String getNumberSurvival_HatchDownTray() { + return NumberSurvival_HatchDownTray; + } + + public void setNumberSurvival_HatchDownTray(String numberSurvival_HatchDownTray) { + NumberSurvival_HatchDownTray = numberSurvival_HatchDownTray; + } + + public String getNumberDead_HatchDownTray() { + return NumberDead_HatchDownTray; + } + + public void setNumberDead_HatchDownTray(String numberDead_HatchDownTray) { + NumberDead_HatchDownTray = numberDead_HatchDownTray; + } + + public String getNumber_HatchChickOut_Estimated() { + return Number_HatchChickOut_Estimated; + } + + public void setNumber_HatchChickOut_Estimated(String number_HatchChickOut_Estimated) { + Number_HatchChickOut_Estimated = number_HatchChickOut_Estimated; + } + + public String getSurvivalyRate() { + return SurvivalyRate; + } + + public void setSurvivalyRate(String survivalyRate) { + SurvivalyRate = survivalyRate; + } + + public String getDeadRate() { + return DeadRate; + } + + public void setDeadRate(String deadRate) { + DeadRate = deadRate; + } + + @Override + public String toString() { + return "HatcheryReportBean{" + + "ID=" + ID + + ", HatchIncubateDate='" + HatchIncubateDate + '\'' + + ", BreedFactory_Name='" + BreedFactory_Name + '\'' + + ", WeekAge='" + WeekAge + '\'' + + ", HatchIncubateNumber='" + HatchIncubateNumber + '\'' + + ", NumberSurvival_HatchDownTray='" + NumberSurvival_HatchDownTray + '\'' + + ", NumberDead_HatchDownTray='" + NumberDead_HatchDownTray + '\'' + + ", Number_HatchChickOut_Estimated='" + Number_HatchChickOut_Estimated + '\'' + + ", SurvivalyRate='" + SurvivalyRate + '\'' + + ", DeadRate='" + DeadRate + '\'' + + '}'; + } +} diff --git a/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportInfoAdapter.java b/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportInfoAdapter.java new file mode 100644 index 0000000..be5795f --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/work/Hatchery/HatcheryReportInfoAdapter.java @@ -0,0 +1,109 @@ +package com.qhclh.ytzh.work.Hatchery; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.qhclh.ytzh.R; +import com.qhclh.ytzh.work.Poultrydailyreport.PoultryReportBean; + +import java.util.List; + +/** + * Created by 青花瓷 on 2017/6/29. + */ +///< 具体信息 +public class HatcheryReportInfoAdapter extends BaseAdapter { + private Context context; + private List list; + + public HatcheryReportInfoAdapter(Context context, List list) { + this.context = context; + this.list = list; + } + + @Override + public int getCount() { + return list.size(); + } + + @Override + public Object getItem(int position) { + return list.get(position); + } + + @Override + public long getItemId(int position) { + return list.get(position).getID(); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + HatcheryReportBean message = list.get(position); + if (convertView == null) { + holder = new ViewHolder(); + convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_hatchery_info, null); + holder.item_rufushijian = (TextView) convertView.findViewById(R.id.item_rufushijian); + holder.item_yangzhichang = (TextView) convertView.findViewById(R.id.item_yangzhichang); + holder.item_zhouling = (TextView) convertView.findViewById(R.id.item_zhouling); + holder.item_shangfushuliang = (TextView) convertView.findViewById(R.id.item_shangfushuliang); + holder.item_huopeidanshuliang = (TextView) convertView.findViewById(R.id.item_huopeidanshuliang); + holder.item_sipeidanshuliang = (TextView) convertView.findViewById(R.id.item_sipeidanshuliang); + holder.item_yujichuchushu = (TextView) convertView.findViewById(R.id.item_yujichuchushu); + holder.item_jianpeidanlv = (TextView) convertView.findViewById(R.id.item_jianpeidanlv); + + + holder.ll_buildhouseinfo = convertView.findViewById(R.id.ll_buildhouseinfo); + holder.item_sipeilv = convertView.findViewById(R.id.item_sipeilv); + + + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + ///< 自己看拼音吧 我也不想看了 + holder.item_rufushijian.setText(message.getHatchIncubateDate()); + holder.item_yangzhichang.setText(message.getBreedFactory_Name()); + holder.item_zhouling.setText(message.getWeekAge()); + + holder.item_shangfushuliang.setText(message.getHatchIncubateNumber()); + holder.item_huopeidanshuliang.setText(message.getNumberSurvival_HatchDownTray()); + holder.item_sipeidanshuliang.setText(message.getNumberDead_HatchDownTray()); + + holder.item_yujichuchushu.setText(message.getNumber_HatchChickOut_Estimated()); + holder.item_jianpeidanlv.setText(message.getSurvivalyRate()); + + holder.item_sipeilv.setText(message.getDeadRate()); + + if (position%2==0){ + holder.ll_buildhouseinfo.setBackgroundColor(context.getResources().getColor(R.color.greyf4f4f4)); + }else { + holder.ll_buildhouseinfo.setBackgroundColor(context.getResources().getColor(R.color.white)); + } + + return convertView; + } + private class ViewHolder { + TextView item_rufushijian; + TextView item_yangzhichang; + TextView item_zhouling; + + TextView item_shangfushuliang; + TextView item_huopeidanshuliang; + TextView item_sipeidanshuliang; + + TextView item_yujichuchushu; + TextView item_jianpeidanlv; + + TextView item_sipeilv; + LinearLayout ll_buildhouseinfo; + } +} + + diff --git a/app/src/main/res/layout/act_hatchery_report.xml b/app/src/main/res/layout/act_hatchery_report.xml new file mode 100644 index 0000000..bd6618d --- /dev/null +++ b/app/src/main/res/layout/act_hatchery_report.xml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_lv_hatchery_info.xml b/app/src/main/res/layout/item_lv_hatchery_info.xml new file mode 100644 index 0000000..6c88f55 --- /dev/null +++ b/app/src/main/res/layout/item_lv_hatchery_info.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file