Commit e9d1aeb5 by chengxiuhong

test main

parent c3361d9f
...@@ -17,13 +17,21 @@ import android.widget.TextView; ...@@ -17,13 +17,21 @@ import android.widget.TextView;
import com.app.baselibrary.base.common.BaseActivity; import com.app.baselibrary.base.common.BaseActivity;
import com.app.baselibrary.commonUtil.CheckUtil; import com.app.baselibrary.commonUtil.CheckUtil;
import com.app.baselibrary.commonUtil.LogUtil;
import com.app.baselibrary.commonUtil.ToastUtil; import com.app.baselibrary.commonUtil.ToastUtil;
import com.oo.eye.EyeConfig; import com.oo.eye.EyeConfig;
import com.oo.eye.R; import com.oo.eye.R;
import com.oo.eye.adapter.MorePeopleAdapter; import com.oo.eye.adapter.MorePeopleAdapter;
import com.oo.eye.adapter.PopuAdapter; import com.oo.eye.adapter.PopuAdapter;
import com.oo.eye.bean.ClassBean;
import com.oo.eye.bean.GradeBean;
import com.oo.eye.bean.PopuBean; import com.oo.eye.bean.PopuBean;
import com.oo.eye.bean.SchoolBean;
import com.oo.eye.bean.SearchParamBean;
import com.oo.eye.bean.StudentBean; import com.oo.eye.bean.StudentBean;
import com.oo.eye.net.EyeDataManager;
import com.oo.seex.netlibrary.net.response.OldResponseImpl;
import com.oo.seex.netlibrary.net.response.RxCallback;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -31,6 +39,7 @@ import java.util.List; ...@@ -31,6 +39,7 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import rx.android.schedulers.AndroidSchedulers;
/** /**
* Date : 2018/8/28. * Date : 2018/8/28.
...@@ -66,8 +75,16 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -66,8 +75,16 @@ public class MorePeopleTestActivity extends BaseActivity {
LinearLayout mSeleteAreaLay; LinearLayout mSeleteAreaLay;
@BindView(R.id.key_test) @BindView(R.id.key_test)
EditText mKeyTest; EditText mKeyTest;
@BindView(R.id.progress)
RelativeLayout mProgress;
private List<StudentBean> mStudentBeans; private List<StudentBean> mStudentBeans;
private MorePeopleAdapter mPeopleAdapter; private MorePeopleAdapter mPeopleAdapter;
private SearchParamBean mSearchParamBean = new SearchParamBean();
private SchoolBean mSchoolBean;
private List<PopuBean> mBeanArrayList = new ArrayList<>();//未测试 已测试
private int popuPosition;//1学校,2未测试,3小组
private PopuAdapter mPopuAdapter;
private List<ClassBean> mClassBeans;//选择学校的所有小组
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
...@@ -78,16 +95,20 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -78,16 +95,20 @@ public class MorePeopleTestActivity extends BaseActivity {
protected void init() { protected void init() {
mRecycleView.setLayoutManager(new LinearLayoutManager(this)); mRecycleView.setLayoutManager(new LinearLayoutManager(this));
mStudentBeans = new ArrayList<>(); mStudentBeans = new ArrayList<>();
for (int i = 0; i < 10; i++) {
StudentBean studentBean = new StudentBean();
studentBean.setRealname("测试"+i);
studentBean.setNumber("2016010"+i);
studentBean.setClasses("动车组"+i);
studentBean.setBirthday("2011010"+i);
mStudentBeans.add(studentBean);
}
mPeopleAdapter = new MorePeopleAdapter(mStudentBeans, this); mPeopleAdapter = new MorePeopleAdapter(mStudentBeans, this);
mRecycleView.setAdapter(mPeopleAdapter); mRecycleView.setAdapter(mPeopleAdapter);
PopuBean popuBean = new PopuBean();
popuBean.setName("全部");
popuBean.setChick(true);
mBeanArrayList.add(popuBean);
PopuBean popuBean1 = new PopuBean();
popuBean1.setName("已测试");
mBeanArrayList.add(popuBean1);
PopuBean popuBean2 = new PopuBean();
popuBean2.setName("未测试");
mBeanArrayList.add(popuBean2);
mSearchParamBean.setSchoolId(EyeConfig.TEST_SCHOOL_ID);
search();
} }
@Override @Override
...@@ -96,22 +117,72 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -96,22 +117,72 @@ public class MorePeopleTestActivity extends BaseActivity {
ButterKnife.bind(this); ButterKnife.bind(this);
} }
@OnClick({R.id.back_iv,R.id.selete_area_lay, R.id.selete_lay, R.id.selete1_lay, R.id.do_search, R.id.begin_test}) @OnClick({R.id.back_iv, R.id.selete_area_lay, R.id.selete_lay, R.id.selete1_lay, R.id.do_search, R.id.begin_test})
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.back_iv: case R.id.back_iv:
finish(); finish();
break; break;
case R.id.selete_area_lay: case R.id.selete_area_lay:
showPopWindow(1); if (!CheckUtil.isNull(mSchoolBean)) {
setAreaData();
} else {
EyeDataManager.getInstance().getSchoolInfo(EyeConfig.TEST_SCHOOL_ID)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new RxCallback<OldResponseImpl<SchoolBean>>() {
@Override
protected void onSuccess(OldResponseImpl<SchoolBean> schoolBeanOldResponse) {
if (schoolBeanOldResponse.getResultData() != null) {
mSchoolBean = schoolBeanOldResponse.getResultData();
if (!CheckUtil.isNull(mSchoolBean)) {
setAreaData();
} else {
ToastUtil.showMessage("暂无数据");
}
}
}
@Override
protected void onError(int errorCode, String errorMessage) {
ToastUtil.showLongMessage(errorMessage);
}
});
}
break; break;
case R.id.selete_lay: case R.id.selete_lay://未测试 已测试
showPopWindow(2); popuPosition = 2;
showPopWindow(mBeanArrayList);
break; break;
case R.id.selete1_lay: case R.id.selete1_lay:
showPopWindow(3); popuPosition = 3;
if (!CheckUtil.isNull(mClassBeans)) {
setClassData();
} else {
EyeDataManager.getInstance().getSchoolInfo(EyeConfig.TEST_SCHOOL_ID)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new RxCallback<OldResponseImpl<SchoolBean>>() {
@Override
protected void onSuccess(OldResponseImpl<SchoolBean> schoolBeanOldResponse) {
if (schoolBeanOldResponse.getResultData() != null) {
mSchoolBean = schoolBeanOldResponse.getResultData();
if (!CheckUtil.isNull(mSchoolBean)) {
setClassData();
} else {
ToastUtil.showMessage("暂无数据");
}
}
}
@Override
protected void onError(int errorCode, String errorMessage) {
ToastUtil.showLongMessage(errorMessage);
}
});
}
break; break;
case R.id.do_search: case R.id.do_search:
mSearchParamBean.setStudentId(mKeyTest.getText().toString());
search();
break; break;
case R.id.begin_test: case R.id.begin_test:
List<StudentBean> beanList = new ArrayList<>(); List<StudentBean> beanList = new ArrayList<>();
...@@ -121,20 +192,62 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -121,20 +192,62 @@ public class MorePeopleTestActivity extends BaseActivity {
beanList.add(bean); beanList.add(bean);
} }
} }
if(!CheckUtil.isEmpty(beanList)) { if (!CheckUtil.isEmpty(beanList)) {
EyeConfig.getInstance().setStudents(beanList); EyeConfig.getInstance().setStudents(beanList);
Intent intent = new Intent(this, TestListActivity.class); Intent intent = new Intent(this, TestListActivity.class);
startActivity(intent); startActivity(intent);
}else{ } else {
ToastUtil.showLongMessage("请选择测试人员"); ToastUtil.showLongMessage("请选择测试人员");
} }
break; break;
} }
} }
private void showPopWindow(int position) { private void setAreaData() {
List<GradeBean> gradeBeans = mSchoolBean.getGradeList();
if (!CheckUtil.isEmpty(gradeBeans)) {
List<PopuBean> popuBeans = new ArrayList<>();
PopuBean all = new PopuBean();
all.setName("全部学校");
all.setChick(true);
popuBeans.add(all);
for (GradeBean gradeBean : gradeBeans) {
PopuBean popuBean = new PopuBean();
popuBean.setName(gradeBean.getName());
popuBean.setClassBeans(gradeBean.getClassList());
popuBeans.add(popuBean);
}
popuPosition = 1;
showPopWindow(popuBeans);
} else {
ToastUtil.showMessage("暂无数据");
}
}
private void setClassData() {
if (!CheckUtil.isEmpty(mClassBeans)) {
List<PopuBean> popuBeans = new ArrayList<>();
PopuBean all = new PopuBean();
all.setName("全部小组");
all.setClassId("");
all.setChick(true);
popuBeans.add(all);
for (ClassBean gradeBean : mClassBeans) {
PopuBean popuBean = new PopuBean();
popuBean.setName(gradeBean.getClasses());
popuBean.setClassId(gradeBean.getId());
popuBeans.add(popuBean);
}
popuPosition = 3;
showPopWindow(popuBeans);
} else {
ToastUtil.showMessage("暂无数据");
}
}
private void showPopWindow(List<PopuBean> popuBeans) {
LinearLayout view = mSeleteLay; LinearLayout view = mSeleteLay;
switch (position) { switch (popuPosition) {
case 1: case 1:
view = mSeleteAreaLay; view = mSeleteAreaLay;
break; break;
...@@ -154,7 +267,8 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -154,7 +267,8 @@ public class MorePeopleTestActivity extends BaseActivity {
ColorDrawable cd = new ColorDrawable(0x00ffffff);// 背景颜色全透明 ColorDrawable cd = new ColorDrawable(0x00ffffff);// 背景颜色全透明
popupWindow.setBackgroundDrawable(cd); popupWindow.setBackgroundDrawable(cd);
ListView listView = (ListView) conview.findViewById(R.id.list_view); ListView listView = (ListView) conview.findViewById(R.id.list_view);
listView.setAdapter(new PopuAdapter(this,null)); mPopuAdapter = new PopuAdapter(this, popuBeans);
listView.setAdapter(mPopuAdapter);
int[] location = new int[2]; int[] location = new int[2];
view.getLocationOnScreen(location); view.getLocationOnScreen(location);
// popupWindow.setAnimationStyle(R.style.style_pop_animation);// 动画效果必须放在showAsDropDown()方法上边,否则无效 // popupWindow.setAnimationStyle(R.style.style_pop_animation);// 动画效果必须放在showAsDropDown()方法上边,否则无效
...@@ -164,7 +278,7 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -164,7 +278,7 @@ public class MorePeopleTestActivity extends BaseActivity {
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
itemClick(position);
} }
}); });
} catch (Exception e) { } catch (Exception e) {
...@@ -173,4 +287,74 @@ public class MorePeopleTestActivity extends BaseActivity { ...@@ -173,4 +287,74 @@ public class MorePeopleTestActivity extends BaseActivity {
} }
private void itemClick(int position) {
List<PopuBean> popuBeans = mPopuAdapter.getBeanList();
for (PopuBean popuBean : popuBeans) {
popuBean.setChick(false);
}
PopuBean popuBean = popuBeans.get(position);
popuBean.setChick(true);
mPopuAdapter.notifyDataSetChanged();
switch (popuPosition) {
case 1://学校
mClassBeans = popuBean.getClassBeans();
mSeleteAreaTv.setText(popuBean.getName());
mSearchParamBean.setGrade(popuBean.getName());
mSearchParamBean.setClassId("");
// mSearchParamBean.setTestStatus("all");
mSelete1Tv.setText("全部小组");
// mSeleteTv.setText("全部");
break;
case 2://测试
mSeleteTv.setText(popuBean.getName());
String test = "all";
// 全部:all,已测试:tested,未测试:untested
switch (position) {
case 0:
test = "all";
break;
case 1:
test = "tested";
break;
case 2:
test = "untested";
break;
}
mSearchParamBean.setTestStatus(test);
break;
case 3://小组
mSearchParamBean.setClassId(popuBean.getClassId());
mSelete1Tv.setText(popuBean.getName());
break;
}
mSearchParamBean.setStudentId("");
search();
}
/**
* 搜索
*/
private void search() {
mProgress.setVisibility(View.VISIBLE);
EyeDataManager.getInstance().getStudents(mSearchParamBean.getParams())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new RxCallback<OldResponseImpl<List<StudentBean>>>() {
@Override
protected void onSuccess(OldResponseImpl<List<StudentBean>> listOldResponse) {
if (listOldResponse != null && listOldResponse.getData() != null) {
mProgress.setVisibility(View.GONE);
mPeopleAdapter.clear();
mPeopleAdapter.appendToListAndNotify(listOldResponse.getData());
} else {
ToastUtil.showMessage("暂无数据");
}
}
@Override
protected void onError(int errorCode, String errorMessage) {
mProgress.setVisibility(View.GONE);
ToastUtil.showMessage(errorMessage);
}
});
}
} }
...@@ -130,6 +130,10 @@ public class SinglePeopleTestActivity extends BaseActivity { ...@@ -130,6 +130,10 @@ public class SinglePeopleTestActivity extends BaseActivity {
List<GradeBean> gradeBeans = mSchoolBean.getGradeList(); List<GradeBean> gradeBeans = mSchoolBean.getGradeList();
if (!CheckUtil.isEmpty(gradeBeans)) { if (!CheckUtil.isEmpty(gradeBeans)) {
List<PopuBean> popuBeans = new ArrayList<>(); List<PopuBean> popuBeans = new ArrayList<>();
PopuBean all = new PopuBean();
all.setName("全部学校");
all.setChick(true);
popuBeans.add(all);
for (GradeBean gradeBean : gradeBeans) { for (GradeBean gradeBean : gradeBeans) {
PopuBean popuBean = new PopuBean(); PopuBean popuBean = new PopuBean();
popuBean.setName(gradeBean.getName()); popuBean.setName(gradeBean.getName());
...@@ -170,6 +174,7 @@ public class SinglePeopleTestActivity extends BaseActivity { ...@@ -170,6 +174,7 @@ public class SinglePeopleTestActivity extends BaseActivity {
mPopuAdapter.notifyDataSetChanged(); mPopuAdapter.notifyDataSetChanged();
mSearchParamBean.setGrade(popuBean.getName()); mSearchParamBean.setGrade(popuBean.getName());
mSearchParamBean.setStudentId(""); mSearchParamBean.setStudentId("");
mSeleteAreaTv.setText(popuBean.getName());
search(); search();
} }
}); });
...@@ -190,6 +195,7 @@ public class SinglePeopleTestActivity extends BaseActivity { ...@@ -190,6 +195,7 @@ public class SinglePeopleTestActivity extends BaseActivity {
protected void onSuccess(OldResponseImpl<List<StudentBean>> listOldResponse) { protected void onSuccess(OldResponseImpl<List<StudentBean>> listOldResponse) {
if (listOldResponse != null && listOldResponse.getData() != null) { if (listOldResponse != null && listOldResponse.getData() != null) {
mProgress.setVisibility(View.GONE); mProgress.setVisibility(View.GONE);
mPeopleAdapter.clear();
mPeopleAdapter.appendToListAndNotify(listOldResponse.getData()); mPeopleAdapter.appendToListAndNotify(listOldResponse.getData());
} else { } else {
ToastUtil.showMessage("暂无数据"); ToastUtil.showMessage("暂无数据");
......
...@@ -62,4 +62,7 @@ public class PopuAdapter extends BaseAdapter { ...@@ -62,4 +62,7 @@ public class PopuAdapter extends BaseAdapter {
textView.setText(bean.getName()); textView.setText(bean.getName());
return view; return view;
} }
public List<PopuBean> getBeanList(){
return mBeanList;
}
} }
...@@ -2,6 +2,8 @@ package com.oo.eye.bean; ...@@ -2,6 +2,8 @@ package com.oo.eye.bean;
import com.app.baselibrary.bean.BaseBean; import com.app.baselibrary.bean.BaseBean;
import java.util.List;
/** /**
* Date : 2018/9/4. * Date : 2018/9/4.
* Author: cxh * Author: cxh
...@@ -11,6 +13,26 @@ public class PopuBean extends BaseBean { ...@@ -11,6 +13,26 @@ public class PopuBean extends BaseBean {
private String name; private String name;
private boolean isChick; private boolean isChick;
public String getClassId() {
return classId;
}
public void setClassId(String classId) {
this.classId = classId;
}
private String classId;
public List<ClassBean> getClassBeans() {
return mClassBeans;
}
public void setClassBeans(List<ClassBean> classBeans) {
mClassBeans = classBeans;
}
private List<ClassBean> mClassBeans;
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
android:id="@+id/selete_tv" android:id="@+id/selete_tv"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="未测试" android:text="全部"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="@dimen/sp_18" /> android:textSize="@dimen/sp_18" />
<ImageView <ImageView
...@@ -278,5 +278,16 @@ ...@@ -278,5 +278,16 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/begin_test" android:layout_above="@+id/begin_test"
android:layout_below="@+id/ddd"></android.support.v7.widget.RecyclerView> android:layout_below="@+id/ddd"></android.support.v7.widget.RecyclerView>
<RelativeLayout
android:id="@+id/progress"
android:layout_below="@+id/ddd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#60000000">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
android:id="@+id/key_test" android:id="@+id/key_test"
android:layout_width="140dip" android:layout_width="140dip"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/white"
android:layout_marginLeft="@dimen/dp_6" android:layout_marginLeft="@dimen/dp_6"
android:background="@null" android:background="@null"
android:hint="输入学员编号后4位" android:hint="输入学员编号后4位"
......
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