diff --git a/IAP6Helper/src/main/res/drawable/dialog_radius_dark.xml b/IAP6Helper/src/main/res/drawable/dialog_radius_dark.xml index 9efa7d341..55c201a9c 100644 --- a/IAP6Helper/src/main/res/drawable/dialog_radius_dark.xml +++ b/IAP6Helper/src/main/res/drawable/dialog_radius_dark.xml @@ -1,5 +1,6 @@ - + \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index bcd252188..1d294d7ef 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -224,5 +224,12 @@ dependencies { //時間選擇器 api 'com.contrarywind:Android-PickerView:4.1.9' + //瀑布流 + api 'com.wuxiaolong.pullloadmorerecyclerview:library:1.1.2' + //时间选择器 + api 'com.contrarywind:Android-PickerView:4.1.9' + //UI框架 + api 'com.github.xuexiangjys:XUI:1.1.6' + api 'com.github.xuexiangjys.XUtil:xutil-core:2.0.0' } diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index 19358ba04..05c947e8c 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -57,7 +57,6 @@ android:name="com.yunbao.common.activity.SelectImageActivity" android:screenOrientation="portrait" /> - @@ -66,6 +65,18 @@ android:name="com.yunbao.common.activity.PreviewVideoActivity" android:screenOrientation="portrait" /> + + + + + diff --git a/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java b/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java new file mode 100644 index 000000000..07e7e8877 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java @@ -0,0 +1,341 @@ +package com.yunbao.common.activity; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.util.SparseArray; +import android.view.View; +import android.view.WindowManager; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +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.adapter.CommentAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.bean.CommentBean; +import com.yunbao.common.dialog.ImagePreviewDialog; +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.utils.DialogUitl; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +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 { + 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; + private EditText comment; + private ImageView send; + private boolean isComment = false; + + @Override + protected int getLayoutId() { + getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); + return R.layout.activity_community_details; + } + + @Override + protected void create() { + super.create(); + } + + @Override + protected void onPause() { + super.onPause(); + OpenAdManager.getInstance().dismiss(); + } + + @Override + protected void main() { + activeBean = getIntent().getParcelableExtra("active"); + initView(); + initData(); + getReply(); + } + + private void initView() { + send = findViewById(R.id.send); + comment = findViewById(R.id.comment); + replyCount = findViewById(R.id.replyCount); + like = findViewById(R.id.like); + userAvatar = findViewById(R.id.userAvatar); + 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) { + ImagePreviewDialog dialog = new ImagePreviewDialog(); + dialog.setImageInfo(dataList.size(), position, false, new ImagePreviewDialog.ActionListener() { + @Override + public void loadImage(ImageView imageView, int position) { + ImgLoader.display(mContext, (String) (dataList.get(position)), imageView); + } + + @Override + public void onDeleteClick(int position) { + + } + }); + dialog.show(((AbsActivity) mContext).getSupportFragmentManager(), "ImagePreviewDialog"); + } + + @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) { + CommonHttpUtil.dynamicLove(activeBean.getId(), new HttpCallback() { + @SuppressLint("SetTextI18n") + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ToastUtil.show(msg); + if (activeBean.getIs_love().equals("1")) { + activeBean.setIs_love("0"); + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like01, like); + likeCount.setText(Integer.parseInt(activeBean.getLove_num()) - 1 + "人觉得很赞"); + } else { + activeBean.setIs_love("1"); + ImgLoader.display(CommunityDetailsActivity.this, R.mipmap.icon_like, like); + likeCount.setText(Integer.parseInt(activeBean.getLove_num()) + 1 + "人觉得很赞"); + } + } + } + }); + } + }); + findViewById(R.id.setting).setVisibility(View.VISIBLE); + findViewById(R.id.setting).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SparseArray array = new SparseArray<>(); + array.append(0, "举报"); + array.append(1, "不感兴趣"); + DialogUitl.showStringArrayDialog(CommunityDetailsActivity.this, array, new DialogUitl.StringArrayDialogCallback() { + @Override + public void onItemClick(String text, int tag) { + if (tag == 0) { + RouteUtil.forwardCommentReportActivity(activeBean.getId(), activeBean.getId()); + } else { + CommonHttpUtil.noInterest(activeBean.getUser_id(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + ToastUtil.show(msg); + } + }); + } + } + }); + } + }); + send.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommonHttpUtil.dynamicReply(activeBean.getId(), isComment ? replyComment.getId() : "0", comment.getText().toString(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + comment.setText(""); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(comment, InputMethodManager.SHOW_FORCED); + imm.hideSoftInputFromWindow(comment.getWindowToken(), 0); //强制隐藏键盘 + getReply(); + } + }); + } + }); + comment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + isComment = false; + } + }); + findViewById(R.id.userLayout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + UserHomeActivity.forwardUserHomeActivity(CommunityDetailsActivity.this, activeBean.getUser_id()); + } + }); + } + + //回复评论 + CommentBean replyComment; + + private void getReply() { + CommonHttpUtil.getCommunityComment(activeBean.getId(), activeBean.getUser_id(), new HttpCallback() { + @SuppressLint("SetTextI18n") + @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, activeBean.getUser_id()); + commentAdapter.setOnItemClickListener(new CommentAdapter.onItemClickListener() { + @Override + public void onReply(CommentBean commentBean) { + replyComment = commentBean; + isComment = true; + comment.requestFocus(); + //键盘输入法管理器 + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(comment, 0); + } + + @Override + public void onReport(CommentBean commentBean) { + //一级回复 举报 + RouteUtil.forwardCommentReportActivity(activeBean.getId(), commentBean.getId()); + } + + @Override + public void onDel(CommentBean activeBean, int position) { + //一级回复 删除 + CommonHttpUtil.delCom(activeBean.getId(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ToastUtil.show(msg); + getReply(); + } + } + }); + } + + @Override + public void onReport(CommentBean.ReplyComment activeBean) { + //二级回复 举报 + RouteUtil.forwardCommentReportActivity(activeBean.getId(), activeBean.getId()); + } + + @Override + public void onDel(CommentBean.ReplyComment activeBean) { + //二级回复 删除 + CommonHttpUtil.delCom(activeBean.getId(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0) { + ToastUtil.show(msg); + getReply(); + } + } + }); + } + }); + 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() + "人觉得很赞"); + if (!StringUtil.isEmpty(activeBean.getContent())) { + 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 + protected void onActivityResult(int requestCode, int resultCode, Intent intent) { + super.onActivityResult(requestCode, resultCode, intent); + } +} diff --git a/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java b/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java new file mode 100644 index 000000000..a61f18b09 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java @@ -0,0 +1,347 @@ +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.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 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); + + 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); + } + } + }); + + mRecyclerViewImage = findViewById(R.id.recyclerView_image); + mRecyclerViewImage.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false)); + 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 + 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/activity/UserHomeActivity.java b/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java new file mode 100644 index 000000000..f0d0bf3ad --- /dev/null +++ b/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java @@ -0,0 +1,387 @@ +package com.yunbao.common.activity; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.graphics.Outline; +import android.view.View; +import android.view.ViewOutlineProvider; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.viewpager.widget.ViewPager; + +import com.alibaba.fastjson.JSONArray; +import com.makeramen.roundedimageview.RoundedImageView; +import com.ms.banner.Banner; +import com.ms.banner.listener.OnBannerClickListener; +import com.xuexiang.xui.widget.flowlayout.FlowTagLayout; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.R; +import com.yunbao.common.adapter.LabelTagAdapter; +import com.yunbao.common.adapter.UserCommunityAdapter; +import com.yunbao.common.adapter.UserHomeImgAdapter; +import com.yunbao.common.bean.ActiveOtherBean; +import com.yunbao.common.bean.HomeUserExhibitInfoBean; +import com.yunbao.common.bean.HomeUserInfoBean; +import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.LabelBean; +import com.yunbao.common.bean.MessageUserInfoBean; +import com.yunbao.common.bean.UserHomeImgBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.interfaces.CommonCallback; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.UserHomeImgsViewHolder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class UserHomeActivity extends AbsActivity { + private String uid; + private Banner mBanner; + private RecyclerView imgsRecyclerView; + private UserHomeImgAdapter userHomeImgAdapter; + private List bannerImgList = new ArrayList<>(); + private List tempList; + private RoundedImageView avatar; + private TextView userName; + private TextView fansCount; + private TextView likeCount; + private LinearLayout followLayout; + private ImageView followIcon; + private TextView followName; + private TextView userId; + private TextView userStatus; + private ImageView userStatusIcon; + private ImageView user_sex; + private ImageView authorIcon; + private TextView level; + private ImageView levelIcon; + private TextView vipLevel; + private LinearLayout authenticationLayout; + private TextView signature; + private LinearLayout moreLayout; + private TextView moreText; + private ImageView moreIcon; + private HomeUserInfoBean userInfo; + RecyclerView communityRecyclerView; + private LinearLayout itemLayout01; + private LinearLayout itemLayout02; + private LinearLayout itemLayout03; + private LinearLayout itemLayout04; + FlowTagLayout myFlowTag; //我的标签 + LabelTagAdapter myAdapter; + private boolean isShowcase; + private boolean isAnchor; + private RelativeLayout userPresidentLayout; + private TextView userPresidentName; + private RelativeLayout authorLayout; + private RelativeLayout levelLayout; + private RoundedImageView fansImg1; + private RoundedImageView fansImg2; + private RoundedImageView fansImg3; + + private List fansImgViewList = new ArrayList<>(); + + public static void forwardUserHomeActivity(Context content, String uid) { + Intent intent = new Intent(content, UserHomeActivity.class); + intent.putExtra(Constants.TO_UID, uid); + content.startActivity(intent); + } + + @Override + protected int getLayoutId() { + return R.layout.activity_user_home; + } + + @Override + protected void create() { + super.create(); + } + + @Override + protected void main() { + uid = getIntent().getStringExtra(Constants.TO_UID); + if (StringUtil.isEmpty(uid)) { + ToastUtil.show("用户不存在"); + finish(); + return; + } + initView(); + getUseData(); + getCommunityList(); + } + + private void getCommunityList() { + CommonHttpUtil.getOtherDynamicList(uid, new com.yunbao.common.http.HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + List beanList = JSONArray.parseArray(Arrays.toString(info), ActiveOtherBean.class); + UserCommunityAdapter userCommunityAdapter = new UserCommunityAdapter(mContext, beanList); + communityRecyclerView.setAdapter(userCommunityAdapter); + } + }); + } + + private void initData(HomeUserInfoBean userInfoBean) { + userInfo = userInfoBean; + if (!userInfo.getCheckBlack().get(0).getU2t().equals("0")) { + ToastUtil.show("已拉黑,无法查看"); + finish(); + return; + } + if (!StringUtil.isEmpty(userInfo.getUserHomeTopInfo().getUser_president_name())) { + userPresidentLayout.setVisibility(View.VISIBLE); + userPresidentName.setText(userInfo.getUserHomeTopInfo().getUser_president_name()); + } + isAnchor = userInfo.getUserHomeTopInfo().getIs_anchor() == 1; + ImgLoader.display(UserHomeActivity.this, userInfo.getUserHomeTopInfo().getUser_avatar(), avatar); + userName.setText(userInfo.getUserHomeTopInfo().getUser_name());//用户名称 + fansCount.setText(String.valueOf(userInfo.getUserHomeTopInfo().getUser_fans_num()));//粉丝数量 + likeCount.setText(String.valueOf(userInfo.getUserHomeTopInfo().getUser_love_num()));//关注数量 + + userId.setText("ID:" + userInfo.getUserHomeTopInfo().getUser_id());//用户ID + userStatus.setText("");//认证状态 + ImgLoader.display(UserHomeActivity.this, Integer.parseInt(String.valueOf(userInfo.getUserHomeTopInfo().getUser_sex())) == 0 ? R.mipmap.icon_man_new : R.mipmap.icon_wumen, user_sex); + ImgLoader.display(UserHomeActivity.this, CommonAppConfig.HOST + userInfo.getUserHomeTopInfo().getUser_level_anchor_img(), authorIcon); + ImgLoader.display(UserHomeActivity.this, userInfo.getUserHomeTopInfo().getUser_level_img(), levelIcon); + + if (isAnchor) {//是否是主播 + authorLayout.setVisibility(View.VISIBLE); + levelLayout.setVisibility(View.VISIBLE); + authenticationLayout.setVisibility(View.VISIBLE); + itemLayout01.setVisibility(View.VISIBLE); + itemLayout02.setVisibility(View.VISIBLE); + itemLayout03.setVisibility(View.VISIBLE); + itemLayout04.setVisibility(View.VISIBLE); + } else { + authorLayout.setVisibility(View.GONE); + authenticationLayout.setVisibility(View.GONE); + itemLayout03.setVisibility(View.VISIBLE); + itemLayout04.setVisibility(View.VISIBLE); + } + signature.setText(userInfo.getUserHomeTopInfo().getUser_signature());//个性签名 + //标签 + myAdapter = new LabelTagAdapter(mContext, new LabelTagAdapter.OnSureOnClickListener() { + @Override + public void sure(LabelBean.Children labelBean) { + + } + }); + if (userInfo.getUserHomeTopInfo().getCn_label() != null) { + if (userInfo.getUserHomeTopInfo().getCn_label().size() > 0) { + myFlowTag.setAdapter(myAdapter); + myFlowTag.setTagCheckedMode(FlowTagLayout.FLOW_TAG_CHECKED_NONE); + myAdapter.setData(userInfo.getUserHomeTopInfo().getCn_label()); + } + } + mBanner.setOutlineProvider(new ViewOutlineProvider() { + @Override + public void getOutline(View view, Outline outline) { + outline.setRoundRect(0, 0, 0, 0, 0); + } + }); + mBanner.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + bannerImgList = userInfo.getUserHomeTopInfo().getUser_home_banner(); + tempList = new ArrayList<>(); + for (int i = 0; i < bannerImgList.size(); i++) { + tempList.add(new UserHomeImgBean(bannerImgList.get(i))); + } + tempList.get(0).setShow(true); + userHomeImgAdapter = new UserHomeImgAdapter(UserHomeActivity.this, tempList); + imgsRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); + imgsRecyclerView.setAdapter(userHomeImgAdapter); + + userHomeImgAdapter.setOnItemClickListener(new UserHomeImgAdapter.onItemClickListener() { + @Override + public void onImgItem(UserHomeImgBean activeBean, int position) { + mBanner.onPageSelected(position); + mBanner.setCurrentPage(position); + for (int i = 0; i < tempList.size(); i++) { + if (i == position) { + tempList.get(i).setShow(true); + } else { + tempList.get(i).setShow(false); + } + } + userHomeImgAdapter.setCommentBeanList(tempList); + } + }); + mBanner.setAutoPlay(false).setPages(bannerImgList, new UserHomeImgsViewHolder()).setOnBannerClickListener(new OnBannerClickListener() { + @Override + public void onBannerClick(List datas, int position) { + + } + }).start(); + } + + private void initView() { + fansImg1 = findViewById(R.id.fansImg1); + fansImg2 = findViewById(R.id.fansImg2); + fansImg3 = findViewById(R.id.fansImg3); + fansImgViewList = new ArrayList<>(); + fansImgViewList.add(fansImg1); + fansImgViewList.add(fansImg2); + fansImgViewList.add(fansImg3); + authorLayout = findViewById(R.id.authorLayout); + levelLayout = findViewById(R.id.levelLayout); + userPresidentLayout = findViewById(R.id.userPresidentLayout); + userPresidentName = findViewById(R.id.userPresidentName); + itemLayout01 = findViewById(R.id.itemLayout01); + itemLayout02 = findViewById(R.id.itemLayout02); + itemLayout03 = findViewById(R.id.itemLayout03); + itemLayout04 = findViewById(R.id.itemLayout04); + communityRecyclerView = findViewById(R.id.communityRecyclerView); + myFlowTag = findViewById(R.id.myFlowTag); + avatar = findViewById(R.id.avatar); + userName = findViewById(R.id.name); + fansCount = findViewById(R.id.fansCount); + likeCount = findViewById(R.id.likeCount); + followLayout = findViewById(R.id.followLayout); + followName = findViewById(R.id.followName); + followIcon = findViewById(R.id.followIcon); + userId = findViewById(R.id.userId); + userStatus = findViewById(R.id.userStatus); + userStatusIcon = findViewById(R.id.userStatusIcon); + user_sex = findViewById(R.id.user_sex); + levelIcon = findViewById(R.id.levelIcon); + level = findViewById(R.id.level); + authorIcon = findViewById(R.id.authorlIcon); + authenticationLayout = findViewById(R.id.authenticationLayout); + signature = findViewById(R.id.signature); + moreLayout = findViewById(R.id.moreLayout); + moreText = findViewById(R.id.moreText); + moreIcon = findViewById(R.id.moreIcon); + + mBanner = findViewById(R.id.banner); + imgsRecyclerView = findViewById(R.id.imgsRecyclerView); + + communityRecyclerView = findViewById(R.id.communityRecyclerView); + communityRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + communityRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER); + + findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + followLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommonHttpUtil.setAttention(String.valueOf(userInfo.getUserHomeTopInfo().getUser_id()), new CommonCallback() { + @Override + public void callback(Integer isAttention) { + if (isAttention == 1) { + ImgLoader.display(UserHomeActivity.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(UserHomeActivity.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)); + } + } + }); + } + }); + moreLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isShowcase) { + if (isAnchor) { + itemLayout01.setVisibility(View.GONE); + itemLayout02.setVisibility(View.GONE); + itemLayout03.setVisibility(View.GONE); + itemLayout04.setVisibility(View.GONE); + } else { + itemLayout03.setVisibility(View.GONE); + itemLayout04.setVisibility(View.GONE); + } + moreText.setText("查看更多"); + ImgLoader.display(mContext, R.mipmap.icon_down, moreIcon); + } else { + if (isAnchor) { + itemLayout01.setVisibility(View.VISIBLE); + itemLayout02.setVisibility(View.VISIBLE); + itemLayout03.setVisibility(View.VISIBLE); + itemLayout04.setVisibility(View.VISIBLE); + } else { + itemLayout01.setVisibility(View.GONE); + itemLayout02.setVisibility(View.GONE); + } + moreText.setText("收起"); + ImgLoader.display(mContext, R.mipmap.icon_up, moreIcon); + } + isShowcase = !isShowcase; + } + }); + findViewById(R.id.back).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } + + private void getUseData() { + LiveNetManager.get(mContext).getUserHomeInfo(uid, new HttpCallback() { + @Override + public void onSuccess(HomeUserInfoBean data) { + initData(data); + } + + @Override + public void onError(String error) { + + } + }); + LiveNetManager.get(mContext).getUserExhibitInfoInfo(uid, new HttpCallback() { + @Override + public void onSuccess(HomeUserExhibitInfoBean data) { + if (data.getUserHomeTopInfo().getFans().getList() != null) { + for (int i = 0; i < data.getUserHomeTopInfo().getFans().getList().size(); i++) { + ImgLoader.display(mContext, data.getUserHomeTopInfo().getFans().getList().get(i).getAvatar(), fansImgViewList.get(i)); + } + } + } + + @Override + public void onError(String error) { + + } + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent intent) { + super.onActivityResult(requestCode, resultCode, intent); + } +} 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..e811a04de --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/CommentAdapter.java @@ -0,0 +1,220 @@ +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.CommonAppConfig; +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.ArrayList; +import java.util.List; + +public class CommentAdapter extends RecyclerView.Adapter { + private List commentBeanList; + private Context mContext; + private String authorId; + private String myUid; + private onItemClickListener onItemClickListener; + + public void setOnItemClickListener(CommentAdapter.onItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + public CommentAdapter(Context content, List commentBeanList, String authorId) { + this.mContext = content; + this.commentBeanList = commentBeanList; + this.authorId = authorId; + myUid = CommonAppConfig.getInstance().getUid(); + } + + @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 TextView replyTextView; + private RoundedImageView mAvatar01; + private TextView replyContent; + private TextView replyCount; + private RecyclerView recyclerView; + private LinearLayout replyLayout; + private TextView firstName; + private TextView isAuth; + private TextView del; + private TextView author; + private TextView del1; + private TextView report1; + + public CommentViewHolder(@NonNull View itemView) { + super(itemView); + firstName = itemView.findViewById(R.id.firstName); + mAvatar = itemView.findViewById(R.id.avatar); + name = itemView.findViewById(R.id.name); + content = itemView.findViewById(R.id.content); + replyTextView = itemView.findViewById(R.id.replyTextView); + report = itemView.findViewById(R.id.report); + mAvatar01 = itemView.findViewById(R.id.avatar01); + isAuth = itemView.findViewById(R.id.isAuth); + replyContent = itemView.findViewById(R.id.replyContent); + replyCount = itemView.findViewById(R.id.expand); + replyLayout = itemView.findViewById(R.id.replyLayout); + recyclerView = itemView.findViewById(R.id.recyclerView); + del = itemView.findViewById(R.id.del); + author = itemView.findViewById(R.id.author); + del1 = itemView.findViewById(R.id.del1); + report1 = itemView.findViewById(R.id.report1); + report.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + CommentBean bean = (CommentBean) v.getTag(); + onItemClickListener.onReport(bean); + } + } + }); + replyTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + CommentBean bean = (CommentBean) v.getTag(); + onItemClickListener.onReply(bean); + } + } + }); + del.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + CommentBean bean = (CommentBean) v.getTag(); + onItemClickListener.onDel(bean, 0); + } + } + }); + } + + @SuppressLint("SetTextI18n") + public void setData(CommentBean bean) { + report.setTag(bean); + replyTextView.setTag(bean); + ImgLoader.display(itemView.getContext(), bean.getUser_avatar(), mAvatar); + name.setText(bean.getUser_name()); + content.setText(bean.getContent()); + if (bean.getUser_id().equals(authorId)) { + author.setVisibility(View.VISIBLE); + } else { + author.setVisibility(View.GONE); + } + if (bean.getUser_id().equals(myUid)) { + del.setVisibility(View.VISIBLE); + } else { + del.setVisibility(View.GONE); + } + 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); + firstName.setText(bean.getReplyCommentList().get(0).getUser_name()); + replyLayout.setVisibility(View.VISIBLE); + if (bean.getReplyCommentList().get(0).getUser_id().equals(authorId)) { + isAuth.setVisibility(View.VISIBLE); + } else { + isAuth.setVisibility(View.GONE); + } + if (bean.getUser_id().equals(myUid)) { + del.setVisibility(View.VISIBLE); + } else { + del.setVisibility(View.GONE); + } + } else { + replyLayout.setVisibility(View.GONE); + replyCount.setVisibility(View.GONE); + } + if (bean.getReplyCommentList().size() > 1) { + replyCount.setVisibility(View.VISIBLE); + replyLayout.setVisibility(View.VISIBLE); + recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)); + recyclerView.addItemDecoration(new TopGradual()); + List tempList = new ArrayList<>(); + tempList.addAll(bean.getReplyCommentList()); + tempList.remove(0); + CommentReplyAdapter commentReplyAdapter = new CommentReplyAdapter(mContext, tempList, authorId); + commentReplyAdapter.setOnItemClickListener(new CommentReplyAdapter.onItemClickListener() { + @Override + public void onReport(CommentBean.ReplyComment activeBean) { + if (onItemClickListener != null) { + onItemClickListener.onReport(activeBean); + } + } + + @Override + public void onDel(CommentBean.ReplyComment activeBean) { + if (onItemClickListener != null) { + onItemClickListener.onDel(activeBean); + } + } + }); + 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()); + } + }); + } + } + } + } + + public interface onItemClickListener { + void onReply(CommentBean activeBean); + + void onReport(CommentBean activeBean); + + void onDel(CommentBean activeBean, int position); + + void onReport(CommentBean.ReplyComment activeBean); + + void onDel(CommentBean.ReplyComment activeBean); + } + +} diff --git a/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java new file mode 100644 index 000000000..c2b1fef33 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/CommentReplyAdapter.java @@ -0,0 +1,115 @@ +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.CommonAppConfig; +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; + private String authorId; + private String myUid; + private onItemClickListener onItemClickListener; + + public void setOnItemClickListener(onItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + public CommentReplyAdapter(Context content, List commentBeanList, String authorId) { + this.mContext = content; + this.commentBeanList = commentBeanList; + this.authorId = authorId; + myUid = CommonAppConfig.getInstance().getUid(); + } + + @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 TextView replyContent; + private TextView author; + private TextView del; + private TextView report; + + public CommentViewHolder(@NonNull View itemView) { + super(itemView); + name = itemView.findViewById(R.id.name); + mAvatar01 = itemView.findViewById(R.id.avatar01); + replyContent = itemView.findViewById(R.id.replyContent); + author = itemView.findViewById(R.id.author); + del = itemView.findViewById(R.id.del); + report = itemView.findViewById(R.id.report); + del.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + onItemClickListener.onDel((CommentBean.ReplyComment) v.getTag()); + } + } + }); + report.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (onItemClickListener != null) { + onItemClickListener.onReport((CommentBean.ReplyComment) v.getTag()); + } + } + }); + } + + @SuppressLint("SetTextI18n") + public void setData(CommentBean.ReplyComment bean) { + del.setTag(bean); + ImgLoader.display(itemView.getContext(), bean.getUser_avatar(), mAvatar01); + name.setText(bean.getUser_name()); + replyContent.setText(bean.getContent()); + if (bean.getUser_id().equals(authorId)) { + author.setVisibility(View.VISIBLE); + } else { + author.setVisibility(View.GONE); + } + if (bean.getUser_id().equals(myUid)) { + del.setVisibility(View.VISIBLE); + } else { + del.setVisibility(View.GONE); + } + } + } + + public interface onItemClickListener { + void onReport(CommentBean.ReplyComment activeBean); + + void onDel(CommentBean.ReplyComment activeBean); + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/ImagePreviewAdapter.java b/common/src/main/java/com/yunbao/common/adapter/ImagePreviewAdapter.java new file mode 100644 index 000000000..bc22ba76c --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/ImagePreviewAdapter.java @@ -0,0 +1,112 @@ +package com.yunbao.common.adapter; + +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.LinearLayoutManager; +import androidx.recyclerview.widget.PagerSnapHelper; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; + + +/** + * Created by cxf on 2018/11/28. + */ + +public class ImagePreviewAdapter extends RecyclerView.Adapter { + + private LayoutInflater mInflater; + private ActionListener mActionListener; + private int mPageCount; + private LinearLayoutManager mLayoutManager; + private int mCurPosition; + + public ImagePreviewAdapter(Context context, int pageCount) { + mPageCount = pageCount; + mInflater = LayoutInflater.from(context); + } + + @NonNull + @Override + public Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(R.layout.item_preview_img, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull Vh vh, int position) { + vh.setData(position); + } + + @Override + public int getItemCount() { + return mPageCount; + } + + + class Vh extends RecyclerView.ViewHolder { + + ImageView mImg; + + public Vh(View itemView) { + super(itemView); + mImg = (ImageView) itemView; + } + + void setData(int position) { + if (mActionListener != null) { + mActionListener.loadImage(mImg, position); + } + } + } + + public void setActionListener(ActionListener actionListener) { + mActionListener = actionListener; + } + + public void setCurPosition(int curPosition) { + mCurPosition = curPosition; + if (mActionListener != null) { + mActionListener.onPageChanged(curPosition); + } + } + + public int getCurPosition(){ + return mCurPosition; + } + + @Override + public void onAttachedToRecyclerView(RecyclerView recyclerView) { + super.onAttachedToRecyclerView(recyclerView); + mLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); + PagerSnapHelper pagerSnapHelper = new PagerSnapHelper(); + pagerSnapHelper.attachToRecyclerView(recyclerView); + recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + } + + @Override + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + int position = mLayoutManager.findFirstCompletelyVisibleItemPosition(); + if (position >= 0 && mCurPosition != position) { + mCurPosition = position; + if (mActionListener != null) { + mActionListener.onPageChanged(position); + } + } + } + }); + } + + + public interface ActionListener { + void onPageChanged(int position); + + void loadImage(ImageView imageView, int position); + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/LabelTagAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LabelTagAdapter.java new file mode 100644 index 000000000..f1737b634 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/LabelTagAdapter.java @@ -0,0 +1,47 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.View; +import android.widget.TextView; + +import com.xuexiang.xui.widget.flowlayout.BaseTagAdapter; +import com.yunbao.common.R; +import com.yunbao.common.bean.LabelBean; + +public class LabelTagAdapter extends BaseTagAdapter { + + OnSureOnClickListener onSureOnClickListener; + + Context mContext; + + public LabelTagAdapter(Context context, OnSureOnClickListener onSureOnClickListener) { + super(context); + this.onSureOnClickListener = onSureOnClickListener; + this.mContext = context; + } + + public LabelTagAdapter(Context context) { + super(context); + } + + @Override + protected TextView newViewHolder(View convertView) { + return (TextView) convertView.findViewById(R.id.tv_tag); + } + + @Override + protected int getLayoutId() { + return R.layout.adapter_item_tag; + } + + @Override + protected void convert(TextView textView, String item, int position) { + textView.setText(item); + textView.setTextColor(mContext.getResources().getColor(R.color.black2)); + } + + public interface OnSureOnClickListener { + void sure(LabelBean.Children labelBean); + } + +} diff --git a/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java b/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java new file mode 100644 index 000000000..0fb6bb278 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/UserCommunityAdapter.java @@ -0,0 +1,132 @@ +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.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.bean.ActiveOtherBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.StringUtil; +import com.yunbao.common.views.NineGridLayout; + +import java.util.ArrayList; +import java.util.List; + +public class UserCommunityAdapter extends RecyclerView.Adapter { + private List commentBeanList; + private Context mContext; + private onItemClickListener onItemClickListener; + + public void setOnItemClickListener(UserCommunityAdapter.onItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + public UserCommunityAdapter(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.activity_user_community_item, 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 userName; + private TextView time; + private TextView content; + private NineGridLayout nineGridLayout; + private RelativeLayout videoLayout; + private ImageView videoImage; + private TextView likeCount; + private TextView comCount; + private TextView shareCount; + + public CommentViewHolder(@NonNull View itemView) { + super(itemView); + mAvatar = itemView.findViewById(R.id.avatar); + userName = itemView.findViewById(R.id.userName); + time = itemView.findViewById(R.id.time); + content = itemView.findViewById(R.id.content); + nineGridLayout = itemView.findViewById(R.id.nine_grid_layout); + videoLayout = itemView.findViewById(R.id.videoLayout); + videoImage = itemView.findViewById(R.id.videoImage); + likeCount = itemView.findViewById(R.id.likeCount); + comCount = itemView.findViewById(R.id.comCount); + shareCount = itemView.findViewById(R.id.shareCount); + + mAvatar.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onItemClickListener.onImgItem((String) v.getTag(), getPosition()); + } + }); + } + + @SuppressLint("SetTextI18n") + public void setData(ActiveOtherBean bean) { + mAvatar.setTag(bean); + ImgLoader.display(mContext, bean.getUser_avatar(), mAvatar); + userName.setText(bean.getUser_name()); + time.setText(bean.getCreate_time()); + if (!StringUtil.isEmpty(bean.getContent())) { + content.setText(String.valueOf(JSONObject.parseObject(bean.getContent()).get("msg"))); + } + likeCount.setText(String.valueOf(bean.getLove_num())); + comCount.setText(String.valueOf(bean.getComment_num())); + shareCount.setText(String.valueOf(bean.getShare_num())); + nineGridLayout.setActionListener(new NineGridLayout.ActionListener() { + @Override + public void onItemClick(List dataList, int position) { + + } + + @Override + public void displayImage(Object path, ImageView imageView) { + ImgLoader.display(mContext, String.valueOf(path), imageView); + } + }); + if (bean.getImg_or_video().equals("1")) {//图片 + JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json()); + List tempList = new ArrayList<>(); + for (int i = 0; i < jsonArray.size(); i++) { + tempList.add(String.valueOf(jsonArray.get(i))); + } + nineGridLayout.setData(tempList); + } else { + ImgLoader.display(mContext, bean.getUser_avatar(), videoImage); + } + + } + } + + public interface onItemClickListener { + void onImgItem(String activeBean, int position); + } +} diff --git a/common/src/main/java/com/yunbao/common/adapter/UserHomeImgAdapter.java b/common/src/main/java/com/yunbao/common/adapter/UserHomeImgAdapter.java new file mode 100644 index 000000000..543fa3d23 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/UserHomeImgAdapter.java @@ -0,0 +1,95 @@ +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.ImageView; +import android.widget.LinearLayout; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.bean.UserHomeImgBean; +import com.yunbao.common.glide.ImgLoader; + +import java.util.List; + +public class UserHomeImgAdapter extends RecyclerView.Adapter { + private List commentBeanList; + private Context mContext; + private onItemClickListener onItemClickListener; + + public void setOnItemClickListener(UserHomeImgAdapter.onItemClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + public List getCommentBeanList() { + return commentBeanList; + } + + public UserHomeImgAdapter(Context content, List commentBeanList) { + this.mContext = content; + this.commentBeanList = commentBeanList; + } + + public void setCommentBeanList(List commentBeanList) { + this.commentBeanList = commentBeanList; + notifyDataSetChanged(); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user_home_img, parent, false); + return new CommentViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + ((CommentViewHolder) holder).setData(commentBeanList.get(position), position); + } + + @Override + public int getItemCount() { + return commentBeanList.size(); + } + + class CommentViewHolder extends RecyclerView.ViewHolder { + RoundedImageView mAvatar01; + RoundedImageView mAvatar02; + + public CommentViewHolder(@NonNull View itemView) { + super(itemView); + mAvatar01 = itemView.findViewById(R.id.avatar01); + mAvatar02 = itemView.findViewById(R.id.avatar02); + } + + @SuppressLint("SetTextI18n") + public void setData(UserHomeImgBean bean, int position) { + mAvatar01.setTag(bean); + mAvatar01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onItemClickListener.onImgItem((UserHomeImgBean) v.getTag(), position); + } + }); + ImgLoader.display(mContext, bean.getImgurl(), mAvatar01); + ImgLoader.display(mContext, bean.getImgurl(), mAvatar02); + if (bean.isShow()) { + mAvatar01.setVisibility(View.GONE); + mAvatar02.setVisibility(View.VISIBLE); + } else { + mAvatar01.setVisibility(View.VISIBLE); + mAvatar02.setVisibility(View.GONE); + } + } + } + + public interface onItemClickListener { + void onImgItem(UserHomeImgBean activeBean, int position); + } +} 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/ActiveOtherBean.java b/common/src/main/java/com/yunbao/common/bean/ActiveOtherBean.java new file mode 100644 index 000000000..be8b4cd64 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/ActiveOtherBean.java @@ -0,0 +1,281 @@ +package com.yunbao.common.bean; + +import android.os.Parcel; +import android.os.Parcelable; + +import androidx.annotation.NonNull; + +/** + * 社區动态 + */ +public class ActiveOtherBean 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 ActiveOtherBean() { + } + + protected ActiveOtherBean(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 ActiveOtherBean createFromParcel(Parcel in) { + return new ActiveOtherBean(in); + } + + @Override + public ActiveOtherBean[] newArray(int size) { + return new ActiveOtherBean[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/CommentBean.java b/common/src/main/java/com/yunbao/common/bean/CommentBean.java new file mode 100644 index 000000000..47d2842fc --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CommentBean.java @@ -0,0 +1,238 @@ +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; + + public List getChild() { + return child; + } + + public void setChild(List child) { + this.child = 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/HomeUserExhibitInfoBean.java b/common/src/main/java/com/yunbao/common/bean/HomeUserExhibitInfoBean.java new file mode 100644 index 000000000..7e526c754 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/HomeUserExhibitInfoBean.java @@ -0,0 +1,137 @@ +package com.yunbao.common.bean; + +import java.util.List; + +public class HomeUserExhibitInfoBean extends BaseModel { + public UserHomeTopInfo userHomeTopInfo; + public List giftAlreadyWall; + + public List getGiftAlreadyWall() { + return giftAlreadyWall; + } + + public void setGiftAlreadyWall(List giftAlreadyWall) { + this.giftAlreadyWall = giftAlreadyWall; + } + + public UserHomeTopInfo getUserHomeTopInfo() { + return userHomeTopInfo; + } + + public void setUserHomeTopInfo(UserHomeTopInfo userHomeTopInfo) { + this.userHomeTopInfo = userHomeTopInfo; + } + + + public class UserHomeTopInfo { + Fans fans; + + public Fans getFans() { + return fans; + } + + public void setFans(Fans fans) { + this.fans = fans; + } + + public class Fans { + public List list; + public String fans_name; + + public String getFans_name() { + return fans_name; + } + + public void setFans_name(String fans_name) { + this.fans_name = fans_name; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public class AvatarList { + String avatar; + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + } + } + + public class Guard { + String avatar; + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + } + + public class Dress { + String display_src; + + public String getDisplay_src() { + return display_src; + } + + public void setDisplay_src(String display_src) { + this.display_src = display_src; + } + } + } + + + public class GiftAlreadyWall { + private String gift_wall_lighten_number; + private String gift_wall_lighten_total; + private List gift_wall; + + public String getGift_wall_lighten_number() { + return gift_wall_lighten_number; + } + + public void setGift_wall_lighten_number(String gift_wall_lighten_number) { + this.gift_wall_lighten_number = gift_wall_lighten_number; + } + + public String getGift_wall_lighten_total() { + return gift_wall_lighten_total; + } + + public void setGift_wall_lighten_total(String gift_wall_lighten_total) { + this.gift_wall_lighten_total = gift_wall_lighten_total; + } + + public List getGift_wall() { + return gift_wall; + } + + public void setGift_wall(List gift_wall) { + this.gift_wall = gift_wall; + } + + public class GiftWall { + private String gifticon; + + public String getGifticon() { + return gifticon; + } + + public void setGifticon(String gifticon) { + this.gifticon = gifticon; + } + } + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java b/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java new file mode 100644 index 000000000..c302f926e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/HomeUserInfoBean.java @@ -0,0 +1,255 @@ +package com.yunbao.common.bean; + +import java.util.List; + +public class HomeUserInfoBean extends BaseModel { + public UserHomeTopInfo userHomeTopInfo; + public List checkBlack; + + public UserHomeTopInfo getUserHomeTopInfo() { + return userHomeTopInfo; + } + + public void setUserHomeTopInfo(UserHomeTopInfo userHomeTopInfo) { + this.userHomeTopInfo = userHomeTopInfo; + } + + public List getCheckBlack() { + return checkBlack; + } + + public void setCheckBlack(List checkBlack) { + this.checkBlack = checkBlack; + } + + public class UserHomeTopInfo { + private long user_id; + private String user_name; + private String user_avatar; + private String user_signature; + private int user_sex; + private String user_level; + private String user_level_anchor; + private String user_goodnum; + private String user_level_img; + private String user_level_anchor_img; + private String user_president_name; + private int user_fans_num; + private int user_love_num; + private List user_home_banner; + private int is_live; + private int is_anchor; + private String fans_name; + private int is_attention; + private String user_avatar_frame; + private List cn_label; + private List en_label; + + 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 void setUser_id(long user_id) { + this.user_id = user_id; + } + + public long getUser_id() { + return user_id; + } + + public void setUser_name(String user_name) { + this.user_name = user_name; + } + + public String getUser_name() { + return user_name; + } + + public void setUser_avatar(String user_avatar) { + this.user_avatar = user_avatar; + } + + public String getUser_avatar() { + return user_avatar; + } + + public void setUser_signature(String user_signature) { + this.user_signature = user_signature; + } + + public String getUser_signature() { + return user_signature; + } + + public void setUser_sex(int user_sex) { + this.user_sex = user_sex; + } + + public int getUser_sex() { + return user_sex; + } + + public void setUser_level(String user_level) { + this.user_level = user_level; + } + + public String getUser_level() { + return user_level; + } + + public void setUser_level_anchor(String user_level_anchor) { + this.user_level_anchor = user_level_anchor; + } + + public String getUser_level_anchor() { + return user_level_anchor; + } + + public void setUser_goodnum(String user_goodnum) { + this.user_goodnum = user_goodnum; + } + + public String getUser_goodnum() { + return user_goodnum; + } + + public void setUser_level_img(String user_level_img) { + this.user_level_img = user_level_img; + } + + public String getUser_level_img() { + return user_level_img; + } + + public void setUser_level_anchor_img(String user_level_anchor_img) { + this.user_level_anchor_img = user_level_anchor_img; + } + + public String getUser_level_anchor_img() { + return user_level_anchor_img; + } + + public void setUser_president_name(String user_president_name) { + this.user_president_name = user_president_name; + } + + public String getUser_president_name() { + return user_president_name; + } + + public void setUser_fans_num(int user_fans_num) { + this.user_fans_num = user_fans_num; + } + + public int getUser_fans_num() { + return user_fans_num; + } + + public void setUser_love_num(int user_love_num) { + this.user_love_num = user_love_num; + } + + public int getUser_love_num() { + return user_love_num; + } + + public void setUser_home_banner(List user_home_banner) { + this.user_home_banner = user_home_banner; + } + + public List getUser_home_banner() { + return user_home_banner; + } + + public void setIs_live(int is_live) { + this.is_live = is_live; + } + + public int getIs_live() { + return is_live; + } + + public void setIs_anchor(int is_anchor) { + this.is_anchor = is_anchor; + } + + public int getIs_anchor() { + return is_anchor; + } + + public void setFans_name(String fans_name) { + this.fans_name = fans_name; + } + + public String getFans_name() { + return fans_name; + } + + public void setIs_attention(int is_attention) { + this.is_attention = is_attention; + } + + public int getIs_attention() { + return is_attention; + } + + public void setUser_avatar_frame(String user_avatar_frame) { + this.user_avatar_frame = user_avatar_frame; + } + + public String getUser_avatar_frame() { + return user_avatar_frame; + } + } + + public class CheckBlack { + private String uidIsAuth; + private String touidIsAuth; + private String u2t; + private String t2u; + + public String getUidIsAuth() { + return uidIsAuth; + } + + public void setUidIsAuth(String uidIsAuth) { + this.uidIsAuth = uidIsAuth; + } + + public String getTouidIsAuth() { + return touidIsAuth; + } + + public void setTouidIsAuth(String touidIsAuth) { + this.touidIsAuth = touidIsAuth; + } + + public String getU2t() { + return u2t; + } + + public void setU2t(String u2t) { + this.u2t = u2t; + } + + public String getT2u() { + return t2u; + } + + public void setT2u(String t2u) { + this.t2u = t2u; + } + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/LabelBean.java b/common/src/main/java/com/yunbao/common/bean/LabelBean.java new file mode 100644 index 000000000..fe6e5b475 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/LabelBean.java @@ -0,0 +1,128 @@ +package com.yunbao.common.bean; + +import java.util.ArrayList; +import java.util.List; + +public class LabelBean extends BaseModel { + private int id; + private int pid; + private String cn_title; + private String en_title; + private List children; + + public static class Children { + private int id; + private int pid; + private String cn_title; + private String en_title; + private List children; + + private boolean isSelect; + + public boolean isSelect() { + return isSelect; + } + + public void setSelect(boolean select) { + isSelect = select; + } + + public Children() { + + } + + public Children(int id, String cn_title) { + this.id = id; + this.cn_title = cn_title; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public String getCn_title() { + return cn_title; + } + + public void setCn_title(String cn_title) { + this.cn_title = cn_title; + } + + public String getEn_title() { + return en_title; + } + + public void setEn_title(String en_title) { + this.en_title = en_title; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public String getCn_title() { + return cn_title; + } + + public void setCn_title(String cn_title) { + this.cn_title = cn_title; + } + + public String getEn_title() { + return en_title; + } + + public void setEn_title(String en_title) { + this.en_title = en_title; + } + + public List getChildren() { + return children; + } + + + public List getStringChildren() { + List stringList = new ArrayList<>(); + for (int i = 0; i < children.size(); i++) { + stringList.add(children.get(i).getCn_title()); + } + return stringList; + } + + public void setChildren(List children) { + this.children = children; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/NewCommunityType.java b/common/src/main/java/com/yunbao/common/bean/NewCommunityType.java new file mode 100644 index 000000000..3a1bbb473 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/NewCommunityType.java @@ -0,0 +1,70 @@ +package com.yunbao.common.bean; + +public class NewCommunityType extends BaseModel { + private int id; + private String talk_name; + private String img; + private String is_hot; + private String hot_time; + private String sort; + + public NewCommunityType() { + } + + public NewCommunityType(int id, String talk_name, String img, String is_hot, String hot_time, String sort) { + this.id = id; + this.talk_name = talk_name; + this.img = img; + this.is_hot = is_hot; + this.hot_time = hot_time; + this.sort = sort; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTalk_name() { + return talk_name; + } + + public void setTalk_name(String talk_name) { + this.talk_name = talk_name; + } + + public String getImg() { + return img; + } + + public void setImg(String img) { + this.img = img; + } + + public String getIs_hot() { + return is_hot; + } + + public void setIs_hot(String is_hot) { + this.is_hot = is_hot; + } + + public String getHot_time() { + return hot_time; + } + + public void setHot_time(String hot_time) { + this.hot_time = hot_time; + } + + public String getSort() { + return sort; + } + + public void setSort(String sort) { + this.sort = sort; + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/UserHomeImgBean.java b/common/src/main/java/com/yunbao/common/bean/UserHomeImgBean.java new file mode 100644 index 000000000..b57c35496 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/UserHomeImgBean.java @@ -0,0 +1,29 @@ +package com.yunbao.common.bean; + +/** + * 社區动态 + */ +public class UserHomeImgBean extends BaseModel { + private String imgurl; + private boolean isShow; + + public UserHomeImgBean(String imgurl) { + this.imgurl = imgurl; + } + + public String getImgurl() { + return imgurl; + } + + public void setImgurl(String imgurl) { + this.imgurl = imgurl; + } + + public boolean isShow() { + return isShow; + } + + public void setShow(boolean show) { + isShow = show; + } +} diff --git a/common/src/main/java/com/yunbao/common/custom/CommonRefreshWaterfallView.java b/common/src/main/java/com/yunbao/common/custom/CommonRefreshWaterfallView.java new file mode 100644 index 000000000..dc778a25e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/custom/CommonRefreshWaterfallView.java @@ -0,0 +1,492 @@ +package com.yunbao.common.custom; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.FrameLayout; + +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.SimpleItemAnimator; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; + +import com.scwang.smartrefresh.layout.SmartRefreshLayout; +import com.scwang.smartrefresh.layout.api.RefreshLayout; +import com.scwang.smartrefresh.layout.footer.ClassicsFooter; +import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener; +import com.scwang.smartrefresh.layout.listener.OnRefreshListener; +import com.yunbao.common.R; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ClassicsHeaderNew; + +import java.util.List; + +/** + * Created by cxf on 2018/6/7. + */ + +public class CommonRefreshWaterfallView extends FrameLayout implements View.OnClickListener { + + private Context mContext; + private DataHelper mDataHelper; + private int mLayoutRes; + private View mContentView; + private SmartRefreshLayout mSmartRefreshLayout; + private ClassicsHeaderNew mHeader; + private ClassicsFooter mFooter; + public RecyclerView mRecyclerView; + private FrameLayout mEmptyLayout;//没有数据的View + private View mLoadFailureView;//加载失败View + private boolean mRefreshEnable;//下拉刷新是否可用 + private boolean mLoadMoreEnable;//上拉加载是否可用 + private int mPageCount;//页数 + private int mItemCount;//每页的Item个数 + + public CommonRefreshWaterfallView(Context context) { + this(context, null); + } + + public CommonRefreshWaterfallView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CommonRefreshWaterfallView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + mContext = context; + TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CommonRefreshView); + mRefreshEnable = ta.getBoolean(R.styleable.CommonRefreshView_crv_refreshEnable, true); + mLoadMoreEnable = ta.getBoolean(R.styleable.CommonRefreshView_crv_loadMoreEnable, true); + mLayoutRes = ta.getResourceId(R.styleable.CommonRefreshView_crv_layout, R.layout.view_refresh_default); + mItemCount = ta.getInteger(R.styleable.CommonRefreshView_crv_itemCount, 20); + ta.recycle(); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + LayoutInflater inflater = LayoutInflater.from(mContext); + View view = inflater.inflate(mLayoutRes, this, false); + mContentView = view; + addView(view); + mSmartRefreshLayout = (SmartRefreshLayout) view.findViewById(R.id.refreshLayout); + mSmartRefreshLayout.setEnableLoadMoreWhenContentNotFull(false);//是否在列表不满一页时候开启上拉加载功能 + mSmartRefreshLayout.setEnableFooterFollowWhenLoadFinished(true);//是否在全部加载结束之后Footer跟随内容 + mSmartRefreshLayout.setEnableOverScrollBounce(false);//设置是否开启越界回弹功能(默认true) + mEmptyLayout = (FrameLayout) view.findViewById(R.id.no_data_container); + mLoadFailureView = view.findViewById(R.id.load_failure); + mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); + mRecyclerView.setHasFixedSize(true); + + StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); + mRecyclerView.setLayoutManager(staggeredGridLayoutManager); + + ((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false); + mSmartRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + @Override + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + refresh(); + } + }); + + mSmartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() { + @Override + public void onLoadMore(@NonNull RefreshLayout refreshlayout) { + Log.i("t2", "来了哦"); + loadMore(); + } + }); + mSmartRefreshLayout.setEnableRefresh(mRefreshEnable); + mSmartRefreshLayout.setEnableLoadMore(mLoadMoreEnable); + View btnReload = view.findViewById(R.id.btn_reload); + if (btnReload != null) { + btnReload.setOnClickListener(this); + } + int textColor = ContextCompat.getColor(mContext, R.color.textColor); + mHeader = findViewById(R.id.header); + mHeader.setAccentColor(textColor); + mFooter = findViewById(R.id.footer); + mFooter.setAccentColor(textColor); + mFooter.setTextSizeTitle(14); + } + + /** + * 设置头部字体颜色 + * + * @param textColor + */ + public void setHeaderTextColor(int textColor) { + mHeader.setAccentColor(textColor); + } + + private HttpCallback mRefreshCallback = new HttpCallback() { + + private int mDataCount; + + @Override + public void onSuccess(int code, String msg, String[] info) { + if (mDataHelper == null) { + return; + } + if (mLoadFailureView != null && mLoadFailureView.getVisibility() == View.VISIBLE) { + mLoadFailureView.setVisibility(View.INVISIBLE); + } + RefreshAdapter adapter = null; + RecyclerView.Adapter recyclerViewAdapter = mRecyclerView.getAdapter(); + if (recyclerViewAdapter != null && recyclerViewAdapter instanceof RefreshAdapter) { + adapter = (RefreshAdapter) recyclerViewAdapter; + } else { + adapter = mDataHelper.getAdapter(); + if (adapter == null) { + return; + } + mRecyclerView.setAdapter(adapter); + } + if (code != 0) { + ToastUtil.show(msg); + return; + } + if (info != null) { + List list = mDataHelper.processData(info); + if (list == null) { + return; + } + mDataCount = list.size(); + if (mDataCount > 0) { + if (mEmptyLayout != null && mEmptyLayout.getVisibility() == View.VISIBLE) { + mEmptyLayout.setVisibility(View.INVISIBLE); + } + adapter.refreshData(list); + } else { + adapter.clearData(); + if (mEmptyLayout != null && mEmptyLayout.getVisibility() != View.VISIBLE) { + mEmptyLayout.setVisibility(View.VISIBLE); + } + } + } else { + if (adapter != null) { + adapter.clearData(); + } + if (mEmptyLayout != null && mEmptyLayout.getVisibility() != View.VISIBLE) { + mEmptyLayout.setVisibility(View.VISIBLE); + } + } + mDataHelper.onRefreshSuccess(adapter.getList(), adapter.getItemCount()); + + } + + + @Override + public void onError() { + if (mEmptyLayout != null && mEmptyLayout.getVisibility() == View.VISIBLE) { + mEmptyLayout.setVisibility(View.INVISIBLE); + } + if (mLoadFailureView != null) { + if (mLoadFailureView.getVisibility() != View.VISIBLE) { + if (mRecyclerView != null) { + RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); + if (adapter != null && adapter.getItemCount() > 0) { + ToastUtil.show(mContext.getString(R.string.load_failure)); + } else { + mLoadFailureView.setVisibility(View.VISIBLE); + } + } else { + mLoadFailureView.setVisibility(View.VISIBLE); + } + } else { + ToastUtil.show(mContext.getString(R.string.load_failure)); + } + } + if (mDataHelper != null) { + mDataHelper.onRefreshFailure(); + } + } + + @Override + public void onFinish() { + if (mSmartRefreshLayout != null) { + mSmartRefreshLayout.finishRefresh(true); + if (mDataCount < mItemCount) { + mSmartRefreshLayout.finishLoadMore(true); + } + + } + } + }; + + private HttpCallback mLoadMoreCallback = new HttpCallback() { + + private int mDataCount; + + @Override + public void onSuccess(int code, String msg, String[] info) { + if (mDataHelper == null) { + mPageCount--; + return; + } + if (code != 0) { + ToastUtil.show(msg); + mPageCount--; + return; + } + if (mLoadFailureView != null && mLoadFailureView.getVisibility() == View.VISIBLE) { + mLoadFailureView.setVisibility(View.INVISIBLE); + } + if (info != null) { + List list = mDataHelper.processData(info); + if (list == null) { + mPageCount--; + return; + } + mDataCount = list.size(); + RefreshAdapter adapter = mDataHelper.getAdapter(); + if (mDataCount > 0) { + if (adapter != null) { + adapter.insertList(list); + } + } else { + mPageCount--; + } + mDataHelper.onLoadMoreSuccess(list, mDataCount); + } else { + mPageCount--; + } + } + + @Override + public void onError() { + super.onError(); + mPageCount--; + if (mDataHelper != null) { + mDataHelper.onLoadMoreFailure(); + } + } + + @Override + public void onFinish() { + Log.i("t2", "更多"); + if (mSmartRefreshLayout != null) { + if (mDataCount <= 0) { + mSmartRefreshLayout.finishLoadMoreWithNoMoreData(); + } else { + mSmartRefreshLayout.finishLoadMore(true); + } + } + } + }; + + public void onFinish() { + if (mLoadFailureView != null && mLoadFailureView.getVisibility() == View.VISIBLE) { + mLoadFailureView.setVisibility(View.INVISIBLE); + } + if (mEmptyLayout != null && mEmptyLayout.getVisibility() == View.VISIBLE) { + mEmptyLayout.setVisibility(View.INVISIBLE); + } + if (mSmartRefreshLayout != null) { + mSmartRefreshLayout.finishRefresh(true); + } + } + + public void setDataHelper(DataHelper dataHelper) { + mDataHelper = dataHelper; + } + + public void setLayoutManager(RecyclerView.LayoutManager layoutManager) { + mRecyclerView.setLayoutManager(layoutManager); + } + + public void setItemDecoration(ItemDecoration itemDecoration) { + mRecyclerView.addItemDecoration(itemDecoration); + } + + /** + * 手动设置没有更多数据 + * 因为日榜/周榜接口没有分页参数,会导致一直读取重复数据 + */ + public void setNotLoadMore() { + mSmartRefreshLayout.finishLoadMoreWithNoMoreData(); + } + + public void showLoading() { + mPageCount = 1; + if (mSmartRefreshLayout != null) { + mSmartRefreshLayout.autoRefreshAnimationOnly(); + } + if (mEmptyLayout != null && mEmptyLayout.getVisibility() == VISIBLE) { + mEmptyLayout.setVisibility(INVISIBLE); + } + if (mLoadFailureView != null && mLoadFailureView.getVisibility() == VISIBLE) { + mLoadFailureView.setVisibility(INVISIBLE); + } + } + + public void showRefreshBar() { + if (mSmartRefreshLayout != null) { + mSmartRefreshLayout.autoRefresh(100);//延迟400毫秒后自动刷新 + + } + } + + public void showEmpty() { + if (mEmptyLayout != null && mEmptyLayout.getVisibility() != VISIBLE) { + mEmptyLayout.setVisibility(VISIBLE); + } + } + + public void hideEmpty() { + if (mEmptyLayout != null && mEmptyLayout.getVisibility() == VISIBLE) { + mEmptyLayout.setVisibility(INVISIBLE); + } + } + + public void hideLoadFailure() { + if (mLoadFailureView != null && mLoadFailureView.getVisibility() == VISIBLE) { + mLoadFailureView.setVisibility(INVISIBLE); + } + } + + + public void initData() { + Log.i("t2", "AAAs1212"); + refresh(); + } + + private void refresh() { + if (mDataHelper != null) { + Log.i("t2", "AAAs"); + mPageCount = 1; + mDataHelper.loadData(mPageCount, mRefreshCallback); + } + if (dataHelperNew != null) { + dataHelperNew.refresh(); + } + } + + private void loadMore() { + Log.i("t2", "来了哦111"); + + if (mDataHelper != null) { + Log.i("t2", "来了哦12121"); + mPageCount++; + mDataHelper.loadData(mPageCount, mLoadMoreCallback); + } + if (dataHelperNew != null) { + dataHelperNew.loadData(mPageCount); + } + } + + public int getPageCount() { + return mPageCount; + } + + public void setPageCount(int pageCount) { + mPageCount = pageCount; + } + + + public int getItemCount() { + return mItemCount; + } + + public void setItemCount(int itemCount) { + mItemCount = itemCount; + } + + public void setRefreshEnable(boolean enable) { + if (mSmartRefreshLayout != null) { + mSmartRefreshLayout.setEnableRefresh(enable); + } + } + + public void setLoadMoreEnable(boolean enable) { + if (mSmartRefreshLayout != null) { + mSmartRefreshLayout.setEnableLoadMore(enable); + } + } + + @Override + public void onClick(View v) { + if (v.getId() == R.id.btn_reload) { + refresh(); + } + } + + public interface DataHelperNew { + void loadData(int p); + + void refresh(); + } + + private DataHelperNew dataHelperNew; + + public CommonRefreshWaterfallView setDataHelperNew(DataHelperNew dataHelperNew) { + this.dataHelperNew = dataHelperNew; + return this; + } + + public interface DataHelper { + RefreshAdapter getAdapter(); + + void loadData(int p, HttpCallback callback); + + List processData(String[] info); + + /** + * 下拉刷新成功 + * + * @param list Adapter的全部数据的List + * @param listCount Adapter的全部数据的个数 + */ + void onRefreshSuccess(List list, int listCount); + + /** + * 下拉刷新失败 + */ + void onRefreshFailure(); + + /** + * 上拉加载成功 + * + * @param loadItemList 本次加载到的数据 + * @param loadItemCount 加载到的数据个数 + */ + void onLoadMoreSuccess(List loadItemList, int loadItemCount); + + /** + * 加载失败 + */ + void onLoadMoreFailure(); + } + + /** + * 空数据的布局 + */ + public void setEmptyLayoutId(int noDataLayoutId) { + if (mEmptyLayout != null) { + mEmptyLayout.removeAllViews(); + View v = LayoutInflater.from(mContext).inflate(noDataLayoutId, mEmptyLayout, false); + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) v.getLayoutParams(); + params.gravity = Gravity.CENTER; + v.setLayoutParams(params); + mEmptyLayout.addView(v); + } + } + + public View getContentView() { + return mContentView; + } + + public void setRecyclerViewAdapter(RefreshAdapter adapter) { + if (mRecyclerView != null) { + mRecyclerView.setAdapter(adapter); + } + } + +} diff --git a/common/src/main/java/com/yunbao/common/dialog/ImagePreviewDialog.java b/common/src/main/java/com/yunbao/common/dialog/ImagePreviewDialog.java new file mode 100644 index 000000000..a19449066 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/ImagePreviewDialog.java @@ -0,0 +1,160 @@ +package com.yunbao.common.dialog; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ValueAnimator; +import android.os.Bundle; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.adapter.ImagePreviewAdapter; +import com.yunbao.common.utils.StringUtil; + +/** + * Created by Martin on 2024/3/15. + * 图片预览弹窗 + */ + +public class ImagePreviewDialog extends AbsDialogFragment implements View.OnClickListener { + + private View mBg; + private RecyclerView mRecyclerView; + private ValueAnimator mAnimator; + private int mPosition; + private int mPageCount; + private ActionListener mActionListener; + private TextView mCount; + private ImagePreviewAdapter mAdapter; + private boolean mNeedDelete; + + + @Override + protected int getLayoutId() { + return R.layout.view_preview_image; + } + + @Override + protected int getDialogStyle() { + return R.style.dialog2; + } + + @Override + protected boolean canCancel() { + return true; + } + + @Override + protected void setWindowAttributes(Window window) { + WindowManager.LayoutParams params = window.getAttributes(); + params.width = WindowManager.LayoutParams.MATCH_PARENT; + params.height = WindowManager.LayoutParams.MATCH_PARENT; + window.setAttributes(params); + } + + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + mBg = mRootView.findViewById(R.id.bg); + mCount = (TextView) findViewById(R.id.count); + findViewById(R.id.btn_close).setOnClickListener(this); + if (mNeedDelete) { + View btnDelete = findViewById(R.id.btn_delete); + btnDelete.setVisibility(View.VISIBLE); + btnDelete.setOnClickListener(this); + } + mRecyclerView = mRootView.findViewById(R.id.recyclerView); + mRecyclerView.setHasFixedSize(true); + mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); + mAnimator = ValueAnimator.ofFloat(0, 1); + mAnimator.setDuration(150); + mAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); + mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + float v = (float) animation.getAnimatedValue(); + mBg.setAlpha(v); + } + }); + mAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (mRecyclerView != null && mPageCount > 0) { + ImagePreviewAdapter adapter = new ImagePreviewAdapter(mContext, mPageCount); + mAdapter = adapter; + adapter.setActionListener(new ImagePreviewAdapter.ActionListener() { + @Override + public void onPageChanged(int position) { + if (mCount != null) { + mCount.setText(StringUtil.contact(String.valueOf(position + 1), "/", String.valueOf(mPageCount))); + } + } + + @Override + public void loadImage(ImageView imageView, int position) { + if (mActionListener != null) { + mActionListener.loadImage(imageView, position); + } + } + }); + mRecyclerView.setAdapter(adapter); + if (mPosition >= 0 && mPosition < mPageCount) { + adapter.setCurPosition(mPosition); + mRecyclerView.scrollToPosition(mPosition); + } + } + } + }); + mAnimator.start(); + } + + public void setImageInfo(int pageCount, int position, boolean needDelete, ActionListener actionListener) { + mActionListener = actionListener; + mPageCount = pageCount; + mPosition = position; + mNeedDelete = needDelete; + } + + + @Override + public void onDestroy() { + if (mAnimator != null) { + mAnimator.cancel(); + } + mContext = null; + mActionListener = null; + super.onDestroy(); + } + + @Override + public void onClick(View v) { + int i = v.getId(); + if (i == R.id.btn_close) { + dismiss(); + } else if (i == R.id.btn_delete) { + delete(); + } + } + + private void delete() { + if (mAdapter != null && mActionListener != null) { + mActionListener.onDeleteClick(mAdapter.getCurPosition()); + } + dismiss(); + } + + public interface ActionListener { + void loadImage(ImageView imageView, int position); + + void onDeleteClick(int position); + } + +} diff --git a/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java b/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java index 49793cd89..733bcc1a3 100644 --- a/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/ProcessFragment.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; @@ -60,7 +61,6 @@ public class ProcessFragment extends Fragment { mPermissionCallback = null; } - /** * 判断申请的权限有没有被允许 */ @@ -119,7 +119,7 @@ public class ProcessFragment extends Fragment { public void onActivityResult(int requestCode, int resultCode, Intent data) { try { RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(null); - }catch (Exception e){ + } catch (Exception e) { } if (mActivityResultCallback != null) { @@ -131,8 +131,8 @@ public class ProcessFragment extends Fragment { } } - public void release(){ - mPermissionCallback=null; - mActivityResultCallback=null; + public void release() { + mPermissionCallback = null; + mActivityResultCallback = null; } } 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..a14a2fe33 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,151 @@ 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); + } + + /** + * 获取动态列表-点赞 + * + * @param callback + */ + public static void dynamicLove(String dynamic_id, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.dynamicLove", "Pdlcommunity.dynamicLove") + .params("dynamic_id", dynamic_id) + .execute(callback); + } + + /** + * 获取动态列表-回复 + * + * @param callback + */ + public static void dynamicReply(String dynamic_id, String to_comment_id, String content, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.sendDynamicComment", "Pdlcommunity.sendDynamicComment") + .params("dynamic_id", dynamic_id) + .params("content", content) + .params("to_comment_id", to_comment_id) + .execute(callback); + } + + /** + * 获取动态-发现 + */ + public static void getCommunityFind(int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getFindDynamicList", "Pdlcommunity.getFindDynamicList") + .params("p", p) + .execute(callback); + } + + /** + * 获取动态-关注 + */ + public static void getCommunityFollow(int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getFindDynamicList", "Pdlcommunity.getFindDynamicList") + .params("p", p) + .execute(callback); + } + + /** + * 获取动态-分类 + */ + public static void getTag(HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getTalkBanner", "Pdlcommunity.getTalkBanner") + .execute(callback); + } + + public static void getTalkHotDynamicList(int talkId, int p, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getTalkHotDynamicList", "Pdlcommunity.getTalkHotDynamicList") + .params("talk_id", talkId) + .params("p", p) + .execute(callback); + } + + public static void getOtherDynamicList(String toUid, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.getOtherDynamicList", "Pdlcommunity.getOtherDynamicList") + .params("tuid", toUid) + .execute(callback); + } + + /** + * 动态-删除 + */ + public static void delCom(String comment_id, HttpCallback callback) { + HttpClient.getInstance().get("Pdlcommunity.delComment", "Pdlcommunity.delComment") + .params("comment_id", comment_id) + .execute(callback); + } + + /** + * 动态-不感兴趣 + */ + public static void noInterest(String uid, HttpCallback callback) { + HttpClient.getInstance().get("User.setBlack", "User.setBlack") + .params("touid", uid) + .execute(callback); + } + + /** + * 用户主页-用户数据 + */ + public static void getUserInfoTop(String uid, HttpCallback callback) { + HttpClient.getInstance().get("Pdluserhome.getUserHomeTopInfo", "Pdluserhome.getUserHomeTopInfo") + .params("select_uid", 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 268f9e52d..a22f599a9 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -27,6 +27,8 @@ import com.yunbao.common.bean.GiftGuideModel; import com.yunbao.common.bean.GiftNamingInfoModel; import com.yunbao.common.bean.GiftWallGiftDetail; import com.yunbao.common.bean.GiftWallModel; +import com.yunbao.common.bean.HomeUserExhibitInfoBean; +import com.yunbao.common.bean.HomeUserInfoBean; import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.IMLoginModel; @@ -1252,4 +1254,11 @@ public interface PDLiveApi { @GET("/api/public/?service=Pdlmsg.getTips") Observable> getMessageSayHiStartTimer( ); + @GET("/api/public/?service=Userhome.getUserHomeBanner") + Observable>> getUserHomeBanner(@Query("select_uid") String tuid); + @GET("/api/public/?service=Pdluserhome.getUserHomeTopInfo") + Observable> getUserHomeInfo(@Query("select_uid") String tuid); + @GET("/api/public/?service=Pdluserhome.getUserHomeInfo") + Observable> getUserHomeExhibitInfo(@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 1371de0a2..f344588e0 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 @@ -30,6 +30,8 @@ import com.yunbao.common.bean.GiftGuideModel; import com.yunbao.common.bean.GiftNamingInfoModel; import com.yunbao.common.bean.GiftWallGiftDetail; import com.yunbao.common.bean.GiftWallModel; +import com.yunbao.common.bean.HomeUserExhibitInfoBean; +import com.yunbao.common.bean.HomeUserInfoBean; import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.LinkMicUserBean; @@ -2787,7 +2789,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()) @@ -3333,11 +3335,79 @@ public class LiveNetManager { }).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(); + } + + public void getUserHomeInfo(String touid, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getUserHomeInfo(touid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel messageUserInfoBeanResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(messageUserInfoBeanResponseModel.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 getUserExhibitInfoInfo(String touid, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getUserHomeExhibitInfo(touid) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel messageUserInfoBeanResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(messageUserInfoBeanResponseModel.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(); + } + private MultipartBody.Part createUploadFile(File file) { RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file); return MultipartBody.Part.createFormData("file", file.getName(), requestBody); } + + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/interfaces/PermissionCallback.java b/common/src/main/java/com/yunbao/common/interfaces/PermissionCallback.java new file mode 100644 index 000000000..6c2084bce --- /dev/null +++ b/common/src/main/java/com/yunbao/common/interfaces/PermissionCallback.java @@ -0,0 +1,12 @@ +package com.yunbao.common.interfaces; + +import java.util.HashMap; + +public abstract class PermissionCallback { + + public abstract void onAllGranted(); + + public void onResult(HashMap resultMap) { + + } +} diff --git a/common/src/main/java/com/yunbao/common/manager/CommunityTypeManager.java b/common/src/main/java/com/yunbao/common/manager/CommunityTypeManager.java new file mode 100644 index 000000000..e31018e0f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/manager/CommunityTypeManager.java @@ -0,0 +1,38 @@ +package com.yunbao.common.manager; + +import android.content.Context; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yunbao.common.bean.FansModel; +import com.yunbao.common.bean.NewCommunityType; +import com.yunbao.common.bean.NewLevelModel; +import com.yunbao.common.manager.base.BaseCacheManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * 动态类别管理 + */ +public class CommunityTypeManager extends BaseCacheManager { + + private final String KEY_COMMUNITY_TYPE = "keyCommunityType"; + private List newCommunityTypeList = new ArrayList<>(); + + public CommunityTypeManager(Context context) { + super(context); + } + + public List getCommunityTypeList() { + return getList(KEY_COMMUNITY_TYPE, new TypeToken>() { + }.getType()); + } + + public void UpCommunityType(String json) { + newCommunityTypeList = new Gson().fromJson(json, new TypeToken>() { + }.getType()); + put(KEY_COMMUNITY_TYPE, newCommunityTypeList); + } + +} diff --git a/common/src/main/java/com/yunbao/common/utils/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/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index f32401100..364b87dc0 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -24,7 +24,7 @@ public class RouteUtil { //Intent隐式启动 action public static final String PATH_LAUNCHER = "/app/LauncherActivity"; public static final String PATH_LOGIN_INVALID = "/main/LoginInvalidActivity"; - public static final String PATH_USER_HOME = "/main/UserHomeActivity"; + public static final String PATH_COIN = "/main/MyWalletActivity"; public static final String PATH_REWARD = "/main/RewardActivity"; public static final String PATH_EDITPROFILE = "/main/EditProfileActivity"; @@ -46,6 +46,10 @@ public class RouteUtil { public static final String PATH_RED_PACKET_LIST = "/main/RedPacketListActivity"; public static final String PATH_RED_PACKET_INFO = "/main/RedPacketInfoActivity"; public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity"; + public static final String PATH_SELECT_AVATAR = "/main/UserAvatarSelectActivity"; + public static final String PATH_BattlePassActivity = "/main/BattlePassActivity"; + public static final String PATH_SudGameActivity = "/live/SudGameActivity"; + public static final String PATH_COMMUNITY_Activity = "/main/MainHomeCommunityActivity"; public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity"; public static final String PATH_BattlePassActivity="/main/BattlePassActivity"; public static final String PATH_SudGameActivity="/live/SudGameActivity"; @@ -57,11 +61,13 @@ public class RouteUtil { ARouter.getInstance().build(PATH_COMMUNITY_Activity) .navigation(); } + public static void forwardFansActivity(String uid) { ARouter.getInstance().build(PATH_FANSACTIVITY) .withString(Constants.TO_UID, uid) .navigation(); } + public static void forwardSudGameActivity(String CreateSudRoom) { ARouter.getInstance().build(PATH_SudGameActivity) .withString("CreateSudRoom", CreateSudRoom) @@ -296,6 +302,19 @@ public class RouteUtil { .navigation(); } + /** + * 举报动态 + * + * @param dynamicId + * @param commentId + */ + public static void forwardCommentReportActivity(String dynamicId, String commentId) { + ARouter.getInstance().build(PATH_LIVEREPORT) + .withString(Constants.TO_UID, dynamicId) + .withString("comment_id", commentId) + .navigation(); + } + /** * 进入facebook登录 */ diff --git a/common/src/main/java/com/yunbao/common/views/AbsUserPageViewHolder.java b/common/src/main/java/com/yunbao/common/views/AbsUserPageViewHolder.java new file mode 100644 index 000000000..955cdd7b4 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/AbsUserPageViewHolder.java @@ -0,0 +1,114 @@ +package com.yunbao.common.views; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.Interpolator; + +import com.yunbao.common.R; +import com.yunbao.common.utils.ScreenDimenUtil; + +/** + * Created by cxf on 2018/10/15. + */ + +public abstract class AbsUserPageViewHolder extends AbsViewHolder implements View.OnClickListener { + + protected ObjectAnimator mEnterAnimator; + protected ObjectAnimator mOutAnimator; + protected boolean mLoad; + protected boolean mShowed; + protected boolean mAnimating; + + public AbsUserPageViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + public AbsUserPageViewHolder(Context context, ViewGroup parentView, Object... args) { + super(context, parentView, args); + } + + + @Override + public void init() { + int screenWidth = ScreenDimenUtil.getInstance().getScreenWdith(); + Interpolator interpolator = new AccelerateDecelerateInterpolator(); + mEnterAnimator = ObjectAnimator.ofFloat(mContentView, "translationX", screenWidth, 0); + mEnterAnimator.setDuration(200); + mEnterAnimator.setInterpolator(interpolator); + mEnterAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mAnimating = false; + mShowed = true; + onShow(); + loadData(); + } + + }); + mOutAnimator = ObjectAnimator.ofFloat(mContentView, "translationX", 0, screenWidth); + mOutAnimator.setDuration(200); + mOutAnimator.setInterpolator(interpolator); + mOutAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mAnimating = false; + mShowed = false; + onHide(); + } + }); + findViewById(R.id.btn_back).setOnClickListener(this); + } + + public abstract void loadData(); + + public void show() { + if (!mAnimating) { + mAnimating = true; + mEnterAnimator.start(); + } + } + + public void hide() { + if (!mAnimating) { + mAnimating = true; + mOutAnimator.start(); + } + } + + public void onShow() { + + } + + public void onHide() { + + } + + public boolean isShowed() { + return mShowed; + } + + @Override + public void onClick(View v) { + int i = v.getId(); + if (i == R.id.btn_back) { + hide(); + } + } + + public void release() { + if (mEnterAnimator != null) { + mEnterAnimator.cancel(); + } + mEnterAnimator = null; + if (mOutAnimator != null) { + mOutAnimator.cancel(); + } + mEnterAnimator = null; + } + +} diff --git a/common/src/main/java/com/yunbao/common/views/FullyLinearLayoutManager.java b/common/src/main/java/com/yunbao/common/views/FullyLinearLayoutManager.java new file mode 100644 index 000000000..5f380d9c9 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/FullyLinearLayoutManager.java @@ -0,0 +1,283 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.graphics.Rect; +import android.util.Log; +import android.view.View; + +import androidx.core.view.ViewCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.BuildConfig; + +import java.lang.reflect.Field; + +public class FullyLinearLayoutManager extends LinearLayoutManager { + + private static boolean canMakeInsetsDirty = true; + private static Field insetsDirtyField = null; + + private static final int CHILD_WIDTH = 0; + private static final int CHILD_HEIGHT = 1; + private static final int DEFAULT_CHILD_SIZE = 100; + + private final int[] childDimensions = new int[2]; + private final RecyclerView view; + + private int childSize = DEFAULT_CHILD_SIZE; + private boolean hasChildSize; + private int overScrollMode = ViewCompat.OVER_SCROLL_ALWAYS; + private final Rect tmpRect = new Rect(); + + public FullyLinearLayoutManager(Context context) { + super(context); + this.view = null; + } + + public FullyLinearLayoutManager(Context context, int orientation, boolean reverseLayout) { + super(context, orientation, reverseLayout); + this.view = null; + } + + public FullyLinearLayoutManager(RecyclerView view) { + super(view.getContext()); + this.view = view; + this.overScrollMode = ViewCompat.getOverScrollMode(view); + } + + public FullyLinearLayoutManager(RecyclerView view, int orientation, boolean reverseLayout) { + super(view.getContext(), orientation, reverseLayout); + this.view = view; + this.overScrollMode = ViewCompat.getOverScrollMode(view); + } + + public void setOverScrollMode(int overScrollMode) { + if (overScrollMode < ViewCompat.OVER_SCROLL_ALWAYS || overScrollMode > ViewCompat.OVER_SCROLL_NEVER) + throw new IllegalArgumentException("Unknown overscroll mode: " + overScrollMode); + if (this.view == null) throw new IllegalStateException("view == null"); + this.overScrollMode = overScrollMode; + ViewCompat.setOverScrollMode(view, overScrollMode); + } + + public static int makeUnspecifiedSpec() { + return View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); + } + + @Override + public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, int widthSpec, int heightSpec) { + final int widthMode = View.MeasureSpec.getMode(widthSpec); + final int heightMode = View.MeasureSpec.getMode(heightSpec); + + final int widthSize = View.MeasureSpec.getSize(widthSpec); + final int heightSize = View.MeasureSpec.getSize(heightSpec); + + final boolean hasWidthSize = widthMode != View.MeasureSpec.UNSPECIFIED; + final boolean hasHeightSize = heightMode != View.MeasureSpec.UNSPECIFIED; + + final boolean exactWidth = widthMode == View.MeasureSpec.EXACTLY; + final boolean exactHeight = heightMode == View.MeasureSpec.EXACTLY; + + final int unspecified = makeUnspecifiedSpec(); + + if (exactWidth && exactHeight) { + // in case of exact calculations for both dimensions let's use default "onMeasure" implementation + super.onMeasure(recycler, state, widthSpec, heightSpec); + return; + } + + final boolean vertical = getOrientation() == VERTICAL; + + initChildDimensions(widthSize, heightSize, vertical); + + int width = 0; + int height = 0; + + // it's possible to get scrap views in recycler which are bound to old (invalid) adapter entities. This + // happens because their invalidation happens after "onMeasure" method. As a workaround let's clear the + // recycler now (it should not cause any performance issues while scrolling as "onMeasure" is never + // called whiles scrolling) + recycler.clear(); + + final int stateItemCount = state.getItemCount(); + final int adapterItemCount = getItemCount(); + // adapter always contains actual data while state might contain old data (f.e. data before the animation is + // done). As we want to measure the view with actual data we must use data from the adapter and not from the + // state + for (int i = 0; i < adapterItemCount; i++) { + if (vertical) { + if (!hasChildSize) { + if (i < stateItemCount) { + // we should not exceed state count, otherwise we'll get IndexOutOfBoundsException. For such items + // we will use previously calculated dimensions + measureChild(recycler, i, widthSize, unspecified, childDimensions); + } else { + logMeasureWarning(i); + } + } + height += childDimensions[CHILD_HEIGHT]; + if (i == 0) { + width = childDimensions[CHILD_WIDTH]; + } + if (hasHeightSize && height >= heightSize) { + break; + } + } else { + if (!hasChildSize) { + if (i < stateItemCount) { + // we should not exceed state count, otherwise we'll get IndexOutOfBoundsException. For such items + // we will use previously calculated dimensions + measureChild(recycler, i, unspecified, heightSize, childDimensions); + } else { + logMeasureWarning(i); + } + } + width += childDimensions[CHILD_WIDTH]; + if (i == 0) { + height = childDimensions[CHILD_HEIGHT]; + } + if (hasWidthSize && width >= widthSize) { + break; + } + } + } + + if (exactWidth) { + width = widthSize; + } else { + width += getPaddingLeft() + getPaddingRight(); + if (hasWidthSize) { + width = Math.min(width, widthSize); + } + } + + if (exactHeight) { + height = heightSize; + } else { + height += getPaddingTop() + getPaddingBottom(); + if (hasHeightSize) { + height = Math.min(height, heightSize); + } + } + + setMeasuredDimension(width, height); + + if (view != null && overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS) { + final boolean fit = (vertical && (!hasHeightSize || height < heightSize)) + || (!vertical && (!hasWidthSize || width < widthSize)); + + ViewCompat.setOverScrollMode(view, fit ? ViewCompat.OVER_SCROLL_NEVER : ViewCompat.OVER_SCROLL_ALWAYS); + } + } + + private void logMeasureWarning(int child) { + if (BuildConfig.DEBUG) { + Log.w("LinearLayoutManager", "Can't measure child #" + child + ", previously used dimensions will be reused." + + "To remove this message either use #setChildSize() method or don't run RecyclerView animations"); + } + } + + private void initChildDimensions(int width, int height, boolean vertical) { + if (childDimensions[CHILD_WIDTH] != 0 || childDimensions[CHILD_HEIGHT] != 0) { + // already initialized, skipping + return; + } + if (vertical) { + childDimensions[CHILD_WIDTH] = width; + childDimensions[CHILD_HEIGHT] = childSize; + } else { + childDimensions[CHILD_WIDTH] = childSize; + childDimensions[CHILD_HEIGHT] = height; + } + } + + @Override + public void setOrientation(int orientation) { + // might be called before the constructor of this class is called + //noinspection ConstantConditions + if (childDimensions != null) { + if (getOrientation() != orientation) { + childDimensions[CHILD_WIDTH] = 0; + childDimensions[CHILD_HEIGHT] = 0; + } + } + super.setOrientation(orientation); + } + + public void clearChildSize() { + hasChildSize = false; + setChildSize(DEFAULT_CHILD_SIZE); + } + + public void setChildSize(int childSize) { + hasChildSize = true; + if (this.childSize != childSize) { + this.childSize = childSize; + requestLayout(); + } + } + + private void measureChild(RecyclerView.Recycler recycler, int position, int widthSize, int heightSize, int[] dimensions) { + final View child; + try { + child = recycler.getViewForPosition(position); + } catch (IndexOutOfBoundsException e) { + if (BuildConfig.DEBUG) { + Log.w("LinearLayoutManager", "LinearLayoutManager doesn't work well with animations. Consider switching them off", e); + } + return; + } + + final RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) child.getLayoutParams(); + + final int hPadding = getPaddingLeft() + getPaddingRight(); + final int vPadding = getPaddingTop() + getPaddingBottom(); + + final int hMargin = p.leftMargin + p.rightMargin; + final int vMargin = p.topMargin + p.bottomMargin; + + // we must make insets dirty in order calculateItemDecorationsForChild to work + makeInsetsDirty(p); + // this method should be called before any getXxxDecorationXxx() methods + calculateItemDecorationsForChild(child, tmpRect); + + final int hDecoration = getRightDecorationWidth(child) + getLeftDecorationWidth(child); + final int vDecoration = getTopDecorationHeight(child) + getBottomDecorationHeight(child); + + final int childWidthSpec = getChildMeasureSpec(widthSize, hPadding + hMargin + hDecoration, p.width, canScrollHorizontally()); + final int childHeightSpec = getChildMeasureSpec(heightSize, vPadding + vMargin + vDecoration, p.height, canScrollVertically()); + + child.measure(childWidthSpec, childHeightSpec); + + dimensions[CHILD_WIDTH] = getDecoratedMeasuredWidth(child) + p.leftMargin + p.rightMargin; + dimensions[CHILD_HEIGHT] = getDecoratedMeasuredHeight(child) + p.bottomMargin + p.topMargin; + + // as view is recycled let's not keep old measured values + makeInsetsDirty(p); + recycler.recycleView(child); + } + + private static void makeInsetsDirty(RecyclerView.LayoutParams p) { + if (!canMakeInsetsDirty) { + return; + } + try { + if (insetsDirtyField == null) { + insetsDirtyField = RecyclerView.LayoutParams.class.getDeclaredField("mInsetsDirty"); + insetsDirtyField.setAccessible(true); + } + insetsDirtyField.set(p, true); + } catch (NoSuchFieldException e) { + onMakeInsertDirtyFailed(); + } catch (IllegalAccessException e) { + onMakeInsertDirtyFailed(); + } + } + + private static void onMakeInsertDirtyFailed() { + canMakeInsetsDirty = false; + if (BuildConfig.DEBUG) { + Log.w("LinearLayoutManager", "Can't make LayoutParams insets dirty, decorations measurements might be incorrect"); + } + } +} \ No newline at end of file diff --git a/common/src/main/java/com/yunbao/common/views/MyFrameLayout2.java b/common/src/main/java/com/yunbao/common/views/MyFrameLayout2.java new file mode 100644 index 000000000..1e6003c78 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MyFrameLayout2.java @@ -0,0 +1,46 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +import androidx.annotation.AttrRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.yunbao.common.R; + +/** + * Created by cxf on 2018/9/27. + */ + +public class MyFrameLayout2 extends FrameLayout { + + private float mRatio; + private float mOffestY; + + public MyFrameLayout2(@NonNull Context context) { + this(context, null); + } + + public MyFrameLayout2(@NonNull Context context, @Nullable AttributeSet attrs) { + this(context, attrs, 0); + } + + public MyFrameLayout2(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { + super(context, attrs, defStyleAttr); + TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyFrameLayout2); + mRatio = ta.getFloat(R.styleable.MyFrameLayout2_mfl_ratio, 1); + mOffestY = ta.getDimension(R.styleable.MyFrameLayout2_mfl_offestY, 0); + ta.recycle(); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int widthSize = MeasureSpec.getSize(widthMeasureSpec); + heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (widthSize * mRatio + mOffestY), MeasureSpec.EXACTLY); + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + +} diff --git a/common/src/main/java/com/yunbao/common/views/MyScrollview.java b/common/src/main/java/com/yunbao/common/views/MyScrollview.java new file mode 100644 index 000000000..b0cddb3de --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MyScrollview.java @@ -0,0 +1,48 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.ViewConfiguration; +import android.widget.ScrollView; + +public class MyScrollview extends ScrollView { + private int downX; + private int downY; + private int mTouchSlop; + + public MyScrollview(Context context) { + super(context); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + public MyScrollview(Context context, AttributeSet attrs) { + super(context, attrs); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + + public MyScrollview(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent e) { + int action = e.getAction(); + switch (action) { + case MotionEvent.ACTION_DOWN: + downX = (int) e.getRawX(); + downY = (int) e.getRawY(); + break; + case MotionEvent.ACTION_MOVE: + int moveY = (int) e.getRawY(); + if (Math.abs(moveY - downY) > mTouchSlop) { + return true; + } else { + super.onInterceptTouchEvent(e); + } + } + return super.onInterceptTouchEvent(e); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/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/java/com/yunbao/common/views/UserHomeImgsViewHolder.java b/common/src/main/java/com/yunbao/common/views/UserHomeImgsViewHolder.java new file mode 100644 index 000000000..ac03f5365 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/UserHomeImgsViewHolder.java @@ -0,0 +1,29 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import com.ms.banner.holder.BannerViewHolder; +import com.yunbao.common.bean.BannerBean; +import com.yunbao.common.glide.ImgLoader; + +public class UserHomeImgsViewHolder implements BannerViewHolder { + + @Override + public View createView(Context context, int position, String data) { + // 返回mImageView页面布局 + ImageView imageView = new ImageView(context); + ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT + ); + imageView.setLayoutParams(params); + imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); + //Glide.with(context).load(data.getImageUrl()).into(imageView); + ImgLoader.display(context, data, imageView); + + return imageView; + } + +} diff --git a/common/src/main/res/drawable/bg_community_comment.xml b/common/src/main/res/drawable/bg_community_comment.xml new file mode 100644 index 000000000..fc5600942 --- /dev/null +++ b/common/src/main/res/drawable/bg_community_comment.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_flow_tag.xml b/common/src/main/res/drawable/bg_flow_tag.xml new file mode 100644 index 000000000..d049cdc07 --- /dev/null +++ b/common/src/main/res/drawable/bg_flow_tag.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_item_active_img.xml b/common/src/main/res/drawable/bg_item_active_img.xml new file mode 100644 index 000000000..dbe7daa74 --- /dev/null +++ b/common/src/main/res/drawable/bg_item_active_img.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file 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.xml b/common/src/main/res/drawable/bg_main_com_type.xml new file mode 100644 index 000000000..a147ea5da --- /dev/null +++ b/common/src/main/res/drawable/bg_main_com_type.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/drawable/bg_user_home_04.xml b/common/src/main/res/drawable/bg_user_home_04.xml new file mode 100644 index 000000000..e4b57461a --- /dev/null +++ b/common/src/main/res/drawable/bg_user_home_04.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/bg_user_home_bottom.xml b/common/src/main/res/drawable/bg_user_home_bottom.xml new file mode 100644 index 000000000..d77d2e85e --- /dev/null +++ b/common/src/main/res/drawable/bg_user_home_bottom.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/main_community_send.xml b/common/src/main/res/drawable/main_community_send.xml new file mode 100644 index 000000000..db65d39e8 --- /dev/null +++ b/common/src/main/res/drawable/main_community_send.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/drawable/main_community_send_edit_bg.xml b/common/src/main/res/drawable/main_community_send_edit_bg.xml new file mode 100644 index 000000000..7211d776f --- /dev/null +++ b/common/src/main/res/drawable/main_community_send_edit_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/activity_community_details.xml b/common/src/main/res/layout/activity_community_details.xml new file mode 100644 index 000000000..f50601e9b --- /dev/null +++ b/common/src/main/res/layout/activity_community_details.xml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/activity_community_send.xml b/common/src/main/res/layout/activity_community_send.xml new file mode 100644 index 000000000..8195f4133 --- /dev/null +++ b/common/src/main/res/layout/activity_community_send.xml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/activity_user_community_item.xml b/common/src/main/res/layout/activity_user_community_item.xml new file mode 100644 index 000000000..4bdb14c0b --- /dev/null +++ b/common/src/main/res/layout/activity_user_community_item.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/activity_user_home.xml b/common/src/main/res/layout/activity_user_home.xml new file mode 100644 index 000000000..349380228 --- /dev/null +++ b/common/src/main/res/layout/activity_user_home.xml @@ -0,0 +1,750 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/adapter_item_tag.xml b/common/src/main/res/layout/adapter_item_tag.xml new file mode 100644 index 000000000..a961ad3e9 --- /dev/null +++ b/common/src/main/res/layout/adapter_item_tag.xml @@ -0,0 +1,21 @@ + + + + + + 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..b647ac5ab --- /dev/null +++ b/common/src/main/res/layout/item_comment_reply_view.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..4af43e1f3 --- /dev/null +++ b/common/src/main/res/layout/item_comment_view.xml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/item_preview_img.xml b/common/src/main/res/layout/item_preview_img.xml new file mode 100644 index 000000000..5fca97d21 --- /dev/null +++ b/common/src/main/res/layout/item_preview_img.xml @@ -0,0 +1,8 @@ + + diff --git a/common/src/main/res/layout/item_user_home_img.xml b/common/src/main/res/layout/item_user_home_img.xml new file mode 100644 index 000000000..c3f9e3992 --- /dev/null +++ b/common/src/main/res/layout/item_user_home_img.xml @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_preview_image.xml b/common/src/main/res/layout/view_preview_image.xml new file mode 100644 index 000000000..997875235 --- /dev/null +++ b/common/src/main/res/layout/view_preview_image.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_title2.xml b/common/src/main/res/layout/view_title2.xml index d1d192362..ab973547d 100644 --- a/common/src/main/res/layout/view_title2.xml +++ b/common/src/main/res/layout/view_title2.xml @@ -1,5 +1,6 @@ + app:tint="@color/textColor" /> + android:visibility="gone" + app:tint="@color/textColor" /> + android:textStyle="bold" + android:visibility="gone" /> + + + diff --git a/common/src/main/res/layout/view_title_new.xml b/common/src/main/res/layout/view_title_new.xml new file mode 100644 index 000000000..eb53f71e4 --- /dev/null +++ b/common/src/main/res/layout/view_title_new.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + diff --git a/common/src/main/res/mipmap-mdpi/bg_main.png b/common/src/main/res/mipmap-mdpi/bg_main.png new file mode 100644 index 000000000..d3827b334 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/bg_main.png differ diff --git a/common/src/main/res/mipmap-mdpi/bg_user_home_01.png b/common/src/main/res/mipmap-mdpi/bg_user_home_01.png new file mode 100644 index 000000000..2e9a838d2 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/bg_user_home_01.png differ diff --git a/common/src/main/res/mipmap-mdpi/bg_user_home_02.png b/common/src/main/res/mipmap-mdpi/bg_user_home_02.png new file mode 100644 index 000000000..822026166 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/bg_user_home_02.png differ diff --git a/common/src/main/res/mipmap-mdpi/bg_user_home_03.png b/common/src/main/res/mipmap-mdpi/bg_user_home_03.png new file mode 100644 index 000000000..494934a78 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/bg_user_home_03.png differ 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_auth_suc.png b/common/src/main/res/mipmap-mdpi/icon_auth_suc.png new file mode 100644 index 000000000..ba775490a Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_auth_suc.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_com_com.png b/common/src/main/res/mipmap-mdpi/icon_com_com.png new file mode 100644 index 000000000..019ce0c6a Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_com_com.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_com_like.png b/common/src/main/res/mipmap-mdpi/icon_com_like.png new file mode 100644 index 000000000..bd72d72f9 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_com_like.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_com_share.png b/common/src/main/res/mipmap-mdpi/icon_com_share.png new file mode 100644 index 000000000..cad84d0a5 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_com_share.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_comment.png b/common/src/main/res/mipmap-mdpi/icon_comment.png new file mode 100644 index 000000000..8474c0584 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_comment.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_community_edit.png b/common/src/main/res/mipmap-mdpi/icon_community_edit.png new file mode 100644 index 000000000..3ceabc69f Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_community_edit.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_community_img_text.png b/common/src/main/res/mipmap-mdpi/icon_community_img_text.png new file mode 100644 index 000000000..2b7f7929d Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_community_img_text.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_community_talk.png b/common/src/main/res/mipmap-mdpi/icon_community_talk.png new file mode 100644 index 000000000..9c1400ebc Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_community_talk.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_community_time.png b/common/src/main/res/mipmap-mdpi/icon_community_time.png new file mode 100644 index 000000000..452e50f35 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_community_time.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_community_video.png b/common/src/main/res/mipmap-mdpi/icon_community_video.png new file mode 100644 index 000000000..e5afe3006 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_community_video.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_down.png b/common/src/main/res/mipmap-mdpi/icon_down.png new file mode 100644 index 000000000..f48c4007d Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_down.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_edit_new.png b/common/src/main/res/mipmap-mdpi/icon_edit_new.png new file mode 100644 index 000000000..376b6d530 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_edit_new.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_grade.png b/common/src/main/res/mipmap-mdpi/icon_grade.png new file mode 100644 index 000000000..ef2a3d595 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_grade.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_gray_new_right.png b/common/src/main/res/mipmap-mdpi/icon_gray_new_right.png new file mode 100644 index 000000000..5bc9f0d35 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_gray_new_right.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_green.png b/common/src/main/res/mipmap-mdpi/icon_green.png new file mode 100644 index 000000000..682176887 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_green.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_index.png b/common/src/main/res/mipmap-mdpi/icon_index.png new file mode 100644 index 000000000..05041b854 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_index.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_index_new.png b/common/src/main/res/mipmap-mdpi/icon_index_new.png new file mode 100644 index 000000000..949f58c4b Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_index_new.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_left.png b/common/src/main/res/mipmap-mdpi/icon_left.png new file mode 100644 index 000000000..fae8ff4da Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_left.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_like.png b/common/src/main/res/mipmap-mdpi/icon_like.png new file mode 100644 index 000000000..ef9ab75e3 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_like.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_follow.png b/common/src/main/res/mipmap-mdpi/icon_like_follow.png new file mode 100644 index 000000000..9549764ae Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_like_follow.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/mipmap-mdpi/icon_man_new.png b/common/src/main/res/mipmap-mdpi/icon_man_new.png new file mode 100644 index 000000000..f5a03a21c Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_man_new.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_play.png b/common/src/main/res/mipmap-mdpi/icon_play.png new file mode 100644 index 000000000..f46a96d4a Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_play.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_right_gray.png b/common/src/main/res/mipmap-mdpi/icon_right_gray.png new file mode 100644 index 000000000..f9365ed15 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_right_gray.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_right_new.png b/common/src/main/res/mipmap-mdpi/icon_right_new.png new file mode 100644 index 000000000..c4749f43c Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_right_new.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_send.png b/common/src/main/res/mipmap-mdpi/icon_send.png new file mode 100644 index 000000000..4c804bd57 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_send.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_setting.png b/common/src/main/res/mipmap-mdpi/icon_setting.png new file mode 100644 index 000000000..6d971d444 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_setting.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_share_new.png b/common/src/main/res/mipmap-mdpi/icon_share_new.png new file mode 100644 index 000000000..f5dffc068 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_share_new.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_trade_union.png b/common/src/main/res/mipmap-mdpi/icon_trade_union.png new file mode 100644 index 000000000..af58be20d Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_trade_union.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_up.png b/common/src/main/res/mipmap-mdpi/icon_up.png new file mode 100644 index 000000000..d4730b3dd Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_up.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_vip_grade.png b/common/src/main/res/mipmap-mdpi/icon_vip_grade.png new file mode 100644 index 000000000..f65fc2338 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_vip_grade.png differ diff --git a/common/src/main/res/mipmap-mdpi/icon_wumen.png b/common/src/main/res/mipmap-mdpi/icon_wumen.png new file mode 100644 index 000000000..bef3daf18 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_wumen.png differ diff --git a/common/src/main/res/mipmap-mdpi/img_honor_default.png b/common/src/main/res/mipmap-mdpi/img_honor_default.png new file mode 100644 index 000000000..9959d9254 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/img_honor_default.png differ diff --git a/common/src/main/res/mipmap-mdpi/img_no1.png b/common/src/main/res/mipmap-mdpi/img_no1.png new file mode 100644 index 000000000..f79cfc680 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/img_no1.png differ diff --git a/common/src/main/res/mipmap-mdpi/img_no2.png b/common/src/main/res/mipmap-mdpi/img_no2.png new file mode 100644 index 000000000..d84f3bfcc Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/img_no2.png differ diff --git a/common/src/main/res/mipmap-mdpi/img_no3.png b/common/src/main/res/mipmap-mdpi/img_no3.png new file mode 100644 index 000000000..4f6e58164 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/img_no3.png differ diff --git a/common/src/main/res/mipmap-mdpi/main_bg.png b/common/src/main/res/mipmap-mdpi/main_bg.png new file mode 100644 index 000000000..bf2881cbd Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/main_bg.png differ diff --git a/common/src/main/res/mipmap-mdpi/temp.png b/common/src/main/res/mipmap-mdpi/temp.png new file mode 100644 index 000000000..246b71fb8 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/temp.png differ diff --git a/common/src/main/res/values-en-rUS/string.xml b/common/src/main/res/values-en-rUS/string.xml index 3427d2365..f5606a71a 100644 --- a/common/src/main/res/values-en-rUS/string.xml +++ b/common/src/main/res/values-en-rUS/string.xml @@ -94,6 +94,7 @@ Please select the correct date Warm tip: you can change your nickname once for free, and then 1800 diamonds will be needed Follow + Theater VIP Rosy Skin @@ -257,6 +258,7 @@ Log in shopmall Recommend + Find CSD Anchor Live broadcast diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index b11150857..83071f619 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -94,6 +94,7 @@ 請選擇正確的日期 溫馨提示:可以免費修改昵稱一次,之後修改需要鑽石1800一次 關注 + 短劇 主播哪裡做的不好~\n哥哥確定要取消關注嗎? 繼續關注 不再關注 @@ -463,6 +464,7 @@ 點擊進入 為你推薦 推薦 + 發現 個性設置 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index 53d35ef5a..0b3c17129 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -94,6 +94,7 @@ 請選擇正確的日期 溫馨提示:可以免費修改昵稱一次,之後修改需要鑽石1800一次 關注 + 短劇 主播哪裡做的不好~\n哥哥確定要取消關注嗎? 繼續關注 不再關注 @@ -463,6 +464,7 @@ 點擊進入 為你推薦 推薦 + 發現 個性設置 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index 205b361b1..5e6be0fa4 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -94,6 +94,7 @@ 請選擇正確的日期 溫馨提示:可以免費修改昵稱一次,之後修改需要鑽石1800一次 關注 + 短劇 主播哪裡做的不好~\n哥哥確定要取消關注嗎? 繼續關注 不再關注 @@ -463,6 +464,7 @@ 點擊進入 為你推薦 推薦 + 發現 個性設置 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/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index c8617802a..571e9d67c 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -94,6 +94,7 @@ Please select the correct date Warm tip: you can change your nickname once for free, and then 1800 diamonds will be needed Follow + Theater VIP Rosy Skin @@ -257,6 +258,7 @@ Log in shopmall Recommend + Find CSD Anchor Live broadcast @@ -1463,4 +1465,22 @@ Limited ride And limited avatar frame 年齡: 打招呼 回復 + 保存到本地相册 + 保存成功 + 完成 + 所有照片 + 最多选 %1$s 张图片哦 + 拍摄 + 取消录制 + 您拒绝了%1$s的权限,请到设置中修改 + 使用摄像头 + 使用麦克风 + 使用定位 + 读取手机信息 + 文件读写 + + + + + diff --git a/live/src/main/res/layout/item_main_com.xml b/live/src/main/res/layout/item_main_com.xml new file mode 100644 index 000000000..9be3fefdf --- /dev/null +++ b/live/src/main/res/layout/item_main_com.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index b18f29c7b..421f70aba 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -122,6 +122,7 @@ import com.yunbao.main.manager.imrongcloud.ConversationIMListManager; import com.yunbao.main.utils.GenerateTestUserSig; import com.yunbao.main.utils.UserInfoManager; import com.yunbao.main.views.FloatBannerView; +import com.yunbao.main.views.MainHomeComViewHolder; import com.yunbao.main.views.MainHomeCommunityViewHolder; import com.yunbao.main.views.MainHomeLiveViewHolder; import com.yunbao.main.views.MainHomeViewHolder; @@ -160,8 +161,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene private TabButtonGroup mTabButtonGroup; private ViewPager mViewPager; private List mViewList; - private MainHomeLiveViewHolder mHomeLiveViewHolder; - private MainHomeViewHolder mainHomeViewHolder; + private MainHomeComViewHolder mainHomeComViewHolder; + private MainHomeLiveViewHolder mainHomeLiveViewHolder; private MainHomeCommunityViewHolder mMainHomeCommunityViewHolder; private MainMessageViewHolder mainMessageViewHolder; private MainMeViewHolder mMeViewHolder; @@ -643,9 +644,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene floatBanner.setVisibility(View.VISIBLE); findViewById(R.id.banner_click).setVisibility(View.VISIBLE); } else { - if (mainHomeViewHolder != null && mainHomeViewHolder.isFloatWarOrder()) { + if (mainHomeComViewHolder != null && mainHomeComViewHolder.isFloatWarOrder()) { floatWarOrder.setVisibility(View.GONE); - } else { + }else { floatWarOrder.setVisibility(View.VISIBLE); } @@ -900,9 +901,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene mFristLoad = false; // getLocation(); loadPageData(0, false); - if (mHomeLiveViewHolder != null) { - mHomeLiveViewHolder.setShowed(true); - } } if (Constants.isShowPage != -1) { mTabButtonGroup.setCurPosition(Constants.isShowPage); @@ -1142,18 +1140,17 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene return; } if (position == 0) { - mainHomeViewHolder = new MainHomeViewHolder(mContext, parent); - vh = mainHomeViewHolder; - + mainHomeComViewHolder = new MainHomeComViewHolder(mContext, parent); + vh = mainHomeComViewHolder; } else if (position == 1) { - mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//社区 + /* mainHomeLiveViewHolder = new MainHomeLiveViewHolder(mContext, parent);//直播 + vh = mainHomeLiveViewHolder;*/ + mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播 vh = mMainHomeCommunityViewHolder; - } else if (position == 2) { mainMessageViewHolder = new MainMessageViewHolder(this, parent); vh = mainMessageViewHolder; - } else if (position == 3) { mMeViewHolder = new MainMeViewHolder(mContext, parent); vh = mMeViewHolder; @@ -1505,7 +1502,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene } floatRedPacket.setOnClickListener(v -> { MobclickAgent.onEvent(mContext, "home_page_to_redpk", "首页点击右下角去红包专区"); - mainHomeViewHolder.setCurPosition(3); + mainHomeComViewHolder.setCurPosition(3); }); } diff --git a/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java b/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java index ab211b57e..9407cf7a4 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainHomeCommunityActivity.java @@ -2,7 +2,6 @@ package com.yunbao.main.activity; import android.view.Window; import android.view.WindowManager; -import android.widget.LinearLayout; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -10,7 +9,6 @@ import androidx.fragment.app.FragmentTransaction; import com.alibaba.android.arouter.facade.annotation.Route; import com.lzf.easyfloat.EasyFloat; import com.yunbao.common.activity.AbsActivity; -import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.main.R; diff --git a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java index 7ce41a8d6..a244f3df5 100644 --- a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java @@ -2,7 +2,6 @@ package com.yunbao.main.activity; import android.content.Intent; import android.text.TextUtils; -import android.util.Log; import android.view.ViewGroup; import com.alibaba.android.arouter.facade.annotation.Route; @@ -20,7 +19,7 @@ import com.yunbao.main.views.UserHomeViewHolder2; /** * Created by cxf on 2018/9/25. */ -@Route(path = RouteUtil.PATH_USER_HOME) +//@Route(path = RouteUtil.PATH_USER_HOME) public class UserHomeActivity extends AbsActivity { private UserHomeViewHolder2 mUserHomeViewHolder; diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java new file mode 100644 index 000000000..31834cdc6 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java @@ -0,0 +1,128 @@ +package com.yunbao.main.adapter; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.main.R; + + +/** + * Created by cxf on 2018/9/26. + * 首页 社区 + */ + +public class MainHomeComAdapter extends RefreshAdapter { + + private Context mContext; + + private View.OnClickListener mOnClickListener; + + 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 + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(com.yunbao.live.R.layout.item_main_com, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { + ((Vh) vh).setData(mList.get(position), position); + } + + @Override + public int getItemCount() { + return super.getItemCount(); + } + + 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); + name = itemView.findViewById(R.id.name); + title = itemView.findViewById(R.id.title); + img = itemView.findViewById(R.id.img); + 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(ActiveBean bean, int position) { + itemView.setTag(bean); + if (bean != null) { + if (bean.getImg_or_video().equals("1")) { + JSONArray jsonArray = (JSONArray) JSONArray.parse(bean.getImg_json()); + if (jsonArray.size() != 0) { + ImgLoader.display(mContext, String.valueOf(jsonArray.get(0)), img); + } + isVideo.setVisibility(View.GONE); + } else { + ImgLoader.display(mContext, bean.getUser_avatar(), img); + isVideo.setVisibility(View.VISIBLE); + } + name.setText(bean.getUser_name()); + JSONObject json = JSONObject.parseObject(bean.getContent()); + if (json != null) { + String content = (String) json.get("msg"); + title.setText(content); + } + likeCount.setText(bean.getLove_num()); + ImgLoader.display(mContext, bean.getUser_avatar(), author); + + if (position == 0) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 550; + heightLayout.setLayoutParams(params); + + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 550; + img.setLayoutParams(imgPa); + + } else { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 750; + heightLayout.setLayoutParams(params); + + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 750; + img.setLayoutParams(imgPa); + } + } + } + } +} diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java new file mode 100644 index 000000000..e32f664b2 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComClassAdapter.java @@ -0,0 +1,107 @@ +package com.yunbao.main.adapter; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Color; +import android.os.Build; +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.yunbao.common.bean.NewCommunityType; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.main.R; + +import java.util.List; +import java.util.Locale; + +public class MainHomeComClassAdapter extends RecyclerView.Adapter { + + private Context mContext; + private List mList; + private LayoutInflater mInflater; + private View.OnClickListener mOnClickListener; + private OnItemClickListener mOnItemClickListener; + + //选中的 + public static int choice = 0; + + public MainHomeComClassAdapter(Context context, List list, boolean dialog) { + mContext = context; + mList = list; + mInflater = LayoutInflater.from(context); + mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + Object tag = v.getTag(); + if (tag != null) { + int position = (int) tag; + NewCommunityType bean = mList.get(position); + if (mOnItemClickListener != null) { + mOnItemClickListener.onItemClick(bean, position); + } + } + } + }; + } + + + public void setOnItemClickListener(OnItemClickListener onItemClickListener) { + mOnItemClickListener = onItemClickListener; + } + + @NonNull + @Override + public MainHomeComClassAdapter.Vh onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + int res = R.layout.item_main_home_com_class; + return new MainHomeComClassAdapter.Vh(mInflater.inflate(res, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull MainHomeComClassAdapter.Vh vh, int position) { + vh.setData(mList.get(position), position); + } + + @Override + public int getItemCount() { + return mList.size(); + } + + class Vh extends RecyclerView.ViewHolder { + TextView mName; + + public Vh(View itemView) { + super(itemView); + mName = (TextView) itemView.findViewById(R.id.tv_class_name); + itemView.setOnClickListener(mOnClickListener); + } + + @SuppressLint("NewApi") + void setData(NewCommunityType bean, int position) { + itemView.setTag(position); + Locale locale; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + locale = mContext.getResources().getConfiguration().getLocales().get(0); + } else { + locale = mContext.getResources().getConfiguration().locale; + } + if (locale.getLanguage().equals("zh")) { + mName.setText(bean.getTalk_name()); + } else { + mName.setText(bean.getTalk_name()); + } + + if (position == choice) { + mName.setBackgroundResource(R.drawable.bg_main_community_type_01); + mName.setTextColor(Color.parseColor("#FFFFFF")); + } else { + mName.setBackgroundResource(R.drawable.bg_main_community_type_02); + mName.setTextColor(Color.parseColor("#777777")); + } + } + } +} \ No newline at end of file diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFindComAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFindComAdapter.java new file mode 100644 index 000000000..22ccc8e72 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFindComAdapter.java @@ -0,0 +1,102 @@ +package com.yunbao.main.adapter; + +import android.content.Context; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.main.R; + +/** + * 关注和推荐的适配器 + */ +public class MainHomeRemFindComAdapter extends RefreshAdapter { + + + private Context context; + private int Height; + private View.OnClickListener mOnClickListener; + + public MainHomeRemFindComAdapter(Context context, int h) { + super(context); + this.context = context; + Log.e("t1", h + "屏1"); + this.Height = h; + } + + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(R.layout.item_main_com, parent, false)); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { + if (vh instanceof Vh) { + ((Vh) vh).setData(mList.get(position), position); + } + } + + class Vh extends RecyclerView.ViewHolder { + + TextView name; + TextView title; + TextView likeCount; + ImageView img; + ImageView author; + LinearLayout heightLayout; + + public Vh(View itemView) { + super(itemView); + name = itemView.findViewById(R.id.name); + title = itemView.findViewById(R.id.title); + img = itemView.findViewById(R.id.img); + author = itemView.findViewById(R.id.author); + likeCount = itemView.findViewById(R.id.like_count); + heightLayout = itemView.findViewById(R.id.imgLayout); + itemView.setOnClickListener(mOnClickListener); + } + + void setData(LiveBean 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 (position == 0) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 450; + heightLayout.setLayoutParams(params); + + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 450; + img.setLayoutParams(imgPa); + + } else { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 700; + heightLayout.setLayoutParams(params); + + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 700; + img.setLayoutParams(imgPa); + } + } + } + +} diff --git a/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollComAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollComAdapter.java new file mode 100644 index 000000000..cb9b50e1e --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeRemFollComAdapter.java @@ -0,0 +1,116 @@ +package com.yunbao.main.adapter; + +import android.content.Context; +import android.text.TextUtils; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.jakewharton.rxbinding3.view.RxView; +import com.squareup.picasso.Picasso; +import com.xj.marqueeview.MarqueeView; +import com.yunbao.common.Constants; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.formatBigNum; +import com.yunbao.main.R; +import com.yunbao.main.utils.MainIconUtil; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import kotlin.Unit; + +/** + * 关注和推荐的适配器 + */ +public class MainHomeRemFollComAdapter extends RefreshAdapter { + + + private Context context; + private int Height; + private View.OnClickListener mOnClickListener; + + public MainHomeRemFollComAdapter(Context context, int h) { + super(context); + this.context = context; + Log.e("t1", h + "屏1"); + this.Height = h; + } + + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new Vh(mInflater.inflate(R.layout.item_main_com, parent, false)); + + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder vh, int position) { + if (vh instanceof Vh) { + ((Vh) vh).setData(mList.get(position), position); + } + } + + class Vh extends RecyclerView.ViewHolder { + + TextView name; + TextView title; + TextView likeCount; + ImageView img; + ImageView author; + LinearLayout heightLayout; + + public Vh(View itemView) { + super(itemView); + name = itemView.findViewById(R.id.name); + title = itemView.findViewById(R.id.title); + img = itemView.findViewById(R.id.img); + author = itemView.findViewById(R.id.author); + likeCount = itemView.findViewById(R.id.like_count); + heightLayout = itemView.findViewById(R.id.imgLayout); + itemView.setOnClickListener(mOnClickListener); + } + + void setData(LiveBean 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 (position == 0) { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 450; + heightLayout.setLayoutParams(params); + + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 450; + img.setLayoutParams(imgPa); + + } else { + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) heightLayout.getLayoutParams(); + params.height = 700; + heightLayout.setLayoutParams(params); + + FrameLayout.LayoutParams imgPa = (FrameLayout.LayoutParams) img.getLayoutParams(); + imgPa.height = 700; + img.setLayoutParams(imgPa); + } + } + } + +} diff --git a/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentComViewHolder.java b/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentComViewHolder.java new file mode 100644 index 000000000..2e334a04c --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentComViewHolder.java @@ -0,0 +1,340 @@ +package com.yunbao.main.views; + +import android.content.Context; +import android.graphics.Color; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.viewpager.widget.ViewPager; + +import com.google.android.material.appbar.AppBarLayout; +import com.yunbao.common.adapter.ViewPagerAdapter; +import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.SpUtil; +import com.yunbao.common.views.AbsMainViewHolder; +import com.yunbao.main.R; +import com.yunbao.main.interfaces.AppBarStateListener; +import com.yunbao.main.interfaces.MainAppBarExpandListener; +import com.yunbao.main.interfaces.MainAppBarLayoutListener; + +import net.lucode.hackware.magicindicator.MagicIndicator; +import net.lucode.hackware.magicindicator.ViewPagerHelper; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator; +import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.CommonPagerTitleView; + +import org.greenrobot.eventbus.EventBus; +import org.w3c.dom.Text; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by cxf on 2019/2/20. + */ + +public abstract class AbsMainHomeParentComViewHolder extends AbsMainViewHolder { + + private AppBarLayout mAppBarLayout; + protected ViewPager mViewPager; + public MagicIndicator mIndicator; + private TextView mRedPoint;//显示未读消息数量的红点 + protected AbsMainHomeChildViewHolder[] mViewHolders; + private MainAppBarLayoutListener mAppBarLayoutListener; + private MainAppBarExpandListener mAppBarExpandListener; + private boolean mPaused; + protected List mViewList; + private int mAppLayoutOffestY; + private List simplePagerTitleViewList; + private List textViewList; + + public AbsMainHomeParentComViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + public void refreshIndex(int index) { + for (int i = 0; i < simplePagerTitleViewList.size(); i++) { + if (index == i) { + simplePagerTitleViewList.get(i).setVisibility(View.VISIBLE); + textViewList.get(i).setTextSize(20); + } else { + simplePagerTitleViewList.get(i).setVisibility(View.INVISIBLE); + textViewList.get(i).setTextSize(18); + } + } + } + + + @Override + public void init() { + mAppBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout); + simplePagerTitleViewList = new ArrayList<>(); + textViewList = new ArrayList<>(); + View mAppBarChildAt = mAppBarLayout.getChildAt(0); + AppBarLayout.LayoutParams mAppBarParams = (AppBarLayout.LayoutParams) mAppBarChildAt.getLayoutParams(); + mAppBarParams.setScrollFlags(0); + mAppBarLayout.addOnOffsetChangedListener(new AppBarStateListener() { + @Override + public void onStateChanged(AppBarLayout appBarLayout, int state) { + switch (state) { + case AppBarStateListener.EXPANDED: + if (mAppBarExpandListener != null) { + mAppBarExpandListener.onExpand(true); + } + break; + case AppBarStateListener.MIDDLE: + case AppBarStateListener.COLLAPSED: + if (mAppBarExpandListener != null) { + mAppBarExpandListener.onExpand(false); + } + break; + } + } + }); + mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { + @Override + public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { + if (mAppBarLayoutListener != null) { + if (verticalOffset > mAppLayoutOffestY) { + mAppBarLayoutListener.onOffsetChanged(false); + } else if (verticalOffset < mAppLayoutOffestY) { + mAppBarLayoutListener.onOffsetChanged(true); + } + mAppLayoutOffestY = verticalOffset; + } + } + }); + mViewList = new ArrayList<>(); + int pageCount = getPageCount(); + for (int i = 0; i < pageCount; i++) { + FrameLayout frameLayout = new FrameLayout(mContext); + frameLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + mViewList.add(frameLayout); + } + mViewHolders = new AbsMainHomeChildViewHolder[pageCount]; + mViewPager = (ViewPager) findViewById(R.id.viewPager); + if (pageCount > 1) { + mViewPager.setOffscreenPageLimit(pageCount - 1); + } + mViewPager.setAdapter(new ViewPagerAdapter(mViewList)); + mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + //切换ViewPager时给主页面发消息隐藏底部(只针对商城) + EventBus.getDefault().post("DownAnimaiton"); + mAppBarLayout.setExpanded(true); + } + + @Override + public void onPageSelected(int position) { + loadPageData(position); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }); + mIndicator = (MagicIndicator) findViewById(R.id.indicator); + final String[] titles = getTitles(); + CommonNavigator commonNavigator = new CommonNavigator(mContext); + commonNavigator.setAdapter(new CommonNavigatorAdapter() { + + @Override + public int getCount() { + return titles.length; + } + + @Override + public IPagerTitleView getTitleView(Context context, final int index) { + CommonPagerTitleView commonPagerTitleView = new CommonPagerTitleView(mContext); + commonPagerTitleView.setContentView(R.layout.simple_pager_title_layout); + // 初始化 + final ImageView titleImg = (ImageView) commonPagerTitleView.findViewById(R.id.index); + final TextView titleText = (TextView) commonPagerTitleView.findViewById(R.id.title); + titleText.setText(titles[index]); + + commonPagerTitleView.setOnPagerTitleChangeListener(new CommonPagerTitleView.OnPagerTitleChangeListener() { + + @Override + public void onSelected(int index, int totalCount) { + if (index == 3) { + return; + } + titleText.setTextSize(20); + } + + @Override + public void onDeselected(int index, int totalCount) { + if (index == 3) { + return; + } + titleText.setTextSize(18); + } + + @Override + public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) { + if (index == 3) { + return; + } + titleImg.setScaleX(1.1f + (0.8f - 1.1f) * leavePercent); + titleImg.setScaleY(1.1f + (0.8f - 1.1f) * leavePercent); + } + + @Override + public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) { + if (index == 3) { + return; + } + titleImg.setScaleX(0.8f + (1.1f - 0.8f) * enterPercent); + titleImg.setScaleY(0.8f + (1.1f - 0.8f) * enterPercent); + } + }); + commonPagerTitleView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mViewPager != null) { + mViewPager.setCurrentItem(index); + } + } + }); + + simplePagerTitleViewList.add(titleImg); + textViewList.add(titleText); + return commonPagerTitleView; + } + + @Override + public IPagerIndicator getIndicator(Context context) { + LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context); + linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT); + linePagerIndicator.setXOffset(DpUtil.dp2px(5)); + linePagerIndicator.setRoundRadius(DpUtil.dp2px(2)); + linePagerIndicator.setColors(Color.parseColor("#7d77fc")); + return null; + } + }); + mIndicator.setNavigator(commonNavigator); + ViewPagerHelper.bind(mIndicator, mViewPager); + mRedPoint = (TextView) findViewById(R.id.red_point); + + mIndicator.setNavigator(commonNavigator); + ViewPagerHelper.bind(mIndicator, mViewPager); + //默认选择第几个 + mIndicator.onPageSelected(1); + mViewPager.setCurrentItem(1); + unReadMsgHandle(); + } + + private void unReadMsgHandle() { + String unReadCount = "0"; + if (SpUtil.getInstance().getBooleanValue(SpUtil.HAS_SYSTEM_MSG)) { + unReadCount = "1"; + } +// String unReadCountIM = ImMessageUtil.getInstance().getAllUnReadMsgCount(); + +// try { +// int num1=Integer.parseInt(unReadCount); +// int num2=Integer.parseInt(unReadCountIM); +// int num3=num1+num2; +// setUnReadCount(""+num3); +// }catch (Exception e){ +// e.printStackTrace(); +// } + } + + + /** + * 设置AppBarLayout滑动监听 + */ + public void setAppBarLayoutListener(MainAppBarLayoutListener appBarLayoutListener) { + mAppBarLayoutListener = appBarLayoutListener; + } + + /** + * 设置AppBarLayout展开监听 + */ + public void setAppBarExpandListener(MainAppBarExpandListener appBarExpandListener) { + mAppBarExpandListener = appBarExpandListener; + } + + @Override + public void loadData() { + if (mViewPager != null) { + loadPageData(mViewPager.getCurrentItem()); + } + } + + @Override + public void onResume() { + super.onResume(); + if (isShowed() && mPaused) { + loadData(); + } + mPaused = false; + unReadMsgHandle(); + } + + + @Override + public void onPause() { + super.onPause(); + mPaused = true; + } + + @Override + public void onDestroy() { + super.onDestroy(); + mAppBarLayoutListener = null; + mAppBarExpandListener = null; + super.onDestroy(); + } + + public int getCurrentPage() { + return mViewPager.getCurrentItem(); + } + + public void setCurrentPage(int position) { + if (mViewPager == null) { + return; + } + if (mViewPager.getCurrentItem() == position) { + loadPageData(position); + } else { + mViewPager.setCurrentItem(position, false); + } + } + + /** + * 显示未读消息 + */ + public void setUnReadCount(String unReadCount) { + if (mRedPoint != null) { + if ("0".equals(unReadCount)) { + if (mRedPoint.getVisibility() == View.VISIBLE) { + mRedPoint.setVisibility(View.INVISIBLE); + } + } else { + if (mRedPoint.getVisibility() != View.VISIBLE) { + mRedPoint.setVisibility(View.VISIBLE); + } + mRedPoint.setText(unReadCount); + } + } + } + + protected abstract void loadPageData(int position); + + protected abstract int getPageCount(); + + protected abstract String[] getTitles(); + + +} diff --git a/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentViewHolder.java b/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentViewHolder.java index f1deac991..73f010231 100644 --- a/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/AbsMainHomeParentViewHolder.java @@ -2,9 +2,11 @@ package com.yunbao.main.views; import android.content.Context; import android.graphics.Color; + import com.google.android.material.appbar.AppBarLayout; -import androidx.core.content.ContextCompat; + import androidx.viewpager.widget.ViewPager; + import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -59,7 +61,7 @@ public abstract class AbsMainHomeParentViewHolder extends AbsMainViewHolder { public void init() { mAppBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout); View mAppBarChildAt = mAppBarLayout.getChildAt(0); - AppBarLayout.LayoutParams mAppBarParams = (AppBarLayout.LayoutParams) mAppBarChildAt.getLayoutParams(); + AppBarLayout.LayoutParams mAppBarParams = (AppBarLayout.LayoutParams) mAppBarChildAt.getLayoutParams(); mAppBarParams.setScrollFlags(0); mAppBarLayout.addOnOffsetChangedListener(new AppBarStateListener() { @Override @@ -137,7 +139,7 @@ public abstract class AbsMainHomeParentViewHolder extends AbsMainViewHolder { public IPagerTitleView getTitleView(Context context, final int index) { SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context); simplePagerTitleView.setNormalColor(Color.parseColor("#B1B1B1")); - simplePagerTitleView.setSelectedColor(Color.parseColor("#7d77fc")); + simplePagerTitleView.setSelectedColor(Color.parseColor("#FFC621")); simplePagerTitleView.setText(titles[index]); simplePagerTitleView.setTextSize(18); simplePagerTitleView.getPaint().setFakeBoldText(true); @@ -158,7 +160,7 @@ public abstract class AbsMainHomeParentViewHolder extends AbsMainViewHolder { linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT); linePagerIndicator.setXOffset(DpUtil.dp2px(5)); linePagerIndicator.setRoundRadius(DpUtil.dp2px(2)); - linePagerIndicator.setColors(Color.parseColor("#7d77fc")); + linePagerIndicator.setColors(Color.parseColor("#FFC621")); return linePagerIndicator; } }); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java new file mode 100644 index 000000000..cfe963061 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java @@ -0,0 +1,150 @@ +package com.yunbao.main.views; + +import android.content.Context; +import android.content.Intent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; + +import com.umeng.analytics.MobclickAgent; +import com.yunbao.common.activity.CommunitySendActivity; +import com.yunbao.common.event.FloatWarOrderEvent; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.main.R; + +import org.greenrobot.eventbus.EventBus; + +/** + * Created by Martin on 2024/3/6. + * MainActivity 首页-社区 + */ + +public class MainHomeComViewHolder extends AbsMainHomeParentComViewHolder { + private MainHomeFollComViewHolder mainHomeFollLiveViewHolder; + private MainHomeNewViewHolder mainHomeLiveViewHolder; + private MainHomeRecomComViewHolder mainHomeRecomComViewHolder; + private MainHomeGameViewHolder mainHomeGameLiveViewHolder; + private final String mPageName = "home_page"; + private ImageView btnSend; + private boolean floatWarOrder; + + public boolean isFloatWarOrder() { + return floatWarOrder; + } + + public MainHomeComViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + @Override + protected int getLayoutId() { + return R.layout.view_main_home_com; + } + + @Override + public void init() { + super.init(); + btnSend = (ImageView) findViewById(R.id.btn_send); + btnSend.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(mContext, CommunitySendActivity.class); + mContext.startActivity(intent); + } + }); + } + + public void setCurPosition(int position) { + mViewPager.setCurrentItem(position); + } + + int selected = 1; + + @Override + protected void loadPageData(int position) { + if (position == 3) { + RouteUtil.forwardCommunityActivity(); + mIndicator.onPageSelected(selected); + setCurPosition(selected); + refreshIndex(selected); + return; + } + selected = position; + refreshIndex(position); + switch (position) { + case 0: + floatWarOrder = false; + MobclickAgent.onEvent(mContext, "home_page_follow", "首页关注列表按钮"); + EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(false)); + break; + case 1: + floatWarOrder = false; + MobclickAgent.onEvent(mContext, "home_page_hot", "首页热门列表按钮"); + EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(false)); + break; + case 2: + floatWarOrder = false; + MobclickAgent.onEvent(mContext, "home_page_recommend", "首页推荐列表按钮"); + EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(false)); + break; + case 3: + floatWarOrder = true; + MobclickAgent.onEvent(mContext, "home_page_redpk", "首页红包列表按钮"); + EventBus.getDefault().post(new FloatWarOrderEvent().setFloatWarOrder(true)); + break; + } + if (mViewHolders == null) { + return; + } + AbsMainHomeChildViewHolder vh = mViewHolders[position]; + if (vh == null) { + if (mViewList != null && position < mViewList.size()) { + FrameLayout parent = mViewList.get(position); + if (parent == null) { + return; + } + if (position == -1) { + } else if (position == 0) { + mainHomeFollLiveViewHolder = new MainHomeFollComViewHolder(mContext, parent); + vh = mainHomeFollLiveViewHolder; + + } else if (position == 1) { + mainHomeLiveViewHolder = new MainHomeNewViewHolder(mContext, parent); + vh = mainHomeLiveViewHolder; + + } else if (position == 2) { + mainHomeRecomComViewHolder = new MainHomeRecomComViewHolder(mContext, parent); + vh = mainHomeRecomComViewHolder; + } + + if (vh == null) { + return; + } + mViewHolders[position] = vh; + vh.addToParent(); + vh.subscribeActivityLifeCycle(); + } + } + if (vh != null) { + vh.loadData(); + } + } + + @Override + public void onResume() { + super.onResume(); + } + + @Override + protected int getPageCount() { + return 4; + } + + @Override + protected String[] getTitles() { + return new String[]{mContext.getString(R.string.follow), mContext.getString(R.string.hot), mContext.getString(R.string.main_type_find), mContext.getString(R.string.main_type_theater),}; + } + + +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index d2900c4c4..43f36482b 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -1,92 +1,33 @@ package com.yunbao.main.views; -import static android.content.Context.CLIPBOARD_SERVICE; - -import android.app.Activity; -import android.app.Dialog; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; -import android.content.Intent; import android.graphics.Color; import android.net.Uri; -import android.os.Build; -import android.os.Handler; -import android.os.Looper; -import android.provider.MediaStore; -import android.text.TextUtils; -import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.webkit.CookieManager; import android.webkit.ValueCallback; -import android.webkit.WebChromeClient; -import android.webkit.WebSettings; import android.webkit.WebView; -import android.webkit.WebViewClient; -import android.widget.LinearLayout; import android.widget.ProgressBar; -import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.RequiresApi; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.viewpager.widget.ViewPager; import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.widget.ViewPager2; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.lxj.xpopup.XPopup; -import com.momo.mcamera.util.JsonUtil; import com.umeng.analytics.MobclickAgent; -import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.Constants; -import com.yunbao.common.HtmlConfig; -import com.yunbao.common.bean.CoolConfig; import com.yunbao.common.bean.LiveBean; -import com.yunbao.common.bean.LiveClassBean; -import com.yunbao.common.bean.NativeCallbackModel; -import com.yunbao.common.dialog.CinemaTicketPopupWindow; -import com.yunbao.common.dialog.WarOrderExchangeDetailsPopupWindow; -import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.fragment.BaseFragment; -import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.http.LiveHttpUtil; -import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.OnItemClickListener; -import com.yunbao.common.manager.IMLoginManager; -import com.yunbao.common.utils.Bus; -import com.yunbao.common.utils.DeviceUtils; -import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; -import com.yunbao.common.utils.JavascriptInterfacePlayLetUtils; -import com.yunbao.common.utils.JavascriptInterfaceUtils; -import com.yunbao.common.utils.L; -import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.RouteUtil; -import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; -import com.yunbao.live.views.LoadingView; import com.yunbao.main.R; import com.yunbao.main.activity.MainActivity; -import com.yunbao.main.activity.MyWalletActivity; -import com.yunbao.main.adapter.MainHomeLivesClassAdapter; -import com.yunbao.main.dialog.EncourageDialog; -import com.yunbao.main.fragment.BattlePassRewardFragment; import com.yunbao.main.fragment.MainHomeCommunityFragment; import com.yunbao.main.fragment.MainHomeCommunityVideoFragment; -import com.yunbao.main.fragment.SearchResultsFragment; -import com.yunbao.main.utils.BottomBarUtil; -import com.yunbao.share.ui.SharePopDialog; -import com.yunbao.video.activity.VideoPlayActivity; -import com.yunbao.video.utils.VideoStorge; import net.lucode.hackware.magicindicator.MagicIndicator; -import net.lucode.hackware.magicindicator.ViewPagerHelper; import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator; import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter; import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator; @@ -95,13 +36,8 @@ import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.Li import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView; import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Locale; /** * Created by Chen Haoxuan on 2022/3/25. diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeFollComViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeFollComViewHolder.java new file mode 100644 index 000000000..304a92ba8 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeFollComViewHolder.java @@ -0,0 +1,156 @@ +package com.yunbao.main.views; + +import android.content.Context; +import android.content.Intent; +import android.os.Parcelable; +import android.util.Log; +import android.view.ViewGroup; + +import com.alibaba.fastjson.JSON; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.activity.CommunityDetailsActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.custom.CommonRefreshWaterfallView; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.main.R; +import com.yunbao.main.activity.MainActivity; +import com.yunbao.main.activity.WeekWebViewActivity; +import com.yunbao.main.adapter.MainHomeComAdapter; +import com.yunbao.main.adapter.MainHomeRemFollComAdapter; +import com.yunbao.main.http.MainHttpConsts; +import com.yunbao.main.http.MainHttpUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class MainHomeFollComViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { + private CommonRefreshWaterfallView mRefreshView; + private MainHomeComAdapter mAdapter; + + public MainHomeFollComViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + @Override + protected int getLayoutId() { + return R.layout.view_main_home_com_recom; + } + + public static int pp; + + //显示顶部商城tab时,显示底部tabGroup + @Subscribe(threadMode = ThreadMode.MAIN) + public void onUpdata(String str) { + if ("Updata".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + mRefreshView.mRecyclerView.scrollToPosition(0); + } + } else if ("blacklist".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + } + } + } + + @Override + public void init() { + + mRefreshView = (CommonRefreshWaterfallView) findViewById(R.id.refreshView); + mRefreshView.setEmptyLayoutId(R.layout.view_no_data_foll_live); + EventBus.getDefault().register(this); + + /*ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 5, 0); + decoration.setOnlySetItemOffsetsButNoDraw(true); + mRefreshView.setItemDecoration(decoration); + */ + mRefreshView.setRecyclerViewAdapter(mAdapter); + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + if (mAdapter == null) { + mAdapter = new MainHomeComAdapter(mContext); + mAdapter.setOnItemClickListener(MainHomeFollComViewHolder.this); + } + return mAdapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + Log.i("t2", "aaa" + p); + pp = 1; + CommonHttpUtil.getCommunityFollow(p, callback); + } + + @Override + public List processData(String[] info) { + return JSON.parseArray(Arrays.toString(info), ActiveBean.class); + } + + @Override + public void onRefreshSuccess(List list, int count) { + EventBus.getDefault().post(new AnchorRecommendModel()); + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + mAdapter.insertList(loadItemList); + } + + @Override + public void onLoadMoreFailure() { + + } + }); + mRefreshView.initData(); + } + + @Override + public void onItemClick(ActiveBean bean, int position) { + Intent intent = new Intent(mContext, CommunityDetailsActivity.class); + intent.putExtra("active", (Parcelable) bean); + mContext.startActivity(intent); + } + + @Override + public void loadData() { +// if (mRefreshView != null) { +// mRefreshView.initData(); +// } + } + + @Override + public void release() { + MainHttpUtil.cancel(MainHttpConsts.GET_HOME_FOLLOW); + + } + + @Override + public void onDestroy() { + super.onDestroy(); + release(); + } + + @Override + public void onResume() { + super.onResume(); + + } +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java new file mode 100644 index 000000000..b8a9bb34b --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java @@ -0,0 +1,336 @@ +package com.yunbao.main.views; + +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; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.alibaba.fastjson.JSON; +import com.google.gson.Gson; +import com.yunbao.common.activity.CommunityDetailsActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.bean.NewCommunityType; +import com.yunbao.common.custom.CommonRefreshWaterfallView; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.CommunityTypeManager; +import com.yunbao.common.manager.OpenAdManager; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.live.bean.RedPackBean; +import com.yunbao.main.R; +import com.yunbao.main.adapter.MainHomeComAdapter; +import com.yunbao.main.adapter.MainHomeComClassAdapter; +import com.yunbao.main.http.MainHttpConsts; +import com.yunbao.main.http.MainHttpUtil; +import com.yunbao.video.interfaces.VideoScrollDataHelper; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by Martin on 2024/3/6. + * MainActivity 社区-热门 + */ + +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; + public static ImageView btnUseIco; + private int select = 0; + //是否是首頁 + private int intoIndex = 0; + private List new_data; + private Map gotoRoomKey = new HashMap<>(); + private Dialog mShowLoadingDialog; + private String typeHot; + + public MainHomeNewViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + @Override + protected int getLayoutId() { + return R.layout.view_main_home_com_hot; + } + + //显示顶部商城tab时,显示底部tabGroup + @Subscribe(threadMode = ThreadMode.MAIN) + public void onUpdata(String str) { + if ("Updata".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + mRefreshView.mRecyclerView.scrollToPosition(0); + } + } else if ("blacklist".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + } + } + } + + @Override + public void init() { + CommonHttpUtil.getTag(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + List list = JSON.parseArray(Arrays.toString(info), NewCommunityType.class); + CommunityTypeManager communityTypeManager = new CommunityTypeManager(mContext); + communityTypeManager.UpCommunityType(Arrays.toString(info)); + initCommunityTypeList(list); + } + }); + + List list = new CommunityTypeManager(mContext).getCommunityTypeList(); + if (list != null && !list.isEmpty()) { + typeHot = list.get(0).getTalk_name(); + select = list.get(0).getId(); + } else { + CommonHttpUtil.getTag(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + List list = JSON.parseArray(Arrays.toString(info), NewCommunityType.class); + CommunityTypeManager communityTypeManager = new CommunityTypeManager(mContext); + communityTypeManager.UpCommunityType(Arrays.toString(info)); + initCommunityTypeList(list); + } + }); + } + mBtnDismiss = findViewById(R.id.btn_dismiss); + mBtnDismiss.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (canClick()) { + if (mShowAnimator != null) { + mShowAnimator.cancel(); + } + if (mHideAnimator != null) { + mHideAnimator.start(); + } + } + } + }); + mRefreshView = (CommonRefreshWaterfallView) findViewById(R.id.refreshView); + btnUseIco = (ImageView) findViewById(R.id.btn_use_ico); + mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live); + EventBus.getDefault().register(this); + + mRefreshView.setLoadMoreEnable(true); + mRefreshView.setRecyclerViewAdapter(mAdapter); + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + if (mAdapter == null) { + mAdapter = new MainHomeComAdapter(mContext); + mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this); + } + return mAdapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + Log.i("t2", "aaa" + p); + CommonHttpUtil.getCommunityHotList(p, callback); + if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) { + CommonHttpUtil.getCommunityHotList(p, callback); + } else { + CommonHttpUtil.getTalkHotDynamicList(select, p, callback); + } + } + + @Override + public List processData(String[] info) { + new_data = new ArrayList<>(); + new_data = JSON.parseArray(Arrays.toString(info), ActiveBean.class); + return new_data; + } + + @Override + public void onRefreshSuccess(List list, int count) { + + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + new_data = new ArrayList<>(); + for (int j = 0; j < loadItemList.size(); j++) { + new_data.add(loadItemList.get(j)); + } + if (loadItemList.size() > 0) { + mAdapter.insertList(new_data); + } + } + + @Override + public void onLoadMoreFailure() { + + } + }); + mClassRecyclerViewTop = (RecyclerView) findViewById(R.id.classRecyclerView_top); + mClassRecyclerViewTop.setHasFixedSize(true); + mClassRecyclerViewTop.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); + mRefreshView.initData(); + initCommunityTypeList(list); + } + + + public void initCommunityTypeList(List list) { + if (list != null && list.size() > 0) { + List targetList = new ArrayList<>(); + if (list.size() <= 6) { + targetList.addAll(list); + } else { + targetList.addAll(list); + } + final MainHomeComClassAdapter topAdapter = new MainHomeComClassAdapter(mContext, targetList, false); + topAdapter.setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(NewCommunityType bean, int position) { + /*switch (bean.getEnglish()) { + case "Hot": + MobclickAgent.onEvent(mContext, "home_page_recommend_hot", "热门"); + break; + case "New": + MobclickAgent.onEvent(mContext, "home_page_recommend_new", "新秀"); + break; + case "Pretty": + MobclickAgent.onEvent(mContext, "home_page_recommend_pretty", "颜值"); + break; + case "Dance": + MobclickAgent.onEvent(mContext, "home_page_recommend_dance", "舞蹈"); + break; + case "Mr.Right": + MobclickAgent.onEvent(mContext, "home_page_recommend_mr.right", "男神"); + break; + case "Music": + MobclickAgent.onEvent(mContext, "home_page_recommend_music", "音乐"); + break; + default: + MobclickAgent.onEvent(mContext, "home_page_recommend_other", "其他"); + break; + }*/ + if (!canClick()) { + return; + } + select = bean.getId(); + typeHot = bean.getTalk_name(); + mRefreshView.initData(); + topAdapter.choice = position; + topAdapter.notifyDataSetChanged(); + } + }); + if (mClassRecyclerViewTop != null) { + mClassRecyclerViewTop.setAdapter(topAdapter); + } + } + } + + private VideoScrollDataHelper mVideoScrollDataHelper; + + @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) { + List tempList = new ArrayList<>(); + for (String s : info) { + VideoBean videoBean = JSONObject.parseObject(s, VideoBean.class); + tempList.add(videoBean); + } + VideoStorge.getInstance().put(Constants.VIDEO_HOME, tempList); + VideoPlayActivity.forward(mContext, position, Constants.VIDEO_HOME, 1); + } + } + });*/ + } + + /** + * Banner双击可能会导致进入两次直播间,点击Banner后需要展示加载中动画 + */ + private void showLoadingDialog() { + mShowLoadingDialog = DialogUitl.loadingDialog(mContext); + mShowLoadingDialog.show(); + } + + @Override + public void loadData() { + } + + @Override + public void release() { + MainHttpUtil.cancel(MainHttpConsts.GET_HOT); + if (mHideAnimator != null) { + mHideAnimator.cancel(); + } + if (mShowAnimator != null) { + mShowAnimator.cancel(); + } + mShowAnimator = null; + mHideAnimator = null; + } + + @Override + public void onDestroy() { + super.onDestroy(); + release(); + } + + @Override + public void onResume() { + super.onResume(); + OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false); + } + + @Override + public void onPause() { + super.onPause(); + if (mShowLoadingDialog != null) { + mShowLoadingDialog.dismiss(); + mShowLoadingDialog = null; + } + } + +} diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java new file mode 100644 index 000000000..47a6d47eb --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java @@ -0,0 +1,163 @@ +package com.yunbao.main.views; + +import android.content.Context; +import android.content.Intent; +import android.os.Parcelable; +import android.view.ViewGroup; + +import androidx.recyclerview.widget.GridLayoutManager; + +import com.alibaba.fastjson.JSON; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.activity.CommunityDetailsActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.ActiveBean; +import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.custom.CommonRefreshWaterfallView; +import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.main.R; +import com.yunbao.main.activity.MainActivity; +import com.yunbao.main.activity.WeekWebViewActivity; +import com.yunbao.main.adapter.MainHomeComAdapter; +import com.yunbao.main.adapter.MainHomeRemFindComAdapter; +import com.yunbao.main.adapter.MainHomeRemFollLiveAdapter; +import com.yunbao.main.http.MainHttpConsts; +import com.yunbao.main.http.MainHttpUtil; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.Arrays; +import java.util.List; + +/** + * 社区-发现 + */ +public class MainHomeRecomComViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener { + private CommonRefreshWaterfallView mRefreshView; + private MainHomeComAdapter mAdapter; + + public MainHomeRecomComViewHolder(Context context, ViewGroup parentView) { + super(context, parentView); + } + + @Override + protected int getLayoutId() { + return R.layout.view_main_home_com_recom; + } + + public static int pp; + + //显示顶部商城tab时,显示底部tabGroup + @Subscribe(threadMode = ThreadMode.MAIN) + public void onUpdata(String str) { + if ("Updata".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + mRefreshView.mRecyclerView.scrollToPosition(0); + } + } else if ("blacklist".equals(str)) { + if (mRefreshView != null) { + mRefreshView.showRefreshBar(); + } + } + } + + @Override + public void init() { + + mRefreshView = (CommonRefreshWaterfallView) findViewById(R.id.refreshView); + mRefreshView.setEmptyLayoutId(R.layout.view_no_data_live); + EventBus.getDefault().register(this); + mRefreshView.setRecyclerViewAdapter(mAdapter); + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + if (mAdapter == null) { + mAdapter = new MainHomeComAdapter(mContext); + mAdapter.setOnItemClickListener(MainHomeRecomComViewHolder.this); + } + return mAdapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + pp = p; + CommonHttpUtil.getCommunityFind(p, callback); + } + + @Override + public List processData(String[] info) { + if (pp == 1) { + return JSON.parseArray(Arrays.toString(info), ActiveBean.class); + } else { + return null; + } + } + + @Override + public void onRefreshSuccess(List list, int count) { + EventBus.getDefault().post(new AnchorRecommendModel()); + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + + } + + @Override + public void onLoadMoreFailure() { + + } + }); + + mRefreshView.initData(); + + + } + + @Override + public void onItemClick(ActiveBean bean, int position) { + Intent intent = new Intent(mContext, CommunityDetailsActivity.class); + intent.putExtra("active", (Parcelable) bean); + mContext.startActivity(intent); + } + + @Override + public void loadData() { +// if (mRefreshView != null) { +// mRefreshView.initData(); +// } + } + + @Override + public void release() { + MainHttpUtil.cancel(MainHttpConsts.GET_RANDOM); + + } + + @Override + public void onDestroy() { + super.onDestroy(); + release(); + } + + @Override + public void onResume() { + super.onResume(); + + } +} diff --git a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java index 7f691cf41..7ffe0d335 100644 --- a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java +++ b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java @@ -464,7 +464,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh avatar = userBean.getAvatar(); ImgLoader.displayBlur(mContext, avatar, mAvatarBg); ImgLoader.displayAvatar(mContext, avatar, mAvatar); - if (userBean.getDress().getAvatar_frame() != null) { + /*if (userBean.getDress().getAvatar_frame() != null) { if (userBean.getDress().getAvatar_frame().contains("svga")) { try { new SVGAParser(mContext).parse(new URL(userBean.getDress().getAvatar_frame()), new SVGAParser.ParseCompletion() { @@ -485,7 +485,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh } else { ImgLoader.display(mContext, userBean.getDress().getAvatar_frame(), gift_svga); } - } + }*/ if (userBean.getDress().getMedal() != null) { diff --git a/main/src/main/res/drawable/bg_main_community_type.xml b/main/src/main/res/drawable/bg_main_community_type.xml new file mode 100644 index 000000000..9be4e9a81 --- /dev/null +++ b/main/src/main/res/drawable/bg_main_community_type.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/main/src/main/res/drawable/bg_main_community_type_01.xml b/main/src/main/res/drawable/bg_main_community_type_01.xml new file mode 100644 index 000000000..9be4e9a81 --- /dev/null +++ b/main/src/main/res/drawable/bg_main_community_type_01.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/main/src/main/res/drawable/bg_main_community_type_02.xml b/main/src/main/res/drawable/bg_main_community_type_02.xml new file mode 100644 index 000000000..9c5be4c31 --- /dev/null +++ b/main/src/main/res/drawable/bg_main_community_type_02.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/main/src/main/res/layout/item_main_home_com.xml b/main/src/main/res/layout/item_main_home_com.xml new file mode 100644 index 000000000..762522b26 --- /dev/null +++ b/main/src/main/res/layout/item_main_home_com.xml @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/item_main_home_com_class.xml b/main/src/main/res/layout/item_main_home_com_class.xml new file mode 100644 index 000000000..ba4eef0db --- /dev/null +++ b/main/src/main/res/layout/item_main_home_com_class.xml @@ -0,0 +1,22 @@ + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/simple_pager_title_layout.xml b/main/src/main/res/layout/simple_pager_title_layout.xml new file mode 100644 index 000000000..e96098453 --- /dev/null +++ b/main/src/main/res/layout/simple_pager_title_layout.xml @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/main/src/main/res/layout/view_main_home_com.xml b/main/src/main/res/layout/view_main_home_com.xml new file mode 100644 index 000000000..8ffe7c2d1 --- /dev/null +++ b/main/src/main/res/layout/view_main_home_com.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/view_main_home_com_hot.xml b/main/src/main/res/layout/view_main_home_com_hot.xml new file mode 100644 index 000000000..f61477767 --- /dev/null +++ b/main/src/main/res/layout/view_main_home_com_hot.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/layout/view_main_home_com_recom.xml b/main/src/main/res/layout/view_main_home_com_recom.xml new file mode 100644 index 000000000..24dfc2357 --- /dev/null +++ b/main/src/main/res/layout/view_main_home_com_recom.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/main/src/main/res/mipmap-mdpi/icon_main_add.png b/main/src/main/res/mipmap-mdpi/icon_main_add.png new file mode 100644 index 000000000..7fdfcbc97 Binary files /dev/null and b/main/src/main/res/mipmap-mdpi/icon_main_add.png differ 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