This commit is contained in:
18401019693 2022-08-12 13:26:21 +08:00
parent 8fb0f7a4e6
commit 0c4448f1f2
10 changed files with 306 additions and 310 deletions

View File

@ -0,0 +1,51 @@
package com.yunbao.common.views.weight;
import android.view.View;
import com.jakewharton.rxbinding3.view.RxView;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import kotlin.Unit;
/**
* View防抖
*/
public class ViewClicksAntiShake {
//防抖回调
public interface ViewClicksCallBack {
void onViewClicks();
}
/**
* 防抖
*/
public static void clicksAntiShake(View view, ViewClicksCallBack callBack) {
RxView.clicks(view)
.throttleFirst(2, TimeUnit.SECONDS)
.subscribe(new Observer<Unit>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Unit unit) {
if (callBack != null)
callBack.onViewClicks();
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
}

View File

@ -33,6 +33,7 @@ import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.SkuDetails;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jakewharton.rxbinding3.view.RxView;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSDKConfig;
@ -113,10 +114,14 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import cn.rongcloud.rtc.api.RCRTCConfig;
import cn.rongcloud.rtc.api.RCRTCEngine;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.rong.imlib.RongIMClient;
import kotlin.Unit;
import static com.yunbao.common.CommonAppContext.isReady;
@ -162,7 +167,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
private int messageNumber = 0, numberMe = 1;
private ImageView waitingTip;
private FloatBannerView floatBanner;
private boolean isClickfloatBanner = false;
private boolean isfloatBannernet = true;
@ -366,11 +370,16 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0);
isInstructor();
findViewById(R.id.banner_click).setOnClickListener(new View.OnClickListener() {
RxView.clicks(findViewById(R.id.banner_click))
.throttleFirst(2, TimeUnit.SECONDS)
.subscribe(new Observer<Unit>() {
@Override
public void onClick(View v) {
if (!isClickfloatBanner) {
isClickfloatBanner = true;
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Unit unit) {
String Uid = floatBanner.getUid();
LiveHttpUtil.getLiveInfo(Uid + "", new HttpCallback() {
@Override
@ -391,19 +400,24 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
});
mCheckLivePresenter.checkLive(liveBean);
isClickfloatBanner = false;
} else {
RouteUtil.forwardUserHome(mContext, Uid, 0);
isClickfloatBanner = false;
}
}
});
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
//选中监听
mTabButtonGroup.addTabButtonGroupChangeListener((view, index) -> {
if (index == 0) {
@ -414,7 +428,6 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
floatBanner.setVisibility(View.GONE);
findViewById(R.id.banner_click).setVisibility(View.GONE);
isfloatBannernet = false;
isClickfloatBanner = false;
}
});
}

View File

@ -23,21 +23,14 @@ import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
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.WeekListBean;
import com.yunbao.common.custom.RatioRoundImageView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.formatBigNum;
import com.yunbao.live.bean.LiveBean;
import com.yunbao.main.R;
import com.yunbao.main.bean.HomeTopBean;
import com.yunbao.main.utils.MainIconUtil;
import com.yunbao.main.views.MainHomeLiveItemViewHolder;
import com.yunbao.main.views.MainHomeLiveViewHolder;
import com.yunbao.main.views.MainHomeLiveWeekItemViewHolder;
import java.util.List;
@ -54,7 +47,6 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
private static final int LEFT = 1;
private static final int RIGHT = 2;
private final int WEEKLAYOUT = 5005;
private View.OnClickListener mOnClickListener;
private View mHeadView;
private Context context;
private int Height;
@ -66,26 +58,6 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
this.Height = h;
mHeadView = mInflater.inflate(R.layout.item_main_home_live_head, null, false);
mHeadView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DpUtil.dp2px(140)));
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!canClick()) {
return;
}
Object tag = v.getTag();
if (tag != null) {
int position = (int) tag;
if (mOnItemClickListener != null) {
if (mList.get(position).getIs_week() != null && mList.get(position).getIs_week().equals("1")) {
if (mList.get(position).getmWeekList() != null && mList.get(position).getmWeekList().size() > 0) {
mList.get(position).setUid(mList.get(position).getmWeekList().get(weekListIndex).getAnchor_id());
}
}
mOnItemClickListener.onItemClick(mList.get(position), position);
}
}
}
};
}
public View getHeadView() {
@ -174,138 +146,6 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
}
}
HomeTopBean HomeTopData;
// class Vh extends RecyclerView.ViewHolder {
// LinearLayout live_info_view, lt_week_list;
// ImageView mCover, img_week_head;
// TextView mName, name2;
// TextView mTitle;
// TextView mNum;
// ImageView mType;
// ImageView live_type;
//
// ImageView mLiveIco;
// TextView mLiveState;
// MarqueeView mRvRankingList;
// ImageView PkAvatar;
// ImageView Pkico;
// ImageView dr_pk_ico;
// View views;
// RatioRoundImageView bgs;
// SVGAImageView week_svga;
//
// public Vh(View itemView) {
// super(itemView);
// live_info_view = (LinearLayout) itemView.findViewById(R.id.live_info_view);
// lt_week_list = (LinearLayout) itemView.findViewById(R.id.lt_week_list);
// mCover = (ImageView) itemView.findViewById(R.id.cover);
// mName = (TextView) itemView.findViewById(R.id.name);
// mTitle = (TextView) itemView.findViewById(R.id.title);
// mNum = (TextView) itemView.findViewById(R.id.num);
// mType = (ImageView) itemView.findViewById(R.id.type);
// mLiveIco = (ImageView) itemView.findViewById(R.id.tv_live_ico);
// PkAvatar = (ImageView) itemView.findViewById(R.id.pk_avatar);
// Pkico = (ImageView) itemView.findViewById(R.id.pk_ico);
// dr_pk_ico = (ImageView) itemView.findViewById(R.id.dr_pk_ico);
// mLiveState = (TextView) itemView.findViewById(R.id.tv_live_state);
// mRvRankingList = (MarqueeView) itemView.findViewById(R.id.rv_ranking_list);
// live_type = (ImageView) itemView.findViewById(R.id.live_type);
// views = itemView.findViewById(R.id.views);
// bgs = itemView.findViewById(R.id.bgs);
// itemView.setOnClickListener(mOnClickListener);
//
// week_svga = (SVGAImageView) itemView.findViewById(R.id.week_svga);
// img_week_head = (ImageView) itemView.findViewById(R.id.img_week_head);
// name2 = (TextView) itemView.findViewById(R.id.name2);
// }
//
// void setData(LiveBean bean, int position) {
// Log.e("MainHomeLiveAdapter", position + " ***************" + "LiveBean:" + bean.getThumb());
//// Log.e("MainHomeLiveAdapter", position + " ***************" + "LiveBean:" + new Gson().toJson(bean));
// itemView.setTag(position);
// live_info_view.setVisibility(View.VISIBLE);
// live_type.setImageDrawable(null);
// if (bean.getContent_pic_size_two() != null && !bean.getContent_pic_size_two().equals("") && Height <= 1920) {
// Picasso.with(mContext)
// .load(bean.getContent_pic_size_two())
// .into(live_type);
// } else if (bean.getContent_pic_size_three() != null && !bean.getContent_pic_size_three().equals("") && Height > 1920) {
// Log.e("t1", position + "222啊" + Height + bean.getContent_pic_size_three());
// Picasso.with(mContext)
// .load(bean.getContent_pic_size_three())
// .into(live_type);
// }
// live_info_view.setVisibility(View.GONE);
// lt_week_list.setVisibility(View.GONE);
// if (bean.getIsTop() != null && bean.getIsTop().equals("1")) {
// if (MainHomeLiveViewHolder.pp != 1) {
// live_info_view.setVisibility(View.GONE);
// mRvRankingList.setVisibility(View.GONE);
// }
// } else {
// live_info_view.setVisibility(View.VISIBLE);
// mRvRankingList.setVisibility(View.GONE);
// bgs.setVisibility(View.GONE);
// if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
// bgs.setVisibility(View.GONE);
// getWeekIntIndex = Constants.getWeekIntIndex;
// getUserHotList(week_svga, live_info_view, lt_week_list, img_week_head, mTitle, name2, position, bean.getmWeekList());
// Log.e("MainHomeLiveAdapter", position + " ***************" + "周星榜");
// } else {
// ImgLoader.display(mContext, bean.getThumb(), mCover);
// bgs.setVisibility(View.VISIBLE);
// }
// Pkico.setVisibility(View.GONE);
// PkAvatar.setVisibility(View.GONE);
// dr_pk_ico.setVisibility(View.GONE);
// if (bean.getDrpk_status() != null && bean.getDrpk_status().equals("1")) {
// dr_pk_ico.setVisibility(View.VISIBLE);
// }
// if (bean.getPk_avatar_thumb() != null && !bean.getPk_avatar_thumb().equals("")) {
// ImgLoader.display(mContext, bean.getPk_avatar_thumb(), PkAvatar);
// Pkico.setVisibility(View.VISIBLE);
// PkAvatar.setVisibility(View.VISIBLE);
// }
// mName.setText(bean.getUserNiceName());
// if (TextUtils.isEmpty(bean.getTitle())) {
// if (mTitle.getVisibility() == View.VISIBLE) {
// mTitle.setVisibility(View.GONE);
// }
// } else {
// if (mTitle.getVisibility() != View.VISIBLE) {
// mTitle.setVisibility(View.VISIBLE);
// }
// mTitle.setText(bean.getTitle());
// }
// mNum.setText(formatBigNum.formatBigNum(bean.getHot_num()));
// views.setVisibility(View.GONE);
// if ("1".equals(bean.getIslive())) {
// views.setVisibility(View.VISIBLE);
// //直播中
// mType.setImageResource(MainIconUtil.getLiveTypeIcon(bean.getType()));
// mType.setVisibility(View.VISIBLE);
// mLiveIco.setImageResource(R.mipmap.icon_main_rest_work);
// mNum.setVisibility(View.VISIBLE);
// live_type.setVisibility(View.VISIBLE);
// mLiveState.setText(R.string.lives_state);
// } else {
// views.setVisibility(View.VISIBLE);
// //休息中
// mType.setImageResource(MainIconUtil.getLiveTypeIcon(Constants.LIVE_TYPE_RESTING));
// mType.setVisibility(View.GONE);
// mLiveIco.setImageResource(R.mipmap.icon_main_rest_spot);
// mLiveState.setText(R.string.rest_state);
// live_type.setVisibility(View.GONE);
// mNum.setVisibility(View.GONE);
// }
// if (bean.getIs_week() != null && bean.getIs_week().equals("1")) {
// views.setVisibility(View.GONE);
// }
// }
// }
// }
private int weekListIndex = 0;
public CountDownTimer countDownTimer;
@ -372,7 +212,7 @@ public class MainHomeLiveAdapter extends RefreshAdapter<LiveBean> {
@Override
public void onError() {
}
},null);
}, null);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -1,8 +1,6 @@
package com.yunbao.main.adapter;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@ -11,6 +9,10 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
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;
@ -22,13 +24,18 @@ import com.yunbao.live.bean.LiveBean;
import com.yunbao.main.R;
import com.yunbao.main.utils.MainIconUtil;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import kotlin.Unit;
/**
* 关注和推荐的适配器
*/
public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
private View.OnClickListener mOnClickListener;
private Context context;
private int Height;
@ -38,25 +45,7 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
Log.e("t1", h + "屏1");
this.Height = h;
mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!canClick()) {
return;
}
Object tag = v.getTag();
if (tag != null) {
int position = (int) tag;
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(mList.get(position), position);
}
}
}
};
}
@NonNull
@ -109,7 +98,38 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
live_type = (ImageView) itemView.findViewById(R.id.live_type);
views = itemView.findViewById(R.id.views);
bgs = itemView.findViewById(R.id.bgs);
itemView.setOnClickListener(mOnClickListener);
RxView.clicks(itemView)
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
.subscribe(new Observer<Unit>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Unit unit) {
if (!canClick()) {
return;
}
Object tag = itemView.getTag();
if (tag != null) {
int position = (int) tag;
if (mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(mList.get(position), position);
}
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
void setData(LiveBean bean, int position) {
@ -131,7 +151,6 @@ public class MainHomeRemFollLiveAdapter extends RefreshAdapter<LiveBean> {
}
live_info_view.setVisibility(View.GONE);
live_info_view.setVisibility(View.VISIBLE);
mRvRankingList.setVisibility(View.GONE);

View File

@ -75,9 +75,11 @@ public class SearchResultsItemFragment extends BaseFragment {
searchList.addOnScrollListener(new OnRecyclerViewScrollListener() {
@Override
public void onBottom() {
if (type>1){
page = page + 1;
setSearchKey(searchKey, type);
}
}
});
emptyLayout.setVisibility(View.GONE);
liveList = contentView.findViewById(R.id.live_list);
@ -139,9 +141,7 @@ public class SearchResultsItemFragment extends BaseFragment {
@Override
public void onSuccess(List<List<SearchModel>> data) {
if (getActivity().isFinishing()) return;
if (page > 1) {
itemAdapter.onLoadMoreData(data, searchKey);
} else {
if (data.get(0).size() == 0 && data.get(1).size() == 0) {
emptyLayout.setVisibility(View.VISIBLE);
@ -150,7 +150,7 @@ public class SearchResultsItemFragment extends BaseFragment {
itemAdapter.showData(data, type, searchKey);
searchList.setVisibility(View.VISIBLE);
}
}
}
@Override

View File

@ -103,7 +103,7 @@ public class FloatBannerView extends FrameLayout {
if (next == 0) {
index = 0;
}
Uid = String.valueOf(list.get(next).getUid());
float targetX = bannerLayout2.getX() - bannerLayout3.getX();
float targetY = bannerLayout2.getY() - bannerLayout3.getY();
bannerLayout3.setVisibility(GONE);

View File

@ -8,6 +8,7 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.jakewharton.rxbinding3.view.RxView;
import com.squareup.picasso.Picasso;
import com.yunbao.common.Constants;
import com.yunbao.common.custom.RatioRoundImageView;
@ -17,6 +18,12 @@ import com.yunbao.live.bean.LiveBean;
import com.yunbao.main.R;
import com.yunbao.main.utils.MainIconUtil;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import kotlin.Unit;
/**
* 直播页面布局
*/
@ -110,14 +117,37 @@ public class MainHomeLiveItemViewHolder extends RecyclerView.ViewHolder {
liveType.setVisibility(View.GONE);
mNum.setVisibility(View.GONE);
}
itemView.setOnClickListener(new View.OnClickListener() {
RxView.clicks(itemView)
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
.subscribe(new Observer<Unit>() {
@Override
public void onClick(View v) {
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Unit unit) {
if (listener != null) {
listener.onItemClick(bean, position);
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
// itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// }
// });
}
public interface OnItemClickListener {

View File

@ -11,6 +11,7 @@ import android.widget.ViewFlipper;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.jakewharton.rxbinding3.view.RxView;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
@ -22,6 +23,11 @@ import com.yunbao.main.R;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import kotlin.Unit;
/**
* 直播星榜数据
@ -68,7 +74,7 @@ public class MainHomeLiveWeekItemViewHolder<T> extends RecyclerView.ViewHolder {
public void onError() {
Log.e("errqs", "errl");
}
},null);
}, null);
}
@ -111,16 +117,32 @@ public class MainHomeLiveWeekItemViewHolder<T> extends RecyclerView.ViewHolder {
}
bannerHandler.removeCallbacks(mFlipRunnable);
bannerHandler.postDelayed(mFlipRunnable, delayMillis);
itemView.setOnClickListener(new View.OnClickListener() {
RxView.clicks(itemView)
.throttleFirst(2, TimeUnit.SECONDS) // 才发送 2s内第1次点击按钮的事件
.subscribe(new Observer<Unit>() {
@Override
public void onClick(View v) {
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Unit unit) {
if (listener != null) {
WeekListBean model = weekList.get(viewflipperBanner.getDisplayedChild());
bean.setUid(model.getAnchor_id());
listener.onItemClick(bean, position);
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
} catch (Exception e) {
e.printStackTrace();

View File

@ -9,6 +9,7 @@ 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.yunbao.common.Constants;
import com.yunbao.common.bean.AnchorRecommendItemModel;
@ -21,6 +22,12 @@ import com.yunbao.main.R;
import com.yunbao.main.event.JumpUserHomeEvent;
import com.yunbao.main.utils.MainIconUtil;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import kotlin.Unit;
public class SearchRecommendBodyItemViewHolder extends RecyclerView.ViewHolder {
private ImageView mCover, liveType, mLiveIco, mType, pkico, drPkIco, pkAvatar;
private RatioRoundImageView bgs;
@ -105,14 +112,32 @@ public class SearchRecommendBodyItemViewHolder extends RecyclerView.ViewHolder {
mLiveState.setText(R.string.rest_state);
liveType.setVisibility(View.GONE);
mNum.setVisibility(View.GONE);
}
mCover.setOnClickListener(new View.OnClickListener() {
}//防抖
RxView.clicks(mCover)
.throttleFirst(2, TimeUnit.SECONDS)
.subscribe(new Observer<Unit>() {
@Override
public void onClick(View v) {
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Unit unit) {
SearchModel searchModel = new SearchModel();
searchModel.setId(Long.parseLong(model.getUid()));
Bus.get().post(new JumpUserHomeEvent(searchModel));
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
}

View File

@ -18,6 +18,7 @@ import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.bean.SearchModel;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.main.R;
import com.yunbao.main.event.JumpUserHomeEvent;
import com.yunbao.main.utils.WordsTypeUtil;
@ -46,14 +47,18 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
contribute = itemView.findViewById(R.id.contribute);
nickLayout = itemView.findViewById(R.id.nick_layout);
avatarLayout = itemView.findViewById(R.id.avatar_layout);
nickLayout.setOnClickListener(jumpUserHome);
avatarLayout.setOnClickListener(jumpUserHome);
//关注主播或者用户
itemView.findViewById(R.id.focus_on).setOnClickListener(v -> {
ViewClicksAntiShake.clicksAntiShake(itemView.findViewById(R.id.focus_on), () -> {
if (callback != null) {
callback.focusOn(model);
}
});
ViewClicksAntiShake.clicksAntiShake(nickLayout, () -> {
Bus.get().post(new JumpUserHomeEvent(model));
});
ViewClicksAntiShake.clicksAntiShake(avatarLayout, () -> {
Bus.get().post(new JumpUserHomeEvent(model));
});
}
public void showData(SearchModel model, int type, String searchKey) {
@ -87,15 +92,6 @@ public class SearchResultsViewHolder extends RecyclerView.ViewHolder {
focusOn.setVisibility(TextUtils.equals(model.getIsattention(), "1") ? View.GONE : View.VISIBLE);
}
/**
* 跳转点击用户主页
*/
View.OnClickListener jumpUserHome = new View.OnClickListener() {
@Override
public void onClick(View v) {
Bus.get().post(new JumpUserHomeEvent(model));
}
};
public interface SearchResultsCallback {
void focusOn(SearchModel model);