Commit fcc1cec6606037d8b7f947a8db3b618614c6b59a
1 parent
425522c4
修改 评论页面代码..
Showing
35 changed files
with
3038 additions
and
29 deletions
app/src/main/java/com/cnlive/gundam/application/CNLiveApplication.java
| 1 | 1 | package com.cnlive.gundam.application; |
| 2 | 2 | |
| 3 | 3 | import android.app.Application; |
| 4 | +import android.content.Context; | |
| 4 | 5 | |
| 5 | 6 | import com.cnlive.libs.util.Config; |
| 6 | 7 | |
| ... | ... | @@ -11,10 +12,15 @@ import com.cnlive.libs.util.Config; |
| 11 | 12 | public class CNLiveApplication extends Application { |
| 12 | 13 | |
| 13 | 14 | public static final String secret = "c2faeb120f0ea2e2d47020d4b03cb8a93bed2585897a94"; |
| 15 | + private static Context mContxt; | |
| 14 | 16 | |
| 15 | 17 | @Override |
| 16 | 18 | public void onCreate() { |
| 17 | 19 | super.onCreate(); |
| 20 | + mContxt=getApplicationContext(); | |
| 18 | 21 | Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9", true);//测试信息 |
| 19 | 22 | } |
| 23 | + public static Context getContext(){ | |
| 24 | + return mContxt; | |
| 25 | + } | |
| 20 | 26 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/main/model/CommentBean.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | |
| 2 | + | |
| 3 | +import android.os.Parcel; | |
| 4 | +import android.os.Parcelable; | |
| 5 | + | |
| 6 | +import java.io.Serializable; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Description: | |
| 11 | + * Created on 2017/3/5 | |
| 12 | + * Author : 萧 | |
| 13 | + */ | |
| 14 | +public class CommentBean implements Serializable, Parcelable { | |
| 15 | + | |
| 16 | + private String userHead; | |
| 17 | + | |
| 18 | + private String userName; | |
| 19 | + | |
| 20 | + private String time; | |
| 21 | + | |
| 22 | + private String commentContent; | |
| 23 | + | |
| 24 | + private String praise; | |
| 25 | + | |
| 26 | + private int replyNum; | |
| 27 | + | |
| 28 | + private String id; | |
| 29 | + | |
| 30 | + private int isPraised=2; | |
| 31 | + | |
| 32 | + private List<ReplyBean> replyList; | |
| 33 | + | |
| 34 | + public CommentBean() { | |
| 35 | + } | |
| 36 | + | |
| 37 | + public CommentBean(String userHead, String userName, String time, String commentContent, String praise, String id) { | |
| 38 | + this.userHead = userHead; | |
| 39 | + this.userName = userName; | |
| 40 | + this.time = time; | |
| 41 | + this.commentContent = commentContent; | |
| 42 | + this.praise = praise; | |
| 43 | + this.id = id; | |
| 44 | + } | |
| 45 | + | |
| 46 | + public String getUserHead() { | |
| 47 | + return userHead; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setUserHead(String userHead) { | |
| 51 | + this.userHead = userHead; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public String getUserName() { | |
| 55 | + return userName; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void setUserName(String userName) { | |
| 59 | + this.userName = userName; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public String getTime() { | |
| 63 | + return time; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setTime(String time) { | |
| 67 | + this.time = time; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public String getCommentContent() { | |
| 71 | + return commentContent; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void setCommentContent(String commentContent) { | |
| 75 | + this.commentContent = commentContent; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public String getPraise() { | |
| 79 | + return praise; | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void setPraise(String praise) { | |
| 83 | + this.praise = praise; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public int isPraised() { | |
| 87 | + return isPraised; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void setPraised(int praised) { | |
| 91 | + isPraised = praised; | |
| 92 | + } | |
| 93 | + | |
| 94 | + public int getReplyNum() { | |
| 95 | + return replyNum; | |
| 96 | + } | |
| 97 | + | |
| 98 | + public void setReplyNum(int replyNum) { | |
| 99 | + this.replyNum = replyNum; | |
| 100 | + } | |
| 101 | + | |
| 102 | + public String getId() { | |
| 103 | + return id; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public void setId(String id) { | |
| 107 | + this.id = id; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public List<ReplyBean> getReplyList() { | |
| 111 | + return replyList; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public void setReplyList(List<ReplyBean> replyList) { | |
| 115 | + this.replyList = replyList; | |
| 116 | + } | |
| 117 | + | |
| 118 | + @Override | |
| 119 | + public String toString() { | |
| 120 | + return "CommentBean{" + | |
| 121 | + "userHead='" + userHead + '\'' + | |
| 122 | + ", userName='" + userName + '\'' + | |
| 123 | + ", time='" + time + '\'' + | |
| 124 | + ", commentContent='" + commentContent + '\'' + | |
| 125 | + ", praise=" + praise + | |
| 126 | + ", replyNum=" + replyNum + | |
| 127 | + ", id=" + id + | |
| 128 | + ", replyList=" + replyList + | |
| 129 | + '}'; | |
| 130 | + } | |
| 131 | + | |
| 132 | + @Override | |
| 133 | + public int describeContents() { | |
| 134 | + return 0; | |
| 135 | + } | |
| 136 | + | |
| 137 | + @Override | |
| 138 | + public void writeToParcel(Parcel dest, int flags) { | |
| 139 | + dest.writeString(this.userHead); | |
| 140 | + dest.writeString(this.userName); | |
| 141 | + dest.writeString(this.time); | |
| 142 | + dest.writeString(this.commentContent); | |
| 143 | + dest.writeString(this.praise); | |
| 144 | + dest.writeInt(this.replyNum); | |
| 145 | + dest.writeString(this.id); | |
| 146 | + dest.writeTypedList(this.replyList); | |
| 147 | + dest.writeInt(this.isPraised); | |
| 148 | + } | |
| 149 | + | |
| 150 | + protected CommentBean(Parcel in) { | |
| 151 | + this.userHead = in.readString(); | |
| 152 | + this.userName = in.readString(); | |
| 153 | + this.time = in.readString(); | |
| 154 | + this.commentContent = in.readString(); | |
| 155 | + this.praise = in.readString(); | |
| 156 | + this.replyNum = in.readInt(); | |
| 157 | + this.id = in.readString(); | |
| 158 | + this.replyList = in.createTypedArrayList(ReplyBean.CREATOR); | |
| 159 | + this.isPraised = in.readInt(); | |
| 160 | + } | |
| 161 | + | |
| 162 | + public static final Creator<CommentBean> CREATOR = new Creator<CommentBean>() { | |
| 163 | + @Override | |
| 164 | + public CommentBean createFromParcel(Parcel source) { | |
| 165 | + return new CommentBean(source); | |
| 166 | + } | |
| 167 | + | |
| 168 | + @Override | |
| 169 | + public CommentBean[] newArray(int size) { | |
| 170 | + return new CommentBean[size]; | |
| 171 | + } | |
| 172 | + }; | |
| 173 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/model/CommentTitleViewModel.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | |
| 2 | + | |
| 3 | +import android.databinding.BaseObservable; | |
| 4 | +import android.databinding.Bindable; | |
| 5 | + | |
| 6 | +import com.cnlive.gundam.BR; | |
| 7 | +import com.cnlive.gundam.R; | |
| 8 | +import com.cnlive.gundam.main.ui.adapter.mul.IBaseMulInterface; | |
| 9 | + | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Created by ZJL on 2017/5/24. | |
| 13 | + */ | |
| 14 | + | |
| 15 | +public class CommentTitleViewModel extends BaseObservable implements IBaseMulInterface { | |
| 16 | + private String count; | |
| 17 | + public CommentTitleViewModel(String count){ | |
| 18 | + this.count =count; | |
| 19 | + | |
| 20 | + | |
| 21 | + } | |
| 22 | + | |
| 23 | + @Bindable | |
| 24 | + public String getCount(){ | |
| 25 | + return count; | |
| 26 | + } | |
| 27 | + public void setCount(String count){ | |
| 28 | + this.count=count; | |
| 29 | + notifyPropertyChanged(BR.count); | |
| 30 | + } | |
| 31 | + @Override | |
| 32 | + public int getItemLayoutId() { | |
| 33 | + return R.layout.item_comment_title; | |
| 34 | + } | |
| 35 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/model/CommentViewModel.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | |
| 2 | + | |
| 3 | +import android.databinding.BaseObservable; | |
| 4 | +import android.databinding.Bindable; | |
| 5 | +import android.databinding.ObservableBoolean; | |
| 6 | + | |
| 7 | +import com.cnlive.gundam.BR; | |
| 8 | +import com.cnlive.gundam.R; | |
| 9 | +import com.cnlive.gundam.main.ui.adapter.mul.IBaseMulInterface; | |
| 10 | + | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Created by ZJL on 2017/5/24. | |
| 14 | + */ | |
| 15 | + | |
| 16 | +public class CommentViewModel extends BaseObservable implements IBaseMulInterface { | |
| 17 | + private CommentBean commentBean; | |
| 18 | + private String praise; | |
| 19 | + private int praiseImage = R.drawable.vod_detail_good; | |
| 20 | + public final ObservableBoolean isClickAble = new ObservableBoolean(true); | |
| 21 | + | |
| 22 | + @Bindable | |
| 23 | + public int getPraiseImage() { | |
| 24 | + return praiseImage; | |
| 25 | + } | |
| 26 | + | |
| 27 | + public void setPraiseImage(int praiseImage) { | |
| 28 | + this.praiseImage = praiseImage; | |
| 29 | + notifyPropertyChanged(BR.praiseImage); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public CommentViewModel(CommentBean commentBean) { | |
| 33 | + this.commentBean = commentBean; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public CommentBean getCommentBean() { | |
| 37 | + return commentBean; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public String getUserHead() { | |
| 41 | + return commentBean.getUserHead(); | |
| 42 | + } | |
| 43 | + | |
| 44 | + public String getUserName() { | |
| 45 | + return commentBean.getUserName(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + public String getId() { | |
| 49 | + return commentBean.getId(); | |
| 50 | + } | |
| 51 | + public String getTime() { | |
| 52 | + return commentBean.getTime(); | |
| 53 | + } | |
| 54 | + | |
| 55 | + public String getCommentContent() { | |
| 56 | + return commentBean.getCommentContent(); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @Bindable | |
| 60 | + public String getPraise() { | |
| 61 | + return commentBean.getPraise(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setPraise(String praiseCount) { | |
| 65 | + commentBean.setPraise(praiseCount); | |
| 66 | + notifyPropertyChanged(BR.praise); | |
| 67 | + } | |
| 68 | + | |
| 69 | + @Override | |
| 70 | + public int getItemLayoutId() { | |
| 71 | + return R.layout.item_comment; | |
| 72 | + } | |
| 73 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/model/ReplyBean.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | |
| 2 | + | |
| 3 | +import android.os.Parcel; | |
| 4 | +import android.os.Parcelable; | |
| 5 | + | |
| 6 | +import java.io.Serializable; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Description: | |
| 10 | + * Created on 2017/3/5 | |
| 11 | + * Author : 萧 | |
| 12 | + */ | |
| 13 | +public class ReplyBean implements Serializable, Parcelable { | |
| 14 | + | |
| 15 | + private Integer recordId; | |
| 16 | + | |
| 17 | + private String userName; | |
| 18 | + | |
| 19 | + private String userHead; | |
| 20 | + | |
| 21 | + private String replyContent; | |
| 22 | + | |
| 23 | + private String replyTime; | |
| 24 | + | |
| 25 | + private Integer commentId; | |
| 26 | + | |
| 27 | + public ReplyBean() { | |
| 28 | + } | |
| 29 | + | |
| 30 | + public ReplyBean(Integer recordId, String userName, String userHead, String replyContent, String replyTime, Integer commentId) { | |
| 31 | + this.recordId = recordId; | |
| 32 | + this.userName = userName; | |
| 33 | + this.userHead = userHead; | |
| 34 | + this.replyContent = replyContent; | |
| 35 | + this.replyTime = replyTime; | |
| 36 | + this.commentId = commentId; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public Integer getRecordId() { | |
| 40 | + return recordId; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public void setRecordId(Integer recordId) { | |
| 44 | + this.recordId = recordId; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public String getUserName() { | |
| 48 | + return userName; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void setUserName(String userName) { | |
| 52 | + this.userName = userName; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public String getUserHead() { | |
| 56 | + return userHead; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void setUserHead(String userHead) { | |
| 60 | + this.userHead = userHead; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public String getReplyContent() { | |
| 64 | + return replyContent; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setReplyContent(String replyContent) { | |
| 68 | + this.replyContent = replyContent; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public String getReplyTime() { | |
| 72 | + return replyTime; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setReplyTime(String replyTime) { | |
| 76 | + this.replyTime = replyTime; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public Integer getCommentId() { | |
| 80 | + return commentId; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public void setCommentId(Integer commentId) { | |
| 84 | + this.commentId = commentId; | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public String toString() { | |
| 89 | + return "ReplyBean{" + | |
| 90 | + "recordId=" + recordId + | |
| 91 | + ", userName='" + userName + '\'' + | |
| 92 | + ", userHead='" + userHead + '\'' + | |
| 93 | + ", replyContent='" + replyContent + '\'' + | |
| 94 | + ", replyTime='" + replyTime + '\'' + | |
| 95 | + ", commentId=" + commentId + | |
| 96 | + '}'; | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Override | |
| 100 | + public int describeContents() { | |
| 101 | + return 0; | |
| 102 | + } | |
| 103 | + | |
| 104 | + @Override | |
| 105 | + public void writeToParcel(Parcel dest, int flags) { | |
| 106 | + dest.writeValue(this.recordId); | |
| 107 | + dest.writeString(this.userName); | |
| 108 | + dest.writeString(this.userHead); | |
| 109 | + dest.writeString(this.replyContent); | |
| 110 | + dest.writeString(this.replyTime); | |
| 111 | + dest.writeValue(this.commentId); | |
| 112 | + } | |
| 113 | + | |
| 114 | + protected ReplyBean(Parcel in) { | |
| 115 | + this.recordId = (Integer) in.readValue(Integer.class.getClassLoader()); | |
| 116 | + this.userName = in.readString(); | |
| 117 | + this.userHead = in.readString(); | |
| 118 | + this.replyContent = in.readString(); | |
| 119 | + this.replyTime = in.readString(); | |
| 120 | + this.commentId = (Integer) in.readValue(Integer.class.getClassLoader()); | |
| 121 | + } | |
| 122 | + | |
| 123 | + public static final Creator<ReplyBean> CREATOR = new Creator<ReplyBean>() { | |
| 124 | + @Override | |
| 125 | + public ReplyBean createFromParcel(Parcel source) { | |
| 126 | + return new ReplyBean(source); | |
| 127 | + } | |
| 128 | + | |
| 129 | + @Override | |
| 130 | + public ReplyBean[] newArray(int size) { | |
| 131 | + return new ReplyBean[size]; | |
| 132 | + } | |
| 133 | + }; | |
| 134 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/model/Series.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by ZJL on 2017/6/14. | |
| 5 | + */ | |
| 6 | + | |
| 7 | +public class Series { | |
| 8 | + private int number; | |
| 9 | + | |
| 10 | + private String title; | |
| 11 | + | |
| 12 | + private String description; | |
| 13 | + | |
| 14 | + private String flashUrl; | |
| 15 | + | |
| 16 | + private String rates; | |
| 17 | + | |
| 18 | + public void setNumber(int number){ | |
| 19 | + this.number = number; | |
| 20 | + } | |
| 21 | + public int getNumber(){ | |
| 22 | + return this.number; | |
| 23 | + } | |
| 24 | + public void setTitle(String title){ | |
| 25 | + this.title = title; | |
| 26 | + } | |
| 27 | + public String getTitle(){ | |
| 28 | + return this.title; | |
| 29 | + } | |
| 30 | + public void setDescription(String description){ | |
| 31 | + this.description = description; | |
| 32 | + } | |
| 33 | + public String getDescription(){ | |
| 34 | + return this.description; | |
| 35 | + } | |
| 36 | + public void setFlashUrl(String flashUrl){ | |
| 37 | + this.flashUrl = flashUrl; | |
| 38 | + } | |
| 39 | + public String getFlashUrl(){ | |
| 40 | + return this.flashUrl; | |
| 41 | + } | |
| 42 | + public void setRates(String rates){ | |
| 43 | + this.rates = rates; | |
| 44 | + } | |
| 45 | + public String getRates(){ | |
| 46 | + return this.rates; | |
| 47 | + } | |
| 48 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/model/VodDetailModel.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.model; | |
| 2 | + | |
| 3 | +import android.os.Parcel; | |
| 4 | +import android.os.Parcelable; | |
| 5 | + | |
| 6 | +import java.io.Serializable; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * Created by ZJL on 2017/6/13. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +public class VodDetailModel extends ErrorMessage implements Parcelable,Serializable { | |
| 14 | + /** | |
| 15 | + * errorMessage : 数据加载成功 | |
| 16 | + * pageUrl : http://v.cnlive.com/ffyl/v_g4zd1nzqgu.html | |
| 17 | + * CMSChannelName : | |
| 18 | + * vipFlag : 0 | |
| 19 | + * type : program | |
| 20 | + * packagePomID : 3_ent/mxfb/ | |
| 21 | + * cmsChannelID : ent/ | |
| 22 | + * MAM_ProducerID : 先锋派 | |
| 23 | + * activityId : | |
| 24 | + * title : 贝思客2017品牌发布会 | |
| 25 | + * MAM_NodeID : 014-018-001 | |
| 26 | + * docSubTitle : 贝思客2017品牌发布会 | |
| 27 | + * playAuto : xiangguanshipin | |
| 28 | + * docID : 807125 | |
| 29 | + * MAM_SmallPosterUrl : http://y1.cnliveimg.com:8080/image/itv/2017/0328/d98b809afa2d4234b3c15b2168be8061_100.jpg | |
| 30 | + * onePomID : 3_82_88d98b809afa2d4234b3c15b2168be8061 | |
| 31 | + * flashUrl : http://wideo00.cnlive.com/video/data3/2017/0328/feifan4_20170328134656.mp4 | |
| 32 | + * mediaId : 82_88d98b809afa2d4234b3c15b2168be8061 | |
| 33 | + * MAM_NodeName : 综合/非凡娱乐/星光回放 | |
| 34 | + * MAM_PosterUrl : http://y1.cnliveimg.com:8080/image/itv/2017/0328/d98b809afa2d4234b3c15b2168be8061_100.jpg | |
| 35 | + * status : 1 | |
| 36 | + * cmsColumnID : ent/mxfb/ | |
| 37 | + * rates : 1,2,3 | |
| 38 | + * freePlayLength : 60 | |
| 39 | + * errorCode : 0 | |
| 40 | + * docDescription : 贝思客2017品牌发布会,此次出席嘉宾是唐嫣,该品牌利用O2O线上线下交互销售。在贝思客PC官网、移动端微网站、手机APP、客服热线等各种方式均可订购蛋糕。 | |
| 41 | + * modules : [{"id":"xiangguanshipin","title":"相关推荐"}] | |
| 42 | + * colName : | |
| 43 | + */ | |
| 44 | + | |
| 45 | + private String pageUrl; | |
| 46 | + private String CMSChannelName; | |
| 47 | + private String vipFlag; | |
| 48 | + private String type; | |
| 49 | + private String packagePomID; | |
| 50 | + private String cmsChannelID; | |
| 51 | + private String MAM_ProducerID; | |
| 52 | + private String activityId; | |
| 53 | + private String title; | |
| 54 | + private String MAM_NodeID; | |
| 55 | + private String docSubTitle; | |
| 56 | + private String playAuto; | |
| 57 | + private String docID; | |
| 58 | + private String MAM_SmallPosterUrl; | |
| 59 | + private String onePomID; | |
| 60 | + private String flashUrl; | |
| 61 | + private String mediaId; | |
| 62 | + private String MAM_NodeName; | |
| 63 | + private String MAM_PosterUrl; | |
| 64 | + private String status; | |
| 65 | + private String cmsColumnID; | |
| 66 | + private String rates; | |
| 67 | + private String freePlayLength; | |
| 68 | + private String docDescription; | |
| 69 | + private String colName; | |
| 70 | + private List<ModulesBean> modules; | |
| 71 | + private List<Series> series ; | |
| 72 | + | |
| 73 | + protected VodDetailModel(Parcel in) { | |
| 74 | + pageUrl = in.readString(); | |
| 75 | + CMSChannelName = in.readString(); | |
| 76 | + vipFlag = in.readString(); | |
| 77 | + type = in.readString(); | |
| 78 | + packagePomID = in.readString(); | |
| 79 | + cmsChannelID = in.readString(); | |
| 80 | + MAM_ProducerID = in.readString(); | |
| 81 | + activityId = in.readString(); | |
| 82 | + title = in.readString(); | |
| 83 | + MAM_NodeID = in.readString(); | |
| 84 | + docSubTitle = in.readString(); | |
| 85 | + playAuto = in.readString(); | |
| 86 | + docID = in.readString(); | |
| 87 | + MAM_SmallPosterUrl = in.readString(); | |
| 88 | + onePomID = in.readString(); | |
| 89 | + flashUrl = in.readString(); | |
| 90 | + mediaId = in.readString(); | |
| 91 | + MAM_NodeName = in.readString(); | |
| 92 | + MAM_PosterUrl = in.readString(); | |
| 93 | + status = in.readString(); | |
| 94 | + cmsColumnID = in.readString(); | |
| 95 | + rates = in.readString(); | |
| 96 | + freePlayLength = in.readString(); | |
| 97 | + docDescription = in.readString(); | |
| 98 | + colName = in.readString(); | |
| 99 | + } | |
| 100 | + | |
| 101 | + public static final Creator<VodDetailModel> CREATOR = new Creator<VodDetailModel>() { | |
| 102 | + @Override | |
| 103 | + public VodDetailModel createFromParcel(Parcel in) { | |
| 104 | + return new VodDetailModel(in); | |
| 105 | + } | |
| 106 | + | |
| 107 | + @Override | |
| 108 | + public VodDetailModel[] newArray(int size) { | |
| 109 | + return new VodDetailModel[size]; | |
| 110 | + } | |
| 111 | + }; | |
| 112 | + | |
| 113 | + public void setSeries(List<Series> series){ | |
| 114 | + this.series = series; | |
| 115 | + } | |
| 116 | + public List<Series> getSeries(){ | |
| 117 | + return this.series; | |
| 118 | + } | |
| 119 | + public String getPageUrl() { | |
| 120 | + return pageUrl; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setPageUrl(String pageUrl) { | |
| 124 | + this.pageUrl = pageUrl; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public String getCMSChannelName() { | |
| 128 | + return CMSChannelName; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void setCMSChannelName(String CMSChannelName) { | |
| 132 | + this.CMSChannelName = CMSChannelName; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public String getVipFlag() { | |
| 136 | + return vipFlag; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public void setVipFlag(String vipFlag) { | |
| 140 | + this.vipFlag = vipFlag; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public String getType() { | |
| 144 | + return type; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void setType(String type) { | |
| 148 | + this.type = type; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public String getPackagePomID() { | |
| 152 | + return packagePomID; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public void setPackagePomID(String packagePomID) { | |
| 156 | + this.packagePomID = packagePomID; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public String getCmsChannelID() { | |
| 160 | + return cmsChannelID; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public void setCmsChannelID(String cmsChannelID) { | |
| 164 | + this.cmsChannelID = cmsChannelID; | |
| 165 | + } | |
| 166 | + | |
| 167 | + public String getMAM_ProducerID() { | |
| 168 | + return MAM_ProducerID; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public void setMAM_ProducerID(String MAM_ProducerID) { | |
| 172 | + this.MAM_ProducerID = MAM_ProducerID; | |
| 173 | + } | |
| 174 | + | |
| 175 | + public String getActivityId() { | |
| 176 | + return activityId; | |
| 177 | + } | |
| 178 | + | |
| 179 | + public void setActivityId(String activityId) { | |
| 180 | + this.activityId = activityId; | |
| 181 | + } | |
| 182 | + | |
| 183 | + public String getTitle() { | |
| 184 | + return title; | |
| 185 | + } | |
| 186 | + | |
| 187 | + public void setTitle(String title) { | |
| 188 | + this.title = title; | |
| 189 | + } | |
| 190 | + | |
| 191 | + public String getMAM_NodeID() { | |
| 192 | + return MAM_NodeID; | |
| 193 | + } | |
| 194 | + | |
| 195 | + public void setMAM_NodeID(String MAM_NodeID) { | |
| 196 | + this.MAM_NodeID = MAM_NodeID; | |
| 197 | + } | |
| 198 | + | |
| 199 | + public String getDocSubTitle() { | |
| 200 | + return docSubTitle; | |
| 201 | + } | |
| 202 | + | |
| 203 | + public void setDocSubTitle(String docSubTitle) { | |
| 204 | + this.docSubTitle = docSubTitle; | |
| 205 | + } | |
| 206 | + | |
| 207 | + public String getPlayAuto() { | |
| 208 | + return playAuto; | |
| 209 | + } | |
| 210 | + | |
| 211 | + public void setPlayAuto(String playAuto) { | |
| 212 | + this.playAuto = playAuto; | |
| 213 | + } | |
| 214 | + | |
| 215 | + public String getDocID() { | |
| 216 | + return docID; | |
| 217 | + } | |
| 218 | + | |
| 219 | + public void setDocID(String docID) { | |
| 220 | + this.docID = docID; | |
| 221 | + } | |
| 222 | + | |
| 223 | + public String getMAM_SmallPosterUrl() { | |
| 224 | + return MAM_SmallPosterUrl; | |
| 225 | + } | |
| 226 | + | |
| 227 | + public void setMAM_SmallPosterUrl(String MAM_SmallPosterUrl) { | |
| 228 | + this.MAM_SmallPosterUrl = MAM_SmallPosterUrl; | |
| 229 | + } | |
| 230 | + | |
| 231 | + public String getOnePomID() { | |
| 232 | + return onePomID; | |
| 233 | + } | |
| 234 | + | |
| 235 | + public void setOnePomID(String onePomID) { | |
| 236 | + this.onePomID = onePomID; | |
| 237 | + } | |
| 238 | + | |
| 239 | + public String getFlashUrl() { | |
| 240 | + return flashUrl; | |
| 241 | + } | |
| 242 | + | |
| 243 | + public void setFlashUrl(String flashUrl) { | |
| 244 | + this.flashUrl = flashUrl; | |
| 245 | + } | |
| 246 | + | |
| 247 | + public String getMediaId() { | |
| 248 | + return mediaId; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public void setMediaId(String mediaId) { | |
| 252 | + this.mediaId = mediaId; | |
| 253 | + } | |
| 254 | + | |
| 255 | + public String getMAM_NodeName() { | |
| 256 | + return MAM_NodeName; | |
| 257 | + } | |
| 258 | + | |
| 259 | + public void setMAM_NodeName(String MAM_NodeName) { | |
| 260 | + this.MAM_NodeName = MAM_NodeName; | |
| 261 | + } | |
| 262 | + | |
| 263 | + public String getMAM_PosterUrl() { | |
| 264 | + return MAM_PosterUrl; | |
| 265 | + } | |
| 266 | + | |
| 267 | + public void setMAM_PosterUrl(String MAM_PosterUrl) { | |
| 268 | + this.MAM_PosterUrl = MAM_PosterUrl; | |
| 269 | + } | |
| 270 | + | |
| 271 | + public String getStatus() { | |
| 272 | + return status; | |
| 273 | + } | |
| 274 | + | |
| 275 | + public void setStatus(String status) { | |
| 276 | + this.status = status; | |
| 277 | + } | |
| 278 | + | |
| 279 | + public String getCmsColumnID() { | |
| 280 | + return cmsColumnID; | |
| 281 | + } | |
| 282 | + | |
| 283 | + public void setCmsColumnID(String cmsColumnID) { | |
| 284 | + this.cmsColumnID = cmsColumnID; | |
| 285 | + } | |
| 286 | + | |
| 287 | + public String getRates() { | |
| 288 | + return rates; | |
| 289 | + } | |
| 290 | + | |
| 291 | + public void setRates(String rates) { | |
| 292 | + this.rates = rates; | |
| 293 | + } | |
| 294 | + | |
| 295 | + public String getFreePlayLength() { | |
| 296 | + return freePlayLength; | |
| 297 | + } | |
| 298 | + | |
| 299 | + public void setFreePlayLength(String freePlayLength) { | |
| 300 | + this.freePlayLength = freePlayLength; | |
| 301 | + } | |
| 302 | + | |
| 303 | + | |
| 304 | + public String getDocDescription() { | |
| 305 | + return docDescription; | |
| 306 | + } | |
| 307 | + | |
| 308 | + public void setDocDescription(String docDescription) { | |
| 309 | + this.docDescription = docDescription; | |
| 310 | + } | |
| 311 | + | |
| 312 | + public String getColName() { | |
| 313 | + return colName; | |
| 314 | + } | |
| 315 | + | |
| 316 | + public void setColName(String colName) { | |
| 317 | + this.colName = colName; | |
| 318 | + } | |
| 319 | + | |
| 320 | + public List<ModulesBean> getModules() { | |
| 321 | + return modules; | |
| 322 | + } | |
| 323 | + | |
| 324 | + public void setModules(List<ModulesBean> modules) { | |
| 325 | + this.modules = modules; | |
| 326 | + } | |
| 327 | + | |
| 328 | + @Override | |
| 329 | + public int describeContents() { | |
| 330 | + return 0; | |
| 331 | + } | |
| 332 | + | |
| 333 | + @Override | |
| 334 | + public void writeToParcel(Parcel dest, int flags) { | |
| 335 | + dest.writeString(pageUrl); | |
| 336 | + dest.writeString(CMSChannelName); | |
| 337 | + dest.writeString(vipFlag); | |
| 338 | + dest.writeString(type); | |
| 339 | + dest.writeString(packagePomID); | |
| 340 | + dest.writeString(cmsChannelID); | |
| 341 | + dest.writeString(MAM_ProducerID); | |
| 342 | + dest.writeString(activityId); | |
| 343 | + dest.writeString(title); | |
| 344 | + dest.writeString(MAM_NodeID); | |
| 345 | + dest.writeString(docSubTitle); | |
| 346 | + dest.writeString(playAuto); | |
| 347 | + dest.writeString(docID); | |
| 348 | + dest.writeString(MAM_SmallPosterUrl); | |
| 349 | + dest.writeString(onePomID); | |
| 350 | + dest.writeString(flashUrl); | |
| 351 | + dest.writeString(mediaId); | |
| 352 | + dest.writeString(MAM_NodeName); | |
| 353 | + dest.writeString(MAM_PosterUrl); | |
| 354 | + dest.writeString(status); | |
| 355 | + dest.writeString(cmsColumnID); | |
| 356 | + dest.writeString(rates); | |
| 357 | + dest.writeString(freePlayLength); | |
| 358 | + dest.writeString(docDescription); | |
| 359 | + dest.writeString(colName); | |
| 360 | + } | |
| 361 | + | |
| 362 | + public static class ModulesBean { | |
| 363 | + /** | |
| 364 | + * id : xiangguanshipin | |
| 365 | + * title : 相关推荐 | |
| 366 | + */ | |
| 367 | + | |
| 368 | + private String id; | |
| 369 | + private String title; | |
| 370 | + | |
| 371 | + public String getId() { | |
| 372 | + return id; | |
| 373 | + } | |
| 374 | + | |
| 375 | + public void setId(String id) { | |
| 376 | + this.id = id; | |
| 377 | + } | |
| 378 | + | |
| 379 | + public String getTitle() { | |
| 380 | + return title; | |
| 381 | + } | |
| 382 | + | |
| 383 | + public void setTitle(String title) { | |
| 384 | + this.title = title; | |
| 385 | + } | |
| 386 | + } | |
| 387 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/presenter/VodDetailPresenter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.presenter; | |
| 2 | + | |
| 3 | +import android.text.TextUtils; | |
| 4 | + | |
| 5 | +import com.cnlive.gundam.R; | |
| 6 | +import com.cnlive.gundam.main.model.CommentBean; | |
| 7 | +import com.cnlive.gundam.main.model.CommentTitleViewModel; | |
| 8 | +import com.cnlive.gundam.main.model.CommentViewModel; | |
| 9 | +import com.cnlive.gundam.video.fragment.CommentDetailsFragment; | |
| 10 | +import com.cnlive.gundam.video.utils.ToastUtil; | |
| 11 | +import com.cnlive.libs.util.chat.model.ErrorMessage; | |
| 12 | +import com.cnlive.libs.util.comment.CommentUtil; | |
| 13 | +import com.cnlive.libs.util.comment.base.CommentCallback; | |
| 14 | +import com.cnlive.libs.util.comment.base.CommentListCallback; | |
| 15 | +import com.cnlive.libs.util.model.CommentItem; | |
| 16 | +import com.cnlive.libs.util.model.CommentPage; | |
| 17 | + | |
| 18 | +import java.util.ArrayList; | |
| 19 | +import java.util.List; | |
| 20 | +/** | |
| 21 | + * 创建:wukuiqing | |
| 22 | + * <p> | |
| 23 | + * 时间:2017/7/12 | |
| 24 | + * <p> | |
| 25 | + * 描述: 评论界面的 presenter | |
| 26 | + */ | |
| 27 | + | |
| 28 | +public class VodDetailPresenter { | |
| 29 | + List mDatas = new ArrayList(); | |
| 30 | + | |
| 31 | + private CommentUtil commentUtil = new CommentUtil(); | |
| 32 | + | |
| 33 | + private int pageCount = 2; | |
| 34 | + CommentDetailsFragment commentFragment; | |
| 35 | + | |
| 36 | + public VodDetailPresenter(CommentDetailsFragment commentFragment) { | |
| 37 | + this.commentFragment = commentFragment; | |
| 38 | + } | |
| 39 | + | |
| 40 | + | |
| 41 | + public void getData() | |
| 42 | + { | |
| 43 | + mDatas.add(new CommentTitleViewModel("0")); | |
| 44 | + commentFragment.onLoadDataComplete(null,mDatas); | |
| 45 | + } | |
| 46 | + public void getComment(final boolean scrollState, String mContentId, int page) { | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + commentUtil.readAllComment(mContentId, page, pageCount, new CommentListCallback() { | |
| 51 | + @Override | |
| 52 | + public void onResponse(CommentPage commentPage) { | |
| 53 | + List mDatas = new ArrayList(); | |
| 54 | + mDatas.clear(); | |
| 55 | + | |
| 56 | + if ("0".equals(commentPage.getErrorCode())) { | |
| 57 | + if (commentPage.getData() == null || commentPage.getData().getComments() == null) { | |
| 58 | + if (commentFragment != null) | |
| 59 | + commentFragment.onLoadCommentComplete(null, false); | |
| 60 | + return; | |
| 61 | + } | |
| 62 | + | |
| 63 | + CommentTitleViewModel commentTitleViewModel = (CommentTitleViewModel) VodDetailPresenter.this.mDatas.get(0); | |
| 64 | + | |
| 65 | + commentTitleViewModel.setCount(commentPage.getData().getTotal_columns() + ""); | |
| 66 | + if (scrollState) { | |
| 67 | + CommentItem item = commentPage.getData().getComments().get(0); | |
| 68 | + CommentBean commentBean = new CommentBean(item.getFacepath(), item.getNick(), item.getCreated_at(), item.getContent(), item.getPraise(), item.getId()); | |
| 69 | + CommentViewModel commentViewModel = new CommentViewModel(commentBean); | |
| 70 | + mDatas.add(commentViewModel); | |
| 71 | + commentFragment.onLoadCommentComplete(mDatas, true); | |
| 72 | + return; | |
| 73 | + | |
| 74 | + } | |
| 75 | + for (CommentItem item : commentPage.getData().getComments()) { | |
| 76 | + CommentBean commentBean = new CommentBean(); | |
| 77 | + commentBean.setCommentContent(item.getContent()); | |
| 78 | + commentBean.setPraise(item.getPraise()); | |
| 79 | + commentBean.setTime(item.getCreated_at()); | |
| 80 | + commentBean.setUserHead(item.getFacepath()); | |
| 81 | + commentBean.setUserName(item.getNick()); | |
| 82 | + commentBean.setId(item.getId()); | |
| 83 | + CommentViewModel commentViewModel = new CommentViewModel(commentBean); | |
| 84 | + mDatas.add(commentViewModel); | |
| 85 | + | |
| 86 | + } | |
| 87 | + commentFragment.onLoadCommentComplete(mDatas, false); | |
| 88 | + } else { | |
| 89 | + ToastUtil.showToast("评论信息加载失败"); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + }); | |
| 93 | + } | |
| 94 | + | |
| 95 | + public void toPraise(final CommentViewModel commentViewModel, String mContentId, String uid) { | |
| 96 | + commentViewModel.isClickAble.set(false); | |
| 97 | + if (commentViewModel.getCommentBean() != null && commentViewModel.getCommentBean().isPraised() == 2) { | |
| 98 | + commentUtil.praiseComment(mContentId, uid, commentViewModel.getCommentBean().getId(), new CommentCallback() { | |
| 99 | + @Override | |
| 100 | + public void onResponse(ErrorMessage errorMessage) { | |
| 101 | + commentViewModel.isClickAble.set(true); | |
| 102 | + if ("0".equals(errorMessage.getErrorCode())) { | |
| 103 | + String praise = commentViewModel.getPraise(); | |
| 104 | + if (!TextUtils.isEmpty(praise)) { | |
| 105 | + int praiseTotal = Integer.parseInt(praise); | |
| 106 | + praiseTotal++; | |
| 107 | + praise = praiseTotal + ""; | |
| 108 | + } | |
| 109 | + commentViewModel.getCommentBean().setPraised(1); | |
| 110 | + commentViewModel.setPraise(praise); | |
| 111 | + commentViewModel.setPraiseImage(R.drawable.icon_praise_selected); | |
| 112 | + } else { | |
| 113 | + ToastUtil.showToast("点赞失败"); | |
| 114 | + } | |
| 115 | + } | |
| 116 | + }); | |
| 117 | + } else { | |
| 118 | + ToastUtil.showToast("已赞"); | |
| 119 | + } | |
| 120 | + } | |
| 121 | + | |
| 122 | + public void addCommment(final String mContentId, String uid, String message) { | |
| 123 | + commentUtil.insertComment(mContentId, uid, message, new CommentCallback() { | |
| 124 | + @Override | |
| 125 | + public void onResponse(ErrorMessage commentPage) { | |
| 126 | + if ("0".equals(commentPage.getErrorCode())) { | |
| 127 | + getComment(true, mContentId, 1); | |
| 128 | + ToastUtil.showToast("评论成功"); | |
| 129 | +// Toast.makeText(getActivity(), "点赞失败", Toast.LENGTH_SHORT).show(); | |
| 130 | + } else { | |
| 131 | + ToastUtil.showToast("评论信息加载失败"); | |
| 132 | + } | |
| 133 | + } | |
| 134 | + }); | |
| 135 | + } | |
| 136 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/presenter/view/VodDetialView.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.presenter.view; | |
| 2 | + | |
| 3 | + | |
| 4 | +import com.cnlive.gundam.main.model.VodDetailModel; | |
| 5 | + | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Created by ZJL on 2017/6/16. | |
| 10 | + */ | |
| 11 | + | |
| 12 | +public interface VodDetialView { | |
| 13 | + void onLoadDataComplete(VodDetailModel model, List mDatas); | |
| 14 | + void onLoadCommentComplete(List mDatas, boolean isScroll); | |
| 15 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/LoadImgAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter; | |
| 2 | + | |
| 3 | +import android.databinding.BindingAdapter; | |
| 4 | +import android.widget.ImageView; | |
| 5 | +import android.widget.TextView; | |
| 6 | +import android.widget.Toast; | |
| 7 | + | |
| 8 | +import com.bumptech.glide.Glide; | |
| 9 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Created by ZJL on 2017/5/15 | |
| 16 | + */ | |
| 17 | + | |
| 18 | +public class LoadImgAdapter { | |
| 19 | + | |
| 20 | + | |
| 21 | + @BindingAdapter({"circleUrl"}) | |
| 22 | + public static void loadCircleImage(ImageView iv, String url) { | |
| 23 | + Glide.with(iv.getContext()).load(url).into(iv); | |
| 24 | + | |
| 25 | + | |
| 26 | + } | |
| 27 | + | |
| 28 | + | |
| 29 | + @BindingAdapter({"backgroundUrl"}) | |
| 30 | + public static void loadNetImageInt(ImageView imageView, int url) { | |
| 31 | + | |
| 32 | +// Glide.with(iv.getContext()).load(url).into(iv); | |
| 33 | +// SimpleTarget target = new SimpleTarget<Drawable>(){ | |
| 34 | +// @Override | |
| 35 | +// public void onResourceReady(Drawable resource, GlideAnimation<? super Drawable> glideAnimation) { | |
| 36 | +// textView.setBackground(resource); | |
| 37 | +// } | |
| 38 | +// }; | |
| 39 | +// Glide.with(textView.getContext()) | |
| 40 | +// .load(R.drawable.search_text_red) | |
| 41 | +// .into(textView); | |
| 42 | + imageView.setImageResource(url); | |
| 43 | + } | |
| 44 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/mul/BaseBindingAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter.mul; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.databinding.ViewDataBinding; | |
| 6 | +import android.support.v7.widget.RecyclerView; | |
| 7 | +import android.view.LayoutInflater; | |
| 8 | +import android.view.ViewGroup; | |
| 9 | + | |
| 10 | + | |
| 11 | +import com.cnlive.gundam.BR; | |
| 12 | + | |
| 13 | +import java.util.ArrayList; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * Created by ZJL on 2017/5/14. | |
| 19 | + */ | |
| 20 | + | |
| 21 | +public class BaseBindingAdapter<D, B extends ViewDataBinding> extends RecyclerView.Adapter<BaseBindingVH<B>> { | |
| 22 | + protected Context mContext; | |
| 23 | + protected int mLayoutId; | |
| 24 | + protected List<D> mDatas; | |
| 25 | + protected LayoutInflater mInfalter; | |
| 26 | + //用于设置Item的事件Presenter | |
| 27 | + protected Object ItemPresenter; | |
| 28 | + | |
| 29 | + public BaseBindingAdapter(Context mContext, List mDatas, int mLayoutId) { | |
| 30 | + this.mContext = mContext; | |
| 31 | + this.mLayoutId = mLayoutId; | |
| 32 | + this.mDatas = mDatas; | |
| 33 | + this.mInfalter = LayoutInflater.from(mContext); | |
| 34 | + } | |
| 35 | + | |
| 36 | + public BaseBindingAdapter(Context mContext, List mDatas) { | |
| 37 | + this.mContext = mContext; | |
| 38 | + this.mDatas = mDatas; | |
| 39 | + this.mInfalter = LayoutInflater.from(mContext); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public BaseBindingVH<B> onCreateViewHolder(ViewGroup parent, int viewType) { | |
| 44 | + BaseBindingVH<B> holder = new BaseBindingVH<B>((B) DataBindingUtil.inflate(mInfalter, mLayoutId, parent, false)); | |
| 45 | + onCreateViewHolder(holder); | |
| 46 | + return holder; | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 如果需要给Vh设置监听器啥的 可以在这里 | |
| 51 | + * | |
| 52 | + * @param holder | |
| 53 | + */ | |
| 54 | + public void onCreateViewHolder(BaseBindingVH<B> holder) { | |
| 55 | + | |
| 56 | + } | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 子类除了绑定数据,还要设置监听器等其他操作。 | |
| 60 | + * 可以重写这个方法,不要删掉super.onBindViewHolder(holder, position); | |
| 61 | + * | |
| 62 | + * @param holder | |
| 63 | + * @param position | |
| 64 | + */ | |
| 65 | + @Override | |
| 66 | + public void onBindViewHolder(BaseBindingVH<B> holder, int position) { | |
| 67 | + holder.getBinding().setVariable(BR.data, mDatas.get(position)); | |
| 68 | + holder.getBinding().setVariable(BR.itemP, ItemPresenter); | |
| 69 | + holder.getBinding().executePendingBindings(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + public int getItemCount() { | |
| 74 | + return null != mDatas ? mDatas.size() : 0; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public Object getItemPresenter() { | |
| 78 | + return ItemPresenter; | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * 用于设置Item的事件Presenter | |
| 83 | + * | |
| 84 | + * @param itemPresenter | |
| 85 | + * @return | |
| 86 | + */ | |
| 87 | + public BaseBindingAdapter setItemPresenter(Object itemPresenter) { | |
| 88 | + ItemPresenter = itemPresenter; | |
| 89 | + return this; | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * 刷新数据,初始化数据 | |
| 94 | + * | |
| 95 | + * @param list | |
| 96 | + */ | |
| 97 | + public void setDatas(List<D> list) { | |
| 98 | + if (this.mDatas != null) { | |
| 99 | + if (null != list) { | |
| 100 | + List<D> temp = new ArrayList<D>(); | |
| 101 | + temp.addAll(list); | |
| 102 | + this.mDatas.clear(); | |
| 103 | + this.mDatas.addAll(temp); | |
| 104 | + } else { | |
| 105 | + this.mDatas.clear(); | |
| 106 | + } | |
| 107 | + } else { | |
| 108 | + this.mDatas = list; | |
| 109 | + } | |
| 110 | + notifyDataSetChanged(); | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * 删除一条数据 | |
| 115 | + * 会自动定向刷新 | |
| 116 | + * | |
| 117 | + * @param i | |
| 118 | + */ | |
| 119 | + public void remove(int i) { | |
| 120 | + if (null != mDatas && mDatas.size() > i && i > -1) { | |
| 121 | + mDatas.remove(i); | |
| 122 | + notifyItemRemoved(i); | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 添加一条数据 至队尾 | |
| 128 | + * 会自动定向刷新 | |
| 129 | + * | |
| 130 | + * @param data | |
| 131 | + */ | |
| 132 | + public void add(D data) { | |
| 133 | + if (data != null && mDatas != null) { | |
| 134 | + mDatas.add(data); | |
| 135 | + notifyItemInserted(mDatas.size()); | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 139 | + /** | |
| 140 | + * 在指定位置添加一条数据 | |
| 141 | + * 会自动定向刷新 | |
| 142 | + * <p> | |
| 143 | + * 如果指定位置越界,则添加在队尾 | |
| 144 | + * | |
| 145 | + * @param position | |
| 146 | + * @param data | |
| 147 | + */ | |
| 148 | + public void add(int position, D data) { | |
| 149 | + if (data != null && mDatas != null) { | |
| 150 | + if (mDatas.size() > position && position > -1) { | |
| 151 | + mDatas.add(position, data); | |
| 152 | + notifyItemInserted(position); | |
| 153 | + notifyItemChanged(position); | |
| 154 | + } else { | |
| 155 | + add(data); | |
| 156 | + } | |
| 157 | + } | |
| 158 | + } | |
| 159 | + | |
| 160 | + public void notifyItem(int position) { | |
| 161 | + notifyItemChanged(position); | |
| 162 | + } | |
| 163 | + | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * 加载更多数据 | |
| 167 | + * | |
| 168 | + * @param list | |
| 169 | + */ | |
| 170 | + public void addDatas(List<D> list) { | |
| 171 | + if (null != list) { | |
| 172 | + List<D> temp = new ArrayList<D>(); | |
| 173 | + temp.addAll(list); | |
| 174 | + if (this.mDatas != null) { | |
| 175 | + this.mDatas.addAll(temp); | |
| 176 | + } else { | |
| 177 | + this.mDatas = temp; | |
| 178 | + } | |
| 179 | + notifyDataSetChanged(); | |
| 180 | + } | |
| 181 | + | |
| 182 | + } | |
| 183 | + | |
| 184 | + | |
| 185 | + public List<D> getDatas() { | |
| 186 | + return mDatas; | |
| 187 | + } | |
| 188 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/mul/BaseBindingVH.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter.mul; | |
| 2 | + | |
| 3 | +import android.databinding.ViewDataBinding; | |
| 4 | +import android.support.v7.widget.RecyclerView; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * Created by ZJL on 2017/5/14. | |
| 8 | + */ | |
| 9 | + | |
| 10 | +public class BaseBindingVH<T extends ViewDataBinding> extends RecyclerView.ViewHolder { | |
| 11 | + protected final T mBinding; | |
| 12 | + | |
| 13 | + public BaseBindingVH(T t) { | |
| 14 | + super(t.getRoot()); | |
| 15 | + mBinding = t; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public T getBinding() { | |
| 19 | + return mBinding; | |
| 20 | + } | |
| 21 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/mul/BaseMulTypeBindingAdapter.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.adapter.mul; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.databinding.ViewDataBinding; | |
| 6 | +import android.util.Log; | |
| 7 | +import android.view.ViewGroup; | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 介绍:多种ItemType的Base类 | |
| 15 | + * 泛型T:多Item多Bean情况可以不传。如果只有一种Bean类型,可以传入Bean,实现IBaseMulInterface接口。 | |
| 16 | + * 或者传入IBaseMulInterface接口,可以拿到 getItemLayoutId(), | |
| 17 | + * 但是通过getItemViewType(int position),一样。所以多Item多Bean建议不传。 | |
| 18 | + * <p> | |
| 19 | + * 基类的泛型B:不用传,因为多种ItemType 肯定Layout长得不一样,那么Binding类也不一样,传入没有任何意义 | |
| 20 | + * Created by ZJL on 2017/5/15 | |
| 21 | + */ | |
| 22 | + | |
| 23 | +public class BaseMulTypeBindingAdapter<T extends IBaseMulInterface> extends BaseBindingAdapter<T, ViewDataBinding> { | |
| 24 | + | |
| 25 | + public BaseMulTypeBindingAdapter(Context mContext, List<T> mDatas) { | |
| 26 | + super(mContext, mDatas); | |
| 27 | + } | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + public int getItemViewType(int position) { | |
| 31 | + return mDatas.get(position).getItemLayoutId(); | |
| 32 | + } | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public BaseBindingVH<ViewDataBinding> onCreateViewHolder(ViewGroup parent, int viewType) { | |
| 36 | + Log.i("zjl","viewType:"+viewType); | |
| 37 | + BaseBindingVH<ViewDataBinding> holder = new BaseBindingVH<ViewDataBinding>(DataBindingUtil.inflate(mInfalter, viewType, parent, false)); | |
| 38 | + onCreateViewHolder(holder); | |
| 39 | + return holder; | |
| 40 | + } | |
| 41 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/adapter/mul/IBaseMulInterface.java
0 → 100644
app/src/main/java/com/cnlive/gundam/main/ui/widget/BaseFooterView.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.util.AttributeSet; | |
| 5 | +import android.widget.FrameLayout; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Created by ZJL on 2017/6/15. | |
| 9 | + */ | |
| 10 | +public abstract class BaseFooterView extends FrameLayout implements FooterViewListener{ | |
| 11 | + | |
| 12 | + public BaseFooterView(Context context) { | |
| 13 | + super(context); | |
| 14 | + } | |
| 15 | + | |
| 16 | + public BaseFooterView(Context context, AttributeSet attrs) { | |
| 17 | + super(context, attrs); | |
| 18 | + } | |
| 19 | + | |
| 20 | + public BaseFooterView(Context context, AttributeSet attrs, int defStyleAttr) { | |
| 21 | + super(context, attrs, defStyleAttr); | |
| 22 | + } | |
| 23 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/widget/BottomTabView.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.support.annotation.Nullable; | |
| 5 | +import android.support.v4.content.ContextCompat; | |
| 6 | +import android.util.AttributeSet; | |
| 7 | +import android.util.Log; | |
| 8 | +import android.view.LayoutInflater; | |
| 9 | +import android.view.View; | |
| 10 | +import android.view.ViewGroup; | |
| 11 | +import android.widget.ImageView; | |
| 12 | +import android.widget.LinearLayout; | |
| 13 | +import android.widget.TextView; | |
| 14 | + | |
| 15 | + | |
| 16 | +import com.cnlive.gundam.R; | |
| 17 | + | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * Created by ZJL on 2017/5/14. | |
| 22 | + */ | |
| 23 | + | |
| 24 | +public class BottomTabView extends LinearLayout { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 记录最新的选择位置 | |
| 28 | + */ | |
| 29 | + private int lastPosition = -1; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 所有 TabItem 的集合 | |
| 33 | + */ | |
| 34 | + private List<TabItemView> tabItemViews; | |
| 35 | + | |
| 36 | + public BottomTabView(Context context) { | |
| 37 | + super(context); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public BottomTabView(Context context, @Nullable AttributeSet attrs) { | |
| 41 | + super(context, attrs); | |
| 42 | + } | |
| 43 | + | |
| 44 | + | |
| 45 | + public BottomTabView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { | |
| 46 | + super(context, attrs, defStyleAttr); | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 设置 Tab Item View | |
| 51 | + */ | |
| 52 | + public void setTabItemViews(List<TabItemView> tabItemViews){ | |
| 53 | + setTabItemViews(tabItemViews, null); | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 设置 Tab Item View | |
| 58 | + */ | |
| 59 | + public void setTabItemViews(List<TabItemView> tabItemViews, View centerView){ | |
| 60 | + | |
| 61 | + if (this.tabItemViews != null){ | |
| 62 | + throw new RuntimeException("不能重复设置!"); | |
| 63 | + } | |
| 64 | + | |
| 65 | + if (tabItemViews == null || tabItemViews.size() < 2){ | |
| 66 | + throw new RuntimeException("TabItemView 的数量必须大于2!"); | |
| 67 | + } | |
| 68 | + | |
| 69 | + this.tabItemViews = tabItemViews; | |
| 70 | + for (int i=0; i<tabItemViews.size(); i++) { | |
| 71 | + | |
| 72 | + if (centerView != null && i == tabItemViews.size() / 2){ | |
| 73 | + this.addView(centerView); | |
| 74 | + } | |
| 75 | + | |
| 76 | + final TabItemView tabItemView = tabItemViews.get(i); | |
| 77 | + | |
| 78 | + this.addView(tabItemView); | |
| 79 | + | |
| 80 | + final int finalI = i; | |
| 81 | + | |
| 82 | + tabItemView.setOnClickListener(new OnClickListener() { | |
| 83 | + @Override | |
| 84 | + public void onClick(View v) { | |
| 85 | + | |
| 86 | + if (finalI == lastPosition){ | |
| 87 | + // 第二次点击 | |
| 88 | + if (onSecondSelectListener != null){ | |
| 89 | + onSecondSelectListener.onSecondSelect(finalI); | |
| 90 | + } | |
| 91 | + return ; | |
| 92 | + } | |
| 93 | + | |
| 94 | + updatePosition(finalI); | |
| 95 | + | |
| 96 | + if (onTabItemSelectListener != null){ | |
| 97 | + onTabItemSelectListener.onTabItemSelect(finalI); | |
| 98 | + } | |
| 99 | + } | |
| 100 | + }); | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * 将所有的 TabItem 设置为 初始化状态 | |
| 105 | + */ | |
| 106 | + for (TabItemView tab : tabItemViews) { | |
| 107 | + tab.setStatus(TabItemView.DEFAULT); | |
| 108 | + } | |
| 109 | + | |
| 110 | + /** | |
| 111 | + * 默认状态选择第一个 | |
| 112 | + */ | |
| 113 | + updatePosition(0); | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * 更新被选中 Tab Item 的状态 | |
| 118 | + * 恢复上一个 Tab Item 的状态 | |
| 119 | + */ | |
| 120 | + public void updatePosition(int position){ | |
| 121 | + Log.i("zjl","position:"+position); | |
| 122 | + if(position==-1){ | |
| 123 | + lastPosition=-1; | |
| 124 | + for (int i = 0; i < tabItemViews.size(); i++) { | |
| 125 | + tabItemViews.get(i).setStatus(TabItemView.DEFAULT); | |
| 126 | + } | |
| 127 | + }else | |
| 128 | + if (lastPosition != position){ | |
| 129 | + tabItemViews.get(position).setStatus(TabItemView.PRESS); | |
| 130 | + if (lastPosition != -1) { | |
| 131 | + tabItemViews.get(lastPosition).setStatus(TabItemView.DEFAULT); | |
| 132 | + } | |
| 133 | + lastPosition = position; | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 137 | + OnTabItemSelectListener onTabItemSelectListener; | |
| 138 | + OnSecondSelectListener onSecondSelectListener; | |
| 139 | + | |
| 140 | + public void setOnTabItemSelectListener(OnTabItemSelectListener onTabItemSelectListener){ | |
| 141 | + this.onTabItemSelectListener = onTabItemSelectListener; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public void setOnSecondSelectListener(OnSecondSelectListener onSecondSelectListener){ | |
| 145 | + this.onSecondSelectListener = onSecondSelectListener; | |
| 146 | + } | |
| 147 | + | |
| 148 | + /** | |
| 149 | + * 第二次被选择的监听器 | |
| 150 | + */ | |
| 151 | + public interface OnSecondSelectListener{ | |
| 152 | + void onSecondSelect(int position); | |
| 153 | + } | |
| 154 | + | |
| 155 | + /** | |
| 156 | + * 第一次被选择的监听器 | |
| 157 | + */ | |
| 158 | + public interface OnTabItemSelectListener{ | |
| 159 | + void onTabItemSelect(int position); | |
| 160 | + } | |
| 161 | + | |
| 162 | + /** | |
| 163 | + * Item | |
| 164 | + */ | |
| 165 | + public static class TabItemView extends LinearLayout { | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * 两个状态 选中、未选中 | |
| 169 | + */ | |
| 170 | + public final static int PRESS = 1; | |
| 171 | + public final static int DEFAULT = 2; | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * Item 的标题 | |
| 175 | + */ | |
| 176 | + public String title; | |
| 177 | + | |
| 178 | + /** | |
| 179 | + * 标题的两个状态的颜色 选中、未选中 | |
| 180 | + */ | |
| 181 | + public int colorDef; | |
| 182 | + public int colorPress; | |
| 183 | + | |
| 184 | + /** | |
| 185 | + * 两个图标的 资源 id ,选中、未选中 | |
| 186 | + */ | |
| 187 | + public int iconResDef; | |
| 188 | + public int iconResPress; | |
| 189 | + | |
| 190 | + public TextView tvTitle; | |
| 191 | + public ImageView ivIcon; | |
| 192 | + | |
| 193 | + public TabItemView(Context context, String title, int colorDef, int colorPress, | |
| 194 | + int iconResDef, int iconResPress) { | |
| 195 | + super(context); | |
| 196 | + this.title = title; | |
| 197 | + this.colorDef = colorDef; | |
| 198 | + this.colorPress = colorPress; | |
| 199 | + this.iconResDef = iconResDef; | |
| 200 | + this.iconResPress = iconResPress; | |
| 201 | + init(); | |
| 202 | + } | |
| 203 | + | |
| 204 | + /** | |
| 205 | + * 初始化 | |
| 206 | + */ | |
| 207 | + public void init(){ | |
| 208 | + View view = LayoutInflater.from(super.getContext()).inflate(R.layout.item_view_tab, this); | |
| 209 | + tvTitle = (TextView) view.findViewById(R.id.tvTitle); | |
| 210 | + ivIcon = (ImageView) view.findViewById(R.id.ivIcon); | |
| 211 | + | |
| 212 | + LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); | |
| 213 | + layoutParams.weight = 1; | |
| 214 | + view.setLayoutParams(layoutParams); | |
| 215 | + | |
| 216 | + tvTitle.setText(title); | |
| 217 | + | |
| 218 | + } | |
| 219 | + | |
| 220 | + /** | |
| 221 | + * 设置状态 | |
| 222 | + */ | |
| 223 | + public void setStatus(int status){ | |
| 224 | + tvTitle.setTextColor(ContextCompat.getColor(super.getContext(), status == PRESS ? colorPress : colorDef)); | |
| 225 | + ivIcon.setImageResource(status == PRESS ? iconResPress : iconResDef); | |
| 226 | + } | |
| 227 | + } | |
| 228 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/widget/FooterViewListener.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | |
| 2 | + | |
| 3 | + | |
| 4 | +public interface FooterViewListener { | |
| 5 | + | |
| 6 | + /** | |
| 7 | + * 网络不好的时候想要展示的UI | |
| 8 | + */ | |
| 9 | + void onNetChange(boolean isAvailable); | |
| 10 | + | |
| 11 | + /** | |
| 12 | + * 正常的loading的View | |
| 13 | + */ | |
| 14 | + void onLoadingMore(); | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 没有更多数据 | |
| 18 | + */ | |
| 19 | + void onNoMore(CharSequence message); | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 错误时展示的View | |
| 23 | + */ | |
| 24 | + void onError(CharSequence message); | |
| 25 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/widget/SimpleFooterView.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.util.AttributeSet; | |
| 5 | +import android.view.LayoutInflater; | |
| 6 | +import android.view.View; | |
| 7 | +import android.view.ViewGroup; | |
| 8 | +import android.widget.ProgressBar; | |
| 9 | +import android.widget.TextView; | |
| 10 | + | |
| 11 | +import com.cnlive.gundam.R; | |
| 12 | + | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Created by ZJL on 2017/6/15. | |
| 16 | + */ | |
| 17 | +public class SimpleFooterView extends BaseFooterView{ | |
| 18 | + | |
| 19 | + private TextView mText; | |
| 20 | + | |
| 21 | + private ProgressBar progressBar; | |
| 22 | + | |
| 23 | + public SimpleFooterView(Context context) { | |
| 24 | + this(context, null); | |
| 25 | + } | |
| 26 | + | |
| 27 | + public SimpleFooterView(Context context, AttributeSet attrs) { | |
| 28 | + this(context, attrs, 0); | |
| 29 | + } | |
| 30 | + | |
| 31 | + public SimpleFooterView(Context context, AttributeSet attrs, int defStyleAttr) { | |
| 32 | + super(context, attrs, defStyleAttr); | |
| 33 | + | |
| 34 | + setLayoutParams(new LayoutParams( | |
| 35 | + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | |
| 36 | + View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_footer_view, this); | |
| 37 | + progressBar = (ProgressBar) view.findViewById(R.id.footer_view_progressbar); | |
| 38 | + mText = (TextView) view.findViewById(R.id.footer_view_tv); | |
| 39 | + } | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void onLoadingMore() { | |
| 45 | + progressBar.setVisibility(VISIBLE); | |
| 46 | + mText.setVisibility(GONE); | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void showText(){ | |
| 50 | + progressBar.setVisibility(GONE); | |
| 51 | + mText.setVisibility(VISIBLE); | |
| 52 | + } | |
| 53 | + | |
| 54 | + /**************文字自行修改或根据传入的参数动态修改****************/ | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public void onNoMore(CharSequence message) { | |
| 58 | + showText(); | |
| 59 | + mText.setText(message); | |
| 60 | + } | |
| 61 | + | |
| 62 | + @Override | |
| 63 | + public void onError(CharSequence message) { | |
| 64 | + showText(); | |
| 65 | + mText.setText("啊哦,好像哪里不对劲!"); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public void onNetChange(boolean isAvailable) { | |
| 70 | + showText(); | |
| 71 | + mText.setText("网络连接不通畅!"); | |
| 72 | + } | |
| 73 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/widget/SwipeRecyclerView.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | |
| 2 | + | |
| 3 | +import android.annotation.TargetApi; | |
| 4 | +import android.content.Context; | |
| 5 | +import android.os.Build; | |
| 6 | +import android.support.annotation.Nullable; | |
| 7 | +import android.support.v4.widget.SwipeRefreshLayout; | |
| 8 | +import android.support.v7.widget.GridLayoutManager; | |
| 9 | +import android.support.v7.widget.GridLayoutManager.SpanSizeLookup; | |
| 10 | +import android.support.v7.widget.LinearLayoutManager; | |
| 11 | +import android.support.v7.widget.RecyclerView; | |
| 12 | +import android.support.v7.widget.RecyclerView.LayoutManager; | |
| 13 | +import android.support.v7.widget.RecyclerView.OnScrollListener; | |
| 14 | +import android.support.v7.widget.StaggeredGridLayoutManager; | |
| 15 | +import android.util.AttributeSet; | |
| 16 | +import android.view.Gravity; | |
| 17 | +import android.view.LayoutInflater; | |
| 18 | +import android.view.View; | |
| 19 | +import android.view.ViewGroup; | |
| 20 | +import android.widget.FrameLayout; | |
| 21 | + | |
| 22 | +import com.cnlive.gundam.R; | |
| 23 | + | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * Created by ZJL on 2017/6/15. | |
| 27 | + */ | |
| 28 | + | |
| 29 | +public class SwipeRecyclerView extends FrameLayout | |
| 30 | + implements SwipeRefreshLayout.OnRefreshListener{ | |
| 31 | + | |
| 32 | + private View mEmptyView; | |
| 33 | + private BaseFooterView mFootView; | |
| 34 | + private RecyclerView recyclerView; | |
| 35 | + private SwipeRefreshLayout mRefreshLayout; | |
| 36 | + | |
| 37 | + private LayoutManager mLayoutManager; | |
| 38 | + private OnLoadListener mListener; | |
| 39 | + private SpanSizeLookup mSpanSizeLookup; | |
| 40 | + private DataObserver mDataObserver; | |
| 41 | + private WrapperAdapter mWrapperAdapter; | |
| 42 | + | |
| 43 | + private boolean isEmptyViewShowing; | |
| 44 | + private boolean isLoadingMore; | |
| 45 | + private boolean isLoadMoreEnable; | |
| 46 | + private boolean isRefreshEnable; | |
| 47 | + | |
| 48 | + private int lastVisiablePosition = 0; | |
| 49 | + private StickyListener mStickyListener; | |
| 50 | + private int fistVisiblePoisiton; | |
| 51 | + | |
| 52 | + public SwipeRecyclerView(Context context) { | |
| 53 | + this(context, null); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public SwipeRecyclerView(Context context, @Nullable AttributeSet attrs) { | |
| 57 | + this(context, attrs, 0); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public SwipeRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) { | |
| 61 | + super(context, attrs, defStyle); | |
| 62 | + setupSwipeRecyclerView(); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @TargetApi(Build.VERSION_CODES.M) | |
| 66 | + private void setupSwipeRecyclerView() { | |
| 67 | + | |
| 68 | + isEmptyViewShowing = false; | |
| 69 | + isRefreshEnable = true; | |
| 70 | + isLoadingMore = false; | |
| 71 | + isLoadMoreEnable = true; | |
| 72 | + | |
| 73 | + mFootView = new SimpleFooterView(getContext()); | |
| 74 | + | |
| 75 | + View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_swipe_recyclerview, this); | |
| 76 | + mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.SwipeRefreshLayout); | |
| 77 | + recyclerView = (RecyclerView) view.findViewById(R.id.RecyclerView); | |
| 78 | + mLayoutManager = recyclerView.getLayoutManager(); | |
| 79 | + | |
| 80 | + mRefreshLayout.setOnRefreshListener(this); | |
| 81 | + recyclerView.setOnScrollListener(new OnScrollListener() { | |
| 82 | + @Override | |
| 83 | + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { | |
| 84 | + super.onScrollStateChanged(recyclerView, newState); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
| 89 | + super.onScrolled(recyclerView, dx, dy); | |
| 90 | + // do nothing if load more is not enable or refreshing or loading more | |
| 91 | + if(mLayoutManager instanceof LinearLayoutManager){ | |
| 92 | + fistVisiblePoisiton=((LinearLayoutManager)mLayoutManager).findFirstVisibleItemPosition(); | |
| 93 | + if(fistVisiblePoisiton>=2&&mStickyListener!=null){ | |
| 94 | + mStickyListener.onSticky(true); | |
| 95 | + }else{ | |
| 96 | + mStickyListener.onSticky(false); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + if(!isLoadMoreEnable || isRefreshing() || isLoadingMore){ | |
| 100 | + return; | |
| 101 | + } | |
| 102 | + //get the lastVisiablePosition | |
| 103 | + mLayoutManager = recyclerView.getLayoutManager(); | |
| 104 | + | |
| 105 | + if(mLayoutManager instanceof LinearLayoutManager){ | |
| 106 | + lastVisiablePosition = ((LinearLayoutManager)mLayoutManager).findLastVisibleItemPosition(); | |
| 107 | + }else if(mLayoutManager instanceof GridLayoutManager){ | |
| 108 | + lastVisiablePosition = ((GridLayoutManager)mLayoutManager).findLastCompletelyVisibleItemPosition(); | |
| 109 | + }else if(mLayoutManager instanceof StaggeredGridLayoutManager){ | |
| 110 | + int[] into = new int[((StaggeredGridLayoutManager) mLayoutManager).getSpanCount()]; | |
| 111 | + ((StaggeredGridLayoutManager) mLayoutManager).findLastVisibleItemPositions(into); | |
| 112 | + lastVisiablePosition = findMax(into); | |
| 113 | + } | |
| 114 | + | |
| 115 | + int childCount = mWrapperAdapter == null ? 0 : mWrapperAdapter.getItemCount(); | |
| 116 | + if(childCount > 1 && lastVisiablePosition == childCount - 1){ | |
| 117 | + | |
| 118 | + if(mListener != null){ | |
| 119 | + isLoadingMore = true; | |
| 120 | + mListener.onLoadMore(); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + } | |
| 124 | + }); | |
| 125 | + } | |
| 126 | + | |
| 127 | + private int findMax(int[] lastPositions) { | |
| 128 | + int max = lastPositions[0]; | |
| 129 | + for (int value : lastPositions) { | |
| 130 | + if (value > max) { | |
| 131 | + max = value; | |
| 132 | + } | |
| 133 | + } | |
| 134 | + return max; | |
| 135 | + } | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * set is enable pull to refresh | |
| 139 | + * @param refreshEnable | |
| 140 | + */ | |
| 141 | + public void setRefreshEnable(boolean refreshEnable){ | |
| 142 | + isRefreshEnable = refreshEnable; | |
| 143 | + mRefreshLayout.setEnabled(isRefreshEnable); | |
| 144 | + } | |
| 145 | + | |
| 146 | + public boolean getRefreshEnable(){ | |
| 147 | + return isRefreshEnable; | |
| 148 | + } | |
| 149 | + | |
| 150 | + /** | |
| 151 | + * set is loading more enable | |
| 152 | + * @param loadMoreEnable | |
| 153 | + * if true when recyclerView scroll to bottom load more action will be trigger | |
| 154 | + */ | |
| 155 | + public void setLoadMoreEnable(boolean loadMoreEnable) { | |
| 156 | + if(!loadMoreEnable){ | |
| 157 | + stopLoadingMore(); | |
| 158 | + } | |
| 159 | + isLoadMoreEnable = loadMoreEnable; | |
| 160 | + } | |
| 161 | + | |
| 162 | + public boolean getLoadMoreEnable(){ | |
| 163 | + return isLoadMoreEnable; | |
| 164 | + } | |
| 165 | + | |
| 166 | + /** | |
| 167 | + * get is refreshing | |
| 168 | + * @return | |
| 169 | + */ | |
| 170 | + public boolean isRefreshing(){ | |
| 171 | + return mRefreshLayout.isRefreshing(); | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * get is loading more | |
| 176 | + * @return | |
| 177 | + */ | |
| 178 | + public boolean isLoadingMore(){ | |
| 179 | + return isLoadingMore; | |
| 180 | + } | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * is empty view showing | |
| 184 | + * @return | |
| 185 | + */ | |
| 186 | + public boolean isEmptyViewShowing(){ | |
| 187 | + return isEmptyViewShowing; | |
| 188 | + } | |
| 189 | + | |
| 190 | + /** | |
| 191 | + * you may need set some other attributes of swipeRefreshLayout | |
| 192 | + * @return | |
| 193 | + * swipeRefreshLayout | |
| 194 | + */ | |
| 195 | + public SwipeRefreshLayout getSwipeRefreshLayout(){ | |
| 196 | + return mRefreshLayout; | |
| 197 | + } | |
| 198 | + | |
| 199 | + /** | |
| 200 | + * you may need set some other attributes of RecyclerView | |
| 201 | + * @return | |
| 202 | + * RecyclerView | |
| 203 | + */ | |
| 204 | + public RecyclerView getRecyclerView(){ | |
| 205 | + return recyclerView; | |
| 206 | + } | |
| 207 | + | |
| 208 | + /** | |
| 209 | + * set load more listener | |
| 210 | + * @param listener | |
| 211 | + */ | |
| 212 | + public void setOnLoadListener(OnLoadListener listener){ | |
| 213 | + mListener = listener; | |
| 214 | + } | |
| 215 | + | |
| 216 | + /** | |
| 217 | + * support for GridLayoutManager | |
| 218 | + * @param spanSizeLookup | |
| 219 | + */ | |
| 220 | + public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup){ | |
| 221 | + this.mSpanSizeLookup = spanSizeLookup; | |
| 222 | + } | |
| 223 | + | |
| 224 | + /** | |
| 225 | + * set the footer view | |
| 226 | + * @param footerView | |
| 227 | + * the view to be showing when pull up | |
| 228 | + */ | |
| 229 | + public void setFooterView(BaseFooterView footerView){ | |
| 230 | + if(footerView != null) { | |
| 231 | + this.mFootView = footerView; | |
| 232 | + } | |
| 233 | + } | |
| 234 | + | |
| 235 | + /** | |
| 236 | + * set a empty view like listview | |
| 237 | + * @param emptyView | |
| 238 | + * the view to be showing when the data set size is zero | |
| 239 | + */ | |
| 240 | + public void setEmptyView(View emptyView){ | |
| 241 | + if(mEmptyView != null){ | |
| 242 | + removeView(mEmptyView); | |
| 243 | + } | |
| 244 | + this.mEmptyView = emptyView; | |
| 245 | + | |
| 246 | + if(mDataObserver != null) { | |
| 247 | + mDataObserver.onChanged(); | |
| 248 | + } | |
| 249 | + } | |
| 250 | + | |
| 251 | + /** | |
| 252 | + * set adapter to recyclerView | |
| 253 | + * @param adapter | |
| 254 | + */ | |
| 255 | + public void setAdapter(RecyclerView.Adapter adapter){ | |
| 256 | + if(adapter != null) { | |
| 257 | + if(mDataObserver == null){ | |
| 258 | + mDataObserver = new DataObserver(); | |
| 259 | + } | |
| 260 | + mWrapperAdapter = new WrapperAdapter(adapter); | |
| 261 | + recyclerView.setAdapter(mWrapperAdapter); | |
| 262 | + adapter.registerAdapterDataObserver(mDataObserver); | |
| 263 | + mDataObserver.onChanged(); | |
| 264 | + } | |
| 265 | + } | |
| 266 | + | |
| 267 | + /** | |
| 268 | + * refresh or load more completed | |
| 269 | + */ | |
| 270 | + public void complete(){ | |
| 271 | + mRefreshLayout.setRefreshing(false); | |
| 272 | + stopLoadingMore(); | |
| 273 | + } | |
| 274 | + | |
| 275 | + /** | |
| 276 | + * set refreshing | |
| 277 | + * if you want load data when first in, you can setRefreshing(true) | |
| 278 | + * after {@link #setOnLoadListener(OnLoadListener)} | |
| 279 | + * @param refreshing | |
| 280 | + */ | |
| 281 | + public void setRefreshing(boolean refreshing){ | |
| 282 | + mRefreshLayout.setRefreshing(refreshing); | |
| 283 | + if(refreshing && !isLoadingMore && mListener != null){ | |
| 284 | + mListener.onRefresh(); | |
| 285 | + } | |
| 286 | + } | |
| 287 | + | |
| 288 | + /** | |
| 289 | + * stop loading more without animation | |
| 290 | + */ | |
| 291 | + public void stopLoadingMore(){ | |
| 292 | + isLoadingMore = false; | |
| 293 | + if(mWrapperAdapter != null) { | |
| 294 | + mWrapperAdapter.notifyItemRemoved(mWrapperAdapter.getItemCount()); | |
| 295 | + } | |
| 296 | + } | |
| 297 | + | |
| 298 | + /** | |
| 299 | + * call method {@link OnLoadListener#onRefresh()} | |
| 300 | + */ | |
| 301 | + @Override | |
| 302 | + public void onRefresh() { | |
| 303 | + if(mListener != null){ | |
| 304 | + | |
| 305 | + //reset footer view status loading | |
| 306 | + if(mFootView != null){ | |
| 307 | + mFootView.onLoadingMore(); | |
| 308 | + } | |
| 309 | + mListener.onRefresh(); | |
| 310 | + } | |
| 311 | + } | |
| 312 | + | |
| 313 | + public void onNetChange(boolean isAvailable) { | |
| 314 | + if(mFootView != null){ | |
| 315 | + mFootView.onNetChange(isAvailable); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + | |
| 319 | + public void onLoadingMore() { | |
| 320 | + if(mFootView != null){ | |
| 321 | + mFootView.onLoadingMore(); | |
| 322 | + } | |
| 323 | + } | |
| 324 | + | |
| 325 | + public void onNoMore(CharSequence message) { | |
| 326 | + if(mFootView != null){ | |
| 327 | + mFootView.onNoMore(message); | |
| 328 | + } | |
| 329 | + } | |
| 330 | + | |
| 331 | + public void onError(CharSequence message) { | |
| 332 | + if(mFootView != null){ | |
| 333 | + mFootView.onError(message); | |
| 334 | + } | |
| 335 | + } | |
| 336 | + | |
| 337 | + | |
| 338 | + private class WrapperAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{ | |
| 339 | + | |
| 340 | + public static final int TYPE_FOOTER = 0x100; | |
| 341 | + | |
| 342 | + RecyclerView.Adapter<RecyclerView.ViewHolder> mInnerAdapter; | |
| 343 | + | |
| 344 | + public WrapperAdapter(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter){ | |
| 345 | + this.mInnerAdapter = adapter; | |
| 346 | + } | |
| 347 | + | |
| 348 | + public boolean isLoadMoreItem(int position){ | |
| 349 | + return isLoadMoreEnable && position == getItemCount() - 1; | |
| 350 | + } | |
| 351 | + | |
| 352 | + @Override | |
| 353 | + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
| 354 | + if(TYPE_FOOTER == viewType){ | |
| 355 | + return new FooterViewHolder(mFootView); | |
| 356 | + } | |
| 357 | + return mInnerAdapter.onCreateViewHolder(parent, viewType); | |
| 358 | + } | |
| 359 | + | |
| 360 | + @Override | |
| 361 | + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | |
| 362 | + if(isLoadMoreItem(position)){ | |
| 363 | + return; | |
| 364 | + } | |
| 365 | + mInnerAdapter.onBindViewHolder(holder, position); | |
| 366 | + } | |
| 367 | + | |
| 368 | + | |
| 369 | + @Override | |
| 370 | + public int getItemViewType(int position) { | |
| 371 | + if(isLoadMoreItem(position)){ | |
| 372 | + return TYPE_FOOTER; | |
| 373 | + }else{ | |
| 374 | + return mInnerAdapter.getItemViewType(position); | |
| 375 | + } | |
| 376 | + } | |
| 377 | + | |
| 378 | + @Override | |
| 379 | + public int getItemCount() { | |
| 380 | + int count = mInnerAdapter == null ? 0 : mInnerAdapter.getItemCount(); | |
| 381 | + | |
| 382 | + //without loadingMore when adapter size is zero | |
| 383 | + if(count == 0){ | |
| 384 | + return 0; | |
| 385 | + } | |
| 386 | + return isLoadMoreEnable ? count + 1 : count; | |
| 387 | + } | |
| 388 | + | |
| 389 | + @Override | |
| 390 | + public long getItemId(int position) { | |
| 391 | + return mInnerAdapter.getItemId(position); | |
| 392 | + } | |
| 393 | + | |
| 394 | + @Override | |
| 395 | + public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { | |
| 396 | + ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams(); | |
| 397 | + if (lp != null | |
| 398 | + && lp instanceof StaggeredGridLayoutManager.LayoutParams | |
| 399 | + && isLoadMoreItem(holder.getLayoutPosition())) | |
| 400 | + { | |
| 401 | + StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp; | |
| 402 | + p.setFullSpan(true); | |
| 403 | + } | |
| 404 | + mInnerAdapter.onViewAttachedToWindow(holder); | |
| 405 | + } | |
| 406 | + | |
| 407 | + @Override | |
| 408 | + public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) { | |
| 409 | + mInnerAdapter.onViewDetachedFromWindow(holder); | |
| 410 | + } | |
| 411 | + | |
| 412 | + @Override | |
| 413 | + public void onAttachedToRecyclerView(RecyclerView recyclerView) { | |
| 414 | + LayoutManager manager = recyclerView.getLayoutManager(); | |
| 415 | + if (manager instanceof GridLayoutManager) { | |
| 416 | + final GridLayoutManager gridManager = ((GridLayoutManager) manager); | |
| 417 | + gridManager.setSpanSizeLookup(new SpanSizeLookup() { | |
| 418 | + @Override | |
| 419 | + public int getSpanSize(int position) { | |
| 420 | + boolean isLoadMore = isLoadMoreItem(position); | |
| 421 | + if(mSpanSizeLookup != null && !isLoadMore){ | |
| 422 | + return mSpanSizeLookup.getSpanSize(position); | |
| 423 | + } | |
| 424 | + return isLoadMore ? gridManager.getSpanCount() : 1; | |
| 425 | + } | |
| 426 | + }); | |
| 427 | + } | |
| 428 | + mInnerAdapter.onAttachedToRecyclerView(recyclerView); | |
| 429 | + } | |
| 430 | + | |
| 431 | + @Override | |
| 432 | + public void onDetachedFromRecyclerView(RecyclerView recyclerView) { | |
| 433 | + mInnerAdapter.onDetachedFromRecyclerView(recyclerView); | |
| 434 | + } | |
| 435 | + | |
| 436 | + @Override | |
| 437 | + public boolean onFailedToRecycleView(RecyclerView.ViewHolder holder) { | |
| 438 | + return mInnerAdapter.onFailedToRecycleView(holder); | |
| 439 | + } | |
| 440 | + | |
| 441 | + @Override | |
| 442 | + public void registerAdapterDataObserver(RecyclerView.AdapterDataObserver observer) { | |
| 443 | + mInnerAdapter.registerAdapterDataObserver(observer); | |
| 444 | + } | |
| 445 | + | |
| 446 | + @Override | |
| 447 | + public void unregisterAdapterDataObserver(RecyclerView.AdapterDataObserver observer) { | |
| 448 | + mInnerAdapter.unregisterAdapterDataObserver(observer); | |
| 449 | + } | |
| 450 | + | |
| 451 | + @Override | |
| 452 | + public void onViewRecycled(RecyclerView.ViewHolder holder) { | |
| 453 | + mInnerAdapter.onViewRecycled(holder); | |
| 454 | + } | |
| 455 | + } | |
| 456 | + | |
| 457 | + /** | |
| 458 | + * ViewHolder of footerView | |
| 459 | + */ | |
| 460 | + private class FooterViewHolder extends RecyclerView.ViewHolder { | |
| 461 | + public FooterViewHolder(View itemView) { | |
| 462 | + super(itemView); | |
| 463 | + } | |
| 464 | + } | |
| 465 | + | |
| 466 | + /** | |
| 467 | + * a inner class used to monitor the dataSet change | |
| 468 | + * <p> | |
| 469 | + * because wrapperAdapter do not know when wrapperAdapter.mInnerAdapter | |
| 470 | + * <p> | |
| 471 | + * dataSet changed, these method are final | |
| 472 | + */ | |
| 473 | + class DataObserver extends RecyclerView.AdapterDataObserver{ | |
| 474 | + | |
| 475 | + @Override | |
| 476 | + public void onChanged() { | |
| 477 | + super.onChanged(); | |
| 478 | + RecyclerView.Adapter adapter = recyclerView.getAdapter(); | |
| 479 | + if(adapter != null && mEmptyView != null){ | |
| 480 | + | |
| 481 | + int count = 0; | |
| 482 | + if(isLoadMoreEnable && adapter.getItemCount() != 0){ | |
| 483 | + count ++; | |
| 484 | + } | |
| 485 | + if(adapter.getItemCount() == count){ | |
| 486 | + isEmptyViewShowing = true; | |
| 487 | + if(mEmptyView.getParent() == null){ | |
| 488 | + LayoutParams params = new LayoutParams( | |
| 489 | + ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
| 490 | + params.gravity = Gravity.CENTER; | |
| 491 | + | |
| 492 | + addView(mEmptyView, params); | |
| 493 | + } | |
| 494 | + | |
| 495 | + recyclerView.setVisibility(GONE); | |
| 496 | + mEmptyView.setVisibility(VISIBLE); | |
| 497 | + }else{ | |
| 498 | + isEmptyViewShowing = false; | |
| 499 | + mEmptyView.setVisibility(GONE); | |
| 500 | + recyclerView.setVisibility(VISIBLE); | |
| 501 | + } | |
| 502 | + } | |
| 503 | + mWrapperAdapter.notifyDataSetChanged(); | |
| 504 | + } | |
| 505 | + | |
| 506 | + @Override | |
| 507 | + public void onItemRangeChanged(int positionStart, int itemCount) { | |
| 508 | + super.onItemRangeChanged(positionStart, itemCount); | |
| 509 | + mWrapperAdapter.notifyItemRangeChanged(positionStart, itemCount); | |
| 510 | + } | |
| 511 | + | |
| 512 | + @Override | |
| 513 | + public void onItemRangeChanged(int positionStart, int itemCount, Object payload) { | |
| 514 | + super.onItemRangeChanged(positionStart, itemCount, payload); | |
| 515 | + mWrapperAdapter.notifyItemRangeChanged(positionStart, itemCount, payload); | |
| 516 | + } | |
| 517 | + | |
| 518 | + @Override | |
| 519 | + public void onItemRangeInserted(int positionStart, int itemCount) { | |
| 520 | + super.onItemRangeInserted(positionStart, itemCount); | |
| 521 | + mWrapperAdapter.notifyItemRangeInserted(positionStart, itemCount); | |
| 522 | + } | |
| 523 | + | |
| 524 | + @Override | |
| 525 | + public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) { | |
| 526 | + super.onItemRangeMoved(fromPosition, toPosition, itemCount); | |
| 527 | + mWrapperAdapter.notifyItemRangeRemoved(fromPosition, itemCount); | |
| 528 | + } | |
| 529 | + | |
| 530 | + @Override | |
| 531 | + public void onItemRangeRemoved(int positionStart, int itemCount) { | |
| 532 | + super.onItemRangeRemoved(positionStart, itemCount); | |
| 533 | + mWrapperAdapter.notifyItemRangeRemoved(positionStart, itemCount); | |
| 534 | + } | |
| 535 | + | |
| 536 | + } | |
| 537 | + public void setStickyListener(StickyListener stickyListener){ | |
| 538 | + mStickyListener=stickyListener; | |
| 539 | + } | |
| 540 | + public interface OnLoadListener { | |
| 541 | + | |
| 542 | + void onRefresh(); | |
| 543 | + | |
| 544 | + void onLoadMore(); | |
| 545 | + } | |
| 546 | + public interface StickyListener{ | |
| 547 | + void onSticky(boolean isVisible); | |
| 548 | + } | |
| 549 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/video/adpter/CommentAdapter.java
| ... | ... | @@ -23,10 +23,10 @@ import java.util.List; |
| 23 | 23 | */ |
| 24 | 24 | public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentHolder> { |
| 25 | 25 | |
| 26 | - protected List<CommentItem> mItems = new ArrayList<CommentItem>(); | |
| 27 | - protected OnImageViewClick onImageViewClick; | |
| 26 | + private List<CommentItem> mItems = new ArrayList<CommentItem>(); | |
| 27 | + private OnImageViewClick onImageViewClick; | |
| 28 | 28 | Context context; |
| 29 | - private final LayoutInflater mLayoutInflater; | |
| 29 | + private LayoutInflater mLayoutInflater; | |
| 30 | 30 | private CommentHolder commentHolder; |
| 31 | 31 | |
| 32 | 32 | public CommentAdapter(Context context) { |
| ... | ... | @@ -36,10 +36,19 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public void addItems(List<CommentItem> items) { |
| 39 | + | |
| 39 | 40 | mItems.addAll(items); |
| 40 | 41 | notifyDataSetChanged(); |
| 41 | 42 | } |
| 42 | 43 | |
| 44 | + public void addItem(CommentItem item) { | |
| 45 | + | |
| 46 | + mItems.add(0,item); | |
| 47 | + | |
| 48 | + notifyDataSetChanged(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 43 | 52 | public void refreshItems(List<CommentItem> items) { |
| 44 | 53 | mItems.clear(); |
| 45 | 54 | mItems.addAll(items); |
| ... | ... | @@ -58,10 +67,17 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH |
| 58 | 67 | return commentHolder; |
| 59 | 68 | } |
| 60 | 69 | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 61 | 74 | @Override |
| 62 | 75 | public void onBindViewHolder(CommentHolder holder, int position) { |
| 63 | 76 | |
| 64 | - final CommentItem commentItem = mItems.get(position); | |
| 77 | + | |
| 78 | + final CommentItem commentItem = mItems.get(position); | |
| 79 | + | |
| 80 | + | |
| 65 | 81 | Glide.with(context).load(commentItem.getFacepath()).into(commentHolder.img_head); |
| 66 | 82 | commentHolder.nick_name.setText(commentItem.getUid()); |
| 67 | 83 | commentHolder.comment_message.setText(commentItem.getContent()); |
| ... | ... | @@ -87,17 +103,18 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH |
| 87 | 103 | this.onImageViewClick = onImageViewClick; |
| 88 | 104 | } |
| 89 | 105 | |
| 106 | + | |
| 90 | 107 | public interface OnImageViewClick { |
| 91 | 108 | void praiseComment(CommentItem commentItem); |
| 92 | 109 | } |
| 93 | 110 | |
| 94 | 111 | class CommentHolder extends RecyclerView.ViewHolder { |
| 95 | 112 | |
| 96 | - public final TextView nick_name; | |
| 97 | - public final TextView comment_message; | |
| 98 | - public final TextView comment_good_count; | |
| 99 | - public final ImageView good_imv1; | |
| 100 | - public final ImageView img_head; | |
| 113 | + public TextView nick_name; | |
| 114 | + public TextView comment_message; | |
| 115 | + public TextView comment_good_count; | |
| 116 | + public ImageView good_imv1; | |
| 117 | + public ImageView img_head; | |
| 101 | 118 | |
| 102 | 119 | public CommentHolder(View itemView) { |
| 103 | 120 | super(itemView); | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/CommentDetailsFragment.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.fragment; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.databinding.DataBindingUtil; | |
| 5 | +import android.graphics.drawable.BitmapDrawable; | |
| 6 | +import android.os.Bundle; | |
| 7 | +import android.support.annotation.Nullable; | |
| 8 | +import android.support.v4.app.Fragment; | |
| 9 | +import android.support.v7.widget.LinearLayoutManager; | |
| 10 | +import android.text.TextUtils; | |
| 11 | +import android.view.Gravity; | |
| 12 | +import android.view.KeyEvent; | |
| 13 | +import android.view.LayoutInflater; | |
| 14 | +import android.view.MotionEvent; | |
| 15 | +import android.view.View; | |
| 16 | +import android.view.ViewGroup; | |
| 17 | +import android.view.WindowManager; | |
| 18 | +import android.view.inputmethod.InputMethodManager; | |
| 19 | +import android.widget.EditText; | |
| 20 | +import android.widget.LinearLayout; | |
| 21 | +import android.widget.PopupWindow; | |
| 22 | + | |
| 23 | +import com.cnlive.gundam.R; | |
| 24 | +import com.cnlive.gundam.databinding.FragmentVodDetialBinding; | |
| 25 | +import com.cnlive.gundam.main.model.CommentTitleViewModel; | |
| 26 | +import com.cnlive.gundam.main.model.CommentViewModel; | |
| 27 | +import com.cnlive.gundam.main.model.VodDetailModel; | |
| 28 | +import com.cnlive.gundam.main.presenter.VodDetailPresenter; | |
| 29 | +import com.cnlive.gundam.main.presenter.view.VodDetialView; | |
| 30 | +import com.cnlive.gundam.main.ui.adapter.mul.BaseMulTypeBindingAdapter; | |
| 31 | +import com.cnlive.gundam.main.ui.widget.SwipeRecyclerView; | |
| 32 | +import com.cnlive.gundam.user.auth.UserService; | |
| 33 | +import com.cnlive.gundam.user.model.User; | |
| 34 | +import com.cnlive.gundam.user.util.InputUtil; | |
| 35 | +import com.cnlive.gundam.video.fragment.chat.CommentFragment; | |
| 36 | +import com.cnlive.gundam.video.utils.ToastUtil; | |
| 37 | +import com.cnlive.libs.util.comment.CommentUtil; | |
| 38 | + | |
| 39 | +import java.util.ArrayList; | |
| 40 | +import java.util.List; | |
| 41 | +import java.util.Random; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * 创建:wukuiqing | |
| 45 | + * <p> | |
| 46 | + * 时间:2017/7/12 | |
| 47 | + * <p> | |
| 48 | + * 描述: 评论界面 | |
| 49 | + */ | |
| 50 | + | |
| 51 | +public class CommentDetailsFragment extends Fragment implements VodDetialView { | |
| 52 | + | |
| 53 | + private boolean loadMoreEnable = true; | |
| 54 | + FragmentVodDetialBinding binding; | |
| 55 | + private View inflate; | |
| 56 | + private InputUtil inputUtil; | |
| 57 | + private UserService userService; | |
| 58 | + | |
| 59 | + private CommentUtil commentUtil = new CommentUtil(); | |
| 60 | + | |
| 61 | + | |
| 62 | + BaseMulTypeBindingAdapter adapter; | |
| 63 | + List mDatas = new ArrayList(); | |
| 64 | + | |
| 65 | + private String programID; | |
| 66 | + private String mContentId; | |
| 67 | + private String userID; | |
| 68 | + User user; | |
| 69 | + int uid; | |
| 70 | + VodDetailPresenter presenter = new VodDetailPresenter(this); | |
| 71 | + | |
| 72 | + public static CommentDetailsFragment newInstance(String programID) { | |
| 73 | + | |
| 74 | + Bundle args = new Bundle(); | |
| 75 | + CommentDetailsFragment fragment = new CommentDetailsFragment(); | |
| 76 | + args.putString("programID", programID); | |
| 77 | + fragment.setArguments(args); | |
| 78 | + return fragment; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| 82 | + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_vod_detial, container, false); | |
| 83 | + | |
| 84 | + userService = UserService.getInstance(getActivity()); | |
| 85 | + if (presenter == null) { | |
| 86 | + presenter = new VodDetailPresenter(this); | |
| 87 | + } | |
| 88 | + //绑定view | |
| 89 | + | |
| 90 | + return binding.getRoot(); | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 96 | + super.onViewCreated(view, savedInstanceState); | |
| 97 | + | |
| 98 | + uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid(); | |
| 99 | + if (uid != 0) { | |
| 100 | + userID = String.valueOf(uid); | |
| 101 | + } else { | |
| 102 | + userID = String.valueOf(new Random().nextInt(99) + 1); | |
| 103 | + } | |
| 104 | + | |
| 105 | + programID = getArguments().getString("programID"); | |
| 106 | + mContentId = programID; | |
| 107 | + binding.srvVodDetail.getSwipeRefreshLayout() | |
| 108 | + .setColorSchemeColors(getResources().getColor(R.color.colorPrimary)); | |
| 109 | + binding.llComment.setOnClickListener(new View.OnClickListener() { | |
| 110 | + @Override | |
| 111 | + public void onClick(View v) { | |
| 112 | + //弹出输入框 | |
| 113 | + if (TextUtils.isEmpty(userService.getActiveAccountInfo().getUid() + "")) { | |
| 114 | + ToastUtil.showToast("请先登录"); | |
| 115 | + return; | |
| 116 | + } | |
| 117 | + | |
| 118 | + showInput(binding.llVodDetail); | |
| 119 | + } | |
| 120 | + }); | |
| 121 | + | |
| 122 | + presenter.getData(); | |
| 123 | + | |
| 124 | + } | |
| 125 | + | |
| 126 | + | |
| 127 | + private int page = 1; | |
| 128 | + private boolean isLoad = false; | |
| 129 | + | |
| 130 | + private EditText mMsgEditText; | |
| 131 | + private PopupWindow mInputPopupWindow; | |
| 132 | + | |
| 133 | + private void showInput(View view) { | |
| 134 | + // 加载popupWindow的布局 | |
| 135 | + View contentView = LayoutInflater.from(getActivity()).inflate(R.layout.layout_chat_input, new LinearLayout(getActivity()), false); | |
| 136 | + contentView.findViewById(R.id.click_view).setOnClickListener(new View.OnClickListener() { | |
| 137 | + @Override | |
| 138 | + public void onClick(View v) { | |
| 139 | + mMsgEditText.setText(""); | |
| 140 | + mInputPopupWindow.dismiss(); | |
| 141 | + } | |
| 142 | + }); | |
| 143 | + mMsgEditText = (EditText) contentView.findViewById(R.id.chat_content); | |
| 144 | + mMsgEditText.setOnKeyListener(new View.OnKeyListener() { | |
| 145 | + @Override | |
| 146 | + public boolean onKey(View v, int keyCode, KeyEvent event) { | |
| 147 | + if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) { | |
| 148 | + InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); | |
| 149 | + if (inputMethodManager.isActive()) { | |
| 150 | + inputMethodManager.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0); | |
| 151 | + } | |
| 152 | + sendMessage(mMsgEditText.getText().toString()); | |
| 153 | + mMsgEditText.setText(""); | |
| 154 | + mInputPopupWindow.dismiss(); | |
| 155 | + return true; | |
| 156 | + } | |
| 157 | + return false; | |
| 158 | + } | |
| 159 | + }); | |
| 160 | + | |
| 161 | + if (mInputPopupWindow != null) mInputPopupWindow.dismiss(); | |
| 162 | + | |
| 163 | + mInputPopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); | |
| 164 | + mInputPopupWindow.setTouchable(true); | |
| 165 | + mInputPopupWindow.setTouchInterceptor(new View.OnTouchListener() { | |
| 166 | + @Override | |
| 167 | + public boolean onTouch(View v, MotionEvent event) { | |
| 168 | + if (event.getAction() == MotionEvent.ACTION_OUTSIDE) | |
| 169 | + mInputPopupWindow.dismiss(); | |
| 170 | + return false; | |
| 171 | + } | |
| 172 | + }); | |
| 173 | + // 设置popupWindow 点击popupWindow外的地方 生效 | |
| 174 | + mInputPopupWindow.setOutsideTouchable(true); | |
| 175 | + // 设置popupWindow 背景 | |
| 176 | + mInputPopupWindow.setBackgroundDrawable(new BitmapDrawable()); | |
| 177 | + mInputPopupWindow.setFocusable(true); //设置获取焦点 | |
| 178 | + mInputPopupWindow.setAnimationStyle(R.style.animation); | |
| 179 | + mInputPopupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED); | |
| 180 | + mInputPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); | |
| 181 | + mInputPopupWindow.showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); | |
| 182 | + mInputPopupWindow.update(); | |
| 183 | + | |
| 184 | + mMsgEditText.requestFocus(); | |
| 185 | + mInputPopupWindow.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED); | |
| 186 | + mInputPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); | |
| 187 | + InputMethodManager imm = (InputMethodManager) getActivity().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); | |
| 188 | + imm.toggleSoftInput(1000, InputMethodManager.HIDE_NOT_ALWAYS); | |
| 189 | + } | |
| 190 | + | |
| 191 | + private void sendMessage(final String message) { | |
| 192 | + | |
| 193 | + String s1 = userService.getActiveAccountInfo().getUid() + ""; | |
| 194 | + //TODO 添加评论 | |
| 195 | + presenter.addCommment(mContentId, s1, message); | |
| 196 | + } | |
| 197 | + | |
| 198 | + @Override | |
| 199 | + public void onLoadDataComplete(VodDetailModel model, List datas) { | |
| 200 | + mDatas = datas; | |
| 201 | + adapter = new BaseMulTypeBindingAdapter(getActivity(), mDatas); | |
| 202 | + adapter.setItemPresenter(new OnBindItemClick()); | |
| 203 | + | |
| 204 | + binding.srvVodDetail.getRecyclerView().setLayoutManager(new LinearLayoutManager(getActivity())); | |
| 205 | + binding.srvVodDetail.setAdapter(adapter); | |
| 206 | + binding.srvVodDetail.setOnLoadListener(new SwipeRecyclerView.OnLoadListener() { | |
| 207 | + @Override | |
| 208 | + public void onRefresh() { | |
| 209 | + presenter.getComment(false, mContentId, page); | |
| 210 | + } | |
| 211 | + | |
| 212 | + @Override | |
| 213 | + public void onLoadMore() { | |
| 214 | + isLoad = true; | |
| 215 | + if (page != 1 && loadMoreEnable) | |
| 216 | + presenter.getComment(false, mContentId, page); | |
| 217 | + } | |
| 218 | + | |
| 219 | + }); | |
| 220 | + binding.srvVodDetail.setRefreshEnable(true); | |
| 221 | + binding.srvVodDetail.setStickyListener(new SwipeRecyclerView.StickyListener() { | |
| 222 | + @Override | |
| 223 | + public void onSticky(boolean isVisible) { | |
| 224 | + if (isVisible) { | |
| 225 | + binding.llComment.setVisibility(View.VISIBLE); | |
| 226 | + } else { | |
| 227 | + binding.llComment.setVisibility(View.GONE); | |
| 228 | + } | |
| 229 | + } | |
| 230 | + }); | |
| 231 | + presenter.getComment(false, mContentId, page); | |
| 232 | + } | |
| 233 | + | |
| 234 | + @Override | |
| 235 | + public void onLoadCommentComplete(List mDatas, boolean isScroll) { | |
| 236 | + CommentTitleViewModel commentTitleViewModel = (CommentTitleViewModel) this.mDatas.get(0); | |
| 237 | + binding.commentTitleTvNums.setText(commentTitleViewModel.getCount() + ""); | |
| 238 | + if (isLoad) { | |
| 239 | + binding.srvVodDetail.stopLoadingMore(); | |
| 240 | + isLoad = false; | |
| 241 | + } else { | |
| 242 | + binding.srvVodDetail.complete(); | |
| 243 | + | |
| 244 | + } | |
| 245 | + if (mDatas == null) { | |
| 246 | + binding.srvVodDetail.onNoMore("快来抢沙发喽~"); | |
| 247 | + loadMoreEnable = false; | |
| 248 | + } else if (isScroll) { | |
| 249 | + adapter.add(1, mDatas.get(0)); | |
| 250 | + binding.srvVodDetail.getRecyclerView().scrollToPosition(1); | |
| 251 | + } else { | |
| 252 | + adapter.addDatas(mDatas); | |
| 253 | + if (mDatas.size() < 2) { | |
| 254 | + binding.srvVodDetail.onNoMore("暂无更多评论~"); | |
| 255 | + loadMoreEnable = false; | |
| 256 | + } | |
| 257 | + page++; | |
| 258 | + | |
| 259 | + } | |
| 260 | + } | |
| 261 | + | |
| 262 | + | |
| 263 | + public class OnBindItemClick { | |
| 264 | + | |
| 265 | + public void onPraiseClick(final CommentViewModel commentViewModel) { | |
| 266 | + if (true) {//判断登录 | |
| 267 | + //TODO 点赞评论 | |
| 268 | + String uid = String.valueOf(userService.getActiveAccountInfo().getUid()); | |
| 269 | + presenter.toPraise(commentViewModel, mContentId, uid); | |
| 270 | + | |
| 271 | + } else { | |
| 272 | + ToastUtil.showToast("请登录"); | |
| 273 | + } | |
| 274 | + } | |
| 275 | + | |
| 276 | + public void onCommentClick() { | |
| 277 | + //弹出输入框 | |
| 278 | + if (TextUtils.isEmpty(userService.getActiveAccountInfo().getUid() + "")) { | |
| 279 | + ToastUtil.showToast("请先登录"); | |
| 280 | + return; | |
| 281 | + } | |
| 282 | + | |
| 283 | + showInput(binding.llVodDetail); | |
| 284 | + } | |
| 285 | + } | |
| 286 | + | |
| 287 | + | |
| 288 | +} | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerVodFragment.java
| ... | ... | @@ -47,7 +47,7 @@ public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSe |
| 47 | 47 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 48 | 48 | binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_vod, container, false); |
| 49 | 49 | VideoListProgram program = (VideoListProgram) getArguments().getSerializable("program"); |
| 50 | - getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, CommentFragment.newInstance(program.getvId()+""), "commentFragment").commit(); | |
| 50 | + getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, CommentDetailsFragment.newInstance(program.getvId()+""), "commentFragment").commit(); | |
| 51 | 51 | return binding.getRoot(); |
| 52 | 52 | } |
| 53 | 53 | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/CommentFragment.java
| ... | ... | @@ -14,6 +14,7 @@ import android.widget.Toast; |
| 14 | 14 | |
| 15 | 15 | import com.cnlive.gundam.R; |
| 16 | 16 | import com.cnlive.gundam.user.auth.UserService; |
| 17 | +import com.cnlive.gundam.user.model.User; | |
| 17 | 18 | import com.cnlive.gundam.user.util.InputUtil; |
| 18 | 19 | import com.cnlive.gundam.video.adpter.CommentAdapter; |
| 19 | 20 | import com.cnlive.libs.util.chat.model.ErrorMessage; |
| ... | ... | @@ -33,7 +34,7 @@ import java.util.Random; |
| 33 | 34 | * @time 2017/6/29 19:44 |
| 34 | 35 | * @desc ${TODD} |
| 35 | 36 | */ |
| 36 | -public class CommentFragment extends Fragment implements View.OnClickListener, CommentAdapter.OnImageViewClick ,InputUtil.SendCommentCallBack{ | |
| 37 | +public class CommentFragment extends Fragment implements View.OnClickListener, CommentAdapter.OnImageViewClick, InputUtil.SendCommentCallBack { | |
| 37 | 38 | |
| 38 | 39 | |
| 39 | 40 | private View inflate; |
| ... | ... | @@ -43,7 +44,7 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 43 | 44 | |
| 44 | 45 | Bundle args = new Bundle(); |
| 45 | 46 | CommentFragment fragment = new CommentFragment(); |
| 46 | - args.putString("programID",programID); | |
| 47 | + args.putString("programID", programID); | |
| 47 | 48 | fragment.setArguments(args); |
| 48 | 49 | return fragment; |
| 49 | 50 | } |
| ... | ... | @@ -53,8 +54,9 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 53 | 54 | private CommentUtil commentUtil; |
| 54 | 55 | private CommentAdapter commentAdapter; |
| 55 | 56 | private RecyclerView recyclerView; |
| 56 | - private String programID ; | |
| 57 | + private String programID; | |
| 57 | 58 | private String userID; |
| 59 | + User user; | |
| 58 | 60 | |
| 59 | 61 | @Nullable |
| 60 | 62 | @Override |
| ... | ... | @@ -71,21 +73,26 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 71 | 73 | initUI(); |
| 72 | 74 | } |
| 73 | 75 | |
| 76 | + int uid; | |
| 77 | + | |
| 74 | 78 | private void initDate() { |
| 79 | + user = UserService.getInstance(getActivity()).getActiveAccountInfo(); | |
| 75 | 80 | inputUtil = new InputUtil(getActivity()); |
| 76 | 81 | inputUtil.setonSendCommentCallBack(this); |
| 77 | - int uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid(); | |
| 78 | - if(uid!=0){ | |
| 79 | - userID=String.valueOf(uid); | |
| 80 | - }else { | |
| 81 | - userID=String.valueOf(new Random().nextInt(100));} | |
| 82 | + uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid(); | |
| 83 | + if (uid != 0) { | |
| 84 | + userID = String.valueOf(uid); | |
| 85 | + } else { | |
| 86 | + userID = String.valueOf(new Random().nextInt(99) + 1); | |
| 87 | + } | |
| 88 | + | |
| 82 | 89 | |
| 83 | 90 | } |
| 84 | 91 | |
| 85 | 92 | |
| 86 | 93 | private void initUI() { |
| 87 | 94 | |
| 88 | - programID= getArguments().getString("programID"); | |
| 95 | + programID = getArguments().getString("programID"); | |
| 89 | 96 | commentAdapter = new CommentAdapter(getActivity()); |
| 90 | 97 | recyclerView = (RecyclerView) getActivity().findViewById(R.id.comment_content); |
| 91 | 98 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); |
| ... | ... | @@ -109,7 +116,7 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 109 | 116 | @Override |
| 110 | 117 | public void onClick(View v) { |
| 111 | 118 | switch (v.getId()) { |
| 112 | - case R.id.input : | |
| 119 | + case R.id.input: | |
| 113 | 120 | inputUtil.showInput(v); |
| 114 | 121 | break; |
| 115 | 122 | } |
| ... | ... | @@ -117,6 +124,8 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 117 | 124 | |
| 118 | 125 | } |
| 119 | 126 | |
| 127 | + //评论的数据 | |
| 128 | + List<CommentItem> comments; | |
| 120 | 129 | |
| 121 | 130 | public void getCommentMesaage() { |
| 122 | 131 | commentUtil.readAllComment(programID, 1, 10, new CommentListCallback() { |
| ... | ... | @@ -124,12 +133,10 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 124 | 133 | public void onResponse(CommentPage commentPage) { |
| 125 | 134 | if (commentPage.getData() != null) { |
| 126 | 135 | Log.v("commentPage", commentPage.getErrorMessage() + ""); |
| 127 | - List<CommentItem> comments = commentPage.getData().getComments(); | |
| 128 | - if(comments==null)return; | |
| 136 | + comments = commentPage.getData().getComments(); | |
| 129 | 137 | recyclerView.setAdapter(commentAdapter); |
| 138 | + if (comments == null) return; | |
| 130 | 139 | commentAdapter.addItems(comments); |
| 131 | - | |
| 132 | - | |
| 133 | 140 | } |
| 134 | 141 | } |
| 135 | 142 | }); |
| ... | ... | @@ -147,13 +154,21 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 147 | 154 | |
| 148 | 155 | @Override |
| 149 | 156 | public void praiseComment(CommentItem commentItem) { |
| 157 | + | |
| 150 | 158 | commentUtil.praiseComment(programID, userID, commentItem.getId(), new CommentCallback() { |
| 151 | 159 | @Override |
| 152 | 160 | public void onResponse(ErrorMessage errorMessage) { |
| 153 | 161 | if (errorMessage != null && errorMessage.getErrorCode().equals("0")) { |
| 154 | 162 | Toast.makeText(getActivity(), "点赞成功", Toast.LENGTH_SHORT).show(); |
| 155 | - commentAdapter.clearItems(); | |
| 156 | - getCommentMesaage(); | |
| 163 | + | |
| 164 | +// String intPrise= commentItem.getPraise(); | |
| 165 | +// int prise= Integer.parseInt(intPrise)+1; | |
| 166 | +// commentItem.setPraise(prise+""); | |
| 167 | +// commentAdapter.notifyDataSetChanged(); | |
| 168 | + | |
| 169 | +// commentAdapter.clearItems(); | |
| 170 | +// getCommentMesaage(); | |
| 171 | + | |
| 157 | 172 | } else Toast.makeText(getActivity(), "点赞失败", Toast.LENGTH_SHORT).show(); |
| 158 | 173 | |
| 159 | 174 | } |
| ... | ... | @@ -162,7 +177,8 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 162 | 177 | |
| 163 | 178 | |
| 164 | 179 | @Override |
| 165 | - public void sendComment(String s) { | |
| 180 | + public void sendComment(final String s) { | |
| 181 | + | |
| 166 | 182 | commentUtil.insertComment(programID, userID, s, new CommentCallback() { |
| 167 | 183 | @Override |
| 168 | 184 | public void onResponse(ErrorMessage errorMessage) { |
| ... | ... | @@ -170,11 +186,29 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C |
| 170 | 186 | |
| 171 | 187 | Toast.makeText(getActivity(), "评论成功", Toast.LENGTH_SHORT).show(); |
| 172 | 188 | edit_comment.setText("我来说两句....."); |
| 173 | - commentAdapter.clearItems(); | |
| 174 | - getCommentMesaage(); | |
| 189 | + CommentItem addItem = new CommentItem(); | |
| 190 | + if (user.getUid() == 0) { | |
| 191 | + //表示游客模式 | |
| 192 | + addItem.setContent(s); | |
| 193 | + addItem.setId(userID); | |
| 194 | + addItem.setPraise("0"); | |
| 195 | + addItem.setFacepath("https://yweb0.cnliveimg.com/main/cnlive/150819151803915_969.jpg"); | |
| 196 | + addItem.setUid(userID + ""); | |
| 197 | + | |
| 198 | + } else { | |
| 199 | + addItem.setContent(s); | |
| 200 | + addItem.setPraise("0"); | |
| 201 | + addItem.setFacepath(user.getFaceurl()); | |
| 202 | + addItem.setUid(user.getUid() + ""); | |
| 203 | + | |
| 204 | + } | |
| 205 | + commentAdapter.addItem(addItem); | |
| 206 | + | |
| 175 | 207 | } else Toast.makeText(getActivity(), "评论失败", Toast.LENGTH_SHORT).show(); |
| 176 | 208 | |
| 177 | 209 | } |
| 178 | 210 | }); |
| 179 | 211 | } |
| 212 | + | |
| 213 | + | |
| 180 | 214 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/video/utils/ToastUtil.java
0 → 100644
| 1 | +package com.cnlive.gundam.video.utils; | |
| 2 | + | |
| 3 | +import android.view.Gravity; | |
| 4 | +import android.widget.Toast; | |
| 5 | + | |
| 6 | + | |
| 7 | +import com.cnlive.gundam.application.CNLiveApplication; | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | +public class ToastUtil { | |
| 13 | + private static long back_pressed; | |
| 14 | + private static String show_msg = ""; | |
| 15 | + | |
| 16 | + public static void showToast(String str, int duration) { | |
| 17 | + if (str.equals("")) return; | |
| 18 | + if (back_pressed + 2000 < System.currentTimeMillis() || !show_msg.equals(str)) { | |
| 19 | + show_msg = str; | |
| 20 | + | |
| 21 | + Toast toast = Toast.makeText(CNLiveApplication.getContext(), str, duration); | |
| 22 | + | |
| 23 | + toast.setGravity(Gravity.CENTER, 0, 0); | |
| 24 | + toast.show(); | |
| 25 | + } | |
| 26 | + back_pressed = System.currentTimeMillis(); | |
| 27 | + } | |
| 28 | + | |
| 29 | + | |
| 30 | + public static void showToast(String str) { | |
| 31 | + showToast(str, Toast.LENGTH_SHORT); | |
| 32 | + } | |
| 33 | +} | ... | ... |
app/src/main/res/drawable-xhdpi/icon_default_portrait_87.png
0 → 100644
1.78 KB
app/src/main/res/drawable-xhdpi/icon_praise_selected.png
0 → 100644
602 Bytes
app/src/main/res/drawable/circle_corner_gray.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + android:shape="rectangle"> | |
| 4 | + <corners android:radius="10px" /> | |
| 5 | + <solid android:color="#f7f7f7" /> | |
| 6 | + <stroke | |
| 7 | + android:width="0.3dp" | |
| 8 | + android:color="#aaa" /> | |
| 9 | + <size | |
| 10 | + android:width="29dp" | |
| 11 | + android:height="34dp" /> | |
| 12 | + | |
| 13 | +</shape> | |
| 0 | 14 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/fragment_vod_detial.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | +<RelativeLayout | |
| 4 | + android:id="@+id/ll_vod_detail" | |
| 5 | + android:orientation="vertical" android:layout_width="match_parent" | |
| 6 | + android:layout_height="match_parent"> | |
| 7 | + | |
| 8 | + <com.cnlive.gundam.main.ui.widget.SwipeRecyclerView | |
| 9 | + android:layout_width="match_parent" | |
| 10 | + android:layout_height="match_parent" | |
| 11 | + android:id="@+id/srv_vod_detail" /> | |
| 12 | + <LinearLayout | |
| 13 | + android:visibility="gone" | |
| 14 | + android:background="@color/white" | |
| 15 | + android:id="@+id/ll_comment" | |
| 16 | + android:layout_width="match_parent" | |
| 17 | + android:layout_height="wrap_content" | |
| 18 | + android:orientation="vertical"> | |
| 19 | + | |
| 20 | + <RelativeLayout | |
| 21 | + android:layout_width="match_parent" | |
| 22 | + android:layout_height="48dp"> | |
| 23 | + | |
| 24 | + <TextView | |
| 25 | + android:id="@+id/comment_title_tv" | |
| 26 | + android:layout_width="wrap_content" | |
| 27 | + android:layout_height="wrap_content" | |
| 28 | + android:layout_centerVertical="true" | |
| 29 | + android:layout_marginLeft="10dp" | |
| 30 | + android:layout_marginRight="12dp" | |
| 31 | + android:text="评论" | |
| 32 | + android:textSize="14sp" /> | |
| 33 | + | |
| 34 | + <TextView | |
| 35 | + android:id="@+id/comment_title_tv_nums" | |
| 36 | + android:layout_width="wrap_content" | |
| 37 | + android:layout_height="wrap_content" | |
| 38 | + android:layout_alignBottom="@id/comment_title_tv" | |
| 39 | + android:layout_toRightOf="@id/comment_title_tv" | |
| 40 | + android:textSize="10sp" | |
| 41 | + /> | |
| 42 | + | |
| 43 | + </RelativeLayout> | |
| 44 | + | |
| 45 | + <View | |
| 46 | + android:layout_width="match_parent" | |
| 47 | + android:layout_height="1dp" | |
| 48 | + android:background="@color/color_cutline_ececec" /> | |
| 49 | + | |
| 50 | + <LinearLayout | |
| 51 | + android:layout_width="match_parent" | |
| 52 | + android:layout_height="63dp" | |
| 53 | + android:gravity="center_vertical" | |
| 54 | + android:orientation="horizontal" | |
| 55 | + android:paddingLeft="15dp"> | |
| 56 | + | |
| 57 | + <ImageView | |
| 58 | + android:id="@+id/comment_title_img_head" | |
| 59 | + android:layout_width="29dp" | |
| 60 | + android:layout_height="29dp" | |
| 61 | + android:layout_marginRight="16dp" | |
| 62 | + /> | |
| 63 | + | |
| 64 | + <RelativeLayout | |
| 65 | + | |
| 66 | + android:id="@+id/comment_title_layout_comment" | |
| 67 | + android:layout_width="290dp" | |
| 68 | + android:layout_height="wrap_content" | |
| 69 | + android:background="@drawable/circle_corner_gray" | |
| 70 | + android:orientation="horizontal" | |
| 71 | + android:paddingRight="10dp"> | |
| 72 | + | |
| 73 | + <TextView | |
| 74 | + android:id="@+id/comment_title_tv_textlimit" | |
| 75 | + android:layout_width="wrap_content" | |
| 76 | + android:layout_height="wrap_content" | |
| 77 | + android:layout_alignParentRight="true" | |
| 78 | + android:layout_centerVertical="true" | |
| 79 | + android:gravity="center_vertical" | |
| 80 | + android:textColor="@color/color_text_normal_999" | |
| 81 | + android:textSize="11sp" /> | |
| 82 | + | |
| 83 | + <TextView | |
| 84 | + android:id="@+id/comment_title_et" | |
| 85 | + android:layout_width="match_parent" | |
| 86 | + android:layout_height="wrap_content" | |
| 87 | + android:layout_centerVertical="true" | |
| 88 | + android:layout_toLeftOf="@id/comment_title_tv_textlimit" | |
| 89 | + android:background="@null" | |
| 90 | + android:gravity="center_vertical" | |
| 91 | + android:hint="我要评论~" | |
| 92 | + android:includeFontPadding="false" | |
| 93 | + android:paddingLeft="15dp" | |
| 94 | + android:textColor="#a1a1a1" | |
| 95 | + android:textSize="13sp" /> | |
| 96 | + | |
| 97 | + </RelativeLayout> | |
| 98 | + | |
| 99 | + | |
| 100 | + </LinearLayout> | |
| 101 | + | |
| 102 | + | |
| 103 | + </LinearLayout> | |
| 104 | +</RelativeLayout> | |
| 105 | +</layout> | |
| 0 | 106 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/item.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + | |
| 4 | + <data> | |
| 5 | + | |
| 6 | + <!--数据--> | |
| 7 | + <variable | |
| 8 | + name="data" | |
| 9 | + type="java.lang.Class"/> | |
| 10 | + <!--事件处理,例如点击事件--> | |
| 11 | + <variable | |
| 12 | + name="itemP" | |
| 13 | + type="java.lang.Class"/> | |
| 14 | + </data> | |
| 15 | + | |
| 16 | + <View | |
| 17 | + android:layout_width="match_parent" | |
| 18 | + android:layout_height="match_parent"/> | |
| 19 | +</layout> | |
| 20 | + | ... | ... |
app/src/main/res/layout/item_comment.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?><!--评论回复 item布局--> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | |
| 4 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | |
| 5 | + <data> | |
| 6 | + <variable | |
| 7 | + name="data" | |
| 8 | + type="com.cnlive.gundam.main.model.CommentViewModel"></variable> | |
| 9 | + <variable | |
| 10 | + name="itemP" | |
| 11 | + type="com.cnlive.gundam.video.fragment.CommentDetailsFragment.OnBindItemClick"/> | |
| 12 | + </data> | |
| 13 | +<LinearLayout | |
| 14 | + android:layout_width="match_parent" | |
| 15 | + android:layout_height="wrap_content" | |
| 16 | + android:orientation="vertical" | |
| 17 | + android:paddingBottom="18dp" | |
| 18 | + android:paddingTop="10dp"> | |
| 19 | + | |
| 20 | + <RelativeLayout | |
| 21 | + android:layout_width="match_parent" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:gravity="center_vertical" | |
| 24 | + android:paddingBottom="5dp" | |
| 25 | + android:paddingTop="5dp"> | |
| 26 | + | |
| 27 | + <ImageView | |
| 28 | + android:id="@+id/comment_item_img" | |
| 29 | + android:layout_width="29dp" | |
| 30 | + android:layout_height="29dp" | |
| 31 | + android:layout_marginLeft="15dp" | |
| 32 | + android:layout_marginRight="10dp" | |
| 33 | + app:circleUrl="@{data.userHead}" | |
| 34 | + tools:src="@drawable/icon_default_portrait_87" /> | |
| 35 | + | |
| 36 | + <LinearLayout | |
| 37 | + android:layout_width="wrap_content" | |
| 38 | + android:layout_height="wrap_content" | |
| 39 | + android:layout_alignBottom="@id/comment_item_img" | |
| 40 | + android:layout_alignTop="@id/comment_item_img" | |
| 41 | + android:layout_toRightOf="@id/comment_item_img" | |
| 42 | + android:gravity="center_vertical" | |
| 43 | + android:orientation="vertical"> | |
| 44 | + | |
| 45 | + <TextView | |
| 46 | + android:id="@+id/comment_item_tv_name" | |
| 47 | + android:layout_width="wrap_content" | |
| 48 | + android:layout_height="wrap_content" | |
| 49 | + android:textColor="#666" | |
| 50 | + android:textSize="11sp" | |
| 51 | + android:text="@{data.id}" /> | |
| 52 | + | |
| 53 | + <TextView | |
| 54 | + android:id="@+id/comment_item_tv_time" | |
| 55 | + android:layout_width="wrap_content" | |
| 56 | + android:layout_height="wrap_content" | |
| 57 | + android:textColor="#b6b6b6" | |
| 58 | + android:textSize="8sp" | |
| 59 | + android:text="@{data.time}" | |
| 60 | + tools:text="2017-3-5 15:46" /> | |
| 61 | + | |
| 62 | + </LinearLayout> | |
| 63 | + | |
| 64 | + <LinearLayout | |
| 65 | + android:clickable="@{data.isClickAble}" | |
| 66 | + | |
| 67 | + | |
| 68 | + android:onClick="@{v->itemP.onPraiseClick(data)}" | |
| 69 | + android:id="@+id/comment_item_layout_praise" | |
| 70 | + android:layout_width="wrap_content" | |
| 71 | + android:layout_height="wrap_content" | |
| 72 | + android:layout_alignBottom="@id/comment_item_img" | |
| 73 | + android:layout_alignTop="@id/comment_item_img" | |
| 74 | + android:layout_marginRight="9dp" | |
| 75 | + android:layout_alignParentRight="true" | |
| 76 | + android:gravity="center_vertical" | |
| 77 | + android:orientation="horizontal"> | |
| 78 | + | |
| 79 | + <ImageView | |
| 80 | + android:id="@+id/comment_item_img_praise" | |
| 81 | + android:layout_width="wrap_content" | |
| 82 | + android:layout_height="wrap_content" | |
| 83 | + android:layout_marginRight="3dp" | |
| 84 | + app:backgroundUrl="@{data.praiseImage}" | |
| 85 | + android:src="@drawable/vod_detail_good"/> | |
| 86 | + | |
| 87 | + <TextView | |
| 88 | + android:id="@+id/comment_item_tv_praisenum" | |
| 89 | + android:layout_width="wrap_content" | |
| 90 | + android:layout_height="wrap_content" | |
| 91 | + android:textColor="#c2c9cc" | |
| 92 | + android:textSize="9sp" | |
| 93 | + android:text="@{data.praise}" | |
| 94 | + tools:text="124" /> | |
| 95 | + | |
| 96 | + </LinearLayout> | |
| 97 | + | |
| 98 | + </RelativeLayout> | |
| 99 | + | |
| 100 | + <TextView | |
| 101 | + android:id="@+id/comment_item_tv_content" | |
| 102 | + android:layout_width="match_parent" | |
| 103 | + android:layout_height="wrap_content" | |
| 104 | + android:layout_marginBottom="14dp" | |
| 105 | + android:layout_marginLeft="54dp" | |
| 106 | + android:gravity="left" | |
| 107 | + android:textColor="#333333" | |
| 108 | + android:textSize="13sp" | |
| 109 | + android:text="@{data.commentContent}" | |
| 110 | + tools:text="明月几时有,把酒问青天。不知天上宫阙,今夕是何年?我欲乘风鬼区,又恐琼楼玉宇,高处不胜寒。" /> | |
| 111 | + | |
| 112 | + <View | |
| 113 | + android:layout_width="match_parent" | |
| 114 | + android:layout_height="1px" | |
| 115 | + android:background="@color/color_9d9d9d"/> | |
| 116 | +</LinearLayout> | |
| 117 | +</layout> | |
| 0 | 118 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/item_comment_title.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + > | |
| 4 | + <data> | |
| 5 | + <variable | |
| 6 | + name="data" | |
| 7 | + type="com.cnlive.gundam.main.model.CommentTitleViewModel"></variable> | |
| 8 | + <variable | |
| 9 | + name="itemP" | |
| 10 | + type="com.cnlive.gundam.video.fragment.CommentDetailsFragment.OnBindItemClick"/> | |
| 11 | + </data> | |
| 12 | +<LinearLayout | |
| 13 | + android:background="@color/white" | |
| 14 | + android:layout_width="match_parent" | |
| 15 | + android:layout_height="wrap_content" | |
| 16 | + android:orientation="vertical"> | |
| 17 | + | |
| 18 | + <RelativeLayout | |
| 19 | + android:layout_width="match_parent" | |
| 20 | + android:layout_height="48dp"> | |
| 21 | + | |
| 22 | + <TextView | |
| 23 | + android:id="@+id/comment_title_tv" | |
| 24 | + android:layout_width="wrap_content" | |
| 25 | + android:layout_height="wrap_content" | |
| 26 | + android:layout_centerVertical="true" | |
| 27 | + android:layout_marginLeft="10dp" | |
| 28 | + android:layout_marginRight="12dp" | |
| 29 | + android:text="评论" | |
| 30 | + android:textSize="14sp" /> | |
| 31 | + | |
| 32 | + <TextView | |
| 33 | + android:id="@+id/comment_title_tv_nums" | |
| 34 | + android:layout_width="wrap_content" | |
| 35 | + android:layout_height="wrap_content" | |
| 36 | + android:layout_alignBottom="@id/comment_title_tv" | |
| 37 | + android:layout_toRightOf="@id/comment_title_tv" | |
| 38 | + android:textSize="10sp" | |
| 39 | + android:text="@{data.count}" /> | |
| 40 | + | |
| 41 | + </RelativeLayout> | |
| 42 | + | |
| 43 | + <View | |
| 44 | + android:layout_width="match_parent" | |
| 45 | + android:layout_height="1dp" | |
| 46 | + android:background="@color/color_cutline_ececec" /> | |
| 47 | + | |
| 48 | + <LinearLayout | |
| 49 | + android:layout_width="match_parent" | |
| 50 | + android:layout_height="63dp" | |
| 51 | + android:gravity="center_vertical" | |
| 52 | + android:orientation="horizontal" | |
| 53 | + android:paddingLeft="15dp"> | |
| 54 | + | |
| 55 | + <ImageView | |
| 56 | + android:id="@+id/comment_title_img_head" | |
| 57 | + android:layout_width="29dp" | |
| 58 | + android:layout_height="29dp" | |
| 59 | + android:layout_marginRight="16dp" | |
| 60 | + /> | |
| 61 | + | |
| 62 | + <RelativeLayout | |
| 63 | + android:onClick="@{v->itemP.onCommentClick()}" | |
| 64 | + android:id="@+id/comment_title_layout_comment" | |
| 65 | + android:layout_width="290dp" | |
| 66 | + android:layout_height="wrap_content" | |
| 67 | + android:background="@drawable/circle_corner_gray" | |
| 68 | + android:orientation="horizontal" | |
| 69 | + android:paddingRight="10dp"> | |
| 70 | + | |
| 71 | + <TextView | |
| 72 | + android:id="@+id/comment_title_tv_textlimit" | |
| 73 | + android:layout_width="wrap_content" | |
| 74 | + android:layout_height="wrap_content" | |
| 75 | + android:layout_alignParentRight="true" | |
| 76 | + android:layout_centerVertical="true" | |
| 77 | + android:gravity="center_vertical" | |
| 78 | + android:textColor="@color/color_text_normal_999" | |
| 79 | + android:textSize="11sp" /> | |
| 80 | + | |
| 81 | + <TextView | |
| 82 | + android:id="@+id/comment_title_et" | |
| 83 | + android:layout_width="match_parent" | |
| 84 | + android:layout_height="wrap_content" | |
| 85 | + android:layout_centerVertical="true" | |
| 86 | + android:layout_toLeftOf="@id/comment_title_tv_textlimit" | |
| 87 | + android:background="@null" | |
| 88 | + android:gravity="center_vertical" | |
| 89 | + android:hint="我要评论~" | |
| 90 | + android:includeFontPadding="false" | |
| 91 | + android:paddingLeft="15dp" | |
| 92 | + android:textColor="#a1a1a1" | |
| 93 | + android:textSize="13sp" /> | |
| 94 | + | |
| 95 | + </RelativeLayout> | |
| 96 | + | |
| 97 | + | |
| 98 | + </LinearLayout> | |
| 99 | + | |
| 100 | + | |
| 101 | +</LinearLayout> | |
| 102 | +</layout> | |
| 0 | 103 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/item_view_tab.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout | |
| 3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | + android:id="@+id/viewTabView" | |
| 5 | + android:orientation="vertical" | |
| 6 | + android:layout_width="match_parent" | |
| 7 | + android:gravity="center" | |
| 8 | + android:layout_height="match_parent"> | |
| 9 | + | |
| 10 | + <ImageView | |
| 11 | + android:id="@+id/ivIcon" | |
| 12 | + android:layout_width="match_parent" | |
| 13 | + android:layout_height="match_parent" | |
| 14 | + android:layout_marginTop="20dp" | |
| 15 | + android:layout_weight="1" | |
| 16 | + android:scaleType="centerInside" | |
| 17 | + android:src="@mipmap/ic_launcher_round" /> | |
| 18 | + | |
| 19 | + <TextView | |
| 20 | + android:id="@+id/tvTitle" | |
| 21 | + android:layout_weight="2" | |
| 22 | + android:gravity="center" | |
| 23 | + android:textSize="12sp" | |
| 24 | + android:layout_width="match_parent" | |
| 25 | + android:layout_height="match_parent" | |
| 26 | + android:text="首页"/> | |
| 27 | + | |
| 28 | +</LinearLayout> | |
| 0 | 29 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_footer_view.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout | |
| 3 | + android:id="@+id/footer_view" | |
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="60dp" | |
| 7 | + android:gravity="center" | |
| 8 | + > | |
| 9 | + <ProgressBar | |
| 10 | + android:id="@+id/footer_view_progressbar" | |
| 11 | + android:layout_width="30dp" | |
| 12 | + android:layout_height="30dp" | |
| 13 | + /> | |
| 14 | + | |
| 15 | + <TextView | |
| 16 | + android:id="@+id/footer_view_tv" | |
| 17 | + android:layout_width="wrap_content" | |
| 18 | + android:layout_height="wrap_content" | |
| 19 | + android:text="正在加载,请稍后..." | |
| 20 | + | |
| 21 | + /> | |
| 22 | +</LinearLayout> | |
| 0 | 23 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/layout_swipe_recyclerview.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<android.support.v4.widget.SwipeRefreshLayout | |
| 3 | + android:id="@+id/SwipeRefreshLayout" | |
| 4 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | + android:layout_width="match_parent" | |
| 6 | + android:layout_height="match_parent" | |
| 7 | + android:orientation="vertical"> | |
| 8 | + | |
| 9 | + <android.support.v7.widget.RecyclerView | |
| 10 | + android:id="@+id/RecyclerView" | |
| 11 | + android:layout_width="match_parent" | |
| 12 | + android:layout_height="match_parent" | |
| 13 | + android:cacheColorHint="@null" | |
| 14 | + android:scrollbars="none"/> | |
| 15 | + | |
| 16 | +</android.support.v4.widget.SwipeRefreshLayout> | |
| 0 | 17 | \ No newline at end of file | ... | ... |
app/src/main/res/values/colors.xml
| ... | ... | @@ -13,4 +13,8 @@ |
| 13 | 13 | <color name="gray_bg">#dedbdb</color> |
| 14 | 14 | |
| 15 | 15 | <color name="play_status_bg">#03faf6</color> |
| 16 | + <color name="white">#ffffff</color> | |
| 17 | + <color name="color_text_normal_999">#999</color> | |
| 18 | + <color name="color_cutline_ececec">#ececec</color> | |
| 19 | + <color name="color_9d9d9d">#9d9d9d</color> | |
| 16 | 20 | </resources> | ... | ... |