@@ -49,7 +49,7 @@ android { |
||
49 | 49 |
zipAlignEnabled false |
50 | 50 |
minifyEnabled false |
51 | 51 |
shrinkResources false |
52 |
- buildConfigField "boolean", "isTestMode", "false" |
|
52 |
+ buildConfigField "boolean", "isTestMode", "true" |
|
53 | 53 |
signingConfig signingConfigs.releaseConfig |
54 | 54 |
} |
55 | 55 |
} |
@@ -5,12 +5,9 @@ package ai.pai.lensman.bean; |
||
5 | 5 |
*/ |
6 | 6 |
public class MessageBean { |
7 | 7 |
|
8 |
- public String createTime; |
|
9 |
- public String senderAvatarUrl; |
|
10 |
- public String senderName; |
|
11 |
- public boolean isRead; |
|
12 |
- public String msgId; |
|
8 |
+ public String paidTime; |
|
9 |
+ public int totalFee; |
|
10 |
+ public String photoId; |
|
13 | 11 |
public String content; |
14 |
- |
|
15 | 12 |
public GroupPhotoItem photoItem; |
16 | 13 |
} |
@@ -21,12 +21,14 @@ import butterknife.OnClick; |
||
21 | 21 |
|
22 | 22 |
public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
23 | 23 |
|
24 |
- @BindView(R.id.tv_today_upload_num) TextView todayUploadNumText; |
|
25 |
- @BindView(R.id.tv_today_point_amount) TextView todayPointAmountText; |
|
26 |
- @BindView(R.id.tv_week_origin_sold_num) TextView weekOriginSoldNumText; |
|
27 |
- @BindView(R.id.tv_week_point_amount) TextView weekPotinAmountText; |
|
28 |
- @BindView(R.id.switcher_order_msg) TextSwitcher orderMsgSwitch; |
|
29 |
- @BindView(R.id.switcher_system_msg) TextSwitcher systemMsgSwitch; |
|
24 |
+ @BindView(R.id.tv_today_upload_num) TextView todayUploadNumText; |
|
25 |
+ @BindView(R.id.tv_today_point_amount) TextView todayPointAmountText; |
|
26 |
+ @BindView(R.id.tv_week_origin_sold_num) TextView weekOriginSoldNumText; |
|
27 |
+ @BindView(R.id.tv_week_point_amount) TextView weekPotinAmountText; |
|
28 |
+ @BindView(R.id.switcher_order_msg) TextSwitcher orderMsgSwitch; |
|
29 |
+ @BindView(R.id.switcher_system_msg) TextSwitcher systemMsgSwitch; |
|
30 |
+ @BindView(R.id.tv_box_num) TextView boxNumText; |
|
31 |
+ @BindView(R.id.tv_box_status) TextView boxStatusText; |
|
30 | 32 |
|
31 | 33 |
private BriefsPresenter presenter; |
32 | 34 |
|
@@ -89,4 +91,10 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
||
89 | 91 |
|
90 | 92 |
} |
91 | 93 |
|
94 |
+ @Override |
|
95 |
+ public void updateBoxInfo(String boxNo, String boxStatus) { |
|
96 |
+ boxNumText.setText(boxNo); |
|
97 |
+ boxStatusText.setText(boxStatus); |
|
98 |
+ } |
|
99 |
+ |
|
92 | 100 |
} |
@@ -12,6 +12,7 @@ public class BriefsContract { |
||
12 | 12 |
public interface View extends BaseView{ |
13 | 13 |
void updateUserInfo(BriefsBean bean); |
14 | 14 |
void updateMessageBar(String sysMsg,String orderMsg); |
15 |
+ void updateBoxInfo(String boxNo,String boxStatus); |
|
15 | 16 |
} |
16 | 17 |
|
17 | 18 |
public interface Presenter extends BasePresenter{ |
@@ -77,12 +77,9 @@ public class BriefsInteractor implements BaseInteractor { |
||
77 | 77 |
for(int count = 0; count<msgArray.length();count++){ |
78 | 78 |
JSONObject childMsg = msgArray.getJSONObject(count); |
79 | 79 |
MessageBean childBean = new MessageBean(); |
80 |
- childBean.createTime = JSONParseUtils.getJSONString(childMsg.getString("created_at")); |
|
81 |
- childBean.isRead = childMsg.getBoolean("read"); |
|
82 |
- childBean.msgId = childMsg.getString("pk"); |
|
83 |
- childBean.senderName = JSONParseUtils.getJSONString(childMsg.getString("from_nickname")); |
|
84 |
- childBean.senderAvatarUrl = JSONParseUtils.getJSONString(childMsg.getString("from_avatar")); |
|
85 |
- childBean.content = JSONParseUtils.getJSONString(childMsg.getString("msg_content")); |
|
80 |
+ childBean.paidTime = JSONParseUtils.getJSONString(childMsg.getString("paid_at")); |
|
81 |
+ childBean.photoId = JSONParseUtils.getJSONString(childMsg.getString("photo_id")); |
|
82 |
+ childBean.totalFee = childMsg.getInt("total_fee"); |
|
86 | 83 |
JSONObject photoObj = childMsg.getJSONObject("group_photo_info"); |
87 | 84 |
childBean.photoItem = GroupPhotoItem.parseFromJSON(photoObj); |
88 | 85 |
msgList.add(childBean); |
@@ -7,30 +7,42 @@ import java.util.Timer; |
||
7 | 7 |
import java.util.TimerTask; |
8 | 8 |
|
9 | 9 |
import ai.pai.lensman.App; |
10 |
+import ai.pai.lensman.R; |
|
10 | 11 |
import ai.pai.lensman.base.BaseInteractor; |
11 | 12 |
import ai.pai.lensman.bean.BriefsBean; |
13 |
+import ai.pai.lensman.bean.MessageBean; |
|
14 |
+import ai.pai.lensman.bean.SystemMessageBean; |
|
15 |
+import ai.pai.lensman.main.QueryBoxStatusInteractor; |
|
12 | 16 |
|
13 |
-public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.InteractorListener<BriefsBean> { |
|
17 |
+public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor.InteractorListener<BriefsBean>,QueryBoxStatusInteractor.BoxStatusListener { |
|
14 | 18 |
|
15 | 19 |
private BriefsContract.View briefsView; |
16 | 20 |
private BriefsInteractor interactor; |
21 |
+ private QueryBoxStatusInteractor boxStatusInteractor; |
|
22 |
+ |
|
17 | 23 |
private BriefsBean briefsBean; |
18 | 24 |
private String NULL_STR = ""; |
19 | 25 |
private Timer timer; |
26 |
+ private MessageBean currentMsg; |
|
27 |
+ private SystemMessageBean currentSystemMsg; |
|
28 |
+ |
|
20 | 29 |
|
21 | 30 |
public BriefsPresenter(BriefsContract.View briefsView){ |
22 | 31 |
this.briefsView = briefsView; |
23 | 32 |
interactor = new BriefsInteractor(this); |
33 |
+ boxStatusInteractor = new QueryBoxStatusInteractor(this); |
|
24 | 34 |
} |
25 | 35 |
|
26 | 36 |
@Override |
27 | 37 |
public void start() { |
28 | 38 |
interactor.startJob(); |
39 |
+ boxStatusInteractor.startJob(); |
|
29 | 40 |
} |
30 | 41 |
|
31 | 42 |
@Override |
32 | 43 |
public void stop() { |
33 | 44 |
interactor.cancelJob(); |
45 |
+ boxStatusInteractor.cancelJob(); |
|
34 | 46 |
if(timer!=null){ |
35 | 47 |
timer.cancel(); |
36 | 48 |
} |
@@ -61,17 +73,31 @@ public class BriefsPresenter implements BriefsContract.Presenter,BaseInteractor. |
||
61 | 73 |
} |
62 | 74 |
|
63 | 75 |
private String getNextOrderMessage(){ |
76 |
+ currentMsg = null; |
|
64 | 77 |
if(briefsBean == null || briefsBean.msgList==null || briefsBean.msgList.size()==0){ |
65 | 78 |
return NULL_STR; |
66 | 79 |
} |
67 |
- return briefsBean.msgList.get(new Random().nextInt(briefsBean.msgList.size())).content; |
|
80 |
+ currentMsg = briefsBean.msgList.get(new Random().nextInt(briefsBean.msgList.size())); |
|
81 |
+ currentMsg.content = formatOrderContent(currentMsg); |
|
82 |
+ return currentMsg.content; |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ private String formatOrderContent(MessageBean messageBean){ |
|
86 |
+ return App.getAppContext().getString(R.string.customer_bought_photo_money, |
|
87 |
+ new java.text.DecimalFormat("#.00").format(messageBean.totalFee*1.0f/100)); |
|
68 | 88 |
} |
69 | 89 |
|
70 | 90 |
private String getNextSystemMessage(){ |
91 |
+ currentSystemMsg = null; |
|
71 | 92 |
if(briefsBean == null || briefsBean.systemMsgList==null || briefsBean.systemMsgList.size()==0){ |
72 | 93 |
return NULL_STR; |
73 | 94 |
} |
74 |
- return briefsBean.systemMsgList.get(new Random().nextInt(briefsBean.systemMsgList.size())).content; |
|
95 |
+ currentSystemMsg = briefsBean.systemMsgList.get(new Random().nextInt(briefsBean.systemMsgList.size())); |
|
96 |
+ return currentSystemMsg.content; |
|
75 | 97 |
} |
76 | 98 |
|
99 |
+ @Override |
|
100 |
+ public void onBoxStatusFetched(String boxNo, String boxStatus, String boxStatusCode) { |
|
101 |
+ briefsView.updateBoxInfo(boxNo,boxStatus+"("+boxStatusCode+")"); |
|
102 |
+ } |
|
77 | 103 |
} |
@@ -1,18 +1,80 @@ |
||
1 | 1 |
package ai.pai.lensman.main; |
2 | 2 |
|
3 | 3 |
|
4 |
+import android.os.AsyncTask; |
|
5 |
+ |
|
6 |
+import com.android.common.executors.ThreadExecutor; |
|
7 |
+ |
|
8 |
+import org.json.JSONObject; |
|
9 |
+ |
|
4 | 10 |
import ai.pai.lensman.base.BaseInteractor; |
11 |
+import ai.pai.lensman.utils.BoxUrlContainer; |
|
12 |
+import ai.pai.lensman.utils.HttpPostTask; |
|
5 | 13 |
|
6 | 14 |
public class QueryBoxStatusInteractor implements BaseInteractor{ |
15 |
+ |
|
16 |
+ private HttpPostTask queryBoxTask; |
|
17 |
+ private BoxStatusListener listener; |
|
18 |
+ |
|
19 |
+ public QueryBoxStatusInteractor(BoxStatusListener listener){ |
|
20 |
+ this.listener = listener; |
|
21 |
+ } |
|
7 | 22 |
|
8 | 23 |
@Override |
9 | 24 |
public void startJob() { |
25 |
+ cancelJob(); |
|
26 |
+ queryBoxTask = new HttpPostTask(null){ |
|
10 | 27 |
|
28 |
+ String boxStatusNum; |
|
29 |
+ String boxStatusMsg; |
|
30 |
+ String boxNo; |
|
31 |
+ @Override |
|
32 |
+ protected boolean parseResponse(String response) { |
|
33 |
+ try{ |
|
34 |
+ JSONObject json = new JSONObject(response); |
|
35 |
+ int status = json.getInt("status"); |
|
36 |
+ if(status == 200){ |
|
37 |
+ boxNo = json.getString("no."); |
|
38 |
+ JSONObject boxStatus = json.getJSONObject("status"); |
|
39 |
+ boxStatusMsg = boxStatus.getString("msg"); |
|
40 |
+ boxStatusNum = boxStatus.getString("code"); |
|
41 |
+ return true; |
|
42 |
+ } |
|
43 |
+ }catch (Exception e){ |
|
44 |
+ e.printStackTrace(); |
|
45 |
+ } |
|
46 |
+ return false; |
|
47 |
+ } |
|
48 |
+ |
|
49 |
+ @Override |
|
50 |
+ protected void onPostFail() { |
|
51 |
+ super.onPostFail(); |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ @Override |
|
55 |
+ protected void onPostSuccess() { |
|
56 |
+ super.onPostSuccess(); |
|
57 |
+ if(listener!=null){ |
|
58 |
+ listener.onBoxStatusFetched(boxNo,boxStatusMsg,boxStatusNum); |
|
59 |
+ } |
|
60 |
+ } |
|
61 |
+ }; |
|
62 |
+ queryBoxTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.BOX_INFO_URL); |
|
11 | 63 |
} |
12 | 64 |
|
13 | 65 |
@Override |
14 | 66 |
public void cancelJob() { |
15 |
- |
|
67 |
+ if(queryBoxTask==null){ |
|
68 |
+ return; |
|
69 |
+ } |
|
70 |
+ if(queryBoxTask.getStatus()== AsyncTask.Status.RUNNING){ |
|
71 |
+ queryBoxTask.cancel(true); |
|
72 |
+ } |
|
73 |
+ queryBoxTask = null; |
|
16 | 74 |
} |
17 | 75 |
|
76 |
+ public interface BoxStatusListener{ |
|
77 |
+ |
|
78 |
+ void onBoxStatusFetched(String boxNo, String boxStatus, String boxStatusCode); |
|
79 |
+ } |
|
18 | 80 |
} |
@@ -23,6 +23,7 @@ public class BoxUrlContainer { |
||
23 | 23 |
*/ |
24 | 24 |
public static String FETCH_ORIGIN_URL = BASE_URL +"fetch_origin"; |
25 | 25 |
|
26 |
+ public static String BOX_INFO_URL = BASE_URL+"box_info"; |
|
26 | 27 |
|
27 | 28 |
|
28 | 29 |
public static void resetIPHost(String ip) { |
@@ -41,6 +42,8 @@ public class BoxUrlContainer { |
||
41 | 42 |
PHOTO_PATH_PREFIX_URL = BASE_URL + "static/"; |
42 | 43 |
|
43 | 44 |
FETCH_ORIGIN_URL = BASE_URL +"fetch_origin"; |
45 |
+ |
|
46 |
+ BOX_INFO_URL = BASE_URL+"box_info"; |
|
44 | 47 |
} |
45 | 48 |
|
46 | 49 |
|
@@ -51,8 +51,19 @@ public class UrlContainer { |
||
51 | 51 |
*/ |
52 | 52 |
public static final String ORIGIN_PHOTO_UPLOAD_URL = HOST_URL+"l/origin_upload"; |
53 | 53 |
|
54 |
- |
|
54 |
+ /** |
|
55 |
+ * user_id # 用户唯一标识 |
|
56 |
+ feedback # 反馈内容,数据库 text 类型存储 |
|
57 |
+ src # 用户反馈来源,0 拍爱用户端,1 拍爱摄影师端,不传默认 0 |
|
58 |
+ */ |
|
55 | 59 |
public static final String FEEDBACK_URL = HOST_URL +"op/feedback"; |
56 | 60 |
|
61 |
+ /** |
|
62 |
+ * user_id # 用户唯一标识 |
|
63 |
+ nomark # 无水印价格(单位:分) |
|
64 |
+ origin # 高清图价格(单位:分) |
|
65 |
+ */ |
|
66 |
+ public static final String PRICE_FIX_URL = HOST_URL+"l/price_fix"; |
|
67 |
+ |
|
57 | 68 |
|
58 | 69 |
} |
@@ -142,4 +142,6 @@ |
||
142 | 142 |
|
143 | 143 |
<string name="check_update_processing">正在检查更新</string> |
144 | 144 |
|
145 |
+ <string name="customer_bought_photo_money">用户 ¥%s 购买了高清图</string> |
|
146 |
+ |
|
145 | 147 |
</resources> |
@@ -5,7 +5,7 @@ buildscript { |
||
5 | 5 |
jcenter() |
6 | 6 |
} |
7 | 7 |
dependencies { |
8 |
- classpath 'com.android.tools.build:gradle:2.1.3' |
|
8 |
+ classpath 'com.android.tools.build:gradle:2.2.0-rc2' |
|
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 |