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 b9ff40117..7124a67a2 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -221,5 +221,7 @@ dependencies { //samsung插件包 api project(':IAP6Helper') + //瀑布流 + api 'com.wuxiaolong.pullloadmorerecyclerview:library:1.1.2' } diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index 19358ba04..b30402cd7 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,14 @@ 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..3e8eb168f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/activity/CommunityDetailsActivity.java @@ -0,0 +1,49 @@ +package com.yunbao.common.activity; + +import android.content.Intent; +import android.widget.LinearLayout; + +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.manager.OpenAdManager; + +public class CommunityDetailsActivity extends AbsActivity { + private RecyclerView mRecyclerViewImage; + private LinearLayout imgTextLayout; + private LinearLayout videoLayout; + + @Override + protected int getLayoutId() { + 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() { + + mRecyclerViewImage = findViewById(R.id.recyclerView); + mRecyclerViewImage.setLayoutManager(new GridLayoutManager(mContext, 3, GridLayoutManager.VERTICAL, false)); + ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 15, 15); + decoration.setOnlySetItemOffsetsButNoDraw(true); + mRecyclerViewImage.addItemDecoration(decoration); + + } + + @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..ff8438f43 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/activity/CommunitySendActivity.java @@ -0,0 +1,65 @@ +package com.yunbao.common.activity; + +import android.content.Intent; +import android.view.View; +import android.widget.LinearLayout; + +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.custom.ItemDecoration; +import com.yunbao.common.manager.OpenAdManager; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; + +public class CommunitySendActivity extends AbsActivity { + private RecyclerView mRecyclerViewImage; + private LinearLayout imgTextLayout; + private LinearLayout videoLayout; + + @Override + protected int getLayoutId() { + return R.layout.activity_community_send; + } + + @Override + protected void create() { + super.create(); + } + + @Override + protected void onPause() { + super.onPause(); + OpenAdManager.getInstance().dismiss(); + } + + @Override + protected void main() { + imgTextLayout = findViewById(R.id.imgTextLayout); + videoLayout = findViewById(R.id.videoLayout); + + imgTextLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + } + }); + videoLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + } + }); + + 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); + + } + + @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/UserHomeActivity.java b/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java new file mode 100644 index 000000000..df21dcd3f --- /dev/null +++ b/common/src/main/java/com/yunbao/common/activity/UserHomeActivity.java @@ -0,0 +1,30 @@ +package com.yunbao.common.activity; + +import android.content.Intent; +import android.view.View; + +import com.yunbao.common.R; + +public class UserHomeActivity extends AbsActivity { + + View bodyLayout; + + @Override + protected int getLayoutId() { + return R.layout.activity_user_home; + } + + @Override + protected void create() { + super.create(); + } + + @Override + protected void main() { + } + + @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/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/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/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/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/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/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_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_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_user_home_bottom.xml b/common/src/main/res/drawable/bg_user_home_bottom.xml new file mode 100644 index 000000000..97e25b6a1 --- /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..a5e7cee5d --- /dev/null +++ b/common/src/main/res/layout/activity_community_details.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..91781ac1d --- /dev/null +++ b/common/src/main/res/layout/activity_community_send.xml @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..94c835f56 --- /dev/null +++ b/common/src/main/res/layout/activity_user_home.xml @@ -0,0 +1,393 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..c57bb5b00 --- /dev/null +++ b/common/src/main/res/layout/view_preview_image.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..23bfe738d --- /dev/null +++ b/common/src/main/res/layout/view_title_new.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + 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/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_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_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_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_man.png b/common/src/main/res/mipmap-mdpi/icon_man.png new file mode 100644 index 000000000..bef3daf18 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/icon_man.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_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/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 b98e1dc22..18c03ef4f 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 6ac031f2d..4c1ac455f 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 249b1f83a..43446271f 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 6b0c30b57..85cf5c9bd 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/strings.xml b/common/src/main/res/values/strings.xml index 015c07bf9..e7b3403b5 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 @@ -1455,4 +1457,22 @@ Limited ride And limited avatar frame Sure + 保存到本地相册 + 保存成功 + 完成 + 所有照片 + 最多选 %1$s 张图片哦 + 拍摄 + 取消录制 + 您拒绝了%1$s的权限,请到设置中修改 + 使用摄像头 + 使用麦克风 + 使用定位 + 读取手机信息 + 文件读写 + + + + + diff --git a/config.gradle b/config.gradle index 9425ef0b0..753ecd6b0 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式、 - serverHost : "https://napi.yaoulive.com", + //serverHost : "https://napi.yaoulive.com", // 测试 -// serverHost : " https://ceshi.yaoulive.com", + serverHost : " https://ceshi.yaoulive.com", //百度语音识别 baiduAppId : "23774720", 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..afbeebebe --- /dev/null +++ b/live/src/main/res/layout/item_main_com.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 2b280ad62..d454a6f7a 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -120,9 +120,9 @@ import com.yunbao.main.interfaces.MainAppBarLayoutListener; import com.yunbao.main.manager.imrongcloud.ConversationIMListManager; import com.yunbao.main.utils.GenerateTestUserSig; 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; import com.yunbao.main.views.MainMeViewHolder; import com.yunbao.main.views.MainMessageViewHolder; import com.yunbao.video.utils.VideoStorge; @@ -158,8 +158,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; @@ -638,9 +638,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); } @@ -895,9 +895,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); @@ -1137,11 +1134,11 @@ 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);//社区 + mMainHomeCommunityViewHolder = new MainHomeCommunityViewHolder(mContext, parent, this);//直播 vh = mMainHomeCommunityViewHolder; } else if (position == 2) { @@ -1500,10 +1497,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/adapter/MainHomeComAdapter.java b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java new file mode 100644 index 000000000..f3a2ab228 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/adapter/MainHomeComAdapter.java @@ -0,0 +1,110 @@ +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.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.main.R; + +import java.util.ArrayList; +import java.util.List; + + +/** + * Created by cxf on 2018/9/26. + * 首页 直播 + */ + +public class MainHomeComAdapter extends RefreshAdapter { + + + private Context mContext; + private View.OnClickListener mOnClickListener; + + public void setmOnClickListener(View.OnClickListener mOnClickListener) { + this.mOnClickListener = mOnClickListener; + } + + private List heightList = new ArrayList<>(); + + public MainHomeComAdapter(Context context) { + super(context); + this.mContext = context; + } + + @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; + + 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 = 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..7124ba97b --- /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.LiveClassBean; +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; + LiveClassBean 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(LiveClassBean 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.getChinese()); + } else { + mName.setText(bean.getEnglish()); + } + + 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..496a0ab3a --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeComViewHolder.java @@ -0,0 +1,151 @@ +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.AbsActivity; +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..0c5eee807 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeFollComViewHolder.java @@ -0,0 +1,165 @@ +package com.yunbao.main.views; + +import android.content.Context; +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.adapter.RefreshAdapter; +import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.custom.CommonRefreshWaterfallView; +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.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 MainHomeRemFollComAdapter 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 MainHomeRemFollComAdapter(mContext, MainActivity.Height); + mAdapter.setOnItemClickListener(MainHomeFollComViewHolder.this); + } + return mAdapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + Log.i("t2", "aaa" + p); + pp = 1; + MainHttpUtil.getHomeFollow(p, callback); + } + + @Override + public List processData(String[] info) { + return JSON.parseArray(Arrays.toString(info), LiveBean.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) { + List new_data = new ArrayList<>(); + for (int j = 0; j < loadItemList.size(); j++) { + if (loadItemList.get(j).getUserNiceName() != null) { + new_data.add(loadItemList.get(j)); + } + } + mAdapter.insertList(new_data); + } + + @Override + public void onLoadMoreFailure() { + + } + }); + + mRefreshView.initData(); + + + } + + + @Override + public void onItemClick(LiveBean bean, int position) { + if ("1".equals(bean.getIslive())) { + watchLive(bean, Constants.LIVE_HOME, position); + } else if (bean.getIs_week() != null && bean.getIs_week().equals("1")) { + String url = CommonAppConfig.HOST + bean.getUrl() + "?a=1"; + WeekWebViewActivity.forward(mContext, url, true); + } else { + RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); + } + } + + @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..1c81c60f1 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeNewViewHolder.java @@ -0,0 +1,440 @@ +package com.yunbao.main.views; + +import android.animation.ObjectAnimator; +import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +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.alibaba.fastjson.JSONObject; +import com.umeng.analytics.MobclickAgent; +import com.yunbao.common.CommonAppConfig; +import com.yunbao.common.Constants; +import com.yunbao.common.activity.CommunityDetailsActivity; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.AnchorRecommendModel; +import com.yunbao.common.bean.BannerBean; +import com.yunbao.common.bean.LiveBean; +import com.yunbao.common.bean.LiveClassBean; +import com.yunbao.common.bean.WeekListBean; +import com.yunbao.common.custom.CommonRefreshWaterfallView; +import com.yunbao.common.event.LiveRoomChangeEvent; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.interfaces.OnItemClickListener; +import com.yunbao.common.manager.LiveClassManager; +import com.yunbao.common.manager.OpenAdManager; +import com.yunbao.common.utils.DialogUitl; +import com.yunbao.common.utils.LiveRoomCheckLivePresenter; +import com.yunbao.common.utils.MicStatusManager; +import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.live.utils.LiveStorge; +import com.yunbao.live.views.LiveRoomViewHolder; +import com.yunbao.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 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 mShadow; + private View mBtnDismiss; + public static CommonRefreshWaterfallView mRefreshView; + private RecyclerView mClassRecyclerViewTop; + private MainHomeComAdapter mAdapter; + private ObjectAnimator mShowAnimator; + private ObjectAnimator mHideAnimator; + private boolean mBannerShowed; + private List mBannerList; + private List mWeekListBean; + public static ImageView btnUseIco; + private int select = 0; + //是否是首頁 + private int intoIndex = 0; + private List new_data; + private boolean isHave = false; + private 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; + } + + 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() { + List list = new LiveClassManager(mContext).getLiveClass(); + if (list != null && !list.isEmpty()) { + typeHot = list.get(0).getEnglish(); + select = list.get(0).getId(); + } + mShadow = findViewById(R.id.shadow); + mBtnDismiss = findViewById(R.id.btn_dismiss); + mBtnDismiss.setOnClickListener(new View.OnClickListener() { + @Override + 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); + + mAdapter = new MainHomeComAdapter(mContext); + mAdapter.setmOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(mContext, CommunityDetailsActivity.class); + mContext.startActivity(intent); + } + }); + mAdapter.setOnItemClickListener(MainHomeNewViewHolder.this); + mAdapter.setHasStableIds(true);// + mRefreshView.setLoadMoreEnable(true); + mRefreshView.setRecyclerViewAdapter(mAdapter); + mRefreshView.setDataHelper(new CommonRefreshWaterfallView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + return null; + } + + @Override + public void loadData(int p, HttpCallback callback) { + Log.i("t2", "aaa" + p); + if (TextUtils.equals(typeHot, "Hot") || TextUtils.equals(typeHot, "hot") || TextUtils.equals(typeHot, "熱門")) { + pp = 1; + LiveHttpUtil.getAnchorLastWeekList(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (mWeekListBean != null) { + mWeekListBean.clear(); + } + if (code == 0 && info.length > 0) { + mWeekListBean = JSON.parseArray(Arrays.toString(info), WeekListBean.class); + } else { + mWeekListBean = null; + } + if (mWeekListBean != null && mWeekListBean.size() > 0) { + isHave = true; + } else { + isHave = false; + } + Constants.getWeekIntIndex = Constants.getWeekIntIndex + 1; + MainHttpUtil.getHot(p, callback); + } + }); + } else { + pp = 0; + MainHttpUtil.getClassLive(select, p, callback); + } + } + + @Override + public List processData(String[] info) { + new_data = new ArrayList<>(); + if (info.length > 0) { + JSONObject obj = JSON.parseObject(info[0]); + + mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class); + if (!obj.containsKey("list")) { + return new_data; + } + List old_data = JSON.parseArray(obj.getString("list"), LiveBean.class); + LiveBean liveModel = null; + if (old_data == null) { + return new_data; + } + for (LiveBean model : old_data) { + //判断周星榜数据 + if (TextUtils.equals(model.getIs_week(), "1")) { + if (mWeekListBean != null && mWeekListBean.size() > 0) { + model.setmWeekList(mWeekListBean); + } else { + liveModel = model; + } + } + } + //满足有周星榜字段但是没有周星榜数据的删掉 + if (liveModel != null) { + old_data.remove(liveModel); + } + new_data.addAll(old_data); + + } + return new_data; + } + + @Override + public void onRefreshSuccess(List list, int count) { + if (CommonAppConfig.LIVE_ROOM_SCROLL) { + LiveStorge.getInstance().put(Constants.LIVE_HOME, list); + } + EventBus.getDefault().post(new AnchorRecommendModel()); + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + new_data = new ArrayList<>(); + for (int j = 0; j < loadItemList.size(); j++) { + if (loadItemList.get(j).getUserNiceName() != null) { + new_data.add(loadItemList.get(j)); + } + } + 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)); + + 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(LiveClassBean 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.getEnglish(); + mRefreshView.initData(); + topAdapter.choice = position; + topAdapter.notifyDataSetChanged(); + + } + }); + if (mClassRecyclerViewTop != null) { + mClassRecyclerViewTop.setAdapter(topAdapter); + } + } + mRefreshView.initData(); + } + + + private void gotoLive(final String live_id) { + LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + if (liveBean == null) { + return; + } + intoIndex = 1; + if (gotoRoomKey != null && gotoRoomKey.isEmpty()) { + gotoRoomKey = null; + } + liveBean.setParams(gotoRoomKey); + new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + @Override + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal)); + } + + @Override + public void onCheckError(String contextError) { + + } + }); + + } else { + intoIndex = 1; + RouteUtil.forwardUserHome(mContext, live_id, 0); + } + } + }); + } + + /** + * Banner双击可能会导致进入两次直播间,点击Banner后需要展示加载中动画 + */ + private void showLoadingDialog() { + mShowLoadingDialog = DialogUitl.loadingDialog(mContext); + mShowLoadingDialog.show(); + } + + @Override + public void onItemClick(LiveBean bean, int position) { + if ("1".equals(bean.getIslive())) { + intoIndex = 1; + watchLive(bean, Constants.LIVE_HOME, position); + } else if (bean.getIs_week() != null && bean.getIs_week().equals("1")) { + String url = CommonAppConfig.HOST + bean.getUrl() + "?a=1"; + LiveHttpUtil.getLiveInfo(bean.getUid(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + + if (liveBean == null) { + return; + } + new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() { + @Override + public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) { + + if (LiveRoomViewHolder.mHandler != null) { + LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); + } + if (!"".endsWith(Constants.mStream)) { + if (MicStatusManager.getInstance().isMic(liveUid)) { + MicStatusManager.getInstance().showDownMicDialog(mContext); + return; + } + EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal))); + } else { + RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk)); + } + } + + @Override + public void onCheckError(String contextError) { + + } + }); + + } else { + ToastUtil.show(msg); + } + } + }); + } else { + intoIndex = 1; + RouteUtil.forwardUserHome(mContext, bean.getUid(), 0); + } + } + + + @Override + public void loadData() { + } + + @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..b6e30de79 --- /dev/null +++ b/main/src/main/java/com/yunbao/main/views/MainHomeRecomComViewHolder.java @@ -0,0 +1,166 @@ +package com.yunbao.main.views; + +import android.content.Context; +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.adapter.RefreshAdapter; +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.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.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 MainHomeRemFindComAdapter 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 MainHomeRemFindComAdapter(mContext, MainActivity.Height); + mAdapter.setOnItemClickListener(MainHomeRecomComViewHolder.this); + } + return mAdapter; + } + + @Override + public void loadData(int p, HttpCallback callback) { + pp = p; + MainHttpUtil.getRandom(p, callback); + } + + @Override + public List processData(String[] info) { + if(pp == 1){ + return JSON.parseArray(Arrays.toString(info), LiveBean.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(LiveBean bean, int position) { + if ("1".equals(bean.getIslive())) { + watchLive(bean, Constants.LIVE_HOME, position); + }else if(bean.getIs_week()!=null&&bean.getIs_week().equals("1")){ + String url = CommonAppConfig.HOST + bean.getUrl()+"?a=1"; + WeekWebViewActivity.forward(mContext, url, true); + } else { + RouteUtil.forwardUserHome(mContext, bean.getUid(),0); + } + } + + @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/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..695ad2f37 --- /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