diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index 2b3794711..05c947e8c 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -74,6 +74,9 @@ android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize" /> + diff --git a/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java b/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java index d7f50e226..9a8db9288 100644 --- a/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java @@ -1,10 +1,14 @@ package com.yunbao.common.activity; import android.annotation.SuppressLint; +import android.content.Context; import android.content.Intent; import android.graphics.Color; +import android.util.SparseArray; import android.view.View; import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -25,6 +29,9 @@ import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.OpenAdManager; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.NineGridLayout; import com.yunbao.common.views.TopGradual; @@ -49,6 +56,9 @@ public class CommunityDetailsActivity extends AbsActivity { private ImageView userAvatar; private ImageView like; private TextView replyCount; + private EditText comment; + private ImageView send; + private boolean isComment = false; @Override protected int getLayoutId() { @@ -76,6 +86,8 @@ public class CommunityDetailsActivity extends AbsActivity { } private void initView() { + send = findViewById(R.id.send); + comment = findViewById(R.id.comment); replyCount = findViewById(R.id.replyCount); like = findViewById(R.id.like); userAvatar = findViewById(R.id.userAvatar); @@ -128,21 +140,76 @@ public class CommunityDetailsActivity extends AbsActivity { like.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (activeBean.getIs_love().equals("1")) { - - } else { - - } + CommonHttpUtil.dynamicLove(activeBean.getId(), new HttpCallback() { + @SuppressLint("SetTextI18n") + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ToastUtil.show(msg); + if (activeBean.getIs_love().equals("1")) { + activeBean.setIs_love("0"); + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like01, like); + likeCount.setText(Integer.parseInt(activeBean.getLove_num()) - 1 + "人觉得很赞"); + } else { + activeBean.setIs_love("1"); + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like, like); + likeCount.setText(Integer.parseInt(activeBean.getLove_num()) + 1 + "人觉得很赞"); + } + } + } + }); } }); findViewById(R.id.setting).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + SparseArray array = new SparseArray<>(); + array.append(0, "举报"); + array.append(1, "不感兴趣"); + DialogUitl.showStringArrayDialog(CommunityDetailsActivity.this, array, new DialogUitl.StringArrayDialogCallback() { + @Override + public void onItemClick(String text, int tag) { + if (tag == 0) { + RouteUtil.forwardCommentReportActivity(activeBean.getId(), activeBean.getId()); + } else { + } + } + }); + } + }); + send.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommonHttpUtil.dynamicReply(activeBean.getId(), isComment ? replyComment.getId() : "0", comment.getText().toString(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + comment.setText(""); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(comment, InputMethodManager.SHOW_FORCED); + imm.hideSoftInputFromWindow(comment.getWindowToken(), 0); //强制隐藏键盘 + getReply(); + } + }); + } + }); + comment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + isComment = false; + } + }); + findViewById(R.id.userLayout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + UserHomeActivity.forwardUserHomeActivity(CommunityDetailsActivity.this, activeBean.getUser_id()); } }); } + //回复评论 + CommentBean replyComment; + private void getReply() { CommonHttpUtil.getCommunityComment(activeBean.getId(), activeBean.getUser_id(), new HttpCallback() { @SuppressLint("SetTextI18n") @@ -151,6 +218,22 @@ public class CommunityDetailsActivity extends AbsActivity { List list = JSON.parseArray(Arrays.toString(info), CommentBean.class); if (list != null) { commentAdapter = new CommentAdapter(mContext, list); + commentAdapter.setOnItemClickListener(new CommentAdapter.onItemClickListener() { + @Override + public void onReply(CommentBean commentBean) { + replyComment = commentBean; + isComment = true; + comment.requestFocus(); + //键盘输入法管理器 + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(comment, 0); + } + + @Override + public void onReport(CommentBean commentBean) { + RouteUtil.forwardCommentReportActivity(activeBean.getId(), commentBean.getId()); + } + }); commentRecyclerView.setAdapter(commentAdapter); replyCount.setText("评论 " + list.size()); } diff --git a/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java b/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java index df21dcd3f..3b8209c35 100644 --- a/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java @@ -1,13 +1,44 @@ package com.yunbao.common.activity; +import android.content.Context; import android.content.Intent; +import android.graphics.Outline; import android.view.View; +import android.view.ViewOutlineProvider; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.ms.banner.Banner; +import com.ms.banner.listener.OnBannerClickListener; +import com.yunbao.common.Constants; import com.yunbao.common.R; +import com.yunbao.common.adapter.UserHomeImgAdapter; +import com.yunbao.common.bean.UserHomeImgBean; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.TopGradual; +import com.yunbao.common.views.UserHomeImgsViewHolder; + +import java.util.ArrayList; +import java.util.List; public class UserHomeActivity extends AbsActivity { + String uid; + Banner mBanner; + RecyclerView imgsRecyclerView; + UserHomeImgAdapter userHomeImgAdapter; - View bodyLayout; + List bannerImgList = new ArrayList<>(); + List tempList; + + public static void forwardUserHomeActivity(Context content, String uid) { + Intent intent = new Intent(content, UserHomeActivity.class); + intent.putExtra(Constants.TO_UID, String.valueOf(97717)); + content.startActivity(intent); + } @Override protected int getLayoutId() { @@ -21,6 +52,66 @@ public class UserHomeActivity extends AbsActivity { @Override protected void main() { + uid = getIntent().getStringExtra(Constants.TO_UID); + if (StringUtil.isEmpty(uid)) { + ToastUtil.show("用户不存在"); + finish(); + return; + } + initView(); + initUseData(); + initUserImgs(); + } + + private void initView() { + mBanner = (Banner) findViewById(R.id.banner); + imgsRecyclerView = findViewById(R.id.imgsRecyclerView); + imgsRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); + imgsRecyclerView.addItemDecoration(new TopGradual()); + imgsRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); + } + + private void initUserImgs() { + mBanner.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); + } + }); + LiveNetManager.get(UserHomeActivity.this).getUserHomeBanner(uid, new HttpCallback>() { + @Override + public void onSuccess(List data) { + bannerImgList = data; + tempList = new ArrayList<>(); + for (int i = 0; i < data.size(); i++) { + tempList.add(new UserHomeImgBean(data.get(i))); + } + tempList.get(0).setShow(true); + userHomeImgAdapter = new UserHomeImgAdapter(UserHomeActivity.this, tempList); + imgsRecyclerView.setAdapter(userHomeImgAdapter); + mBanner.setAutoPlay(false).setPages(bannerImgList, new UserHomeImgsViewHolder()).setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int position) { + + } + }).start(); + } + + @Override + public void onError(String error) { + + } + }); + findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + + private void initUseData() { + } @Override diff --git a/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java index a5054e2a5..836deefd9 100644 --- a/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java @@ -18,11 +18,17 @@ import com.yunbao.common.bean.CommentBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.views.TopGradual; +import java.util.ArrayList; import java.util.List; public class CommentAdapter extends RecyclerView.Adapter { private List commentBeanList; private Context mContext; + private onItemClickListener onItemClickListener; + + public void setOnItemClickListener(CommentAdapter.onItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } public CommentAdapter(Context content, List commentBeanList) { this.mContext = content; @@ -52,29 +58,53 @@ public class CommentAdapter extends RecyclerView.Adapter { private TextView name; private TextView content; private TextView report; + private TextView replyTextView; private RoundedImageView mAvatar01; - private RoundedImageView mAvatar02; private TextView replyContent; private TextView replyCount; private RecyclerView recyclerView; private LinearLayout replyLayout; + private TextView firstName; + private TextView isAuth; public CommentViewHolder(@NonNull View itemView) { super(itemView); + firstName = itemView.findViewById(R.id.firstName); mAvatar = itemView.findViewById(R.id.avatar); name = itemView.findViewById(R.id.name); content = itemView.findViewById(R.id.content); + replyTextView = itemView.findViewById(R.id.replyTextView); report = itemView.findViewById(R.id.report); mAvatar01 = itemView.findViewById(R.id.avatar01); - mAvatar02 = itemView.findViewById(R.id.avatar02); + isAuth = itemView.findViewById(R.id.isAuth); replyContent = itemView.findViewById(R.id.replyContent); replyCount = itemView.findViewById(R.id.expand); replyLayout = itemView.findViewById(R.id.replyLayout); recyclerView = itemView.findViewById(R.id.recyclerView); + report.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + CommentBean bean = (CommentBean) v.getTag(); + onItemClickListener.onReport(bean); + } + } + }); + replyTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + CommentBean bean = (CommentBean) v.getTag(); + onItemClickListener.onReply(bean); + } + } + }); } @SuppressLint("SetTextI18n") public void setData(CommentBean bean) { + report.setTag(bean); + replyTextView.setTag(bean); ImgLoader.display(itemView.getContext(), bean.getUser_avatar(), mAvatar); name.setText(bean.getUser_name()); content.setText(bean.getContent()); @@ -83,35 +113,45 @@ public class CommentAdapter extends RecyclerView.Adapter { if (bean.getReplyCommentList().size() > 0) { replyContent.setText(bean.getReplyCommentList().get(0).getContent()); ImgLoader.display(itemView.getContext(), bean.getReplyCommentList().get(0).getUser_avatar(), mAvatar01); - ImgLoader.display(itemView.getContext(), bean.getReplyCommentList().get(0).getUser_avatar(), mAvatar02); - replyLayout.setVisibility(View.VISIBLE); - } else if (bean.getReplyCommentList().size() > 1) { - replyCount.setVisibility(View.VISIBLE); + firstName.setText(bean.getReplyCommentList().get(0).getUser_name()); replyLayout.setVisibility(View.VISIBLE); } else { replyLayout.setVisibility(View.GONE); replyCount.setVisibility(View.GONE); } - recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); - recyclerView.addItemDecoration(new TopGradual()); - CommentReplyAdapter commentReplyAdapter = new CommentReplyAdapter(mContext, bean.getReplyCommentList()); - recyclerView.setAdapter(commentReplyAdapter); - recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); - replyCount.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!bean.isShow()) { - recyclerView.setVisibility(View.VISIBLE); - replyCount.setText("收起"); - } else { - recyclerView.setVisibility(View.GONE); - replyCount.setText("共" + bean.getReplyCommentList().size() + "条回复>"); + if (bean.getReplyCommentList().size() > 1) { + replyCount.setVisibility(View.VISIBLE); + replyLayout.setVisibility(View.VISIBLE); + recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + recyclerView.addItemDecoration(new TopGradual()); + List tempList = new ArrayList<>(); + tempList.addAll(bean.getReplyCommentList()); + tempList.remove(0); + CommentReplyAdapter commentReplyAdapter = new CommentReplyAdapter(mContext, tempList); + recyclerView.setAdapter(commentReplyAdapter); + recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); + replyCount.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (!bean.isShow()) { + recyclerView.setVisibility(View.VISIBLE); + replyCount.setText("收起"); + } else { + recyclerView.setVisibility(View.GONE); + replyCount.setText("共" + bean.getReplyCommentList().size() + "条回复>"); + } + bean.setShow(!bean.isShow()); } - bean.setShow(!bean.isShow()); - } - }); + }); + } } } } + public interface onItemClickListener { + void onReply(CommentBean activeBean); + + void onReport(CommentBean activeBean); + } + } diff --git a/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java index dc0527fa0..41458d034 100644 --- a/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java @@ -47,21 +47,18 @@ public class CommentReplyAdapter extends RecyclerView.Adapter { class CommentViewHolder extends RecyclerView.ViewHolder { private TextView name; private RoundedImageView mAvatar01; - private RoundedImageView mAvatar02; private TextView replyContent; public CommentViewHolder(@NonNull View itemView) { super(itemView); name = itemView.findViewById(R.id.name); mAvatar01 = itemView.findViewById(R.id.avatar01); - mAvatar02 = itemView.findViewById(R.id.avatar02); replyContent = itemView.findViewById(R.id.replyContent); } @SuppressLint("SetTextI18n") public void setData(CommentBean.ReplyComment bean) { ImgLoader.display(itemView.getContext(), bean.getUser_avatar(), mAvatar01); - ImgLoader.display(itemView.getContext(), bean.getUser_avatar(), mAvatar02); name.setText(bean.getUser_name()); replyContent.setText(bean.getContent()); } diff --git a/common/src/main/java/com/yunbao/common/adapter/UserHomeImgAdapter.java b/common/src/main/java/com/yunbao/common/adapter/UserHomeImgAdapter.java new file mode 100644 index 000000000..2379bd115 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/UserHomeImgAdapter.java @@ -0,0 +1,86 @@ +package com.yunbao.common.adapter; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.bean.UserHomeImgBean; +import com.yunbao.common.glide.ImgLoader; + +import java.util.List; + +public class UserHomeImgAdapter extends RecyclerView.Adapter { + private List commentBeanList; + private Context mContext; + private onItemClickListener onItemClickListener; + + public void setOnItemClickListener(UserHomeImgAdapter.onItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + public UserHomeImgAdapter(Context content, List commentBeanList) { + this.mContext = content; + this.commentBeanList = commentBeanList; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_home_img, parent, false); + return new CommentViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + CommentViewHolder commentViewHolder = (CommentViewHolder) holder; + commentViewHolder.setData(commentBeanList.get(position)); + } + + @Override + public int getItemCount() { + return commentBeanList.size(); + } + + class CommentViewHolder extends RecyclerView.ViewHolder { + private RoundedImageView mAvatar; + + public CommentViewHolder(@NonNull View itemView) { + super(itemView); + mAvatar = itemView.findViewById(R.id.avatar); + mAvatar.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onItemClickListener.onImgItem((String) v.getTag()); + } + }); + } + + @SuppressLint("SetTextI18n") + public void setData(UserHomeImgBean bean) { + mAvatar.setTag(bean); + ImgLoader.display(itemView.getContext(), bean.getImgurl(), mAvatar); + if (bean.isShow()) { + ViewGroup.LayoutParams viewGroup = mAvatar.getLayoutParams(); + viewGroup.height = 200; + viewGroup.width = 200; + mAvatar.setLayoutParams(viewGroup); + } else { + ViewGroup.LayoutParams viewGroup = mAvatar.getLayoutParams(); + viewGroup.height = 100; + viewGroup.width = 100; + mAvatar.setLayoutParams(viewGroup); + } + } + } + + public interface onItemClickListener { + void onImgItem(String activeBean); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/CommentBean.java b/common/src/main/java/com/yunbao/common/bean/CommentBean.java index 49e4c522b..47d2842fc 100644 --- a/common/src/main/java/com/yunbao/common/bean/CommentBean.java +++ b/common/src/main/java/com/yunbao/common/bean/CommentBean.java @@ -18,6 +18,15 @@ public class CommentBean extends BaseModel { private String user_id; private String user_avatar; private List child; + + public List getChild() { + return child; + } + + public void setChild(List child) { + this.child = child; + } + private boolean isShow; public String getId() { diff --git a/common/src/main/java/com/yunbao/common/bean/NewCommunityType.java b/common/src/main/java/com/yunbao/common/bean/NewCommunityType.java new file mode 100644 index 000000000..3a1bbb473 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NewCommunityType.java @@ -0,0 +1,70 @@ +package com.yunbao.common.bean; + +public class NewCommunityType extends BaseModel { + private int id; + private String talk_name; + private String img; + private String is_hot; + private String hot_time; + private String sort; + + public NewCommunityType() { + } + + public NewCommunityType(int id, String talk_name, String img, String is_hot, String hot_time, String sort) { + this.id = id; + this.talk_name = talk_name; + this.img = img; + this.is_hot = is_hot; + this.hot_time = hot_time; + this.sort = sort; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTalk_name() { + return talk_name; + } + + public void setTalk_name(String talk_name) { + this.talk_name = talk_name; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getIs_hot() { + return is_hot; + } + + public void setIs_hot(String is_hot) { + this.is_hot = is_hot; + } + + public String getHot_time() { + return hot_time; + } + + public void setHot_time(String hot_time) { + this.hot_time = hot_time; + } + + public String getSort() { + return sort; + } + + public void setSort(String sort) { + this.sort = sort; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/UserHomeImgBean.java b/common/src/main/java/com/yunbao/common/bean/UserHomeImgBean.java new file mode 100644 index 000000000..b57c35496 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/UserHomeImgBean.java @@ -0,0 +1,29 @@ +package com.yunbao.common.bean; + +/** + * 社區动态 + */ +public class UserHomeImgBean extends BaseModel { + private String imgurl; + private boolean isShow; + + public UserHomeImgBean(String imgurl) { + this.imgurl = imgurl; + } + + public String getImgurl() { + return imgurl; + } + + public void setImgurl(String imgurl) { + this.imgurl = imgurl; + } + + public boolean isShow() { + return isShow; + } + + public void setShow(boolean show) { + isShow = show; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java index b9de3c2d7..b96415618 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -551,6 +551,63 @@ public class CommonHttpUtil { .execute(callback); } + /** + * 获取动态列表-点赞 + * + * @param callback + */ + public static void dynamicLove(String dynamic_id, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.dynamicLove", "Pdlcommunity.dynamicLove") + .params("dynamic_id", dynamic_id) + .execute(callback); + } + + /** + * 获取动态列表-回复 + * + * @param callback + */ + public static void dynamicReply(String dynamic_id, String to_comment_id, String content, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.sendDynamicComment", "Pdlcommunity.sendDynamicComment") + .params("dynamic_id", dynamic_id) + .params("content", content) + .params("to_comment_id", to_comment_id) + .execute(callback); + } + + /** + * 获取动态-发现 + */ + public static void getCommunityFind(int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getFindDynamicList", "Pdlcommunity.getFindDynamicList") + .params("p", p) + .execute(callback); + } + + /** + * 获取动态-关注 + */ + public static void getCommunityFollow(int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getFindDynamicList", "Pdlcommunity.getFindDynamicList") + .params("p", p) + .execute(callback); + } + + + /** + * 获取动态-分类 + */ + public static void getTag(HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getTalkBanner", "Pdlcommunity.getTalkBanner") + .execute(callback); + } + + public static void getTalkHotDynamicList(int talkId, int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getTalkHotDynamicList", "Pdlcommunity.getTalkHotDynamicList") + .params("talk_id", talkId) + .params("p", p) + .execute(callback); + } } diff --git a/common/src/main/java/com/yunbao/common/manager/CommunityTypeManager.java b/common/src/main/java/com/yunbao/common/manager/CommunityTypeManager.java new file mode 100644 index 000000000..e31018e0f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/CommunityTypeManager.java @@ -0,0 +1,38 @@ +package com.yunbao.common.manager; + +import android.content.Context; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yunbao.common.bean.FansModel; +import com.yunbao.common.bean.NewCommunityType; +import com.yunbao.common.bean.NewLevelModel; +import com.yunbao.common.manager.base.BaseCacheManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * 动态类别管理 + */ +public class CommunityTypeManager extends BaseCacheManager { + + private final String KEY_COMMUNITY_TYPE = "keyCommunityType"; + private List newCommunityTypeList = new ArrayList<>(); + + public CommunityTypeManager(Context context) { + super(context); + } + + public List getCommunityTypeList() { + return getList(KEY_COMMUNITY_TYPE, new TypeToken>() { + }.getType()); + } + + public void UpCommunityType(String json) { + newCommunityTypeList = new Gson().fromJson(json, new TypeToken>() { + }.getType()); + put(KEY_COMMUNITY_TYPE, newCommunityTypeList); + } + +} diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 281357214..9dcd2c357 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -1,6 +1,5 @@ package com.yunbao.common.utils; -import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -24,7 +23,7 @@ public class RouteUtil { //Intent隐式启动 action public static final String PATH_LAUNCHER = "/app/LauncherActivity"; public static final String PATH_LOGIN_INVALID = "/main/LoginInvalidActivity"; - public static final String PATH_USER_HOME = "/main/UserHomeActivity"; + public static final String PATH_COIN = "/main/MyWalletActivity"; public static final String PATH_REWARD = "/main/RewardActivity"; public static final String PATH_EDITPROFILE = "/main/EditProfileActivity"; @@ -46,21 +45,22 @@ public class RouteUtil { public static final String PATH_RED_PACKET_LIST = "/main/RedPacketListActivity"; public static final String PATH_RED_PACKET_INFO = "/main/RedPacketInfoActivity"; public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity"; - public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity"; - public static final String PATH_BattlePassActivity="/main/BattlePassActivity"; - public static final String PATH_SudGameActivity="/live/SudGameActivity"; - public static final String PATH_COMMUNITY_Activity="/main/MainHomeCommunityActivity"; - + public static final String PATH_SELECT_AVATAR = "/main/UserAvatarSelectActivity"; + public static final String PATH_BattlePassActivity = "/main/BattlePassActivity"; + public static final String PATH_SudGameActivity = "/live/SudGameActivity"; + public static final String PATH_COMMUNITY_Activity = "/main/MainHomeCommunityActivity"; public static void forwardCommunityActivity() { ARouter.getInstance().build(PATH_COMMUNITY_Activity) .navigation(); } + public static void forwardFansActivity(String uid) { ARouter.getInstance().build(PATH_FANSACTIVITY) .withString(Constants.TO_UID, uid) .navigation(); } + public static void forwardSudGameActivity(String CreateSudRoom) { ARouter.getInstance().build(PATH_SudGameActivity) .withString("CreateSudRoom", CreateSudRoom) @@ -215,7 +215,7 @@ public class RouteUtil { * 跳转到充值页面 */ public static void forwardMyCoin(Context context) { - String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=zhifu&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : 0); + String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=zhifu&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0); ARouter.getInstance().build(PATH_COIN).withString("url", url).navigation(); } @@ -266,14 +266,14 @@ public class RouteUtil { postcard.navigation(); } - public static void forwardGiftWallActivity(String mStream, String mAnchorName, String mLiveUid, String mAvatarUrl, int isAttention,boolean isLive) { + public static void forwardGiftWallActivity(String mStream, String mAnchorName, String mLiveUid, String mAvatarUrl, int isAttention, boolean isLive) { ARouter.getInstance().build(PATH_GIFT_WALL) .withString(Constants.LIVE_UID, mLiveUid) .withString(Constants.STREAM, mStream) .withString("mAnchorName", mAnchorName) .withString("mAvatarUrl", mAvatarUrl) .withInt("isAttention", isAttention) - .withBoolean("isLive",isLive) + .withBoolean("isLive", isLive) .navigation(); } @@ -295,6 +295,19 @@ public class RouteUtil { .navigation(); } + /** + * 举报动态 + * + * @param dynamicId + * @param commentId + */ + public static void forwardCommentReportActivity(String dynamicId, String commentId) { + ARouter.getInstance().build(PATH_LIVEREPORT) + .withString(Constants.TO_UID, dynamicId) + .withString("comment_id", commentId) + .navigation(); + } + /** * 进入facebook登录 */ @@ -351,7 +364,7 @@ public class RouteUtil { /** * 战令 */ - public static void forwardBattlePass(){ + public static void forwardBattlePass() { ARouter.getInstance().build(PATH_BattlePassActivity) .navigation(); } diff --git a/common/src/main/java/com/yunbao/common/views/FullyLinearLayoutManager.java b/common/src/main/java/com/yunbao/common/views/FullyLinearLayoutManager.java new file mode 100644 index 000000000..5f380d9c9 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/FullyLinearLayoutManager.java @@ -0,0 +1,283 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.graphics.Rect; +import android.util.Log; +import android.view.View; + +import androidx.core.view.ViewCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.BuildConfig; + +import java.lang.reflect.Field; + +public class FullyLinearLayoutManager extends LinearLayoutManager { + + private static boolean canMakeInsetsDirty = true; + private static Field insetsDirtyField = null; + + private static final int CHILD_WIDTH = 0; + private static final int CHILD_HEIGHT = 1; + private static final int DEFAULT_CHILD_SIZE = 100; + + private final int[] childDimensions = new int[2]; + private final RecyclerView view; + + private int childSize = DEFAULT_CHILD_SIZE; + private boolean hasChildSize; + private int overScrollMode = ViewCompat.OVER_SCROLL_ALWAYS; + private final Rect tmpRect = new Rect(); + + public FullyLinearLayoutManager(Context context) { + super(context); + this.view = null; + } + + public FullyLinearLayoutManager(Context context, int orientation, boolean reverseLayout) { + super(context, orientation, reverseLayout); + this.view = null; + } + + public FullyLinearLayoutManager(RecyclerView view) { + super(view.getContext()); + this.view = view; + this.overScrollMode = ViewCompat.getOverScrollMode(view); + } + + public FullyLinearLayoutManager(RecyclerView view, int orientation, boolean reverseLayout) { + super(view.getContext(), orientation, reverseLayout); + this.view = view; + this.overScrollMode = ViewCompat.getOverScrollMode(view); + } + + public void setOverScrollMode(int overScrollMode) { + if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER) + throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode); + if (this.view == null) throw new IllegalStateException("view == null"); + this.overScrollMode = overScrollMode; + ViewCompat.setOverScrollMode(view, overScrollMode); + } + + public static int makeUnspecifiedSpec() { + return View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + } + + @Override + public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) { + final int widthMode = View.MeasureSpec.getMode(widthSpec); + final int heightMode = View.MeasureSpec.getMode(heightSpec); + + final int widthSize = View.MeasureSpec.getSize(widthSpec); + final int heightSize = View.MeasureSpec.getSize(heightSpec); + + final boolean hasWidthSize = widthMode != View.MeasureSpec.UNSPECIFIED; + final boolean hasHeightSize = heightMode != View.MeasureSpec.UNSPECIFIED; + + final boolean exactWidth = widthMode == View.MeasureSpec.EXACTLY; + final boolean exactHeight = heightMode == View.MeasureSpec.EXACTLY; + + final int unspecified = makeUnspecifiedSpec(); + + if (exactWidth && exactHeight) { + // in case of exact calculations for both dimensions let's use default "onMeasure" implementation + super.onMeasure(recycler, state, widthSpec, heightSpec); + return; + } + + final boolean vertical = getOrientation() == VERTICAL; + + initChildDimensions(widthSize, heightSize, vertical); + + int width = 0; + int height = 0; + + // it's possible to get scrap views in recycler which are bound to old (invalid) adapter entities. This + // happens because their invalidation happens after "onMeasure" method. As a workaround let's clear the + // recycler now (it should not cause any performance issues while scrolling as "onMeasure" is never + // called whiles scrolling) + recycler.clear(); + + final int stateItemCount = state.getItemCount(); + final int adapterItemCount = getItemCount(); + // adapter always contains actual data while state might contain old data (f.e. data before the animation is + // done). As we want to measure the view with actual data we must use data from the adapter and not from the + // state + for (int i = 0; i < adapterItemCount; i++) { + if (vertical) { + if (!hasChildSize) { + if (i < stateItemCount) { + // we should not exceed state count, otherwise we'll get IndexOutOfBoundsException. For such items + // we will use previously calculated dimensions + measureChild(recycler, i, widthSize, unspecified, childDimensions); + } else { + logMeasureWarning(i); + } + } + height += childDimensions[CHILD_HEIGHT]; + if (i == 0) { + width = childDimensions[CHILD_WIDTH]; + } + if (hasHeightSize && height >= heightSize) { + break; + } + } else { + if (!hasChildSize) { + if (i < stateItemCount) { + // we should not exceed state count, otherwise we'll get IndexOutOfBoundsException. For such items + // we will use previously calculated dimensions + measureChild(recycler, i, unspecified, heightSize, childDimensions); + } else { + logMeasureWarning(i); + } + } + width += childDimensions[CHILD_WIDTH]; + if (i == 0) { + height = childDimensions[CHILD_HEIGHT]; + } + if (hasWidthSize && width >= widthSize) { + break; + } + } + } + + if (exactWidth) { + width = widthSize; + } else { + width += getPaddingLeft() + getPaddingRight(); + if (hasWidthSize) { + width = Math.min(width, widthSize); + } + } + + if (exactHeight) { + height = heightSize; + } else { + height += getPaddingTop() + getPaddingBottom(); + if (hasHeightSize) { + height = Math.min(height, heightSize); + } + } + + setMeasuredDimension(width, height); + + if (view != null && overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS) { + final boolean fit = (vertical && (!hasHeightSize || height < heightSize)) + || (!vertical && (!hasWidthSize || width < widthSize)); + + ViewCompat.setOverScrollMode(view, fit ? ViewCompat.OVER_SCROLL_NEVER : ViewCompat.OVER_SCROLL_ALWAYS); + } + } + + private void logMeasureWarning(int child) { + if (BuildConfig.DEBUG) { + Log.w("LinearLayoutManager", "Can't measure child #" + child + ", previously used dimensions will be reused." + + "To remove this message either use #setChildSize() method or don't run RecyclerView animations"); + } + } + + private void initChildDimensions(int width, int height, boolean vertical) { + if (childDimensions[CHILD_WIDTH] != 0 || childDimensions[CHILD_HEIGHT] != 0) { + // already initialized, skipping + return; + } + if (vertical) { + childDimensions[CHILD_WIDTH] = width; + childDimensions[CHILD_HEIGHT] = childSize; + } else { + childDimensions[CHILD_WIDTH] = childSize; + childDimensions[CHILD_HEIGHT] = height; + } + } + + @Override + public void setOrientation(int orientation) { + // might be called before the constructor of this class is called + //noinspection ConstantConditions + if (childDimensions != null) { + if (getOrientation() != orientation) { + childDimensions[CHILD_WIDTH] = 0; + childDimensions[CHILD_HEIGHT] = 0; + } + } + super.setOrientation(orientation); + } + + public void clearChildSize() { + hasChildSize = false; + setChildSize(DEFAULT_CHILD_SIZE); + } + + public void setChildSize(int childSize) { + hasChildSize = true; + if (this.childSize != childSize) { + this.childSize = childSize; + requestLayout(); + } + } + + private void measureChild(RecyclerView.Recycler recycler, int position, int widthSize, int heightSize, int[] dimensions) { + final View child; + try { + child = recycler.getViewForPosition(position); + } catch (IndexOutOfBoundsException e) { + if (BuildConfig.DEBUG) { + Log.w("LinearLayoutManager", "LinearLayoutManager doesn't work well with animations. Consider switching them off", e); + } + return; + } + + final RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) child.getLayoutParams(); + + final int hPadding = getPaddingLeft() + getPaddingRight(); + final int vPadding = getPaddingTop() + getPaddingBottom(); + + final int hMargin = p.leftMargin + p.rightMargin; + final int vMargin = p.topMargin + p.bottomMargin; + + // we must make insets dirty in order calculateItemDecorationsForChild to work + makeInsetsDirty(p); + // this method should be called before any getXxxDecorationXxx() methods + calculateItemDecorationsForChild(child, tmpRect); + + final int hDecoration = getRightDecorationWidth(child) + getLeftDecorationWidth(child); + final int vDecoration = getTopDecorationHeight(child) + getBottomDecorationHeight(child); + + final int childWidthSpec = getChildMeasureSpec(widthSize, hPadding + hMargin + hDecoration, p.width, canScrollHorizontally()); + final int childHeightSpec = getChildMeasureSpec(heightSize, vPadding + vMargin + vDecoration, p.height, canScrollVertically()); + + child.measure(childWidthSpec, childHeightSpec); + + dimensions[CHILD_WIDTH] = getDecoratedMeasuredWidth(child) + p.leftMargin + p.rightMargin; + dimensions[CHILD_HEIGHT] = getDecoratedMeasuredHeight(child) + p.bottomMargin + p.topMargin; + + // as view is recycled let's not keep old measured values + makeInsetsDirty(p); + recycler.recycleView(child); + } + + private static void makeInsetsDirty(RecyclerView.LayoutParams p) { + if (!canMakeInsetsDirty) { + return; + } + try { + if (insetsDirtyField == null) { + insetsDirtyField = RecyclerView.LayoutParams.class.getDeclaredField("mInsetsDirty"); + insetsDirtyField.setAccessible(true); + } + insetsDirtyField.set(p, true); + } catch (NoSuchFieldException e) { + onMakeInsertDirtyFailed(); + } catch (IllegalAccessException e) { + onMakeInsertDirtyFailed(); + } + } + + private static void onMakeInsertDirtyFailed() { + canMakeInsetsDirty = false; + if (BuildConfig.DEBUG) { + Log.w("LinearLayoutManager", "Can't make LayoutParams insets dirty, decorations measurements might be incorrect"); + } + } +} \ No newline at end of file diff --git a/common/src/main/java/com/yunbao/common/views/MyScrollview.java b/common/src/main/java/com/yunbao/common/views/MyScrollview.java new file mode 100644 index 000000000..b0cddb3de --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MyScrollview.java @@ -0,0 +1,48 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.ViewConfiguration; +import android.widget.ScrollView; + +public class MyScrollview extends ScrollView { + private int downX; + private int downY; + private int mTouchSlop; + + public MyScrollview(Context context) { + super(context); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + public MyScrollview(Context context, AttributeSet attrs) { + super(context, attrs); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + + public MyScrollview(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent e) { + int action = e.getAction(); + switch (action) { + case MotionEvent.ACTION_DOWN: + downX = (int) e.getRawX(); + downY = (int) e.getRawY(); + break; + case MotionEvent.ACTION_MOVE: + int moveY = (int) e.getRawY(); + if (Math.abs(moveY - downY) > mTouchSlop) { + return true; + } else { + super.onInterceptTouchEvent(e); + } + } + return super.onInterceptTouchEvent(e); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/UserHomeImgsViewHolder.java b/common/src/main/java/com/yunbao/common/views/UserHomeImgsViewHolder.java new file mode 100644 index 000000000..ac03f5365 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/UserHomeImgsViewHolder.java @@ -0,0 +1,29 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.ms.banner.holder.BannerViewHolder; +import com.yunbao.common.bean.BannerBean; +import com.yunbao.common.glide.ImgLoader; + +public class UserHomeImgsViewHolder implements BannerViewHolder { + + @Override + public View createView(Context context, int position, String data) { + // 返回mImageView页面布局 + ImageView imageView = new ImageView(context); + ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT + ); + imageView.setLayoutParams(params); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + //Glide.with(context).load(data.getImageUrl()).into(imageView); + ImgLoader.display(context, data, imageView); + + return imageView; + } + +} diff --git a/common/src/main/res/drawable/bg_user_home_bottom.xml b/common/src/main/res/drawable/bg_user_home_bottom.xml index 97e25b6a1..d77d2e85e 100644 --- a/common/src/main/res/drawable/bg_user_home_bottom.xml +++ b/common/src/main/res/drawable/bg_user_home_bottom.xml @@ -6,7 +6,7 @@ + android:topLeftRadius="25dp" + android:topRightRadius="25dp" /> \ No newline at end of file diff --git a/common/src/main/res/layout/activity_community_details.xml b/common/src/main/res/layout/activity_community_details.xml index 99a9973dc..f50601e9b 100644 --- a/common/src/main/res/layout/activity_community_details.xml +++ b/common/src/main/res/layout/activity_community_details.xml @@ -9,7 +9,7 @@ - @@ -22,6 +22,7 @@ android:orientation="vertical"> @@ -181,21 +182,28 @@ - + android:descendantFocusability="blocksDescendants"> + + + - + - diff --git a/common/src/main/res/layout/item_comment_reply_view.xml b/common/src/main/res/layout/item_comment_reply_view.xml index e6c175e78..23e02a9d3 100644 --- a/common/src/main/res/layout/item_comment_reply_view.xml +++ b/common/src/main/res/layout/item_comment_reply_view.xml @@ -8,6 +8,7 @@ tools:ignore="MissingDefaultResource"> + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:orientation="horizontal"> - - - - - - - + @@ -69,8 +57,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp" - android:layout_marginTop="5dp" - android:text="现在还没有结冰哦,但是雪大了会封路现在还没有结冰哦,但是雪大了会封路" + android:text="" android:textColor="#777777" android:textSize="12dp" /> @@ -79,7 +66,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp" - android:layout_marginTop="10dp" + android:layout_marginTop="20dp" android:visibility="gone" /> diff --git a/common/src/main/res/layout/item_comment_view.xml b/common/src/main/res/layout/item_comment_view.xml index 172889a0c..6b77117fe 100644 --- a/common/src/main/res/layout/item_comment_view.xml +++ b/common/src/main/res/layout/item_comment_view.xml @@ -10,12 +10,13 @@ @@ -23,7 +24,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="10dp" - android:layout_marginTop="10dp" + android:layout_marginTop="7dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="vertical"> @@ -48,14 +49,14 @@ + android:textSize="11dp" /> @@ -75,50 +76,39 @@ android:id="@+id/replyLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginLeft="60dp" + android:layout_marginLeft="50dp" android:layout_marginTop="10dp" android:layout_marginRight="10dp" android:background="@drawable/bg_item_comment" android:orientation="vertical" - android:padding="10dp"> + android:padding="10dp" + android:visibility="visible"> + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:orientation="horizontal"> - - - - - - - + + android:textSize="11dp" + android:visibility="gone" /> @@ -138,9 +129,9 @@ android:layout_height="wrap_content" android:layout_marginLeft="30dp" android:layout_marginTop="5dp" - android:text="现在还没有结冰哦,但是雪大了会封路现在还没有结冰哦,但是雪大了会封路" + android:text="" android:textColor="#777777" - android:textSize="12dp" /> + android:textSize="11dp" /> + \ No newline at end of file diff --git a/common/src/main/res/layout/item_user_home_img.xml b/common/src/main/res/layout/item_user_home_img.xml new file mode 100644 index 000000000..e71b0cc8c --- /dev/null +++ b/common/src/main/res/layout/item_user_home_img.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index d454a6f7a..e650fb87d 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -178,9 +178,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private String mUrlCsd; private TextView v_table_redpoint; private View v_table_redpoint_me; - String TAG = "GooglePay"; - public static int Height; private boolean isWebClose = false; public static boolean isTabClose = false; @@ -189,7 +187,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private ImageView waitingTip; private FloatBannerView floatBanner; private boolean isfloatBannernet = true, isFirst = true; - private View floatRedPacket; private View floatWarOrder;//战令浮窗 @@ -206,7 +203,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene super.create(); getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); getWindow().setSharedElementEnterTransition(new FullAdToBannerTransition(1, 0.4f, new DecelerateInterpolator())); - } @Override @@ -1136,16 +1132,15 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene if (position == 0) { mainHomeComViewHolder = new MainHomeComViewHolder(mContext, parent); vh = mainHomeComViewHolder; - } else if (position == 1) { - mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播 - vh = mMainHomeCommunityViewHolder; - + mainHomeLiveViewHolder = new MainHomeLiveViewHolder(mContext, parent);//直播 + vh = mainHomeLiveViewHolder; + /* mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播 + vh = mMainHomeCommunityViewHolder;*/ } else if (position == 2) { mainMessageViewHolder = new MainMessageViewHolder(this, parent); vh = mainMessageViewHolder; - } else if (position == 3) { mMeViewHolder = new MainMeViewHolder(mContext, parent); vh = mMeViewHolder; diff --git a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java index 7ce41a8d6..a244f3df5 100644 --- a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java @@ -2,7 +2,6 @@ package com.yunbao.main.activity; import android.content.Intent; import android.text.TextUtils; -import android.util.Log; import android.view.ViewGroup; import com.alibaba.android.arouter.facade.annotation.Route; @@ -20,7 +19,7 @@ import com.yunbao.main.views.UserHomeViewHolder2; /** * Created by cxf on 2018/9/25. */ -@Route(path = RouteUtil.PATH_USER_HOME) +//@Route(path = RouteUtil.PATH_USER_HOME) public class UserHomeActivity extends AbsActivity { private UserHomeViewHolder2 mUserHomeViewHolder; diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java index d150cc107..31834cdc6 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java @@ -84,42 +84,44 @@ public class MainHomeComAdapter extends RefreshAdapter { void setData(ActiveBean bean, int position) { itemView.setTag(bean); - if (bean.getImg_or_video().equals("1")) { - JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json()); - if (jsonArray.size() != 0) { - ImgLoader.display(mContext, String.valueOf(jsonArray.get(0)), img); + if (bean != null) { + if (bean.getImg_or_video().equals("1")) { + JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json()); + if (jsonArray.size() != 0) { + ImgLoader.display(mContext, String.valueOf(jsonArray.get(0)), img); + } + isVideo.setVisibility(View.GONE); + } else { + ImgLoader.display(mContext, bean.getUser_avatar(), img); + isVideo.setVisibility(View.VISIBLE); } - isVideo.setVisibility(View.GONE); - } else { - ImgLoader.display(mContext, bean.getUser_avatar(), img); - isVideo.setVisibility(View.VISIBLE); - } - name.setText(bean.getUser_name()); - JSONObject json = JSONObject.parseObject(bean.getContent()); - if (json != null) { - String content = (String) json.get("msg"); - title.setText(content); - } - likeCount.setText(bean.getLove_num()); - ImgLoader.display(mContext, bean.getUser_avatar(), author); + name.setText(bean.getUser_name()); + JSONObject json = JSONObject.parseObject(bean.getContent()); + if (json != null) { + String content = (String) json.get("msg"); + title.setText(content); + } + likeCount.setText(bean.getLove_num()); + ImgLoader.display(mContext, bean.getUser_avatar(), author); - if (position == 0) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); - params.height = 550; - heightLayout.setLayoutParams(params); + if (position == 0) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 550; + heightLayout.setLayoutParams(params); - FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); - imgPa.height = 550; - img.setLayoutParams(imgPa); + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 550; + img.setLayoutParams(imgPa); - } else { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); - params.height = 750; - heightLayout.setLayoutParams(params); + } else { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 750; + heightLayout.setLayoutParams(params); - FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); - imgPa.height = 750; - img.setLayoutParams(imgPa); + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 750; + img.setLayoutParams(imgPa); + } } } } diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java index 7124ba97b..e32f664b2 100644 --- a/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java @@ -12,7 +12,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.yunbao.common.bean.LiveClassBean; +import com.yunbao.common.bean.NewCommunityType; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.main.R; @@ -22,15 +22,15 @@ import java.util.Locale; public class MainHomeComClassAdapter extends RecyclerView.Adapter { private Context mContext; - private List mList; + private List mList; private LayoutInflater mInflater; private View.OnClickListener mOnClickListener; - private OnItemClickListener mOnItemClickListener; + private OnItemClickListener mOnItemClickListener; //选中的 public static int choice = 0; - public MainHomeComClassAdapter(Context context, List list, boolean dialog) { + public MainHomeComClassAdapter(Context context, List list, boolean dialog) { mContext = context; mList = list; mInflater = LayoutInflater.from(context); @@ -40,7 +40,7 @@ public class MainHomeComClassAdapter extends RecyclerView.Adapter onItemClickListener) { + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { mOnItemClickListener = onItemClickListener; } @@ -81,7 +81,7 @@ public class MainHomeComClassAdapter extends RecyclerView.Adapter= Build.VERSION_CODES.N) { @@ -90,9 +90,9 @@ public class MainHomeComClassAdapter extends RecyclerView.Adapter { +public class MainHomeFollComViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { private CommonRefreshWaterfallView mRefreshView; - private MainHomeRemFollComAdapter mAdapter; + private MainHomeComAdapter mAdapter; public MainHomeFollComViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -71,11 +77,11 @@ public class MainHomeFollComViewHolder extends AbsMainHomeChildViewHolder implem mRefreshView.setItemDecoration(decoration); */ mRefreshView.setRecyclerViewAdapter(mAdapter); - mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { @Override - public RefreshAdapter getAdapter() { + public RefreshAdapter getAdapter() { if (mAdapter == null) { - mAdapter = new MainHomeRemFollComAdapter(mContext, MainActivity.Height); + mAdapter = new MainHomeComAdapter(mContext); mAdapter.setOnItemClickListener(MainHomeFollComViewHolder.this); } return mAdapter; @@ -85,16 +91,16 @@ public class MainHomeFollComViewHolder extends AbsMainHomeChildViewHolder implem public void loadData(int p, HttpCallback callback) { Log.i("t2", "aaa" + p); pp = 1; - MainHttpUtil.getHomeFollow(p, callback); + CommonHttpUtil.getCommunityFollow(p, callback); } @Override - public List processData(String[] info) { - return JSON.parseArray(Arrays.toString(info), LiveBean.class); + public List processData(String[] info) { + return JSON.parseArray(Arrays.toString(info), ActiveBean.class); } @Override - public void onRefreshSuccess(List list, int count) { + public void onRefreshSuccess(List list, int count) { EventBus.getDefault().post(new AnchorRecommendModel()); } @@ -104,14 +110,8 @@ public class MainHomeFollComViewHolder extends AbsMainHomeChildViewHolder implem } @Override - public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { - List new_data = new ArrayList<>(); - for (int j = 0; j < loadItemList.size(); j++) { - if (loadItemList.get(j).getUserNiceName() != null) { - new_data.add(loadItemList.get(j)); - } - } - mAdapter.insertList(new_data); + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + mAdapter.insertList(loadItemList); } @Override @@ -119,23 +119,14 @@ public class MainHomeFollComViewHolder extends AbsMainHomeChildViewHolder implem } }); - mRefreshView.initData(); - - } - @Override - public void onItemClick(LiveBean bean, int position) { - if ("1".equals(bean.getIslive())) { - watchLive(bean, Constants.LIVE_HOME, position); - } else if (bean.getIs_week() != null && bean.getIs_week().equals("1")) { - String url = CommonAppConfig.HOST + bean.getUrl() + "?a=1"; - WeekWebViewActivity.forward(mContext, url, true); - } else { - RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); - } + public void onItemClick(ActiveBean bean, int position) { + Intent intent = new Intent(mContext, CommunityDetailsActivity.class); + intent.putExtra("active", (Parcelable) bean); + mContext.startActivity(intent); } @Override diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java index dd16b3dcc..b8a9bb34b 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java @@ -15,36 +15,25 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.umeng.analytics.MobclickAgent; -import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.Constants; +import com.google.gson.Gson; import com.yunbao.common.activity.CommunityDetailsActivity; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.bean.ActiveBean; -import com.yunbao.common.bean.BannerBean; -import com.yunbao.common.bean.LiveClassBean; -import com.yunbao.common.bean.VideoBean; +import com.yunbao.common.bean.NewCommunityType; import com.yunbao.common.custom.CommonRefreshWaterfallView; import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; -import com.yunbao.common.manager.LiveClassManager; +import com.yunbao.common.manager.CommunityTypeManager; import com.yunbao.common.manager.OpenAdManager; import com.yunbao.common.utils.DialogUitl; -import com.yunbao.live.adapter.LiveAdminRoomAdapter; -import com.yunbao.live.bean.LiveAdminRoomBean; -import com.yunbao.live.views.LiveMyRoomViewHolder; +import com.yunbao.live.bean.RedPackBean; import com.yunbao.main.R; import com.yunbao.main.adapter.MainHomeComAdapter; import com.yunbao.main.adapter.MainHomeComClassAdapter; import com.yunbao.main.http.MainHttpConsts; import com.yunbao.main.http.MainHttpUtil; -import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.http.VideoHttpUtil; import com.yunbao.video.interfaces.VideoScrollDataHelper; -import com.yunbao.video.utils.VideoStorge; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -86,8 +75,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements return R.layout.view_main_home_com_hot; } - public static int pp; - //显示顶部商城tab时,显示底部tabGroup @Subscribe(threadMode = ThreadMode.MAIN) public void onUpdata(String str) { @@ -105,10 +92,30 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements @Override public void init() { - List list = new LiveClassManager(mContext).getLiveClass(); + CommonHttpUtil.getTag(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + List list = JSON.parseArray(Arrays.toString(info), NewCommunityType.class); + CommunityTypeManager communityTypeManager = new CommunityTypeManager(mContext); + communityTypeManager.UpCommunityType(Arrays.toString(info)); + initCommunityTypeList(list); + } + }); + + List list = new CommunityTypeManager(mContext).getCommunityTypeList(); if (list != null && !list.isEmpty()) { - typeHot = list.get(0).getEnglish(); + typeHot = list.get(0).getTalk_name(); select = list.get(0).getId(); + } else { + CommonHttpUtil.getTag(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + List list = JSON.parseArray(Arrays.toString(info), NewCommunityType.class); + CommunityTypeManager communityTypeManager = new CommunityTypeManager(mContext); + communityTypeManager.UpCommunityType(Arrays.toString(info)); + initCommunityTypeList(list); + } + }); } mBtnDismiss = findViewById(R.id.btn_dismiss); mBtnDismiss.setOnClickListener(new View.OnClickListener() { @@ -144,12 +151,11 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements @Override public void loadData(int p, HttpCallback callback) { Log.i("t2", "aaa" + p); + CommonHttpUtil.getCommunityHotList(p, callback); if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) { - pp = 1; CommonHttpUtil.getCommunityHotList(p, callback); } else { - pp = 0; - MainHttpUtil.getClassLive(select, p, callback); + CommonHttpUtil.getTalkHotDynamicList(select, p, callback); } } @@ -189,19 +195,24 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mClassRecyclerViewTop = (RecyclerView) findViewById(R.id.classRecyclerView_top); mClassRecyclerViewTop.setHasFixedSize(true); mClassRecyclerViewTop.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); + mRefreshView.initData(); + initCommunityTypeList(list); + } + + public void initCommunityTypeList(List list) { if (list != null && list.size() > 0) { - List targetList = new ArrayList<>(); + List targetList = new ArrayList<>(); if (list.size() <= 6) { targetList.addAll(list); } else { targetList.addAll(list); } final MainHomeComClassAdapter topAdapter = new MainHomeComClassAdapter(mContext, targetList, false); - topAdapter.setOnItemClickListener(new OnItemClickListener() { + topAdapter.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(LiveClassBean bean, int position) { - switch (bean.getEnglish()) { + public void onItemClick(NewCommunityType bean, int position) { + /*switch (bean.getEnglish()) { case "Hot": MobclickAgent.onEvent(mContext, "home_page_recommend_hot", "热门"); break; @@ -223,12 +234,12 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements default: MobclickAgent.onEvent(mContext, "home_page_recommend_other", "其他"); break; - } + }*/ if (!canClick()) { return; } select = bean.getId(); - typeHot = bean.getEnglish(); + typeHot = bean.getTalk_name(); mRefreshView.initData(); topAdapter.choice = position; topAdapter.notifyDataSetChanged(); @@ -238,7 +249,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mClassRecyclerViewTop.setAdapter(topAdapter); } } - mRefreshView.initData(); } private VideoScrollDataHelper mVideoScrollDataHelper; diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java index b6e30de79..47a6d47eb 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java @@ -1,6 +1,8 @@ package com.yunbao.main.views; import android.content.Context; +import android.content.Intent; +import android.os.Parcelable; import android.view.ViewGroup; import androidx.recyclerview.widget.GridLayoutManager; @@ -8,18 +10,22 @@ import androidx.recyclerview.widget.GridLayoutManager; import com.alibaba.fastjson.JSON; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; +import com.yunbao.common.activity.CommunityDetailsActivity; import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.custom.CommonRefreshWaterfallView; import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.utils.RouteUtil; import com.yunbao.main.R; import com.yunbao.main.activity.MainActivity; import com.yunbao.main.activity.WeekWebViewActivity; +import com.yunbao.main.adapter.MainHomeComAdapter; import com.yunbao.main.adapter.MainHomeRemFindComAdapter; import com.yunbao.main.adapter.MainHomeRemFollLiveAdapter; import com.yunbao.main.http.MainHttpConsts; @@ -35,9 +41,9 @@ import java.util.List; /** * 社区-发现 */ -public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { +public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { private CommonRefreshWaterfallView mRefreshView; - private MainHomeRemFindComAdapter mAdapter; + private MainHomeComAdapter mAdapter; public MainHomeRecomComViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -58,7 +64,7 @@ public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder imple mRefreshView.showRefreshBar(); mRefreshView.mRecyclerView.scrollToPosition(0); } - }else if ("blacklist".equals(str)) { + } else if ("blacklist".equals(str)) { if (mRefreshView != null) { mRefreshView.showRefreshBar(); } @@ -72,11 +78,11 @@ public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder imple mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live); EventBus.getDefault().register(this); mRefreshView.setRecyclerViewAdapter(mAdapter); - mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { @Override - public RefreshAdapter getAdapter() { + public RefreshAdapter getAdapter() { if (mAdapter == null) { - mAdapter = new MainHomeRemFindComAdapter(mContext, MainActivity.Height); + mAdapter = new MainHomeComAdapter(mContext); mAdapter.setOnItemClickListener(MainHomeRecomComViewHolder.this); } return mAdapter; @@ -84,21 +90,21 @@ public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder imple @Override public void loadData(int p, HttpCallback callback) { - pp = p; - MainHttpUtil.getRandom(p, callback); + pp = p; + CommonHttpUtil.getCommunityFind(p, callback); } @Override - public List processData(String[] info) { - if(pp == 1){ - return JSON.parseArray(Arrays.toString(info), LiveBean.class); - }else{ + public List processData(String[] info) { + if (pp == 1) { + return JSON.parseArray(Arrays.toString(info), ActiveBean.class); + } else { return null; } } @Override - public void onRefreshSuccess(List list, int count) { + public void onRefreshSuccess(List list, int count) { EventBus.getDefault().post(new AnchorRecommendModel()); } @@ -108,7 +114,7 @@ public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder imple } @Override - public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { } @@ -123,20 +129,11 @@ public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder imple } - - - - @Override - public void onItemClick(LiveBean bean, int position) { - if ("1".equals(bean.getIslive())) { - watchLive(bean, Constants.LIVE_HOME, position); - }else if(bean.getIs_week()!=null&&bean.getIs_week().equals("1")){ - String url = CommonAppConfig.HOST + bean.getUrl()+"?a=1"; - WeekWebViewActivity.forward(mContext, url, true); - } else { - RouteUtil.forwardUserHome(mContext, bean.getUid(),0); - } + public void onItemClick(ActiveBean bean, int position) { + Intent intent = new Intent(mContext, CommunityDetailsActivity.class); + intent.putExtra("active", (Parcelable) bean); + mContext.startActivity(intent); } @Override diff --git a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java index 7f691cf41..7ffe0d335 100644 --- a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java +++ b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java @@ -464,7 +464,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh avatar = userBean.getAvatar(); ImgLoader.displayBlur(mContext, avatar, mAvatarBg); ImgLoader.displayAvatar(mContext, avatar, mAvatar); - if (userBean.getDress().getAvatar_frame() != null) { + /*if (userBean.getDress().getAvatar_frame() != null) { if (userBean.getDress().getAvatar_frame().contains("svga")) { try { new SVGAParser(mContext).parse(new URL(userBean.getDress().getAvatar_frame()), new SVGAParser.ParseCompletion() { @@ -485,7 +485,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh } else { ImgLoader.display(mContext, userBean.getDress().getAvatar_frame(), gift_svga); } - } + }*/ if (userBean.getDress().getMedal() != null) {