| @ -0,0 +1,72 @@ | |||
| package com.qhclh.ytzh.bean; | |||
| /** | |||
| * Created by 青花瓷 on 2017/6/29. | |||
| */ | |||
| ///< 利润行 | |||
| public class ReportBean { | |||
| private String item_dayage; | |||
| private String item_death; | |||
| private String item_eliminatee; | |||
| private String item_water; | |||
| private String item_weight; | |||
| public ReportBean(String item_dayage, String item_death, String item_eliminatee, String item_water, String item_weight) { | |||
| this.item_dayage = item_dayage; | |||
| this.item_death = item_death; | |||
| this.item_eliminatee = item_eliminatee; | |||
| this.item_water = item_water; | |||
| this.item_weight = item_weight; | |||
| } | |||
| public String getItem_dayage() { | |||
| return item_dayage; | |||
| } | |||
| public void setItem_dayage(String item_dayage) { | |||
| this.item_dayage = item_dayage; | |||
| } | |||
| public String getItem_death() { | |||
| return item_death; | |||
| } | |||
| public void setItem_death(String item_death) { | |||
| this.item_death = item_death; | |||
| } | |||
| public String getItem_eliminatee() { | |||
| return item_eliminatee; | |||
| } | |||
| public void setItem_eliminatee(String item_eliminatee) { | |||
| this.item_eliminatee = item_eliminatee; | |||
| } | |||
| public String getItem_water() { | |||
| return item_water; | |||
| } | |||
| public void setItem_water(String item_water) { | |||
| this.item_water = item_water; | |||
| } | |||
| public String getItem_weight() { | |||
| return item_weight; | |||
| } | |||
| public void setItem_weight(String item_weight) { | |||
| this.item_weight = item_weight; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return "ReportBean{" + | |||
| "item_dayage='" + item_dayage + '\'' + | |||
| ", item_death='" + item_death + '\'' + | |||
| ", item_eliminatee='" + item_eliminatee + '\'' + | |||
| ", item_water='" + item_water + '\'' + | |||
| ", item_weight='" + item_weight + '\'' + | |||
| '}'; | |||
| } | |||
| } | |||
| @ -0,0 +1,42 @@ | |||
| package com.qhclh.ytzh.ui; | |||
| import android.content.Context; | |||
| import android.util.AttributeSet; | |||
| import android.widget.HorizontalScrollView; | |||
| /** | |||
| * Created by 青花瓷 on 2017/6/29. | |||
| */ | |||
| public class LinkedHorizontalScrollView extends HorizontalScrollView { | |||
| private LinkScrollChangeListener listener; | |||
| public LinkedHorizontalScrollView(Context context) { | |||
| super(context); | |||
| } | |||
| public LinkedHorizontalScrollView(Context context, AttributeSet attrs) { | |||
| super(context, attrs); | |||
| } | |||
| public LinkedHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) { | |||
| super(context, attrs, defStyleAttr); | |||
| } | |||
| public void setMyScrollChangeListener(LinkScrollChangeListener listener){ | |||
| this.listener = listener; | |||
| } | |||
| @Override | |||
| protected void onScrollChanged(int l, int t, int oldl, int oldt) { | |||
| super.onScrollChanged(l, t, oldl, oldt); | |||
| if(null != listener) | |||
| listener.onscroll(this, l, t, oldl, oldt); | |||
| } | |||
| /** | |||
| * 控制滑动速度 | |||
| */ | |||
| @Override | |||
| public void fling(int velocityY) { | |||
| super.fling(velocityY / 2); | |||
| } | |||
| public interface LinkScrollChangeListener { | |||
| void onscroll(LinkedHorizontalScrollView view, int l, int t, int oldl, int oldt); | |||
| } | |||
| } | |||
| @ -0,0 +1,40 @@ | |||
| package com.qhclh.ytzh.ui; | |||
| import android.content.Context; | |||
| import android.util.AttributeSet; | |||
| import android.view.MotionEvent; | |||
| import android.widget.HorizontalScrollView; | |||
| /** | |||
| * Created by 青花瓷 on 2017/6/29. | |||
| */ | |||
| public class NoScrollHorizontalScrollView extends HorizontalScrollView { | |||
| public NoScrollHorizontalScrollView(Context context) { | |||
| super(context); | |||
| } | |||
| public NoScrollHorizontalScrollView(Context context, AttributeSet attrs) { | |||
| super(context, attrs); | |||
| } | |||
| public NoScrollHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) { | |||
| super(context, attrs, defStyleAttr); | |||
| } | |||
| @Override | |||
| public boolean onInterceptHoverEvent(MotionEvent event) { | |||
| return false; | |||
| } | |||
| @Override | |||
| public boolean dispatchTouchEvent(MotionEvent ev) { | |||
| return super.dispatchTouchEvent(ev); | |||
| } | |||
| @Override | |||
| public boolean onTouchEvent(MotionEvent ev) { | |||
| return false; | |||
| } | |||
| } | |||
| @ -0,0 +1,70 @@ | |||
| package com.qhclh.ytzh.work.tablepoultry; | |||
| 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 java.util.List; | |||
| /** | |||
| * Created by 青花瓷 on 2017/6/29. | |||
| */ | |||
| ///< 利润分析中一个适配器 | |||
| public class LvBuildhousenaneAdapter extends BaseAdapter { | |||
| private Context context; | |||
| private List<String> list; | |||
| public LvBuildhousenaneAdapter(Context context, List<String> 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 position; | |||
| } | |||
| @Override | |||
| public View getView(int position, View convertView, ViewGroup parent) { | |||
| ViewHolder holder; | |||
| if (convertView == null) { | |||
| holder = new ViewHolder(); | |||
| convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_buildhouse_name, null); | |||
| holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name); | |||
| holder.ll_buildhousename = convertView.findViewById(R.id.ll_buildhousename); | |||
| convertView.setTag(holder); | |||
| } else { | |||
| holder = (ViewHolder) convertView.getTag(); | |||
| } | |||
| holder.tv_name.setText(list.get(position)); | |||
| if (position%2==0){ | |||
| holder.ll_buildhousename.setBackgroundColor(context.getResources().getColor(R.color.greyf4f4f4)); | |||
| }else { | |||
| holder.ll_buildhousename.setBackgroundColor(context.getResources().getColor(R.color.white)); | |||
| } | |||
| return convertView; | |||
| } | |||
| class ViewHolder { | |||
| TextView tv_name; | |||
| LinearLayout ll_buildhousename; | |||
| } | |||
| } | |||
| @ -0,0 +1,89 @@ | |||
| package com.qhclh.ytzh.work.tablepoultry; | |||
| 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.bean.ReportBean; | |||
| import java.util.List; | |||
| /** | |||
| * Created by 青花瓷 on 2017/6/29. | |||
| */ | |||
| ///< 利润分析中的适配器 | |||
| public class LvReportInfoAdapter extends BaseAdapter { | |||
| private Context context; | |||
| private List<ReportBean> list; | |||
| public LvReportInfoAdapter(Context context, List<ReportBean> 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 position; | |||
| } | |||
| @Override | |||
| public View getView(int position, View convertView, ViewGroup parent) { | |||
| ViewHolder holder; | |||
| ReportBean message = list.get(position); | |||
| if (convertView == null) { | |||
| holder = new ViewHolder(); | |||
| convertView = LayoutInflater.from(context).inflate(R.layout.item_lv_buildhouse_info, null); | |||
| holder.item_dayage = (TextView) convertView.findViewById(R.id.item_dayage); | |||
| holder.item_death = (TextView) convertView.findViewById(R.id.item_death); | |||
| holder.item_eliminatee = (TextView) convertView.findViewById(R.id.item_eliminatee); | |||
| holder.item_water = (TextView) convertView.findViewById(R.id.item_water); | |||
| holder.item_weight = (TextView) convertView.findViewById(R.id.item_weight); | |||
| holder.ll_buildhouseinfo = convertView.findViewById(R.id.ll_buildhouseinfo); | |||
| convertView.setTag(holder); | |||
| } else { | |||
| holder = (ViewHolder) convertView.getTag(); | |||
| } | |||
| ///< 自己看拼音吧 我也不想看了 | |||
| holder.item_dayage.setText(message.getItem_dayage()); | |||
| holder.item_death.setText(message.getItem_death()); | |||
| holder.item_eliminatee.setText(message.getItem_eliminatee()); | |||
| holder.item_water.setText(message.getItem_water()); | |||
| holder.item_weight.setText(message.getItem_weight()); | |||
| 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_dayage; | |||
| TextView item_death; | |||
| TextView item_eliminatee; | |||
| TextView item_water; | |||
| TextView item_weight; | |||
| LinearLayout ll_buildhouseinfo; | |||
| } | |||
| } | |||
| @ -0,0 +1,147 @@ | |||
| package com.qhclh.ytzh.work.tablepoultry; | |||
| 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.ReportBean; | |||
| import com.qhclh.ytzh.ui.LinkedHorizontalScrollView; | |||
| import com.qhclh.ytzh.ui.NoScrollHorizontalScrollView; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import butterknife.BindView; | |||
| /** | |||
| * Created by 青花瓷 on 2017/12/12. | |||
| */ | |||
| public class ReportActivity extends BaseActivity { | |||
| @BindView(R.id.toolbar) | |||
| Toolbar mToolbar; | |||
| @BindView(R.id.sv_title) | |||
| NoScrollHorizontalScrollView sv_title;//不可滑动的顶部左侧的ScrollView | |||
| @BindView(R.id.sv_report_detail) | |||
| LinkedHorizontalScrollView sv_report_detail;//底部左侧的ScrollView | |||
| @BindView(R.id.lv_buildhousename) | |||
| ListView lv_buildhousename;//底部左侧的ListView | |||
| @BindView(R.id.lv_report_info) | |||
| ListView lv_report_info;//底部右侧的ListView | |||
| private boolean isLeftListEnabled = false; | |||
| private boolean isRightListEnabled = false; | |||
| private LvBuildhousenaneAdapter lvBuildhousenaneAdapter; | |||
| private LvReportInfoAdapter lvReportInfoAdapter; | |||
| private List<String> buildhouseList; | |||
| private List<ReportBean> reportBeanList; | |||
| @Override | |||
| protected int setLayoutId() { | |||
| return R.layout.act_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() { | |||
| buildhouseList = new ArrayList<>(); | |||
| reportBeanList = new ArrayList<>(); | |||
| for (int i=0;i<10;i++){ | |||
| buildhouseList.add("栋舍"+i); | |||
| reportBeanList.add(new ReportBean("1"+i,"2"+i,"3"+i,"4"+i,"5"+i)); | |||
| } | |||
| lvBuildhousenaneAdapter = new LvBuildhousenaneAdapter(this,buildhouseList); | |||
| lvReportInfoAdapter = new LvReportInfoAdapter(this,reportBeanList); | |||
| lv_buildhousename.setAdapter(lvBuildhousenaneAdapter); | |||
| lv_report_info.setAdapter(lvReportInfoAdapter); | |||
| } | |||
| @Override | |||
| protected void initOper() { | |||
| } | |||
| 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()); | |||
| } | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| @ -0,0 +1,122 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:orientation="vertical"> | |||
| <include layout="@layout/include_tool_bar" /> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent"> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="1px" | |||
| android:background="@color/greydbdbdb" /> | |||
| <TextView | |||
| android:id="@+id/tv_name" | |||
| android:layout_width="110dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:background="@color/white" | |||
| android:gravity="center" | |||
| android:paddingBottom="@dimen/dp_8" | |||
| android:paddingTop="@dimen/dp_8" | |||
| android:text="@string/Buildinghomes" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="20sp" /> | |||
| <com.qhclh.ytzh.ui.NoScrollHorizontalScrollView | |||
| android:id="@+id/sv_title" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_toRightOf="@id/tv_name" | |||
| android:background="@color/white" | |||
| android:paddingBottom="@dimen/dp_8" | |||
| android:paddingTop="@dimen/dp_8" | |||
| android:scrollbars="none"> | |||
| <LinearLayout | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/dayage" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="20sp" /> | |||
| <TextView | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/death" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="20sp" /> | |||
| <TextView | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/eliminatee" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="20sp" /> | |||
| <TextView | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/water1" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="20sp" /> | |||
| <TextView | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/weight" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="20sp" /> | |||
| </LinearLayout> | |||
| </com.qhclh.ytzh.ui.NoScrollHorizontalScrollView> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="1px" | |||
| android:layout_below="@id/tv_name" | |||
| android:background="@color/greydbdbdb" /> | |||
| <ListView | |||
| android:id="@+id/lv_buildhousename" | |||
| android:layout_width="110dp" | |||
| android:layout_height="match_parent" | |||
| android:layout_below="@id/tv_name" | |||
| android:scrollbars="none"></ListView> | |||
| <com.qhclh.ytzh.ui.LinkedHorizontalScrollView | |||
| android:id="@+id/sv_report_detail" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="match_parent" | |||
| android:layout_below="@id/tv_name" | |||
| android:layout_toRightOf="@id/lv_buildhousename" | |||
| android:scrollbars="none"> | |||
| <ListView | |||
| android:id="@+id/lv_report_info" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="match_parent"></ListView> | |||
| </com.qhclh.ytzh.ui.LinkedHorizontalScrollView> | |||
| </RelativeLayout> | |||
| </LinearLayout> | |||
| @ -0,0 +1,59 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:id="@+id/ll_buildhouseinfo" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:orientation="horizontal" | |||
| android:paddingBottom="@dimen/dp_8" | |||
| android:paddingTop="@dimen/dp_8"> | |||
| <TextView | |||
| android:id="@+id/item_dayage" | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/dayage" | |||
| android:textColor="@color/black303030" | |||
| android:textSize="@dimen/text_size_18" /> | |||
| <TextView | |||
| android:id="@+id/item_death" | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/death" | |||
| android:textColor="@color/black303030" | |||
| android:textSize="@dimen/text_size_18" /> | |||
| <TextView | |||
| android:id="@+id/item_eliminatee" | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/eliminatee" | |||
| android:textColor="@color/black303030" | |||
| android:textSize="@dimen/text_size_18" /> | |||
| <TextView | |||
| android:id="@+id/item_water" | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/water1" | |||
| android:textColor="@color/black303030" | |||
| android:textSize="@dimen/text_size_18" /> | |||
| <TextView | |||
| android:id="@+id/item_weight" | |||
| android:layout_width="80dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center" | |||
| android:text="@string/weight" | |||
| android:textColor="@color/black303030" | |||
| android:textSize="@dimen/text_size_18" /> | |||
| </LinearLayout> | |||
| @ -0,0 +1,19 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:id="@+id/ll_buildhousename" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:orientation="vertical" | |||
| android:paddingBottom="@dimen/dp_8" | |||
| android:paddingTop="@dimen/dp_8"> | |||
| <TextView | |||
| android:id="@+id/tv_name" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_gravity="center_horizontal" | |||
| android:gravity="center_horizontal" | |||
| android:textColor="@color/grey666666" | |||
| android:textSize="@dimen/text_size_18"></TextView> | |||
| </LinearLayout> | |||