Commit 2767a923a77a96acceb6fa1b3534cb91a94e02bc
解决冲突
Showing
64 changed files
with
3670 additions
and
80 deletions
app/build.gradle
| @@ -86,4 +86,5 @@ dependencies { | @@ -86,4 +86,5 @@ dependencies { | ||
| 86 | compile 'com.squareup.okhttp3:okhttp-ws:3.2.0' | 86 | compile 'com.squareup.okhttp3:okhttp-ws:3.2.0' |
| 87 | compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' | 87 | compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' |
| 88 | compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4' | 88 | compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4' |
| 89 | + | ||
| 89 | } | 90 | } |
app/src/main/java/com/cnlive/gundam/application/CNLiveApplication.java
| 1 | package com.cnlive.gundam.application; | 1 | package com.cnlive.gundam.application; |
| 2 | 2 | ||
| 3 | import android.app.Application; | 3 | import android.app.Application; |
| 4 | +import android.content.Context; | ||
| 4 | 5 | ||
| 5 | import com.cnlive.libs.util.Config; | 6 | import com.cnlive.libs.util.Config; |
| 6 | 7 | ||
| @@ -11,10 +12,15 @@ import com.cnlive.libs.util.Config; | @@ -11,10 +12,15 @@ import com.cnlive.libs.util.Config; | ||
| 11 | public class CNLiveApplication extends Application { | 12 | public class CNLiveApplication extends Application { |
| 12 | 13 | ||
| 13 | public static final String secret = "c2faeb120f0ea2e2d47020d4b03cb8a93bed2585897a94"; | 14 | public static final String secret = "c2faeb120f0ea2e2d47020d4b03cb8a93bed2585897a94"; |
| 15 | + private static Context mContxt; | ||
| 14 | 16 | ||
| 15 | @Override | 17 | @Override |
| 16 | public void onCreate() { | 18 | public void onCreate() { |
| 17 | super.onCreate(); | 19 | super.onCreate(); |
| 20 | + mContxt=getApplicationContext(); | ||
| 18 | Config.init(getApplicationContext(), "60_j4fc7dsm83", "4c8658abc5d66f270f9bf5dcd1ef11e3597fab4c4e0af9", true);//测试信息 | 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/MsgEvent.java
0 → 100644
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 = 10; | ||
| 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/fragment/ConfigFragment.java
| @@ -18,6 +18,7 @@ import com.cnlive.gundam.user.activity.LoginActivity; | @@ -18,6 +18,7 @@ import com.cnlive.gundam.user.activity.LoginActivity; | ||
| 18 | import com.cnlive.gundam.user.activity.UserPersonalActivity; | 18 | import com.cnlive.gundam.user.activity.UserPersonalActivity; |
| 19 | import com.cnlive.gundam.user.auth.UserService; | 19 | import com.cnlive.gundam.user.auth.UserService; |
| 20 | import com.cnlive.gundam.user.model.User; | 20 | import com.cnlive.gundam.user.model.User; |
| 21 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 21 | import com.cnlive.libs.user.IUserService; | 22 | import com.cnlive.libs.user.IUserService; |
| 22 | import com.cnlive.libs.user.UserUtil; | 23 | import com.cnlive.libs.user.UserUtil; |
| 23 | import com.cnlive.libs.user.model.UserData; | 24 | import com.cnlive.libs.user.model.UserData; |
| @@ -29,7 +30,8 @@ import com.cnlive.libs.util.data.network.Callback; | @@ -29,7 +30,8 @@ import com.cnlive.libs.util.data.network.Callback; | ||
| 29 | 30 | ||
| 30 | public class ConfigFragment extends Fragment implements View.OnClickListener { | 31 | public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 31 | private UserFragmentBinding binding; | 32 | private UserFragmentBinding binding; |
| 32 | - private User activeAccountInfo; | 33 | + |
| 34 | + private User user; | ||
| 33 | 35 | ||
| 34 | @Nullable | 36 | @Nullable |
| 35 | @Override | 37 | @Override |
| @@ -89,14 +91,16 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | @@ -89,14 +91,16 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | ||
| 89 | @Override | 91 | @Override |
| 90 | public void onResume() { | 92 | public void onResume() { |
| 91 | super.onResume(); | 93 | super.onResume(); |
| 92 | - notifyUI(UserService.getInstance(getActivity()).getActiveAccountInfo().getUid() != 0); | 94 | + user = UserService.getInstance(getActivity()).getActiveAccountInfo(); |
| 95 | + boolean isLogin = user != null && user.getUid() != 0; | ||
| 96 | + notifyUI(isLogin); | ||
| 97 | + if (!isLogin) return; | ||
| 98 | + updateUserInfo(); | ||
| 93 | } | 99 | } |
| 94 | 100 | ||
| 95 | private void notifyUI(boolean isLogin) { | 101 | private void notifyUI(boolean isLogin) { |
| 96 | if(isLogin){ | 102 | if(isLogin){ |
| 97 | - activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | ||
| 98 | - updateUserInfo(activeAccountInfo); | ||
| 99 | - activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | 103 | + User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); |
| 100 | Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg); | 104 | Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg); |
| 101 | binding.tvNickname.setText(activeAccountInfo.getNickname()); | 105 | binding.tvNickname.setText(activeAccountInfo.getNickname()); |
| 102 | }else{ | 106 | }else{ |
| @@ -105,9 +109,7 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | @@ -105,9 +109,7 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | ||
| 105 | } | 109 | } |
| 106 | } | 110 | } |
| 107 | 111 | ||
| 108 | - | ||
| 109 | - | ||
| 110 | - private void updateUserInfo(User user) { | 112 | + private void updateUserInfo() { |
| 111 | UserUtil.queryUserInfo(String.valueOf(user.getUid()), String.valueOf(user.getUid()), new Callback() { | 113 | UserUtil.queryUserInfo(String.valueOf(user.getUid()), String.valueOf(user.getUid()), new Callback() { |
| 112 | @Override | 114 | @Override |
| 113 | public void onState(int i, String s, Object obj) { | 115 | public void onState(int i, String s, Object obj) { |
| @@ -115,6 +117,12 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | @@ -115,6 +117,12 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | ||
| 115 | UserData userData = (UserData) obj; | 117 | UserData userData = (UserData) obj; |
| 116 | UserService userService = UserService.getInstance(getActivity()); | 118 | UserService userService = UserService.getInstance(getActivity()); |
| 117 | userService.setActiveAccountInfo(userData.getData()); | 119 | userService.setActiveAccountInfo(userData.getData()); |
| 120 | + notifyUI(true); | ||
| 121 | + } else if (i == IUserService.ERROR_TOKEN_INVALID) { | ||
| 122 | + ToastUtil.show(getActivity(), getString(R.string.user_token_invalid)); | ||
| 123 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 124 | + userService.clearUser(); | ||
| 125 | + notifyUI(false); | ||
| 118 | } | 126 | } |
| 119 | } | 127 | } |
| 120 | }); | 128 | }); |
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/GlideCircleTransform.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.graphics.Bitmap; | ||
| 5 | +import android.graphics.BitmapShader; | ||
| 6 | +import android.graphics.Canvas; | ||
| 7 | +import android.graphics.Paint; | ||
| 8 | + | ||
| 9 | +import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; | ||
| 10 | +import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 创建:wukuiqing | ||
| 14 | + * <p> | ||
| 15 | + * 时间:2017/7/13 | ||
| 16 | + * <p> | ||
| 17 | + * 描述: | ||
| 18 | + */ | ||
| 19 | + | ||
| 20 | +//圆形图片 | ||
| 21 | +public class GlideCircleTransform extends BitmapTransformation { | ||
| 22 | + public GlideCircleTransform(Context context) { | ||
| 23 | + super(context); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { | ||
| 27 | + return circleCrop(pool, toTransform); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + private static Bitmap circleCrop(BitmapPool pool, Bitmap source) { | ||
| 31 | + if (source == null) return null; | ||
| 32 | + | ||
| 33 | + int size = Math.min(source.getWidth(), source.getHeight()); | ||
| 34 | + int x = (source.getWidth() - size) / 2; | ||
| 35 | + int y = (source.getHeight() - size) / 2; | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + Bitmap squared = Bitmap.createBitmap(source, x, y, size, size); | ||
| 39 | + | ||
| 40 | + Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888); | ||
| 41 | + if (result == null) { | ||
| 42 | + result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + Canvas canvas = new Canvas(result); | ||
| 46 | + Paint paint = new Paint(); | ||
| 47 | + paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP)); | ||
| 48 | + paint.setAntiAlias(true); | ||
| 49 | + float r = size / 2f; | ||
| 50 | + canvas.drawCircle(r, r, r, paint); | ||
| 51 | + return result; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override public String getId() { | ||
| 55 | + return getClass().getName(); | ||
| 56 | + } | ||
| 57 | +} | ||
| 58 | + |
app/src/main/java/com/cnlive/gundam/main/ui/widget/RecyclerSpace.java
0 → 100644
| 1 | +package com.cnlive.gundam.main.ui.widget; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | + | ||
| 5 | +import android.graphics.Canvas; | ||
| 6 | +import android.graphics.Paint; | ||
| 7 | +import android.graphics.Rect; | ||
| 8 | +import android.graphics.drawable.Drawable; | ||
| 9 | +import android.support.annotation.ColorRes; | ||
| 10 | +import android.support.v7.widget.GridLayoutManager; | ||
| 11 | +import android.support.v7.widget.LinearLayoutManager; | ||
| 12 | +import android.support.v7.widget.RecyclerView; | ||
| 13 | +import android.view.View; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 创建:wukuiqing | ||
| 17 | + * <p> | ||
| 18 | + * 时间:2017/7/12 | ||
| 19 | + * <p> | ||
| 20 | + * 描述:分割线 | ||
| 21 | + */ | ||
| 22 | +public class RecyclerSpace extends RecyclerView.ItemDecoration { | ||
| 23 | + private int space; | ||
| 24 | + private int color = -1; | ||
| 25 | + private Drawable mDivider; | ||
| 26 | + private Paint mPaint; | ||
| 27 | + private int type; | ||
| 28 | + | ||
| 29 | + public int getColor() { | ||
| 30 | + return color; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public void setColor(@ColorRes int color) { | ||
| 34 | + this.color = color; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public RecyclerSpace(int space) { | ||
| 38 | + this.space = space; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public RecyclerSpace(int space, int color) { | ||
| 42 | + this.space = space; | ||
| 43 | + this.color = color; | ||
| 44 | + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 45 | + mPaint.setColor(color); | ||
| 46 | + mPaint.setStyle(Paint.Style.FILL); | ||
| 47 | + mPaint.setStrokeWidth(space * 2); | ||
| 48 | + } | ||
| 49 | + public RecyclerSpace(int space, int color,int type) { | ||
| 50 | + this.space = space; | ||
| 51 | + this.color = color; | ||
| 52 | + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
| 53 | + mPaint.setColor(color); | ||
| 54 | + mPaint.setStyle(Paint.Style.FILL); | ||
| 55 | + mPaint.setStrokeWidth(space * 2); | ||
| 56 | + this.type=type; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public RecyclerSpace(int space, Drawable mDivider) { | ||
| 60 | + this.space = space; | ||
| 61 | + this.mDivider = mDivider; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public void getItemOffsets(Rect outRect, View view, | ||
| 66 | + RecyclerView parent, RecyclerView.State state) { | ||
| 67 | + if (parent.getLayoutManager() != null) { | ||
| 68 | + if (parent.getLayoutManager() instanceof LinearLayoutManager && !(parent.getLayoutManager() instanceof GridLayoutManager)) { | ||
| 69 | + if (((LinearLayoutManager) parent.getLayoutManager()).getOrientation() == LinearLayoutManager.HORIZONTAL) { | ||
| 70 | + outRect.set(space, 0, space, 0); | ||
| 71 | + } else { | ||
| 72 | + outRect.set(0, space, 0, space); | ||
| 73 | + } | ||
| 74 | + } else { | ||
| 75 | + outRect.set(space, space, space, space); | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { | ||
| 83 | + super.onDraw(c, parent, state); | ||
| 84 | + if (parent.getLayoutManager() != null) { | ||
| 85 | + if (parent.getLayoutManager() instanceof LinearLayoutManager && !(parent.getLayoutManager() instanceof GridLayoutManager)) { | ||
| 86 | + if (((LinearLayoutManager) parent.getLayoutManager()).getOrientation() == LinearLayoutManager.HORIZONTAL) { | ||
| 87 | + drawHorizontal(c, parent); | ||
| 88 | + } else { | ||
| 89 | + drawVertical(c, parent); | ||
| 90 | + } | ||
| 91 | + } else { | ||
| 92 | + if(type==0){ | ||
| 93 | + drawGrideview(c, parent); | ||
| 94 | + }else{ | ||
| 95 | + drawGrideview1(c, parent); | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + //绘制纵向 item 分割线 | ||
| 102 | + | ||
| 103 | + private void drawVertical(Canvas canvas, RecyclerView parent) { | ||
| 104 | + final int top = parent.getPaddingTop(); | ||
| 105 | + final int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom(); | ||
| 106 | + final int childSize = parent.getChildCount(); | ||
| 107 | + for (int i = 0; i < childSize; i++) { | ||
| 108 | + final View child = parent.getChildAt(i); | ||
| 109 | + RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); | ||
| 110 | + final int left = child.getRight() + layoutParams.rightMargin; | ||
| 111 | + final int right = left + space; | ||
| 112 | + if (mDivider != null) { | ||
| 113 | + mDivider.setBounds(left, top, right, bottom); | ||
| 114 | + mDivider.draw(canvas); | ||
| 115 | + } | ||
| 116 | + if (mPaint != null) { | ||
| 117 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + //绘制横向 item 分割线 | ||
| 123 | + private void drawHorizontal(Canvas canvas, RecyclerView parent) { | ||
| 124 | + int left = parent.getPaddingLeft(); | ||
| 125 | + int right = parent.getMeasuredWidth() - parent.getPaddingRight(); | ||
| 126 | + final int childSize = parent.getChildCount(); | ||
| 127 | + for (int i = 0; i < childSize; i++) { | ||
| 128 | + final View child = parent.getChildAt(i); | ||
| 129 | + RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); | ||
| 130 | + int top = child.getBottom() + layoutParams.bottomMargin; | ||
| 131 | + int bottom = top + space; | ||
| 132 | + if (mDivider != null) { | ||
| 133 | + mDivider.setBounds(left, top, right, bottom); | ||
| 134 | + mDivider.draw(canvas); | ||
| 135 | + } | ||
| 136 | + if (mPaint != null) { | ||
| 137 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + //绘制grideview item 分割线 不是填充满的 | ||
| 144 | + private void drawGrideview(Canvas canvas, RecyclerView parent) { | ||
| 145 | + GridLayoutManager linearLayoutManager = (GridLayoutManager) parent.getLayoutManager(); | ||
| 146 | + int childSize = parent.getChildCount(); | ||
| 147 | + int other = parent.getChildCount() / linearLayoutManager.getSpanCount() - 1; | ||
| 148 | + if (other < 1) { | ||
| 149 | + other = 1; | ||
| 150 | + } | ||
| 151 | + other = other * linearLayoutManager.getSpanCount(); | ||
| 152 | + if (parent.getChildCount() < linearLayoutManager.getSpanCount()) { | ||
| 153 | + other = parent.getChildCount(); | ||
| 154 | + } | ||
| 155 | + int top, bottom, left, right, spancount; | ||
| 156 | + spancount = linearLayoutManager.getSpanCount() - 1; | ||
| 157 | + for (int i = 0; i < childSize; i++) { | ||
| 158 | + final View child = parent.getChildAt(i); | ||
| 159 | + RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); | ||
| 160 | + if (i < other) { | ||
| 161 | + top = child.getBottom() + layoutParams.bottomMargin; | ||
| 162 | + bottom = top + space; | ||
| 163 | + left = (layoutParams.leftMargin + space) * (i + 1); | ||
| 164 | + right = child.getMeasuredWidth() * (i + 1) + left + space * i; | ||
| 165 | + if (mDivider != null) { | ||
| 166 | + mDivider.setBounds(left, top, right, bottom); | ||
| 167 | + mDivider.draw(canvas); | ||
| 168 | + } | ||
| 169 | + if (mPaint != null) { | ||
| 170 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + if (i != spancount) { | ||
| 174 | + top = (layoutParams.topMargin + space) * (i / linearLayoutManager.getSpanCount() + 1); | ||
| 175 | + bottom = (child.getMeasuredHeight() + space) * (i / linearLayoutManager.getSpanCount() + 1) + space; | ||
| 176 | + left = child.getRight() + layoutParams.rightMargin; | ||
| 177 | + right = left + space; | ||
| 178 | + if (mDivider != null) { | ||
| 179 | + mDivider.setBounds(left, top, right, bottom); | ||
| 180 | + mDivider.draw(canvas); | ||
| 181 | + } | ||
| 182 | + if (mPaint != null) { | ||
| 183 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 184 | + } | ||
| 185 | + } else { | ||
| 186 | + spancount += 4; | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + /***/ | ||
| 192 | + private void drawGrideview1(Canvas canvas, RecyclerView parent) { | ||
| 193 | + GridLayoutManager linearLayoutManager = (GridLayoutManager) parent.getLayoutManager(); | ||
| 194 | + int childSize = parent.getChildCount(); | ||
| 195 | + int top, bottom, left, right,spancount; | ||
| 196 | + spancount=linearLayoutManager.getSpanCount(); | ||
| 197 | + for (int i = 0; i < childSize; i++) { | ||
| 198 | + final View child = parent.getChildAt(i); | ||
| 199 | + //画横线 | ||
| 200 | + RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams(); | ||
| 201 | + top = child.getBottom() + layoutParams.bottomMargin; | ||
| 202 | + bottom = top + space; | ||
| 203 | + left = layoutParams.leftMargin+child.getPaddingLeft()+space; | ||
| 204 | + right = child.getMeasuredWidth() * (i + 1) + left + space * i; | ||
| 205 | + if (mDivider != null) { | ||
| 206 | + mDivider.setBounds(left, top, right, bottom); | ||
| 207 | + mDivider.draw(canvas); | ||
| 208 | + } | ||
| 209 | + if (mPaint != null) { | ||
| 210 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 211 | + } | ||
| 212 | + //画竖线 | ||
| 213 | + top = (layoutParams.topMargin + space) * (i / linearLayoutManager.getSpanCount() + 1); | ||
| 214 | + bottom = (child.getMeasuredHeight() + space) * (i / linearLayoutManager.getSpanCount() + 1) + space; | ||
| 215 | + left = child.getRight() + layoutParams.rightMargin; | ||
| 216 | + right = left + space; | ||
| 217 | + if (mDivider != null) { | ||
| 218 | + mDivider.setBounds(left, top, right, bottom); | ||
| 219 | + mDivider.draw(canvas); | ||
| 220 | + } | ||
| 221 | + if (mPaint != null) { | ||
| 222 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + //画上缺失的线框 | ||
| 226 | + if(i<spancount){ | ||
| 227 | + top = child.getTop() + layoutParams.topMargin; | ||
| 228 | + bottom = top + space; | ||
| 229 | + left = (layoutParams.leftMargin + space) * (i + 1); | ||
| 230 | + right = child.getMeasuredWidth() * (i + 1) + left + space * i; | ||
| 231 | + if (mDivider != null) { | ||
| 232 | + mDivider.setBounds(left, top, right, bottom); | ||
| 233 | + mDivider.draw(canvas); | ||
| 234 | + } | ||
| 235 | + if (mPaint != null) { | ||
| 236 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + if(i%spancount==0){ | ||
| 240 | + top = (layoutParams.topMargin + space) * (i / linearLayoutManager.getSpanCount() + 1); | ||
| 241 | + bottom = (child.getMeasuredHeight() + space) * (i / linearLayoutManager.getSpanCount() + 1) + space; | ||
| 242 | + left = child.getLeft() + layoutParams.leftMargin; | ||
| 243 | + right = left + space; | ||
| 244 | + if (mDivider != null) { | ||
| 245 | + mDivider.setBounds(left, top, right, bottom); | ||
| 246 | + mDivider.draw(canvas); | ||
| 247 | + } | ||
| 248 | + if (mPaint != null) { | ||
| 249 | + canvas.drawRect(left, top, right, bottom, mPaint); | ||
| 250 | + } | ||
| 251 | + } | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | +} | ||
| 0 | \ No newline at end of file | 255 | \ No newline at end of file |
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/user/fragment/UserPersonalEditFragment.java
| @@ -14,6 +14,7 @@ import com.cnlive.gundam.databinding.FragmentPersonalEditBinding; | @@ -14,6 +14,7 @@ import com.cnlive.gundam.databinding.FragmentPersonalEditBinding; | ||
| 14 | import com.cnlive.gundam.user.activity.UserPersonalActivity; | 14 | import com.cnlive.gundam.user.activity.UserPersonalActivity; |
| 15 | import com.cnlive.gundam.user.auth.UserService; | 15 | import com.cnlive.gundam.user.auth.UserService; |
| 16 | import com.cnlive.gundam.user.model.User; | 16 | import com.cnlive.gundam.user.model.User; |
| 17 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 17 | import com.cnlive.libs.user.IUserService; | 18 | import com.cnlive.libs.user.IUserService; |
| 18 | import com.cnlive.libs.user.UserUtil; | 19 | import com.cnlive.libs.user.UserUtil; |
| 19 | import com.cnlive.libs.user.model.UserData; | 20 | import com.cnlive.libs.user.model.UserData; |
| @@ -130,6 +131,7 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | @@ -130,6 +131,7 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | ||
| 130 | updateUserInfo(); | 131 | updateUserInfo(); |
| 131 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); | 132 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); |
| 132 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { | 133 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { |
| 134 | + ToastUtil.show(getActivity(), getString(R.string.user_token_invalid)); | ||
| 133 | UserService userService = UserService.getInstance(getActivity()); | 135 | UserService userService = UserService.getInstance(getActivity()); |
| 134 | userService.clearUser(); | 136 | userService.clearUser(); |
| 135 | getActivity().finish(); | 137 | getActivity().finish(); |
| @@ -147,6 +149,7 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | @@ -147,6 +149,7 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | ||
| 147 | UserService userService = UserService.getInstance(getActivity()); | 149 | UserService userService = UserService.getInstance(getActivity()); |
| 148 | userService.setActiveAccountInfo(userData.getData()); | 150 | userService.setActiveAccountInfo(userData.getData()); |
| 149 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { | 151 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { |
| 152 | + ToastUtil.show(getActivity(), getString(R.string.user_token_invalid)); | ||
| 150 | UserService userService = UserService.getInstance(getActivity()); | 153 | UserService userService = UserService.getInstance(getActivity()); |
| 151 | userService.clearUser(); | 154 | userService.clearUser(); |
| 152 | getActivity().finish(); | 155 | getActivity().finish(); |
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalFragment.java
| @@ -31,6 +31,7 @@ import com.cnlive.gundam.user.auth.UserService; | @@ -31,6 +31,7 @@ import com.cnlive.gundam.user.auth.UserService; | ||
| 31 | import com.cnlive.gundam.user.model.PersonalData; | 31 | import com.cnlive.gundam.user.model.PersonalData; |
| 32 | import com.cnlive.gundam.user.model.User; | 32 | import com.cnlive.gundam.user.model.User; |
| 33 | import com.cnlive.gundam.user.util.PictureUtil; | 33 | import com.cnlive.gundam.user.util.PictureUtil; |
| 34 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 34 | import com.cnlive.gundam.user.view.SelectPopupWindow; | 35 | import com.cnlive.gundam.user.view.SelectPopupWindow; |
| 35 | import com.cnlive.libs.user.IUserService; | 36 | import com.cnlive.libs.user.IUserService; |
| 36 | import com.cnlive.libs.user.UserUtil; | 37 | import com.cnlive.libs.user.UserUtil; |
| @@ -284,6 +285,7 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | @@ -284,6 +285,7 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | ||
| 284 | updateUserInfo(); | 285 | updateUserInfo(); |
| 285 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); | 286 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); |
| 286 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { | 287 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { |
| 288 | + ToastUtil.show(getActivity(), getString(R.string.user_token_invalid)); | ||
| 287 | UserService userService = UserService.getInstance(getActivity()); | 289 | UserService userService = UserService.getInstance(getActivity()); |
| 288 | userService.clearUser(); | 290 | userService.clearUser(); |
| 289 | getActivity().finish(); | 291 | getActivity().finish(); |
| @@ -303,6 +305,7 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | @@ -303,6 +305,7 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | ||
| 303 | user = userService.getActiveAccountInfo(); | 305 | user = userService.getActiveAccountInfo(); |
| 304 | initData(); | 306 | initData(); |
| 305 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { | 307 | } else if (i == IUserService.ERROR_TOKEN_INVALID) { |
| 308 | + ToastUtil.show(getActivity(), getString(R.string.user_token_invalid)); | ||
| 306 | UserService userService = UserService.getInstance(getActivity()); | 309 | UserService userService = UserService.getInstance(getActivity()); |
| 307 | userService.clearUser(); | 310 | userService.clearUser(); |
| 308 | getActivity().finish(); | 311 | getActivity().finish(); |
app/src/main/java/com/cnlive/gundam/video/activity/PlayerActivity.java
| @@ -9,13 +9,20 @@ import android.support.v7.app.AppCompatActivity; | @@ -9,13 +9,20 @@ import android.support.v7.app.AppCompatActivity; | ||
| 9 | import android.widget.Toast; | 9 | import android.widget.Toast; |
| 10 | 10 | ||
| 11 | import com.cnlive.gundam.R; | 11 | import com.cnlive.gundam.R; |
| 12 | +import com.cnlive.gundam.main.model.MsgEvent; | ||
| 12 | import com.cnlive.gundam.main.model.VideoListProgram; | 13 | import com.cnlive.gundam.main.model.VideoListProgram; |
| 14 | +import com.cnlive.gundam.main.utils.SharedPreferencesHelper; | ||
| 15 | +import com.cnlive.gundam.user.util.ToastUtil; | ||
| 13 | import com.cnlive.gundam.video.fragment.PlayerLiveFragment; | 16 | import com.cnlive.gundam.video.fragment.PlayerLiveFragment; |
| 14 | import com.cnlive.gundam.video.fragment.PlayerUgcLiveFragment; | 17 | import com.cnlive.gundam.video.fragment.PlayerUgcLiveFragment; |
| 15 | import com.cnlive.gundam.video.fragment.PlayerUgcVodFragment; | 18 | import com.cnlive.gundam.video.fragment.PlayerUgcVodFragment; |
| 16 | import com.cnlive.gundam.video.fragment.PlayerVodFragment; | 19 | import com.cnlive.gundam.video.fragment.PlayerVodFragment; |
| 17 | import com.cnlive.gundam.video.utils.PlayerUtils; | 20 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 18 | 21 | ||
| 22 | +import org.greenrobot.eventbus.EventBus; | ||
| 23 | +import org.greenrobot.eventbus.Subscribe; | ||
| 24 | +import org.greenrobot.eventbus.ThreadMode; | ||
| 25 | + | ||
| 19 | /** | 26 | /** |
| 20 | * Created by gujun on 2017/4/5. | 27 | * Created by gujun on 2017/4/5. |
| 21 | * screenDirect //0:竖向 1;横向 ugcLive ugcVod 播放页面用到了 | 28 | * screenDirect //0:竖向 1;横向 ugcLive ugcVod 播放页面用到了 |
| @@ -28,11 +35,14 @@ public class PlayerActivity extends AppCompatActivity { | @@ -28,11 +35,14 @@ public class PlayerActivity extends AppCompatActivity { | ||
| 28 | //默认横屏 | 35 | //默认横屏 |
| 29 | private int screenDirect = 1; | 36 | private int screenDirect = 1; |
| 30 | 37 | ||
| 38 | + | ||
| 31 | @Override | 39 | @Override |
| 32 | protected void onCreate(@Nullable Bundle savedInstanceState) { | 40 | protected void onCreate(@Nullable Bundle savedInstanceState) { |
| 33 | super.onCreate(savedInstanceState); | 41 | super.onCreate(savedInstanceState); |
| 34 | setContentView(R.layout.activity_player); | 42 | setContentView(R.layout.activity_player); |
| 35 | addData(getIntent()); | 43 | addData(getIntent()); |
| 44 | + | ||
| 45 | + | ||
| 36 | } | 46 | } |
| 37 | 47 | ||
| 38 | @Override | 48 | @Override |
| @@ -80,11 +90,20 @@ public class PlayerActivity extends AppCompatActivity { | @@ -80,11 +90,20 @@ public class PlayerActivity extends AppCompatActivity { | ||
| 80 | 90 | ||
| 81 | @Override | 91 | @Override |
| 82 | public void onBackPressed() { | 92 | public void onBackPressed() { |
| 93 | + | ||
| 83 | if (!(PlayerUtils.isPortrait(this)) && (fragment instanceof PlayerLiveFragment || fragment instanceof PlayerVodFragment)) { | 94 | if (!(PlayerUtils.isPortrait(this)) && (fragment instanceof PlayerLiveFragment || fragment instanceof PlayerVodFragment)) { |
| 84 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); | 95 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); |
| 96 | + } else if (SharedPreferencesHelper.getInstance(this).getIntValue("ishow") == 0) { | ||
| 97 | + EventBus.getDefault().post(new MsgEvent()); | ||
| 85 | } else { | 98 | } else { |
| 86 | super.onBackPressed(); | 99 | super.onBackPressed(); |
| 87 | } | 100 | } |
| 88 | } | 101 | } |
| 89 | 102 | ||
| 103 | + | ||
| 104 | + @Override | ||
| 105 | + protected void onDestroy() { | ||
| 106 | + super.onDestroy(); | ||
| 107 | + | ||
| 108 | + } | ||
| 90 | } | 109 | } |
app/src/main/java/com/cnlive/gundam/video/adpter/CommentAdapter.java
| @@ -23,10 +23,10 @@ import java.util.List; | @@ -23,10 +23,10 @@ import java.util.List; | ||
| 23 | */ | 23 | */ |
| 24 | public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentHolder> { | 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 | Context context; | 28 | Context context; |
| 29 | - private final LayoutInflater mLayoutInflater; | 29 | + private LayoutInflater mLayoutInflater; |
| 30 | private CommentHolder commentHolder; | 30 | private CommentHolder commentHolder; |
| 31 | 31 | ||
| 32 | public CommentAdapter(Context context) { | 32 | public CommentAdapter(Context context) { |
| @@ -36,10 +36,19 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH | @@ -36,10 +36,19 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH | ||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | public void addItems(List<CommentItem> items) { | 38 | public void addItems(List<CommentItem> items) { |
| 39 | + | ||
| 39 | mItems.addAll(items); | 40 | mItems.addAll(items); |
| 40 | notifyDataSetChanged(); | 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 | public void refreshItems(List<CommentItem> items) { | 52 | public void refreshItems(List<CommentItem> items) { |
| 44 | mItems.clear(); | 53 | mItems.clear(); |
| 45 | mItems.addAll(items); | 54 | mItems.addAll(items); |
| @@ -58,10 +67,17 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH | @@ -58,10 +67,17 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH | ||
| 58 | return commentHolder; | 67 | return commentHolder; |
| 59 | } | 68 | } |
| 60 | 69 | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + | ||
| 61 | @Override | 74 | @Override |
| 62 | public void onBindViewHolder(CommentHolder holder, int position) { | 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 | Glide.with(context).load(commentItem.getFacepath()).into(commentHolder.img_head); | 81 | Glide.with(context).load(commentItem.getFacepath()).into(commentHolder.img_head); |
| 66 | commentHolder.nick_name.setText(commentItem.getUid()); | 82 | commentHolder.nick_name.setText(commentItem.getUid()); |
| 67 | commentHolder.comment_message.setText(commentItem.getContent()); | 83 | commentHolder.comment_message.setText(commentItem.getContent()); |
| @@ -87,17 +103,18 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH | @@ -87,17 +103,18 @@ public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.CommentH | ||
| 87 | this.onImageViewClick = onImageViewClick; | 103 | this.onImageViewClick = onImageViewClick; |
| 88 | } | 104 | } |
| 89 | 105 | ||
| 106 | + | ||
| 90 | public interface OnImageViewClick { | 107 | public interface OnImageViewClick { |
| 91 | void praiseComment(CommentItem commentItem); | 108 | void praiseComment(CommentItem commentItem); |
| 92 | } | 109 | } |
| 93 | 110 | ||
| 94 | class CommentHolder extends RecyclerView.ViewHolder { | 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 | public CommentHolder(View itemView) { | 119 | public CommentHolder(View itemView) { |
| 103 | super(itemView); | 120 | super(itemView); |
app/src/main/java/com/cnlive/gundam/video/adpter/CommonAdapter.java
| @@ -8,6 +8,7 @@ import android.view.View; | @@ -8,6 +8,7 @@ import android.view.View; | ||
| 8 | import android.view.ViewGroup; | 8 | import android.view.ViewGroup; |
| 9 | import android.widget.BaseAdapter; | 9 | import android.widget.BaseAdapter; |
| 10 | import android.widget.LinearLayout; | 10 | import android.widget.LinearLayout; |
| 11 | +import android.widget.RelativeLayout; | ||
| 11 | 12 | ||
| 12 | import com.cnlive.gundam.databinding.ItemListRightBinding; | 13 | import com.cnlive.gundam.databinding.ItemListRightBinding; |
| 13 | import com.cnlive.gundam.video.model.MessageContent; | 14 | import com.cnlive.gundam.video.model.MessageContent; |
| @@ -62,17 +63,18 @@ public class CommonAdapter<T> extends BaseAdapter { | @@ -62,17 +63,18 @@ public class CommonAdapter<T> extends BaseAdapter { | ||
| 62 | binding = DataBindingUtil.getBinding(convertView); | 63 | binding = DataBindingUtil.getBinding(convertView); |
| 63 | } | 64 | } |
| 64 | binding.setVariable(variableId, mDataList.get(position)); | 65 | binding.setVariable(variableId, mDataList.get(position)); |
| 66 | + | ||
| 65 | MessageContent user = (MessageContent) mDataList.get(position); | 67 | MessageContent user = (MessageContent) mDataList.get(position); |
| 66 | 68 | ||
| 67 | if(((MessageContent) mDataList.get(position)).isSendInfo()){ | 69 | if(((MessageContent) mDataList.get(position)).isSendInfo()){ |
| 68 | ItemListRightBinding binding1 = (ItemListRightBinding) binding; | 70 | ItemListRightBinding binding1 = (ItemListRightBinding) binding; |
| 69 | LinearLayout rightLin = binding1.rightLin; | 71 | LinearLayout rightLin = binding1.rightLin; |
| 70 | - LinearLayout leftLin = binding1.leftLin; | 72 | + RelativeLayout leftLin = binding1.leftLin; |
| 71 | leftLin.setVisibility(View.VISIBLE); | 73 | leftLin.setVisibility(View.VISIBLE); |
| 72 | rightLin.setVisibility(View.INVISIBLE); | 74 | rightLin.setVisibility(View.INVISIBLE); |
| 73 | }else { | 75 | }else { |
| 74 | ItemListRightBinding binding1 = (ItemListRightBinding) binding; | 76 | ItemListRightBinding binding1 = (ItemListRightBinding) binding; |
| 75 | - LinearLayout leftLin = binding1.leftLin; | 77 | + RelativeLayout leftLin = binding1.leftLin; |
| 76 | LinearLayout rightLin = binding1.rightLin; | 78 | LinearLayout rightLin = binding1.rightLin; |
| 77 | rightLin.setVisibility(View.VISIBLE); | 79 | rightLin.setVisibility(View.VISIBLE); |
| 78 | 80 |
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 | + } | ||
| 242 | + | ||
| 243 | + if (binding.srvVodDetail.isRefreshing()) { | ||
| 244 | + binding.srvVodDetail.complete(); | ||
| 245 | + } | ||
| 246 | + if (mDatas == null) { | ||
| 247 | + binding.srvVodDetail.onNoMore("快来抢沙发喽~"); | ||
| 248 | + loadMoreEnable = false; | ||
| 249 | + } else if (isScroll) { | ||
| 250 | + adapter.add(1, mDatas.get(0)); | ||
| 251 | + binding.srvVodDetail.getRecyclerView().scrollToPosition(1); | ||
| 252 | + } else { | ||
| 253 | + adapter.addDatas(mDatas); | ||
| 254 | + if (mDatas.size() < 2) { | ||
| 255 | + binding.srvVodDetail.onNoMore("暂无更多评论~"); | ||
| 256 | + loadMoreEnable = false; | ||
| 257 | + } | ||
| 258 | + page++; | ||
| 259 | + | ||
| 260 | + } | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + | ||
| 264 | + public class OnBindItemClick { | ||
| 265 | + | ||
| 266 | + public void onPraiseClick(final CommentViewModel commentViewModel) { | ||
| 267 | + if (true) {//判断登录 | ||
| 268 | + //TODO 点赞评论 | ||
| 269 | + String uid = String.valueOf(userService.getActiveAccountInfo().getUid()); | ||
| 270 | + presenter.toPraise(commentViewModel, mContentId, uid); | ||
| 271 | + | ||
| 272 | + } else { | ||
| 273 | + ToastUtil.showToast("请登录"); | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + public void onCommentClick() { | ||
| 278 | + //弹出输入框 | ||
| 279 | + if (TextUtils.isEmpty(userService.getActiveAccountInfo().getUid() + "")) { | ||
| 280 | + ToastUtil.showToast("请先登录"); | ||
| 281 | + return; | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + showInput(binding.llVodDetail); | ||
| 285 | + } | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + | ||
| 289 | +} |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerVodFragment.java
| @@ -48,7 +48,7 @@ public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSe | @@ -48,7 +48,7 @@ public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSe | ||
| 48 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | 48 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 49 | binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_vod, container, false); | 49 | binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_vod, container, false); |
| 50 | VideoListProgram program = (VideoListProgram) getArguments().getSerializable("program"); | 50 | VideoListProgram program = (VideoListProgram) getArguments().getSerializable("program"); |
| 51 | - getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, CommentFragment.newInstance(program.getvId()+""), "commentFragment").commit(); | 51 | + getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, CommentDetailsFragment.newInstance(program.getvId()+""), "commentFragment").commit(); |
| 52 | return binding.getRoot(); | 52 | return binding.getRoot(); |
| 53 | } | 53 | } |
| 54 | 54 |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
| @@ -8,6 +8,7 @@ import android.os.Bundle; | @@ -8,6 +8,7 @@ import android.os.Bundle; | ||
| 8 | import android.support.annotation.NonNull; | 8 | import android.support.annotation.NonNull; |
| 9 | import android.support.annotation.Nullable; | 9 | import android.support.annotation.Nullable; |
| 10 | import android.support.v4.app.Fragment; | 10 | import android.support.v4.app.Fragment; |
| 11 | +import android.support.v4.app.FragmentActivity; | ||
| 11 | import android.support.v4.content.ContextCompat; | 12 | import android.support.v4.content.ContextCompat; |
| 12 | import android.support.v7.widget.GridLayoutManager; | 13 | import android.support.v7.widget.GridLayoutManager; |
| 13 | import android.support.v7.widget.SwitchCompat; | 14 | import android.support.v7.widget.SwitchCompat; |
| @@ -21,10 +22,15 @@ import com.bumptech.glide.Glide; | @@ -21,10 +22,15 @@ import com.bumptech.glide.Glide; | ||
| 21 | import com.cnlive.gundam.BR; | 22 | import com.cnlive.gundam.BR; |
| 22 | import com.cnlive.gundam.R; | 23 | import com.cnlive.gundam.R; |
| 23 | import com.cnlive.gundam.databinding.FragmentChatBinding; | 24 | import com.cnlive.gundam.databinding.FragmentChatBinding; |
| 25 | +import com.cnlive.gundam.main.model.MsgEvent; | ||
| 26 | +import com.cnlive.gundam.main.ui.widget.GlideCircleTransform; | ||
| 27 | +import com.cnlive.gundam.main.ui.widget.RecyclerSpace; | ||
| 28 | +import com.cnlive.gundam.main.utils.SharedPreferencesHelper; | ||
| 24 | import com.cnlive.gundam.user.auth.UserService; | 29 | import com.cnlive.gundam.user.auth.UserService; |
| 25 | import com.cnlive.gundam.user.model.User; | 30 | import com.cnlive.gundam.user.model.User; |
| 26 | import com.cnlive.gundam.user.util.InputUtil; | 31 | import com.cnlive.gundam.user.util.InputUtil; |
| 27 | import com.cnlive.gundam.user.util.ToastUtil; | 32 | import com.cnlive.gundam.user.util.ToastUtil; |
| 33 | +import com.cnlive.gundam.video.activity.PlayerActivity; | ||
| 28 | import com.cnlive.gundam.video.adpter.CommonAdapter; | 34 | import com.cnlive.gundam.video.adpter.CommonAdapter; |
| 29 | import com.cnlive.gundam.video.adpter.GiftAdapter; | 35 | import com.cnlive.gundam.video.adpter.GiftAdapter; |
| 30 | import com.cnlive.gundam.video.barrage.BarrageBaseMessage; | 36 | import com.cnlive.gundam.video.barrage.BarrageBaseMessage; |
| @@ -36,8 +42,11 @@ import com.cnlive.libs.util.chat.base.IChat; | @@ -36,8 +42,11 @@ import com.cnlive.libs.util.chat.base.IChat; | ||
| 36 | import com.cnlive.libs.util.chat.model.CNUserInfo; | 42 | import com.cnlive.libs.util.chat.model.CNUserInfo; |
| 37 | import com.cnlive.libs.video.barrage.BarrageLayout; | 43 | import com.cnlive.libs.video.barrage.BarrageLayout; |
| 38 | 44 | ||
| 39 | -import java.util.ArrayList; | 45 | +import org.greenrobot.eventbus.EventBus; |
| 46 | +import org.greenrobot.eventbus.Subscribe; | ||
| 47 | +import org.greenrobot.eventbus.ThreadMode; | ||
| 40 | 48 | ||
| 49 | +import java.util.ArrayList; | ||
| 41 | 50 | ||
| 42 | 51 | ||
| 43 | /** | 52 | /** |
| @@ -78,27 +87,32 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -78,27 +87,32 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 78 | 87 | ||
| 79 | } | 88 | } |
| 80 | 89 | ||
| 90 | + String faceurl; | ||
| 91 | + | ||
| 81 | @Override | 92 | @Override |
| 82 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | 93 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 83 | super.onViewCreated(view, savedInstanceState); | 94 | super.onViewCreated(view, savedInstanceState); |
| 84 | initListener(); | 95 | initListener(); |
| 96 | + EventBus.getDefault().register(this); | ||
| 97 | + faceurl = UserService.getInstance(getActivity()).getActiveAccountInfo().getFaceurl(); | ||
| 85 | initDate(); | 98 | initDate(); |
| 86 | initGift(); | 99 | initGift(); |
| 87 | int checkCallPhonePermission = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_PHONE_STATE); | 100 | int checkCallPhonePermission = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_PHONE_STATE); |
| 88 | if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) { | 101 | if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) { |
| 89 | requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, PERMISSION_REQUEST_CODE); | 102 | requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, PERMISSION_REQUEST_CODE); |
| 90 | - }else{ | 103 | + } else { |
| 91 | initChat(); | 104 | initChat(); |
| 92 | } | 105 | } |
| 93 | } | 106 | } |
| 107 | + | ||
| 94 | @Override | 108 | @Override |
| 95 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | 109 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| 96 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | 110 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| 97 | - if(requestCode == PERMISSION_REQUEST_CODE){ | 111 | + if (requestCode == PERMISSION_REQUEST_CODE) { |
| 98 | if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { | 112 | if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { |
| 99 | initChat(); | 113 | initChat(); |
| 100 | } else { | 114 | } else { |
| 101 | - ToastUtil.show(getActivity(),"使用聊天功能,请通过权限审核"); | 115 | + ToastUtil.show(getActivity(), "使用聊天功能,请通过权限审核"); |
| 102 | } | 116 | } |
| 103 | } | 117 | } |
| 104 | } | 118 | } |
| @@ -121,6 +135,8 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -121,6 +135,8 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 121 | } | 135 | } |
| 122 | } | 136 | } |
| 123 | }); | 137 | }); |
| 138 | + | ||
| 139 | + | ||
| 124 | } | 140 | } |
| 125 | 141 | ||
| 126 | @BindingAdapter("android:src") | 142 | @BindingAdapter("android:src") |
| @@ -130,10 +146,12 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -130,10 +146,12 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 130 | 146 | ||
| 131 | @BindingAdapter({"imageUrl"}) | 147 | @BindingAdapter({"imageUrl"}) |
| 132 | public static void loadImage(ImageView imageView, String url) { | 148 | public static void loadImage(ImageView imageView, String url) { |
| 133 | - if (url == null) { | ||
| 134 | - imageView.setImageResource(R.mipmap.ic_launcher); | 149 | + if (url == null || url.equals("")) { |
| 150 | +// imageView.setImageResource(R.mipmap.ic_launcher); | ||
| 151 | + | ||
| 152 | + Glide.with(imageView.getContext()).load(R.mipmap.ic_launcher).bitmapTransform(new GlideCircleTransform(imageView.getContext())).error(R.mipmap.ic_launcher).into(imageView); | ||
| 135 | } else { | 153 | } else { |
| 136 | - Glide.with(imageView.getContext()).load(url).error(R.mipmap.ic_launcher).into(imageView); | 154 | + Glide.with(imageView.getContext()).load(url).bitmapTransform(new GlideCircleTransform(imageView.getContext())).error(R.mipmap.ic_launcher).into(imageView); |
| 137 | } | 155 | } |
| 138 | } | 156 | } |
| 139 | 157 | ||
| @@ -143,11 +161,11 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -143,11 +161,11 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 143 | } | 161 | } |
| 144 | 162 | ||
| 145 | 163 | ||
| 146 | - | ||
| 147 | @Override | 164 | @Override |
| 148 | public void onDestroy() { | 165 | public void onDestroy() { |
| 149 | super.onDestroy(); | 166 | super.onDestroy(); |
| 150 | ChatUtil.disconnect(false); | 167 | ChatUtil.disconnect(false); |
| 168 | + EventBus.getDefault().unregister(this); | ||
| 151 | } | 169 | } |
| 152 | 170 | ||
| 153 | private void initChat() { | 171 | private void initChat() { |
| @@ -178,11 +196,14 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -178,11 +196,14 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 178 | @Override | 196 | @Override |
| 179 | public void onClick(View view) { | 197 | public void onClick(View view) { |
| 180 | int i = View.INVISIBLE == fragmentChatBinding.rlGift.getVisibility() ? View.VISIBLE : View.INVISIBLE; | 198 | int i = View.INVISIBLE == fragmentChatBinding.rlGift.getVisibility() ? View.VISIBLE : View.INVISIBLE; |
| 199 | + SharedPreferencesHelper.getInstance(getActivity()).setValue("ishow", i); | ||
| 181 | fragmentChatBinding.rlGift.setVisibility(i); | 200 | fragmentChatBinding.rlGift.setVisibility(i); |
| 182 | } | 201 | } |
| 183 | }); | 202 | }); |
| 184 | GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 6); | 203 | GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 6); |
| 185 | fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager); | 204 | fragmentChatBinding.recyclerGift.setLayoutManager(gridLayoutManager); |
| 205 | + fragmentChatBinding.recyclerGift.addItemDecoration(new RecyclerSpace(10)); | ||
| 206 | + | ||
| 186 | fragmentChatBinding.setGiftAdapter(new GiftAdapter(roomId, getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean)); | 207 | fragmentChatBinding.setGiftAdapter(new GiftAdapter(roomId, getActivity(), giftArray, R.layout.fragment_gift_receycel, BR.dataBean)); |
| 187 | } | 208 | } |
| 188 | 209 | ||
| @@ -202,6 +223,9 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -202,6 +223,9 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 202 | } | 223 | } |
| 203 | } | 224 | } |
| 204 | 225 | ||
| 226 | + /** | ||
| 227 | + * 设置礼物 | ||
| 228 | + */ | ||
| 205 | private void initGift() { | 229 | private void initGift() { |
| 206 | fragmentChatBinding.sendMessage.setOnClickListener(new View.OnClickListener() { | 230 | fragmentChatBinding.sendMessage.setOnClickListener(new View.OnClickListener() { |
| 207 | 231 | ||
| @@ -218,30 +242,61 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | @@ -218,30 +242,61 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback | ||
| 218 | 242 | ||
| 219 | } | 243 | } |
| 220 | 244 | ||
| 245 | + /** | ||
| 246 | + * 初始化监听事件 | ||
| 247 | + */ | ||
| 221 | private void initListener() { | 248 | private void initListener() { |
| 222 | barrageBottom(); | 249 | barrageBottom(); |
| 223 | initMessageAdapter(); | 250 | initMessageAdapter(); |
| 224 | messageContentInfo = new MessageContentInfo(); | 251 | messageContentInfo = new MessageContentInfo(); |
| 225 | - messageContentInfo.setOnReceiveAndSendListener( roomId, getActivity(), ChatRoomFragment.this); | 252 | + messageContentInfo.setOnReceiveAndSendListener(roomId, getActivity(), ChatRoomFragment.this); |
| 226 | } | 253 | } |
| 227 | 254 | ||
| 228 | 255 | ||
| 229 | public void giftItem(int postion) { | 256 | public void giftItem(int postion) { |
| 230 | fragmentChatBinding.rlGift.setVisibility(View.INVISIBLE); | 257 | fragmentChatBinding.rlGift.setVisibility(View.INVISIBLE); |
| 231 | - messageContents.add(new MessageContent(messageContents.get(0).getName(),"送了" + gitName[postion]+":",messageContents.get(0).getIcon(),false)); | 258 | + |
| 259 | + messageContents.add(new MessageContent(messageContents.get(0).getName(), "送了" + gitName[postion] + ":", faceurl, false)); | ||
| 232 | messageContentCommonAdapter.addItems((messageContents)); | 260 | messageContentCommonAdapter.addItems((messageContents)); |
| 233 | } | 261 | } |
| 234 | 262 | ||
| 235 | ArrayList<MessageContent> messageContents; | 263 | ArrayList<MessageContent> messageContents; |
| 264 | + | ||
| 265 | + /** | ||
| 266 | + * 聊天的回调接口 | ||
| 267 | + * | ||
| 268 | + * @param messageContents | ||
| 269 | + */ | ||
| 236 | @Override | 270 | @Override |
| 237 | public void onchat(ArrayList<MessageContent> messageContents) { | 271 | public void onchat(ArrayList<MessageContent> messageContents) { |
| 238 | - this.messageContents=messageContents; | 272 | + this.messageContents = messageContents; |
| 239 | messageContentCommonAdapter.addItems((messageContents)); | 273 | messageContentCommonAdapter.addItems((messageContents)); |
| 240 | 274 | ||
| 241 | } | 275 | } |
| 242 | 276 | ||
| 277 | + /** | ||
| 278 | + * 弹幕 | ||
| 279 | + * | ||
| 280 | + * @param barrageBaseMessage | ||
| 281 | + */ | ||
| 243 | @Override | 282 | @Override |
| 244 | public void onbarrage(BarrageBaseMessage barrageBaseMessage) { | 283 | public void onbarrage(BarrageBaseMessage barrageBaseMessage) { |
| 245 | barrageLayout.addMessage(barrageBaseMessage); | 284 | barrageLayout.addMessage(barrageBaseMessage); |
| 246 | } | 285 | } |
| 286 | + | ||
| 287 | + //在处理礼物返回问题 | ||
| 288 | + | ||
| 289 | + | ||
| 290 | + /** | ||
| 291 | + * 接收页面 {@link PlayerActivity} | ||
| 292 | + * | ||
| 293 | + * @param event 处理 礼物出现后activity 和fragment的返回问题. | ||
| 294 | + */ | ||
| 295 | + @Subscribe(threadMode = ThreadMode.MAIN) //第2步:注册一个在后台线程执行的方法,用于接收事件 | ||
| 296 | + public void onUserEvent(MsgEvent event) { | ||
| 297 | + | ||
| 298 | + fragmentChatBinding.rlGift.setVisibility(View.INVISIBLE); | ||
| 299 | + SharedPreferencesHelper.getInstance(getActivity()).setValue("ishow", 4); | ||
| 300 | + } | ||
| 301 | + | ||
| 247 | } | 302 | } |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/CommentFragment.java
| @@ -14,6 +14,7 @@ import android.widget.Toast; | @@ -14,6 +14,7 @@ import android.widget.Toast; | ||
| 14 | 14 | ||
| 15 | import com.cnlive.gundam.R; | 15 | import com.cnlive.gundam.R; |
| 16 | import com.cnlive.gundam.user.auth.UserService; | 16 | import com.cnlive.gundam.user.auth.UserService; |
| 17 | +import com.cnlive.gundam.user.model.User; | ||
| 17 | import com.cnlive.gundam.user.util.InputUtil; | 18 | import com.cnlive.gundam.user.util.InputUtil; |
| 18 | import com.cnlive.gundam.video.adpter.CommentAdapter; | 19 | import com.cnlive.gundam.video.adpter.CommentAdapter; |
| 19 | import com.cnlive.libs.util.chat.model.ErrorMessage; | 20 | import com.cnlive.libs.util.chat.model.ErrorMessage; |
| @@ -33,7 +34,7 @@ import java.util.Random; | @@ -33,7 +34,7 @@ import java.util.Random; | ||
| 33 | * @time 2017/6/29 19:44 | 34 | * @time 2017/6/29 19:44 |
| 34 | * @desc ${TODD} | 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 | private View inflate; | 40 | private View inflate; |
| @@ -43,7 +44,7 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -43,7 +44,7 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 43 | 44 | ||
| 44 | Bundle args = new Bundle(); | 45 | Bundle args = new Bundle(); |
| 45 | CommentFragment fragment = new CommentFragment(); | 46 | CommentFragment fragment = new CommentFragment(); |
| 46 | - args.putString("programID",programID); | 47 | + args.putString("programID", programID); |
| 47 | fragment.setArguments(args); | 48 | fragment.setArguments(args); |
| 48 | return fragment; | 49 | return fragment; |
| 49 | } | 50 | } |
| @@ -53,8 +54,9 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -53,8 +54,9 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 53 | private CommentUtil commentUtil; | 54 | private CommentUtil commentUtil; |
| 54 | private CommentAdapter commentAdapter; | 55 | private CommentAdapter commentAdapter; |
| 55 | private RecyclerView recyclerView; | 56 | private RecyclerView recyclerView; |
| 56 | - private String programID ; | 57 | + private String programID; |
| 57 | private String userID; | 58 | private String userID; |
| 59 | + User user; | ||
| 58 | 60 | ||
| 59 | @Nullable | 61 | @Nullable |
| 60 | @Override | 62 | @Override |
| @@ -71,21 +73,26 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -71,21 +73,26 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 71 | initUI(); | 73 | initUI(); |
| 72 | } | 74 | } |
| 73 | 75 | ||
| 76 | + int uid; | ||
| 77 | + | ||
| 74 | private void initDate() { | 78 | private void initDate() { |
| 79 | + user = UserService.getInstance(getActivity()).getActiveAccountInfo(); | ||
| 75 | inputUtil = new InputUtil(getActivity()); | 80 | inputUtil = new InputUtil(getActivity()); |
| 76 | inputUtil.setonSendCommentCallBack(this); | 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 | private void initUI() { | 93 | private void initUI() { |
| 87 | 94 | ||
| 88 | - programID= getArguments().getString("programID"); | 95 | + programID = getArguments().getString("programID"); |
| 89 | commentAdapter = new CommentAdapter(getActivity()); | 96 | commentAdapter = new CommentAdapter(getActivity()); |
| 90 | recyclerView = (RecyclerView) getActivity().findViewById(R.id.comment_content); | 97 | recyclerView = (RecyclerView) getActivity().findViewById(R.id.comment_content); |
| 91 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); | 98 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); |
| @@ -109,7 +116,7 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -109,7 +116,7 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 109 | @Override | 116 | @Override |
| 110 | public void onClick(View v) { | 117 | public void onClick(View v) { |
| 111 | switch (v.getId()) { | 118 | switch (v.getId()) { |
| 112 | - case R.id.input : | 119 | + case R.id.input: |
| 113 | inputUtil.showInput(v); | 120 | inputUtil.showInput(v); |
| 114 | break; | 121 | break; |
| 115 | } | 122 | } |
| @@ -117,6 +124,8 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -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 | public void getCommentMesaage() { | 130 | public void getCommentMesaage() { |
| 122 | commentUtil.readAllComment(programID, 1, 10, new CommentListCallback() { | 131 | commentUtil.readAllComment(programID, 1, 10, new CommentListCallback() { |
| @@ -124,12 +133,10 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -124,12 +133,10 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 124 | public void onResponse(CommentPage commentPage) { | 133 | public void onResponse(CommentPage commentPage) { |
| 125 | if (commentPage.getData() != null) { | 134 | if (commentPage.getData() != null) { |
| 126 | Log.v("commentPage", commentPage.getErrorMessage() + ""); | 135 | Log.v("commentPage", commentPage.getErrorMessage() + ""); |
| 127 | - List<CommentItem> comments = commentPage.getData().getComments(); | ||
| 128 | - if(comments==null)return; | 136 | + comments = commentPage.getData().getComments(); |
| 129 | recyclerView.setAdapter(commentAdapter); | 137 | recyclerView.setAdapter(commentAdapter); |
| 138 | + if (comments == null) return; | ||
| 130 | commentAdapter.addItems(comments); | 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,13 +154,21 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 147 | 154 | ||
| 148 | @Override | 155 | @Override |
| 149 | public void praiseComment(CommentItem commentItem) { | 156 | public void praiseComment(CommentItem commentItem) { |
| 157 | + | ||
| 150 | commentUtil.praiseComment(programID, userID, commentItem.getId(), new CommentCallback() { | 158 | commentUtil.praiseComment(programID, userID, commentItem.getId(), new CommentCallback() { |
| 151 | @Override | 159 | @Override |
| 152 | public void onResponse(ErrorMessage errorMessage) { | 160 | public void onResponse(ErrorMessage errorMessage) { |
| 153 | if (errorMessage != null && errorMessage.getErrorCode().equals("0")) { | 161 | if (errorMessage != null && errorMessage.getErrorCode().equals("0")) { |
| 154 | Toast.makeText(getActivity(), "点赞成功", Toast.LENGTH_SHORT).show(); | 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 | } else Toast.makeText(getActivity(), "点赞失败", Toast.LENGTH_SHORT).show(); | 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,7 +177,8 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 162 | 177 | ||
| 163 | 178 | ||
| 164 | @Override | 179 | @Override |
| 165 | - public void sendComment(String s) { | 180 | + public void sendComment(final String s) { |
| 181 | + | ||
| 166 | commentUtil.insertComment(programID, userID, s, new CommentCallback() { | 182 | commentUtil.insertComment(programID, userID, s, new CommentCallback() { |
| 167 | @Override | 183 | @Override |
| 168 | public void onResponse(ErrorMessage errorMessage) { | 184 | public void onResponse(ErrorMessage errorMessage) { |
| @@ -170,11 +186,29 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | @@ -170,11 +186,29 @@ public class CommentFragment extends Fragment implements View.OnClickListener, C | ||
| 170 | 186 | ||
| 171 | Toast.makeText(getActivity(), "评论成功", Toast.LENGTH_SHORT).show(); | 187 | Toast.makeText(getActivity(), "评论成功", Toast.LENGTH_SHORT).show(); |
| 172 | edit_comment.setText("我来说两句....."); | 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 | } else Toast.makeText(getActivity(), "评论失败", Toast.LENGTH_SHORT).show(); | 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/fragment/chat/MessageContentInfo.java
| @@ -67,9 +67,9 @@ public class MessageContentInfo { | @@ -67,9 +67,9 @@ public class MessageContentInfo { | ||
| 67 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": 送了" + messagecontent, message.getUserInfo().getHeadUrl(), true)); | 67 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": 送了" + messagecontent, message.getUserInfo().getHeadUrl(), true)); |
| 68 | } else if (messageType.equals(ChatRoom)) { | 68 | } else if (messageType.equals(ChatRoom)) { |
| 69 | if (message.getUserInfo().getUserId().equals(ChatUtil.getCurrentUserInfo().getUserId())) { | 69 | if (message.getUserInfo().getUserId().equals(ChatUtil.getCurrentUserInfo().getUserId())) { |
| 70 | - messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); | 70 | + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " : ", message.getUserInfo().getHeadUrl(), false)); |
| 71 | } else { | 71 | } else { |
| 72 | - messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), " :" + messagecontent, message.getUserInfo().getHeadUrl(), true)); | 72 | + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), " : " + messagecontent, message.getUserInfo().getHeadUrl(), true)); |
| 73 | } | 73 | } |
| 74 | if (onChatListener != null) { | 74 | if (onChatListener != null) { |
| 75 | onChatListener.onbarrage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); | 75 | onChatListener.onbarrage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); |
| @@ -85,7 +85,7 @@ public class MessageContentInfo { | @@ -85,7 +85,7 @@ public class MessageContentInfo { | ||
| 85 | if (onChatListener != null) { | 85 | if (onChatListener != null) { |
| 86 | onChatListener.onbarrage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "来了", "")); | 86 | onChatListener.onbarrage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "来了", "")); |
| 87 | } | 87 | } |
| 88 | - messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": " + "来了", message.getUserInfo().getHeadUrl(), true)); | 88 | + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), " : " + "来了", message.getUserInfo().getHeadUrl(), true)); |
| 89 | } | 89 | } |
| 90 | if (onChatListener != null) { | 90 | if (onChatListener != null) { |
| 91 | onChatListener.onchat(messageContentArrayList); | 91 | onChatListener.onchat(messageContentArrayList); |
| @@ -112,7 +112,7 @@ public class MessageContentInfo { | @@ -112,7 +112,7 @@ public class MessageContentInfo { | ||
| 112 | String messageType = cnMessageModle.getType(); | 112 | String messageType = cnMessageModle.getType(); |
| 113 | if (messageType.equals(ChatRoom)) { | 113 | if (messageType.equals(ChatRoom)) { |
| 114 | onChatListener.onbarrage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); | 114 | onChatListener.onbarrage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); |
| 115 | - messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); | 115 | + messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " : ", message.getUserInfo().getHeadUrl(), false)); |
| 116 | onChatListener.onchat(messageContentArrayList); | 116 | onChatListener.onchat(messageContentArrayList); |
| 117 | } | 117 | } |
| 118 | } catch (Exception e) { | 118 | } catch (Exception e) { |
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/color/chat_send_text.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:color="#515151" android:state_selected="true" /> | ||
| 4 | + <item android:color="#515151" android:state_pressed="true" /> | ||
| 5 | + <item android:color="#515151" android:state_focused="true" /> | ||
| 6 | + <item android:color="#656565" /> | ||
| 7 | +</selector> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/src/main/res/drawable-xhdpi/btn_expression_nor.png
0 → 100644
705 Bytes
app/src/main/res/drawable-xhdpi/btn_expression_sel.png
0 → 100644
682 Bytes
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/btn_chat_send_nor.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 | + <solid android:color="#e6e6e6" /> | ||
| 5 | + <corners android:radius="2dp" /> | ||
| 6 | + <stroke android:width="1px" android:color="#bfbfbf" android:dashWidth="1px" | ||
| 7 | + android:dashGap="0dp" /> | ||
| 8 | +</shape> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/drawable/btn_chat_send_sel.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 | + <solid android:color="#d2d2d2" /> | ||
| 5 | + <corners android:radius="2dp" /> | ||
| 6 | + <stroke android:width="1px" android:color="#ababab" android:dashWidth="1px" | ||
| 7 | + android:dashGap="0dp" /> | ||
| 8 | +</shape> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/drawable/btn_input.png
0 → 100644
1 KB
app/src/main/res/drawable/btn_send_chat_selector.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | + | ||
| 3 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:drawable="@drawable/btn_chat_send_sel" android:state_pressed="true" /> | ||
| 5 | + <item android:drawable="@drawable/btn_chat_send_nor" android:state_pressed="false" /> | ||
| 6 | + <item android:drawable="@drawable/btn_chat_send_nor" /> | ||
| 7 | +</selector> | ||
| 0 | \ No newline at end of file | 8 | \ No newline at end of file |
app/src/main/res/drawable/chat_gift_bg.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 | + android:useLevel="false"> | ||
| 5 | + <solid android:color="#454543" /> | ||
| 6 | + <size android:height="24dp" /> | ||
| 7 | + <corners | ||
| 8 | + android:bottomLeftRadius="8dp" | ||
| 9 | + android:bottomRightRadius="8dp" | ||
| 10 | + android:topLeftRadius="8dp" | ||
| 11 | + android:topRightRadius="8dp" /> <!-- 设置四个角的半径 --> | ||
| 12 | + | ||
| 13 | +</shape> | ||
| 0 | \ No newline at end of file | 14 | \ No newline at end of file |
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 | \ No newline at end of file | 14 | \ No newline at end of file |
app/src/main/res/drawable/edit_text.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 | + <solid android:color="#e6e6e6" /> | ||
| 5 | + <corners android:radius="2dp" /> | ||
| 6 | + <stroke android:width="1dp" android:color="#bfbfbf" android:dashWidth="1dp" | ||
| 7 | + android:dashGap="0dp" /> | ||
| 8 | +</shape> | ||
| 0 | \ No newline at end of file | 9 | \ No newline at end of file |
app/src/main/res/drawable/expression_face_selector.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | + <item android:state_pressed="true" android:drawable="@drawable/btn_expression_sel" /> | ||
| 4 | + <item android:state_pressed="false" android:drawable="@drawable/btn_expression_nor" /> | ||
| 5 | +</selector> |
app/src/main/res/drawable/switch_track_dan_off.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | ||
| 3 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | 3 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| 4 | - <solid android:color="#CC000000" /> | ||
| 5 | - <corners android:radius="9dp" /> | 4 | + <solid android:color="#555756" /> |
| 5 | + | ||
| 6 | + | ||
| 7 | + <corners android:radius="30dp" /> | ||
| 6 | <size | 8 | <size |
| 7 | android:height="18dp" /> | 9 | android:height="18dp" /> |
| 8 | <stroke | 10 | <stroke |
app/src/main/res/drawable/switch_track_dan_on.xml
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | 3 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> |
| 4 | <solid android:color="#FF4E51" /> | 4 | <solid android:color="#FF4E51" /> |
| 5 | - <corners android:radius="9dp" /> | 5 | + <corners android:radius="30dp" /> |
| 6 | <size | 6 | <size |
| 7 | android:height="18dp" /> | 7 | android:height="18dp" /> |
| 8 | <stroke | 8 | <stroke |
app/src/main/res/layout/fragment_chat.xml
| @@ -38,9 +38,11 @@ | @@ -38,9 +38,11 @@ | ||
| 38 | android:id="@+id/edit_layout" | 38 | android:id="@+id/edit_layout" |
| 39 | android:layout_width="match_parent" | 39 | android:layout_width="match_parent" |
| 40 | android:layout_height="50dp" | 40 | android:layout_height="50dp" |
| 41 | + android:background="#555756" | ||
| 42 | + android:orientation="horizontal" | ||
| 41 | android:layout_alignParentBottom="true" | 43 | android:layout_alignParentBottom="true" |
| 42 | - android:background="#e0000000" | ||
| 43 | - android:orientation="horizontal"> | 44 | + android:layout_alignParentLeft="true" |
| 45 | + android:layout_alignParentStart="true"> | ||
| 44 | 46 | ||
| 45 | <ImageView | 47 | <ImageView |
| 46 | android:id="@+id/sendMessage" | 48 | android:id="@+id/sendMessage" |
| @@ -83,6 +85,7 @@ | @@ -83,6 +85,7 @@ | ||
| 83 | android:visibility="invisible"> | 85 | android:visibility="invisible"> |
| 84 | 86 | ||
| 85 | <android.support.v7.widget.RecyclerView | 87 | <android.support.v7.widget.RecyclerView |
| 88 | + android:padding="5dp" | ||
| 86 | android:id="@+id/recycler_gift" | 89 | android:id="@+id/recycler_gift" |
| 87 | android:layout_width="match_parent" | 90 | android:layout_width="match_parent" |
| 88 | android:layout_height="wrap_content" | 91 | android:layout_height="wrap_content" |
app/src/main/res/layout/fragment_gift_receycel.xml
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | </data> | 10 | </data> |
| 11 | 11 | ||
| 12 | <RelativeLayout | 12 | <RelativeLayout |
| 13 | + android:background="@drawable/record_end" | ||
| 13 | android:id="@+id/ll_item" | 14 | android:id="@+id/ll_item" |
| 14 | android:layout_width="match_parent" | 15 | android:layout_width="match_parent" |
| 15 | android:layout_height="wrap_content"> | 16 | android:layout_height="wrap_content"> |
app/src/main/res/layout/fragment_player_live.xml
| @@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
| 21 | 21 | ||
| 22 | <RelativeLayout | 22 | <RelativeLayout |
| 23 | android:id="@+id/contentLayout" | 23 | android:id="@+id/contentLayout" |
| 24 | - android:background="@android:color/black" | 24 | + android:background="#282828" |
| 25 | android:layout_width="match_parent" | 25 | android:layout_width="match_parent" |
| 26 | android:layout_height="match_parent" | 26 | android:layout_height="match_parent" |
| 27 | android:layout_below="@+id/videoView"> | 27 | android:layout_below="@+id/videoView"> |
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 | \ No newline at end of file | 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 | \ No newline at end of file | 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 | \ No newline at end of file | 103 | \ No newline at end of file |
app/src/main/res/layout/item_list_right.xml
| @@ -11,64 +11,99 @@ | @@ -11,64 +11,99 @@ | ||
| 11 | </data> | 11 | </data> |
| 12 | 12 | ||
| 13 | <RelativeLayout | 13 | <RelativeLayout |
| 14 | + | ||
| 14 | android:layout_width="match_parent" | 15 | android:layout_width="match_parent" |
| 15 | - android:layout_height="match_parent"> | 16 | + android:layout_height="wrap_content" |
| 17 | + android:padding="10dp"> | ||
| 16 | 18 | ||
| 17 | - <LinearLayout | 19 | + <RelativeLayout |
| 18 | android:id="@+id/left_lin" | 20 | android:id="@+id/left_lin" |
| 19 | - | ||
| 20 | android:layout_width="wrap_content" | 21 | android:layout_width="wrap_content" |
| 21 | android:layout_height="50dp" | 22 | android:layout_height="50dp" |
| 22 | - android:orientation="horizontal"> | 23 | + android:layout_alignParentLeft="true" |
| 24 | + android:background="@drawable/chat_gift_bg" | ||
| 23 | 25 | ||
| 24 | - <com.cnlive.gundam.user.view.CircleImageView | ||
| 25 | - android:layout_width="20dp" | ||
| 26 | - android:layout_height="20dp" | ||
| 27 | - app:imageUrl="@{user.icon}"/> | 26 | + android:paddingBottom="5dp" |
| 27 | + android:paddingLeft="10dp" | ||
| 28 | + android:paddingRight="10dp" | ||
| 29 | + android:paddingTop="5dp"> | ||
| 28 | 30 | ||
| 29 | - <TextView | ||
| 30 | - android:layout_width="wrap_content" | ||
| 31 | - android:layout_height="wrap_content" | ||
| 32 | - android:textColor="@android:color/white" | ||
| 33 | - android:text="@{user.name}" /> | 31 | + <ImageView |
| 34 | 32 | ||
| 35 | - <TextView | 33 | + android:id="@+id/iv_left_user_icon" |
| 34 | + android:layout_width="30dp" | ||
| 35 | + android:layout_height="30dp" | ||
| 36 | + android:layout_centerVertical="true" | ||
| 37 | + app:imageUrl="@{user.icon}" /> | ||
| 38 | + | ||
| 39 | + <LinearLayout | ||
| 36 | android:layout_width="wrap_content" | 40 | android:layout_width="wrap_content" |
| 37 | android:layout_height="wrap_content" | 41 | android:layout_height="wrap_content" |
| 38 | - android:textColor="@android:color/white" | ||
| 39 | - android:text="@{user.messaage}" /> | ||
| 40 | - </LinearLayout> | 42 | + android:layout_marginLeft="10dp" |
| 43 | + android:layout_toRightOf="@+id/iv_left_user_icon" | ||
| 44 | + android:orientation="vertical"> | ||
| 45 | + | ||
| 46 | + <TextView | ||
| 47 | + android:id="@+id/tv_left_user_name" | ||
| 48 | + android:layout_width="wrap_content" | ||
| 49 | + android:layout_height="wrap_content" | ||
| 50 | + android:text='@{user.name}' | ||
| 51 | + android:textColor="@android:color/white" /> | ||
| 52 | + | ||
| 53 | + <TextView | ||
| 54 | + android:id="@+id/tv_left_user_mewssage" | ||
| 55 | + android:layout_width="wrap_content" | ||
| 56 | + android:layout_height="wrap_content" | ||
| 57 | + android:layout_marginTop="5dp" | ||
| 58 | + android:text='@{user.messaage}' | ||
| 59 | + android:textColor="@android:color/white" /> | ||
| 60 | + </LinearLayout> | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + </RelativeLayout> | ||
| 41 | 64 | ||
| 42 | 65 | ||
| 43 | 66 | ||
| 44 | <LinearLayout | 67 | <LinearLayout |
| 45 | android:id="@+id/right_lin" | 68 | android:id="@+id/right_lin" |
| 69 | + android:background="@drawable/chat_gift_bg" | ||
| 46 | 70 | ||
| 71 | + android:paddingBottom="5dp" | ||
| 72 | + android:paddingLeft="10dp" | ||
| 73 | + android:paddingRight="10dp" | ||
| 74 | + android:paddingTop="5dp" | ||
| 47 | android:layout_alignParentRight="true" | 75 | android:layout_alignParentRight="true" |
| 48 | android:layout_width="wrap_content" | 76 | android:layout_width="wrap_content" |
| 49 | android:layout_height="50dp" | 77 | android:layout_height="50dp" |
| 50 | android:orientation="horizontal"> | 78 | android:orientation="horizontal"> |
| 51 | 79 | ||
| 52 | <TextView | 80 | <TextView |
| 81 | + android:layout_gravity="center_vertical" | ||
| 82 | + android:layout_marginRight="10dp" | ||
| 53 | android:layout_width="wrap_content" | 83 | android:layout_width="wrap_content" |
| 54 | android:layout_height="wrap_content" | 84 | android:layout_height="wrap_content" |
| 55 | android:textColor="@android:color/white" | 85 | android:textColor="@android:color/white" |
| 56 | android:text="@{user.messaage}" /> | 86 | android:text="@{user.messaage}" /> |
| 57 | <TextView | 87 | <TextView |
| 88 | + android:layout_gravity="center_vertical" | ||
| 89 | + android:visibility="gone" | ||
| 58 | android:layout_width="wrap_content" | 90 | android:layout_width="wrap_content" |
| 59 | android:layout_height="wrap_content" | 91 | android:layout_height="wrap_content" |
| 60 | android:textColor="@android:color/white" | 92 | android:textColor="@android:color/white" |
| 61 | android:text="@{user.name}" /> | 93 | android:text="@{user.name}" /> |
| 62 | 94 | ||
| 63 | - <com.cnlive.gundam.user.view.CircleImageView | ||
| 64 | - android:layout_width="20dp" | ||
| 65 | - android:layout_height="20dp" | 95 | + <ImageView |
| 96 | + android:layout_gravity="center_vertical" | ||
| 97 | + android:layout_width="30dp" | ||
| 98 | + android:layout_height="30dp" | ||
| 66 | app:imageUrl="@{user.icon}" | 99 | app:imageUrl="@{user.icon}" |
| 67 | /> | 100 | /> |
| 68 | 101 | ||
| 69 | </LinearLayout> | 102 | </LinearLayout> |
| 70 | 103 | ||
| 71 | 104 | ||
| 105 | + | ||
| 106 | + | ||
| 72 | </RelativeLayout> | 107 | </RelativeLayout> |
| 73 | 108 | ||
| 74 | </layout> | 109 | </layout> |
| 75 | \ No newline at end of file | 110 | \ 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 | \ No newline at end of file | 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 | \ No newline at end of file | 23 | \ No newline at end of file |
app/src/main/res/layout/layout_input.xml
0 → 100644
| 1 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + xmlns:emojicon="http://schemas.android.com/apk/res-auto" | ||
| 3 | + android:layout_width="match_parent" | ||
| 4 | + android:layout_height="48dp" | ||
| 5 | + android:background="@android:color/white"> | ||
| 6 | + | ||
| 7 | + <ImageView | ||
| 8 | + android:layout_width="match_parent" | ||
| 9 | + android:layout_height="1px" | ||
| 10 | + android:background="@color/main_tab_spinner_line_color" /> | ||
| 11 | + | ||
| 12 | + <ImageView | ||
| 13 | + android:id="@+id/emoticons_button" | ||
| 14 | + android:layout_width="30dp" | ||
| 15 | + android:layout_height="30dp" | ||
| 16 | + android:layout_centerVertical="true" | ||
| 17 | + android:layout_marginLeft="8dp" | ||
| 18 | + android:src="@drawable/expression_face_selector" /> | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + <LinearLayout | ||
| 22 | + android:layout_width="match_parent" | ||
| 23 | + android:layout_height="30dp" | ||
| 24 | + android:layout_centerVertical="true" | ||
| 25 | + android:layout_marginLeft="8dp" | ||
| 26 | + android:layout_toLeftOf="@+id/post_button" | ||
| 27 | + android:layout_toRightOf="@+id/emoticons_button" | ||
| 28 | + android:background="@drawable/edit_text" | ||
| 29 | + android:orientation="horizontal"> | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + <EditText | ||
| 33 | + android:id="@+id/chat_content" | ||
| 34 | + android:layout_width="match_parent" | ||
| 35 | + android:layout_height="match_parent" | ||
| 36 | + android:background="@null" | ||
| 37 | + android:gravity="center_vertical" | ||
| 38 | + android:hint="@string/input_button_text" | ||
| 39 | + android:imeOptions="actionSend" | ||
| 40 | + android:inputType="textLongMessage" | ||
| 41 | + android:maxLength="120" | ||
| 42 | + android:paddingLeft="8dp" | ||
| 43 | + android:textColor="@color/text_input_color" | ||
| 44 | + android:textColorHint="@color/text_hint_color" | ||
| 45 | + android:textSize="16sp" | ||
| 46 | + /> | ||
| 47 | + </LinearLayout> | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + <TextView | ||
| 51 | + android:id="@+id/post_button" | ||
| 52 | + android:layout_width="50dp" | ||
| 53 | + android:layout_height="30dp" | ||
| 54 | + android:layout_alignParentRight="true" | ||
| 55 | + android:layout_centerVertical="true" | ||
| 56 | + android:layout_marginLeft="8dp" | ||
| 57 | + android:layout_marginRight="8dp" | ||
| 58 | + android:background="@drawable/btn_send_chat_selector" | ||
| 59 | + android:gravity="center" | ||
| 60 | + android:text="发送" | ||
| 61 | + android:textColor="@color/chat_send_text" | ||
| 62 | + android:textSize="16sp" /> | ||
| 63 | + | ||
| 64 | +</RelativeLayout> | ||
| 0 | \ No newline at end of file | 65 | \ 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 | \ No newline at end of file | 17 | \ No newline at end of file |
app/src/main/res/values/colors.xml
| @@ -25,4 +25,10 @@ | @@ -25,4 +25,10 @@ | ||
| 25 | <color name="record_title_bg_default">#919191</color> | 25 | <color name="record_title_bg_default">#919191</color> |
| 26 | <color name="record_title_bg_selected">#616060</color> | 26 | <color name="record_title_bg_selected">#616060</color> |
| 27 | <color name="ffcc00">#ffcc00</color> | 27 | <color name="ffcc00">#ffcc00</color> |
| 28 | + <color name="white">#ffffff</color> | ||
| 29 | + <color name="color_text_normal_999">#999</color> | ||
| 30 | + <color name="color_cutline_ececec">#ececec</color> | ||
| 31 | + <color name="color_9d9d9d">#9d9d9d</color> | ||
| 32 | + | ||
| 33 | + <color name="main_tab_spinner_line_color">#D5D5D5</color> | ||
| 28 | </resources> | 34 | </resources> |
app/src/main/res/values/strings.xml
| @@ -40,6 +40,8 @@ | @@ -40,6 +40,8 @@ | ||
| 40 | <string name="ugc_live">直播</string> | 40 | <string name="ugc_live">直播</string> |
| 41 | <string name="ugc_vod">回放</string> | 41 | <string name="ugc_vod">回放</string> |
| 42 | 42 | ||
| 43 | + <string name="user_token_invalid">用户的token失效,请重新登录</string> | ||
| 44 | + | ||
| 43 | <string name="verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&plat=a&appId=%s </string> | 45 | <string name="verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&plat=a&appId=%s </string> |
| 44 | <string name="debug_verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&plat=a&appId=%s&type=0 </string> | 46 | <string name="debug_verified_url" formatted="false">https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp?sid=%s&plat=a&appId=%s&type=0 </string> |
| 45 | 47 |