@@ -1,6 +1,7 @@ |
||
1 | 1 |
package ai.pai.lensman.upload; |
2 | 2 |
|
3 | 3 |
import android.content.Context; |
4 |
+import android.content.Intent; |
|
4 | 5 |
import android.support.v7.widget.RecyclerView; |
5 | 6 |
import android.view.LayoutInflater; |
6 | 7 |
import android.view.View; |
@@ -9,25 +10,32 @@ import android.widget.ImageView; |
||
9 | 10 |
import android.widget.TextView; |
10 | 11 |
|
11 | 12 |
import com.android.common.utils.DeviceUtils; |
13 |
+import com.nostra13.universalimageloader.core.DisplayImageOptions; |
|
12 | 14 |
|
15 |
+import java.io.File; |
|
13 | 16 |
import java.util.ArrayList; |
14 | 17 |
|
15 | 18 |
import ai.pai.lensman.R; |
16 | 19 |
import ai.pai.lensman.bean.SessionBean; |
20 |
+import ai.pai.lensman.session.SessionActivity; |
|
21 |
+import ai.pai.lensman.utils.Constants; |
|
22 |
+import ai.pai.lensman.utils.ImageLoaderUtils; |
|
17 | 23 |
import butterknife.BindView; |
18 | 24 |
import butterknife.ButterKnife; |
19 | 25 |
|
20 | 26 |
public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecyclerAdapter.MyViewHolder> { |
21 | 27 |
|
28 |
+ private int width; |
|
22 | 29 |
private Context context; |
23 | 30 |
private LayoutInflater mInflater; |
31 |
+ private DisplayImageOptions options; |
|
24 | 32 |
private ArrayList<SessionBean> sessionList; |
25 |
- private int width; |
|
26 | 33 |
|
27 | 34 |
public SessionRecyclerAdapter(Context context){ |
28 | 35 |
this.context = context; |
29 | 36 |
width = DeviceUtils.getScreenWidth(this.context)/2; |
30 | 37 |
mInflater = LayoutInflater.from(this.context); |
38 |
+ options = ImageLoaderUtils.getOptions(R.drawable.default_img); |
|
31 | 39 |
} |
32 | 40 |
|
33 | 41 |
public synchronized void addSessionBean(SessionBean item){ |
@@ -77,7 +85,10 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
77 | 85 |
return; |
78 | 86 |
} |
79 | 87 |
final SessionBean item = sessionList.get(position); |
80 |
- holder.photo.setImageResource(R.drawable.demo1); |
|
88 |
+ if(item.sessionPhotos!=null && item.sessionPhotos.size()>0){ |
|
89 |
+ String path = Constants.APP_IMAGE_DIR + File.separator+item.sessionId+File.separator+Constants.THUMBNAIL_DIR_NAME+File.separator+item.sessionPhotos.get(0).photoName; |
|
90 |
+ ImageLoaderUtils.displayLocalImage(path, holder.photo, options); |
|
91 |
+ } |
|
81 | 92 |
int height = width; |
82 | 93 |
ViewGroup.LayoutParams lp=holder.photo.getLayoutParams(); |
83 | 94 |
lp.width = width; |
@@ -87,7 +98,9 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
87 | 98 |
holder.itemView.setOnClickListener(new View.OnClickListener(){ |
88 | 99 |
@Override |
89 | 100 |
public void onClick(View v) { |
90 |
- |
|
101 |
+ Intent intent = new Intent(context, SessionActivity.class); |
|
102 |
+ intent.putExtra("session",item); |
|
103 |
+ context.startActivity(intent); |
|
91 | 104 |
} |
92 | 105 |
}); |
93 | 106 |
} |
@@ -9,7 +9,6 @@ import android.widget.ImageView; |
||
9 | 9 |
import android.widget.TextView; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
-import java.util.Random; |
|
13 | 12 |
|
14 | 13 |
import ai.pai.lensman.R; |
15 | 14 |
import ai.pai.lensman.base.BaseActivity; |
@@ -23,10 +22,9 @@ import butterknife.OnClick; |
||
23 | 22 |
|
24 | 23 |
public class UploadActivity extends BaseActivity implements UploadContract.View { |
25 | 24 |
|
26 |
- @BindView(R.id.tv_bt_status) TextView btStatusTextView; |
|
27 |
- @BindView(R.id.iv_bt_status) ImageView btStatusImageView; |
|
28 |
- @BindView(R.id.icon_no_data) |
|
29 |
- android.view.View noDataLayout; |
|
25 |
+ @BindView(R.id.tv_box_status) TextView boxStatusTextView; |
|
26 |
+ @BindView(R.id.iv_box_status) ImageView boxStatusImageView; |
|
27 |
+ @BindView(R.id.icon_no_data) android.view.View noDataLayout; |
|
30 | 28 |
@BindView(R.id.recycler_view_sessions) RecyclerView sessionsRecyclerView; |
31 | 29 |
private SessionRecyclerAdapter adapter; |
32 | 30 |
private UploadContract.Presenter presenter; |
@@ -37,7 +35,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
37 | 35 |
setContentView(R.layout.activity_upload); |
38 | 36 |
ButterKnife.bind(this); |
39 | 37 |
|
40 |
- presenter = new UploadPresenter(this); |
|
38 |
+ presenter = new UploadPresenter(this,Preferences.getInstance(this).getLensManId()); |
|
41 | 39 |
adapter = new SessionRecyclerAdapter(this); |
42 | 40 |
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this,2,LinearLayoutManager.VERTICAL,false); |
43 | 41 |
sessionsRecyclerView.setLayoutManager(layoutManager); |
@@ -63,13 +61,11 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
63 | 61 |
|
64 | 62 |
@OnClick(R.id.iv_add_session) |
65 | 63 |
void jumpToNewSession(){ |
66 |
- SessionBean sessionBean = new SessionBean(); |
|
67 |
- |
|
68 |
- jumpToSelectedSession(sessionBean); |
|
64 |
+ jumpToSelectedSession( presenter.createNewSession()); |
|
69 | 65 |
} |
70 | 66 |
|
71 |
- @OnClick(R.id.iv_bt_status) |
|
72 |
- void checkBTStatus(){ |
|
67 |
+ @OnClick(R.id.iv_box_status) |
|
68 |
+ void checkBoxStatus(){ |
|
73 | 69 |
|
74 | 70 |
} |
75 | 71 |
|
@@ -80,50 +76,28 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
80 | 76 |
} |
81 | 77 |
|
82 | 78 |
@Override |
83 |
- public void showBTDisconnectedView() { |
|
84 |
- runOnUiThread(new Runnable() { |
|
85 |
- @Override |
|
86 |
- public void run() { |
|
87 |
- btStatusTextView.setText(R.string.bt_disconnected); |
|
88 |
- btStatusImageView.setImageResource(R.drawable.wifi_disconnect); |
|
89 |
- } |
|
90 |
- }); |
|
91 |
- |
|
79 |
+ public void showBoxDisconnectedView() { |
|
80 |
+ boxStatusTextView.setText(R.string.bt_disconnected); |
|
81 |
+ boxStatusImageView.setImageResource(R.drawable.wifi_disconnect); |
|
92 | 82 |
} |
93 | 83 |
|
94 | 84 |
@Override |
95 |
- public void showBTConnectedView() { |
|
96 |
- runOnUiThread(new Runnable() { |
|
97 |
- @Override |
|
98 |
- public void run() { |
|
99 |
- btStatusTextView.setText(R.string.bt_connected); |
|
100 |
- btStatusImageView.setImageResource(R.drawable.wifi_connect); |
|
101 |
- } |
|
102 |
- }); |
|
85 |
+ public void showBoxConnectedView() { |
|
86 |
+ boxStatusTextView.setText(R.string.bt_connected); |
|
87 |
+ boxStatusImageView.setImageResource(R.drawable.wifi_connect); |
|
103 | 88 |
} |
104 | 89 |
|
105 | 90 |
@Override |
106 | 91 |
public void showEmptyView() { |
107 |
- runOnUiThread(new Runnable() { |
|
108 |
- @Override |
|
109 |
- public void run() { |
|
110 |
- sessionsRecyclerView.setVisibility(android.view.View.GONE); |
|
111 |
- noDataLayout.setVisibility(android.view.View.VISIBLE); |
|
112 |
- } |
|
113 |
- }); |
|
92 |
+ sessionsRecyclerView.setVisibility(android.view.View.GONE); |
|
93 |
+ noDataLayout.setVisibility(android.view.View.VISIBLE); |
|
114 | 94 |
|
115 | 95 |
} |
116 | 96 |
|
117 | 97 |
@Override |
118 | 98 |
public void showSessionViews() { |
119 |
- runOnUiThread(new Runnable() { |
|
120 |
- @Override |
|
121 |
- public void run() { |
|
122 |
- noDataLayout.setVisibility(android.view.View.GONE); |
|
123 |
- sessionsRecyclerView.setVisibility(android.view.View.VISIBLE); |
|
124 |
- } |
|
125 |
- }); |
|
126 |
- |
|
99 |
+ noDataLayout.setVisibility(android.view.View.GONE); |
|
100 |
+ sessionsRecyclerView.setVisibility(android.view.View.VISIBLE); |
|
127 | 101 |
} |
128 | 102 |
|
129 | 103 |
@Override |
@@ -133,21 +107,12 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
133 | 107 |
|
134 | 108 |
@Override |
135 | 109 |
public void refreshSessionViews(final ArrayList<SessionBean> sessionList) { |
136 |
- runOnUiThread(new Runnable() { |
|
137 |
- @Override |
|
138 |
- public void run() { |
|
139 |
- adapter.clear(); |
|
140 |
- adapter.addSessionBeans(sessionList); |
|
141 |
- } |
|
142 |
- }); |
|
110 |
+ adapter.clear(); |
|
111 |
+ adapter.addSessionBeans(sessionList); |
|
143 | 112 |
} |
144 | 113 |
|
145 | 114 |
|
146 |
- public void jumpToSelectedSession(SessionBean sessionBean) { |
|
147 |
- sessionBean.lensmanId = Preferences.getInstance(this).getLensManId(); |
|
148 |
- sessionBean.sessionDate=20160813; |
|
149 |
- sessionBean.sessionSeq = new Random().nextInt(10000); |
|
150 |
- sessionBean.sessionId ="chengzhenyu_test"+sessionBean.sessionSeq; |
|
115 |
+ private void jumpToSelectedSession(SessionBean sessionBean) { |
|
151 | 116 |
Intent intent = new Intent(this, SessionActivity.class); |
152 | 117 |
intent.putExtra("session",sessionBean); |
153 | 118 |
startActivity(intent); |
@@ -14,8 +14,8 @@ public class UploadContract { |
||
14 | 14 |
interface View extends BaseView { |
15 | 15 |
|
16 | 16 |
void addNewSessionView(SessionBean bean); |
17 |
- void showBTDisconnectedView(); |
|
18 |
- void showBTConnectedView(); |
|
17 |
+ void showBoxDisconnectedView(); |
|
18 |
+ void showBoxConnectedView(); |
|
19 | 19 |
void showEmptyView(); |
20 | 20 |
void showSessionViews(); |
21 | 21 |
void updateSessionUploadView(SessionBean bean); |
@@ -23,7 +23,7 @@ public class UploadContract { |
||
23 | 23 |
} |
24 | 24 |
|
25 | 25 |
interface Presenter extends BasePresenter{ |
26 |
- |
|
26 |
+ SessionBean createNewSession(); |
|
27 | 27 |
} |
28 | 28 |
|
29 | 29 |
} |
@@ -8,10 +8,12 @@ public class UploadPresenter implements UploadContract.Presenter { |
||
8 | 8 |
|
9 | 9 |
private UploadContract.View uploadView; |
10 | 10 |
private ArrayList<SessionBean> sessionList; |
11 |
+ private String lensmanId; |
|
12 |
+ private int sessionSeq; |
|
11 | 13 |
|
12 |
- |
|
13 |
- public UploadPresenter( UploadContract.View view){ |
|
14 |
+ public UploadPresenter(UploadContract.View view,String lensmanId){ |
|
14 | 15 |
this.uploadView = view; |
16 |
+ this.lensmanId = lensmanId; |
|
15 | 17 |
sessionList = new ArrayList<>(); |
16 | 18 |
} |
17 | 19 |
|
@@ -24,6 +26,7 @@ public class UploadPresenter implements UploadContract.Presenter { |
||
24 | 26 |
uploadView.showSessionViews(); |
25 | 27 |
uploadView.refreshSessionViews(sessionList); |
26 | 28 |
} |
29 |
+ sessionSeq = sessionList.size(); |
|
27 | 30 |
} |
28 | 31 |
|
29 | 32 |
@Override |
@@ -31,4 +34,14 @@ public class UploadPresenter implements UploadContract.Presenter { |
||
31 | 34 |
|
32 | 35 |
} |
33 | 36 |
|
37 |
+ @Override |
|
38 |
+ public SessionBean createNewSession() { |
|
39 |
+ SessionBean sessionBean = new SessionBean(); |
|
40 |
+ sessionBean.lensmanId = lensmanId; |
|
41 |
+ sessionBean.sessionDate=20160813; |
|
42 |
+ sessionBean.sessionSeq = sessionSeq+1; |
|
43 |
+ sessionBean.sessionId ="chengzhenyu_test"+sessionBean.sessionSeq; |
|
44 |
+ sessionList.add(sessionBean); |
|
45 |
+ return sessionBean; |
|
46 |
+ } |
|
34 | 47 |
} |
@@ -76,17 +76,10 @@ |
||
76 | 76 |
android:layout_height="match_parent" |
77 | 77 |
android:layout_below="@id/title_bar_with_back_btn"> |
78 | 78 |
|
79 |
- <android.support.v4.widget.SwipeRefreshLayout |
|
80 |
- android:id="@+id/refresh_layout" |
|
79 |
+ <android.support.v7.widget.RecyclerView |
|
80 |
+ android:id="@+id/recycler_view_photos" |
|
81 | 81 |
android:layout_width="match_parent" |
82 |
- android:layout_height="match_parent"> |
|
83 |
- |
|
84 |
- <android.support.v7.widget.RecyclerView |
|
85 |
- android:id="@+id/recycler_view_photos" |
|
86 |
- android:layout_width="match_parent" |
|
87 |
- android:layout_height="match_parent" /> |
|
88 |
- |
|
89 |
- </android.support.v4.widget.SwipeRefreshLayout> |
|
82 |
+ android:layout_height="match_parent" /> |
|
90 | 83 |
|
91 | 84 |
<ImageButton |
92 | 85 |
android:id="@+id/btn_session_complete" |
@@ -21,7 +21,7 @@ |
||
21 | 21 |
android:layout_height="32dp" |
22 | 22 |
android:layout_gravity="center_vertical" |
23 | 23 |
android:layout_marginLeft="6dp" |
24 |
- android:src="@drawable/ic_launcher" /> |
|
24 |
+ android:src="@drawable/logo" /> |
|
25 | 25 |
|
26 | 26 |
<TextView |
27 | 27 |
android:layout_width="0dp" |
@@ -43,18 +43,12 @@ |
||
43 | 43 |
android:layout_centerInParent="true" |
44 | 44 |
android:src="@drawable/no_photo_tip" /> |
45 | 45 |
|
46 |
- <android.support.v4.widget.SwipeRefreshLayout |
|
47 |
- android:id="@+id/swipe_refresh_layout_sessions" |
|
46 |
+ <android.support.v7.widget.RecyclerView |
|
47 |
+ android:id="@+id/recycler_view_sessions" |
|
48 | 48 |
android:layout_width="match_parent" |
49 | 49 |
android:layout_height="match_parent" |
50 |
- android:layout_below="@id/title_layout"> |
|
50 |
+ android:layout_below="@id/title_layout"/> |
|
51 | 51 |
|
52 |
- <android.support.v7.widget.RecyclerView |
|
53 |
- android:id="@+id/recycler_view_sessions" |
|
54 |
- android:layout_width="match_parent" |
|
55 |
- android:layout_height="match_parent" /> |
|
56 |
- |
|
57 |
- </android.support.v4.widget.SwipeRefreshLayout> |
|
58 | 52 |
|
59 | 53 |
<RelativeLayout |
60 | 54 |
android:layout_width="match_parent" |
@@ -75,7 +69,7 @@ |
||
75 | 69 |
android:gravity="center_horizontal"> |
76 | 70 |
|
77 | 71 |
<ImageView |
78 |
- android:id="@+id/iv_bt_status" |
|
72 |
+ android:id="@+id/iv_box_status" |
|
79 | 73 |
android:layout_width="24dp" |
80 | 74 |
android:layout_height="24dp" |
81 | 75 |
android:layout_centerHorizontal="true" |
@@ -83,10 +77,10 @@ |
||
83 | 77 |
android:src="@drawable/wifi_connect" /> |
84 | 78 |
|
85 | 79 |
<TextView |
86 |
- android:id="@+id/tv_bt_status" |
|
80 |
+ android:id="@+id/tv_box_status" |
|
87 | 81 |
android:layout_width="wrap_content" |
88 | 82 |
android:layout_height="wrap_content" |
89 |
- android:layout_below="@id/iv_bt_status" |
|
83 |
+ android:layout_below="@id/iv_box_status" |
|
90 | 84 |
android:layout_centerHorizontal="true" |
91 | 85 |
android:text="@string/bt_connected" |
92 | 86 |
android:textColor="@color/grey" |