Commit 6ad95bc3 authored by Xinghaoxiang's avatar Xinghaoxiang

coding

parent 349c6026
......@@ -9,6 +9,7 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/treeview_lib" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
......
......@@ -5,6 +5,7 @@
<module fileurl="file://$PROJECT_DIR$/DutyManager.iml" filepath="$PROJECT_DIR$/DutyManager.iml" />
<module fileurl="file://$PROJECT_DIR$/Zhiban.iml" filepath="$PROJECT_DIR$/Zhiban.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/treeview_lib/treeview_lib.iml" filepath="$PROJECT_DIR$/treeview_lib/treeview_lib.iml" />
</modules>
</component>
</project>
\ No newline at end of file
......@@ -7,8 +7,8 @@ android {
applicationId "cn.bsl.bxbg.zhiban"
minSdkVersion 22
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionCode 7
versionName "1.7.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
......@@ -29,7 +29,7 @@ android {
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
......@@ -44,6 +44,9 @@ dependencies {
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.2'
compile 'com.android.support:design:26.0.0-alpha1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile project(':treeview_lib')
compile files('libs/xutils3.jar')
}
......@@ -14,14 +14,14 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!--<category android:name="android.intent.category.LAUNCHER" />-->
</intent-filter>
</activity>
<activity
android:name=".view.ZhibanInfoActivity"
android:label="值班信息" />
<activity
android:name=".view.ZhibanTableActivity"
android:name=".view.ZhibanTableActivity"
android:label="值班表" />
<activity
android:name=".view.TiaobanRecordActivity"
......@@ -35,9 +35,19 @@
<activity
android:name=".view.TiaoBanPublish"
android:label="调班申请" />
<activity android:name=".view.DutyChangePeopleActivity"
android:label="变更人选择"
<activity
android:name=".view.DutyChangePeopleActivity"
android:label="变更人选择" />
<activity
android:name=".view.WaitMeActivity"
android:label="待办事项" />
<activity android:name=".view.DutyTransferActivity"
android:label="交接班管理"
/>
<activity android:name=".view.TakeOverDetailsActivity"
android:label="详情"
/>
<activity android:name=".view.AddMeetingPersonActivity2" />
</application>
</manifest>
\ No newline at end of file
package com.bril.baoding.studio.aidl;
interface GetUserid {
int getUserid();
String getUsername();
}
\ No newline at end of file
package cn.bsl.bxbg.zhiban;
import android.app.Application;
import org.xutils.x;
/**
* Created by Xinghx on 2018/5/18 0018.
*/
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
x.Ext.init(this);
x.Ext.setDebug(BuildConfig.DEBUG);
}
}
package cn.bsl.bxbg.zhiban.adapter;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.RadioButton;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.bean.Group;
import cn.bsl.bxbg.zhiban.bean.SppUser;
import cn.bsl.bxbg.zhiban.listener.OnAddUserCountListener;
public class EListAdapter extends BaseExpandableListAdapter implements ExpandableListView.OnChildClickListener {
private Context context;
private ArrayList<Group> groups;
private ArrayList<SppUser> childs;
private OnAddUserCountListener listener;
private Boolean flag;// converview监听radiobutton
public EListAdapter(Context context, ArrayList<Group> groups) {
this.context = context;
this.groups = groups;
childs = new ArrayList<SppUser>();
listener = (OnAddUserCountListener) this.context;// 接口回调--选择人数--刷新视图
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getGroupCount()
*/
@Override
public int getGroupCount() {
return groups.size();
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getChildrenCount(int)
*/
@Override
public int getChildrenCount(int groupPosition) {
return groups.get(groupPosition).getChildrenCount();
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getGroup(int)
*/
@Override
public Object getGroup(int groupPosition) {
return groups.get(groupPosition);
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getChild(int, int)
*/
@Override
public Object getChild(int groupPosition, int childPosition) {
return groups.get(groupPosition).getChildItem(childPosition);
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getGroupId(int)
*/
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getChildId(int, int)
*/
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#hasStableIds()
*/
@Override
public boolean hasStableIds() {
return true;
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getGroupView(int, boolean,
* android.view.View, android.view.ViewGroup)
*/
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
Group group = (Group) getGroup(groupPosition);
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.group_layout, null);
}
TextView tv = (TextView) convertView.findViewById(R.id.tvGroup);
tv.setText(group.getName());
// 重新產生 CheckBox 時,將存起來的 isChecked 狀態重新設定
CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.chbGroup);
checkBox.setChecked(group.getChecked());
// 點擊 CheckBox 時,將狀態存起來
if (groupPosition == 0) {
checkBox.setOnClickListener(new Group_CheckBox_Click2());
if (group.getChecked()) {
checkBox.setBackgroundResource(R.drawable.check_all);
} else {
checkBox.setBackgroundResource(R.drawable.check_no);
}
} else {
checkBox.setOnClickListener(new Group_CheckBox_Click(groupPosition));
// 檢查 User CheckBox 是否有全部勾選,以控制 Dept CheckBox
int childrenCount = groups.get(groupPosition).getChildrenCount();
boolean childrenAllIsChecked = true;
Log.e("TAG", "SIZE=" + childrenCount);
for (int i = 0; i < childrenCount; i++) {
if (!groups.get(groupPosition).getChildItem(i).getChecked())
childrenAllIsChecked = false;
}
if (childrenAllIsChecked) {
groups.get(groupPosition).setChecked(childrenAllIsChecked);
// checkBox.setChecked(childrenAllIsChecked);
checkBox.setBackgroundResource(R.drawable.check_all);
} else {
groups.get(groupPosition).setChecked(group.getChecked());
// checkBox.setChecked(group.getChecked());
List<SppUser> ll = groups.get(groupPosition).getChildren();
boolean flg = false;
for (int i = 0; i < ll.size(); i++) {
if (ll.get(i).getChecked()) {
flg = true;
break;
}
}
if (flg)
checkBox.setBackgroundResource(R.drawable.check_some);
else
checkBox.setBackgroundResource(R.drawable.check_no);
}
}
return convertView;
}
/** 勾選 Group CheckBox 時,存 Group CheckBox 的狀態,以及改變 SppUser CheckBox 的狀態 */
class Group_CheckBox_Click implements OnClickListener {
private int groupPosition;
Group_CheckBox_Click(int groupPosition) {
this.groupPosition = groupPosition;
}
public void onClick(View v) {
groups.get(groupPosition).toggle();
childs.clear();
// 將 Children 的 isChecked 全面設成跟 Group 一樣
int childrenCount = groups.get(groupPosition).getChildrenCount();
boolean groupIsChecked = groups.get(groupPosition).getChecked();
for (int i = 0; i < childrenCount; i++) {
groups.get(groupPosition).getChildItem(i).setChecked(groupIsChecked);
// if (groupIsChecked) {
// childs.add(groups.get(groupPosition).getChildItem(i));
// } else {
// childs.remove(groups.get(groupPosition).getChildItem(i));
// }
}
boolean allChecked = true;
for (int i = 1; i < groups.size(); i++) {
if (!groups.get(i).getChecked())
allChecked = false;
}
groups.get(0).setChecked(allChecked);
// 注意,一定要通知 ExpandableListView 資料已經改變,ExpandableListView 會重新產生畫面
notifyDataSetChanged();
personsCount();
listener.OnAddUserCountListener(childs.size());
}
}
/** 勾選 Group CheckBox 時,存 Group CheckBox 的狀態,以及改變 SppUser CheckBox 的狀態 */
class Group_CheckBox_Click2 implements OnClickListener {
public void onClick(View v) {
// childs.clear();
// 將 Children 的 isChecked 全面設成跟 Group 一樣
for (int i = 0; i < groups.size(); i++) {
groups.get(i).toggle();
Boolean group0IsCheck = groups.get(0).getChecked();
groups.get(i).setChecked(group0IsCheck);
int childrenCount = groups.get(i).getChildrenCount();
boolean groupIsChecked = groups.get(i).getChecked();
for (int j = 0; j < childrenCount; j++) {
groups.get(i).getChildItem(j).setChecked(groupIsChecked);
// if (groupIsChecked) {
// childs.add(groups.get(i).getChildItem(j));
// } else {
// childs.remove(groups.get(i).getChildItem(j));
// }
}
}
personsCount();
listener.OnAddUserCountListener(childs.size());
// 注意,一定要通知 ExpandableListView 資料已經改變,ExpandableListView 會重新產生畫面
notifyDataSetChanged();
}
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#getChildView(int, int, boolean,
* android.view.View, android.view.ViewGroup)
*/
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
SppUser child = groups.get(groupPosition).getChildItem(childPosition);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.child_layout, null);
}
TextView tv = (TextView) convertView.findViewById(R.id.tvChild);
tv.setText(child.getRolename());
TextView name = (TextView) convertView.findViewById(R.id.tv_name);
name.setText(child.getUsername());
// 重新產生 CheckBox 時,將存起來的 isChecked 狀態重新設定
final RadioButton checkBox = (RadioButton) convertView.findViewById(R.id.chbChild);
checkBox.setChecked(child.getChecked());
// 點擊 CheckBox 時,將狀態存起來
checkBox.setOnClickListener(new Child_CheckBox_Click(groupPosition, childPosition));
return convertView;
}
/** 勾選 SppUser CheckBox 時,存 SppUser CheckBox 的狀態 */
class Child_CheckBox_Click implements OnClickListener {
private int groupPosition;
private int childPosition;
Child_CheckBox_Click(int groupPosition, int childPosition) {
this.groupPosition = groupPosition;
this.childPosition = childPosition;
}
public void onClick(View v) {
handleClick(childPosition, groupPosition);
personsCount();
listener.OnAddUserCountListener(EListAdapter.this.childs.size());
}
}
public void handleClick(int childPosition, int groupPosition) {
groups.get(groupPosition).getChildItem(childPosition).toggle();
boolean flg = groups.get(groupPosition).getChildItem(childPosition).getChecked();
// if (flg) {
// childs.add(groups.get(groupPosition).getChildItem(childPosition));
// } else {
// childs.remove(groups.get(groupPosition).getChildItem(childPosition));
// }
// 檢查 SppUser CheckBox 是否有全部勾選,以控制 Group CheckBox
int childrenCount = groups.get(groupPosition).getChildrenCount();
boolean childrenAllIsChecked = true;
for (int i = 0; i < childrenCount; i++) {
if (!groups.get(groupPosition).getChildItem(i).getChecked())
childrenAllIsChecked = false;
}
groups.get(groupPosition).setChecked(childrenAllIsChecked);
boolean allChecked = true;
for (int i = 1; i < groups.size(); i++) {
if (!groups.get(i).getChecked())
allChecked = false;
}
groups.get(0).setChecked(allChecked);
// 注意,一定要通知 ExpandableListView 資料已經改變,ExpandableListView 會重新產生畫面
notifyDataSetChanged();
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListAdapter#isChildSelectable(int, int)
*/
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
/*
* (non-Javadoc)
*
* @see android.widget.ExpandableListView.OnChildClickListener#onChildClick(
* android .widget.ExpandableListView, android.view.View, int, int, long)
*/
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
handleClick(childPosition, groupPosition);
return true;
}
public ArrayList<SppUser> getSelectedChild() {
return childs;
}
public void personsCount() {
childs.clear();
int count = this.getGroupCount();
for (int i = 1; i < count; i++) {
Group group = groups.get(i);
int childrenCount = group.getChildrenCount();
for (int j = 0; j < childrenCount; j++) {
if (group.getChecked()) {
childs.add(group.getChildItem(j));
} else if (group.getChildItem(j).getChecked()) {
childs.add(group.getChildItem(j));
}
}
}
}
}
/*
* PopAdapter.java
* classes : cn.com.bril.meeting.adapter.PopAdapter
* @author 李小娇
* V 1.0.0
* Create at 2016-10-9 下午2:19:58
*/
package cn.bsl.bxbg.zhiban.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import java.util.List;
import cn.bsl.bxbg.zhiban.R;
/**
* @title: PopAdapter.java
* @package:cn.com.bril.meeting.adapter.PopAdapter
* @description: TODO
* @author 李小娇
* @time:create at 2016-10-9 下午2:19:58
*/
public class PopAdapter extends BaseAdapter {
private static final String TAG = "PopAdapter";
private Context context;
private List<String> list;
public PopAdapter(Context context, List<String> list) {
this.context = context;
this.list = list;
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getCount()
*/
@Override
public int getCount() {
return list.size();
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getItem(int)
*/
@Override
public Object getItem(int position) {
return position;
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getItemId(int)
*/
@Override
public long getItemId(int position) {
return position;
}
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(context).inflate(R.layout.pop_item, null);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.checkbox);
holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tv_name.setText(list.get(position));
return convertView;
}
class ViewHolder {
CheckBox checkBox;
TextView tv_name;
}
}
package cn.bsl.bxbg.zhiban.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.bean.ShiftBean;
/**
* Created by Xinghx on 2018/5/20 0020.
*/
public class ShiftAdapter extends BaseAdapter {
private List<ShiftBean> shiftBeen = new ArrayList<>();
public ShiftAdapter(List<ShiftBean> shiftBeen) {
this.shiftBeen = shiftBeen;
}
@Override
public int getCount() {
return shiftBeen.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_zhiban_info, parent, false);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.nextPeople.setText("下个值班人员:");
viewHolder.zbName.setText(shiftBeen.get(position).getSuccessor());
viewHolder.zbTime.setText(shiftBeen.get(position).getDutyDate());
viewHolder.zbTitle.setText(shiftBeen.get(position).getHandover()+"的值班");
return convertView;
}
static class ViewHolder {
@BindView(R.id.zb_title)
TextView zbTitle;
@BindView(R.id.zb_name)
TextView zbName;
@BindView(R.id.zb_time)
TextView zbTime;
@BindView(R.id.zb_name_title)
TextView nextPeople;
ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
}
......@@ -51,12 +51,13 @@ public class TiaobanInfoAdapter extends BaseAdapter {
} else {
holder = (ViewHolder) convertView.getTag();
}
String applicant = ccShiftses.get(position).getApplicant();
String transferredName = ccShiftses.get(position).getTransferredName()+"";
String transferedClass = ccShiftses.get(position).getTransferredClass()+"";
if (transferedClass.equals(Constant.USER_NAME)) {
if (transferredName.equals(Constant.USER_NAME)) {
holder.tbTitle.setText(transferredName + "的换班申请");
} else if (transferredName.equals(Constant.USER_NAME)){
holder.tbTitle.setText("与" + transferedClass+"的换班申请");
} else if (applicant.equals(Constant.USER_NAME)){
holder.tbTitle.setText("与" + transferredName+"的换班申请");
}
holder.tbName.setText(ccShiftses.get(position).getApplicant());
holder.tbTime.setText(ccShiftses.get(position).getLastUpdateTime());
......
......@@ -13,6 +13,8 @@ import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.bean.DutyPlanDutiesBean;
import static cn.bsl.bxbg.zhiban.R.id.zb_title;
/**
* Created by Xinghx on 2018/3/6 0006.
*/
......@@ -49,14 +51,25 @@ public class ZhibanInfoAdapter extends BaseAdapter {
} else {
holder = (ViewHolder) convertView.getTag();
}
String type = dutyPlanResponses.get(position).getType();
switch (type) {
case "0":
holder.zbTitle.setText("值班(早)");
break;
case "1":
holder.zbTitle.setText("值班(中)");
break;
case "2":
holder.zbTitle.setText("值班(晚)");
break;
}
holder.zbName.setText(dutyPlanResponses.get(position).getLeader());
holder.zbTime.setText(dutyPlanResponses.get(position).getDutyDate());
return convertView;
}
class ViewHolder {
@BindView(R.id.zb_title)
@BindView(zb_title)
TextView zbTitle;
@BindView(R.id.zb_name)
TextView zbName;
......
......@@ -11,16 +11,16 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.bean.DutyPlanDutiesBean;
import cn.bsl.bxbg.zhiban.net.response.CCDuties;
/**
* Created by Xinghx on 2018/3/6 0006.
*/
public class ZhibanTableAdapter extends BaseAdapter {
private List<DutyPlanDutiesBean> testBeen;
private List<CCDuties> testBeen;
public ZhibanTableAdapter(List<DutyPlanDutiesBean> testBeen) {
public ZhibanTableAdapter(List<CCDuties> testBeen) {
this.testBeen = testBeen;
}
......@@ -50,7 +50,7 @@ public class ZhibanTableAdapter extends BaseAdapter {
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.zbTableLeader.setText(testBeen.get(position).getDutyDate() + "\n 带班领导:" +testBeen.get(position).getLeader());
viewHolder.zbTableLeader.setText(testBeen.get(position).getDutyDate() + "\n 带班领导:" +testBeen.get(position).getClassLeaders());
// viewHolder.zbTableLeader.setText("\n2018-01-01" + "\n\n带班领导:" + testBeen.get(position).getLeader() + "\n");
viewHolder.zao.setText(testBeen.get(position).getMorning());
viewHolder.zhong.setText(testBeen.get(position).getNoon());
......
/*
* Dept.java
* classes : cn.com.bril.announcement.entity.Group
* @author 李小娇
* V 1.0.0
* Create at 2016-9-25 下午4:53:26
*/
package cn.bsl.bxbg.zhiban.bean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @title: Dept.java
* @package:cn.com.bril.announcement.entity.Group
* @description: TODO
* @author 李小娇
* @time:create at 2016-9-25 下午4:53:26
*/
public class Dept implements Serializable{
private static final String TAG = "Dept";
private String id;
private String name;
private ArrayList<User> children;
private boolean isChecked;
public Dept(String id, String name) {
this.name = name;
this.id=id;
children = new ArrayList<User>();
this.isChecked = false;
}
public void setChecked(boolean isChecked) {
this.isChecked = isChecked;
}
public void toggle() {
this.isChecked = !this.isChecked;
}
public boolean getChecked() {
return this.isChecked;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public void addChildrenItem(User child) {
children.add(child);
}
public void addChildrenAll(List<User> childs) {
children.addAll(childs);
}
public int getChildrenCount() {
return children.size();
}
public User getChildItem(int index) {
return children.get(index);
}
public ArrayList<User> getChildren() {
return this.children;
}
public void setChildren(ArrayList<User> children) {
this.children = children;}
public void deleteChild(int poi){
children.remove(poi);
}
}
......@@ -14,6 +14,7 @@ public class DutyPlanDutiesBean {
private String evening;
private String leader;
private String dutyDate;
private String type;
public String getPlanId() {
return planId;
......@@ -87,6 +88,14 @@ public class DutyPlanDutiesBean {
this.dutyDate = dutyDate;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "DutyPlanDutiesBean{" +
......
/*
* Group.java
* classes : cn.com.bril.announcement.entity.Group
* @author 李小娇
* V 1.0.0
* Create at 2016-9-25 下午4:53:26
*/
package cn.bsl.bxbg.zhiban.bean;
import java.io.Serializable;
import java.util.ArrayList;
public class Group implements Serializable {
private static final String TAG = "Group";
private String id;
private String dept;
private ArrayList<SppUser> users;
private boolean isChecked;
public Group(String id, String name) {
this.dept = name;
users = new ArrayList<SppUser>();
this.isChecked = false;
}
public void setId(String id) {
this.id = id;
}
public void setChecked(boolean isChecked) {
this.isChecked = isChecked;
}
public void toggle() {
this.isChecked = !this.isChecked;
}
public boolean getChecked() {
return this.isChecked;
}
public String getId() {
return id;
}
public String getName() {
return dept;
}
public void addChildrenItem(SppUser child) {
users.add(child);
}
public int getChildrenCount() {
return users.size();
}
public SppUser getChildItem(int index) {
return users.get(index);
}
public ArrayList<SppUser> getChildren() {
return users;
}
public void setChildren(ArrayList<SppUser> children) {
this.users = children;
}
}
package cn.bsl.bxbg.zhiban.bean;
import java.util.List;
/**
*
* @Title: GroupPeople.java
* @Package cn.bsl.bxbg.oa.ui.meeting.bean
* @Description: 群组人员 返回数据
* @author 郝晓聪
* @date 2016年12月19日 下午1:44:28
*/
public class GroupPeople {
private String titleName;
private List<IdentityUser> identityUser;
public void setTitleName(String titleName) {
this.titleName = titleName;
}
public String getTitleName() {
return this.titleName;
}
public void setIdentityUser(List<IdentityUser> identityUser) {
this.identityUser = identityUser;
}
public List<IdentityUser> getIdentityUser() {
return this.identityUser;
}
}
package cn.bsl.bxbg.zhiban.bean;
public class IdentityUser {
private int id;
private int userid;
private String usename;
private String depatcode;
private String identityId;
private String deParentDeptCode;
private String title;
private String titlename;
private String udrCoMid;
private String identityCode;
private String identitytype;
public String getUsename() {
return usename;
}
public void setUsename(String usename) {
this.usename = usename;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public void setUserid(int userid) {
this.userid = userid;
}
public int getUserid() {
return this.userid;
}
public void setDepatcode(String depatcode) {
this.depatcode = depatcode;
}
public String getDepatcode() {
return this.depatcode;
}
public void setIdentityId(String identityId) {
this.identityId = identityId;
}
public String getIdentityId() {
return this.identityId;
}
public void setDeParentDeptCode(String deParentDeptCode) {
this.deParentDeptCode = deParentDeptCode;
}
public String getDeParentDeptCode() {
return this.deParentDeptCode;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return this.title;
}
public void setTitlename(String titlename) {
this.titlename = titlename;
}
public String getTitlename() {
return this.titlename;
}
public void setUdrCoMid(String udrCoMid) {
this.udrCoMid = udrCoMid;
}
public String getUdrCoMid() {
return this.udrCoMid;
}
public void setIdentityCode(String identityCode) {
this.identityCode = identityCode;
}
public String getIdentityCode() {
return this.identityCode;
}
public void setIdentitytype(String identitytype) {
this.identitytype = identitytype;
}
public String getIdentitytype() {
return this.identitytype;
}
}
package cn.bsl.bxbg.zhiban.bean;
/**
* Created by Xinghx on 2018/5/20 0020.
*/
public class ShiftBean {
/**
* id : b8797ea8367843c1bcf80b6c922b3158
* ccDutyId : 4435208a43554a6aa823759a40fb735b
* handover : 赵睿
* successor : 卜海军
* successorTime :
* dutyContent :
* createTime : 2018-05-20 11:45:58
* lastUpdateTime : 2018-05-20 11:45:58
* remark : 0
* dutyDepartment :
* dutyDate : 2018-05-21
* dutyShift : 1
*/
private String id;
private String ccDutyId;
private String handover;
private String successor;
private String successorTime;
private String dutyContent;
private String createTime;
private String lastUpdateTime;
private String remark;
private String dutyDepartment;
private String dutyDate;
private String dutyShift;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCcDutyId() {
return ccDutyId;
}
public void setCcDutyId(String ccDutyId) {
this.ccDutyId = ccDutyId;
}
public String getHandover() {
return handover;
}
public void setHandover(String handover) {
this.handover = handover;
}
public String getSuccessor() {
return successor;
}
public void setSuccessor(String successor) {
this.successor = successor;
}
public String getSuccessorTime() {
return successorTime;
}
public void setSuccessorTime(String successorTime) {
this.successorTime = successorTime;
}
public String getDutyContent() {
return dutyContent;
}
public void setDutyContent(String dutyContent) {
this.dutyContent = dutyContent;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(String lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getDutyDepartment() {
return dutyDepartment;
}
public void setDutyDepartment(String dutyDepartment) {
this.dutyDepartment = dutyDepartment;
}
public String getDutyDate() {
return dutyDate;
}
public void setDutyDate(String dutyDate) {
this.dutyDate = dutyDate;
}
public String getDutyShift() {
return dutyShift;
}
public void setDutyShift(String dutyShift) {
this.dutyShift = dutyShift;
}
}
/*
* SppUser.java
* classes : cn.com.bril.announcement.entity.Child
* @author 李小娇
* V 1.0.0
* Create at 2016-9-25 下午4:53:36
*/
package cn.bsl.bxbg.zhiban.bean;
import java.io.Serializable;
/**
* @title: SppUser.java
* @package:cn.com.bril.announcement.entity.Child
* @description: TODO
* @author 李小娇
* @time:create at 2016-9-25 下午4:53:36
*/
public class SppUser implements Serializable {
private static final String TAG = "SppUser";
private boolean isChecked;
private int userid;// 用户id
private String loginname; // 接收人登录账号
private String username; // 接受人名
private String rolename; // 角色
private String departname; // 部门
public SppUser(int userid, String rolename, String username) {
this.userid = userid;
this.rolename = rolename;
this.username = username;
this.isChecked = false;
}
public void setChecked(boolean isChecked) {
this.isChecked = isChecked;
}
public void toggle() {
this.isChecked = !this.isChecked;
}
public boolean getChecked() {
return this.isChecked;
}
public boolean isChecked() {
return isChecked;
}
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getRolename() {
return rolename;
}
public void setRolename(String rolename) {
this.rolename = rolename;
}
public String getDepartname() {
return departname;
}
public void setDepartname(String departname) {
this.departname = departname;
}
}
package cn.bsl.bxbg.zhiban.bean;
/**
* Created by Xinghx on 2018/5/18 0018.
*/
public class TimeBean {
/**
* systemDate : 2018-05-18 10:08:34
* systemTime : 1526609314768
*/
private String systemDate;
private long systemTime;
public String getSystemDate() {
return systemDate;
}
public void setSystemDate(String systemDate) {
this.systemDate = systemDate;
}
public long getSystemTime() {
return systemTime;
}
public void setSystemTime(long systemTime) {
this.systemTime = systemTime;
}
}
/*
* User.java
* classes : cn.com.bril.announcement.entity.Child
* @author 李小娇
* V 1.0.0
* Create at 2016-9-25 下午4:53:36
*/
package cn.bsl.bxbg.zhiban.bean;
import java.io.Serializable;
/**
* @title: User.java
* @package:cn.com.bril.announcement.entity.Child
* @description: TODO
* @author 李小娇
* @time:create at 2016-9-25 下午4:53:36
*/
public class User implements Serializable {
private static final String TAG = "User";
private String userid;
private String rolecode;
private String rolename;
private String username;
private boolean isChecked;
private String deptname;
private String deptcode;
private String status;
public User(String userid, String username, String rolecode, String rolename) {
this.userid = userid;
this.rolecode = rolecode;
this.rolename = rolename;
this.username = username;
this.isChecked = false;
}
public void setChecked(boolean isChecked) {
this.isChecked = isChecked;
}
public void toggle() {
this.isChecked = !this.isChecked;
}
public boolean getChecked() {
return this.isChecked;
}
public String getUserid() {
return userid;
}
public String getRolecode() {
return this.rolecode;
}
public void setRolecode(String rolecode) {
this.rolecode = rolecode;
}
public String getRolename() {
return this.rolename;
}
public void setRolename(String rolename) {
this.rolename = rolename;
}
public boolean isChecked() {
return this.isChecked;
}
public void setUserid(String userid) {
this.userid = userid;
}
public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
}
public String getDeptname() {
return this.deptname;
}
public void setDeptname(String deptname) {
this.deptname = deptname;
}
public String getDeptcode() {
return this.deptcode;
}
public void setDeptcode(String deptcode) {
this.deptcode = deptcode;
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.ShiftAdapter;
import cn.bsl.bxbg.zhiban.bean.ShiftBean;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.utils.Constant;
import cn.bsl.bxbg.zhiban.utils.DateUtils;
import cn.bsl.bxbg.zhiban.view.TakeOverDetailsActivity;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Xinghx on 2018/5/20 0020.
*/
public class AlreadyTakeOverFragment extends BaseFragment implements AdapterView.OnItemClickListener{
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
@BindView(R.id.none)
TextView none;
Unbinder unbinder;
private View rootView;
private List<ShiftBean> shiftBeen = new ArrayList<>();
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
initData();
return rootView;
}
private void initData() {
dutyPlanClient.shiftList(DateUtils.getMonth(), Constant.USER_NAME,"handover")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(shiftBeen -> {
this.shiftBeen.clear();
for (int i = 0; i < shiftBeen.size(); i++) {
if (shiftBeen.get(i).getRemark().equals("2")) {
this.shiftBeen.add(shiftBeen.get(i));
}
}
notFinishLv.setAdapter(new ShiftAdapter(this.shiftBeen));
notFinishLv.setOnItemClickListener(this);
},Throwable::printStackTrace);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(), TakeOverDetailsActivity.class);
intent.putExtra("id", shiftBeen.get(position).getId());
intent.putExtra("status", shiftBeen.get(position).getRemark());
intent.putExtra("dutyTime", shiftBeen.get(position).getDutyDate());
intent.putExtra("dutyShift", shiftBeen.get(position).getDutyShift());
intent.putExtra("dutyContent", shiftBeen.get(position).getDutyContent());
startActivityForResult(intent, 0);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
initData();
}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.support.v4.app.Fragment;
/**
* Created by Xinghx on 2018/4/15 0015.
*/
public class BaseFragment extends Fragment {
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.TiaobanInfoAdapter;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsInclude;
import cn.bsl.bxbg.zhiban.view.TiaobanDetailsActivity;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Xinghx on 2018/4/15 0015.
*/
public class TiaoBanFinishFragment extends BaseFragment implements AdapterView.OnItemClickListener{
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
View rootView;
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
@BindView(R.id.none)
TextView none;
Unbinder unbinder;
private List<CCShifts> ccShift;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
initData();
notFinishLv.setOnItemClickListener(this);
return rootView;
}
private void initData() {
dutyPlanClient.shiftFinish().enqueue(new Callback<List<CCShiftsInclude>>() {
@Override
public void onResponse(Call<List<CCShiftsInclude>> call, Response<List<CCShiftsInclude>> response) {
List<CCShiftsInclude> body = response.body();
ccShift = new ArrayList<>();
for (CCShiftsInclude ccShiftsInclude : body) {
CCShiftsInclude.IncludesBean.CcDutyBean cc_duty = ccShiftsInclude.getIncludes().getCc_duty();
if (cc_duty != null) {
CCShifts ccShifts = new CCShifts();
ccShifts.setId(ccShiftsInclude.getSuperior().getId());
ccShifts.setApplicantId(ccShiftsInclude.getSuperior().getApplicantId());
ccShifts.setApplicant(ccShiftsInclude.getSuperior().getApplicant());
ccShifts.setTransferredName(ccShiftsInclude.getSuperior().getTransferredName());
ccShifts.setTransferredClass(ccShiftsInclude.getSuperior().getTransferredClass());
ccShifts.setShiftTime(ccShiftsInclude.getSuperior().getShiftTime());
ccShifts.setApplicantDutyId(ccShiftsInclude.getSuperior().getApplicantDutyId());
ccShifts.setLastUpdateTime(ccShiftsInclude.getSuperior().getLastUpdateTime());
ccShift.add(ccShifts);
}
}
if (ccShift != null && ccShift.size() > 0) {
notFinishLv.setAdapter(new TiaobanInfoAdapter(ccShift));
}
}
@Override
public void onFailure(Call<List<CCShiftsInclude>> call, Throwable t) {
t.printStackTrace();
}
});
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(),TiaobanDetailsActivity.class);
intent.putExtra("id", ccShift.get(position).getId());
startActivity(intent);
}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.TiaobanInfoAdapter;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsInclude;
import cn.bsl.bxbg.zhiban.view.TiaobanDetailsActivity;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Xinghx on 2018/4/15
*/
public class TiaoBanNotFinishFragment extends BaseFragment implements AdapterView.OnItemClickListener{
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
View rootView;
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
@BindView(R.id.none)
TextView none;
Unbinder unbinder;
private List<CCShifts> ccShift;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
initData();
notFinishLv.setOnItemClickListener(this);
return rootView;
}
private void initData() {
dutyPlanClient.shiftInclNotFinish().enqueue(new Callback<List<CCShiftsInclude>>() {
@Override
public void onResponse(Call<List<CCShiftsInclude>> call, Response<List<CCShiftsInclude>> response) {
List<CCShiftsInclude> body = response.body();
ccShift = new ArrayList<>();
for (CCShiftsInclude ccShiftsInclude : body) {
CCShiftsInclude.IncludesBean.CcDutyBean cc_duty = ccShiftsInclude.getIncludes().getCc_duty();
if (cc_duty != null) {
CCShifts ccShifts = new CCShifts();
ccShifts.setId(ccShiftsInclude.getSuperior().getId());
ccShifts.setApplicantId(ccShiftsInclude.getSuperior().getApplicantId());
ccShifts.setApplicant(ccShiftsInclude.getSuperior().getApplicant());
ccShifts.setTransferredName(ccShiftsInclude.getSuperior().getTransferredName());
ccShifts.setTransferredClass(ccShiftsInclude.getSuperior().getTransferredClass());
ccShifts.setShiftTime(ccShiftsInclude.getSuperior().getShiftTime());
ccShifts.setApplicantDutyId(ccShiftsInclude.getSuperior().getApplicantDutyId());
ccShifts.setLastUpdateTime(ccShiftsInclude.getSuperior().getLastUpdateTime());
ccShift.add(ccShifts);
}
}
// ccShift = response.body();
if (ccShift != null && ccShift.size() > 0) {
notFinishLv.setAdapter(new TiaobanInfoAdapter(ccShift));
}
}
@Override
public void onFailure(Call<List<CCShiftsInclude>> call, Throwable t) {
t.printStackTrace();
}
});
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(),TiaobanDetailsActivity.class);
intent.putExtra("id", ccShift.get(position).getId());
startActivity(intent);
}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.TiaobanInfoAdapter;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsInclude;
import cn.bsl.bxbg.zhiban.view.TiaobanDetailsActivity;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Xinghx on 2018/4/15 0015.
*/
public class WaitMeFinishFragment extends BaseFragment implements AdapterView.OnItemClickListener {
private static final String TAG = "WaitMeFinishFragment";
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
Unbinder unbinder;
@BindView(R.id.none)
TextView none;
private View rootView;
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
private List<CCShifts> ccShiftses;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
initData();
notFinishLv.setOnItemClickListener(this);
return rootView;
}
private void initData() {
dutyPlanClient.shiftWaitMe("1").enqueue(new Callback<List<CCShiftsInclude>>() {
@Override
public void onResponse(Call<List<CCShiftsInclude>> call, Response<List<CCShiftsInclude>> response) {
List<CCShiftsInclude> body = response.body();
ccShiftses = new ArrayList<>();
for (CCShiftsInclude ccShiftsInclude : body) {
CCShiftsInclude.IncludesBean.CcDutyBean cc_duty = ccShiftsInclude.getIncludes().getCc_duty();
if (cc_duty != null) {
CCShifts ccShifts = new CCShifts();
ccShifts.setId(ccShiftsInclude.getSuperior().getId());
ccShifts.setApplicantId(ccShiftsInclude.getSuperior().getApplicantId());
ccShifts.setApplicant(ccShiftsInclude.getSuperior().getApplicant());
ccShifts.setTransferredName(ccShiftsInclude.getSuperior().getTransferredName());
ccShifts.setTransferredClass(ccShiftsInclude.getSuperior().getTransferredClass());
ccShifts.setShiftTime(ccShiftsInclude.getSuperior().getShiftTime());
ccShifts.setApplicantDutyId(ccShiftsInclude.getSuperior().getApplicantDutyId());
ccShifts.setLastUpdateTime(ccShiftsInclude.getSuperior().getLastUpdateTime());
ccShiftses.add(ccShifts);
}
}
if (ccShiftses != null && ccShiftses.size() > 0) {
TiaobanInfoAdapter adapter = new TiaobanInfoAdapter(ccShiftses);
notFinishLv.setAdapter(adapter);
} else {
notFinishLv.setVisibility(View.GONE);
none.setVisibility(View.VISIBLE);
}
}
@Override
public void onFailure(Call<List<CCShiftsInclude>> call, Throwable t) {
t.printStackTrace();
}
});
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(), TiaobanDetailsActivity.class);
intent.putExtra("id", ccShiftses.get(position).getId());
startActivity(intent);
}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.TiaobanInfoAdapter;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsInclude;
import cn.bsl.bxbg.zhiban.view.TiaobanDetailsActivity;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by Xinghx on 2018/4/15 0015.
*/
public class WaitMeNotFinishFragment extends BaseFragment implements AdapterView.OnItemClickListener{
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
Unbinder unbinder;
private View rootView;
private List<CCShifts> ccShiftses;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
notFinishLv.setOnItemClickListener(this);
initData();
return rootView;
}
private void initData() {
dutyPlanClient.shiftWaitMe("0").enqueue(new Callback<List<CCShiftsInclude>>() {
@Override
public void onResponse(Call<List<CCShiftsInclude>> call, Response<List<CCShiftsInclude>> response) {
List<CCShiftsInclude> body = response.body();
ccShiftses = new ArrayList<>();
for (CCShiftsInclude ccShiftsInclude : body) {
CCShiftsInclude.IncludesBean.CcDutyBean cc_duty = ccShiftsInclude.getIncludes().getCc_duty();
if (cc_duty != null) {
CCShifts ccShifts = new CCShifts();
ccShifts.setId(ccShiftsInclude.getSuperior().getId());
ccShifts.setApplicantId(ccShiftsInclude.getSuperior().getApplicantId());
ccShifts.setApplicant(ccShiftsInclude.getSuperior().getApplicant());
ccShifts.setTransferredName(ccShiftsInclude.getSuperior().getTransferredName());
ccShifts.setTransferredClass(ccShiftsInclude.getSuperior().getTransferredClass());
ccShifts.setShiftTime(ccShiftsInclude.getSuperior().getShiftTime());
ccShifts.setApplicantDutyId(ccShiftsInclude.getSuperior().getApplicantDutyId());
ccShifts.setLastUpdateTime(ccShiftsInclude.getSuperior().getLastUpdateTime());
ccShiftses.add(ccShifts);
}
}
if (ccShiftses != null || ccShiftses.size() > 0) {
TiaobanInfoAdapter adapter = new TiaobanInfoAdapter(ccShiftses);
notFinishLv.setAdapter(adapter);
}
}
@Override
public void onFailure(Call<List<CCShiftsInclude>> call, Throwable t) {
t.printStackTrace();
}
});
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(),TiaobanDetailsActivity.class);
intent.putExtra("id", ccShiftses.get(position).getId());
startActivity(intent);
}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.ShiftAdapter;
import cn.bsl.bxbg.zhiban.bean.ShiftBean;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.utils.Constant;
import cn.bsl.bxbg.zhiban.utils.DateUtils;
import cn.bsl.bxbg.zhiban.view.TakeOverDetailsActivity;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Xinghx on 2018/5/20 0020.
*/
public class WaitShiftFragment extends BaseFragment implements AdapterView.OnItemClickListener{
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
@BindView(R.id.none)
TextView none;
private Unbinder unbinder;
private View rootView;
private List<ShiftBean> shiftBeen = new ArrayList<>();
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
initData();
return rootView;
}
private void initData() {
dutyPlanClient.shiftList(DateUtils.getMonth(), Constant.USER_NAME,"handover")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(shiftBeen -> {
this.shiftBeen.clear();
for (int i = 0; i < shiftBeen.size(); i++) {
if (shiftBeen.get(i).getRemark().equals("1")) {
this.shiftBeen.add(shiftBeen.get(i));
}
}
notFinishLv.setAdapter(new ShiftAdapter(this.shiftBeen));
notFinishLv.setOnItemClickListener(this);
},Throwable::printStackTrace);
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(), TakeOverDetailsActivity.class);
intent.putExtra("id", shiftBeen.get(position).getId());
intent.putExtra("status", shiftBeen.get(position).getRemark());
intent.putExtra("dutyTime", shiftBeen.get(position).getDutyDate());
intent.putExtra("dutyShift", shiftBeen.get(position).getDutyShift());
intent.putExtra("dutyContent", shiftBeen.get(position).getDutyContent());
startActivityForResult(intent, 0);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
initData();
}
}
package cn.bsl.bxbg.zhiban.fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.ShiftAdapter;
import cn.bsl.bxbg.zhiban.bean.ShiftBean;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.utils.Constant;
import cn.bsl.bxbg.zhiban.utils.DateUtils;
import cn.bsl.bxbg.zhiban.view.TakeOverDetailsActivity;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Xinghx on 2018/5/20 0020.
*/
public class WaitTakeOverFragment extends BaseFragment implements AdapterView.OnItemClickListener{
@BindView(R.id.not_finish_lv)
ListView notFinishLv;
@BindView(R.id.none)
TextView none;
Unbinder unbinder;
private View rootView;
private List<ShiftBean> shiftBeen = new ArrayList<>();
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.waitme_fragment, container, false);
unbinder = ButterKnife.bind(this, rootView);
initData();
return rootView;
}
private void initData() {
dutyPlanClient.shiftList(DateUtils.getMonth(), Constant.USER_NAME,"successor")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(shiftBeen -> {
this.shiftBeen.clear();
for (int i = 0; i < shiftBeen.size(); i++) {
if (shiftBeen.get(i).getRemark().equals("0")) {
this.shiftBeen.add(shiftBeen.get(i));
}
}
notFinishLv.setAdapter(new ShiftAdapter(this.shiftBeen));
notFinishLv.setOnItemClickListener(this);
},Throwable::printStackTrace);
}
@Override
public void onDestroyView() {
super.onDestroyView();
unbinder.unbind();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(getActivity(), TakeOverDetailsActivity.class);
intent.putExtra("id", shiftBeen.get(position).getId());
intent.putExtra("status", shiftBeen.get(position).getRemark());
intent.putExtra("dutyTime", shiftBeen.get(position).getDutyDate());
intent.putExtra("dutyShift", shiftBeen.get(position).getDutyShift());
intent.putExtra("dutyContent", shiftBeen.get(position).getDutyContent());
startActivityForResult(intent, 0);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
initData();
}
}
package cn.bsl.bxbg.zhiban.listener;
public interface OnAddUserCountListener {
public void OnAddUserCountListener(int num);
}
......@@ -2,9 +2,12 @@ package cn.bsl.bxbg.zhiban.net.api;
import java.util.List;
import cn.bsl.bxbg.zhiban.bean.ShiftBean;
import cn.bsl.bxbg.zhiban.bean.TimeBean;
import cn.bsl.bxbg.zhiban.net.response.CCDuties;
import cn.bsl.bxbg.zhiban.net.response.CCDutiesEdit;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsInclude;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsUni;
import cn.bsl.bxbg.zhiban.net.response.DutiesTbResponse;
import cn.bsl.bxbg.zhiban.net.response.DutyPlanResponse;
......@@ -33,16 +36,23 @@ public interface DutyAPI {
@GET("cc_duties")
Observable<List<CCDuties>> dutiesRecord(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("sortItem") String filters);
@Query("sortItem") String sortItem,
@Query("filters") String filters);
@GET("cc_duties/{id}")
Observable<CCDuties> dutiesById(@Header("X-Auth-Token") String header,
@Path("id") String id);
@Path("id") String id);
@FormUrlEncoded
@POST("roleManagerController.do")
Call<ResponseBody> people(@Field("method") String method, @Field("userId") String userId);
@FormUrlEncoded
@POST("return_department_people")
Call<ResponseBody> getAllpeople(@Field("userId") String userId);
@FormUrlEncoded
@POST("cc_shifts/new")
Observable<TiaobanBean> tbRecord(@Header("X-Auth-Token") String header,
......@@ -54,7 +64,8 @@ public interface DutyAPI {
@Field("reason") String reason,
@Field("shiftTime") String shiftTime,
@Field("status") String status,
@Field("transferredClassTime") String transferredClassTime);
@Field("transferredClassTime") String transferredClassTime,
@Field("applicantPosition") String applicatPosition);
@FormUrlEncoded
@POST("cc_duties/{id}/edit")
......@@ -65,39 +76,103 @@ public interface DutyAPI {
@FormUrlEncoded
@POST("cc_duties/{id}/edit")
Observable<CCDutiesEdit> editNoon(@Header("X-Auth-Token") String header,
@Path("id") String cc_duty_id,
@Field("noon") String noon);
@Path("id") String cc_duty_id,
@Field("noon") String noon);
@FormUrlEncoded
@POST("cc_duties/{id}/edit")
Observable<CCDutiesEdit> editNight(@Header("X-Auth-Token") String header,
@Path("id") String cc_duty_id,
@Field("night") String night);
@Field("night") String night);
@FormUrlEncoded
@POST("cc_duties/{id}/edit")
Observable<CCDutiesEdit> editLeader(@Header("X-Auth-Token") String header,
@Path("id") String cc_duty_id,
@Field("classLeaders") String leader);
@GET("cc_duties")
Observable<List<DutiesTbResponse>> dutiesTb(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("refers") String refers);
@Query("pageSize") String pageSize,
@Query("refers") String refers);
@GET("cc_shifts")
Observable<List<DutiesTbResponse>> dutiesTbDetails(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("filters") String filters,
@Query("includes") String refers);
@Query("pageSize") String pageSize,
@Query("filters") String filters,
@Query("includes") String refers);
@GET("cc_shifts")
Call<List<CCShifts>> ccShifts(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("filters") String filters);
@Query("filters") String filters,
@Query("sortItem") String sortItem,
@Query("sortOrder") String sortOrder,
@Query("includes") String includes);
@GET("cc_shifts")
Call<List<CCShiftsInclude>> ccShiftsicl(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("filters") String filters,
@Query("sortItem") String sortItem,
@Query("sortOrder") String sortOrder,
@Query("includes") String includes);
@GET("cc_shifts")
Observable<List<CCShiftsUni>> ccShiftsUnique(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("filters") String filters,
@Query("includes") String includes);
@Query("pageSize") String pageSize,
@Query("filters") String filters,
@Query("includes") String includes);
@FormUrlEncoded
@POST("cc_shifts/{cc_shift_id}/edit")
Observable<CCShifts> ccShiftsEdit(@Header("X-Auth-Token") String header,
@Path("cc_shift_id") String id,
@Field("status") String status);
@Path("cc_shift_id") String id,
@Field("status") String status);
@GET("obtain_time")
Call<TimeBean> timeBean();
@GET("cc_duties")
Observable<List<CCDuties>> findPeopleByTime(@Query("filters")String filters);
// 交接班
// 待交班 状态为1 , 点击交班后状态修改为0,详情中 如果状态为0 那么就提示 等待接班人接班。
// 接班人接班后 状态改为2,已交班完成 并且交班日期生成
@FormUrlEncoded
@POST("cc_shift_shifts/new")
Observable<ShiftBean> shiftNew(@Header("X-Auth-Token") String token,
@Field("ccDutyId") String dutyId,
@Field("handover") String handover,
@Field("successor") String successor,
@Field("remark") String type,
@Field("dutyDepartment") String dutyDepartment,
@Field("dutyDate") String dutyDate,
@Field("dutyShift") String duryShift);
// 待接班
@GET("cc_shift_shifts")
Observable<List<ShiftBean>> shiftList(@Query("pageNo") String pageNo,
@Query("pageSize") String pageSize,
@Query("filters") String filters,
@Query("sortItem") String sortItem,
@Query("sortOrder") String sortOrder);
// 修改状态
@FormUrlEncoded
@POST("cc_shift_shifts/{id}/edit")
Observable<ShiftBean> editShiftStatus(@Header("X-Auth-Token") String token,
@Path("id") String ccShiftID,
@Field("remark") String status);
// 修改值班内容。
@FormUrlEncoded
@POST("cc_shift_shifts/{id}/edit")
Observable<ShiftBean> editShiftRecord(@Header("X-Auth-Token") String token,
@Path("id") String ccShiftID,
@Field("dutyContent") String dutyContent);
}
......@@ -15,7 +15,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class AllPeopleClient extends BaseClient {
DutyAPI dutyAPI = new Retrofit.Builder()
.baseUrl(Constant.BASE_URL)
.baseUrl(Constant.HOST)
.client(getClient())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
......@@ -25,4 +25,9 @@ public class AllPeopleClient extends BaseClient {
public Call<ResponseBody> stringCall() {
return dutyAPI.people("searchDeptTree","11");
}
public Call<ResponseBody> getAllUser() {
return dutyAPI.getAllpeople(Constant.USER_ID+"");
}
}
......@@ -2,15 +2,19 @@ package cn.bsl.bxbg.zhiban.net.client;
import java.util.List;
import cn.bsl.bxbg.zhiban.bean.ShiftBean;
import cn.bsl.bxbg.zhiban.bean.TimeBean;
import cn.bsl.bxbg.zhiban.net.api.DutyAPI;
import cn.bsl.bxbg.zhiban.net.response.CCDuties;
import cn.bsl.bxbg.zhiban.net.response.CCDutiesEdit;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsInclude;
import cn.bsl.bxbg.zhiban.net.response.CCShiftsUni;
import cn.bsl.bxbg.zhiban.net.response.DutiesTbResponse;
import cn.bsl.bxbg.zhiban.net.response.DutyPlanResponse;
import cn.bsl.bxbg.zhiban.net.response.TiaobanBean;
import cn.bsl.bxbg.zhiban.utils.Constant;
import cn.bsl.bxbg.zhiban.utils.DateUtils;
import io.reactivex.Observable;
import retrofit2.Call;
import retrofit2.Retrofit;
......@@ -35,7 +39,7 @@ public class DutyPlanClient extends BaseClient {
}
public Observable<List<CCDuties>> dutiesRecord() {
return dutyAPI.dutiesRecord("1", "100","duty_date");
return dutyAPI.dutiesRecord("1", "100","duty_date","{'cc_duty':{'duty_date':{like:'%"+ DateUtils.getMonth()+"%'}}}");
}
public Observable<CCDuties> dutiesById(String id) {
......@@ -44,21 +48,25 @@ public class DutyPlanClient extends BaseClient {
// 调班申请默认为0 , 1为同意调班 2为不同意调班 // 手机端调班人和申请人为同一人
public Observable<TiaobanBean> tiaobanBean(String transferredName,String id,String reason,String dutyTime,String shift_timeStatus) {
return dutyAPI.tbRecord(Constant.USER_ID,Constant.USER_ID,Constant.USER_NAME,
Constant.USER_NAME,transferredName,id,reason,dutyTime,"0",shift_timeStatus);
public Observable<TiaobanBean> tiaobanBean(String transferredClass,String transferredName,String id,String reason,String dutyTime,String shift_timeStatus,String departMent) {
return dutyAPI.tbRecord(Constant.USER_ID+"",Constant.USER_ID+"",Constant.USER_NAME,
transferredName,transferredClass,id,reason,dutyTime,"0",shift_timeStatus,departMent);
}
public Observable<CCDutiesEdit> editMorning(String cc_id,String morning) {
return dutyAPI.editMorning(Constant.USER_ID, cc_id, morning);
return dutyAPI.editMorning(Constant.USER_ID+"", cc_id, morning);
}
public Observable<CCDutiesEdit> editNoon(String cc_id,String noon) {
return dutyAPI.editNoon(Constant.USER_ID, cc_id, noon);
return dutyAPI.editNoon(Constant.USER_ID+"", cc_id, noon);
}
public Observable<CCDutiesEdit> editNight(String cc_id,String night) {
return dutyAPI.editNight(Constant.USER_ID, cc_id, night);
return dutyAPI.editNight(Constant.USER_ID+"", cc_id, night);
}
public Observable<CCDutiesEdit> editLeader(String cc_id,String leader) {
return dutyAPI.editLeader(Constant.USER_ID+"", cc_id, leader);
}
public Observable<List<DutiesTbResponse>> dutiesTb() {
......@@ -70,8 +78,32 @@ public class DutyPlanClient extends BaseClient {
}
public Call<List<CCShifts>> shiftsRecord() {
return dutyAPI.ccShifts("1","1000","{'cc_shift':{'applicantTransferredNameequalTo':{'fieldsValuesOr':{'fields':['transferred_class','transferred_name'],'values':['"+Constant.USER_NAME+"']}}}}");
return dutyAPI.ccShifts("1","1000","{'cc_shift':{'applicantTransferredNameequalTo':{'fieldsValuesOr':{'fields':['transferred_class','transferred_name'],'values':['"+Constant.USER_NAME+"']}}}}","last_update_time","desc",
"{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Call<List<CCShifts>> shiftRecordFinish() {
return dutyAPI.ccShifts("1","1000","{'cc_shift': {'applicant': {'equalTo': '"+Constant.USER_NAME+"'},'status': {'notEqualTo': '0'}}}","last_update_time","desc","{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Call<List<CCShiftsInclude>> shiftFinish() {
return dutyAPI.ccShiftsicl("1","1000","{'cc_shift': {'applicant': {'equalTo': '"+Constant.USER_NAME+"'},'status': {'notEqualTo': '0'}}}","last_update_time","desc","{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Call<List<CCShifts>> shiftRecordNotFinish() {
return dutyAPI.ccShifts("1","1000","{'cc_shift': {'applicant': {'equalTo': '"+Constant.USER_NAME+"'},'status': {'equalTo': '0'}}}","last_update_time","desc","{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Call<List<CCShiftsInclude>> shiftInclNotFinish() {
return dutyAPI.ccShiftsicl("1","1000","{'cc_shift': {'applicant': {'equalTo': '"+Constant.USER_NAME+"'},'status': {'equalTo': '0'}}}","last_update_time","desc","{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Call<List<CCShiftsInclude>> shiftWaitMe(String status) {
return dutyAPI.ccShiftsicl("1","1000","{'cc_shift': {'transferred_name': {'equalTo': '"+Constant.USER_NAME+"'},'status': {'equalTo': '"+status+"'}}}","last_update_time","desc","{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Call<List<CCShifts>> shiftWaitMe() {
return dutyAPI.ccShifts("1","1000","{'cc_shift': {'transferred_name': {'equalTo': '"+Constant.USER_NAME+"'},'status': {'notEqualTo': 'status'}}}","last_update_time","desc","{'cc_duty':{'includes':['applicant_duty_id']}}");
}
public Observable<List<CCShiftsUni>> ccshiftUni(String id) {
......@@ -80,7 +112,37 @@ public class DutyPlanClient extends BaseClient {
}
public Observable<CCShifts> ccShiftsEdit(String id, String status) {
return dutyAPI.ccShiftsEdit(Constant.USER_ID, id, status);
return dutyAPI.ccShiftsEdit(Constant.USER_ID+"", id, status);
}
public Call<TimeBean> timeBean() {
return dutyAPI.timeBean();
}
// 以下为交接班操作
public Observable<ShiftBean> shiftNew(String ccId,String successor,String dutyDepartment,
String dutyDate,String dutyShift) {
return dutyAPI.shiftNew(Constant.USER_ID + "", ccId,
Constant.USER_NAME, successor, "1", dutyDepartment, dutyDate, dutyShift);
}
public Observable<List<CCDuties>> findPeopleByTime(String date) {
return dutyAPI.findPeopleByTime("{'cc_duty':{'duty_date':{'equalTo':'"+date+"'}}}");
}
// column 代表的是要查哪个字段
public Observable<List<ShiftBean>> shiftList(String date,String name,String column) {
return dutyAPI.shiftList("1","1000","{'cc_shift_shift':{'duty_date':{'like':'%"+date+"%'},'"+column+"':{'equalTo':'"+name+"'}}}","create_time","desc");
}
public Observable<ShiftBean> editShiftRecord(String id,String content) {
return dutyAPI.editShiftRecord(Constant.USER_ID + "", id, content);
}
public Observable<ShiftBean> editShiftStatus(String id,String status) {
return dutyAPI.editShiftStatus(Constant.USER_ID+"",id,status);
}
}
......@@ -42,6 +42,8 @@ public class CCShifts {
private Object leaderId;
private Object applicantPosition;
public String getId() {
return id;
}
......
package cn.bsl.bxbg.zhiban.net.response;
/**
* Created by Xinghx on 2018/5/23 0023.
*/
public class CCShiftsInclude {
/**
* superior : {"id":"f79e081f00ad451db5e05f7ef591ce4f","applicantId":"716","applicant":"赵睿","transferredName":"冯伟","transferredClass":"717","shiftTime":"2018-05-26","applicantDutyId":"85002627dc34421cb4355bfcfc20af5d","transferredClassTime":"0","transferredClassDutyId":"","status":"0","reason":"测试版","applicationTime":"","createTime":"2018-05-21 18:11:30","lastUpdateTime":"2018-05-21 18:11:30","leaderId":"","applicantPosition":"","approvalResult":"","dutyDepartment":""}
* includes : {"cc_duty":{"id":"85002627dc34421cb4355bfcfc20af5d","classLeadersId":"720","classLeaders":"张华","department":"市-信息网络管理中心","postLeaders":"党组书记、检察长","morning":"赵睿,卜海军","noon":"赵睿,李健骅","evening":"周泽楷,张慧军","watchPeople":"","type":"","dutyDate":"2018-05-26","endTime":"","startTime":"","createTime":"2018-05-21 16:30:38","lastUpdateTime":"2018-05-23 15:34:20","onDutyPlanId":"","dutyStage":"","postDuty":"","remark":"五月26号","numberDays":"","holiday":"","holidayName":""}}
* refers : {}
* relates : {}
*/
private SuperiorBean superior;
private IncludesBean includes;
private RefersBean refers;
private RelatesBean relates;
public SuperiorBean getSuperior() {
return superior;
}
public void setSuperior(SuperiorBean superior) {
this.superior = superior;
}
public IncludesBean getIncludes() {
return includes;
}
public void setIncludes(IncludesBean includes) {
this.includes = includes;
}
public RefersBean getRefers() {
return refers;
}
public void setRefers(RefersBean refers) {
this.refers = refers;
}
public RelatesBean getRelates() {
return relates;
}
public void setRelates(RelatesBean relates) {
this.relates = relates;
}
public static class SuperiorBean {
/**
* id : f79e081f00ad451db5e05f7ef591ce4f
* applicantId : 716
* applicant : 赵睿
* transferredName : 冯伟
* transferredClass : 717
* shiftTime : 2018-05-26
* applicantDutyId : 85002627dc34421cb4355bfcfc20af5d
* transferredClassTime : 0
* transferredClassDutyId :
* status : 0
* reason : 测试版
* applicationTime :
* createTime : 2018-05-21 18:11:30
* lastUpdateTime : 2018-05-21 18:11:30
* leaderId :
* applicantPosition :
* approvalResult :
* dutyDepartment :
*/
private String id;
private String applicantId;
private String applicant;
private String transferredName;
private String transferredClass;
private String shiftTime;
private String applicantDutyId;
private String transferredClassTime;
private String transferredClassDutyId;
private String status;
private String reason;
private String applicationTime;
private String createTime;
private String lastUpdateTime;
private String leaderId;
private String applicantPosition;
private String approvalResult;
private String dutyDepartment;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getApplicantId() {
return applicantId;
}
public void setApplicantId(String applicantId) {
this.applicantId = applicantId;
}
public String getApplicant() {
return applicant;
}
public void setApplicant(String applicant) {
this.applicant = applicant;
}
public String getTransferredName() {
return transferredName;
}
public void setTransferredName(String transferredName) {
this.transferredName = transferredName;
}
public String getTransferredClass() {
return transferredClass;
}
public void setTransferredClass(String transferredClass) {
this.transferredClass = transferredClass;
}
public String getShiftTime() {
return shiftTime;
}
public void setShiftTime(String shiftTime) {
this.shiftTime = shiftTime;
}
public String getApplicantDutyId() {
return applicantDutyId;
}
public void setApplicantDutyId(String applicantDutyId) {
this.applicantDutyId = applicantDutyId;
}
public String getTransferredClassTime() {
return transferredClassTime;
}
public void setTransferredClassTime(String transferredClassTime) {
this.transferredClassTime = transferredClassTime;
}
public String getTransferredClassDutyId() {
return transferredClassDutyId;
}
public void setTransferredClassDutyId(String transferredClassDutyId) {
this.transferredClassDutyId = transferredClassDutyId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getApplicationTime() {
return applicationTime;
}
public void setApplicationTime(String applicationTime) {
this.applicationTime = applicationTime;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(String lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getLeaderId() {
return leaderId;
}
public void setLeaderId(String leaderId) {
this.leaderId = leaderId;
}
public String getApplicantPosition() {
return applicantPosition;
}
public void setApplicantPosition(String applicantPosition) {
this.applicantPosition = applicantPosition;
}
public String getApprovalResult() {
return approvalResult;
}
public void setApprovalResult(String approvalResult) {
this.approvalResult = approvalResult;
}
public String getDutyDepartment() {
return dutyDepartment;
}
public void setDutyDepartment(String dutyDepartment) {
this.dutyDepartment = dutyDepartment;
}
}
public static class IncludesBean {
/**
* cc_duty : {"id":"85002627dc34421cb4355bfcfc20af5d","classLeadersId":"720","classLeaders":"张华","department":"市-信息网络管理中心","postLeaders":"党组书记、检察长","morning":"赵睿,卜海军","noon":"赵睿,李健骅","evening":"周泽楷,张慧军","watchPeople":"","type":"","dutyDate":"2018-05-26","endTime":"","startTime":"","createTime":"2018-05-21 16:30:38","lastUpdateTime":"2018-05-23 15:34:20","onDutyPlanId":"","dutyStage":"","postDuty":"","remark":"五月26号","numberDays":"","holiday":"","holidayName":""}
*/
private CcDutyBean cc_duty;
public CcDutyBean getCc_duty() {
return cc_duty;
}
public void setCc_duty(CcDutyBean cc_duty) {
this.cc_duty = cc_duty;
}
public static class CcDutyBean {
/**
* id : 85002627dc34421cb4355bfcfc20af5d
* classLeadersId : 720
* classLeaders : 张华
* department : 市-信息网络管理中心
* postLeaders : 党组书记、检察长
* morning : 赵睿,卜海军
* noon : 赵睿,李健骅
* evening : 周泽楷,张慧军
* watchPeople :
* type :
* dutyDate : 2018-05-26
* endTime :
* startTime :
* createTime : 2018-05-21 16:30:38
* lastUpdateTime : 2018-05-23 15:34:20
* onDutyPlanId :
* dutyStage :
* postDuty :
* remark : 五月26号
* numberDays :
* holiday :
* holidayName :
*/
private String id;
private String classLeadersId;
private String classLeaders;
private String department;
private String postLeaders;
private String morning;
private String noon;
private String evening;
private String watchPeople;
private String type;
private String dutyDate;
private String endTime;
private String startTime;
private String createTime;
private String lastUpdateTime;
private String onDutyPlanId;
private String dutyStage;
private String postDuty;
private String remark;
private String numberDays;
private String holiday;
private String holidayName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getClassLeadersId() {
return classLeadersId;
}
public void setClassLeadersId(String classLeadersId) {
this.classLeadersId = classLeadersId;
}
public String getClassLeaders() {
return classLeaders;
}
public void setClassLeaders(String classLeaders) {
this.classLeaders = classLeaders;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getPostLeaders() {
return postLeaders;
}
public void setPostLeaders(String postLeaders) {
this.postLeaders = postLeaders;
}
public String getMorning() {
return morning;
}
public void setMorning(String morning) {
this.morning = morning;
}
public String getNoon() {
return noon;
}
public void setNoon(String noon) {
this.noon = noon;
}
public String getEvening() {
return evening;
}
public void setEvening(String evening) {
this.evening = evening;
}
public String getWatchPeople() {
return watchPeople;
}
public void setWatchPeople(String watchPeople) {
this.watchPeople = watchPeople;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDutyDate() {
return dutyDate;
}
public void setDutyDate(String dutyDate) {
this.dutyDate = dutyDate;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(String lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getOnDutyPlanId() {
return onDutyPlanId;
}
public void setOnDutyPlanId(String onDutyPlanId) {
this.onDutyPlanId = onDutyPlanId;
}
public String getDutyStage() {
return dutyStage;
}
public void setDutyStage(String dutyStage) {
this.dutyStage = dutyStage;
}
public String getPostDuty() {
return postDuty;
}
public void setPostDuty(String postDuty) {
this.postDuty = postDuty;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getNumberDays() {
return numberDays;
}
public void setNumberDays(String numberDays) {
this.numberDays = numberDays;
}
public String getHoliday() {
return holiday;
}
public void setHoliday(String holiday) {
this.holiday = holiday;
}
public String getHolidayName() {
return holidayName;
}
public void setHolidayName(String holidayName) {
this.holidayName = holidayName;
}
}
}
public static class RefersBean {
}
public static class RelatesBean {
}
}
......@@ -4,11 +4,12 @@ package cn.bsl.bxbg.zhiban.utils;
* Created by Xinghx on 2018/3/14 0014.
*/
public interface Constant {
String HOST = "http://zjk.haomo-studio.com/zhangjiakouOA/";
String USER_ID = "11";
String USER_NAME = "科员";
String BASE_URL="http://haomo-tech.com:8077/hbOA/";
// 获取全部人员
String URL_GET_ALL_PEOPLE1 = BASE_URL + "roleManagerController.do?method=searchDeptTree";
public class Constant {
// public static String HOST = "http://zjk.haomo-tech.com/zhangjiakouOA/";
public static String HOST = "http://143.19.128.79/api/";
public static int USER_ID = 0;
public static String USER_NAME = "";
public static String BASE_URL="http://haomo-tech.com:8077/hbOA/";
public static String systemDate = "";
public static long systemTime = 0L;
}
package cn.bsl.bxbg.zhiban.utils;
import android.util.Log;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by Xinghx on 2018/5/19 0019.
*/
public class DateUtils {
public static Calendar getInputCalendar(String date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
try {
Date parse = sdf.parse(date);
calendar.setTime(parse);
} catch (ParseException e) {
e.printStackTrace();
}
return calendar;
}
public static String getMonth() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
Calendar calendar = Calendar.getInstance();
String getYearAndMonth = sdf.format(calendar.getTime());
Log.d("datedate", "getMonth: " + calendar.getTime());
return getYearAndMonth;
}
public static Calendar getTomorrowDate(String date) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
try {
Date parse = sdf.parse(date);
calendar.setTime(parse);
calendar.add(calendar.DATE, 1);
Log.d("datedate", "getTomorrowDate: " + calendar.getTime());
} catch (ParseException e) {
e.printStackTrace();
} finally {
return calendar;
}
}
}
package cn.bsl.bxbg.zhiban.utils;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import cn.bsl.bxbg.zhiban.R;
public class DialogUtil
{
private static DialogUtil instance;
private DialogUtil()
{
}
public static DialogUtil getInstance()
{
if (instance == null)
{
instance = new DialogUtil();
}
return instance;
}
public LoadDialog showLoadDialog(Context context, String text)
{
LoadDialog dialog = new LoadDialog(context, R.style.popup_dialog_style);
Window window = dialog.getWindow();
window.setGravity(Gravity.TOP);
WindowManager mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams lp = window.getAttributes();
lp.y = 60;// 设置y坐标
window.setAttributes(lp);
window.setWindowManager(mWindowManager, null, null);
dialog.setCanceledOnTouchOutside(false);// 设置点击Dialog外部任意区域不可关闭Dialog
dialog.show();
if (text != null && !text.equals(""))
{
dialog.setLoadText(text);
}
return dialog;
}
public LoadDialog showLoadDialog(Context context)
{
LoadDialog dialog = new LoadDialog(context, R.style.popup_dialog_style);
Window window = dialog.getWindow();
window.setGravity(Gravity.TOP);
WindowManager mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams lp = window.getAttributes();
lp.y = 60;// 设置y坐标
window.setAttributes(lp);
window.setWindowManager(mWindowManager, null, null);
dialog.setCanceledOnTouchOutside(false);// 设置点击Dialog外部任意区域不可关闭Dialog
dialog.show();
return dialog;
}
public void dialogDismiss(Dialog dialog)
{
if (dialog != null && dialog.isShowing())
{
dialog.dismiss();
}
}
}
package cn.bsl.bxbg.zhiban.utils;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
import cn.bsl.bxbg.zhiban.R;
public class LoadDialog extends Dialog
{
Context mContext;
private TextView loadTv;
public LoadDialog(Context context)
{
super(context);
this.mContext = context;
}
public LoadDialog(Context context, int theme)
{
super(context, theme);
this.mContext = context;
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.widget_load_dialog);
// 使dialog全局
getWindow().setLayout(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
initViews();
}
// 控件初始化
private void initViews()
{
loadTv = (TextView) findViewById(R.id.widget_dialog_loading_tv);
}
public void setLoadText(String text)
{
loadTv.setText(text);
}
}
package cn.bsl.bxbg.zhiban.view;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.EListAdapter;
import cn.bsl.bxbg.zhiban.adapter.PopAdapter;
import cn.bsl.bxbg.zhiban.bean.Dept;
import cn.bsl.bxbg.zhiban.bean.GroupPeople;
import cn.bsl.bxbg.zhiban.bean.User;
import cn.bsl.bxbg.zhiban.listener.OnAddUserCountListener;
import cn.bsl.bxbg.zhiban.net.client.AllPeopleClient;
import cn.bsl.bxbg.zhiban.utils.DialogUtil;
import cn.bsl.bxbg.zhiban.utils.LoadDialog;
import me.texy.treeview.TreeNode;
import me.texy.treeview.TreeView;
import me.texy.treeview.TreeViewAdapter;
import me.texy.treeview.bean.TreeChildren;
import me.texy.treeview.binder.MyNodeViewFactory;
import me.texy.treeview.helper.TreeNodeHelper;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
public class AddMeetingPersonActivity2 extends AppCompatActivity implements OnClickListener,OnAddUserCountListener,TreeViewAdapter.OnSingleCheckedListener {
private static final String TAG = "AddMeetingPersonActivity";
private ImageView img_back;
private TextView tv_name, tv_right, tv_count;
private RadioGroup groups_radiogroup;
private RadioButton groups_radiobutten01;
private RadioButton groups_radiobutten02;
private ArrayList<Dept> groups;
private ArrayList<Dept> groupGroupList;
private ArrayList<Dept> groupList;
// private ExpandableListView listView;
private EListAdapter adapter;
private Button bt_select;
private PopupWindow popupWindow;
private ListView pop_list;
private List<String> list_pop = new ArrayList<String>();
private String userid;
private int level;
private Intent intent;
private Map<String, List<User>> map;
private Map<String, User> map_id;
// private MyReceiver rece;
private List<Dept> dept;
private Context mContext;
private LoadDialog dialog;
private ViewGroup viewGroup;
private TreeNode root;
private TreeView treeView;
private PopAdapter groupAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_meeting_person);
mContext = this;
root = TreeNode.root();
intent = getIntent();
level = intent.getIntExtra("level", -1);
dept = (List<Dept>) intent.getSerializableExtra("dept");
// rece = new MyReceiver();
// IntentFilter filter = new IntentFilter();
// filter.addAction("cn.com.bril");
// registerReceiver(rece, filter);
initView();
initEvent();
initData();
// groups_radiobutten01.setChecked(true);
}
private void initView() {
viewGroup = (RelativeLayout) findViewById(R.id.container);
groups_radiogroup = (RadioGroup) findViewById(R.id.radio_group);
groups_radiobutten01 = (RadioButton) findViewById(R.id.radio_butten01);
groups_radiobutten02 = (RadioButton) findViewById(R.id.radio_butten02);
img_back = (ImageView) findViewById(R.id.back);
tv_name = (TextView) findViewById(R.id.title);
// tv_right.setBackgroundColor(Color.parseColor("#00000000"));
tv_name.setText("选择调班人员");
bt_select = (Button) findViewById(R.id.bt_select);
groups = new ArrayList<Dept>();
groupList = new ArrayList<Dept>();
groupGroupList = new ArrayList<Dept>();
}
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("result", null);
intent.putExtras(bundle);
}
private void initEvent() {
img_back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
// tv_right.setOnClickListener(this);
tv_name.setOnClickListener(this);
// groups_radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(RadioGroup group, int checkedId) {
//
// if (groups_radiobutten01.getId() == checkedId) {
// initData();
// } else if (groups_radiobutten02.getId() == checkedId) {
// try {
// initGroupData();
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
// });
}
private void initData() {
dialog = DialogUtil.getInstance().showLoadDialog(mContext, "请求数据中");
AllPeopleClient allPeopleClient = new AllPeopleClient();
allPeopleClient.getAllUser().enqueue(new retrofit2.Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
String result = response.body().string();
if (null != dialog && dialog.isShowing()) {
dialog.dismiss();
}
String s = result.replace("\"children\":\"\"", "\"children\":[]");
List<TreeChildren> list = new Gson().fromJson(s, new TypeToken<List<TreeChildren>>() {
}.getType());
TreeNodeHelper.buildTree(root, list);
if (treeView == null) {
treeView = new TreeView(root, mContext, new MyNodeViewFactory(View.GONE));
View view = treeView.getView();
view.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
viewGroup.addView(view);
} else {
treeView.refreshTreeView();
}
treeView.expandLevel(0);
treeView.setTreeViewSingleListener(AddMeetingPersonActivity2.this);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
t.printStackTrace();
}
});
// dialog = DialogUtil.getInstance().showLoadDialog(mContext, "请求数据中");
// RequestParams params = new RequestParams(Constant.ALLUSER);//
// params.addBodyParameter("userId", Constant.USER_ID+"");
// x.http().post(params, new Callback.CommonCallback<String>() {
// @Override
// public void onSuccess(String result) {
// if (null != dialog && dialog.isShowing()) {
// dialog.dismiss();
// }
// String s = result.replace("\"children\":\"\"", "\"children\":[]");
// List<TreeChildren> list = new Gson().fromJson(s, new TypeToken<List<TreeChildren>>() {
// }.getType());
// TreeNodeHelper.buildTree(root, list);
// if (treeView == null) {
// treeView = new TreeView(root, mContext, new MyNodeViewFactory(View.GONE));
// View view = treeView.getView();
// view.setLayoutParams(new ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// viewGroup.addView(view);
// } else {
// treeView.refreshTreeView();
// }
// treeView.expandLevel(0);
// treeView.setTreeViewSingleListener(AddMeetingPersonActivity2.this);
//
// }
//
// @Override
// public void onError(Throwable ex, boolean isOnCallback) {
// if (null != dialog && dialog.isShowing()) {
// dialog.dismiss();
// }
// Toast.makeText(mContext, "", Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// public void onCancelled(CancelledException cex) {
// if (null != dialog && dialog.isShowing())
// dialog.dismiss();
// }
//
// @Override
// public void onFinished() {
// if (null != dialog && dialog.isShowing())
// dialog.dismiss();
// }
// });
}
// private void initGroupData() throws JSONException {
// dialog = DialogUtil.getInstance().showLoadDialog(mContext, R.string.toast_web_wait);
// JSONObject obj=new JSONObject();
// obj.put("userid",Constant.USER_ID);
// RequestParams params=new RequestParams(Constant.GET_DEPT_PERSON);
// params.addBodyParameter("p", obj.toString());
// x.http().get(params, new Callback.CommonCallback<String>() {
// @Override
// public void onSuccess(String result) {
// if (null != dialog && dialog.isShowing()) {
// dialog.dismiss();
// }
// groupGroupList.clear();
// List<GroupPeople> l = GsonUtil.getInstance().fromJson(result, new TypeToken<List<GroupPeople>>() {
// }.getType());
// if (l == null) {
// return;
// }
//
// buildGroupTree(root, l);
// if (treeView == null) {
// treeView = new TreeView(root, mContext, new MyNodeViewFactory());
// View view = treeView.getView();
// view.setLayoutParams(new ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// viewGroup.addView(view);
// } else {
// treeView.refreshTreeView();
// }
// treeView.expandLevel(0);
// }
//
// @Override
// public void onError(Throwable ex, boolean isOnCallback) {
// if (null != dialog && dialog.isShowing()) {
// dialog.dismiss();
// }
// Toast.makeText(mContext, R.string.toast_web_failure, Toast.LENGTH_SHORT).show();
//
// }
//
// @Override
// public void onCancelled(CancelledException cex) {
// if (null != dialog && dialog.isShowing()) {
// dialog.dismiss();
// }
// }
//
// @Override
// public void onFinished() {
// if (null != dialog && dialog.isShowing()) {
// dialog.dismiss();
// }
// }
// });
// }
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_select:
showPop(v);
break;
// case R.id.tv_ok:
// Intent intent = new Intent();
// Bundle bundle = new Bundle();
// bundle.putSerializable("result", root);
// intent.putExtras(bundle);
// setResult(RESULT_OK, intent);
// finish();
// break;
case R.id.tv_name:
showPop(v);
break;
default:
break;
}
}
public TreeNode buildGroupTree(TreeNode root, List<GroupPeople> list) {
root.getChildren().clear();
TreeNode treeNode0 = new TreeNode("保定市检务通", "保定市检务通");
treeNode0.setLevel(0);
root.addChild(treeNode0);
for (int i = 0; i < list.size(); i++) {
TreeNode treeNode = new TreeNode(new String(list.get(i).getTitleName()), list.get(i).getTitleName());
treeNode.setLevel(1);
if (list.get(i).getIdentityUser() != null && list.get(i).getIdentityUser().size() > 0) {
for (int j = 0; j < list.get(i).getIdentityUser().size(); j++) {
TreeNode treeNode1 = new TreeNode(new String(list.get(i).getIdentityUser().get(j).getUsename()), list.get(i).getIdentityUser().get(j).getUserid() + "");
treeNode1.setLevel(2);
treeNode.addChild(treeNode1);
}
}
root.getChildren().get(0).addChild(treeNode);
}
return root;
}
public void showPop(View parent) {
if (popupWindow == null) {
View view = LayoutInflater.from(this).inflate(R.layout.pop_list, null);
pop_list = (ListView) view.findViewById(R.id.pop_list);
groupAdapter = new PopAdapter(this, list_pop);
pop_list.setAdapter(groupAdapter);
// 创建一个PopuWidow对象
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
int wid = windowManager.getDefaultDisplay().getWidth() / 4 * 3;
int heig = windowManager.getDefaultDisplay().getHeight() / 3;
popupWindow = new PopupWindow(view, wid, heig);
}
// 使其聚集
popupWindow.setFocusable(true);
// 设置允许在外点击消失
popupWindow.setOutsideTouchable(true);
// 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
popupWindow.setBackgroundDrawable(new BitmapDrawable());
WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
// 显示的位置为:屏幕的宽度的一半-PopupWindow的高度的一半
int xPos = windowManager.getDefaultDisplay().getWidth() / 2 - popupWindow.getWidth() / 2;
Log.i("coder", "xPos:" + xPos);
popupWindow.showAsDropDown(parent, -xPos, 0);
pop_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
CheckBox cb = (CheckBox) view.findViewById(R.id.checkbox);
boolean flg = cb.isChecked();
if (flg) {
cb.setChecked(false);
for (int i = 0; i < groups.size(); i++) {
List<User> list = groups.get(i).getChildren();
for (int j = 0; j < list.size(); j++) {
if ((position + 1 + "").equals(list.get(j).getRolecode())) {
list.get(j).setChecked(false);
}
}
}
adapter.notifyDataSetChanged();
} else {
cb.setChecked(true);
for (int i = 0; i < groups.size(); i++) {
List<User> list = groups.get(i).getChildren();
for (int j = 0; j < list.size(); j++) {
if ((position + 1 + "").equals(list.get(j).getRolecode())) {
list.get(j).setChecked(true);
}
}
}
adapter.notifyDataSetChanged();
}
if (popupWindow != null) {
popupWindow.dismiss();
}
}
});
}
// class MyReceiver extends BroadcastReceiver {
//
// @Override
// public void onReceive(Context context, Intent intent) {
// String count = intent.getStringExtra("count");
// }
// }
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
// unregisterReceiver(rece);
}
@Override
public void OnAddUserCountListener(int num) {
// TODO Auto-generated method stub
}
@Override
public void singleChecked(TreeNode treeNode) {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("result", treeNode);
intent.putExtras(bundle);
setResult(RESULT_OK, intent);
finish();
}
}
package cn.bsl.bxbg.zhiban.view;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.fragment.AlreadyTakeOverFragment;
import cn.bsl.bxbg.zhiban.fragment.WaitShiftFragment;
import cn.bsl.bxbg.zhiban.fragment.WaitTakeOverFragment;
public class DutyTransferActivity extends BaseActivity {
@BindView(R.id.jj_layout)
TabLayout jjLayout;
@BindView(R.id.jj_viewpager)
ViewPager jjViewpager;
private ArrayList<Fragment> waitMeFinishFragments = new ArrayList<>();
private ViewPagerAdapter viewPagerAdapter;
private String[] mTitles = new String[]{"待交班", "待接班","已交班"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_duty_transfer);
ButterKnife.bind(this);
initView();
}
private void initView() {
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
waitMeFinishFragments.add(new WaitShiftFragment());
waitMeFinishFragments.add(new WaitTakeOverFragment());
waitMeFinishFragments.add(new AlreadyTakeOverFragment());
jjViewpager.setAdapter(viewPagerAdapter);
jjLayout.setupWithViewPager(jjViewpager);
}
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return waitMeFinishFragments.get(position);
}
@Override
public int getCount() {
return waitMeFinishFragments.size();
}
@Override
public CharSequence getPageTitle(int position) {
return mTitles[position];
}
}
}
package cn.bsl.bxbg.zhiban.view;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import com.bril.baoding.studio.aidl.GetUserid;
import java.util.ArrayList;
import java.util.List;
......@@ -15,18 +23,43 @@ import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.HomeAdapter;
import cn.bsl.bxbg.zhiban.bean.MenuBean;
import cn.bsl.bxbg.zhiban.bean.TimeBean;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.utils.Constant;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends BaseActivity implements AdapterView.OnItemClickListener{
public class MainActivity extends BaseActivity implements AdapterView.OnItemClickListener {
@BindView(R.id.home_gv)
GridView homeGv;
private GetUserid mService;
private static final String TAG = "MainActivity";
private DutyPlanClient dutyPlanClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
bindService();
initTab();
}
@Override
protected void onResume() {
super.onResume();
initData();
}
private void bindService() {
Intent intent = new Intent();
intent.setComponent(
new ComponentName("com.bril.baoding.studio", "com.bril.baoding.studio.service.AIDLService"));
bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE);
}
private void initTab() {
......@@ -34,17 +67,58 @@ public class MainActivity extends BaseActivity implements AdapterView.OnItemClic
homeGv.setOnItemClickListener(this);
}
private void initData() {
dutyPlanClient = new DutyPlanClient();
dutyPlanClient.timeBean().enqueue(new Callback<TimeBean>() {
@Override
public void onResponse(Call<TimeBean> call, Response<TimeBean> response) {
Constant.systemDate = response.body().getSystemDate();
Constant.systemTime = response.body().getSystemTime();
}
@Override
public void onFailure(Call<TimeBean> call, Throwable t) {
t.printStackTrace();
}
});
}
private List<MenuBean> menuData() {
List<MenuBean> menuList = new ArrayList<>();
MenuBean fbjl = new MenuBean(R.drawable.zb_info,"值班信息");
MenuBean fbj2 = new MenuBean(R.drawable.zb_table,"值班表");
MenuBean fbj3 = new MenuBean(R.drawable.tb_record,"调班记录");
MenuBean fbjl = new MenuBean(R.drawable.zb_info, "值班信息");
MenuBean fbj2 = new MenuBean(R.drawable.zb_table, "值班表");
MenuBean fbj3 = new MenuBean(R.drawable.tb_record, "调班记录");
MenuBean fbj4 = new MenuBean(R.drawable.waitme, "待办事项");
MenuBean fbj5 = new MenuBean(R.drawable.jiaoban_record,"交接班记录");
menuList.add(fbjl);
menuList.add(fbj2);
menuList.add(fbj3);
menuList.add(fbj4);
menuList.add(fbj5);
return menuList;
}
private ServiceConnection mServiceConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName arg0) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName arg0, IBinder arg1) {
mService = GetUserid.Stub.asInterface(arg1);
try {
Constant.USER_ID = mService.getUserid();
Constant.USER_NAME = mService.getUsername();
} catch (RemoteException e) {
e.printStackTrace();
}
Log.d(TAG, "onServiceConnected: " + Constant.USER_NAME);
}
};
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent();
......@@ -56,7 +130,13 @@ public class MainActivity extends BaseActivity implements AdapterView.OnItemClic
intent.setClass(MainActivity.this, ZhibanTableActivity.class);
break;
case 2:
intent.setClass(MainActivity.this,TiaobanRecordActivity.class);
intent.setClass(MainActivity.this, TiaobanRecordActivity.class);
break;
case 3:
intent.setClass(MainActivity.this, WaitMeActivity.class);
break;
case 4:
intent.setClass(MainActivity.this, DutyTransferActivity.class);
break;
}
startActivity(intent);
......
package cn.bsl.bxbg.zhiban.view;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Xinghx on 2018/5/20 0020.
*/
public class TakeOverDetailsActivity extends BaseActivity {
@BindView(R.id.shift_zb_time)
TextView shiftZbTime;
@BindView(R.id.shift_zb_shift)
TextView shiftZbShift;
@BindView(R.id.shift_zb_person)
TextView shiftZbPerson;
@BindView(R.id.shift_zb_content)
EditText shiftZbContent;
@BindView(R.id.btn_ok)
Button btnOk;
@BindView(R.id.save)
TextView save;
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
private String trsid;
private String dutyContent;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shift_details_layout);
ButterKnife.bind(this);
initView();
}
private void initData() {
}
private void initView() {
trsid = getIntent().getStringExtra("id");
String status = getIntent().getStringExtra("status");
String dutyTime = getIntent().getStringExtra("dutyTime");
String dutyShift = getIntent().getStringExtra("dutyShift");
dutyContent = getIntent().getStringExtra("dutyContent");
shiftZbTime.setText(dutyTime);
switch (dutyShift) {
case "0":
shiftZbShift.setText("早");
break;
case "1":
shiftZbShift.setText("中");
break;
case "2":
shiftZbShift.setText("晚");
break;
}
shiftZbContent.setText(dutyContent + "");
switch (status) {
case "0":
btnOk.setText("确认接班");
shiftZbContent.setEnabled(false);
shiftZbContent.setFocusable(false);
shiftZbContent.setKeyListener(null);
shiftZbContent.setHint("");
break;
case "1":
save.setVisibility(View.VISIBLE);
btnOk.setText("交班");
break;
case "2":
btnOk.setVisibility(View.GONE);
shiftZbContent.setEnabled(false);
shiftZbContent.setFocusable(false);
shiftZbContent.setKeyListener(null);
shiftZbContent.setHint("");
break;
}
}
@OnClick({R.id.save, R.id.btn_ok})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.save:
// 编辑值班记录
dutyPlanClient.editShiftRecord(trsid,shiftZbContent.getText().toString())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(shiftBeen -> {
Toast.makeText(this, "修改成功", Toast.LENGTH_SHORT).show();
finish();
},Throwable::printStackTrace);
break;
case R.id.btn_ok:
if (btnOk.getText().equals("确认接班")) {
dutyPlanClient.editShiftStatus(trsid,"2")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(shiftBean -> {
Toast.makeText(this, "接班成功", Toast.LENGTH_SHORT).show();
finish();
},Throwable::printStackTrace);
} else if (btnOk.getText().equals("交班")) {
dutyPlanClient.editShiftStatus(trsid, "0")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(shiftBean -> {
Toast.makeText(this, "等待交班", Toast.LENGTH_SHORT).show();
finish();
},Throwable::printStackTrace);
}
break;
}
}
}
......@@ -6,7 +6,10 @@ import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
......@@ -19,34 +22,41 @@ import butterknife.OnClick;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCDutiesEdit;
import cn.bsl.bxbg.zhiban.net.response.TiaobanBean;
import cn.bsl.bxbg.zhiban.utils.Constant;
import io.reactivex.ObservableSource;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import me.texy.treeview.TreeNode;
import me.texy.treeview.TreeView;
public class TiaoBanPublish extends BaseActivity {
private TreeNode root;
private TreeView treeView;
private static final String TAG = "TiaoBanPublish";
@BindView(R.id.reason)
EditText reason;
@BindView(R.id.button)
TextView button;
private static final String TAG = "TiaoBanPublish";
@BindView(R.id.choose_result)
TextView chooseResult;
@BindView(R.id.choose_time_area)
TextView chooseTimeArea;
@BindView(R.id.daibanLeader)
CheckBox daibanLeader;
@BindView(R.id.choose_time)
LinearLayout chooseTime;
private String morning;
private String noon;
private String evening;
private String leaderChange;
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
private String id;
private String dutyTime;
private boolean isLeader = false;
private String departMent;
private int approveID;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -54,6 +64,7 @@ public class TiaoBanPublish extends BaseActivity {
setContentView(R.layout.activity_tiao_ban_publish);
ButterKnife.bind(this);
initData();
initView();
}
private void initData() {
......@@ -62,40 +73,62 @@ public class TiaoBanPublish extends BaseActivity {
noon = getIntent().getStringExtra("noon");
evening = getIntent().getStringExtra("evening");
dutyTime = getIntent().getStringExtra("dutyTime");
leaderChange = getIntent().getStringExtra("leaderChange");
departMent = getIntent().getStringExtra("department");
if (!leaderChange.equals(Constant.USER_NAME)) {
daibanLeader.setVisibility(View.GONE);
}
}
private void initView() {
daibanLeader.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
chooseTime.setVisibility(View.GONE);
isLeader = true;
} else {
chooseTime.setVisibility(View.VISIBLE);
isLeader = false;
}
}
});
}
@OnClick({R.id.change_people,R.id.choose_time,R.id.button})
@OnClick({R.id.change_people, R.id.choose_time, R.id.button})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.change_people:
Intent intent = new Intent(this, DutyChangePeopleActivity.class);
Intent intent = new Intent(this, AddMeetingPersonActivity2.class);
startActivityForResult(intent, 0x00);
break;
case R.id.choose_time:
showTimeSelector();
break;
case R.id.button:
submit();
submit(isLeader);
break;
}
}
// private void leaderTiaoban(String choose_leader,)
private void tiaoBan(String choose_person,String choose_time,String choose_reason) {
String timeStatus;
private void tiaoBan(String choose_person, String choose_time, String choose_reason) {
String timeStatus="";
if (choose_time.equals("08:30 - 12:00")) {
// morning
timeStatus = "0";
} else if (choose_time.equals("12:00 - 18:30")){
} else if (choose_time.equals("12:00 - 18:30")) {
// noon
timeStatus = "1";
} else {
} else if (choose_time.equals("18:30 - 08:30")){
// evening
timeStatus = "2";
} else if (choose_time.equals("isLeader")) {
timeStatus = "3";
}
dutyPlanClient.tiaobanBean(choose_person,id,choose_reason,dutyTime,timeStatus)
dutyPlanClient.tiaobanBean(approveID+"",choose_person, id, choose_reason, dutyTime, timeStatus,departMent)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<TiaobanBean>() {
......@@ -104,53 +137,45 @@ public class TiaoBanPublish extends BaseActivity {
Toast.makeText(TiaoBanPublish.this, "发起调班成功,请等待对方确认", Toast.LENGTH_SHORT).show();
finish();
}
},Throwable::printStackTrace);
}, Throwable::printStackTrace);
}
private void submit() {
String choose_person = chooseResult.getText().toString();
String choose_time = chooseTimeArea.getText().toString();
String choose_reason = reason.getText().toString();
if (TextUtils.isEmpty(choose_reason)) {
Toast.makeText(this, "请输入调班原因", Toast.LENGTH_SHORT).show();
return;
}
if (choose_time.equals("选择您要调整的时间段")) {
Toast.makeText(this, "请选择时间", Toast.LENGTH_SHORT).show();
return;
}
if (choose_person.equals("请选择变更人")) {
Toast.makeText(this, "请选择变更人", Toast.LENGTH_SHORT).show();
return;
private void submit(boolean leaderStatus) {
if (leaderStatus) {
String choose_person = chooseResult.getText().toString();
String choose_reason = reason.getText().toString();
if (TextUtils.isEmpty(choose_reason)) {
Toast.makeText(this, "请输入调班原因", Toast.LENGTH_SHORT).show();
return;
}
if (choose_person.equals("请选择变更人")) {
Toast.makeText(this, "请选择变更人", Toast.LENGTH_SHORT).show();
return;
}
tiaoBan(choose_person, "isLeader", choose_reason);
} else {
String choose_person = chooseResult.getText().toString();
String choose_time = chooseTimeArea.getText().toString();
String choose_reason = reason.getText().toString();
if (TextUtils.isEmpty(choose_reason)) {
Toast.makeText(this, "请输入调班原因", Toast.LENGTH_SHORT).show();
return;
}
if (choose_time.equals("选择您要调整的时间段")) {
Toast.makeText(this, "请选择时间", Toast.LENGTH_SHORT).show();
return;
}
if (choose_person.equals("请选择变更人")) {
Toast.makeText(this, "请选择变更人", Toast.LENGTH_SHORT).show();
return;
}
tiaoBan(choose_person, choose_time, choose_reason);
}
tiaoBan(choose_person,choose_time,choose_reason);
// TODO the flatMap will delete
// dutyPlanClient.tiaobanBean(choose_person,id,choose_reason,dutyTime,choose_time)
// .flatMap(new Function<TiaobanBean, ObservableSource<CCDutiesEdit>>() {
// @Override
// public ObservableSource<CCDutiesEdit> apply(@NonNull TiaobanBean tiaobanBean) throws Exception {
// if (choose_time.equals("08:30 - 12:00")) {
// // morning
// return dutyPlanClient.editMorning(id, morning.replace(Constant.USER_NAME, choose_person));
// } else if (choose_time.equals("12:00 - 18:30")){
// // noon
// return dutyPlanClient.editNoon(id, noon.replace(Constant.USER_NAME, choose_person));
// } else {
// // evening
// return dutyPlanClient.editNight(id, evening.replace(Constant.USER_NAME, choose_person));
// }
// }
// }).subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Consumer<CCDutiesEdit>() {
// @Override
// public void accept(CCDutiesEdit ccDutiesEdit) throws Exception {
// Toast.makeText(TiaoBanPublish.this, "申请成功", Toast.LENGTH_SHORT).show();
// finish();
// }
// },Throwable::printStackTrace);
}
private void showTimeSelector() {
......@@ -173,7 +198,6 @@ public class TiaoBanPublish extends BaseActivity {
.setItems(strings, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
chooseTimeArea.setText(strings[which]);
}
})
......@@ -186,9 +210,12 @@ public class TiaoBanPublish extends BaseActivity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x00 && data != null) {
String id = data.getStringExtra("id");
String name = data.getStringExtra("name");
chooseResult.setText(name);
Bundle bundles = data.getExtras();
TreeNode singleTreeNode = (TreeNode) bundles.getSerializable("result");
approveID = Integer.parseInt(singleTreeNode.getUserId());
String approveName = (String) singleTreeNode.getValue();
chooseResult.setText(approveName);
}
}
......
......@@ -50,6 +50,8 @@ public class TiaobanDetailsActivity extends BaseActivity {
RadioGroup rg;
@BindView(R.id.tv_status)
TextView tvStatus;
@BindView(R.id.duty_dept)
TextView dutyDept;
private String id;
DutyPlanClient dutyPlanClient = new DutyPlanClient();
String status = "1";
......@@ -74,14 +76,16 @@ public class TiaobanDetailsActivity extends BaseActivity {
public void accept(List<DutiesTbResponse> dutiesTbResponses) throws Exception {
cc_duty_id = dutiesTbResponses.get(0).getIncludes().getCc_duty().getId();
String createTime = dutiesTbResponses.get(0).getSuperior().getCreateTime();
String dutyDepts = dutiesTbResponses.get(0).getIncludes().getCc_duty().getDepartment();
String dutyDate = dutiesTbResponses.get(0).getIncludes().getCc_duty().getDutyDate();
String people = " 早:" + dutiesTbResponses.get(0).getIncludes().getCc_duty().getMorning() + "\n 中:" + dutiesTbResponses.get(0).getIncludes().getCc_duty().getNoon() + "\n 晚:" + dutiesTbResponses.get(0).getIncludes().getCc_duty().getEvening();
String change = dutiesTbResponses.get(0).getSuperior().getTransferredName() + " 变更为 " + dutiesTbResponses.get(0).getSuperior().getTransferredClass();
String change = dutiesTbResponses.get(0).getSuperior().getApplicant() + " 变更为 " + dutiesTbResponses.get(0).getSuperior().getTransferredName();
dutyDept.setText(dutyDepts);
dutyTimes.setText(dutyDate);
person.setText(people);
changePerson.setText(change);
// simple if 换班人是我判断id 如果被换班是我 直接修改
if (dutiesTbResponses.get(0).getSuperior().getTransferredName().equals(Constant.USER_NAME)) {
// simple if 换班人是我判断id 如果被换班是我
if (dutiesTbResponses.get(0).getSuperior().getApplicant().equals(Constant.USER_NAME)) {
if (dutiesTbResponses.get(0).getSuperior().getStatus().equals("0")) {
tvStatus.setText("调班状态:等待对方操作");
......@@ -98,7 +102,7 @@ public class TiaobanDetailsActivity extends BaseActivity {
rg.setVisibility(View.GONE);
submit.setVisibility(View.GONE);
}
} else if (dutiesTbResponses.get(0).getSuperior().getTransferredClass().equals(Constant.USER_NAME)) {
} else if (dutiesTbResponses.get(0).getSuperior().getTransferredName().equals(Constant.USER_NAME)) {
// 被换班人是我
if (dutiesTbResponses.get(0).getSuperior().getStatus().equals("0")) {
tvStatus.setVisibility(View.GONE);
......@@ -144,7 +148,7 @@ public class TiaobanDetailsActivity extends BaseActivity {
public void onViewClicked() {
if (status.equals("1")) {
dutyPlanClient.ccShiftsEdit(id,status).flatMap(new Function<CCShifts, ObservableSource<List<CCShiftsUni>>>() {
dutyPlanClient.ccShiftsEdit(id, status).flatMap(new Function<CCShifts, ObservableSource<List<CCShiftsUni>>>() {
@Override
public ObservableSource<List<CCShiftsUni>> apply(CCShifts ccShifts) throws Exception {
return dutyPlanClient.ccshiftUni(id);
......@@ -158,19 +162,21 @@ public class TiaobanDetailsActivity extends BaseActivity {
} else if (ccShiftsUnis.get(0).getSuperior().getTransferredClassTime().equals("1")) {
String noon = ccShiftsUnis.get(0).getIncludes().getCc_duty().getNoon();
return dutyPlanClient.editNoon(cc_duty_id, noon.replace(ccShiftsUnis.get(0).getSuperior().getTransferredName(), ccShiftsUnis.get(0).getSuperior().getTransferredClass()));
} else {
} else if (ccShiftsUnis.get(0).getSuperior().getTransferredClassTime().equals("2")) {
String eve = ccShiftsUnis.get(0).getIncludes().getCc_duty().getEvening();
return dutyPlanClient.editNight(cc_duty_id, eve.replace(ccShiftsUnis.get(0).getSuperior().getTransferredName(), ccShiftsUnis.get(0).getSuperior().getTransferredClass()));
} else {
return dutyPlanClient.editLeader(cc_duty_id, ccShiftsUnis.get(0).getSuperior().getTransferredClass());
}
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ccDutiesEdit -> {
Toast.makeText(TiaobanDetailsActivity.this, "操作成功", Toast.LENGTH_SHORT).show();
finish();
},Throwable::printStackTrace);
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ccDutiesEdit -> {
Toast.makeText(TiaobanDetailsActivity.this, "操作成功", Toast.LENGTH_SHORT).show();
finish();
}, Throwable::printStackTrace);
} else {
dutyPlanClient.ccShiftsEdit(id,status).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(ccShifts -> {
dutyPlanClient.ccShiftsEdit(id, status).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(ccShifts -> {
Toast.makeText(TiaobanDetailsActivity.this, "操作成功", Toast.LENGTH_SHORT).show();
finish();
}, Throwable::printStackTrace);
......
package cn.bsl.bxbg.zhiban.view;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import java.util.List;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.TiaobanInfoAdapter;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import cn.bsl.bxbg.zhiban.fragment.TiaoBanFinishFragment;
import cn.bsl.bxbg.zhiban.fragment.TiaoBanNotFinishFragment;
public class TiaobanRecordActivity extends BaseActivity {
@BindView(R.id.tbLv)
ListView tbLv;
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
private ArrayList<Fragment> waitMeFinishFragments = new ArrayList<>();
private ViewPagerAdapter viewPagerAdapter;
@BindView(R.id.tb_layout)
TabLayout tbLayout;
@BindView(R.id.tb_viewpager)
ViewPager tbViewpager;
private String[] mTitles = new String[]{"已完成", "未完成"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tiaoban_record);
ButterKnife.bind(this);
queryRecord();
initView();
}
private void queryRecord() {
dutyPlanClient.shiftsRecord().enqueue(new Callback<List<CCShifts>>() {
@Override
public void onResponse(Call<List<CCShifts>> call, Response<List<CCShifts>> response) {
List<CCShifts> ccShift = response.body();
tbLv.setAdapter(new TiaobanInfoAdapter(ccShift));
tbLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(TiaobanRecordActivity.this,TiaobanDetailsActivity.class);
intent.putExtra("id", ccShift.get(position).getId());
startActivity(intent);
}
});
}
@Override
public void onFailure(Call<List<CCShifts>> call, Throwable t) {
t.printStackTrace();
}
});
private void initView() {
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
waitMeFinishFragments.add(new TiaoBanFinishFragment());
waitMeFinishFragments.add(new TiaoBanNotFinishFragment());
tbViewpager.setAdapter(viewPagerAdapter);
tbLayout.setupWithViewPager(tbViewpager);
}
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return waitMeFinishFragments.get(position);
}
@Override
public int getCount() {
return waitMeFinishFragments.size();
}
@Override
public CharSequence getPageTitle(int position) {
return mTitles[position];
}
}
}
package cn.bsl.bxbg.zhiban.view;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.TiaobanInfoAdapter;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class TiaobanRecordActivity2 extends BaseActivity {
@BindView(R.id.tbLv)
ListView tbLv;
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tiaoban_record);
ButterKnife.bind(this);
queryRecord();
}
private void queryRecord() {
dutyPlanClient.shiftsRecord().enqueue(new Callback<List<CCShifts>>() {
@Override
public void onResponse(Call<List<CCShifts>> call, Response<List<CCShifts>> response) {
List<CCShifts> ccShift = response.body();
tbLv.setAdapter(new TiaobanInfoAdapter(ccShift));
tbLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(TiaobanRecordActivity2.this,TiaobanDetailsActivity.class);
intent.putExtra("id", ccShift.get(position).getId());
startActivity(intent);
}
});
}
@Override
public void onFailure(Call<List<CCShifts>> call, Throwable t) {
t.printStackTrace();
}
});
}
}
package cn.bsl.bxbg.zhiban.view;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.fragment.WaitMeFinishFragment;
import cn.bsl.bxbg.zhiban.fragment.WaitMeNotFinishFragment;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCShifts;
public class WaitMeActivity extends BaseActivity {
List<CCShifts> ccShiftsList;
private ViewPagerAdapter viewPagerAdapter;
@BindView(R.id.tb_layout)
TabLayout tbLayout;
@BindView(R.id.tb_viewpager)
ViewPager tbViewpager;
private String[] mTitles = new String[]{"已完成", "未完成"};
private DutyPlanClient dutyPlanClient = new DutyPlanClient();
private ArrayList<Fragment> waitMeFinishFragments = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wait_me);
ButterKnife.bind(this);
viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
waitMeFinishFragments.add(new WaitMeFinishFragment());
waitMeFinishFragments.add(new WaitMeNotFinishFragment());
tbViewpager.setAdapter(viewPagerAdapter);
tbLayout.setupWithViewPager(tbViewpager);
// initData();
}
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return waitMeFinishFragments.get(position);
}
@Override
public int getCount() {
return waitMeFinishFragments.size();
}
@Override
public CharSequence getPageTitle(int position) {
return mTitles[position];
}
}
}
......@@ -2,10 +2,15 @@ package cn.bsl.bxbg.zhiban.view;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import butterknife.BindView;
......@@ -14,20 +19,42 @@ import butterknife.OnClick;
import cn.bsl.bxbg.zhiban.BaseActivity;
import cn.bsl.bxbg.zhiban.R;
import cn.bsl.bxbg.zhiban.adapter.ZbPeopleAdapter;
import cn.bsl.bxbg.zhiban.bean.TimeBean;
import cn.bsl.bxbg.zhiban.net.client.DutyPlanClient;
import cn.bsl.bxbg.zhiban.net.response.CCDuties;
import cn.bsl.bxbg.zhiban.utils.Constant;
import cn.bsl.bxbg.zhiban.utils.DateUtils;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ZhibanDetailsActivity extends BaseActivity {
private List<CCDuties> ccDuties = new ArrayList<>();
@BindView(R.id.tvTiaoban)
TextView tvTiaoban;
@BindView(R.id.start_zb)
LinearLayout startZb;
@BindView(R.id.duty_dept)
TextView dutyDept;
@BindView(R.id.tb)
LinearLayout tb;
@BindView(R.id.tvZhiban)
TextView tvZhiban;
@BindView(R.id.tbs)
LinearLayout tbs;
private List<CCDuties> ccDutiesList = new ArrayList<>();
@BindView(R.id.duty_time)
TextView dutyTime;
@BindView(R.id.zb_people)
ListView zbPeople;
DutyPlanClient dutyPlanClient = new DutyPlanClient();
private String dutyId;
private String shift;
private String dutyTimes;
private String tomorrowMorning;
private CCDuties netClcDuties;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -35,10 +62,56 @@ public class ZhibanDetailsActivity extends BaseActivity {
setContentView(R.layout.activity_zhiban_details);
ButterKnife.bind(this);
initData();
initTime();
nextTime();
}
private void nextTime() {
Calendar tomorrowDate = DateUtils.getTomorrowDate(dutyTimes);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date = sdf.format(tomorrowDate.getTime());
dutyPlanClient.findPeopleByTime(date)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ccDuties -> {
if (ccDuties != null && ccDuties.size() > 0) {
tomorrowMorning = ccDuties.get(0).getMorning();
}
}, Throwable::printStackTrace);
}
private void initTime() {
dutyPlanClient.timeBean().enqueue(new Callback<TimeBean>() {
@Override
public void onResponse(Call<TimeBean> call, Response<TimeBean> response) {
Constant.systemDate = response.body().getSystemDate();
Constant.systemTime = response.body().getSystemTime();
}
@Override
public void onFailure(Call<TimeBean> call, Throwable t) {
t.printStackTrace();
}
});
}
private void initData() {
// 拿ZhibanInfo传入的早中晚数据进行调班,但是展示需要使用dutyId查询出当天所有的记录.
dutyId = getIntent().getStringExtra("dutyId");
String classLeader = getIntent().getStringExtra("dutyLeader") + "";
String morning = getIntent().getStringExtra("dutyPersonMorning") + "";
String noon = getIntent().getStringExtra("dutyPersonNoon") + "";
String evening = getIntent().getStringExtra("dutyPersonEvening") + "";
dutyTimes = getIntent().getStringExtra("dutyTime") + "";
shift = getIntent().getStringExtra("shift") + "";
CCDuties ccDuties = new CCDuties();
ccDuties.setId(dutyId);
ccDuties.setClassLeaders(classLeader);
ccDuties.setMorning(morning);
ccDuties.setNoon(noon);
ccDuties.setEvening(evening);
ccDuties.setDutyDate(dutyTimes);
ccDutiesList.add(ccDuties);
queryDetails(dutyId);
}
......@@ -47,21 +120,58 @@ public class ZhibanDetailsActivity extends BaseActivity {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(clcDuties -> {
ccDuties.clear();
netClcDuties = clcDuties;
// ccDutiesList.clear();
dutyTime.setText(clcDuties.getDutyDate());
dutyDept.setText(clcDuties.getDepartment());
// ccDutiesList.add(clcDuties);
List<CCDuties> ccDuties = new ArrayList<CCDuties>();
ccDuties.add(clcDuties);
zbPeople.setAdapter(new ZbPeopleAdapter(ccDuties));
}, Throwable::printStackTrace);
}
@OnClick(R.id.tb)
public void onViewClicked() {
Intent intent = new Intent(this,TiaoBanPublish.class);
intent.putExtra("id", dutyId);
intent.putExtra("morning", ccDuties.get(0).getMorning());
intent.putExtra("noon", ccDuties.get(0).getNoon());
intent.putExtra("evening", ccDuties.get(0).getEvening());
intent.putExtra("dutyTime", dutyTime.getText().toString());
startActivity(intent);
@OnClick({R.id.tb, R.id.start_zb})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.tb:
Intent intent = new Intent(this, TiaoBanPublish.class);
intent.putExtra("id", dutyId);
intent.putExtra("morning", ccDutiesList.get(0).getMorning());
intent.putExtra("noon", ccDutiesList.get(0).getNoon());
intent.putExtra("evening", ccDutiesList.get(0).getEvening());
intent.putExtra("dutyTime", dutyTime.getText().toString());
intent.putExtra("leaderChange", ccDutiesList.get(0).getClassLeaders());
intent.putExtra("department", netClcDuties.getDepartment());
startActivity(intent);
break;
case R.id.start_zb:
// 如果班次为早班, 那么需要传入中班A岗的人员,如果是中班, 需要拿到晚班的A岗,如果是晚班
// ,需要拿第二天值班的早班
String nextPeople = "数据错误";
if (shift.equals("2")) {
String[] split = tomorrowMorning.split(",");
nextPeople = split[0];
} else if (shift.equals("0")) {
// 早班拿中班
String[] split = netClcDuties.getNoon().split(",");
nextPeople = split[0];
} else if (shift.equals("1")) {
// 中班拿晚班
String[] split = netClcDuties.getEvening().split(",");
nextPeople = split[0];
}
dutyPlanClient.shiftNew(dutyId, nextPeople, ccDutiesList.get(0).getDepartment(),
ccDutiesList.get(0).getDutyDate(), shift)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(shiftBean -> {
Toast.makeText(this, "开始值班,您可以在交接班记录编辑您的值班记录", Toast.LENGTH_SHORT).show();
finish();
}, Throwable::printStackTrace);
break;
}
}
}
......@@ -42,7 +42,86 @@ public class ZhibanInfoActivity extends BaseActivity implements AdapterView.OnIt
setContentView(R.layout.activity_zhiban_info);
ButterKnife.bind(this);
initView();
queryRecord();
// queryRecord();
initData();
}
List<DutyPlanDutiesBean> dutyPlanDutiesBeen = new ArrayList<>();
private void initData() {
dutyPlanClient.dutiesRecord()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ccDuties -> {
dutyPlanDutiesBeen.clear();
for (int i = 0; i < ccDuties.size(); i++) {
// 现在逻辑为值班分早中晚三个班次,所以希望按早中晚展示出来。
if (ccDuties.get(i).getClassLeaders().contains(Constant.USER_NAME)) {
DutyPlanDutiesBean dutyPlanDutiesBean = new DutyPlanDutiesBean();
dutyPlanDutiesBean.setDutyId(ccDuties.get(i).getId());
dutyPlanDutiesBean.setLeader(ccDuties.get(i).getClassLeaders());
dutyPlanDutiesBean.setMorning(ccDuties.get(i).getMorning());
dutyPlanDutiesBean.setNoon(ccDuties.get(i).getNoon());
dutyPlanDutiesBean.setEvening(ccDuties.get(i).getEvening());
dutyPlanDutiesBean.setDutyDate(ccDuties.get(i).getDutyDate());
dutyPlanDutiesBean.setType("4");
dutyPlanDutiesBeen.add(dutyPlanDutiesBean);
}
if (ccDuties.get(i).getMorning().contains(Constant.USER_NAME)) {
DutyPlanDutiesBean dutyPlanDutiesBean = new DutyPlanDutiesBean();
dutyPlanDutiesBean.setDutyId(ccDuties.get(i).getId());
dutyPlanDutiesBean.setLeader(ccDuties.get(i).getClassLeaders());
dutyPlanDutiesBean.setMorning(ccDuties.get(i).getMorning());
dutyPlanDutiesBean.setNoon(ccDuties.get(i).getNoon());
dutyPlanDutiesBean.setEvening(ccDuties.get(i).getEvening());
dutyPlanDutiesBean.setDutyDate(ccDuties.get(i).getDutyDate());
dutyPlanDutiesBean.setType("0");
dutyPlanDutiesBeen.add(dutyPlanDutiesBean);
}
if (ccDuties.get(i).getNoon().contains(Constant.USER_NAME)) {
DutyPlanDutiesBean dutyPlanDutiesBean = new DutyPlanDutiesBean();
dutyPlanDutiesBean.setDutyId(ccDuties.get(i).getId());
dutyPlanDutiesBean.setLeader(ccDuties.get(i).getClassLeaders());
dutyPlanDutiesBean.setMorning(ccDuties.get(i).getMorning());
dutyPlanDutiesBean.setNoon(ccDuties.get(i).getNoon());
dutyPlanDutiesBean.setEvening(ccDuties.get(i).getEvening());
dutyPlanDutiesBean.setDutyDate(ccDuties.get(i).getDutyDate());
dutyPlanDutiesBean.setType("1");
dutyPlanDutiesBeen.add(dutyPlanDutiesBean);
}
if (ccDuties.get(i).getEvening().contains(Constant.USER_NAME)) {
DutyPlanDutiesBean dutyPlanDutiesBean = new DutyPlanDutiesBean();
dutyPlanDutiesBean.setDutyId(ccDuties.get(i).getId());
dutyPlanDutiesBean.setLeader(ccDuties.get(i).getClassLeaders());
dutyPlanDutiesBean.setMorning(ccDuties.get(i).getMorning());
dutyPlanDutiesBean.setNoon(ccDuties.get(i).getNoon());
dutyPlanDutiesBean.setEvening(ccDuties.get(i).getEvening());
dutyPlanDutiesBean.setDutyDate(ccDuties.get(i).getDutyDate());
dutyPlanDutiesBean.setType("2");
dutyPlanDutiesBeen.add(dutyPlanDutiesBean);
}
// if (ccDuties.get(i).getMorning().contains(Constant.USER_NAME)
// || ccDuties.get(i).getNoon().contains(Constant.USER_NAME)
// || ccDuties.get(i).getEvening().contains(Constant.USER_NAME)
// || ccDuties.get(i).getClassLeaders().contains(Constant.USER_NAME)) {
// DutyPlanDutiesBean dutyPlanDutiesBean = new DutyPlanDutiesBean();
// dutyPlanDutiesBean.setDutyId(ccDuties.get(i).getId());
// dutyPlanDutiesBean.setLeader(ccDuties.get(i).getClassLeaders());
// dutyPlanDutiesBean.setMorning(ccDuties.get(i).getMorning());
// dutyPlanDutiesBean.setNoon(ccDuties.get(i).getNoon());
// dutyPlanDutiesBean.setEvening(ccDuties.get(i).getEvening());
// dutyPlanDutiesBean.setDutyDate(ccDuties.get(i).getDutyDate());
// dutyPlanDutiesBeen.add(dutyPlanDutiesBean);
// planDuties = dutyPlanDutiesBeen;
// zhibanInfoAdapter=new ZhibanInfoAdapter(planDuties);
// zbLv.setAdapter(zhibanInfoAdapter);
// }
}
planDuties = dutyPlanDutiesBeen;
zhibanInfoAdapter=new ZhibanInfoAdapter(planDuties);
zbLv.setAdapter(zhibanInfoAdapter);
},Throwable::printStackTrace);
}
private void initView() {
......@@ -53,6 +132,17 @@ public class ZhibanInfoActivity extends BaseActivity implements AdapterView.OnIt
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(ZhibanInfoActivity.this, ZhibanDetailsActivity.class);
intent.putExtra("dutyId", planDuties.get(position).getDutyId());
intent.putExtra("dutyTime", planDuties.get(position).getDutyDate());
intent.putExtra("dutyLeader", planDuties.get(position).getLeader());
String type = planDuties.get(position).getType();
if (type.equals("0")) {
intent.putExtra("dutyPersonMorning", planDuties.get(position).getMorning());
} else if (type.equals("1")) {
intent.putExtra("dutyPersonNoon", planDuties.get(position).getNoon());
} else if (type.equals("2")) {
intent.putExtra("dutyPersonEvening", planDuties.get(position).getEvening());
}
intent.putExtra("shift", type);
startActivity(intent);
}
......
......@@ -35,7 +35,16 @@ public class ZhibanTableActivity extends BaseActivity {
setContentView(R.layout.activity_zhiban_table);
ButterKnife.bind(this);
// zbTableLv.setAdapter(new ZhibanTableAdapter(TestBean.testBeen()));
queryRecord();
// queryRecord();
initData();
}
private void initData() {
dutyPlanClient.dutiesRecord()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ccDuties -> zbTableLv.setAdapter(new ZhibanTableAdapter(ccDuties))
,Throwable::printStackTrace);
}
private void queryRecord() {
......@@ -73,8 +82,10 @@ public class ZhibanTableActivity extends BaseActivity {
.subscribe(new Consumer<List<DutyPlanDutiesBean>>() {
@Override
public void accept(List<DutyPlanDutiesBean> dutyPlanDutiesBeen) throws Exception {
zbTableLv.setAdapter(new ZhibanTableAdapter(dutyPlanDutiesBeen));
}
}, Throwable::printStackTrace);
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/check_all" android:state_checked="true"/>
<item android:drawable="@drawable/check_no" android:state_checked="false"/>
<item android:drawable="@drawable/check_no"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/loding2"
android:pivotX="50.0%"
android:pivotY="50.0%" />
<?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:background="#fff"
android:orientation="vertical">
<include layout="@layout/conn" />
<Button
android:id="@+id/bt_select"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:clickable="false"
android:text="按职位选择"
android:visibility="gone" />
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="horizontal"
android:visibility="gone"
android:padding="3dp">
<RadioButton
android:id="@+id/radio_butten01"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="部门分组"
android:textColor="#333333"
android:textSize="@dimen/detail_left_text_size" />
<RadioButton
android:id="@+id/radio_butten02"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="群组"
/>
</RadioGroup>
<RelativeLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"></RelativeLayout>
</LinearLayout>
\ No newline at end of file
<?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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="cn.bsl.bxbg.zhiban.view.DutyTransferActivity">
<include layout="@layout/conn" />
<android.support.design.widget.TabLayout
android:id="@+id/jj_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF"
app:tabSelectedTextColor="@color/colorAccent"
>
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/jj_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:visibility="gone"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="已交班"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:visibility="gone"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="待接班"
/>
</LinearLayout>
</LinearLayout>
......@@ -10,7 +10,9 @@
<include layout="@layout/conn" />
<ImageView
android:layout_width="match_parent"
android:layout_height="120dp" />
android:layout_height="wrap_content"
android:background="@drawable/banner"
/>
<GridView
android:id="@+id/home_gv"
android:layout_width="match_parent"
......
......@@ -25,7 +25,12 @@
android:background="@null"
android:gravity="top"
android:hint="请输入原因" />
<CheckBox
android:id="@+id/daibanLeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="带班领导"
/>
<LinearLayout
android:id="@+id/choose_time"
android:layout_width="match_parent"
......
......@@ -79,6 +79,30 @@
android:textSize="16sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#000"
android:text="值班部门"
/>
<TextView
android:id="@+id/duty_dept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="部门"
android:layout_marginLeft="10dp"
android:textSize="16sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -8,9 +8,20 @@
tools:context="cn.bsl.bxbg.zhiban.view.TiaobanRecordActivity">
<include layout="@layout/conn" />
<ListView
android:id="@+id/tbLv"
<android.support.design.widget.TabLayout
android:id="@+id/tb_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="wrap_content"
android:background="#FFF"
app:tabSelectedTextColor="@color/colorAccent"
>
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tb_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
<?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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="cn.bsl.bxbg.zhiban.view.TiaobanRecordActivity">
<include layout="@layout/conn" />
<ListView
android:id="@+id/tbLv"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
<?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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="cn.bsl.bxbg.zhiban.view.WaitMeActivity">
<include layout="@layout/conn" />
<android.support.design.widget.TabLayout
android:id="@+id/tb_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF"
app:tabSelectedTextColor="@color/colorAccent"
>
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:id="@+id/tb_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
......@@ -48,6 +48,34 @@
android:textSize="20sp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="值班部门"
android:textColor="#4a4a4a" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/duty_dept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="部门"
android:textColor="#4a4a4a"
android:textSize="20sp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -60,24 +88,55 @@
</LinearLayout>
<LinearLayout
android:id="@+id/tb"
android:id="@+id/tbs"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="vertical"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="#00BF8B"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true">
android:layout_alignParentStart="true">
<LinearLayout
android:id="@+id/tb"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:background="#bfbfbf"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:layout_gravity="center"
android:text="调班"
/>
android:layout_weight="0.5"
>
<TextView
android:id="@+id/tvTiaoban"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:text="调班"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/start_zb"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:background="#00BF8B"
android:layout_weight="0.5"
>
<TextView
android:id="@+id/tvZhiban"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:text="开始值班"
/>
</LinearLayout>
</LinearLayout>
......@@ -85,6 +144,6 @@
android:id="@+id/zb_people"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/tb"
android:layout_above="@id/tbs"
android:layout_below="@id/ll_zb_info" />
</RelativeLayout>
<?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:background="#FFF"
android:orientation="horizontal"
android:padding="10dp" >
<RadioButton
android:id="@+id/chbChild"
style="@style/CustomCheckboxTheme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:clickable="false"
android:focusable="false"
android:scaleX="1.5"
android:scaleY="1.5" />
<ImageView
android:id="@+id/img"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:background="@drawable/person_icon" />
<LinearLayout
android:id="@+id/linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@id/img"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666"
android:textSize="16sp" />
<TextView
android:id="@+id/tvChild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#666"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -14,20 +14,33 @@
<ImageView
android:id="@+id/back"
android:layout_width="30dp"
android:layout_height="25dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_weight="0.05"
android:src="@drawable/fanhui" />
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="30dp"
android:gravity="center"
android:layout_marginLeft="20dp"
android:text=""
android:layout_weight="0.79"
android:textColor="#00BF8B"
android:textSize="17sp" />
<TextView
android:id="@+id/save"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.18"
android:visibility="gone"
android:textColor="#00BF8B"
android:text="保存"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?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:background="@drawable/pull"
android:orientation="horizontal"
android:padding="10dp" >
<!-- android:button="@null" -->
<CheckBox
android:id="@+id/chbGroup"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:button="@null"
android:focusable="false" />
<TextView
android:id="@+id/tvGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:textColor="#898989"
android:textSize="14sp" >
</TextView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/zb_info"
/>
android:src="@drawable/zb_info" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="发布记录"
/>
android:text="发布记录" />
</LinearLayout>
\ No newline at end of file
......@@ -31,6 +31,7 @@
>
<TextView
android:id="@+id/zb_name_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="值班领导:"
......
<?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="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:id="@+id/checkbox"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:id="@+id/tv_name"/>
</LinearLayout>
<?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" >
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_list"
android:divider="#e8e8e8"
android:scrollbars="none"
android:dividerHeight="1dp"/>
</LinearLayout>
<?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/conn" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center"
android:text="值班时间:"
/>
<TextView
android:id="@+id/shift_zb_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center"
android:text="2018-05-20"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#B3ECDD" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center"
android:text="值班班次:"
/>
<TextView
android:id="@+id/shift_zb_shift"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center"
android:text="早"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#B3ECDD" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:layout_marginLeft="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center"
android:text="值班人员:"
/>
<TextView
android:id="@+id/shift_zb_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_gravity="center"
android:text="赵睿"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#B3ECDD" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="值班内容:"
/>
<EditText
android:id="@+id/shift_zb_content"
android:layout_width="match_parent"
android:layout_height="300dp"
android:textSize="16sp"
android:gravity="top"
android:background="@null"
android:hint="请输入值班内容"
/>
</LinearLayout>
<Button
android:id="@+id/btn_ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="确定交班"
android:background="@drawable/sign_button_shape"
android:layout_margin="10dp"
android:textColor="#FFF"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
\ No newline at end of file
<?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:background="#FFF"
android:orientation="vertical">
<ListView
android:id="@+id/not_finish_lv"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/none"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="18sp"
android:text="暂无数据"
android:visibility="gone"
/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/ic_widget_dialog_load_bg"
android:gravity="center"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/widget_dialog_loading_icon"
style="?android:attr/progressBarStyleLargeInverse"
android:layout_width="30dp"
android:layout_height="30dp"
android:indeterminateDrawable="@drawable/dialog_loading1"
android:visibility="visible" />
<TextView
android:id="@+id/widget_dialog_loading_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="加载中"
android:textAppearance="@style/dialog_load_white_font"
android:textColor="#FFF" />
</LinearLayout>
\ No newline at end of file
......@@ -3,4 +3,5 @@
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#00BF8B</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="detail_left_text_size">16sp</dimen>
</resources>
\ No newline at end of file
......@@ -8,4 +8,24 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_style</item>
</style>
<style name="dialog_load_white_font">
<item name="android:textColor">#FFF</item>
<item name="android:textSize">16sp</item>
</style>
<style name="popup_dialog_style" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowBackground">@color/transparent</item>
</style>
</resources>
include ':app'
include ':app', ':treeview_lib'
/build
/bintray.gradle
\ No newline at end of file
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
}
//apply from: "bintray.gradle"
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/zxy/AndroidStudioProjects/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.texy.treeview">
<!--<application android:allowBackup="true" android:label="@string/app_name"-->
<!--android:supportsRtl="true">-->
<!--</application>-->
</manifest>
package me.texy.treeview;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.ScrollView;
/**
* Created by Administrator on 2017/8/14 0014.
*/
public class MyScrollview extends ScrollView {
private int downX;
private int downY;
private int mTouchSlop;
public MyScrollview(Context context) {
super(context);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
public MyScrollview(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
public MyScrollview(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
int action = e.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
downX = (int) e.getRawX();
downY = (int) e.getRawY();
break;
case MotionEvent.ACTION_MOVE:
int moveY = (int) e.getRawY();
if (Math.abs(moveY - downY) > mTouchSlop) {
return true;
}
}
return super.onInterceptTouchEvent(e);
}
}
\ No newline at end of file
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import me.texy.treeview.util.StringUtil;
/**
* Created by xinyuanzhong on 2017/4/20.
*/
public class TreeNode implements Serializable {
private int level;
private String userId;
private boolean isPerson;
private Object value;
private TreeNode parent;
private List<TreeNode> children;
private int index;
private boolean expanded;
private boolean selected;
private boolean itemClickEnable = true;
public TreeNode(Object value) {
this.value = value;
this.children = new ArrayList<>();
}
public TreeNode(Object value, String id) {
this.value = value;
this.userId = id;
this.children = new ArrayList<>();
this.isPerson = StringUtil.isInteger(id);
}
public static TreeNode root() {
TreeNode treeNode = new TreeNode(null);
return treeNode;
}
public void addChild(TreeNode treeNode) {
if (treeNode == null) {
return;
}
children.add(treeNode);
treeNode.setIndex(getChildren().size());
treeNode.setParent(this);
}
public void removeChild(TreeNode treeNode) {
if (treeNode == null || getChildren().size() < 1) {
return;
}
if (getChildren().indexOf(treeNode) != -1) {
getChildren().remove(treeNode);
}
}
public boolean isLastChild() {
if (parent == null) {
return false;
}
List<TreeNode> children = parent.getChildren();
return children.size() > 0 && children.indexOf(this) == children.size() - 1;
}
public boolean isRoot() {
return parent == null;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public TreeNode getParent() {
return parent;
}
public void setParent(TreeNode parent) {
this.parent = parent;
}
public List<TreeNode> getChildren() {
if (children == null) {
return new ArrayList<>();
}
return children;
}
public void setChildren(List<TreeNode> children) {
this.children = children;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
public boolean isExpanded() {
return expanded;
}
public boolean hasChild() {
return children.size() > 0;
}
public boolean isItemClickEnable() {
return itemClickEnable;
}
public void setItemClickEnable(boolean itemClickEnable) {
this.itemClickEnable = itemClickEnable;
}
public String getId() {
return getLevel() + "," + getIndex();
}
private int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public boolean isPerson() {
return isPerson;
}
public void setPerson(boolean person) {
isPerson = person;
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SimpleItemAnimator;
import android.view.View;
import java.util.List;
import me.texy.treeview.base.BaseNodeViewFactory;
import me.texy.treeview.base.SelectableTreeAction;
import me.texy.treeview.helper.TreeHelper;
import me.texy.treeview.util.RecycleViewDivider;
/**
* Created by xinyuanzhong on 2017/4/20.
*/
public class TreeView implements SelectableTreeAction,TreeViewAdapter.OnSingleCheckedListener {
private TreeNode root;
private Context context;
private BaseNodeViewFactory baseNodeViewFactory;
private RecyclerView rootView;
private TreeViewAdapter adapter;
private boolean itemSelectable = true;
public void setItemAnimator(RecyclerView.ItemAnimator itemAnimator) {
this.itemAnimator = itemAnimator;
if (rootView != null && itemAnimator != null) {
rootView.setItemAnimator(itemAnimator);
}
}
private RecyclerView.ItemAnimator itemAnimator;
public TreeNode getSingleTreeNode() {
return singleTreeNode;
}
public void setSingleTreeNode(TreeNode singleTreeNode) {
this.singleTreeNode = singleTreeNode;
}
private TreeNode singleTreeNode;
public TreeView(@NonNull TreeNode root, @NonNull Context context, @NonNull BaseNodeViewFactory baseNodeViewFactory) {
this.root = root;
this.context = context;
this.baseNodeViewFactory = baseNodeViewFactory;
if (baseNodeViewFactory == null) {
throw new IllegalArgumentException("You must assign a BaseNodeViewFactory!");
}
}
public View getView() {
if (rootView == null) {
this.rootView = buildRootView();
}
return rootView;
}
@NonNull
private RecyclerView buildRootView() {
RecyclerView recyclerView = new RecyclerView(context);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
/**
* disable multi touch event to prevent terrible data set error when calculate list.
*/
recyclerView.setMotionEventSplittingEnabled(false);
SimpleItemAnimator itemAnimator = (SimpleItemAnimator) recyclerView.getItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);
recyclerView.setItemAnimator(itemAnimator);
recyclerView.addItemDecoration(new RecycleViewDivider(context, LinearLayoutManager.VERTICAL, 10, context.getResources().getColor(R.color.line)));
adapter = new TreeViewAdapter(context, root, baseNodeViewFactory);
adapter.setTreeView(this);
recyclerView.setAdapter(adapter);
return recyclerView;
}
@Override
public void expandAll() {
if (root == null) {
return;
}
TreeHelper.expandAll(root);
refreshTreeView();
}
public void refreshTreeView() {
if (rootView != null) {
((TreeViewAdapter) rootView.getAdapter()).refreshView();
}
}
@Override
public void expandNode(TreeNode treeNode) {
adapter.expandNode(treeNode);
}
@Override
public void expandLevel(int level) {
TreeHelper.expandLevel(root, level);
refreshTreeView();
}
@Override
public void collapseAll() {
if (root == null) {
return;
}
TreeHelper.collapseAll(root);
refreshTreeView();
}
@Override
public void collapseNode(TreeNode treeNode) {
adapter.collapseNode(treeNode);
}
@Override
public void collapseLevel(int level) {
TreeHelper.collapseLevel(root, level);
refreshTreeView();
}
@Override
public void toggleNode(TreeNode treeNode) {
if (treeNode.isExpanded()) {
collapseNode(treeNode);
} else {
expandNode(treeNode);
}
}
@Override
public void deleteNode(TreeNode node) {
adapter.deleteNode(node);
}
@Override
public void addNode(TreeNode parent, TreeNode treeNode) {
parent.addChild(treeNode);
refreshTreeView();
}
@Override
public List<TreeNode> getAllNodes() {
return TreeHelper.getAllNodes(root);
}
@Override
public void selectNode(TreeNode treeNode) {
if (treeNode != null) {
adapter.selectNode(true, treeNode);
}
}
@Override
public void deselectNode(TreeNode treeNode) {
if (treeNode != null) {
adapter.selectNode(false, treeNode);
}
}
@Override
public void selectAll() {
TreeHelper.selectNodeAndChild(root, true);
refreshTreeView();
}
@Override
public void deselectAll() {
TreeHelper.selectNodeAndChild(root, false);
refreshTreeView();
}
@Override
public List<TreeNode> getSelectedNodes() {
return TreeHelper.getSelectedNodes(root);
}
public boolean isItemSelectable() {
return itemSelectable;
}
public void setItemSelectable(boolean itemSelectable) {
this.itemSelectable = itemSelectable;
}
public void setAdapterSingleListener(){
adapter.setSingleCheckedListener(this);
}
public void setTreeViewSingleListener(TreeViewAdapter.OnSingleCheckedListener listener){
adapter.setSingleCheckedListener(listener);
}
@Override
public void singleChecked(TreeNode node) {
singleTreeNode=node;
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import java.util.ArrayList;
import java.util.List;
import me.texy.treeview.base.BaseNodeViewBinder;
import me.texy.treeview.base.BaseNodeViewFactory;
import me.texy.treeview.base.CheckableNodeViewBinder;
import me.texy.treeview.helper.TreeHelper;
/**
* Created by xinyuanzhong on 2017/4/21.
*/
public class TreeViewAdapter extends RecyclerView.Adapter {
private Context context;
/**
* Tree root.
*/
private TreeNode root;
/**
* The current data set of Adapter,which means excluding the collapsed nodes.
*/
private List<TreeNode> expandedNodeList;
/**
* The binder factory.A binder provide the layoutId which needed in method
* <code>onCreateViewHolder</code> and the way how to render ViewHolder.
*/
private BaseNodeViewFactory baseNodeViewFactory;
/**
* This parameter make no sense just for avoiding IllegalArgumentException of ViewHolder's
* constructor.
*/
private View EMPTY_PARAMETER;
private TreeView treeView;
private OnSingleCheckedListener listener;
public TreeViewAdapter(Context context, TreeNode root,
@NonNull BaseNodeViewFactory baseNodeViewFactory) {
this.context = context;
this.root = root;
this.baseNodeViewFactory = baseNodeViewFactory;
this.EMPTY_PARAMETER = new View(context);
this.expandedNodeList = new ArrayList<>();
buildExpandedNodeList();
}
//添加监听
public void setSingleCheckedListener(OnSingleCheckedListener listener){
this.listener=listener;
}
private void buildExpandedNodeList() {
expandedNodeList.clear();
for (TreeNode child : root.getChildren()) {
insertNode(expandedNodeList, child);
}
}
private void insertNode(List<TreeNode> nodeList, TreeNode treeNode) {
nodeList.add(treeNode);
if (!treeNode.hasChild()) {
return;
}
if (treeNode.isExpanded()) {
for (TreeNode child : treeNode.getChildren()) {
insertNode(nodeList, child);
}
}
}
@Override
public int getItemViewType(int position) {
return expandedNodeList.get(position).getLevel();
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int level) {
View view = LayoutInflater.from(context).inflate(baseNodeViewFactory
.getNodeViewBinder(EMPTY_PARAMETER, level).getLayoutId(), parent, false);
BaseNodeViewBinder nodeViewBinder = baseNodeViewFactory.getNodeViewBinder(view, level);
nodeViewBinder.setTreeView(treeView);
return nodeViewBinder;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final View nodeView = holder.itemView;
final TreeNode treeNode = expandedNodeList.get(position);
final BaseNodeViewBinder viewBinder = (BaseNodeViewBinder) holder;
if (viewBinder.getToggleTriggerViewId() != 0) {
View triggerToggleView = nodeView.findViewById(viewBinder.getToggleTriggerViewId());
if (triggerToggleView != null) {
triggerToggleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNodeToggled(treeNode);
viewBinder.onNodeToggled(treeNode, treeNode.isExpanded());
}
});
}
} else if (treeNode.isItemClickEnable()) {
nodeView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNodeToggled(treeNode);
viewBinder.onNodeToggled(treeNode, treeNode.isExpanded());
if(treeNode.isPerson()&& null!=listener)
listener.singleChecked(treeNode);
}
});
}
if (viewBinder instanceof CheckableNodeViewBinder) {
final View view = nodeView
.findViewById(((CheckableNodeViewBinder) viewBinder).getCheckableViewId());
if (view != null && view instanceof CheckBox) {
final CheckBox checkableView = (CheckBox) view;
checkableView.setChecked(treeNode.isSelected());
checkableView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = checkableView.isChecked();
selectNode(checked, treeNode);
((CheckableNodeViewBinder) viewBinder).onNodeSelectedChanged(treeNode, checked);
}
});
} else {
throw new ClassCastException("The getCheckableViewId() " +
"must return a CheckBox's id");
}
}
viewBinder.bindView(treeNode);
}
public void selectNode(boolean checked, TreeNode treeNode) {
treeNode.setSelected(checked);
selectChildren(treeNode, checked);
selectParentIfNeed(treeNode, checked);
}
private void selectChildren(TreeNode treeNode, boolean checked) {
List<TreeNode> impactedChildren = TreeHelper.selectNodeAndChild(treeNode, checked);
int index = expandedNodeList.indexOf(treeNode);
if (index != -1 && impactedChildren.size() > 0) {
notifyItemRangeChanged(index, impactedChildren.size() + 1);
}
}
private void selectParentIfNeed(TreeNode treeNode, boolean checked) {
List<TreeNode> impactedParents = TreeHelper.selectParentIfNeedWhenNodeSelected(treeNode, checked);
if (impactedParents.size() > 0) {
for (TreeNode parent : impactedParents) {
int position = expandedNodeList.indexOf(parent);
if (position != -1) notifyItemChanged(position);
}
}
}
private void onNodeToggled(TreeNode treeNode) {
treeNode.setExpanded(!treeNode.isExpanded());
if (treeNode.isExpanded()) {
expandNode(treeNode);
} else {
collapseNode(treeNode);
}
}
@Override
public int getItemCount() {
return expandedNodeList == null ? 0 : expandedNodeList.size();
}
/**
* Refresh all,this operation is only used for refreshing list when a large of nodes have
* changed value or structure because it take much calculation.
*/
public void refreshView() {
buildExpandedNodeList();
notifyDataSetChanged();
}
/**
* Insert a node list after index.
*
* @param index the index before new addition nodes's first position
* @param additionNodes nodes to add
*/
private void insertNodesAtIndex(int index, List<TreeNode> additionNodes) {
if (index < 0 || index > expandedNodeList.size() - 1 || additionNodes == null) {
return;
}
expandedNodeList.addAll(index + 1, additionNodes);
notifyItemRangeInserted(index + 1, additionNodes.size());
}
/**
* Remove a node list after index.
*
* @param index the index before the removedNodes nodes's first position
* @param removedNodes nodes to remove
*/
private void removeNodesAtIndex(int index, List<TreeNode> removedNodes) {
if (index < 0 || index > expandedNodeList.size() - 1 || removedNodes == null) {
return;
}
expandedNodeList.removeAll(removedNodes);
notifyItemRangeRemoved(index + 1, removedNodes.size());
}
/**
* Expand node. This operation will keep the structure of children(not expand children)
*
* @param treeNode
*/
public void expandNode(TreeNode treeNode) {
if (treeNode == null) {
return;
}
List<TreeNode> additionNodes = TreeHelper.expandNode(treeNode, false);
int index = expandedNodeList.indexOf(treeNode);
insertNodesAtIndex(index, additionNodes);
}
/**
* Collapse node. This operation will keep the structure of children(not collapse children)
*
* @param treeNode
*/
public void collapseNode(TreeNode treeNode) {
if (treeNode == null) {
return;
}
List<TreeNode> removedNodes = TreeHelper.collapseNode(treeNode, false);
int index = expandedNodeList.indexOf(treeNode);
removeNodesAtIndex(index, removedNodes);
}
/**
* Delete a node from list.This operation will also delete its children.
*
* @param node
*/
public void deleteNode(TreeNode node) {
if (node == null || node.getParent() == null) {
return;
}
List<TreeNode> allNodes = TreeHelper.getAllNodes(root);
if (allNodes.indexOf(node) != -1) {
node.getParent().removeChild(node);
}
//remove children form list before delete
collapseNode(node);
int index = expandedNodeList.indexOf(node);
if (index != -1) {
expandedNodeList.remove(node);
}
notifyItemRemoved(index);
}
public void setTreeView(TreeView treeView) {
this.treeView = treeView;
}
//单选按钮功能
public interface OnSingleCheckedListener{
void singleChecked(TreeNode TreeNode);
}
}
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.texy.treeview.animator;
import android.support.annotation.NonNull;
import android.support.v4.animation.AnimatorCompatHelper;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.support.v7.widget.SimpleItemAnimator;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
/**
* This implementation of RecyclerView.ItemAnimator provides basic
* animations on remove, add, and move events that happen to the items in
* a RecyclerView. RecyclerView uses a DefaultItemAnimator by default.
*/
public class DefaultItemAnimator extends SimpleItemAnimator {
private static final boolean DEBUG = false;
private ArrayList<ViewHolder> mPendingRemovals = new ArrayList<>();
private ArrayList<ViewHolder> mPendingAdditions = new ArrayList<>();
private ArrayList<MoveInfo> mPendingMoves = new ArrayList<>();
private ArrayList<ChangeInfo> mPendingChanges = new ArrayList<>();
ArrayList<ArrayList<ViewHolder>> mAdditionsList = new ArrayList<>();
ArrayList<ArrayList<MoveInfo>> mMovesList = new ArrayList<>();
ArrayList<ArrayList<ChangeInfo>> mChangesList = new ArrayList<>();
ArrayList<ViewHolder> mAddAnimations = new ArrayList<>();
ArrayList<ViewHolder> mMoveAnimations = new ArrayList<>();
ArrayList<ViewHolder> mRemoveAnimations = new ArrayList<>();
ArrayList<ViewHolder> mChangeAnimations = new ArrayList<>();
private static class MoveInfo {
public ViewHolder holder;
public int fromX, fromY, toX, toY;
MoveInfo(ViewHolder holder, int fromX, int fromY, int toX, int toY) {
this.holder = holder;
this.fromX = fromX;
this.fromY = fromY;
this.toX = toX;
this.toY = toY;
}
}
private static class ChangeInfo {
public ViewHolder oldHolder, newHolder;
public int fromX, fromY, toX, toY;
private ChangeInfo(ViewHolder oldHolder, ViewHolder newHolder) {
this.oldHolder = oldHolder;
this.newHolder = newHolder;
}
ChangeInfo(ViewHolder oldHolder, ViewHolder newHolder,
int fromX, int fromY, int toX, int toY) {
this(oldHolder, newHolder);
this.fromX = fromX;
this.fromY = fromY;
this.toX = toX;
this.toY = toY;
}
@Override
public String toString() {
return "ChangeInfo{" +
"oldHolder=" + oldHolder +
", newHolder=" + newHolder +
", fromX=" + fromX +
", fromY=" + fromY +
", toX=" + toX +
", toY=" + toY +
'}';
}
}
@Override
public void runPendingAnimations() {
boolean removalsPending = !mPendingRemovals.isEmpty();
boolean movesPending = !mPendingMoves.isEmpty();
boolean changesPending = !mPendingChanges.isEmpty();
boolean additionsPending = !mPendingAdditions.isEmpty();
if (!removalsPending && !movesPending && !additionsPending && !changesPending) {
// nothing to animate
return;
}
// First, remove stuff
for (ViewHolder holder : mPendingRemovals) {
animateRemoveImpl(holder);
}
mPendingRemovals.clear();
// Next, move stuff
if (movesPending) {
final ArrayList<MoveInfo> moves = new ArrayList<>();
moves.addAll(mPendingMoves);
mMovesList.add(moves);
mPendingMoves.clear();
Runnable mover = new Runnable() {
@Override
public void run() {
for (MoveInfo moveInfo : moves) {
animateMoveImpl(moveInfo.holder, moveInfo.fromX, moveInfo.fromY,
moveInfo.toX, moveInfo.toY);
}
moves.clear();
mMovesList.remove(moves);
}
};
if (removalsPending) {
View view = moves.get(0).holder.itemView;
ViewCompat.postOnAnimationDelayed(view, mover, getRemoveDuration());
} else {
mover.run();
}
}
// Next, change stuff, to run in parallel with move animations
if (changesPending) {
final ArrayList<ChangeInfo> changes = new ArrayList<>();
changes.addAll(mPendingChanges);
mChangesList.add(changes);
mPendingChanges.clear();
Runnable changer = new Runnable() {
@Override
public void run() {
for (ChangeInfo change : changes) {
animateChangeImpl(change);
}
changes.clear();
mChangesList.remove(changes);
}
};
if (removalsPending) {
ViewHolder holder = changes.get(0).oldHolder;
ViewCompat.postOnAnimationDelayed(holder.itemView, changer, getRemoveDuration());
} else {
changer.run();
}
}
// Next, add stuff
if (additionsPending) {
final ArrayList<ViewHolder> additions = new ArrayList<>();
additions.addAll(mPendingAdditions);
mAdditionsList.add(additions);
mPendingAdditions.clear();
Runnable adder = new Runnable() {
@Override
public void run() {
for (ViewHolder holder : additions) {
animateAddImpl(holder);
}
additions.clear();
mAdditionsList.remove(additions);
}
};
if (removalsPending || movesPending || changesPending) {
long removeDuration = removalsPending ? getRemoveDuration() : 0;
long moveDuration = movesPending ? getMoveDuration() : 0;
long changeDuration = changesPending ? getChangeDuration() : 0;
long totalDelay = removeDuration + Math.max(moveDuration, changeDuration);
View view = additions.get(0).itemView;
ViewCompat.postOnAnimationDelayed(view, adder, totalDelay);
} else {
adder.run();
}
}
}
@Override
public boolean animateRemove(final ViewHolder holder) {
resetAnimation(holder);
mPendingRemovals.add(holder);
return true;
}
protected void animateRemoveImpl(final ViewHolder holder) {
final View view = holder.itemView;
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
mRemoveAnimations.add(holder);
animation.setDuration(getRemoveDuration())
.alpha(0).setListener(new VpaListenerAdapter() {
@Override
public void onAnimationStart(View view) {
dispatchRemoveStarting(holder);
}
@Override
public void onAnimationEnd(View view) {
animation.setListener(null);
ViewCompat.setAlpha(view, 1);
dispatchRemoveFinished(holder);
mRemoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
@Override
public boolean animateAdd(final ViewHolder holder) {
resetAnimation(holder);
ViewCompat.setAlpha(holder.itemView, 0);
mPendingAdditions.add(holder);
return true;
}
protected void animateAddImpl(final ViewHolder holder) {
final View view = holder.itemView;
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
mAddAnimations.add(holder);
animation.alpha(1).setDuration(getAddDuration()).
setListener(new VpaListenerAdapter() {
@Override
public void onAnimationStart(View view) {
dispatchAddStarting(holder);
}
@Override
public void onAnimationCancel(View view) {
ViewCompat.setAlpha(view, 1);
}
@Override
public void onAnimationEnd(View view) {
animation.setListener(null);
dispatchAddFinished(holder);
mAddAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY,
int toX, int toY) {
final View view = holder.itemView;
fromX += ViewCompat.getTranslationX(holder.itemView);
fromY += ViewCompat.getTranslationY(holder.itemView);
resetAnimation(holder);
int deltaX = toX - fromX;
int deltaY = toY - fromY;
if (deltaX == 0 && deltaY == 0) {
dispatchMoveFinished(holder);
return false;
}
if (deltaX != 0) {
ViewCompat.setTranslationX(view, -deltaX);
}
if (deltaY != 0) {
ViewCompat.setTranslationY(view, -deltaY);
}
mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
return true;
}
protected void animateMoveImpl(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
final View view = holder.itemView;
final int deltaX = toX - fromX;
final int deltaY = toY - fromY;
if (deltaX != 0) {
ViewCompat.animate(view).translationX(0);
}
if (deltaY != 0) {
ViewCompat.animate(view).translationY(0);
}
// TODO: make EndActions end listeners instead, since end actions aren't called when
// vpas are canceled (and can't end them. why?)
// need listener functionality in VPACompat for this. Ick.
final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
mMoveAnimations.add(holder);
animation.setDuration(getMoveDuration()).setListener(new VpaListenerAdapter() {
@Override
public void onAnimationStart(View view) {
dispatchMoveStarting(holder);
}
@Override
public void onAnimationCancel(View view) {
if (deltaX != 0) {
ViewCompat.setTranslationX(view, 0);
}
if (deltaY != 0) {
ViewCompat.setTranslationY(view, 0);
}
}
@Override
public void onAnimationEnd(View view) {
animation.setListener(null);
dispatchMoveFinished(holder);
mMoveAnimations.remove(holder);
dispatchFinishedWhenDone();
}
}).start();
}
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,
int fromX, int fromY, int toX, int toY) {
if (oldHolder == newHolder) {
// Don't know how to run change animations when the same view holder is re-used.
// run a move animation to handle position changes.
return animateMove(oldHolder, fromX, fromY, toX, toY);
}
final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
resetAnimation(oldHolder);
int deltaX = (int) (toX - fromX - prevTranslationX);
int deltaY = (int) (toY - fromY - prevTranslationY);
// recover prev translation state after ending animation
ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
if (newHolder != null) {
// carry over translation values
resetAnimation(newHolder);
ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
ViewCompat.setAlpha(newHolder.itemView, 0);
}
mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
return true;
}
protected void animateChangeImpl(final ChangeInfo changeInfo) {
final ViewHolder holder = changeInfo.oldHolder;
final View view = holder == null ? null : holder.itemView;
final ViewHolder newHolder = changeInfo.newHolder;
final View newView = newHolder != null ? newHolder.itemView : null;
if (view != null) {
final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view).setDuration(
getChangeDuration());
mChangeAnimations.add(changeInfo.oldHolder);
oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() {
@Override
public void onAnimationStart(View view) {
dispatchChangeStarting(changeInfo.oldHolder, true);
}
@Override
public void onAnimationEnd(View view) {
oldViewAnim.setListener(null);
ViewCompat.setAlpha(view, 1);
ViewCompat.setTranslationX(view, 0);
ViewCompat.setTranslationY(view, 0);
dispatchChangeFinished(changeInfo.oldHolder, true);
mChangeAnimations.remove(changeInfo.oldHolder);
dispatchFinishedWhenDone();
}
}).start();
}
if (newView != null) {
final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
mChangeAnimations.add(changeInfo.newHolder);
newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).
alpha(1).setListener(new VpaListenerAdapter() {
@Override
public void onAnimationStart(View view) {
dispatchChangeStarting(changeInfo.newHolder, false);
}
@Override
public void onAnimationEnd(View view) {
newViewAnimation.setListener(null);
ViewCompat.setAlpha(newView, 1);
ViewCompat.setTranslationX(newView, 0);
ViewCompat.setTranslationY(newView, 0);
dispatchChangeFinished(changeInfo.newHolder, false);
mChangeAnimations.remove(changeInfo.newHolder);
dispatchFinishedWhenDone();
}
}).start();
}
}
private void endChangeAnimation(List<ChangeInfo> infoList, ViewHolder item) {
for (int i = infoList.size() - 1; i >= 0; i--) {
ChangeInfo changeInfo = infoList.get(i);
if (endChangeAnimationIfNecessary(changeInfo, item)) {
if (changeInfo.oldHolder == null && changeInfo.newHolder == null) {
infoList.remove(changeInfo);
}
}
}
}
private void endChangeAnimationIfNecessary(ChangeInfo changeInfo) {
if (changeInfo.oldHolder != null) {
endChangeAnimationIfNecessary(changeInfo, changeInfo.oldHolder);
}
if (changeInfo.newHolder != null) {
endChangeAnimationIfNecessary(changeInfo, changeInfo.newHolder);
}
}
private boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, ViewHolder item) {
boolean oldItem = false;
if (changeInfo.newHolder == item) {
changeInfo.newHolder = null;
} else if (changeInfo.oldHolder == item) {
changeInfo.oldHolder = null;
oldItem = true;
} else {
return false;
}
ViewCompat.setAlpha(item.itemView, 1);
ViewCompat.setTranslationX(item.itemView, 0);
ViewCompat.setTranslationY(item.itemView, 0);
dispatchChangeFinished(item, oldItem);
return true;
}
@Override
public void endAnimation(ViewHolder item) {
final View view = item.itemView;
// this will trigger end callback which should set properties to their target values.
ViewCompat.animate(view).cancel();
// TODO if some other animations are chained to end, how do we cancel them as well?
for (int i = mPendingMoves.size() - 1; i >= 0; i--) {
MoveInfo moveInfo = mPendingMoves.get(i);
if (moveInfo.holder == item) {
ViewCompat.setTranslationY(view, 0);
ViewCompat.setTranslationX(view, 0);
dispatchMoveFinished(item);
mPendingMoves.remove(i);
}
}
endChangeAnimation(mPendingChanges, item);
if (mPendingRemovals.remove(item)) {
ViewCompat.setAlpha(view, 1);
dispatchRemoveFinished(item);
}
if (mPendingAdditions.remove(item)) {
ViewCompat.setAlpha(view, 1);
dispatchAddFinished(item);
}
for (int i = mChangesList.size() - 1; i >= 0; i--) {
ArrayList<ChangeInfo> changes = mChangesList.get(i);
endChangeAnimation(changes, item);
if (changes.isEmpty()) {
mChangesList.remove(i);
}
}
for (int i = mMovesList.size() - 1; i >= 0; i--) {
ArrayList<MoveInfo> moves = mMovesList.get(i);
for (int j = moves.size() - 1; j >= 0; j--) {
MoveInfo moveInfo = moves.get(j);
if (moveInfo.holder == item) {
ViewCompat.setTranslationY(view, 0);
ViewCompat.setTranslationX(view, 0);
dispatchMoveFinished(item);
moves.remove(j);
if (moves.isEmpty()) {
mMovesList.remove(i);
}
break;
}
}
}
for (int i = mAdditionsList.size() - 1; i >= 0; i--) {
ArrayList<ViewHolder> additions = mAdditionsList.get(i);
if (additions.remove(item)) {
ViewCompat.setAlpha(view, 1);
dispatchAddFinished(item);
if (additions.isEmpty()) {
mAdditionsList.remove(i);
}
}
}
// animations should be ended by the cancel above.
//noinspection PointlessBooleanExpression,ConstantConditions
if (mRemoveAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mRemoveAnimations list");
}
//noinspection PointlessBooleanExpression,ConstantConditions
if (mAddAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mAddAnimations list");
}
//noinspection PointlessBooleanExpression,ConstantConditions
if (mChangeAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mChangeAnimations list");
}
//noinspection PointlessBooleanExpression,ConstantConditions
if (mMoveAnimations.remove(item) && DEBUG) {
throw new IllegalStateException("after animation is cancelled, item should not be in "
+ "mMoveAnimations list");
}
dispatchFinishedWhenDone();
}
private void resetAnimation(ViewHolder holder) {
AnimatorCompatHelper.clearInterpolator(holder.itemView);
endAnimation(holder);
}
@Override
public boolean isRunning() {
return (!mPendingAdditions.isEmpty() ||
!mPendingChanges.isEmpty() ||
!mPendingMoves.isEmpty() ||
!mPendingRemovals.isEmpty() ||
!mMoveAnimations.isEmpty() ||
!mRemoveAnimations.isEmpty() ||
!mAddAnimations.isEmpty() ||
!mChangeAnimations.isEmpty() ||
!mMovesList.isEmpty() ||
!mAdditionsList.isEmpty() ||
!mChangesList.isEmpty());
}
/**
* Check the state of currently pending and running animations. If there are none
* pending/running, call {@link #dispatchAnimationsFinished()} to notify any
* listeners.
*/
void dispatchFinishedWhenDone() {
if (!isRunning()) {
dispatchAnimationsFinished();
}
}
@Override
public void endAnimations() {
int count = mPendingMoves.size();
for (int i = count - 1; i >= 0; i--) {
MoveInfo item = mPendingMoves.get(i);
View view = item.holder.itemView;
ViewCompat.setTranslationY(view, 0);
ViewCompat.setTranslationX(view, 0);
dispatchMoveFinished(item.holder);
mPendingMoves.remove(i);
}
count = mPendingRemovals.size();
for (int i = count - 1; i >= 0; i--) {
ViewHolder item = mPendingRemovals.get(i);
dispatchRemoveFinished(item);
mPendingRemovals.remove(i);
}
count = mPendingAdditions.size();
for (int i = count - 1; i >= 0; i--) {
ViewHolder item = mPendingAdditions.get(i);
View view = item.itemView;
ViewCompat.setAlpha(view, 1);
dispatchAddFinished(item);
mPendingAdditions.remove(i);
}
count = mPendingChanges.size();
for (int i = count - 1; i >= 0; i--) {
endChangeAnimationIfNecessary(mPendingChanges.get(i));
}
mPendingChanges.clear();
if (!isRunning()) {
return;
}
int listCount = mMovesList.size();
for (int i = listCount - 1; i >= 0; i--) {
ArrayList<MoveInfo> moves = mMovesList.get(i);
count = moves.size();
for (int j = count - 1; j >= 0; j--) {
MoveInfo moveInfo = moves.get(j);
ViewHolder item = moveInfo.holder;
View view = item.itemView;
ViewCompat.setTranslationY(view, 0);
ViewCompat.setTranslationX(view, 0);
dispatchMoveFinished(moveInfo.holder);
moves.remove(j);
if (moves.isEmpty()) {
mMovesList.remove(moves);
}
}
}
listCount = mAdditionsList.size();
for (int i = listCount - 1; i >= 0; i--) {
ArrayList<ViewHolder> additions = mAdditionsList.get(i);
count = additions.size();
for (int j = count - 1; j >= 0; j--) {
ViewHolder item = additions.get(j);
View view = item.itemView;
ViewCompat.setAlpha(view, 1);
dispatchAddFinished(item);
additions.remove(j);
if (additions.isEmpty()) {
mAdditionsList.remove(additions);
}
}
}
listCount = mChangesList.size();
for (int i = listCount - 1; i >= 0; i--) {
ArrayList<ChangeInfo> changes = mChangesList.get(i);
count = changes.size();
for (int j = count - 1; j >= 0; j--) {
endChangeAnimationIfNecessary(changes.get(j));
if (changes.isEmpty()) {
mChangesList.remove(changes);
}
}
}
cancelAll(mRemoveAnimations);
cancelAll(mMoveAnimations);
cancelAll(mAddAnimations);
cancelAll(mChangeAnimations);
dispatchAnimationsFinished();
}
void cancelAll(List<ViewHolder> viewHolders) {
for (int i = viewHolders.size() - 1; i >= 0; i--) {
ViewCompat.animate(viewHolders.get(i).itemView).cancel();
}
}
/**
* {@inheritDoc}
* <p>
* If the payload list is not empty, DefaultItemAnimator returns <code>true</code>.
* When this is the case:
* <ul>
* <li>If you override {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)}, both
* ViewHolder arguments will be the same instance.
* </li>
* <li>
* If you are not overriding {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)},
* then DefaultItemAnimator will call {@link #animateMove(ViewHolder, int, int, int, int)} and
* run a move animation instead.
* </li>
* </ul>
*/
@Override
public boolean canReuseUpdatedViewHolder(@NonNull ViewHolder viewHolder,
@NonNull List<Object> payloads) {
return !payloads.isEmpty() || super.canReuseUpdatedViewHolder(viewHolder, payloads);
}
private static class VpaListenerAdapter implements ViewPropertyAnimatorListener {
VpaListenerAdapter() {
}
@Override
public void onAnimationStart(View view) {
}
@Override
public void onAnimationEnd(View view) {
}
@Override
public void onAnimationCancel(View view) {
}
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.animator;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
/**
* Created by xinyuanzhong on 2017/4/28.
*/
public class TreeItemAnimator extends DefaultItemAnimator {
@Override
public boolean animateAdd(RecyclerView.ViewHolder holder) {
super.animateAdd(holder);
ViewCompat.setAlpha(holder.itemView, 1);
return true;
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.base;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import me.texy.treeview.TreeNode;
import me.texy.treeview.TreeView;
/**
* Created by zxy on 17/4/23.
*/
public abstract class BaseNodeViewBinder extends RecyclerView.ViewHolder {
/**
* This reference of TreeView make BaseNodeViewBinder has the ability
* to expand node or select node.
*/
protected TreeView treeView;
public BaseNodeViewBinder(View itemView) {
super(itemView);
}
public void setTreeView(TreeView treeView) {
this.treeView = treeView;
}
/**
* Get node item layout id
*
* @return
*/
public abstract int getLayoutId();
/**
* Bind your data to view,you can get the data from treeNode by getValue()
*
* @param treeNode Node data
*/
public abstract void bindView(TreeNode treeNode);
/**
* if you do not want toggle the node when click whole item view,then you can assign a view to
* trigger the toggle action
*
* @return The assigned view id to trigger expand or collapse.
*/
public int getToggleTriggerViewId() {
return 0;
}
/**
* Callback when a toggle action happened (only by clicked)
*
* @param treeNode The toggled node
* @param expand Expanded or collapsed
*/
public void onNodeToggled(TreeNode treeNode, boolean expand) {
//empty
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.base;
import android.view.View;
/**
* Created by zxy on 17/4/23.
*/
public abstract class BaseNodeViewFactory {
/**
* If you want build a tree view,you must implement this factory method
*
* @param view The parameter for BaseNodeViewBinder's constructor, do not use this for other
* purpose!
* @param level The treeNode level
* @return
*/
public abstract BaseNodeViewBinder getNodeViewBinder(View view, int level);
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.base;
import java.util.List;
import me.texy.treeview.TreeNode;
/**
* Created by xinyuanzhong on 2017/4/20.
*/
public interface BaseTreeAction {
void expandAll();
void expandNode(TreeNode treeNode);
void expandLevel(int level);
void collapseAll();
void collapseNode(TreeNode treeNode);
void collapseLevel(int level);
void toggleNode(TreeNode treeNode);
void deleteNode(TreeNode node);
void addNode(TreeNode parent, TreeNode treeNode);
List<TreeNode> getAllNodes();
// TODO: 17/4/30
// 1.add node at position
// 2.add slide delete or other operations
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.base;
import android.view.View;
import me.texy.treeview.TreeNode;
/**
* Created by xinyuanzhong on 2017/4/27.
*/
public abstract class CheckableNodeViewBinder extends BaseNodeViewBinder {
public CheckableNodeViewBinder(View itemView) {
super(itemView);
}
/**
* Get the checkable view id. MUST BE A CheckBox CLASS!
*
* @return
*/
public abstract int getCheckableViewId();
/**
* Do something when a node select or deselect(only triggered by clicked)
*
* @param treeNode
* @param selected
*/
public void onNodeSelectedChanged(TreeNode treeNode, boolean selected) {
/*empty*/
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.base;
import java.util.List;
import me.texy.treeview.TreeNode;
/**
* Created by xinyuanzhong on 2017/4/27.
*/
public interface SelectableTreeAction extends BaseTreeAction {
void selectNode(TreeNode treeNode);
void deselectNode(TreeNode treeNode);
void selectAll();
void deselectAll();
List<TreeNode> getSelectedNodes();
}
/**
* Copyright 2017 bejson.com
*/
package me.texy.treeview.bean;
import java.util.List;
public class TreeChildren {
// private boolean isPerson;
private String id;
private String text;
private String state;
private List<TreeChildren> children;
// public TreeChildren() {
// isPerson = StringUtil.isInteger(id);
// }
//
// public boolean isPerson() {
// return isPerson;
// }
//
// public void setPerson(boolean person) {
// isPerson = person;
// }
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setText(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setState(String state) {
this.state = state;
}
public String getState() {
return state;
}
public void setChildren(List<TreeChildren> children) {
this.children = children;
}
public List<TreeChildren> getChildren() {
return children;
}
}
\ No newline at end of file
package me.texy.treeview.binder;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import me.texy.treeview.R;
import me.texy.treeview.TreeNode;
import me.texy.treeview.base.CheckableNodeViewBinder;
/**
* Created by zxy on 17/4/23.
*/
public class FirstLevelNodeViewBinder extends CheckableNodeViewBinder {
private int checkBoxVisible;
CheckBox checkBox;
TextView textView;
ImageView imageView;
public FirstLevelNodeViewBinder(View itemView, int checkBoxVisible) {
super(itemView);
this.checkBoxVisible = checkBoxVisible;
checkBox = (CheckBox) itemView.findViewById(R.id.checkBox);
textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
}
@Override
public int getCheckableViewId() {
return R.id.checkBox;
}
@Override
public int getLayoutId() {
return R.layout.item_first_level;
}
@Override
public void bindView(final TreeNode treeNode) {
textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
checkBox.setVisibility(checkBoxVisible);
}
@Override
public void onNodeToggled(TreeNode treeNode, boolean expand) {
if (expand) {
imageView.animate().rotation(90).setDuration(200).start();
} else {
imageView.animate().rotation(0).setDuration(200).start();
}
}
}
package me.texy.treeview.binder;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import me.texy.treeview.R;
import me.texy.treeview.TreeNode;
import me.texy.treeview.base.CheckableNodeViewBinder;
/**
* Created by zxy on 17/4/23.
*/
public class FourthLevelNodeViewBinder extends CheckableNodeViewBinder {
TextView textView;
private int checkBoxVisible;
CheckBox checkBox;
public FourthLevelNodeViewBinder(View itemView, int checkBoxVisible) {
super(itemView);
this.checkBoxVisible = checkBoxVisible;
checkBox = (CheckBox) itemView.findViewById(R.id.checkBox);
textView = (TextView) itemView.findViewById(R.id.node_name_view);
}
@Override
public int getCheckableViewId() {
return R.id.checkBox;
}
@Override
public int getLayoutId() {
return R.layout.item_fourth_level;
}
@Override
public void bindView(TreeNode treeNode) {
checkBox.setVisibility(checkBoxVisible);
textView.setText(treeNode.getValue().toString());
}
}
package me.texy.treeview.binder;
import android.view.View;
import me.texy.treeview.base.BaseNodeViewBinder;
import me.texy.treeview.base.BaseNodeViewFactory;
/**
* Created by zxy on 17/4/23.
*/
public class MyNodeViewFactory extends BaseNodeViewFactory {
private int checkBoxVisible = View.VISIBLE;
public MyNodeViewFactory() {
}
public MyNodeViewFactory(int checkBoxVisible) {
this.checkBoxVisible = checkBoxVisible;
}
@Override
public BaseNodeViewBinder getNodeViewBinder(View view, int level) {
switch (level) {
case 0:
return new FirstLevelNodeViewBinder(view, checkBoxVisible);
case 1:
return new SecondLevelNodeViewBinder(view, checkBoxVisible);
case 2:
return new ThirdLevelNodeViewBinder(view, checkBoxVisible);
case 3:
return new ThirdLevelNodeViewBinder(view, checkBoxVisible);
case 4:
return new ThirdLevelNodeViewBinder(view, checkBoxVisible);
default:
return new FourthLevelNodeViewBinder(view, checkBoxVisible);
}
}
}
package me.texy.treeview.binder;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import me.texy.treeview.R;
import me.texy.treeview.TreeNode;
import me.texy.treeview.base.CheckableNodeViewBinder;
/**
* Created by zxy on 17/4/23.
*/
public class SecondLevelNodeViewBinder extends CheckableNodeViewBinder {
private int checkBoxVisible;
CheckBox checkBox;
TextView textView;
ImageView imageView;
public SecondLevelNodeViewBinder(View itemView, int checkBoxVisible) {
super(itemView);
this.checkBoxVisible = checkBoxVisible;
checkBox = (CheckBox) itemView.findViewById(R.id.checkBox);
textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
}
@Override
public int getCheckableViewId() {
return R.id.checkBox;
}
@Override
public int getLayoutId() {
return R.layout.item_second_level;
}
@Override
public void bindView(final TreeNode treeNode) {
textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
checkBox.setVisibility(checkBoxVisible);
if (treeNode.isPerson()) {
imageView.setVisibility(View.INVISIBLE);
} else {
imageView.setVisibility(View.VISIBLE);
}
}
@Override
public void onNodeToggled(TreeNode treeNode, boolean expand) {
if (expand) {
imageView.animate().rotation(90).setDuration(200).start();
} else {
imageView.animate().rotation(0).setDuration(200).start();
}
}
}
package me.texy.treeview.binder;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import me.texy.treeview.R;
import me.texy.treeview.TreeNode;
import me.texy.treeview.base.CheckableNodeViewBinder;
/**
* Created by zxy on 17/4/23.
*/
public class ThirdLevelNodeViewBinder extends CheckableNodeViewBinder {
private int checkBoxVisible;
CheckBox checkBox;
TextView textView;
ImageView imageView;
public ThirdLevelNodeViewBinder(View itemView, int checkBoxVisible) {
super(itemView);
this.checkBoxVisible = checkBoxVisible;
checkBox = (CheckBox) itemView.findViewById(R.id.checkBox);
textView = (TextView) itemView.findViewById(R.id.node_name_view);
imageView = (ImageView) itemView.findViewById(R.id.arrow_img);
}
@Override
public int getCheckableViewId() {
return R.id.checkBox;
}
@Override
public int getLayoutId() {
return R.layout.item_third_level;
}
@Override
public void bindView(final TreeNode treeNode) {
textView.setText(treeNode.getValue().toString());
imageView.setRotation(treeNode.isExpanded() ? 90 : 0);
checkBox.setVisibility(checkBoxVisible);
if (treeNode.isPerson()) {
imageView.setVisibility(View.INVISIBLE);
} else {
imageView.setVisibility(View.VISIBLE);
}
}
@Override
public void onNodeToggled(TreeNode treeNode, boolean expand) {
if (expand) {
imageView.animate().rotation(90).setDuration(200).start();
} else {
imageView.animate().rotation(0).setDuration(200).start();
}
}
}
/*
* Copyright 2016 - 2017 ShineM (Xinyuan)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under.
*/
package me.texy.treeview.helper;
import java.util.ArrayList;
import java.util.List;
import me.texy.treeview.TreeNode;
/**
* Created by xinyuanzhong on 2017/4/27.
*/
public class TreeHelper {
public static void expandAll(TreeNode node) {
if (node == null) {
return;
}
expandNode(node, true);
}
/**
* Expand node and calculate the visible addition nodes.
*
* @param treeNode target node to expand
* @param includeChild should expand child
* @return the visible addition nodes
*/
public static List<TreeNode> expandNode(TreeNode treeNode, boolean includeChild) {
List<TreeNode> expandChildren = new ArrayList<>();
if (treeNode == null) {
return expandChildren;
}
treeNode.setExpanded(true);
if (!treeNode.hasChild()) {
return expandChildren;
}
for (TreeNode child : treeNode.getChildren()) {
expandChildren.add(child);
if (includeChild || child.isExpanded()) {
expandChildren.addAll(expandNode(child, includeChild));
}
}
return expandChildren;
}
/**
* Expand the same deep(level) nodes.
*
* @param root the tree root
* @param level the level to expand
* @return
*/
public static void expandLevel(TreeNode root, int level) {
if (root == null) {
return;
}
for (TreeNode child : root.getChildren()) {
if (child.getLevel() == level) {
expandNode(child, false);
} else {
expandLevel(child, level);
}
}
}
public static void collapseAll(TreeNode node) {
if (node == null) {
return;
}
for (TreeNode child : node.getChildren()) {
performCollapseNode(child, true);
}
}
/**
* Collapse node and calculate the visible removed nodes.
*
* @param node target node to collapse
* @param includeChild should collapse child
* @return the visible addition nodes before remove
*/
public static List<TreeNode> collapseNode(TreeNode node, boolean includeChild) {
List<TreeNode> treeNodes = performCollapseNode(node, includeChild);
node.setExpanded(false);
return treeNodes;
}
private static List<TreeNode> performCollapseNode(TreeNode node, boolean includeChild) {
List<TreeNode> collapseChildren = new ArrayList<>();
if (node == null) {
return collapseChildren;
}
if (includeChild) {
node.setExpanded(false);
}
for (TreeNode child : node.getChildren()) {
collapseChildren.add(child);
if (child.isExpanded()) {
collapseChildren.addAll(performCollapseNode(child, includeChild));
} else if (includeChild) {
performCollapseNodeInner(child);
}
}
return collapseChildren;
}
/**
* Collapse all children node recursive
*
* @param node target node to collapse
*/
private static void performCollapseNodeInner(TreeNode node) {
if (node == null) {
return;
}
node.setExpanded(false);
for (TreeNode child : node.getChildren()) {
performCollapseNodeInner(child);
}
}
public static void collapseLevel(TreeNode root, int level) {
if (root == null) {
return;
}
for (TreeNode child : root.getChildren()) {
if (child.getLevel() == level) {
collapseNode(child, false);
} else {
collapseLevel(child, level);
}
}
}
public static List<TreeNode> getAllNodes(TreeNode root) {
List<TreeNode> allNodes = new ArrayList<>();
fillNodeList(allNodes, root);
allNodes.remove(root);
return allNodes;
}
private static void fillNodeList(List<TreeNode> treeNodes, TreeNode treeNode) {
treeNodes.add(treeNode);
if (treeNode.hasChild()) {
for (TreeNode child : treeNode.getChildren()) {
fillNodeList(treeNodes, child);
}
}
}
/**
* Select the node and node's children,return the visible nodes
*
* @param treeNode
* @param select
* @return
*/
public static List<TreeNode> selectNodeAndChild(TreeNode treeNode, boolean select) {
List<TreeNode> expandChildren = new ArrayList<>();
if (treeNode == null) {
return expandChildren;
}
treeNode.setSelected(select);
if (!treeNode.hasChild()) {
return expandChildren;
}
if (treeNode.isExpanded()) {
for (TreeNode child : treeNode.getChildren()) {
expandChildren.add(child);
if (child.isExpanded()) {
expandChildren.addAll(selectNodeAndChild(child, select));
} else {
selectNodeInner(child, select);
}
}
} else {
selectNodeInner(treeNode, select);
}
return expandChildren;
}
private static void selectNodeInner(TreeNode treeNode, boolean select) {
if (treeNode == null) {
return;
}
treeNode.setSelected(select);
if (treeNode.hasChild()) {
for (TreeNode child : treeNode.getChildren()) {
selectNodeInner(child, select);
}
}
}
/**
* Select parent when all the brothers have been selected, otherwise deselect parent,
* and check the grand parent recursive.
*
* @param treeNode
* @param select
* @return
*/
public static List<TreeNode> selectParentIfNeedWhenNodeSelected(TreeNode treeNode, boolean select) {
List<TreeNode> impactedParents = new ArrayList<>();
if (treeNode == null) {
return impactedParents;
}
//ensure that the node's level is bigger than 1(first level is 1)
TreeNode parent = treeNode.getParent();
if (parent == null || parent.getParent() == null) {
return impactedParents;
}
List<TreeNode> brothers = parent.getChildren();
int selectedBrotherCount = 0;
for (TreeNode brother : brothers) {
if (brother.isSelected()) selectedBrotherCount++;
}
if (select && selectedBrotherCount == brothers.size()) {
parent.setSelected(true);
impactedParents.add(parent);
impactedParents.addAll(selectParentIfNeedWhenNodeSelected(parent, true));
} else if (!select && selectedBrotherCount == brothers.size() - 1) {
// only the condition that the size of selected's brothers
// is one less than total count can trigger the deselect
parent.setSelected(false);
impactedParents.add(parent);
impactedParents.addAll(selectParentIfNeedWhenNodeSelected(parent, false));
}
return impactedParents;
}
/**
* Get the selected nodes under current node, include itself
*
* @param treeNode
* @return
*/
public static List<TreeNode> getSelectedNodes(TreeNode treeNode) {
List<TreeNode> selectedNodes = new ArrayList<>();
if (treeNode == null) {
return selectedNodes;
}
if (treeNode.isSelected() && treeNode.getParent() != null) selectedNodes.add(treeNode);
for (TreeNode child : treeNode.getChildren()) {
selectedNodes.addAll(getSelectedNodes(child));
}
return selectedNodes;
}
/**
* Return true when the node has one selected child(recurse all children) at least,
* otherwise return false
*
* @param treeNode
* @return
*/
public static boolean hasOneSelectedNodeAtLeast(TreeNode treeNode) {
if (treeNode == null || treeNode.getChildren().size() == 0) {
return false;
}
List<TreeNode> children = treeNode.getChildren();
for (TreeNode child : children) {
if (child.isSelected() || hasOneSelectedNodeAtLeast(child)) {
return true;
}
}
return false;
}
}
package me.texy.treeview.helper;
import java.util.ArrayList;
import java.util.List;
import me.texy.treeview.TreeNode;
import me.texy.treeview.bean.TreeChildren;
/**
* Created by Administrator on 2017/8/14 0014.
*/
public class TreeNodeHelper {
public static TreeNode buildTree(TreeNode root, List<TreeChildren> list) {
root.getChildren().clear();
for (int i = 0; i < list.size(); i++) {
TreeNode treeNode = new TreeNode(new String(list.get(i).getText()), list.get(i).getId());
treeNode.setLevel(0);
if (list.get(i).getChildren() != null && list.get(i).getChildren().size() > 0) {
for (int j = 0; j < list.get(i).getChildren().size(); j++) {
TreeNode treeNode1 = new TreeNode(new String(list.get(i).getChildren().get(j).getText()), list.get(i).getChildren().get(j).getId());
treeNode1.setLevel(1);
if (list.get(i).getChildren().get(j).getChildren() != null && list.get(i).getChildren().get(j).getChildren().size() > 0) {
for (int k = 0; k < list.get(i).getChildren().get(j).getChildren().size(); k++) {
TreeNode treeNode2 = new TreeNode(new String(list.get(i).getChildren().get(j).getChildren().get(k).getText()), list.get(i).getChildren().get(j).getChildren().get(k).getId());
treeNode2.setLevel(2);
if (list.get(i).getChildren().get(j).getChildren().get(k).getChildren() != null && list.get(i).getChildren().get(j).getChildren().get(k).getChildren().size() > 0) {
for (int l = 0; l < list.get(i).getChildren().get(j).getChildren().get(k).getChildren().size(); l++) {
TreeNode treeNode3 = new TreeNode(new String(list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getText()), list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getId());
treeNode3.setLevel(3);
if(list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren() !=null && list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().size()>0){
for (int m =0 ;m <list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().size();m++){
TreeNode treeNode4 = new TreeNode(new String(list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getText()), list.get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getId());
treeNode4.setLevel(4);
treeNode3.addChild(treeNode4);
}
}
treeNode2.addChild(treeNode3);
}
}
treeNode1.addChild(treeNode2);
}
}
treeNode.addChild(treeNode1);
}
}
root.addChild(treeNode);
}
return root;
}
public static TreeNode getSelectTreeNode(TreeNode root) {
for (int i = root.getChildren().size() - 1; i >= 0; i--) {
for (int j = root.getChildren().get(i).getChildren().size() - 1; j >= 0; j--) {
for (int k = root.getChildren().get(i).getChildren().get(j).getChildren().size() - 1; k >= 0; k--) {
for (int l = root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().size() - 1; l >= 0; l--) {
for (int m = root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().size() - 1; m >= 0; m--){
if ((root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).isPerson() && !root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).isSelected()) || (!root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).isPerson() && !root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).hasChild())) {
root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).removeChild(root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m));
}
}
if ((root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).isPerson() && !root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).isSelected()) || (!root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).isPerson() && !root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l).hasChild())) {
root.getChildren().get(i).getChildren().get(j).getChildren().get(k).removeChild(root.getChildren().get(i).getChildren().get(j).getChildren().get(k).getChildren().get(l));
}
}
if ((root.getChildren().get(i).getChildren().get(j).getChildren().get(k).isPerson() && !root.getChildren().get(i).getChildren().get(j).getChildren().get(k).isSelected()) || (!root.getChildren().get(i).getChildren().get(j).getChildren().get(k).isPerson() && !root.getChildren().get(i).getChildren().get(j).getChildren().get(k).hasChild())) {
root.getChildren().get(i).getChildren().get(j).removeChild(root.getChildren().get(i).getChildren().get(j).getChildren().get(k));
}
}
if ((root.getChildren().get(i).getChildren().get(j).isPerson() && !root.getChildren().get(i).getChildren().get(j).isSelected()) || (!root.getChildren().get(i).getChildren().get(j).isPerson() && !root.getChildren().get(i).getChildren().get(j).hasChild())) {
root.getChildren().get(i).removeChild(root.getChildren().get(i).getChildren().get(j));
}
}
if ((root.getChildren().get(i).isPerson() && !root.getChildren().get(i).isSelected()) || (!root.getChildren().get(i).isPerson() && !root.getChildren().get(i).hasChild())) {
root.removeChild(root.getChildren().get(i));
}
}
return root;
}
public static List<Integer> changeToUserIdStr(List<TreeNode> treeNode, List<Integer> stringBuilder) {
if (stringBuilder == null) {
stringBuilder = new ArrayList<Integer>();
}
for (TreeNode node : treeNode) {
if (node.isPerson()) {
stringBuilder.add(Integer.parseInt(node.getUserId()));
}
changeToUserIdStr(node.getChildren(), stringBuilder);
}
return stringBuilder;
}
//针对3级
public static List<TreeNode> getRootChildren(TreeNode treeNode,List<TreeNode> nodes) {
if(nodes ==null)
nodes=new ArrayList<>();
for (int i = 0; i < treeNode.getChildren().size(); i++) {
TreeNode node = treeNode.getChildren().get(i);
if (!node.isPerson()) {
getRootChildren(node,nodes);
} else nodes.add(node);
}
return nodes;
}
}
\ No newline at end of file
package me.texy.treeview.util;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* Created by sunny on 2018-3-6.
*/
public class RecycleViewDivider extends RecyclerView.ItemDecoration {
private Paint mPaint;
private Drawable mDivider;
private int mDividerHeight = 2;//分割线高度,默认为1px
private int mOrientation;//列表的方向:LinearLayoutManager.VERTICAL或LinearLayoutManager.HORIZONTAL
private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
/**
* 默认分割线:高度为2px,颜色为灰色
*
* @param context
* @param orientation 列表方向
*/
public RecycleViewDivider(Context context, int orientation) {
if (orientation != LinearLayoutManager.VERTICAL && orientation != LinearLayoutManager.HORIZONTAL) {
throw new IllegalArgumentException("请输入正确的参数!");
}
mOrientation = orientation;
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
}
/**
* 自定义分割线
*
* @param context
* @param orientation 列表方向
* @param drawableId 分割线图片
*/
public RecycleViewDivider(Context context, int orientation, int drawableId) {
this(context, orientation);
mDivider = ContextCompat.getDrawable(context, drawableId);
mDividerHeight = mDivider.getIntrinsicHeight();
}
/**
* 自定义分割线
*
* @param context
* @param orientation 列表方向
* @param dividerHeight 分割线高度
* @param dividerColor 分割线颜色
*/
public RecycleViewDivider(Context context, int orientation, int dividerHeight, int dividerColor) {
this(context, orientation);
mDividerHeight = dividerHeight;
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(dividerColor);
mPaint.setStyle(Paint.Style.FILL);
}
//获取分割线尺寸
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
outRect.set(0, 0, 0, mDividerHeight);
}
//绘制分割线
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDraw(c, parent, state);
if (mOrientation == LinearLayoutManager.VERTICAL) {
drawVertical(c, parent);
} else {
drawHorizontal(c, parent);
}
}
//绘制横向 item 分割线
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getMeasuredWidth() - parent.getPaddingRight();
final int childSize = parent.getChildCount();
for (int i = 0; i < childSize; i++) {
final View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getBottom() + layoutParams.bottomMargin;
final int bottom = top + mDividerHeight;
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
//绘制纵向 item 分割线
private void drawVertical(Canvas canvas, RecyclerView parent) {
final int top = parent.getPaddingTop();
final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
final int childSize = parent.getChildCount();
for (int i = 0; i < childSize; i++) {
final View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
final int left = child.getRight() + layoutParams.rightMargin;
final int right = left + mDividerHeight;
if (mDivider != null) {
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(canvas);
}
if (mPaint != null) {
canvas.drawRect(left, top, right, bottom, mPaint);
}
}
}
}
package me.texy.treeview.util;
import java.util.regex.Pattern;
/**
* Created by Administrator on 2017/8/7 0007.
*/
public class StringUtil {
/*
* 判断是否为整数
* @param str 传入的字符串
* @return 是整数返回true,否则返回false
*/
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/cb_focuse"/>
<item android:state_checked="false" android:drawable="@drawable/cb_normal"/>
</selector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"
android:fillColor="#00cc99"/>
</vector>
<?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="50dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/node_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/arrow_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_right_white_24px" />
<TextView
android:id="@+id/node_name_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="monospace"
android:text="Tree Node"
android:textSize="15dp" />
</LinearLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/checkBox"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:button="@null"
android:background="@drawable/cb_selector"
android:layout_marginRight="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="@color/line"></View>
</RelativeLayout>
\ No newline at end of file
<?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="40dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/node_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="108dp"
android:orientation="horizontal">
<TextView
android:id="@+id/node_name_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="monospace"
android:text="Tree Node"
android:textSize="15dp" />
</LinearLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/checkBox"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_alignParentBottom="true"
android:background="@android:color/darker_gray"></View>
</RelativeLayout>
\ No newline at end of file
<?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="40dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/node_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="36dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/arrow_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_right_white_24px" />
<TextView
android:id="@+id/node_name_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="monospace"
android:text="Tree Node"
android:textSize="15dp" />
</LinearLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/checkBox"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:button="@null"
android:background="@drawable/cb_selector"
android:layout_marginRight="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="@color/line"></View>
</RelativeLayout>
\ No newline at end of file
<?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="40dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/node_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="72dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/arrow_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_keyboard_arrow_right_white_24px" />
<TextView
android:id="@+id/node_name_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="monospace"
android:text="Tree Node"
android:textSize="15dp" />
</LinearLayout>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/checkBox"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:button="@null"
android:background="@drawable/cb_selector"
android:layout_marginRight="10dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="@color/line"></View>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#034d7f</color>
<color name="colorPrimaryDark">#034d7f</color>
<color name="colorAccent">#034d7f</color>
<color name="line">#E7E6E6</color>
<color name="transparent">#00000000</color>
</resources>
<resources>
<string name="app_name">treeview</string>
</resources>
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