@@ -1,9 +1,17 @@ |
||
| 1 | 1 |
package ai.pai.lensman.bean; |
| 2 | 2 |
|
| 3 |
+import java.util.ArrayList; |
|
| 4 |
+ |
|
| 3 | 5 |
/** |
| 4 | 6 |
* Created by chengzhenyu on 2016/8/24. |
| 5 | 7 |
*/ |
| 6 | 8 |
|
| 7 | 9 |
public class BriefsBean {
|
| 8 | 10 |
|
| 11 |
+ public float avgIncome; |
|
| 12 |
+ public int todayUpload; |
|
| 13 |
+ public float todayIncome; |
|
| 14 |
+ public ArrayList<MessageBean> msgList; |
|
| 15 |
+ public ArrayList<SystemMessageBean> systemMsgList; |
|
| 16 |
+ |
|
| 9 | 17 |
} |
@@ -0,0 +1,83 @@ |
||
| 1 |
+package ai.pai.lensman.bean; |
|
| 2 |
+ |
|
| 3 |
+import com.android.common.utils.JSONParseUtils; |
|
| 4 |
+ |
|
| 5 |
+import org.json.JSONException; |
|
| 6 |
+import org.json.JSONObject; |
|
| 7 |
+ |
|
| 8 |
+import java.io.Serializable; |
|
| 9 |
+ |
|
| 10 |
+public class GroupPhotoItem implements Serializable{
|
|
| 11 |
+ |
|
| 12 |
+ public String photoName; |
|
| 13 |
+ public String photoId; |
|
| 14 |
+ public String captureTime; |
|
| 15 |
+ public String thumbnailUrl; |
|
| 16 |
+ public String bigThumbnailUrl; |
|
| 17 |
+ public String photoUrl; |
|
| 18 |
+ public String groupId; |
|
| 19 |
+ public short thumbnailWidth; |
|
| 20 |
+ public short thumbnailHeight; |
|
| 21 |
+ public String groupAvatar; |
|
| 22 |
+ public String uploaderId; |
|
| 23 |
+ public String groupName; |
|
| 24 |
+ public int groupDefaultAvatar; |
|
| 25 |
+ public String uploaderName; |
|
| 26 |
+ public String uploaderAvatar; |
|
| 27 |
+ public int commentNum; |
|
| 28 |
+ public int thumbupNum; |
|
| 29 |
+ public int groupFrom; |
|
| 30 |
+ public int photoFrom; |
|
| 31 |
+ public boolean thumbUp; |
|
| 32 |
+ |
|
| 33 |
+ public String mediumPhotoUrl; |
|
| 34 |
+ public String rawPhotoUrl; |
|
| 35 |
+ |
|
| 36 |
+ public String shareUrl; |
|
| 37 |
+ |
|
| 38 |
+ @Override |
|
| 39 |
+ public boolean equals(Object o) {
|
|
| 40 |
+ if(o == this){
|
|
| 41 |
+ return true; |
|
| 42 |
+ } |
|
| 43 |
+ if(!(o instanceof GroupPhotoItem)){
|
|
| 44 |
+ return false; |
|
| 45 |
+ } |
|
| 46 |
+ GroupPhotoItem item = (GroupPhotoItem)o; |
|
| 47 |
+ return item.photoId.equals(photoId); |
|
| 48 |
+ } |
|
| 49 |
+ |
|
| 50 |
+ public static GroupPhotoItem parseFromJSON(JSONObject photoObj) throws JSONException{
|
|
| 51 |
+ GroupPhotoItem item = new GroupPhotoItem(); |
|
| 52 |
+ item.groupId= JSONParseUtils.getJSONString(photoObj.getString("group_id"));
|
|
| 53 |
+ item.groupName = JSONParseUtils.getJSONString(photoObj.getString("group_name"));
|
|
| 54 |
+ item.thumbnailWidth = (short)photoObj.getInt("photo_thumbnail_w");
|
|
| 55 |
+ item.thumbnailHeight = (short)photoObj.getInt("photo_thumbnail_h");
|
|
| 56 |
+ item.uploaderAvatar = JSONParseUtils.getJSONString(photoObj.getString("avatar"));
|
|
| 57 |
+ item.commentNum = photoObj.getInt("comment_num");
|
|
| 58 |
+ item.thumbupNum = photoObj.getInt("thumbup_num");
|
|
| 59 |
+ item.groupAvatar = JSONParseUtils.getJSONString(photoObj.getString("group_avatar"));
|
|
| 60 |
+ item.uploaderId = JSONParseUtils.getJSONString(photoObj.getString("user_id"));
|
|
| 61 |
+ item.uploaderName = JSONParseUtils.getJSONString(photoObj.getString("nickname"));
|
|
| 62 |
+ item.groupDefaultAvatar = photoObj.getInt("group_default_avatar");
|
|
| 63 |
+ item.photoId= JSONParseUtils.getJSONString(photoObj.getString("photo_id"));
|
|
| 64 |
+ item.photoUrl= JSONParseUtils.getJSONString(photoObj.getString("photo_url"));
|
|
| 65 |
+ item.thumbnailUrl= JSONParseUtils.getJSONString(photoObj.getString("photo_thumbnail_url"));
|
|
| 66 |
+ item.bigThumbnailUrl= JSONParseUtils.getJSONString(photoObj.getString("photo_thumbnail2_url"));
|
|
| 67 |
+ item.captureTime = JSONParseUtils.getJSONString(photoObj.getString("created_at"));
|
|
| 68 |
+ item.groupFrom = photoObj.getInt("group_from");
|
|
| 69 |
+ item.photoFrom = photoObj.getInt("photo_from");
|
|
| 70 |
+ item.thumbUp = photoObj.getBoolean("thumbup");
|
|
| 71 |
+ if(photoObj.has("photo_share_url")){
|
|
| 72 |
+ item.shareUrl = photoObj.getString("photo_share_url");
|
|
| 73 |
+ } |
|
| 74 |
+ JSONObject pOrderObj = photoObj.getJSONObject("porder");
|
|
| 75 |
+ if(pOrderObj.has("r_photo_url")){
|
|
| 76 |
+ item.rawPhotoUrl = JSONParseUtils.getJSONString(pOrderObj.getString("r_photo_url"));
|
|
| 77 |
+ } |
|
| 78 |
+ if(pOrderObj.has("m_photo_url")){
|
|
| 79 |
+ item.mediumPhotoUrl = JSONParseUtils.getJSONString(pOrderObj.getString("m_photo_url"));
|
|
| 80 |
+ } |
|
| 81 |
+ return item; |
|
| 82 |
+ } |
|
| 83 |
+} |
@@ -0,0 +1,16 @@ |
||
| 1 |
+package ai.pai.lensman.bean; |
|
| 2 |
+ |
|
| 3 |
+/** |
|
| 4 |
+ * Created by chengzhenyu on 16/1/10. |
|
| 5 |
+ */ |
|
| 6 |
+public class MessageBean {
|
|
| 7 |
+ |
|
| 8 |
+ public String createTime; |
|
| 9 |
+ public String senderAvatarUrl; |
|
| 10 |
+ public String senderName; |
|
| 11 |
+ public boolean isRead; |
|
| 12 |
+ public String msgId; |
|
| 13 |
+ public String content; |
|
| 14 |
+ |
|
| 15 |
+ public GroupPhotoItem photoItem; |
|
| 16 |
+} |
@@ -0,0 +1,14 @@ |
||
| 1 |
+package ai.pai.lensman.bean; |
|
| 2 |
+ |
|
| 3 |
+/** |
|
| 4 |
+ * Created by chengzhenyu on 2016/3/28. |
|
| 5 |
+ */ |
|
| 6 |
+public class SystemMessageBean {
|
|
| 7 |
+ |
|
| 8 |
+ public String content; |
|
| 9 |
+ public boolean isRead; |
|
| 10 |
+ public String msgId; |
|
| 11 |
+ public String url; |
|
| 12 |
+ public String title; |
|
| 13 |
+ |
|
| 14 |
+} |
@@ -53,7 +53,12 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{
|
||
| 53 | 53 |
|
| 54 | 54 |
@Override |
| 55 | 55 |
public void updateUserInfo(BriefsBean bean) {
|
| 56 |
- |
|
| 56 |
+ uploadPhotoNumText.setText(String.valueOf(bean.todayUpload)); |
|
| 57 |
+ captureNumText.setText(String.valueOf(bean.todayUpload)); |
|
| 58 |
+ averageMoneyText.setText(String.valueOf(bean.avgIncome)); |
|
| 59 |
+ todayIncomingText.setText(String.valueOf(bean.todayIncome)); |
|
| 60 |
+ totalIncomingText.setText(String.valueOf(bean.todayIncome)); |
|
| 61 |
+ todayCaptureHoursText.setText(String.valueOf(bean.todayUpload)); |
|
| 57 | 62 |
} |
| 58 | 63 |
|
| 59 | 64 |
} |
@@ -3,13 +3,19 @@ package ai.pai.lensman.briefs; |
||
| 3 | 3 |
import android.os.AsyncTask; |
| 4 | 4 |
|
| 5 | 5 |
import com.android.common.executors.ThreadExecutor; |
| 6 |
+import com.android.common.utils.JSONParseUtils; |
|
| 6 | 7 |
|
| 8 |
+import org.json.JSONArray; |
|
| 7 | 9 |
import org.json.JSONObject; |
| 8 | 10 |
|
| 11 |
+import java.util.ArrayList; |
|
| 9 | 12 |
import java.util.HashMap; |
| 10 | 13 |
|
| 11 | 14 |
import ai.pai.lensman.base.BaseInteractor; |
| 12 | 15 |
import ai.pai.lensman.bean.BriefsBean; |
| 16 |
+import ai.pai.lensman.bean.GroupPhotoItem; |
|
| 17 |
+import ai.pai.lensman.bean.MessageBean; |
|
| 18 |
+import ai.pai.lensman.bean.SystemMessageBean; |
|
| 13 | 19 |
import ai.pai.lensman.db.Preferences; |
| 14 | 20 |
import ai.pai.lensman.utils.HttpPostTask; |
| 15 | 21 |
import ai.pai.lensman.utils.UrlContainer; |
@@ -42,7 +48,46 @@ public class BriefsInteractor implements BaseInteractor {
|
||
| 42 | 48 |
JSONObject json = new JSONObject(response); |
| 43 | 49 |
int status = json.getInt("status");
|
| 44 | 50 |
if(status == 200){
|
| 51 |
+ JSONObject data = json.getJSONObject("data");
|
|
| 45 | 52 |
bean = new BriefsBean(); |
| 53 |
+ bean.avgIncome =(float)data.getDouble("avg_income");
|
|
| 54 |
+ bean.todayIncome = (float)data.getDouble("today_income");
|
|
| 55 |
+ bean.todayUpload = data.getInt("today_upload");
|
|
| 56 |
+ JSONObject msgObj = data.getJSONObject("messages");
|
|
| 57 |
+ JSONArray systemMsgArray = msgObj.getJSONArray("system");
|
|
| 58 |
+ |
|
| 59 |
+ if(systemMsgArray!=null && systemMsgArray.length()>0){
|
|
| 60 |
+ ArrayList<SystemMessageBean> systemMsgList = new ArrayList<>(); |
|
| 61 |
+ for(int k = 0 ;k<systemMsgArray.length();k++){
|
|
| 62 |
+ JSONObject systemMsgObj = systemMsgArray.getJSONObject(k); |
|
| 63 |
+ SystemMessageBean bean = new SystemMessageBean(); |
|
| 64 |
+ bean.content = JSONParseUtils.getJSONString(systemMsgObj.getString("content"));
|
|
| 65 |
+ bean.isRead = systemMsgObj.getBoolean("read");
|
|
| 66 |
+ bean.url = JSONParseUtils.getJSONString(systemMsgObj.getString("url"));
|
|
| 67 |
+ bean.msgId =JSONParseUtils.getJSONString(systemMsgObj.getString("pk"));
|
|
| 68 |
+ bean.title = JSONParseUtils.getJSONString(systemMsgObj.getString("title"));
|
|
| 69 |
+ systemMsgList.add(bean); |
|
| 70 |
+ } |
|
| 71 |
+ bean.systemMsgList = systemMsgList; |
|
| 72 |
+ } |
|
| 73 |
+ JSONArray msgArray = msgObj.getJSONArray("orders");
|
|
| 74 |
+ if(msgArray!=null && msgArray.length()>0){
|
|
| 75 |
+ ArrayList<MessageBean> msgList = new ArrayList<>(); |
|
| 76 |
+ for(int count = 0; count<msgArray.length();count++){
|
|
| 77 |
+ JSONObject childMsg = msgArray.getJSONObject(count); |
|
| 78 |
+ MessageBean childBean = new MessageBean(); |
|
| 79 |
+ childBean.createTime = JSONParseUtils.getJSONString(childMsg.getString("created_at"));
|
|
| 80 |
+ childBean.isRead = childMsg.getBoolean("read");
|
|
| 81 |
+ childBean.msgId = childMsg.getString("pk");
|
|
| 82 |
+ childBean.senderName = JSONParseUtils.getJSONString(childMsg.getString("from_nickname"));
|
|
| 83 |
+ childBean.senderAvatarUrl = JSONParseUtils.getJSONString(childMsg.getString("from_avatar"));
|
|
| 84 |
+ childBean.content = JSONParseUtils.getJSONString(childMsg.getString("msg_content"));
|
|
| 85 |
+ JSONObject photoObj = childMsg.getJSONObject("group_photo_info");
|
|
| 86 |
+ childBean.photoItem = GroupPhotoItem.parseFromJSON(photoObj); |
|
| 87 |
+ msgList.add(childBean); |
|
| 88 |
+ } |
|
| 89 |
+ bean.msgList = msgList; |
|
| 90 |
+ } |
|
| 46 | 91 |
return true; |
| 47 | 92 |
}else{
|
| 48 | 93 |
message = json.getString("message");
|
@@ -65,7 +110,7 @@ public class BriefsInteractor implements BaseInteractor {
|
||
| 65 | 110 |
listener.onInteractSuccess(bean); |
| 66 | 111 |
} |
| 67 | 112 |
}; |
| 68 |
- fetchInfoTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.SESSION_IDS_CREATE); |
|
| 113 |
+ fetchInfoTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.BRIEFS_URL); |
|
| 69 | 114 |
} |
| 70 | 115 |
|
| 71 | 116 |
@Override |
@@ -35,6 +35,8 @@ public class UrlContainer {
|
||
| 35 | 35 |
*/ |
| 36 | 36 |
public static final String WX_LOGIN_URL = HOST_URL+"l/wx/authorize"; |
| 37 | 37 |
|
| 38 |
+ public static final String BRIEFS_URL = HOST_URL+"l/brief"; |
|
| 39 |
+ |
|
| 38 | 40 |
|
| 39 | 41 |
|
| 40 | 42 |
} |
@@ -34,7 +34,6 @@ |
||
| 34 | 34 |
android:gravity="center" |
| 35 | 35 |
android:paddingLeft="10dp" |
| 36 | 36 |
android:paddingRight="10dp" |
| 37 |
- android:singleLine="true" |
|
| 38 | 37 |
android:text="@string/settings" |
| 39 | 38 |
android:textColor="@color/text_white" |
| 40 | 39 |
android:textSize="@dimen/action_bar_title_medium_text_size" /> |
@@ -59,5 +58,19 @@ |
||
| 59 | 58 |
|
| 60 | 59 |
</LinearLayout> |
| 61 | 60 |
|
| 61 |
+ <ScrollView |
|
| 62 |
+ android:layout_below="@id/title_bar_with_back_btn" |
|
| 63 |
+ android:layout_width="match_parent" |
|
| 64 |
+ android:layout_height="match_parent"> |
|
| 65 |
+ |
|
| 66 |
+ <LinearLayout |
|
| 67 |
+ android:layout_width="match_parent" |
|
| 68 |
+ android:layout_height="wrap_content" |
|
| 69 |
+ android:orientation="vertical"> |
|
| 70 |
+ |
|
| 71 |
+ |
|
| 72 |
+ </LinearLayout> |
|
| 73 |
+ </ScrollView> |
|
| 74 |
+ |
|
| 62 | 75 |
|
| 63 | 76 |
</RelativeLayout> |