diff --git a/common/build.gradle b/common/build.gradle index 7124a67a2..abf5d8c5e 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -223,5 +223,11 @@ dependencies { //瀑布流 api 'com.wuxiaolong.pullloadmorerecyclerview:library:1.1.2' + //时间选择器 + api 'com.contrarywind:Android-PickerView:4.1.9' + //播放器-https://github.com/yangchong211/YCVideoPlayer + api 'cn.yc:VideoPlayer:3.1.0' + api 'cn.yc:VideoCache:3.0.5' + api 'cn.yc:VideoKernel:3.0.6' } diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index b30402cd7..2b3794711 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -71,7 +71,8 @@ + 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 3e8eb168f..d7f50e226 100644 --- a/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java @@ -1,22 +1,58 @@ package com.yunbao.common.activity; +import android.annotation.SuppressLint; import android.content.Intent; +import android.graphics.Color; +import android.view.View; +import android.view.WindowManager; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; -import androidx.recyclerview.widget.GridLayoutManager; +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.yunbao.common.CommonAppConfig; import com.yunbao.common.R; -import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.adapter.CommentAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.bean.CommentBean; +import com.yunbao.common.glide.ImgLoader; +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.views.NineGridLayout; +import com.yunbao.common.views.TopGradual; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class CommunityDetailsActivity extends AbsActivity { - private RecyclerView mRecyclerViewImage; - private LinearLayout imgTextLayout; - private LinearLayout videoLayout; + ActiveBean activeBean; + private ImageView avatar; + private TextView name; + private TextView time; + private TextView content; + private LinearLayout followLayout; + private ImageView followIcon; + private TextView followName; + private NineGridLayout mNineGridLayout; + private ImageView videoImage; + private RecyclerView commentRecyclerView; + private CommentAdapter commentAdapter; + private TextView likeCount; + private ImageView userAvatar; + private ImageView like; + private TextView replyCount; @Override protected int getLayoutId() { + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); return R.layout.activity_community_details; } @@ -33,13 +69,129 @@ public class CommunityDetailsActivity extends AbsActivity { @Override protected void main() { + activeBean = getIntent().getParcelableExtra("active"); + initView(); + initData(); + getReply(); + } - mRecyclerViewImage = findViewById(R.id.recyclerView); - mRecyclerViewImage.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false)); - ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 15, 15); - decoration.setOnlySetItemOffsetsButNoDraw(true); - mRecyclerViewImage.addItemDecoration(decoration); + private void initView() { + replyCount = findViewById(R.id.replyCount); + like = findViewById(R.id.like); + userAvatar = findViewById(R.id.userAvatar); + likeCount = findViewById(R.id.likeCount); + avatar = findViewById(R.id.avatar); + name = findViewById(R.id.name); + time = findViewById(R.id.time); + content = findViewById(R.id.content); + followLayout = findViewById(R.id.followLayout); + followIcon = findViewById(R.id.followIcon); + followName = findViewById(R.id.followName); + videoImage = findViewById(R.id.videoImage); + mNineGridLayout = findViewById(R.id.nine_grid_layout); + commentRecyclerView = findViewById(R.id.commentListView); + commentRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + commentRecyclerView.addItemDecoration(new TopGradual()); + commentRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); + mNineGridLayout.setActionListener(new NineGridLayout.ActionListener() { + @Override + public void onItemClick(List dataList, int position) { + } + + @Override + public void displayImage(Object path, ImageView imageView) { + ImgLoader.display(CommunityDetailsActivity.this, String.valueOf(path), imageView); + } + }); + followLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommonHttpUtil.setAttention(activeBean.getUser_id(), new CommonCallback() { + @Override + public void callback(Integer isAttention) { + if (isAttention == 1) { + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like_followed, followIcon); + followName.setText("已关注"); + followName.setTextColor(Color.parseColor("#777777")); + followLayout.setBackground(getResources().getDrawable(R.drawable.bg_main_com_type_1)); + } else { + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like_follow, followIcon); + followName.setText("关注"); + followName.setTextColor(getResources().getColor(R.color.white)); + followLayout.setBackground(getResources().getDrawable(R.drawable.bg_main_com_type)); + } + } + }); + } + }); + like.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (activeBean.getIs_love().equals("1")) { + + } else { + + } + } + }); + findViewById(R.id.setting).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + } + + private void getReply() { + CommonHttpUtil.getCommunityComment(activeBean.getId(), activeBean.getUser_id(), new HttpCallback() { + @SuppressLint("SetTextI18n") + @Override + public void onSuccess(int code, String msg, String[] info) { + List list = JSON.parseArray(Arrays.toString(info), CommentBean.class); + if (list != null) { + commentAdapter = new CommentAdapter(mContext, list); + commentRecyclerView.setAdapter(commentAdapter); + replyCount.setText("评论 " + list.size()); + } + } + }); + } + + @SuppressLint("UseCompatLoadingForDrawables") + private void initData() { + ImgLoader.display(CommunityDetailsActivity.this, CommonAppConfig.getInstance().getUserBean().getAvatarThumb(), userAvatar); + ImgLoader.display(CommunityDetailsActivity.this, activeBean.getUser_avatar(), avatar); + name.setText(activeBean.getUser_name()); + time.setText(activeBean.getCreate_time()); + likeCount.setText(activeBean.getLove_num() + "人觉得很赞"); + content.setText(String.valueOf(JSONObject.parseObject(activeBean.getContent()).get("msg"))); + if (activeBean.getIs_attention().equals("1")) {//关注 + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like_followed, followIcon); + followName.setText("已关注"); + followName.setTextColor(Color.parseColor("#777777")); + followLayout.setBackground(getResources().getDrawable(R.drawable.bg_main_com_type_1)); + } else { + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like_follow, followIcon); + followName.setText("关注"); + followName.setTextColor(getResources().getColor(R.color.white)); + followLayout.setBackground(getResources().getDrawable(R.drawable.bg_main_com_type)); + } + if (activeBean.getImg_or_video().equals("1")) {//图片 + JSONArray jsonArray = (JSONArray) JSONArray.parse(activeBean.getImg_json()); + List tempList = new ArrayList<>(); + for (int i = 0; i < jsonArray.size(); i++) { + tempList.add(String.valueOf(jsonArray.get(i))); + } + mNineGridLayout.setData(tempList); + } else { + ImgLoader.display(CommunityDetailsActivity.this, activeBean.getUser_avatar(), videoImage); + } + if (activeBean.getIs_love().equals("1")) { + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like, like); + } else { + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like01, like); + } } @Override diff --git a/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java b/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java index ff8438f43..a61f18b09 100644 --- a/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java @@ -1,52 +1,171 @@ package com.yunbao.common.activity; +import android.Manifest; +import android.annotation.SuppressLint; +import android.content.ClipData; +import android.content.ContentResolver; import android.content.Intent; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.net.Uri; +import android.os.Build; +import android.provider.MediaStore; import android.view.View; +import android.widget.EditText; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; +import android.widget.VideoView; +import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.bigkoo.pickerview.builder.OptionsPickerBuilder; +import com.bigkoo.pickerview.builder.TimePickerBuilder; +import com.bigkoo.pickerview.listener.OnDismissListener; +import com.bigkoo.pickerview.listener.OnOptionsSelectListener; +import com.bigkoo.pickerview.listener.OnTimeSelectListener; +import com.bigkoo.pickerview.view.OptionsPickerView; +import com.bigkoo.pickerview.view.TimePickerView; +import com.lzy.okgo.utils.HttpUtils; import com.yunbao.common.R; import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; import com.yunbao.common.manager.OpenAdManager; -import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.utils.ActiveImageAdapter; +import com.yunbao.common.utils.DateFormatUtil; +import com.yunbao.common.utils.L; +import com.yunbao.common.utils.ProcessImageUtil; +import com.yunbao.common.utils.ProcessResultUtil; + +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; public class CommunitySendActivity extends AbsActivity { + public static final int PERMISSION_REQUEST_CODE_IMG = 0; + public static final int PERMISSION_REQUEST_CODE_VIDEO = 1; private RecyclerView mRecyclerViewImage; private LinearLayout imgTextLayout; private LinearLayout videoLayout; + private LinearLayout talkLayout; + private LinearLayout timeLayout; + private EditText content; + private TextView chooseTime; + private final int CHOOSE_IMG = 100;//Android 5.0以下的 + private final int CHOOSE_VIDEO = 200;//Android 5.0以上的 + private List uriList = new ArrayList<>(); + private Uri videoUri; + private ActiveImageAdapter activeImageAdapter; + private VideoView videoView; + private RelativeLayout videoViewLayout; + private ImageView delVideo; + private TextView talkContent; + private List talkList = new ArrayList<>(); + private TextView submit; + private boolean isImage; @Override protected int getLayoutId() { return R.layout.activity_community_send; } - @Override - protected void create() { - super.create(); - } - - @Override - protected void onPause() { - super.onPause(); - OpenAdManager.getInstance().dismiss(); - } - @Override protected void main() { + talkList.add("热门"); + talkList.add("新秀"); + talkList.add("颜值"); + talkList.add("舞蹈"); + talkList.add("男神"); + talkList.add("音乐"); + talkList.add("英语"); + + content = findViewById(R.id.content); + submit = findViewById(R.id.submit); + submit.setVisibility(View.VISIBLE); + talkContent = findViewById(R.id.talkContent); + delVideo = findViewById(R.id.delVideo); + videoViewLayout = findViewById(R.id.videoViewLayout); + videoView = findViewById(R.id.videoView); imgTextLayout = findViewById(R.id.imgTextLayout); videoLayout = findViewById(R.id.videoLayout); + talkLayout = findViewById(R.id.talkLayout); + timeLayout = findViewById(R.id.timeLayout); + chooseTime = findViewById(R.id.chooseTime); - imgTextLayout.setOnClickListener(new View.OnClickListener() { + submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + submit(); + } + }); + delVideo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + videoUri = null; + videoView.stopPlayback(); + videoViewLayout.setVisibility(View.GONE); + } + }); + talkLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showTalkChooseDialog(); + } + }); + timeLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showTimeChooseDialog(); + } + }); + imgTextLayout.setOnClickListener(new View.OnClickListener() { + @RequiresApi(api = Build.VERSION_CODES.TIRAMISU) + @Override + public void onClick(View v) { + String permission1 = Manifest.permission.READ_EXTERNAL_STORAGE; + String permission2 = Manifest.permission.WRITE_EXTERNAL_STORAGE; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + permission1 = Manifest.permission.READ_MEDIA_IMAGES; + permission2 = Manifest.permission.READ_MEDIA_VIDEO; + } + int isPermission1 = ContextCompat.checkSelfPermission(mContext, permission1); + int isPermission2 = ContextCompat.checkSelfPermission(mContext, permission2); + if (isPermission1 == PackageManager.PERMISSION_GRANTED && isPermission2 == PackageManager.PERMISSION_GRANTED) { + openImageChooserActivity(); + } else { + //申请权限 + ActivityCompat.requestPermissions(CommunitySendActivity.this, new String[]{permission1, permission2}, PERMISSION_REQUEST_CODE_IMG); + } } }); videoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + String permission1 = Manifest.permission.READ_EXTERNAL_STORAGE; + String permission2 = Manifest.permission.WRITE_EXTERNAL_STORAGE; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + permission1 = Manifest.permission.READ_MEDIA_IMAGES; + permission2 = Manifest.permission.READ_MEDIA_VIDEO; + } + int isPermission1 = ContextCompat.checkSelfPermission(mContext, permission1); + int isPermission2 = ContextCompat.checkSelfPermission(mContext, permission2); + if (isPermission1 == PackageManager.PERMISSION_GRANTED && isPermission2 == PackageManager.PERMISSION_GRANTED) { + openVideoChooserActivity(); + } else { + //申请权限 + ActivityCompat.requestPermissions(CommunitySendActivity.this, new String[]{permission1, permission2}, PERMISSION_REQUEST_CODE_VIDEO); + } } }); @@ -55,11 +174,174 @@ public class CommunitySendActivity extends AbsActivity { ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 15, 15); decoration.setOnlySetItemOffsetsButNoDraw(true); mRecyclerViewImage.addItemDecoration(decoration); + activeImageAdapter = new ActiveImageAdapter(CommunitySendActivity.this); + mRecyclerViewImage.setAdapter(activeImageAdapter); + mRecyclerViewImage.setVisibility(View.VISIBLE); + activeImageAdapter.setActionListener(new ActiveImageAdapter.ActionListener() { + @Override + public void onAddClick() { + } + + @Override + public void onItemClick(int position) { + + } + + @Override + public void onDeleteAll() { + + } + + @Override + public void onDel(int position) { + + } + }); + } + + private void submit() { + StringBuffer files = new StringBuffer(); + if (isImage) { + for (int i = 0; i < uriList.size(); i++) { + if (i == 0) { + files.append(uri2File(uriList.get(i)).getPath()); + } else { + files.append("," + uri2File(uriList.get(i)).getPath()); + } + } + } else { + files.append(uri2File(videoUri).getPath()); + } + CommonHttpUtil.pushCommunity(isImage, content.getText().toString(), "1", files.toString(), chooseTime.getText().toString(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + + } + }); + } + + private void showTalkChooseDialog() { + OptionsPickerView pickerView = new OptionsPickerBuilder(CommunitySendActivity.this, new OnOptionsSelectListener() { + @Override + public void onOptionsSelect(int options1, int options2, int options3, View v) { + talkContent.setText(talkList.get(options1)); + } + }).setTitleText("选择话题").setContentTextSize(16).build(); + pickerView.setPicker(talkList, null, null); + pickerView.show(); } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent intent) { - super.onActivityResult(requestCode, resultCode, intent); + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode == PERMISSION_REQUEST_CODE_IMG) { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + openImageChooserActivity(); + } else { + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE_IMG); + } + } + if (requestCode == PERMISSION_REQUEST_CODE_VIDEO) { + if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + openVideoChooserActivity(); + } else { + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE_VIDEO); + } + } + } + + public void showTimeChooseDialog() { + TimePickerView timePickerView = new TimePickerBuilder(CommunitySendActivity.this, new OnTimeSelectListener() { + @SuppressLint("SetTextI18n") + @Override + public void onTimeSelect(Date date, View v) { + chooseTime.setText(DateFormatUtil.getTimeStrings(date.getTime())); + } + }).setType(new boolean[]{true, true, true, true, true, false})// 默认全部显示 + .setCancelText("Cancel")//取消按钮文字 + .setSubmitText("Sure")//确认按钮文字 + .setTitleSize(20)//标题文字大小 + .setTitleText("Title")//标题文字 + .setOutSideCancelable(false)//点击屏幕,点在控件外部范围时,是否取消显示 + .isCyclic(true)//是否循环滚动 + .setLabel("年", "月", "日", "时", "分", "")//默认设置为年月日时分秒 + .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。 + .build(); + timePickerView.show(); + timePickerView.setOnDismissListener(new OnDismissListener() { + @Override + public void onDismiss(Object o) { + + } + }); + } + + private void openImageChooserActivity() { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("image/*"); + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); + startActivityForResult(intent, CHOOSE_IMG); + } + + private void openVideoChooserActivity() { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("video/*"); + startActivityForResult(intent, CHOOSE_VIDEO); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode == RESULT_OK && requestCode == CHOOSE_IMG) { + // 获取用户选择的图片 URI + Uri[] imageUris = null; + if (data != null) { + ClipData clipData = data.getClipData(); + if (clipData != null) { + // 如果支持多选,则通过 getItemAt() 方法获取每个被选中的图片 URI + imageUris = new Uri[clipData.getItemCount()]; + List tempList = new ArrayList<>(); + for (int i = 0; i < clipData.getItemCount(); i++) { + imageUris[i] = clipData.getItemAt(i).getUri(); + File file = new File(uri2File(imageUris[i]).getPath()); + tempList.add(file.getPath()); + L.e("imageUris:" + imageUris[i].getPath() + "_" + imageUris[i].getEncodedPath()); + } + activeImageAdapter.insertList(tempList); + } else { + // 单选情况下直接获取图片 URI + imageUris = new Uri[]{data.getData()}; + uriList.add(imageUris[0]); + List tempList = new ArrayList<>(); + File file = new File(uri2File(imageUris[0]).getPath()); + tempList.add(file.getPath()); + activeImageAdapter.insertList(tempList); + } + } + isImage = true; + } else if (requestCode == CHOOSE_VIDEO && resultCode == RESULT_OK && data != null) { + Uri uri = data.getData(); + videoUri = uri; + videoView.setVideoURI(videoUri); + videoView.start(); + videoViewLayout.setVisibility(View.VISIBLE); + isImage = false; + } + } + + private File uri2File(Uri uri) { + String img_path; + String[] proj = {MediaStore.Images.Media.DATA}; + Cursor actualimagecursor = this.managedQuery(uri, proj, null, null, null); + if (actualimagecursor == null) { + img_path = uri.getPath(); + } else { + int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); + actualimagecursor.moveToFirst(); + img_path = actualimagecursor.getString(actual_image_column_index); + } + File file = new File(img_path); + return file; } } diff --git a/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java new file mode 100644 index 000000000..a5054e2a5 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java @@ -0,0 +1,117 @@ +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 android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.bean.CommentBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.views.TopGradual; + +import java.util.List; + +public class CommentAdapter extends RecyclerView.Adapter { + private List commentBeanList; + private Context mContext; + + public CommentAdapter(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_comment_view, 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; + private TextView name; + private TextView content; + private TextView report; + private RoundedImageView mAvatar01; + private RoundedImageView mAvatar02; + private TextView replyContent; + private TextView replyCount; + private RecyclerView recyclerView; + private LinearLayout replyLayout; + + public CommentViewHolder(@NonNull View itemView) { + super(itemView); + mAvatar = itemView.findViewById(R.id.avatar); + name = itemView.findViewById(R.id.name); + content = itemView.findViewById(R.id.content); + report = itemView.findViewById(R.id.report); + mAvatar01 = itemView.findViewById(R.id.avatar01); + mAvatar02 = itemView.findViewById(R.id.avatar02); + replyContent = itemView.findViewById(R.id.replyContent); + replyCount = itemView.findViewById(R.id.expand); + replyLayout = itemView.findViewById(R.id.replyLayout); + recyclerView = itemView.findViewById(R.id.recyclerView); + } + + @SuppressLint("SetTextI18n") + public void setData(CommentBean bean) { + ImgLoader.display(itemView.getContext(), bean.getUser_avatar(), mAvatar); + name.setText(bean.getUser_name()); + content.setText(bean.getContent()); + if (bean.getReplyCommentList() != null) { + replyCount.setText("共" + bean.getReplyCommentList().size() + "条回复>"); + 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); + 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() + "条回复>"); + } + bean.setShow(!bean.isShow()); + } + }); + } + } + } + +} diff --git a/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java new file mode 100644 index 000000000..dc0527fa0 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java @@ -0,0 +1,69 @@ +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 android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.bean.CommentBean; +import com.yunbao.common.glide.ImgLoader; + +import java.util.List; + +public class CommentReplyAdapter extends RecyclerView.Adapter { + private List commentBeanList; + private Context mContext; + + public CommentReplyAdapter(Context content, List commentBeanList) { + this.mContext = content; + this.commentBeanList = commentBeanList; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View runGamesView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_reply_view, parent, false); + return new CommentViewHolder(runGamesView); + } + + @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 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/bean/ActiveBean.java b/common/src/main/java/com/yunbao/common/bean/ActiveBean.java new file mode 100644 index 000000000..dbae4db35 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/ActiveBean.java @@ -0,0 +1,281 @@ +package com.yunbao.common.bean; + +import android.os.Parcel; +import android.os.Parcelable; + +import androidx.annotation.NonNull; + +/** + * 社區动态 + */ +public class ActiveBean extends BaseModel implements Parcelable { + private String id; + private String img_or_video; + private String img_json; + private String video; + private String content; + private String talk_id; + private String love_num; + private String comment_num; + private String share_num; + private String gift_num; + private String hot_num; + private String create_time; + private String ai_content; + private String is_delete; + private String user_name; + private String user_avatar; + private String is_anchor; + private String is_live; + private String is_attention; + private String user_id; + private String talk_name; + private String is_love; + + public ActiveBean() { + } + + protected ActiveBean(Parcel in) { + id = in.readString(); + img_or_video = in.readString(); + img_json = in.readString(); + video = in.readString(); + content = in.readString(); + talk_id = in.readString(); + love_num = in.readString(); + comment_num = in.readString(); + share_num = in.readString(); + gift_num = in.readString(); + hot_num = in.readString(); + create_time = in.readString(); + ai_content = in.readString(); + is_delete = in.readString(); + user_name = in.readString(); + user_avatar = in.readString(); + is_anchor = in.readString(); + is_live = in.readString(); + is_attention = in.readString(); + user_id = in.readString(); + talk_name = in.readString(); + is_love = in.readString(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public ActiveBean createFromParcel(Parcel in) { + return new ActiveBean(in); + } + + @Override + public ActiveBean[] newArray(int size) { + return new ActiveBean[size]; + } + }; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getImg_or_video() { + return img_or_video; + } + + public void setImg_or_video(String img_or_video) { + this.img_or_video = img_or_video; + } + + public String getImg_json() { + return img_json; + } + + public void setImg_json(String img_json) { + this.img_json = img_json; + } + + public String getVideo() { + return video; + } + + public void setVideo(String video) { + this.video = video; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getTalk_id() { + return talk_id; + } + + public void setTalk_id(String talk_id) { + this.talk_id = talk_id; + } + + public String getLove_num() { + return love_num; + } + + public void setLove_num(String love_num) { + this.love_num = love_num; + } + + public String getComment_num() { + return comment_num; + } + + public void setComment_num(String comment_num) { + this.comment_num = comment_num; + } + + public String getShare_num() { + return share_num; + } + + public void setShare_num(String share_num) { + this.share_num = share_num; + } + + public String getGift_num() { + return gift_num; + } + + public void setGift_num(String gift_num) { + this.gift_num = gift_num; + } + + public String getHot_num() { + return hot_num; + } + + public void setHot_num(String hot_num) { + this.hot_num = hot_num; + } + + public String getCreate_time() { + return create_time; + } + + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + + public String getAi_content() { + return ai_content; + } + + public void setAi_content(String ai_content) { + this.ai_content = ai_content; + } + + public String getIs_delete() { + return is_delete; + } + + public void setIs_delete(String is_delete) { + this.is_delete = is_delete; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getUser_avatar() { + return user_avatar; + } + + public void setUser_avatar(String user_avatar) { + this.user_avatar = user_avatar; + } + + public String getIs_anchor() { + return is_anchor; + } + + public void setIs_anchor(String is_anchor) { + this.is_anchor = is_anchor; + } + + public String getIs_live() { + return is_live; + } + + public void setIs_live(String is_live) { + this.is_live = is_live; + } + + public String getIs_attention() { + return is_attention; + } + + public void setIs_attention(String is_attention) { + this.is_attention = is_attention; + } + + public String getUser_id() { + return user_id; + } + + public void setUser_id(String user_id) { + this.user_id = user_id; + } + + public String getTalk_name() { + return talk_name; + } + + public void setTalk_name(String talk_name) { + this.talk_name = talk_name; + } + + public String getIs_love() { + return is_love; + } + + public void setIs_love(String is_love) { + this.is_love = is_love; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeString(id); + dest.writeString(img_or_video); + dest.writeString(img_json); + dest.writeString(video); + dest.writeString(content); + dest.writeString(talk_id); + dest.writeString(love_num); + dest.writeString(comment_num); + dest.writeString(share_num); + dest.writeString(gift_num); + dest.writeString(hot_num); + dest.writeString(create_time); + dest.writeString(ai_content); + dest.writeString(is_delete); + dest.writeString(user_name); + dest.writeString(user_avatar); + dest.writeString(is_anchor); + dest.writeString(is_live); + dest.writeString(is_attention); + dest.writeString(user_id); + dest.writeString(talk_name); + dest.writeString(is_love); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/ActiveImageBean.java b/common/src/main/java/com/yunbao/common/bean/ActiveImageBean.java new file mode 100644 index 000000000..1eb0d079c --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/ActiveImageBean.java @@ -0,0 +1,23 @@ +package com.yunbao.common.bean; + +import java.io.File; + +public class ActiveImageBean { + private File mImageFile; + + public ActiveImageBean() { + + } + + public ActiveImageBean(File imageFile) { + mImageFile = imageFile; + } + + public File getImageFile() { + return mImageFile; + } + + public void setImageFile(File imageFile) { + mImageFile = imageFile; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/CommentBean.java b/common/src/main/java/com/yunbao/common/bean/CommentBean.java new file mode 100644 index 000000000..49e4c522b --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CommentBean.java @@ -0,0 +1,229 @@ +package com.yunbao.common.bean; + +import java.util.List; + +/** + * 社區动态 + */ +public class CommentBean extends BaseModel { + private String id; + private String dynamic_id; + private String uid; + private String to_comment_id; + private String content; + private String create_time; + private String status; + private String is_dynamic_user; + private String user_name; + private String user_id; + private String user_avatar; + private List child; + private boolean isShow; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDynamic_id() { + return dynamic_id; + } + + public void setDynamic_id(String dynamic_id) { + this.dynamic_id = dynamic_id; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getTo_comment_id() { + return to_comment_id; + } + + public void setTo_comment_id(String to_comment_id) { + this.to_comment_id = to_comment_id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getCreate_time() { + return create_time; + } + + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getIs_dynamic_user() { + return is_dynamic_user; + } + + public void setIs_dynamic_user(String is_dynamic_user) { + this.is_dynamic_user = is_dynamic_user; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getUser_id() { + return user_id; + } + + public void setUser_id(String user_id) { + this.user_id = user_id; + } + + public String getUser_avatar() { + return user_avatar; + } + + public void setUser_avatar(String user_avatar) { + this.user_avatar = user_avatar; + } + + public List getReplyCommentList() { + return child; + } + + public void setReplyCommentList(List replyCommentList) { + this.child = replyCommentList; + } + + public boolean isShow() { + return isShow; + } + + public void setShow(boolean show) { + isShow = show; + } + + public static class ReplyComment { + private String id; + private String dynamic_id; + private String uid; + private String to_comment_id; + private String content; + private String create_time; + private String status; + private String is_dynamic_user; + private String user_name; + private String user_id; + private String user_avatar; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDynamic_id() { + return dynamic_id; + } + + public void setDynamic_id(String dynamic_id) { + this.dynamic_id = dynamic_id; + } + + public String getUid() { + return uid; + } + + public void setUid(String uid) { + this.uid = uid; + } + + public String getTo_comment_id() { + return to_comment_id; + } + + public void setTo_comment_id(String to_comment_id) { + this.to_comment_id = to_comment_id; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getCreate_time() { + return create_time; + } + + public void setCreate_time(String create_time) { + this.create_time = create_time; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getIs_dynamic_user() { + return is_dynamic_user; + } + + public void setIs_dynamic_user(String is_dynamic_user) { + this.is_dynamic_user = is_dynamic_user; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getUser_id() { + return user_id; + } + + public void setUser_id(String user_id) { + this.user_id = user_id; + } + + public String getUser_avatar() { + return user_avatar; + } + + public void setUser_avatar(String user_avatar) { + this.user_avatar = user_avatar; + } + } + +} diff --git a/common/src/main/java/com/yunbao/common/bean/MessageChatUserBean.java b/common/src/main/java/com/yunbao/common/bean/MessageChatUserBean.java new file mode 100644 index 000000000..c56507b7e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/MessageChatUserBean.java @@ -0,0 +1,93 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; +import com.yunbao.common.utils.StringUtil; + +public class MessageChatUserBean extends UserBean{ + private String type; + private int modelType; + @SerializedName("user_nicename") + protected String userNiceName; + @SerializedName("isAttention") + private int attention;//isAttention 1被关注 2已关注 3互相关注 + + + public String getType() { + return type; + } + + public void setType(int type){ + this.type=type+""; + } + public int getTypeInt(){ + if(StringUtil.isEmpty(type)){ + return 0; + } + return Integer.parseInt(type); + } + + + @Override + public String getUserNiceName() { + return userNiceName; + } + + public int getModelType() { + return modelType; + } + + public void setModelType(int modelType) { + this.modelType = modelType; + } + + @Override + public void setUserNiceName(String userNiceName) { + this.userNiceName = userNiceName; + } + + public int getAttention() { + return attention; + } + + public void setAttention(int attention) { + this.attention = attention; + } + + @Override + public String toString() { + return "MessageChatUserBean{" + + "type='" + type + '\'' + + ", modelType='" + modelType + '\'' + + ", userNiceName='" + userNiceName + '\'' + + ", id='" + id + '\'' + + ", userNiceName='" + userNiceName + '\'' + + ", avatar='" + avatar + '\'' + + ", avatarThumb='" + avatarThumb + '\'' + + ", sex=" + sex + + ", signature='" + signature + '\'' + + ", coin='" + coin + '\'' + + ", gold='" + gold + '\'' + + ", votes='" + votes + '\'' + + ", consumption='" + consumption + '\'' + + ", votestotal='" + votestotal + '\'' + + ", province='" + province + '\'' + + ", city='" + city + '\'' + + ", location='" + location + '\'' + + ", birthday='" + birthday + '\'' + + ", level=" + level + + ", levelAnchor=" + levelAnchor + + ", lives=" + lives + + ", follows=" + follows + + ", fans=" + fans + + ", vip=" + vip + + ", liang=" + liang + + ", car=" + car + + ", medal_level=" + medal_level + + ", medal_name='" + medal_name + '\'' + + ", Dress=" + Dress + + ", noble_id='" + noble_id + '\'' + + ", yuanbao='" + yuanbao + '\'' + + ", typeMic=" + typeMic + + '}'; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java b/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java new file mode 100644 index 000000000..976191284 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/MessageUserInfoBean.java @@ -0,0 +1,449 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; +import com.yunbao.common.utils.StringUtil; + +import java.util.List; + +public class MessageUserInfoBean extends BaseModel{ + IMLoginModel user; + UserInfo info; + UserLevel level; + @SerializedName("gift_num") + int giftNum; + + int status; //0 需要跳转到 编辑资料页面 + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public MessageUserInfoBean() { + } + + public IMLoginModel getUser() { + return user; + } + + public void setUser(IMLoginModel user) { + this.user = user; + } + + public UserInfo getInfo() { + return info; + } + + public void setInfo(UserInfo info) { + this.info = info; + } + + public UserLevel getLevel() { + return level; + } + + public void setLevel(UserLevel level) { + this.level = level; + } + + public int getGiftNum() { + return giftNum; + } + + public void setGiftNum(int giftNum) { + this.giftNum = giftNum; + } + + public static class UserInfo { + private int id; + private String label_id; + private List cn_label; + private List en_label; + private int first_mate; + private long create_time; + private long update_time; + private int sex; + private int b_y; + private int b_ym; + private String b_ymd; + private int name_auth;//1 未提交 2 已认证 3已提交 4被驳回 + private long name_auth_time; + private String auth_front; + private String auth_back; + private String auth_remark; + private int sage_auth;//1 未提交 2 已认证 3已提交 4被驳回 + private long sage_auth_time; + private int is_hot; + private String vodie_price; + private String price; + private int star; + private String area; + private int is_hello; + private String star_name; + + public UserInfo() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getLabel_id() { + return label_id; + } + + public void setLabel_id(String label_id) { + this.label_id = label_id; + } + + public List getCn_label() { + return cn_label; + } + + public void setCn_label(List cn_label) { + this.cn_label = cn_label; + } + + public List getEn_label() { + return en_label; + } + + public void setEn_label(List en_label) { + this.en_label = en_label; + } + + public int getFirst_mate() { + return first_mate; + } + + public void setFirst_mate(int first_mate) { + this.first_mate = first_mate; + } + + public long getCreate_time() { + return create_time; + } + + public void setCreate_time(long create_time) { + this.create_time = create_time; + } + + public long getUpdate_time() { + return update_time; + } + + public void setUpdate_time(long update_time) { + this.update_time = update_time; + } + + public int getSex() { + return sex; + } + + public void setSex(int sex) { + this.sex = sex; + } + + public int getB_y() { + return b_y; + } + + public void setB_y(int b_y) { + this.b_y = b_y; + } + + public int getB_ym() { + return b_ym; + } + + public void setB_ym(int b_ym) { + this.b_ym = b_ym; + } + + public String getB_ymd() { + return b_ymd; + } + + public void setB_ymd(String b_ymd) { + this.b_ymd = b_ymd; + } + + public int getName_auth() { + return name_auth; + } + + public void setName_auth(int name_auth) { + this.name_auth = name_auth; + } + + public long getName_auth_time() { + return name_auth_time; + } + + public void setName_auth_time(long name_auth_time) { + this.name_auth_time = name_auth_time; + } + + public String getAuth_front() { + return auth_front; + } + + public void setAuth_front(String auth_front) { + this.auth_front = auth_front; + } + + public String getAuth_back() { + return auth_back; + } + + public void setAuth_back(String auth_back) { + this.auth_back = auth_back; + } + + public String getAuth_remark() { + return auth_remark; + } + + public void setAuth_remark(String auth_remark) { + this.auth_remark = auth_remark; + } + + public int getSage_auth() { + return sage_auth; + } + + public void setSage_auth(int sage_auth) { + this.sage_auth = sage_auth; + } + + public long getSage_auth_time() { + return sage_auth_time; + } + + public void setSage_auth_time(long sage_auth_time) { + this.sage_auth_time = sage_auth_time; + } + + public int getIs_hot() { + return is_hot; + } + + public void setIs_hot(int is_hot) { + this.is_hot = is_hot; + } + + public String getVodie_price() { + return vodie_price; + } + + public void setVodie_price(String vodie_price) { + this.vodie_price = vodie_price; + } + + public String getPrice() { + return price; + } + + public void setPrice(String price) { + this.price = price; + } + + public int getStar() { + return star; + } + + public void setStar(int star) { + this.star = star; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public int getIs_hello() { + return is_hello; + } + + public void setIs_hello(int is_hello) { + this.is_hello = is_hello; + } + + public String getStar_name() { + return star_name; + } + + public void setStar_name(String star_name) { + this.star_name = star_name; + } + } + + public static class UserLevel { + private int id; + private int wealth; + private int wealth_level; + private int charm; + private int charm_level; + private int level; + private int exp; + private long wealth_update; + private long wealth_level_update; + private long charm_update; + private long charm_level_update; + private long exp_update; + private long level_update; + private long create_time; + private String icon; + private String charm_icon; + private String wealth_icon; + + public UserLevel() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getWealth() { + return wealth; + } + + public void setWealth(int wealth) { + this.wealth = wealth; + } + + public int getWealth_level() { + return wealth_level; + } + + public void setWealth_level(int wealth_level) { + this.wealth_level = wealth_level; + } + + public int getCharm() { + return charm; + } + + public void setCharm(int charm) { + this.charm = charm; + } + + public int getCharm_level() { + return charm_level; + } + + public void setCharm_level(int charm_level) { + this.charm_level = charm_level; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public int getExp() { + return exp; + } + + public void setExp(int exp) { + this.exp = exp; + } + + public long getWealth_update() { + return wealth_update; + } + + public void setWealth_update(long wealth_update) { + this.wealth_update = wealth_update; + } + + public long getWealth_level_update() { + return wealth_level_update; + } + + public void setWealth_level_update(long wealth_level_update) { + this.wealth_level_update = wealth_level_update; + } + + public long getCharm_update() { + return charm_update; + } + + public void setCharm_update(long charm_update) { + this.charm_update = charm_update; + } + + public long getCharm_level_update() { + return charm_level_update; + } + + public void setCharm_level_update(long charm_level_update) { + this.charm_level_update = charm_level_update; + } + + public long getExp_update() { + return exp_update; + } + + public void setExp_update(long exp_update) { + this.exp_update = exp_update; + } + + public long getLevel_update() { + return level_update; + } + + public void setLevel_update(long level_update) { + this.level_update = level_update; + } + + public long getCreate_time() { + return create_time; + } + + public void setCreate_time(long create_time) { + this.create_time = create_time; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public String getCharm_icon() { + return charm_icon; + } + + public void setCharm_icon(String charm_icon) { + this.charm_icon = charm_icon; + } + + public String getWealth_icon() { + return wealth_icon; + } + + public void setWealth_icon(String wealth_icon) { + this.wealth_icon = wealth_icon; + } + } +} 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 2e28c2a88..b9de3c2d7 100644 --- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java @@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.lzy.okgo.OkGo; +import com.lzy.okgo.callback.Callback; import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.model.Response; import com.lzy.okgo.request.PostRequest; @@ -338,7 +339,7 @@ public class CommonHttpUtil { */ public static void getBalance(HttpCallback callback) { String isGoogle; - if (CommonAppConfig.IS_GOOGLE_PLAY==1) { + if (CommonAppConfig.IS_GOOGLE_PLAY == 1) { isGoogle = "1"; } else { isGoogle = "-1"; @@ -495,6 +496,63 @@ public class CommonHttpUtil { // .execute(callback); // } + /** + * 发送动态 + * + * @param isImgOrVideo + * @param content + * @param talkId + * @param fileAry + * @param createAt + * @param callback + */ + public static void pushCommunity(boolean isImgOrVideo, String content, String talkId, String fileAry, String createAt, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.sendDynamic", CommonHttpConsts.GET_USER_BASEINFO) + .params("img_or_video", isImgOrVideo ? 1 : 2) + .params("content", content) + .params("talk_id", talkId) + .params("file_name_ary", fileAry) + .params("created_at", createAt) + .execute(callback); + } + + /** + * 获取动态列表-热门 + * + * @param callback + */ + public static void getCommunityHotList(int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getFindDynamicList", "Pdlcommunity.getFindDynamicList") + .params("p", p) + .execute(callback); + } + + + /** + * 获取动态列表-热门 + * + * @param callback + */ + public static void getCommunityDetails(String dynamic_id, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getDynamicInfo", "Pdlcommunity.getDynamicInfo") + .params("dynamic_id", dynamic_id) + .execute(callback); + } + + /** + * 获取动态列表-评论 + * + * @param callback + */ + public static void getCommunityComment(String dynamic_id, String dynamic_uid, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getDynamicCommentList", "Pdlcommunity.getDynamicCommentList") + .params("dynamic_id", dynamic_id) + .params("dynamic_uid", dynamic_uid) + .execute(callback); + } + + + } diff --git a/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java b/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java index 616a2d0f7..fa01db24f 100644 --- a/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java @@ -351,6 +351,7 @@ public class LiveHttpUtil { .params("p", p) .execute(callback); } + public static void getContactMsg(int page, HttpCallback callback) { HttpClient.getInstance().get("Live.getContactMsg", "getContactMsg") .params("p", page) @@ -645,6 +646,7 @@ public class LiveHttpUtil { .params("appVersion", CommonAppConfig.getInstance().getVersion()) .execute(callback); } + /** * 观众给主播送礼物 - 包裹 * @@ -662,6 +664,7 @@ public class LiveHttpUtil { .params("appVersion", CommonAppConfig.getInstance().getVersion()) .execute(callback); } + /** * 观众给主播送礼物 - 粉丝团 * @@ -679,6 +682,7 @@ public class LiveHttpUtil { .params("appVersion", CommonAppConfig.getInstance().getVersion()) .execute(callback); } + public static void sendBlindBoxTicket(String by, String liveUid, String stream, int giftId, HttpCallback callback) { HttpClient.getInstance().get("Live.sendBlindBoxTicket", LiveHttpConsts.SEND_GIFT) .params("liveuid", liveUid) @@ -1040,10 +1044,9 @@ public class LiveHttpUtil { /** * 获取短剧Url */ - public static void getCoolydrama(HttpCallback callback){ + public static void getCoolydrama(HttpCallback callback) { HttpClient.getInstance().get("cool.register", "Home.getFollow") - .params("lang", WordUtil.isNewZh()?"zh_CN":"en") + .params("lang", WordUtil.isNewZh() ? "zh_CN" : "en") .execute(callback); } - } diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 537b97f59..69a6b4f98 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -43,6 +43,8 @@ import com.yunbao.common.bean.LiveStetUpStatusModel; import com.yunbao.common.bean.LiveTaskModel; import com.yunbao.common.bean.LiveUserMailBoxModel; import com.yunbao.common.bean.MedalAchievementModel; +import com.yunbao.common.bean.MessageChatUserBean; +import com.yunbao.common.bean.MessageUserInfoBean; import com.yunbao.common.bean.MsgSwitchDetailModel; import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.bean.NobleRankHideUserListModel; @@ -68,6 +70,7 @@ import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudgameCodeModel; import com.yunbao.common.bean.UserAreaBean; import com.yunbao.common.bean.UserAvatarSelectBean; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; @@ -1162,4 +1165,17 @@ public interface PDLiveApi { @GET("/api/public/?service=Sudgameserver.getRoomMicStatus") Observable> getRoomMicStatus(); + + @GET("/api/public/?service=Pdluser.friend") + Observable>> getPdluserFriend(@Query("p") int p); + @GET("/api/public/?service=Pdluser.follow") + Observable>> getPdluserFollow(@Query("p") int p); + @GET("/api/public/?service=Pdluser.fans") + Observable>> getPdluserFans(@Query("p") int p); + @GET("/api/public/?service=Pdluser.search") + Observable>> addressBookSearch(@Query("user_nicename") String key); + @GET("/api/public/?service=Pdlinfos.getOtherInfo") + Observable> getOtherInfo(@Query("tuid") String tuid); + @GET("/api/public/?service=Userhome.getUserHomeBanner") + Observable>> getUserHomeBanner(@Query("select_uid") String tuid); } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 9b4321c7a..e799ca09f 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -43,6 +43,8 @@ import com.yunbao.common.bean.LiveStetUpStatusModel; import com.yunbao.common.bean.LiveTaskModel; import com.yunbao.common.bean.LiveUserMailBoxModel; import com.yunbao.common.bean.MedalAchievementModel; +import com.yunbao.common.bean.MessageChatUserBean; +import com.yunbao.common.bean.MessageUserInfoBean; import com.yunbao.common.bean.NobleRankHideUserListModel; import com.yunbao.common.bean.NobleTrumpetModel; import com.yunbao.common.bean.OpenAdModel; @@ -64,6 +66,7 @@ import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudgameCodeModel; import com.yunbao.common.bean.UserAreaBean; import com.yunbao.common.bean.UserAvatarSelectBean; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListModel; @@ -2770,7 +2773,7 @@ public class LiveNetManager { }).isDisposed(); } - public void addChatCount(String stream,HttpCallback callback) { + public void addChatCount(String stream, HttpCallback callback) { API.get().pdLiveApi(mContext) .addChatCount(stream) .subscribeOn(Schedulers.io()) @@ -2931,6 +2934,126 @@ public class LiveNetManager { } + public void getPdluserFollow(int p, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getPdluserFollow(p) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getOtherInfo(String touid, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getOtherInfo(touid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getPdluserFriend(int p, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getPdluserFriend(p) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getPdluserFans(int p, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getPdluserFans(p) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void addressBookSearch(String search, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .addressBookSearch(search) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getUserHomeBanner(String search,HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getUserHomeBanner(search) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(roomMicStatusModelResponseModel -> { + if (callback != null) { + callback.onSuccess(roomMicStatusModelResponseModel.getData().getInfo()); + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/utils/ActiveImageAdapter.java b/common/src/main/java/com/yunbao/common/utils/ActiveImageAdapter.java new file mode 100644 index 000000000..a802b8994 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/ActiveImageAdapter.java @@ -0,0 +1,208 @@ +package com.yunbao.common.utils; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.ActiveImageBean; +import com.yunbao.common.glide.ImgLoader; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class ActiveImageAdapter extends RecyclerView.Adapter { + + private Context mContext; + private List mList; + private LayoutInflater mInflater; + private View.OnClickListener mOnClickListener; + private View.OnClickListener mODelListener; + private ActionListener mActionListener; + + public ActiveImageAdapter(Context context) { + mContext = context; + mList = new ArrayList<>(); + mInflater = LayoutInflater.from(context); + mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag == null) { + return; + } + int position = (int) tag; + ActiveImageBean bean = mList.get(position); + if (bean.getImageFile() == null) { + if (mActionListener != null) { + mActionListener.onAddClick(); + } + } else { + if (mActionListener != null) { + mActionListener.onItemClick(position); + } + } + } + }; + mODelListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag == null) { + return; + } + int position = (int) tag; + ActiveImageBean bean = mList.get(position); + if (bean.getImageFile() == null) { + if (mActionListener != null) { + mActionListener.onAddClick(); + } + } else { + if (mActionListener != null) { + mActionListener.onDel(position); + } + } + } + }; + } + + public void setActionListener(ActionListener actionListener) { + mActionListener = actionListener; + } + + public void insertList(List imagePathList) { + int index = 0; + for (ActiveImageBean bean : mList) { + if (bean.getImageFile() == null) { + bean.setImageFile(new File(imagePathList.get(index))); + index++; + } + } + int moreCount = 9 - mList.size(); + if (moreCount > 0) { + moreCount = Math.min(moreCount, imagePathList.size() - index); + for (int i = 0; i < moreCount; i++) { + mList.add(new ActiveImageBean(new File(imagePathList.get(index + i)))); + } + } + if (mList.size() < 9) { + mList.add(new ActiveImageBean()); + } + notifyDataSetChanged(); + } + + public void deleteItem(int position) { + if (mList == null) { + return; + } + if (position >= 0 && position < mList.size()) { + mList.remove(position); + } + int size = mList.size(); + ActiveImageBean bean = mList.get(size - 1); + if (bean.getImageFile() != null) { + mList.add(new ActiveImageBean()); + } else { + if (size == 1) { + mList.clear(); + } + } + notifyDataSetChanged(); + if (mList.size() == 0 && mActionListener != null) { + mActionListener.onDeleteAll(); + } + } + + public List getImageFileList() { + List list = null; + for (ActiveImageBean bean : mList) { + File file = bean.getImageFile(); + if (file != null && file.exists()) { + if (list == null) { + list = new ArrayList<>(); + } + list.add(file); + } + } + return list; + } + + public int getImageFileCount() { + int count = 0; + for (ActiveImageBean bean : mList) { + File file = bean.getImageFile(); + if (file != null && file.exists()) { + count++; + } + } + return count; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int position) { + return new Vh(mInflater.inflate(R.layout.item_active_image, viewGroup, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { + ((Vh) vh).setData(mList.get(position), position); + } + + @Override + public int getItemCount() { + return mList.size(); + } + + + class Vh extends RecyclerView.ViewHolder { + + View mIconAdd; + ImageView mImg; + ImageView del; + + public Vh(@NonNull View itemView) { + super(itemView); + mIconAdd = itemView.findViewById(R.id.icon_add); + mImg = itemView.findViewById(R.id.img); + del = itemView.findViewById(R.id.del); + itemView.setOnClickListener(mOnClickListener); + del.setOnClickListener(mODelListener); + } + + void setData(ActiveImageBean bean, int position) { + itemView.setTag(position); + if (bean.getImageFile() == null) { + mImg.setImageDrawable(null); + if (mIconAdd.getVisibility() != View.VISIBLE) { + mIconAdd.setVisibility(View.VISIBLE); + } + if (del.getVisibility() != View.VISIBLE) { + del.setVisibility(View.VISIBLE); + } + } else { + if (mIconAdd.getVisibility() == View.VISIBLE) { + mIconAdd.setVisibility(View.INVISIBLE); + } + if (del.getVisibility() == View.VISIBLE) { + del.setVisibility(View.GONE); + } + ImgLoader.display(mContext, bean.getImageFile(), mImg); + } + } + } + + + public interface ActionListener { + void onAddClick(); + void onItemClick(int position); + void onDeleteAll(); + void onDel(int position); + } +} diff --git a/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java b/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java index 853e0e0ef..8b5bb110c 100644 --- a/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java @@ -1,7 +1,5 @@ package com.yunbao.common.utils; -import com.yunbao.common.http.Data; - import java.text.SimpleDateFormat; import java.util.Date; @@ -36,6 +34,13 @@ public class DateFormatUtil { return formattedDate; } + public static String getTimeStrings(long time) { + Date date = new Date(time); // 创建Date对象并传入时间戳参数 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // 设置日期格式 + String formattedDate = sdf.format(date); // 格式化日期字符串 + return formattedDate; + } + public static String getVideoCurTimeString() { return sFormat2.format(new Date()); diff --git a/common/src/main/java/com/yunbao/common/views/NineGridLayout.java b/common/src/main/java/com/yunbao/common/views/NineGridLayout.java new file mode 100644 index 000000000..b303cbce4 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/NineGridLayout.java @@ -0,0 +1,216 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.util.DisplayMetrics; +import android.view.Gravity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; + +import java.util.ArrayList; +import java.util.List; + +public class NineGridLayout extends FrameLayout { + + private Context mContext; + private int mWidth1; + private int mWidth2; + private int mWidth3; + private int mDividerWidth; + private int mCornerRadius; + private List mViewList; + private ActionListener mActionListener; + private LayoutParams mLayoutParams00; + private LayoutParams mLayoutParams10; + private LayoutParams mLayoutParams11; + private LayoutParams[] mLayoutParamsArray; + private OnClickListener mOnClickListener; + private List mDataList; + + + public NineGridLayout(Context context) { + this(context, null); + } + + public NineGridLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public NineGridLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + int space = 0; + int dividerWidth = 0; + TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.NineGridLayout); + space = (int) ta.getDimension(R.styleable.NineGridLayout_ngl_space, 0); + dividerWidth = (int) ta.getDimension(R.styleable.NineGridLayout_ngl_divider_width, 0); + mCornerRadius = (int) ta.getDimension(R.styleable.NineGridLayout_ngl_corner_radius, 0); + ta.recycle(); + mContext = context; + mViewList = new ArrayList<>(); + DisplayMetrics dm = context.getResources().getDisplayMetrics(); + float scale = dm.density; + int width = dm.widthPixels - space; + mDividerWidth = dividerWidth; + mWidth1 = (int) (scale * 220 + 0.5f); + mWidth2 = (width - dividerWidth) / 2; + mWidth3 = (width - dividerWidth * 2) / 3; + mOnClickListener = new OnClickListener() { + @Override + public void onClick(View v) { + if (mActionListener != null) { + for (int i = 0, size = mViewList.size(); i < size; i++) { + if (v == mViewList.get(i)) { + mActionListener.onItemClick(mDataList, i); + break; + } + } + } + } + }; + } + + + public void setData(List list) { + if (list == null) { + hideItem(0); + return; + } + int dataSize = list.size(); + if (dataSize == 0) { + hideItem(0); + return; + } + mDataList = list; + int viewSize = mViewList.size(); + if (viewSize < dataSize) { + for (int i = 0, size = dataSize - viewSize; i < size; i++) { + addItem(); + } + } else if (viewSize > dataSize) { + hideItem(dataSize); + } + if (dataSize == 1) { + RoundedImageView imageView = mViewList.get(0); + if (mLayoutParams00 == null) { + mLayoutParams00 = new LayoutParams(mWidth1, mWidth1); + } + if (imageView.getLayoutParams() != mLayoutParams00) { + imageView.setLayoutParams(mLayoutParams00); + } + if (imageView.getVisibility() != VISIBLE) { + imageView.setVisibility(VISIBLE); + } + setHeight(mWidth1); + if (mActionListener != null) { + mActionListener.displayImage(list.get(0), imageView); + } + } else if (dataSize == 2) { + RoundedImageView imageView0 = mViewList.get(0); + RoundedImageView imageView1 = mViewList.get(1); + if (mLayoutParams10 == null) { + mLayoutParams10 = new LayoutParams(mWidth2, mWidth2); + } + if (mLayoutParams11 == null) { + mLayoutParams11 = new LayoutParams(mWidth2, mWidth2); + mLayoutParams11.gravity = Gravity.RIGHT; + } + if (imageView0.getLayoutParams() != mLayoutParams10) { + imageView0.setLayoutParams(mLayoutParams10); + } + if (imageView1.getLayoutParams() != mLayoutParams11) { + imageView1.setLayoutParams(mLayoutParams11); + } + if (imageView0.getVisibility() != VISIBLE) { + imageView0.setVisibility(VISIBLE); + } + if (imageView1.getVisibility() != VISIBLE) { + imageView1.setVisibility(VISIBLE); + } + setHeight(mWidth2); + if (mActionListener != null) { + mActionListener.displayImage(list.get(0), imageView0); + mActionListener.displayImage(list.get(1), imageView1); + } + } else { + if (mLayoutParamsArray == null) { + mLayoutParamsArray = new LayoutParams[9]; + } + int rowCount = dataSize / 3; + if (dataSize % 3 != 0) { + rowCount++; + } + setHeight(mWidth3 * rowCount + mDividerWidth * (rowCount - 1)); + for (int i = 0; i < dataSize; i++) { + RoundedImageView imageView = mViewList.get(i); + if (mLayoutParamsArray[i] == null) { + mLayoutParamsArray[i] = new LayoutParams(mWidth3, mWidth3); + int row = i / 3;//行 + int col = i % 3;//列 + int margin = mWidth3 + mDividerWidth; + mLayoutParamsArray[i].leftMargin = margin * col; + mLayoutParamsArray[i].topMargin = margin * row; + } + if (imageView.getLayoutParams() != mLayoutParamsArray[i]) { + imageView.setLayoutParams(mLayoutParamsArray[i]); + } + if (imageView.getVisibility() != VISIBLE) { + imageView.setVisibility(VISIBLE); + } + if (mActionListener != null) { + mActionListener.displayImage(list.get(i), imageView); + } + } + } + } + + + private void setHeight(int height) { + ViewGroup.LayoutParams layoutParams = getLayoutParams(); + if (height != layoutParams.height) { + layoutParams.height = height; + requestLayout(); + } + } + + + private void hideItem(int fromIndex) { + for (int i = 0, size = mViewList.size(); i < size; i++) { + if (i >= fromIndex) { + RoundedImageView imageView = mViewList.get(i); + imageView.setImageDrawable(null); + if (imageView.getVisibility() == VISIBLE) { + imageView.setVisibility(INVISIBLE); + } + } + } + } + + private void addItem() { + RoundedImageView imageView = new RoundedImageView(mContext); + imageView.setCornerRadius(mCornerRadius); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + imageView.setOnClickListener(mOnClickListener); + mViewList.add(imageView); + addView(imageView); + } + + + public void setActionListener(ActionListener actionListener) { + mActionListener = actionListener; + } + + public interface ActionListener { + + void onItemClick(List dataList, int position); + + void displayImage(Object path, ImageView imageView); + } + + +} diff --git a/common/src/main/res/drawable/bg_item_comment.xml b/common/src/main/res/drawable/bg_item_comment.xml new file mode 100644 index 000000000..84fe7184e --- /dev/null +++ b/common/src/main/res/drawable/bg_item_comment.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_main_com_author.xml b/common/src/main/res/drawable/bg_main_com_author.xml new file mode 100644 index 000000000..ce80fef56 --- /dev/null +++ b/common/src/main/res/drawable/bg_main_com_author.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/common/src/main/res/drawable/bg_main_com_type_1.xml b/common/src/main/res/drawable/bg_main_com_type_1.xml new file mode 100644 index 000000000..17ffb4350 --- /dev/null +++ b/common/src/main/res/drawable/bg_main_com_type_1.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/common/src/main/res/layout/activity_community_details.xml b/common/src/main/res/layout/activity_community_details.xml index a5e7cee5d..99a9973dc 100644 --- a/common/src/main/res/layout/activity_community_details.xml +++ b/common/src/main/res/layout/activity_community_details.xml @@ -1,9 +1,11 @@ + android:orientation="vertical" + android:paddingTop="15dp"> @@ -14,7 +16,7 @@ @@ -22,14 +24,15 @@ + android:id="@+id/avatar" + android:layout_width="68dp" + android:layout_height="68dp" + android:src="@mipmap/icon_data_empty" + app:riv_corner_radius="20dp" /> + android:textColor="#AAAAAA" + android:textSize="12dp" /> - + android:layout_marginTop="15dp" + app:ngl_corner_radius="5dp" + app:ngl_divider_width="6dp" + app:ngl_space="30dp" /> + + + + + + + + @@ -129,6 +165,7 @@ android:gravity="center_vertical"> @@ -155,22 +193,24 @@ + android:paddingRight="20dp"> - + android:layout_marginBottom="10dp" + android:src="@mipmap/icon_data_empty" + app:riv_corner_radius="20dp" /> diff --git a/common/src/main/res/layout/activity_community_send.xml b/common/src/main/res/layout/activity_community_send.xml index 91781ac1d..8195f4133 100644 --- a/common/src/main/res/layout/activity_community_send.xml +++ b/common/src/main/res/layout/activity_community_send.xml @@ -6,196 +6,245 @@ - + android:layout_height="wrap_content"> - - - - - - - - - - - - + android:orientation="vertical"> - + - + + + + + + + + + + + android:layout_marginLeft="15dp" + android:layout_marginBottom="20dp" + android:visibility="visible"> + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_marginStart="15dp" + android:layout_marginTop="5dp" + android:layout_marginEnd="15dp" + android:background="@drawable/main_community_send_edit_bg" + android:orientation="vertical" + android:paddingLeft="15dp" + android:paddingTop="10dp" + android:paddingEnd="15dp" + android:paddingBottom="10dp"> - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/common/src/main/res/layout/item_active_image.xml b/common/src/main/res/layout/item_active_image.xml new file mode 100644 index 000000000..2ed7c3fe5 --- /dev/null +++ b/common/src/main/res/layout/item_active_image.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_comment_reply_view.xml b/common/src/main/res/layout/item_comment_reply_view.xml new file mode 100644 index 000000000..e6c175e78 --- /dev/null +++ b/common/src/main/res/layout/item_comment_reply_view.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_comment_view.xml b/common/src/main/res/layout/item_comment_view.xml new file mode 100644 index 000000000..172889a0c --- /dev/null +++ b/common/src/main/res/layout/item_comment_view.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-mdpi/icon_active_add.png b/common/src/main/res/mipmap-mdpi/icon_active_add.png new file mode 100644 index 000000000..0597a7a39 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_active_add.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_like01.png b/common/src/main/res/mipmap-mdpi/icon_like01.png new file mode 100644 index 000000000..e38de99f4 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_like01.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_like_followed.png b/common/src/main/res/mipmap-mdpi/icon_like_followed.png new file mode 100644 index 000000000..fc12f7329 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_like_followed.png differ diff --git a/common/src/main/res/values/attrs.xml b/common/src/main/res/values/attrs.xml index 46dfd145b..5c2bf8e7c 100644 --- a/common/src/main/res/values/attrs.xml +++ b/common/src/main/res/values/attrs.xml @@ -67,4 +67,11 @@ + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_main_com.xml b/live/src/main/res/layout/item_main_com.xml index afbeebebe..9be3fefdf 100644 --- a/live/src/main/res/layout/item_main_com.xml +++ b/live/src/main/res/layout/item_main_com.xml @@ -94,6 +94,7 @@ { - +public class MainHomeComAdapter extends RefreshAdapter { private Context mContext; + private View.OnClickListener mOnClickListener; - public void setmOnClickListener(View.OnClickListener mOnClickListener) { - this.mOnClickListener = mOnClickListener; - } - - private List heightList = new ArrayList<>(); - public MainHomeComAdapter(Context context) { super(context); this.mContext = context; + mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag != null && mOnItemClickListener != null) { + mOnItemClickListener.onItemClick((ActiveBean) tag, 0); + } + } + }; } @NonNull @@ -60,13 +62,13 @@ public class MainHomeComAdapter extends RefreshAdapter { } class Vh extends RecyclerView.ViewHolder { - TextView name; TextView title; TextView likeCount; ImageView img; ImageView author; LinearLayout heightLayout; + ImageView isVideo; public Vh(View itemView) { super(itemView); @@ -76,16 +78,30 @@ public class MainHomeComAdapter extends RefreshAdapter { author = itemView.findViewById(R.id.author); likeCount = itemView.findViewById(R.id.like_count); heightLayout = itemView.findViewById(R.id.imgLayout); + isVideo = itemView.findViewById(R.id.isVideo); itemView.setOnClickListener(mOnClickListener); } - void setData(LiveBean bean, int position) { + void setData(ActiveBean bean, int position) { itemView.setTag(bean); - //name.setText(bean.getCity()); - //title.setText(bean.getCity()); - likeCount.setText(bean.getNums()); - ImgLoader.display(mContext, "https://img2.baidu.com/it/u=1540900496,2036305732&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500", img); - ImgLoader.display(mContext, bean.getAvatar(), author); + 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); + } + 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(); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java index 496a0ab3a..cfe963061 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java @@ -8,7 +8,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import com.umeng.analytics.MobclickAgent; -import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.CommunitySendActivity; import com.yunbao.common.event.FloatWarOrderEvent; import com.yunbao.common.utils.RouteUtil; 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 1c81c60f1..dd16b3dcc 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java @@ -4,6 +4,7 @@ import android.animation.ObjectAnimator; import android.app.Dialog; import android.content.Context; import android.content.Intent; +import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; import android.view.View; @@ -14,36 +15,36 @@ 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.yunbao.common.activity.CommunityDetailsActivity; import com.yunbao.common.adapter.RefreshAdapter; -import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.BannerBean; -import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveClassBean; -import com.yunbao.common.bean.WeekListBean; +import com.yunbao.common.bean.VideoBean; import com.yunbao.common.custom.CommonRefreshWaterfallView; -import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.interfaces.OnItemClickListener; import com.yunbao.common.manager.LiveClassManager; import com.yunbao.common.manager.OpenAdManager; import com.yunbao.common.utils.DialogUitl; -import com.yunbao.common.utils.LiveRoomCheckLivePresenter; -import com.yunbao.common.utils.MicStatusManager; -import com.yunbao.common.utils.RouteUtil; -import com.yunbao.common.utils.ToastUtil; -import com.yunbao.live.utils.LiveStorge; -import com.yunbao.live.views.LiveRoomViewHolder; +import com.yunbao.live.adapter.LiveAdminRoomAdapter; +import com.yunbao.live.bean.LiveAdminRoomBean; +import com.yunbao.live.views.LiveMyRoomViewHolder; 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; @@ -60,23 +61,18 @@ import java.util.Map; * MainActivity 社区-热门 */ -public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { - private View mShadow; +public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { private View mBtnDismiss; public static CommonRefreshWaterfallView mRefreshView; private RecyclerView mClassRecyclerViewTop; private MainHomeComAdapter mAdapter; private ObjectAnimator mShowAnimator; private ObjectAnimator mHideAnimator; - private boolean mBannerShowed; - private List mBannerList; - private List mWeekListBean; public static ImageView btnUseIco; private int select = 0; //是否是首頁 private int intoIndex = 0; - private List new_data; - private boolean isHave = false; + private List new_data; private Map gotoRoomKey = new HashMap<>(); private Dialog mShowLoadingDialog; private String typeHot; @@ -114,7 +110,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements typeHot = list.get(0).getEnglish(); select = list.get(0).getId(); } - mShadow = findViewById(R.id.shadow); mBtnDismiss = findViewById(R.id.btn_dismiss); mBtnDismiss.setOnClickListener(new View.OnClickListener() { @Override @@ -134,22 +129,16 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live); EventBus.getDefault().register(this); - mAdapter = new MainHomeComAdapter(mContext); - mAdapter.setmOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(mContext, CommunityDetailsActivity.class); - mContext.startActivity(intent); - } - }); - mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this); - mAdapter.setHasStableIds(true);// mRefreshView.setLoadMoreEnable(true); mRefreshView.setRecyclerViewAdapter(mAdapter); - mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { @Override - public RefreshAdapter getAdapter() { - return null; + public RefreshAdapter getAdapter() { + if (mAdapter == null) { + mAdapter = new MainHomeComAdapter(mContext); + mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this); + } + return mAdapter; } @Override @@ -157,26 +146,7 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements Log.i("t2", "aaa" + p); if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) { pp = 1; - LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (mWeekListBean != null) { - mWeekListBean.clear(); - } - if (code == 0 && info.length > 0) { - mWeekListBean = JSON.parseArray(Arrays.toString(info), WeekListBean.class); - } else { - mWeekListBean = null; - } - if (mWeekListBean != null && mWeekListBean.size() > 0) { - isHave = true; - } else { - isHave = false; - } - Constants.getWeekIntIndex = Constants.getWeekIntIndex + 1; - MainHttpUtil.getHot(p, callback); - } - }); + CommonHttpUtil.getCommunityHotList(p, callback); } else { pp = 0; MainHttpUtil.getClassLive(select, p, callback); @@ -184,46 +154,15 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements } @Override - public List processData(String[] info) { + public List processData(String[] info) { new_data = new ArrayList<>(); - if (info.length > 0) { - JSONObject obj = JSON.parseObject(info[0]); - - mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class); - if (!obj.containsKey("list")) { - return new_data; - } - List old_data = JSON.parseArray(obj.getString("list"), LiveBean.class); - LiveBean liveModel = null; - if (old_data == null) { - return new_data; - } - for (LiveBean model : old_data) { - //判断周星榜数据 - if (TextUtils.equals(model.getIs_week(), "1")) { - if (mWeekListBean != null && mWeekListBean.size() > 0) { - model.setmWeekList(mWeekListBean); - } else { - liveModel = model; - } - } - } - //满足有周星榜字段但是没有周星榜数据的删掉 - if (liveModel != null) { - old_data.remove(liveModel); - } - new_data.addAll(old_data); - - } + new_data = JSON.parseArray(Arrays.toString(info), ActiveBean.class); return new_data; } @Override - public void onRefreshSuccess(List list, int count) { - if (CommonAppConfig.LIVE_ROOM_SCROLL) { - LiveStorge.getInstance().put(Constants.LIVE_HOME, list); - } - EventBus.getDefault().post(new AnchorRecommendModel()); + public void onRefreshSuccess(List list, int count) { + } @Override @@ -232,12 +171,10 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements } @Override - public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { new_data = new ArrayList<>(); for (int j = 0; j < loadItemList.size(); j++) { - if (loadItemList.get(j).getUserNiceName() != null) { - new_data.add(loadItemList.get(j)); - } + new_data.add(loadItemList.get(j)); } if (loadItemList.size() > 0) { mAdapter.insertList(new_data); @@ -295,7 +232,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mRefreshView.initData(); topAdapter.choice = position; topAdapter.notifyDataSetChanged(); - } }); if (mClassRecyclerViewTop != null) { @@ -305,39 +241,40 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mRefreshView.initData(); } + private VideoScrollDataHelper mVideoScrollDataHelper; - private void gotoLive(final String live_id) { - LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() { + @Override + public void onItemClick(ActiveBean bean, int position) { + Intent intent = new Intent(mContext, CommunityDetailsActivity.class); + intent.putExtra("active", (Parcelable) bean); + mContext.startActivity(intent); + + /*if (bean.getImg_or_video().equals("2")) { + if (mVideoScrollDataHelper == null) { + mVideoScrollDataHelper = new VideoScrollDataHelper() { + @Override + public void loadData(int p, HttpCallback callback) { + VideoHttpUtil.getHomeVideoList(p, callback); + } + }; + } + VideoStorge.getInstance().putDataHelper(Constants.VIDEO_HOME, mVideoScrollDataHelper); + VideoPlayActivity.forward(mContext, position, Constants.VIDEO_HOME, 1); + }*/ + /*VideoHttpUtil.getHomeVideoList(1, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); - if (liveBean == null) { - return; + if (code == 0) { + List tempList = new ArrayList<>(); + for (String s : info) { + VideoBean videoBean = JSONObject.parseObject(s, VideoBean.class); + tempList.add(videoBean); } - intoIndex = 1; - if (gotoRoomKey != null && gotoRoomKey.isEmpty()) { - gotoRoomKey = null; - } - liveBean.setParams(gotoRoomKey); - new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { - @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); - } - - @Override - public void onCheckError(String contextError) { - - } - }); - - } else { - intoIndex = 1; - RouteUtil.forwardUserHome(mContext, live_id, 0); + VideoStorge.getInstance().put(Constants.VIDEO_HOME, tempList); + VideoPlayActivity.forward(mContext, position, Constants.VIDEO_HOME, 1); } } - }); + });*/ } /** @@ -348,58 +285,6 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mShowLoadingDialog.show(); } - @Override - public void onItemClick(LiveBean bean, int position) { - if ("1".equals(bean.getIslive())) { - intoIndex = 1; - 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"; - LiveHttpUtil.getLiveInfo(bean.getUid(), new HttpCallback() { - @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info.length > 0) { - LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); - - if (liveBean == null) { - return; - } - new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { - @Override - public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { - - if (LiveRoomViewHolder.mHandler != null) { - LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); - } - if (!"".endsWith(Constants.mStream)) { - if (MicStatusManager.getInstance().isMic(liveUid)) { - MicStatusManager.getInstance().showDownMicDialog(mContext); - return; - } - EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal))); - } else { - RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk)); - } - } - - @Override - public void onCheckError(String contextError) { - - } - }); - - } else { - ToastUtil.show(msg); - } - } - }); - } else { - intoIndex = 1; - RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); - } - } - - @Override public void loadData() { } @@ -437,4 +322,5 @@ public class MainHomeNewViewHolder extends AbsMainHomeChildViewHolder implements mShowLoadingDialog = null; } } + } diff --git a/main/src/main/res/layout/view_main_home_com.xml b/main/src/main/res/layout/view_main_home_com.xml index 695ad2f37..8ffe7c2d1 100644 --- a/main/src/main/res/layout/view_main_home_com.xml +++ b/main/src/main/res/layout/view_main_home_com.xml @@ -11,7 +11,7 @@ android:id="@+id/appBarLayout" android:layout_width="match_parent" android:layout_height="70dp" - android:layout_marginTop="10dp" + android:layout_marginTop="20dp" android:background="@android:color/transparent" android:fadingEdge="none" app:elevation="0dp" diff --git a/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java index 1750df210..d25d51daf 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoPlayViewHolder.java @@ -70,10 +70,7 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList mVideoCover = findViewById(R.id.video_cover); mPlayBtn = findViewById(R.id.btn_play); //暂停按钮动画 - mPlayBtnAnimator = ObjectAnimator.ofPropertyValuesHolder(mPlayBtn, - PropertyValuesHolder.ofFloat("scaleX", 4f, 0.8f, 1f), - PropertyValuesHolder.ofFloat("scaleY", 4f, 0.8f, 1f), - PropertyValuesHolder.ofFloat("alpha", 0f, 1f)); + mPlayBtnAnimator = ObjectAnimator.ofPropertyValuesHolder(mPlayBtn, PropertyValuesHolder.ofFloat("scaleX", 4f, 0.8f, 1f), PropertyValuesHolder.ofFloat("scaleY", 4f, 0.8f, 1f), PropertyValuesHolder.ofFloat("alpha", 0f, 1f)); mPlayBtnAnimator.setDuration(150); mPlayBtnAnimator.setInterpolator(new AccelerateInterpolator()); } @@ -87,9 +84,8 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://加载完成,开始播放的回调 mStartPlay = true; if (mActionListener != null) { - mActionListener.onPlayBegin(); + mActionListener.onPlayBegin(txVodPlayer.getDuration()); } - break; case TXLiveConstants.PLAY_EVT_PLAY_LOADING: //开始加载的回调 if (mActionListener != null) { @@ -116,6 +112,13 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取到视频宽高回调 onVideoSizeChanged(bundle.getInt("EVT_PARAM1", 0), bundle.getInt("EVT_PARAM2", 0)); break; + case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS: + if (mActionListener != null) { + int progress = bundle.getInt(TXLiveConstants.EVT_PLAY_PROGRESS_MS); + int duration = bundle.getInt(TXLiveConstants.EVT_PLAY_DURATION_MS); + mActionListener.onProgress(progress, duration); + } + break; } } @@ -289,11 +292,13 @@ public class VideoPlayViewHolder extends AbsViewHolder implements ITXVodPlayList public interface ActionListener { - void onPlayBegin(); + void onPlayBegin(float duration); void onPlayLoading(); void onFirstFrame(); + + void onProgress(int progress, int duration); } diff --git a/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java index 231aea3ed..fbc8a5b43 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoPlayWrapViewHolder.java @@ -4,18 +4,24 @@ import android.animation.ValueAnimator; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Bundle; + import androidx.core.content.ContextCompat; + import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.view.animation.Animation; import android.view.animation.ScaleAnimation; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; +import android.widget.SeekBar; import android.widget.TextView; +import com.alibaba.android.arouter.utils.TextUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; @@ -61,7 +67,10 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli private Drawable[] mLikeAnimDrawables;//点赞帧动画 private int mLikeAnimIndex; private String mTag; - private TextView tv_video_report; + private SeekBar seekbar; + private LinearLayout progressTextLayout; + private TextView progressTextView; + private TextView progressCount; public VideoPlayWrapViewHolder(Context context, ViewGroup parentView) { super(context, parentView); @@ -75,27 +84,51 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli @Override public void init() { mTag = this.toString(); + + seekbar = (SeekBar) findViewById(R.id.seekbar); + progressTextLayout = (LinearLayout) findViewById(R.id.progressTextLayout); + progressTextView = (TextView) findViewById(R.id.progress); + progressCount = (TextView) findViewById(R.id.progressCount); + mVideoContainer = (ViewGroup) findViewById(R.id.video_container); mCover = (ImageView) findViewById(R.id.cover); - mAvatar = (ImageView) findViewById(R.id.avatar2); + mAvatar = (ImageView) findViewById(R.id.avatar); mName = (TextView) findViewById(R.id.name); mTitle = (TextView) findViewById(R.id.title); mBtnLike = (ImageView) findViewById(R.id.btn_like); mLikeNum = (TextView) findViewById(R.id.like_num); mCommentNum = (TextView) findViewById(R.id.comment_num); mShareNum = (TextView) findViewById(R.id.share_num); - mBtnFollow = (ImageView) findViewById(R.id.btn_follow2); + mBtnFollow = (ImageView) findViewById(R.id.btn_follow); - tv_video_report = (TextView) findViewById(R.id.tv_video_report); - -// mFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_video_follow_1); + mFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_video_follow_1); mUnFollowDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_video_follow_0); mAvatar.setOnClickListener(this); mBtnFollow.setOnClickListener(this); mBtnLike.setOnClickListener(this); findViewById(R.id.btn_comment).setOnClickListener(this); findViewById(R.id.btn_share).setOnClickListener(this); - findViewById(R.id.tv_video_report).setOnClickListener(this); + seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (fromUser) { + progressTextLayout.setVisibility(View.VISIBLE); + } else { + progressTextLayout.setVisibility(View.GONE); + } + progressTextView.setText(String.valueOf(progress)); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); } /** @@ -181,11 +214,9 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli } if (mBtnLike != null) { if (bean.getLike() == 1) { - if (mLikeAnimDrawables != null && mLikeAnimDrawables.length > 0) { - mBtnLike.setImageDrawable(mLikeAnimDrawables[mLikeAnimDrawables.length - 1]); - } + mBtnLike.setImageResource(R.mipmap.icon_video_zan_new02); } else { - mBtnLike.setImageResource(R.mipmap.icon_video_zan_01); + mBtnLike.setImageResource(R.mipmap.icon_video_zan_new01); } } if (mLikeNum != null) { @@ -197,36 +228,36 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli if (mShareNum != null) { mShareNum.setText(bean.getShareNum()); } -// if (u != null && mBtnFollow != null) { -// String toUid = u.getId(); -// if (!TextUtils.isEmpty(toUid) && !toUid.equals(CommonAppConfig.getInstance().getUid())) { -// if (mBtnFollow.getVisibility() != View.VISIBLE) { -// mBtnFollow.setVisibility(View.VISIBLE); -// } -// if (bean.getAttent() == 1) { -// mBtnFollow.setImageDrawable(mFollowDrawable); -// } else { -// mBtnFollow.setImageDrawable(mUnFollowDrawable); -// } -// } else { -// if (mBtnFollow.getVisibility() == View.VISIBLE) { -// mBtnFollow.setVisibility(View.INVISIBLE); -// } -// } -// } + if (u != null && mBtnFollow != null) { + String toUid = u.getId(); + if (!TextUtils.isEmpty(toUid) && !toUid.equals(CommonAppConfig.getInstance().getUid())) { + if (mBtnFollow.getVisibility() != View.VISIBLE) { + mBtnFollow.setVisibility(View.VISIBLE); + } + if (bean.getAttent() == 1) { + mBtnFollow.setImageDrawable(mFollowDrawable); + } else { + mBtnFollow.setImageDrawable(mUnFollowDrawable); + } + } else { + if (mBtnFollow.getVisibility() == View.VISIBLE) { + mBtnFollow.setVisibility(View.INVISIBLE); + } + } + } if (!Constants.myUid.endsWith(bean.getUid())) { -// if (bean.getAttent() == 2) { -// mBtnFollow.setVisibility(View.VISIBLE); -// if (bean.getAttent() == 1) { -// mBtnFollow.setImageDrawable(mFollowDrawable); -// } else { -// mBtnFollow.setImageDrawable(mUnFollowDrawable); -// } -// } else { -// mBtnFollow.setVisibility(View.GONE); -// } + if (bean.getAttent() == 2) { + mBtnFollow.setVisibility(View.VISIBLE); + if (bean.getAttent() == 1) { + mBtnFollow.setImageDrawable(mFollowDrawable); + } else { + mBtnFollow.setImageDrawable(mUnFollowDrawable); + } + } else { + mBtnFollow.setVisibility(View.GONE); + } } else { -// mBtnFollow.setVisibility(View.GONE); + mBtnFollow.setVisibility(View.GONE); } } @@ -278,6 +309,17 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli return mVideoBean; } + public void setProgress(int progresss) { + if (progressTextView != null) { + progressTextView.setText(String.valueOf(progresss)); + } + } + + public void setDuration(int duration) { + if (progressCount != null) { + progressCount.setText(String.valueOf(duration)); + } + } /** * 获取到视频首帧回调 @@ -324,7 +366,7 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli return; } int i = v.getId(); - if (i == R.id.btn_follow2) { + if (i == R.id.btn_follow) { clickFollow(); } else if (i == R.id.btn_comment) { clickComment(); @@ -334,12 +376,12 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli clickLike(); } else if (i == R.id.avatar2) { clickAvatar(); - } else if (i == R.id.tv_video_report) { + } /*else if (i == R.id.tv_video_report) { if (mVideoBean == null) { return; } LiveReportActivity.forward2(mContext, mVideoBean.getId()); - } + }*/ } @@ -376,15 +418,9 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli } if (mBtnLike != null) { if (like == 1) { - if (mLikeAnimtor == null) { - initLikeAnimtor(); - } - mLikeAnimIndex = -1; - if (mLikeAnimtor != null) { - mLikeAnimtor.start(); - } + mBtnLike.setImageResource(R.mipmap.icon_video_zan_new02); } else { - mBtnLike.setImageResource(R.mipmap.icon_video_zan_01); + mBtnLike.setImageResource(R.mipmap.icon_video_zan_new01); } } } else { @@ -409,6 +445,11 @@ public class VideoPlayWrapViewHolder extends AbsViewHolder implements View.OnCli @Override public void callback(Integer attent) { mVideoBean.setAttent(attent); + if (attent == 1) { + mBtnFollow.setImageDrawable(mFollowDrawable); + } else { + mBtnFollow.setImageDrawable(mUnFollowDrawable); + } if (mCurPageShowed) { if (mFollowAnimation == null) { initFollowAnimation(); diff --git a/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java b/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java index 1bc5445a4..6025aed8f 100644 --- a/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java +++ b/video/src/main/java/com/yunbao/video/views/VideoScrollViewHolder.java @@ -1,9 +1,11 @@ package com.yunbao.video.views; import android.content.Context; + import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; + import android.view.View; import android.view.ViewGroup; @@ -34,9 +36,7 @@ import java.util.List; * 视频滑动 */ -public class VideoScrollViewHolder extends AbsViewHolder implements - VideoScrollAdapter.ActionListener, SwipeRefreshLayout.OnRefreshListener, - VideoPlayViewHolder.ActionListener, View.OnClickListener { +public class VideoScrollViewHolder extends AbsViewHolder implements VideoScrollAdapter.ActionListener, SwipeRefreshLayout.OnRefreshListener, VideoPlayViewHolder.ActionListener, View.OnClickListener { private VideoPlayViewHolder mVideoPlayViewHolder; private View mPlayView; @@ -218,7 +218,7 @@ public class VideoScrollViewHolder extends AbsViewHolder implements } @Override - public void onPlayBegin() { + public void onPlayBegin(float duration) { if (mVideoLoadingBar != null) { mVideoLoadingBar.setLoading(false); } @@ -238,6 +238,14 @@ public class VideoScrollViewHolder extends AbsViewHolder implements } } + @Override + public void onProgress(int progress, int duration) { + if (mVideoPlayWrapViewHolder != null) { + mVideoPlayWrapViewHolder.setProgress(progress); + mVideoPlayWrapViewHolder.setDuration(duration); + } + } + /** * 关注发生变化 */ diff --git a/video/src/main/res/layout/view_video_play_wrap.xml b/video/src/main/res/layout/view_video_play_wrap.xml index f6f0f2b22..fc485b867 100644 --- a/video/src/main/res/layout/view_video_play_wrap.xml +++ b/video/src/main/res/layout/view_video_play_wrap.xml @@ -10,7 +10,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> - - + android:visibility="visible"> - + android:src="@mipmap/icon_video_back" /> + android:layout_marginBottom="120dp" + android:visibility="visible"> + android:layout_centerHorizontal="true" + android:layout_marginTop="25dp" + android:padding="4dp" + android:visibility="visible" /> + android:textSize="10sp" + android:visibility="visible" /> + android:src="@mipmap/icon_video_comment_new" + android:visibility="visible" /> + android:textSize="10sp" /> + android:layout_centerHorizontal="true" + android:layout_marginTop="30dp" + android:padding="4dp" + android:src="@mipmap/icon_video_share_new" + android:visibility="visible" /> + android:textSize="10sp" + android:visibility="visible" /> @@ -135,34 +134,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" - android:layout_marginLeft="18dp" + android:layout_marginLeft="10dp" android:layout_marginRight="120dp" android:layout_marginBottom="30dp" android:orientation="horizontal"> - - - - - - - + + + + + + + + + + + + + diff --git a/video/src/main/res/mipmap-mdpi/icon_video_back.png b/video/src/main/res/mipmap-mdpi/icon_video_back.png new file mode 100644 index 000000000..fae8ff4da Binary files /dev/null and b/video/src/main/res/mipmap-mdpi/icon_video_back.png differ diff --git a/video/src/main/res/mipmap-mdpi/icon_video_comment_new.png b/video/src/main/res/mipmap-mdpi/icon_video_comment_new.png new file mode 100644 index 000000000..40018fc91 Binary files /dev/null and b/video/src/main/res/mipmap-mdpi/icon_video_comment_new.png differ diff --git a/video/src/main/res/mipmap-mdpi/icon_video_share_new.png b/video/src/main/res/mipmap-mdpi/icon_video_share_new.png new file mode 100644 index 000000000..cd249e21c Binary files /dev/null and b/video/src/main/res/mipmap-mdpi/icon_video_share_new.png differ diff --git a/video/src/main/res/mipmap-mdpi/icon_video_zan_new01.png b/video/src/main/res/mipmap-mdpi/icon_video_zan_new01.png new file mode 100644 index 000000000..8c4449727 Binary files /dev/null and b/video/src/main/res/mipmap-mdpi/icon_video_zan_new01.png differ diff --git a/video/src/main/res/mipmap-mdpi/icon_video_zan_new02.png b/video/src/main/res/mipmap-mdpi/icon_video_zan_new02.png new file mode 100644 index 000000000..76ed0f180 Binary files /dev/null and b/video/src/main/res/mipmap-mdpi/icon_video_zan_new02.png differ