@@ -1,4 +1,5 @@ |
||
1 | 1 |
apply plugin: 'com.android.application' |
2 |
+apply plugin: 'android-apt' |
|
2 | 3 |
|
3 | 4 |
android { |
4 | 5 |
compileSdkVersion 24 |
@@ -24,6 +25,10 @@ dependencies { |
||
24 | 25 |
compile 'com.android.support:appcompat-v7:24.0.0' |
25 | 26 |
compile 'com.android.support:recyclerview-v7:24.0.0' |
26 | 27 |
compile 'com.android.support:design:24.0.0' |
28 |
+ |
|
29 |
+ compile 'com.jakewharton:butterknife:8.2.1' |
|
30 |
+ apt 'com.jakewharton:butterknife-compiler:8.2.1' |
|
31 |
+ |
|
27 | 32 |
compile project(path: ':common') |
28 | 33 |
compile project(path: ':common') |
29 | 34 |
compile files('libs/zxing.jar') |
@@ -12,6 +12,8 @@ import com.android.common.utils.DeviceUtils; |
||
12 | 12 |
import java.util.ArrayList; |
13 | 13 |
|
14 | 14 |
import ai.pai.lensman.R; |
15 |
+import butterknife.BindView; |
|
16 |
+import butterknife.ButterKnife; |
|
15 | 17 |
|
16 | 18 |
public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdapter.MyViewHolder> { |
17 | 19 |
|
@@ -55,10 +57,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
55 | 57 |
|
56 | 58 |
@Override |
57 | 59 |
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
58 |
- View view = mInflater.inflate(R.layout.photo_item,parent,false); |
|
59 |
- MyViewHolder viewHolder = new MyViewHolder(view); |
|
60 |
- viewHolder.photo = (ImageView) view.findViewById(R.id.iv_session_photo_item); |
|
61 |
- return viewHolder; |
|
60 |
+ return new MyViewHolder(mInflater.inflate(R.layout.photo_item,parent,false)); |
|
62 | 61 |
} |
63 | 62 |
|
64 | 63 |
@Override |
@@ -91,10 +90,11 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
91 | 90 |
|
92 | 91 |
class MyViewHolder extends RecyclerView.ViewHolder{ |
93 | 92 |
|
94 |
- private ImageView photo; |
|
93 |
+ @BindView(R.id.iv_session_photo_item) ImageView photo; |
|
95 | 94 |
|
96 | 95 |
public MyViewHolder(View view){ |
97 | 96 |
super(view); |
97 |
+ ButterKnife.bind(this,view); |
|
98 | 98 |
} |
99 | 99 |
} |
100 | 100 |
} |
@@ -5,21 +5,19 @@ import android.support.v7.app.AppCompatActivity; |
||
5 | 5 |
import android.support.v7.widget.LinearLayoutManager; |
6 | 6 |
import android.support.v7.widget.RecyclerView; |
7 | 7 |
import android.view.View; |
8 |
-import android.widget.ImageButton; |
|
9 |
-import android.widget.ImageView; |
|
10 | 8 |
import android.widget.TextView; |
11 | 9 |
|
12 | 10 |
import ai.pai.lensman.R; |
13 | 11 |
import ai.pai.lensman.upload.SessionBean; |
12 |
+import butterknife.BindView; |
|
13 |
+import butterknife.ButterKnife; |
|
14 |
+import butterknife.OnClick; |
|
14 | 15 |
|
15 |
-public class SessionActivity extends AppCompatActivity implements SessionContract.SessionView,View.OnClickListener { |
|
16 |
+public class SessionActivity extends AppCompatActivity implements SessionContract.SessionView { |
|
16 | 17 |
|
17 |
- private View noPhotoLayout; |
|
18 |
- private RecyclerView photosRecyclerView; |
|
19 |
- private TextView titleTextView; |
|
20 |
- private ImageView scanImageView; |
|
21 |
- private ImageView qrcodeImageView; |
|
22 |
- private ImageButton sessionCompleteBtn; |
|
18 |
+ @BindView(R.id.icon_no_data) View noPhotoLayout; |
|
19 |
+ @BindView(R.id.title_bar_middle_txt) TextView titleTextView; |
|
20 |
+ @BindView(R.id.recycler_view_photos) RecyclerView photosRecyclerView; |
|
23 | 21 |
private PhotoRecyclerAdapter adapter; |
24 | 22 |
|
25 | 23 |
private SessionContract.SessionPresenter presenter; |
@@ -28,26 +26,15 @@ public class SessionActivity extends AppCompatActivity implements SessionContrac |
||
28 | 26 |
protected void onCreate(Bundle savedInstanceState) { |
29 | 27 |
super.onCreate(savedInstanceState); |
30 | 28 |
setContentView(R.layout.activity_session); |
31 |
- |
|
29 |
+ ButterKnife.bind(this); |
|
32 | 30 |
presenter = new SessionPresenterImpl(this,this); |
33 | 31 |
|
34 | 32 |
SessionBean sessionBean =(SessionBean)getIntent().getSerializableExtra("session"); |
35 |
- titleTextView = (TextView)findViewById(R.id.title_bar_middle_txt); |
|
36 | 33 |
titleTextView.setText(getString(R.string.scene)+sessionBean.sessionSeq); |
37 |
- noPhotoLayout = findViewById(R.id.icon_no_data); |
|
38 |
- photosRecyclerView = (RecyclerView)findViewById(R.id.recycler_view_photos); |
|
39 | 34 |
adapter = new PhotoRecyclerAdapter(this); |
40 | 35 |
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); |
41 | 36 |
photosRecyclerView.setLayoutManager(layoutManager); |
42 | 37 |
photosRecyclerView.setAdapter(adapter); |
43 |
- scanImageView = (ImageView)findViewById(R.id.iv_scan); |
|
44 |
- qrcodeImageView = (ImageView)findViewById(R.id.iv_qrcode); |
|
45 |
- sessionCompleteBtn = (ImageButton)findViewById(R.id.btn_session_complete); |
|
46 |
- |
|
47 |
- scanImageView.setOnClickListener(this); |
|
48 |
- qrcodeImageView.setOnClickListener(this); |
|
49 |
- sessionCompleteBtn.setOnClickListener(this); |
|
50 |
- findViewById(R.id.title_bar_back_layout).setOnClickListener(this); |
|
51 | 38 |
} |
52 | 39 |
|
53 | 40 |
@Override |
@@ -62,23 +49,24 @@ public class SessionActivity extends AppCompatActivity implements SessionContrac |
||
62 | 49 |
presenter.stop(); |
63 | 50 |
} |
64 | 51 |
|
65 |
- @Override |
|
66 |
- public void onClick(View view) { |
|
67 |
- |
|
68 |
- switch (view.getId()){ |
|
69 |
- case R.id.title_bar_back_layout: |
|
70 |
- finish(); |
|
71 |
- break; |
|
72 |
- case R.id.iv_qrcode: |
|
73 |
- presenter.showQRCodeForSession(); |
|
74 |
- break; |
|
75 |
- case R.id.iv_scan: |
|
76 |
- presenter.scanToFetchSessionQR(); |
|
77 |
- break; |
|
78 |
- case R.id.btn_session_complete: |
|
79 |
- presenter.onSessionComplete(); |
|
80 |
- break; |
|
81 |
- } |
|
52 |
+ @OnClick(R.id.iv_scan) |
|
53 |
+ void scanToFetchSessionQR(){ |
|
54 |
+ |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ @OnClick(R.id.iv_qrcode) |
|
58 |
+ void showQRCodeForSession(){ |
|
59 |
+ |
|
60 |
+ } |
|
61 |
+ |
|
62 |
+ @OnClick(R.id.title_bar_back_layout) |
|
63 |
+ void backToMain(){ |
|
64 |
+ finish(); |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ @OnClick(R.id.btn_session_complete) |
|
68 |
+ void onSessionComplete(){ |
|
69 |
+ |
|
82 | 70 |
} |
83 | 71 |
|
84 | 72 |
@Override |
@@ -13,9 +13,6 @@ public class SessionContract { |
||
13 | 13 |
|
14 | 14 |
interface SessionPresenter{ |
15 | 15 |
void start(); |
16 |
- void onSessionComplete(); |
|
17 |
- void scanToFetchSessionQR(); |
|
18 |
- void showQRCodeForSession(); |
|
19 | 16 |
void stop(); |
20 | 17 |
} |
21 | 18 |
} |
@@ -29,22 +29,6 @@ public class SessionPresenterImpl implements SessionContract.SessionPresenter ,S |
||
29 | 29 |
} |
30 | 30 |
|
31 | 31 |
@Override |
32 |
- public void onSessionComplete() { |
|
33 |
- context.finish(); |
|
34 |
- |
|
35 |
- } |
|
36 |
- |
|
37 |
- @Override |
|
38 |
- public void scanToFetchSessionQR() { |
|
39 |
- |
|
40 |
- } |
|
41 |
- |
|
42 |
- @Override |
|
43 |
- public void showQRCodeForSession() { |
|
44 |
- |
|
45 |
- } |
|
46 |
- |
|
47 |
- @Override |
|
48 | 32 |
public void stop() { |
49 | 33 |
interactor.stopCapture(); |
50 | 34 |
} |
@@ -13,6 +13,8 @@ import com.android.common.utils.DeviceUtils; |
||
13 | 13 |
import java.util.ArrayList; |
14 | 14 |
|
15 | 15 |
import ai.pai.lensman.R; |
16 |
+import butterknife.BindView; |
|
17 |
+import butterknife.ButterKnife; |
|
16 | 18 |
|
17 | 19 |
public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecyclerAdapter.MyViewHolder> { |
18 | 20 |
|
@@ -65,11 +67,7 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
65 | 67 |
|
66 | 68 |
@Override |
67 | 69 |
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
68 |
- View view = mInflater.inflate(R.layout.session_item,parent,false); |
|
69 |
- MyViewHolder viewHolder = new MyViewHolder(view); |
|
70 |
- viewHolder.photo = (ImageView) view.findViewById(R.id.iv_session_item); |
|
71 |
- viewHolder.sesseionSeq = (TextView)view.findViewById(R.id.tv_session_seq); |
|
72 |
- return viewHolder; |
|
70 |
+ return new MyViewHolder(mInflater.inflate(R.layout.session_item,parent,false)); |
|
73 | 71 |
} |
74 | 72 |
|
75 | 73 |
@Override |
@@ -103,12 +101,13 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
103 | 101 |
|
104 | 102 |
class MyViewHolder extends RecyclerView.ViewHolder{ |
105 | 103 |
|
106 |
- private ImageView photo; |
|
104 |
+ @BindView(R.id.iv_session_item) ImageView photo; |
|
107 | 105 |
|
108 |
- private TextView sesseionSeq; |
|
106 |
+ @BindView(R.id.tv_session_seq) TextView sesseionSeq; |
|
109 | 107 |
|
110 | 108 |
public MyViewHolder(View view){ |
111 | 109 |
super(view); |
110 |
+ ButterKnife.bind(this, view); |
|
112 | 111 |
} |
113 | 112 |
} |
114 | 113 |
} |
@@ -12,51 +12,30 @@ import android.widget.TextView; |
||
12 | 12 |
import java.util.ArrayList; |
13 | 13 |
|
14 | 14 |
import ai.pai.lensman.R; |
15 |
+import butterknife.BindView; |
|
16 |
+import butterknife.ButterKnife; |
|
17 |
+import butterknife.OnClick; |
|
15 | 18 |
|
16 | 19 |
public class UploadActivity extends AppCompatActivity implements UploadContract.UploadView{ |
17 | 20 |
|
18 |
- private TextView btStatusTextView; |
|
19 |
- private ImageView btStatusImageView; |
|
20 |
- private View noDataLayout; |
|
21 |
+ @BindView(R.id.tv_bt_status) TextView btStatusTextView; |
|
22 |
+ @BindView(R.id.iv_bt_status) ImageView btStatusImageView; |
|
23 |
+ @BindView(R.id.icon_no_data) View noDataLayout; |
|
24 |
+ @BindView(R.id.recycler_view_sessions) RecyclerView sessionsRecyclerView; |
|
21 | 25 |
private SessionRecyclerAdapter adapter; |
22 |
- private RecyclerView sessionsRecyclerView; |
|
23 | 26 |
private UploadContract.UploadPresenter presenter; |
24 | 27 |
|
25 | 28 |
@Override |
26 | 29 |
protected void onCreate(Bundle savedInstanceState) { |
27 | 30 |
super.onCreate(savedInstanceState); |
28 | 31 |
setContentView(R.layout.activity_upload); |
32 |
+ ButterKnife.bind(this); |
|
29 | 33 |
|
30 | 34 |
presenter = new UploadPresenterImpl(this,this); |
31 |
- noDataLayout = findViewById(R.id.icon_no_data); |
|
32 |
- btStatusImageView = (ImageView)findViewById(R.id.iv_bt_status); |
|
33 |
- btStatusTextView = (TextView)findViewById(R.id.tv_bt_status); |
|
34 |
- sessionsRecyclerView = (RecyclerView)findViewById(R.id.recycler_view_sessions); |
|
35 | 35 |
adapter = new SessionRecyclerAdapter(this); |
36 | 36 |
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this,2,LinearLayoutManager.VERTICAL,false); |
37 | 37 |
sessionsRecyclerView.setLayoutManager(layoutManager); |
38 | 38 |
sessionsRecyclerView.setAdapter(adapter); |
39 |
- findViewById(R.id.iv_briefs).setOnClickListener(new View.OnClickListener(){ |
|
40 |
- @Override |
|
41 |
- public void onClick(View view) { |
|
42 |
- presenter.jumpToBriefs(); |
|
43 |
- } |
|
44 |
- }); |
|
45 |
- |
|
46 |
- findViewById(R.id.iv_add_session).setOnClickListener(new View.OnClickListener(){ |
|
47 |
- @Override |
|
48 |
- public void onClick(View view) { |
|
49 |
- presenter.jumpToNewSession(); |
|
50 |
- } |
|
51 |
- }); |
|
52 |
- |
|
53 |
- btStatusImageView.setOnClickListener(new View.OnClickListener(){ |
|
54 |
- @Override |
|
55 |
- public void onClick(View view) { |
|
56 |
- presenter.checkBTStatus(); |
|
57 |
- } |
|
58 |
- }); |
|
59 |
- |
|
60 | 39 |
} |
61 | 40 |
|
62 | 41 |
@Override |
@@ -71,6 +50,22 @@ public class UploadActivity extends AppCompatActivity implements UploadContract. |
||
71 | 50 |
presenter.stop(); |
72 | 51 |
} |
73 | 52 |
|
53 |
+ @OnClick(R.id.iv_briefs) |
|
54 |
+ void jumpToBriefs(){ |
|
55 |
+ |
|
56 |
+ } |
|
57 |
+ |
|
58 |
+ @OnClick(R.id.iv_add_session) |
|
59 |
+ void jumpToNewSession(){ |
|
60 |
+ presenter.jumpToNewSession(); |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ @OnClick(R.id.iv_bt_status) |
|
64 |
+ void checkBTStatus(){ |
|
65 |
+ presenter.checkBTStatus(); |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ |
|
74 | 69 |
@Override |
75 | 70 |
public void addNewSessionView(SessionBean bean) { |
76 | 71 |
|
@@ -6,7 +6,7 @@ buildscript { |
||
6 | 6 |
} |
7 | 7 |
dependencies { |
8 | 8 |
classpath 'com.android.tools.build:gradle:2.1.2' |
9 |
- |
|
9 |
+ classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' |
|
10 | 10 |
// NOTE: Do not place your application dependencies here; they belong |
11 | 11 |
// in the individual module build.gradle files |
12 | 12 |
} |