@@ -1,9 +1,17 @@ |
||
1 | 1 |
package ai.pai.lensman.briefs; |
2 | 2 |
|
3 | 3 |
import android.content.Intent; |
4 |
+import android.graphics.Color; |
|
4 | 5 |
import android.os.Bundle; |
5 | 6 |
import android.support.annotation.Nullable; |
7 |
+import android.text.TextUtils; |
|
8 |
+import android.view.Gravity; |
|
9 |
+import android.view.View; |
|
10 |
+import android.widget.TextSwitcher; |
|
6 | 11 |
import android.widget.TextView; |
12 |
+import android.widget.ViewSwitcher; |
|
13 |
+ |
|
14 |
+import com.android.common.utils.DeviceUtils; |
|
7 | 15 |
|
8 | 16 |
import ai.pai.lensman.R; |
9 | 17 |
import ai.pai.lensman.base.BaseActivity; |
@@ -21,6 +29,8 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
||
21 | 29 |
@BindView(R.id.tv_today_incoming_account) TextView todayIncomingText; |
22 | 30 |
@BindView(R.id.tv_total_incoming_account) TextView totalIncomingText; |
23 | 31 |
@BindView(R.id.tv_today_capture_hours_account) TextView todayCaptureHoursText; |
32 |
+ @BindView(R.id.switcher_order_msg) TextSwitcher orderMsgSwitch; |
|
33 |
+ @BindView(R.id.switcher_system_msg) TextSwitcher systemMsgSwitch; |
|
24 | 34 |
|
25 | 35 |
private BriefsPresenter presenter; |
26 | 36 |
|
@@ -30,6 +40,18 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
||
30 | 40 |
setContentView(R.layout.activity_briefs); |
31 | 41 |
unbinder = ButterKnife.bind(this); |
32 | 42 |
|
43 |
+ ViewSwitcher.ViewFactory factory = new ViewSwitcher.ViewFactory() { |
|
44 |
+ |
|
45 |
+ public View makeView() { |
|
46 |
+ TextView myText = new TextView(BriefsActivity.this); |
|
47 |
+ myText.setGravity(Gravity.CENTER_VERTICAL); |
|
48 |
+ myText.setTextSize(18); |
|
49 |
+ myText.setTextColor(Color.parseColor("#333333")); |
|
50 |
+ return myText; |
|
51 |
+ } |
|
52 |
+ }; |
|
53 |
+ orderMsgSwitch.setFactory(factory); |
|
54 |
+ systemMsgSwitch.setFactory(factory); |
|
33 | 55 |
presenter = new BriefsPresenter(this); |
34 | 56 |
presenter.start(); |
35 | 57 |
} |
@@ -61,4 +83,16 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
||
61 | 83 |
todayCaptureHoursText.setText(String.valueOf(bean.todayUpload)); |
62 | 84 |
} |
63 | 85 |
|
86 |
+ @Override |
|
87 |
+ public void updateMessageBar(final String sysMsg, final String orderMsg) { |
|
88 |
+ systemMsgSwitch.post(new Runnable() { |
|
89 |
+ @Override |
|
90 |
+ public void run() { |
|
91 |
+ orderMsgSwitch.setText(TextUtils.isEmpty(orderMsg) ? getString(R.string.no_order_msg) : orderMsg); |
|
92 |
+ systemMsgSwitch.setText(TextUtils.isEmpty(sysMsg) ? getString(R.string.no_system_msg): sysMsg); |
|
93 |
+ } |
|
94 |
+ }); |
|
95 |
+ |
|
96 |
+ } |
|
97 |
+ |
|
64 | 98 |
} |
@@ -11,6 +11,7 @@ public class BriefsContract { |
||
11 | 11 |
|
12 | 12 |
public interface View extends BaseView{ |
13 | 13 |
void updateUserInfo(BriefsBean bean); |
14 |
+ void updateMessageBar(String sysMsg,String orderMsg); |
|
14 | 15 |
} |
15 | 16 |
|
16 | 17 |
public interface Presenter extends BasePresenter{ |
@@ -2,17 +2,21 @@ package ai.pai.lensman.briefs; |
||
2 | 2 |
|
3 | 3 |
import com.android.common.utils.NetworkUtil; |
4 | 4 |
|
5 |
+import java.util.Random; |
|
6 |
+import java.util.Timer; |
|
7 |
+import java.util.TimerTask; |
|
8 |
+ |
|
5 | 9 |
import ai.pai.lensman.App; |
6 | 10 |
import ai.pai.lensman.base.BaseInteractor; |
7 | 11 |
import ai.pai.lensman.bean.BriefsBean; |
8 | 12 |
|
9 |
-/** |
|
10 |
- * Created by chengzhenyu on 2016/8/22. |
|
11 |
- */ |
|
12 | 13 |
public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.InteractorListener<BriefsBean> { |
13 | 14 |
|
14 | 15 |
private BriefsContract.View briefsView; |
15 | 16 |
private BriefsInteractor interactor; |
17 |
+ private BriefsBean briefsBean; |
|
18 |
+ private String NULL_STR = ""; |
|
19 |
+ private Timer timer; |
|
16 | 20 |
|
17 | 21 |
public BriefsPresenter(BriefsContract.View briefsView){ |
18 | 22 |
this.briefsView = briefsView; |
@@ -27,11 +31,26 @@ public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor. |
||
27 | 31 |
@Override |
28 | 32 |
public void stop() { |
29 | 33 |
interactor.cancelJob(); |
34 |
+ if(timer!=null){ |
|
35 |
+ timer.cancel(); |
|
36 |
+ } |
|
30 | 37 |
} |
31 | 38 |
|
32 | 39 |
@Override |
33 | 40 |
public void onInteractSuccess(BriefsBean bean) { |
41 |
+ this.briefsBean = bean; |
|
34 | 42 |
briefsView.updateUserInfo(bean); |
43 |
+ briefsView.updateMessageBar(getNextSystemMessage(),getNextOrderMessage()); |
|
44 |
+ if(timer!=null){ |
|
45 |
+ timer.cancel(); |
|
46 |
+ } |
|
47 |
+ timer = new Timer(); |
|
48 |
+ timer.schedule(new TimerTask() { |
|
49 |
+ @Override |
|
50 |
+ public void run() { |
|
51 |
+ briefsView.updateMessageBar(getNextSystemMessage(),getNextOrderMessage()); |
|
52 |
+ } |
|
53 |
+ },1000,3000); |
|
35 | 54 |
} |
36 | 55 |
|
37 | 56 |
@Override |
@@ -41,4 +60,18 @@ public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor. |
||
41 | 60 |
} |
42 | 61 |
} |
43 | 62 |
|
63 |
+ private String getNextOrderMessage(){ |
|
64 |
+ if(briefsBean == null || briefsBean.msgList==null || briefsBean.msgList.size()==0){ |
|
65 |
+ return NULL_STR; |
|
66 |
+ } |
|
67 |
+ return briefsBean.msgList.get(new Random().nextInt(briefsBean.msgList.size())).content; |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ private String getNextSystemMessage(){ |
|
71 |
+ if(briefsBean == null || briefsBean.systemMsgList==null || briefsBean.systemMsgList.size()==0){ |
|
72 |
+ return NULL_STR; |
|
73 |
+ } |
|
74 |
+ return briefsBean.systemMsgList.get(new Random().nextInt(briefsBean.systemMsgList.size())).content; |
|
75 |
+ } |
|
76 |
+ |
|
44 | 77 |
} |
@@ -95,6 +95,7 @@ |
||
95 | 95 |
android:layout_width="match_parent" |
96 | 96 |
android:layout_height="90dp" |
97 | 97 |
android:orientation="horizontal" |
98 |
+ android:gravity="center_vertical" |
|
98 | 99 |
android:background="@color/background_white"> |
99 | 100 |
|
100 | 101 |
<RelativeLayout |
@@ -124,6 +125,11 @@ |
||
124 | 125 |
|
125 | 126 |
</RelativeLayout> |
126 | 127 |
|
128 |
+ <View |
|
129 |
+ android:layout_width="1px" |
|
130 |
+ android:layout_height="45dp" |
|
131 |
+ android:background="@color/text_hint_grey_color"/> |
|
132 |
+ |
|
127 | 133 |
<RelativeLayout |
128 | 134 |
android:layout_width="0dp" |
129 | 135 |
android:layout_weight="1" |
@@ -161,6 +167,81 @@ |
||
161 | 167 |
android:background="@color/background_white" |
162 | 168 |
android:orientation="vertical"> |
163 | 169 |
|
170 |
+ <LinearLayout |
|
171 |
+ android:layout_width="match_parent" |
|
172 |
+ android:layout_height="32dp" |
|
173 |
+ android:orientation="horizontal"> |
|
174 |
+ |
|
175 |
+ <TextView |
|
176 |
+ android:layout_width="wrap_content" |
|
177 |
+ android:layout_height="wrap_content" |
|
178 |
+ android:layout_gravity="center_vertical" |
|
179 |
+ android:text="@string/message" |
|
180 |
+ android:paddingLeft="10dp" |
|
181 |
+ android:textColor="@color/_7B8088" |
|
182 |
+ android:textSize="14sp" |
|
183 |
+ /> |
|
184 |
+ </LinearLayout> |
|
185 |
+ |
|
186 |
+ </LinearLayout> |
|
187 |
+ |
|
188 |
+ <View |
|
189 |
+ android:layout_width="match_parent" |
|
190 |
+ android:layout_height="1px" |
|
191 |
+ android:background="@color/text_hint_grey_color"/> |
|
192 |
+ |
|
193 |
+ <LinearLayout |
|
194 |
+ android:layout_width="match_parent" |
|
195 |
+ android:layout_height="44dp" |
|
196 |
+ android:paddingLeft="10dp" |
|
197 |
+ android:paddingRight="6dp" |
|
198 |
+ android:background="@color/background_white" |
|
199 |
+ android:orientation="horizontal"> |
|
200 |
+ |
|
201 |
+ <TextSwitcher |
|
202 |
+ android:id="@+id/switcher_system_msg" |
|
203 |
+ android:layout_width="0dp" |
|
204 |
+ android:inAnimation="@android:anim/slide_in_left" |
|
205 |
+ android:outAnimation="@android:anim/slide_out_right" |
|
206 |
+ android:layout_height="wrap_content" |
|
207 |
+ android:layout_gravity="center_vertical" |
|
208 |
+ android:layout_weight="1"/> |
|
209 |
+ |
|
210 |
+ <ImageView |
|
211 |
+ android:layout_width="10dp" |
|
212 |
+ android:layout_height="18dp" |
|
213 |
+ android:layout_gravity="center_vertical" |
|
214 |
+ android:src="@drawable/arrow_right"/> |
|
215 |
+ |
|
216 |
+</LinearLayout> |
|
217 |
+ |
|
218 |
+ <View |
|
219 |
+ android:layout_width="match_parent" |
|
220 |
+ android:layout_height="1px" |
|
221 |
+ android:background="@color/text_hint_grey_color"/> |
|
222 |
+ |
|
223 |
+ <LinearLayout |
|
224 |
+ android:layout_width="match_parent" |
|
225 |
+ android:layout_height="44dp" |
|
226 |
+ android:paddingLeft="10dp" |
|
227 |
+ android:paddingRight="6dp" |
|
228 |
+ android:background="@color/background_white" |
|
229 |
+ android:orientation="horizontal"> |
|
230 |
+ |
|
231 |
+ <TextSwitcher |
|
232 |
+ android:id="@+id/switcher_order_msg" |
|
233 |
+ android:layout_width="0dp" |
|
234 |
+ android:layout_height="wrap_content" |
|
235 |
+ android:inAnimation="@android:anim/slide_in_left" |
|
236 |
+ android:outAnimation="@android:anim/slide_out_right" |
|
237 |
+ android:layout_gravity="center_vertical" |
|
238 |
+ android:layout_weight="1"/> |
|
239 |
+ |
|
240 |
+ <ImageView |
|
241 |
+ android:layout_width="10dp" |
|
242 |
+ android:layout_height="18dp" |
|
243 |
+ android:layout_gravity="center_vertical" |
|
244 |
+ android:src="@drawable/arrow_right"/> |
|
164 | 245 |
|
165 | 246 |
</LinearLayout> |
166 | 247 |
|
@@ -169,6 +250,7 @@ |
||
169 | 250 |
android:layout_marginTop="8dp" |
170 | 251 |
android:layout_width="match_parent" |
171 | 252 |
android:layout_height="130dp" |
253 |
+ android:gravity="center_vertical" |
|
172 | 254 |
android:background="@color/background_white" |
173 | 255 |
android:orientation="horizontal"> |
174 | 256 |
|
@@ -201,6 +283,11 @@ |
||
201 | 283 |
|
202 | 284 |
</RelativeLayout> |
203 | 285 |
|
286 |
+ <View |
|
287 |
+ android:layout_width="1px" |
|
288 |
+ android:layout_height="45dp" |
|
289 |
+ android:background="@color/text_hint_grey_color"/> |
|
290 |
+ |
|
204 | 291 |
<RelativeLayout |
205 | 292 |
android:layout_width="0dp" |
206 | 293 |
android:layout_weight="1" |
@@ -230,6 +317,10 @@ |
||
230 | 317 |
|
231 | 318 |
</RelativeLayout> |
232 | 319 |
|
320 |
+ <View |
|
321 |
+ android:layout_width="1px" |
|
322 |
+ android:layout_height="45dp" |
|
323 |
+ android:background="@color/text_hint_grey_color"/> |
|
233 | 324 |
|
234 | 325 |
<RelativeLayout |
235 | 326 |
android:layout_width="0dp" |
@@ -52,4 +52,10 @@ |
||
52 | 52 |
<string name="photo_upload_count">累计上传</string> |
53 | 53 |
|
54 | 54 |
<string name="total_incoming">累计收入</string> |
55 |
+ |
|
56 |
+ <string name="message">消息</string> |
|
57 |
+ |
|
58 |
+ <string name="no_system_msg">暂无新系统消息</string> |
|
59 |
+ |
|
60 |
+ <string name="no_order_msg">暂无新购买消息</string> |
|
55 | 61 |
</resources> |