xuxiuxi
2017-03-30 a2df837618f1ef81b7198851ac5bd0608c116ce3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package cn.com.basic.face.fragment;
 
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
 
import com.bsk.zhangbo.demoforbsk.R;
import cn.com.basic.face.adapter.VisitAdapter;
import cn.com.basic.face.base.LeftRightBaseFragment;
import cn.com.basic.face.base.MainActivity;
 
import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
import com.camnter.easyrecyclerview.widget.EasyRecyclerView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.event.OnClick;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * Created by Sinoe on 2017/2/23.
 */
 
public class VisitFragment extends LeftRightBaseFragment implements EasyRecyclerViewHolder.OnItemClickListener{
    private View mViewLeft,mViewRight;
    private LinearLayout mRowLayout1,mRowLayout2,mRowLayout3,mRowLayout4,mRowLayout5,mRowLayout6,mRowLayout7;
    private TextView mRow1TextViewLeft,mRow1TextViewRight,mRow2TextViewLeft,mRow2TextViewRight,mRow3TextViewLeft,mRow3TextViewRight,mRow4TextViewLeft,mRow4TextViewRight,
    mRow5TextViewLeft,mRow5TextViewRight,mRow6TextViewLeft,mRow6TextViewRight,mRow7TextViewLeft,mRow7TextViewRight;
    private VisitAdapter mAdapter;
    private EasyRecyclerView mRecyclerView;
    private int mOldPosition = 0,mNewPosition = 0;
    public static VisitFragment newInstance(){
        return new VisitFragment();
    }
 
    public View addLeftLayout() {
        mViewLeft = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_visit_left,null);
        mRecyclerView = (EasyRecyclerView) mViewLeft.findViewById(R.id.visitor_manager_recycler);
        LinearLayoutManager manager = new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false);
        mRecyclerView.setLayoutManager(manager);
        mAdapter = new VisitAdapter();
        ViewUtils.inject(this, mViewLeft);
        return mViewLeft;
    }
 
    public View addRightLayout() {
        mViewRight = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_visit_right,null);
        mRowLayout1 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row1);
        mRowLayout2 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row2);
        mRowLayout3 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row3);
        mRowLayout4 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row4);
        mRowLayout5 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row5);
        mRowLayout6 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row6);
        mRowLayout7 = (LinearLayout) mViewRight.findViewById(R.id.visitor_manager_row7);
 
        mRow1TextViewLeft = (TextView) mRowLayout1.findViewById(R.id.visitor_manager_row_title_left);
        mRow1TextViewRight = (TextView) mRowLayout1.findViewById(R.id.visitor_manager_row_title_right);
        mRow1TextViewLeft.setText(R.string.title_name);
        mRow1TextViewRight.setText(R.string.title_phone);
 
        mRow2TextViewLeft = (TextView) mRowLayout2.findViewById(R.id.visitor_manager_row_title_left);
        mRow2TextViewRight = (TextView) mRowLayout2.findViewById(R.id.visitor_manager_row_title_right);
        mRow2TextViewLeft.setText(R.string.title_sex);
        mRow2TextViewRight.setText(R.string.title_idClass);
 
        mRow3TextViewLeft = (TextView) mRowLayout3.findViewById(R.id.visitor_manager_row_title_left);
        mRow3TextViewRight = (TextView) mRowLayout3.findViewById(R.id.visitor_manager_row_title_right);
        mRow3TextViewLeft.setText(R.string.title_nation);
        mRow3TextViewRight.setText(R.string.title_idNumber);
 
        mRow4TextViewLeft = (TextView) mRowLayout4.findViewById(R.id.visitor_manager_row_title_left);
        mRow4TextViewRight = (TextView) mRowLayout4.findViewById(R.id.visitor_manager_row_title_right);
        mRow4TextViewLeft.setText(R.string.title_birthday);
        mRow4TextViewRight.setText(R.string.title_companyName);
 
        mRow5TextViewLeft = (TextView) mRowLayout5.findViewById(R.id.visitor_manager_row_title_left);
        mRow5TextViewRight = (TextView) mRowLayout5.findViewById(R.id.visitor_manager_row_title_right);
        mRow5TextViewLeft.setText(R.string.title_visitor);
        mRow5TextViewRight.setText(R.string.title_visitor_thing);
 
        mRow6TextViewLeft = (TextView) mRowLayout6.findViewById(R.id.visitor_manager_row_title_left);
        mRow6TextViewRight = (TextView) mRowLayout6.findViewById(R.id.visitor_manager_row_title_right);
        mRow6TextViewLeft.setText(R.string.title_visitor_department);
        mRow6TextViewRight.setText(R.string.title_visitor_state);
 
        mRow7TextViewLeft = (TextView) mRowLayout7.findViewById(R.id.visitor_manager_row_title_left);
        mRow7TextViewRight = (TextView) mRowLayout7.findViewById(R.id.visitor_manager_row_title_right);
        mRow7TextViewLeft.setText(R.string.title_visitor_start_time);
        mRow7TextViewRight.setText(R.string.title_visitor_end_time);
        return mViewRight;
    }
 
    @Override
    protected void initListeners() {
        mAdapter.setOnItemClickListener(this);
    }
 
    @Override
    protected void initData() {
        List list = new ArrayList();
        for (int i = 0;i<20;i++){
            list.add("");
        }
        mAdapter.setList(list);
        mRecyclerView.setAdapter(mAdapter);
    }
 
    @Override
    public void onItemClick(View convertView, int position) {
        if (position ==0 ||position ==3 ||position ==8){
 
        }else {
            mNewPosition = position;
            mAdapter.checkItemShow(mOldPosition,mNewPosition);
            mOldPosition = mNewPosition;
            mAdapter.getItem(position);
            Toast.makeText(getActivity(),position+"",Toast.LENGTH_SHORT).show();
//            Log.e("aaaaaaaaaaaaaaaaaa",position+"");
////            ((CheckBox)mRecyclerView.getChildAt(position).findViewById(R.id.item_visitor_info_check)).setChecked(true);
//            CheckBox checkBox = (CheckBox) mRecyclerView.getChildAt(position).findViewById(R.id.item_visitor_info_check);
//            checkBox.setChecked(true);
        }
    }
 
    @OnClick(R.id.visitor_manager_back)
    public void back(View view) {
        MainActivity.selectPage(0);
    }
 
}