首页推荐TAB UI修改
This commit is contained in:
@@ -627,10 +627,7 @@
|
||||
android:name=".home.activity.CollectionRoomActivity"
|
||||
android:label="收藏房间"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".home.activity.HomeMoreRoomActivity"
|
||||
android:label="房间"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.wallet.ExchangeGoldActivity"
|
||||
android:label="兑换钻石"
|
||||
|
@@ -21,6 +21,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.idlefish.flutterboost.FlutterBoost;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
@@ -58,6 +59,7 @@ import com.yizhuan.erban.community.im.WorldDynamicShareViewHolder;
|
||||
import com.yizhuan.erban.community.publish.view.PublishActivity;
|
||||
import com.yizhuan.erban.community.square.SquareFragment;
|
||||
import com.yizhuan.erban.family.view.activity.FamilyHomeActivity;
|
||||
import com.yizhuan.erban.home.HomeViewModel;
|
||||
import com.yizhuan.erban.home.dialog.ProtocolUpdateDialog;
|
||||
import com.yizhuan.erban.flutter.RouterConstants;
|
||||
import com.yizhuan.erban.home.fragment.ContactsListFragment;
|
||||
@@ -232,7 +234,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
* 管理限制进房
|
||||
*/
|
||||
private LimitEnterRoomHelper limitEnterRoomHelper;
|
||||
|
||||
private HomeViewModel homeViewModel;
|
||||
@Nullable
|
||||
private Fragment tempFragment = null;
|
||||
private final SparseArray<Fragment> fragmentArray = new SparseArray<>();
|
||||
@@ -278,7 +280,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
homeViewModel = new ViewModelProvider(this).get(HomeViewModel.class);
|
||||
NimMiddleActivity.firstEnter = false;
|
||||
if (savedInstanceState != null) {
|
||||
mCurrentMainPosition = savedInstanceState.getInt(Constants.KEY_MAIN_POSITION);
|
||||
@@ -859,7 +861,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
checkProtocolUpdate();
|
||||
|
||||
// 互动消息未读数量
|
||||
HomeModel.get().getUnreadCount(AuthModel.get().getCurrentUid())
|
||||
HomeModel.INSTANCE.getUnreadCount(AuthModel.get().getCurrentUid())
|
||||
.compose(bindUntilEvent(ActivityEvent.DESTROY))
|
||||
.subscribe((integer, throwable) -> {
|
||||
if (integer != null) {
|
||||
|
@@ -1505,7 +1505,7 @@ public class HomePartyRoomFragment extends BaseMvpFragment<IHomePartyView, HomeP
|
||||
int startTime = Integer.parseInt(openTime.substring(0, openTime.indexOf("-")).replace(":", ""));
|
||||
int endTime = Integer.parseInt(openTime.substring(openTime.indexOf("-") + 1).replace(":", ""));
|
||||
|
||||
if (getFragmentManager() != null && TimeUtils.getTimeLimit(startTime, endTime)) {
|
||||
if (getFragmentManager() != null && startTime != endTime && TimeUtils.getTimeLimit(startTime, endTime)) {
|
||||
ChooseTreasureBoxDialogFragment chooseTreasureBoxDialogFragment = new ChooseTreasureBoxDialogFragment(GoldBoxHelper.getBoxOpenTime());
|
||||
chooseTreasureBoxDialogFragment.setOnTreasureBoxChooseListener(type -> {
|
||||
if (type == 0) {// 幸运许愿池(默认)
|
||||
|
@@ -4,6 +4,6 @@ package com.yizhuan.erban.base;
|
||||
* Created by huangmeng1 on 2018/5/7.
|
||||
*/
|
||||
|
||||
public class BaseViewModel {
|
||||
public class BaseVM {
|
||||
|
||||
}
|
30
app/src/main/java/com/yizhuan/erban/base/BaseViewModel.kt
Normal file
30
app/src/main/java/com/yizhuan/erban/base/BaseViewModel.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.yizhuan.erban.base
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
open class BaseViewModel : ViewModel() {
|
||||
|
||||
fun safeLaunch(
|
||||
onError: (e: Throwable) -> Unit = { it.message.toast() },
|
||||
onComplete: (() -> Unit)? = null,
|
||||
block: suspend CoroutineScope.() -> Unit
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
block()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
onError(e)
|
||||
} finally {
|
||||
onComplete?.invoke()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
36
app/src/main/java/com/yizhuan/erban/home/HomeViewModel.kt
Normal file
36
app/src/main/java/com/yizhuan/erban/home/HomeViewModel.kt
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.yizhuan.erban.home
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.xchat_android_core.bean.response.ListResult
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoom
|
||||
import com.yizhuan.xchat_android_core.home.model.HomeModel
|
||||
|
||||
class HomeViewModel : BaseViewModel() {
|
||||
|
||||
private val _bannerLiveData = MutableLiveData<List<BannerInfo>>()
|
||||
val bannerLiveData: LiveData<List<BannerInfo>> = _bannerLiveData
|
||||
|
||||
private val _hotRoomLiveData = MutableLiveData<ListResult<HomeRoom>>()
|
||||
val hotRoomLiveData: LiveData<ListResult<HomeRoom>> = _hotRoomLiveData
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch {
|
||||
_bannerLiveData.value = HomeModel.getHomeBanner("9")
|
||||
}
|
||||
}
|
||||
|
||||
fun getHotRoom(pageNum: Int, pageSize: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_hotRoomLiveData.value = ListResult.failed(pageNum)
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHotRoom(pageNum, pageSize)
|
||||
_hotRoomLiveData.value = ListResult.success(result, pageNum)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
@@ -1,209 +0,0 @@
|
||||
package com.yizhuan.erban.home.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.yizhuan.erban.avroom.ktv.KtvMusicManager;
|
||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
import com.yizhuan.erban.home.adapter.HomeConcernsAdapter;
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter;
|
||||
import com.yizhuan.erban.home.fragment.HomeTabMapFragment;
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper;
|
||||
import com.yizhuan.erban.home.presenter.MainFragmentPresenter;
|
||||
import com.yizhuan.erban.home.view.IMainFragmentView;
|
||||
import com.yizhuan.erban.service.DaemonService;
|
||||
import com.yizhuan.erban.ui.widget.OnPageSelectedListener;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.VerticalDecoration;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeConcernsInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.TagListInfo;
|
||||
import com.yizhuan.xchat_android_core.manager.AudioEngineManager;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.SizeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@CreatePresenter(MainFragmentPresenter.class)
|
||||
public class HomeMoreRoomActivity extends BaseMvpActivity<IMainFragmentView, MainFragmentPresenter> implements IMainFragmentView, MainMagicIndicatorAdapter.OnItemSelectListener {
|
||||
|
||||
@BindView(R.id.magic_indicator)
|
||||
MagicIndicator magicIndicator;
|
||||
@BindView(R.id.view_pager)
|
||||
ViewPager viewPager;
|
||||
@BindView(R.id.rv_follow_room)
|
||||
RecyclerView rvFollowRoom;
|
||||
private HomeConcernsAdapter mFollowRoomsAdapter;
|
||||
private List<Fragment> mFragments;
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent intent = new Intent(context, HomeMoreRoomActivity.class);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_home_more_room);
|
||||
ButterKnife.bind(this);
|
||||
initWhiteTitleBar("房间");
|
||||
initRoomTitleTab();
|
||||
initRoomConcern();
|
||||
}
|
||||
|
||||
private void initRoomTitleTab() {
|
||||
getMvpPresenter().getHomeTag();
|
||||
}
|
||||
|
||||
private void initRoomConcern() {
|
||||
mFollowRoomsAdapter = new HomeConcernsAdapter(null, context);
|
||||
rvFollowRoom.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
rvFollowRoom.addItemDecoration(new VerticalDecoration(SizeUtils.dp2px(this, 10), false, true));
|
||||
mFollowRoomsAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_HOME_INTO_DBRUK_CLICK, "点击顶部我的房间/关注进入房间");
|
||||
if (position == 0) {
|
||||
OpenRoomHelper.openRoom(this);
|
||||
return;
|
||||
}
|
||||
HomeConcernsInfo homeConcernsInfo = mFollowRoomsAdapter.getItem(position);
|
||||
if (homeConcernsInfo != null) {
|
||||
AVRoomActivity.startForFromType(this, homeConcernsInfo.getRoomUid(),
|
||||
AVRoomActivity.FROM_TYPE_USER, homeConcernsInfo.getName(), String.valueOf(homeConcernsInfo.getFollowedUid()));
|
||||
}
|
||||
});
|
||||
rvFollowRoom.setAdapter(mFollowRoomsAdapter);
|
||||
getMvpPresenter().getHomeConcerns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelect(int position, TextView view) {
|
||||
|
||||
if (mFragments == null || mFragments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Fragment fragment = mFragments.get(position);
|
||||
if (fragment == null) {
|
||||
return;
|
||||
}
|
||||
viewPager.setCurrentItem(position);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestOpenRoomResult(int openRoomFailType, Object... arg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showByMarketCheckingStatus(List<TagListInfo> tagListInfoList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFollowRoomsSuccess(List<HomeConcernsInfo> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
rvFollowRoom.setVisibility(View.VISIBLE);
|
||||
mFollowRoomsAdapter.setNewData(list);
|
||||
} else {
|
||||
rvFollowRoom.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFollowRoomFail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRoom(RoomInfo roomInfo) {
|
||||
//ktv退出的时候需要用到
|
||||
if (AudioEngineManager.get().isOpenKtv() && roomInfo != null) {
|
||||
KtvMusicManager.INSTANCE.deleteUserAllChooseMusic(roomInfo.getUid()).subscribe();
|
||||
AudioEngineManager.get().closeKtvModel();
|
||||
}
|
||||
DaemonService.stop(HomeMoreRoomActivity.this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onGetHomeBannerSuccess(List<BannerInfo> bannerInfos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetHomeTagSuccess(List<HomeTagInfo> info) {
|
||||
List<CharSequence> mTabInfoList = new ArrayList<>();
|
||||
if (!ListUtils.isListEmpty(mFragments)) {
|
||||
mFragments.clear();
|
||||
}
|
||||
mFragments = new ArrayList<>();
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
//过滤对象是空和没有标签名同时也没有子标签的情况
|
||||
CharSequence title;
|
||||
int tabId;
|
||||
Fragment fragment;
|
||||
String name = info.get(i).getName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
title = name;
|
||||
tabId = info.get(i).getId();
|
||||
fragment = HomeTabMapFragment.newInstance(tabId);
|
||||
mFragments.add(fragment);
|
||||
mTabInfoList.add(title);
|
||||
}
|
||||
|
||||
CommonNavigator commonNavigator = new CommonNavigator(HomeMoreRoomActivity.this);
|
||||
MainMagicIndicatorAdapter magicIndicatorAdapter = new MainMagicIndicatorAdapter(HomeMoreRoomActivity.this, mTabInfoList, true);
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this);
|
||||
commonNavigator.setTitleWrapContent(true);
|
||||
commonNavigator.setAdapter(magicIndicatorAdapter);
|
||||
magicIndicator.setNavigator(commonNavigator);
|
||||
commonNavigator.getTitleContainer().setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
|
||||
viewPager.setOffscreenPageLimit(5);
|
||||
viewPager.setAdapter(new RoomContributeListAdapter(getSupportFragmentManager(), mFragments));
|
||||
viewPager.addOnPageChangeListener(new OnPageSelectedListener() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
||||
}
|
||||
});
|
||||
ViewPagerHelper.bind(magicIndicator, viewPager);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStatusBar() {
|
||||
super.setStatusBar();
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.yizhuan.erban.home.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoom
|
||||
|
||||
|
||||
class HotRoomAdapter : BaseQuickAdapter<HomeRoom, BaseViewHolder>(R.layout.item_room_common) {
|
||||
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoom) {
|
||||
helper.apply {
|
||||
getView<ImageView>(R.id.iv_room_image).load(item.avatar, 8f)
|
||||
setText(R.id.tv_online_number, "${item.onlineNum}人热聊中")
|
||||
setText(R.id.tv_room_title, item.title)
|
||||
setText(R.id.tv_room_tag, item.roomTag)
|
||||
itemView.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.uid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,14 +1,12 @@
|
||||
package com.yizhuan.erban.home.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.ui.widget.XRecyclerView.ScaleTransitionPagerTitleView;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
@@ -39,10 +37,10 @@ public class MainMagicIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context,R.color.text_secondary_4f516a));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(Color.WHITE);
|
||||
scaleTransitionPagerTitleView.setMinScale(0.8f);
|
||||
scaleTransitionPagerTitleView.setTextSize(16);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context,R.color.color_444444));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context,R.color.color_333333));
|
||||
scaleTransitionPagerTitleView.setMinScale(0.83f);
|
||||
scaleTransitionPagerTitleView.setTextSize(24);
|
||||
int padding = UIUtil.dip2px(context, 5);
|
||||
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i));
|
||||
|
@@ -1,121 +0,0 @@
|
||||
package com.yizhuan.erban.home.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.base.BaseFragment;
|
||||
import com.yizhuan.erban.common.EmptyViewHelper;
|
||||
import com.yizhuan.erban.home.adapter.HomeDynamicAdapter;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeDynamicInfo;
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent;
|
||||
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
|
||||
import com.yizhuan.xchat_android_core.user.event.LoadLoginUserInfoEvent;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2020/1/7
|
||||
*/
|
||||
public class HomeDynamicFragment extends BaseFragment {
|
||||
|
||||
Unbinder unbinder;
|
||||
@BindView(R.id.recycler_view)
|
||||
RecyclerView recyclerView;
|
||||
|
||||
private HomeDynamicAdapter dynamicAdapter;
|
||||
private final List<HomeDynamicInfo> dynamicList = new ArrayList<>();
|
||||
|
||||
public static HomeDynamicFragment newInstance() {
|
||||
HomeDynamicFragment fragment = new HomeDynamicFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
mView = inflater.inflate(R.layout.fragment_home_dynamic, container, false);
|
||||
unbinder = ButterKnife.bind(this, mView);
|
||||
EventBus.getDefault().register(this);
|
||||
return mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
recyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NotNull Rect outRect, @NotNull View view, @NotNull RecyclerView parent, @NotNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int bottom = ScreenUtil.dip2px(10);
|
||||
int top = ScreenUtil.dip2px(5);
|
||||
outRect.set(0, top, 0, bottom);
|
||||
}
|
||||
});
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
dynamicAdapter = new HomeDynamicAdapter(getActivity());
|
||||
recyclerView.setAdapter(dynamicAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void getHomeDynamic() {
|
||||
GameHomeModel.get().getHomeDynamic().subscribe((serviceResult, throwable) -> {
|
||||
if (throwable != null) {
|
||||
dynamicAdapter.setEmptyView(EmptyViewHelper.createEmptyView(getContext(),"暂无数据"));
|
||||
} else {
|
||||
dynamicList.clear();
|
||||
dynamicList.addAll(serviceResult);
|
||||
if (ListUtils.isListEmpty(dynamicList)) {
|
||||
dynamicAdapter.setEmptyView(EmptyViewHelper.createEmptyView(getContext(),"暂无数据"));
|
||||
} else {
|
||||
dynamicAdapter.setNewData(dynamicList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
|
||||
getHomeDynamic();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoadLoginUserInfoEvent(RefreshHomeDataEvent event) {
|
||||
getHomeDynamic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroyView();
|
||||
unbinder.unbind();
|
||||
}
|
||||
|
||||
}
|
@@ -1,682 +0,0 @@
|
||||
package com.yizhuan.erban.home.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.adapter.RoomContributeListAdapter;
|
||||
import com.yizhuan.erban.base.BaseMvpFragment;
|
||||
import com.yizhuan.erban.databinding.FragmentGameHomeBinding;
|
||||
import com.yizhuan.erban.home.activity.HomeMoreRoomActivity;
|
||||
import com.yizhuan.erban.home.adapter.BannerAdapter;
|
||||
import com.yizhuan.erban.home.adapter.HomeAddFriendsAdapter;
|
||||
import com.yizhuan.erban.home.adapter.HomeConcernsAdapter;
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter;
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper;
|
||||
import com.yizhuan.erban.home.presenter.MainFragmentPresenter;
|
||||
import com.yizhuan.erban.home.view.IMainFragmentView;
|
||||
import com.yizhuan.erban.radish.signin.SignInActivity;
|
||||
import com.yizhuan.erban.ui.search.SearchActivity;
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||||
import com.yizhuan.erban.ui.widget.OnPageSelectedListener;
|
||||
import com.yizhuan.erban.ui.widget.higuide.TuTuGuideHelper;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.VerticalDecoration;
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.Util;
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeConcernsInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomePlayInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.TagListInfo;
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent;
|
||||
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.market_verify.MarketVerifyModel;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_core.user.event.LoadLoginUserInfoEvent;
|
||||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
||||
import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.TextUtils;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SizeUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* 音游首页
|
||||
*/
|
||||
@CreatePresenter(MainFragmentPresenter.class)
|
||||
public class HomeFragment extends BaseMvpFragment<IMainFragmentView, MainFragmentPresenter>
|
||||
implements IMainFragmentView, View.OnClickListener, MainMagicIndicatorAdapter.OnItemSelectListener, MainMagicIndicatorAdapter.OnBottomItemSelectListener {
|
||||
public static final String TAG = "GameHomeFragment";
|
||||
/**
|
||||
* 动态
|
||||
*/
|
||||
public static final int TAB_TYPE_DYNAMIC = 0;
|
||||
/**
|
||||
* 聊天交友
|
||||
*/
|
||||
public static final int TAB_TYPE_PLAY = 1;
|
||||
/**
|
||||
* 首页Banner
|
||||
*/
|
||||
private static final String BANNER_TYPE = "1";
|
||||
@NonNull
|
||||
private final List<Fragment> mFragments = new ArrayList<>();
|
||||
@NonNull
|
||||
private final List<CharSequence> mTabInfoList = new ArrayList<>();
|
||||
private FragmentGameHomeBinding mBinding;
|
||||
private List<Fragment> mFragmentsBottom;
|
||||
private boolean needAutoScroll = true;
|
||||
private HomeAddFriendsAdapter addFriendsAdapter;
|
||||
private BannerAdapter bannerAdapter;
|
||||
@Nullable
|
||||
private Disposable addFriendsDisposable;
|
||||
private boolean isLoaded;
|
||||
private HomeConcernsAdapter mFollowRoomsAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_open_room:
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.game_homepage_createroom_click, "创建房间按钮");
|
||||
OpenRoomHelper.openRoom(getBaseActivity());
|
||||
break;
|
||||
|
||||
case R.id.tv_search_room:
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_SEARCH, "进入搜索页");
|
||||
SearchActivity.start(getActivity());
|
||||
break;
|
||||
|
||||
case R.id.iv_to_sign_in:
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_GAME_HOMEPAGE_SIGN_CLICK,
|
||||
"签到-首页");
|
||||
SignInActivity.start(mContext);
|
||||
SharedPreferenceUtils.put("sign_entrance_" + AuthModel.get().getCurrentUid(), 1);
|
||||
break;
|
||||
|
||||
//首页榜单
|
||||
case R.id.iv_ranking:
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_HOME_RANK_CLICK, "首页_榜单");
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking());
|
||||
break;
|
||||
|
||||
case R.id.tv_room_more:
|
||||
HomeMoreRoomActivity.start(mContext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_game_home;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
mBinding.setClick(this);
|
||||
mBinding.setOpenVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
mBinding.rollView.setVisibility(View.GONE);
|
||||
initGuide();
|
||||
initRefreshView();
|
||||
initTitleTab();
|
||||
initRoomConcern();
|
||||
if (AuthModel.get().getCurrentUid() != 0) {
|
||||
tryLoadData(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void initRefreshView() {
|
||||
mBinding.refreshLayout.setOnRefreshListener(refreshLayout -> {
|
||||
mBinding.refreshLayout.finishRefresh();
|
||||
tryLoadData(true);
|
||||
getHomeConcern();
|
||||
EventBus.getDefault().post(new RefreshHomeDataEvent());
|
||||
});
|
||||
mBinding.refreshLayout.setEnableOverScrollBounce(false);
|
||||
mBinding.refreshHeader.getLastUpdateText().setTextColor(Color.WHITE);
|
||||
mBinding.refreshHeader.getTitleText().setTextColor(Color.WHITE);
|
||||
mBinding.refreshHeader.setBackgroundResource(R.drawable.bg_shape_home_top);
|
||||
ProgressDrawable progressDrawable = new ProgressDrawable();
|
||||
progressDrawable.setColor(Color.WHITE);
|
||||
mBinding.refreshHeader.getProgressView().setImageDrawable(progressDrawable);
|
||||
}
|
||||
|
||||
//尝试加载不需要登录就可以加载的数据
|
||||
private void tryLoadData(boolean refresh) {
|
||||
if (!isLoaded || refresh) {
|
||||
isLoaded = true;
|
||||
initRoomTitleTab();
|
||||
initBanner();
|
||||
loadHomPlay();
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
if (userInfo != null && !TextUtils.isEmptyText(userInfo.getNick())) {
|
||||
getHomeConcern();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void scrollToView() {
|
||||
mBinding.appBarLayout.addOnOffsetChangedListener((appBarLayout, i) -> {
|
||||
mBinding.refreshLayout.setEnabled(i >= 0);
|
||||
});
|
||||
mBinding.magicIndicatorBottom.onPageSelected(InitialModel.get().getDefaultHomeTab());
|
||||
mBinding.viewPagerBottom.setCurrentItem(InitialModel.get().getDefaultHomeTab());
|
||||
if (needAutoScroll) {
|
||||
needAutoScroll = false;
|
||||
mBinding.coordinatorLayout.post(() -> {
|
||||
int distance = mBinding.rvFollowRoom.getMeasuredHeight();
|
||||
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) mBinding.appBarLayout.getLayoutParams()).getBehavior();
|
||||
if (behavior != null)
|
||||
behavior.onNestedPreScroll(mBinding.coordinatorLayout, mBinding.appBarLayout, mBinding.rvFollowRoom, 0, distance, new int[]{0, 0}, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐房间TAG
|
||||
*/
|
||||
private void initRoomTitleTab() {
|
||||
getMvpPresenter().getHomeTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化动态和聊天交友tab
|
||||
*/
|
||||
private void initTitleTab() {
|
||||
List<Integer> fragmentPos = new ArrayList<>();
|
||||
fragmentPos.add(TAB_TYPE_PLAY);
|
||||
fragmentPos.add(TAB_TYPE_DYNAMIC);
|
||||
List<String> tagList = new ArrayList<>();
|
||||
mFragmentsBottom = new ArrayList<>();
|
||||
|
||||
tagList.add(getResources().getString(R.string.home_tab_caht));
|
||||
tagList.add(getResources().getString(R.string.home_tab_dynamic));
|
||||
|
||||
mFragmentsBottom.add(HomePlayFragment.newInstance());
|
||||
mFragmentsBottom.add(HomeDynamicFragment.newInstance());
|
||||
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getContext());
|
||||
commonNavigator.setTitleWrapContent(true);
|
||||
MainMagicIndicatorAdapter magicIndicatorAdapter = new MainMagicIndicatorAdapter(getContext(), tagList, false);
|
||||
magicIndicatorAdapter.setOnBottomItemSelectListener(this);
|
||||
commonNavigator.setAdapter(magicIndicatorAdapter);
|
||||
mBinding.magicIndicatorBottom.setNavigator(commonNavigator);
|
||||
|
||||
commonNavigator.getTitleContainer().setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
|
||||
mBinding.viewPagerBottom.setOffscreenPageLimit(5);
|
||||
mBinding.viewPagerBottom.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), mFragmentsBottom));
|
||||
mBinding.viewPagerBottom.addOnPageChangeListener(new OnPageSelectedListener() {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
}
|
||||
});
|
||||
|
||||
ViewPagerHelper.bind(mBinding.magicIndicatorBottom, mBinding.viewPagerBottom);
|
||||
|
||||
scrollToView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestOpenRoomResult(int openRoomFailType, Object... arg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showByMarketCheckingStatus(List<TagListInfo> tagListInfoList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFollowRoomsSuccess(List<HomeConcernsInfo> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
mBinding.rvFollowRoom.setVisibility(View.VISIBLE);
|
||||
mFollowRoomsAdapter.setNewData(list);
|
||||
} else {
|
||||
mBinding.rvFollowRoom.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFollowRoomFail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRoom(RoomInfo roomInfo) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 顶部关注房间
|
||||
*/
|
||||
private void initRoomConcern() {
|
||||
mFollowRoomsAdapter = new HomeConcernsAdapter(null, mContext);
|
||||
mBinding.rvFollowRoom.setHasFixedSize(true);
|
||||
mBinding.rvFollowRoom.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
mBinding.rvFollowRoom.addItemDecoration(new VerticalDecoration(SizeUtils.dp2px(mContext, 10), false, true));
|
||||
mFollowRoomsAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_HOME_INTO_DBRUK_CLICK, "点击顶部我的房间/关注进入房间");
|
||||
if (position == 0) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_HOME_INTO_MY_ROOM_CLICK, "首页_进入我的房间");
|
||||
OpenRoomHelper.openRoom(getBaseActivity());
|
||||
return;
|
||||
}
|
||||
HomeConcernsInfo homeConcernsInfo = mFollowRoomsAdapter.getItem(position);
|
||||
if (homeConcernsInfo != null) {
|
||||
AVRoomActivity.startForFromType(mContext, homeConcernsInfo.getRoomUid(),
|
||||
AVRoomActivity.FROM_TYPE_USER, homeConcernsInfo.getName(), String.valueOf(homeConcernsInfo.getFollowedUid()));
|
||||
}
|
||||
});
|
||||
mBinding.rvFollowRoom.setAdapter(mFollowRoomsAdapter);
|
||||
}
|
||||
|
||||
private void getHomeConcern() {
|
||||
getMvpPresenter().getHomeConcerns();
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐房间
|
||||
*
|
||||
* @param position
|
||||
* @param view
|
||||
*/
|
||||
@Override
|
||||
public void onItemSelect(int position, TextView view) {
|
||||
if (mFragments == null || mFragments.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Fragment fragment = mFragments.get(position);
|
||||
if (fragment == null) {
|
||||
return;
|
||||
}
|
||||
mBinding.viewPager.setCurrentItem(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部动态聊天交友
|
||||
*
|
||||
* @param position
|
||||
* @param view
|
||||
*/
|
||||
@Override
|
||||
public void onBottomItemSelect(int position, TextView view) {
|
||||
if (mFragmentsBottom == null || mFragmentsBottom.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Fragment fragment = mFragmentsBottom.get(position);
|
||||
if (fragment == null) {
|
||||
return;
|
||||
}
|
||||
mBinding.viewPagerBottom.setCurrentItem(position);
|
||||
if (position == 1) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_HOME_SCREEN_DONG_TAI_CLICK, "首页_聊天交友切换到动态");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetHomeBannerSuccess(List<BannerInfo> bannerInfos) {
|
||||
setBanner(bannerInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetHomeTagSuccess(List<HomeTagInfo> info) {
|
||||
boolean changed = false;
|
||||
|
||||
List<CharSequence> oldTabInfoList = new ArrayList<>(mTabInfoList);
|
||||
|
||||
for (HomeTagInfo tagInfo : info) {
|
||||
if (!oldTabInfoList.contains(tagInfo.getName())) {
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//只有HomeTagInfo发生改变才刷新数据,否则刷新当前可见的那个Fragment
|
||||
if (changed) {
|
||||
LogUtils.e(changed + ":oldTabInfoList");
|
||||
mTabInfoList.clear();
|
||||
mFragments.clear();
|
||||
for (int i = 0; i < info.size(); i++) {
|
||||
//过滤对象是空和没有标签名同时也没有子标签的情况
|
||||
CharSequence title;
|
||||
int tabId;
|
||||
Fragment fragment;
|
||||
String name = info.get(i).getName();
|
||||
if (name != null) {
|
||||
name = name.trim();
|
||||
}
|
||||
title = name;
|
||||
mTabInfoList.add(title);
|
||||
tabId = info.get(i).getId();
|
||||
fragment = HomeTabHomeFragment.newInstance(tabId);
|
||||
mFragments.add(fragment);
|
||||
}
|
||||
CommonNavigator commonNavigator = new CommonNavigator(getContext());
|
||||
commonNavigator.setTitleWrapContent(true);
|
||||
MainMagicIndicatorAdapter magicIndicatorAdapter = new MainMagicIndicatorAdapter(getContext(), mTabInfoList, false);
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this);
|
||||
commonNavigator.setAdapter(magicIndicatorAdapter);
|
||||
mBinding.magicIndicator.setNavigator(commonNavigator);
|
||||
commonNavigator.getTitleContainer().setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
|
||||
mBinding.viewPager.setOffscreenPageLimit(5);
|
||||
mBinding.viewPager.setAdapter(new RoomContributeListAdapter(getChildFragmentManager(), mFragments));
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager);
|
||||
} else {
|
||||
for (Fragment fragment : mFragments) {
|
||||
if (fragment instanceof LazyLoadFragment) {
|
||||
((LazyLoadFragment) fragment).tryLoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息更新
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void loadLoginUserInfoEvent(LoginUserInfoUpdateEvent event) {
|
||||
refreshData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息更新
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void loadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
|
||||
refreshData();
|
||||
}
|
||||
|
||||
private void refreshData() {
|
||||
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
|
||||
assert userInfo != null;
|
||||
// 超管不展示开房按钮
|
||||
mBinding.setOpenVisible(!(userInfo.getPlatformRole() == 1));
|
||||
tryLoadData(false);
|
||||
if (!TextUtils.isEmptyText(userInfo.getNick())) {
|
||||
getHomeConcern();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initBanner() {
|
||||
getMvpPresenter().getHomeBanner(BANNER_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否要显示首页引导
|
||||
*/
|
||||
private void initGuide() {
|
||||
mView.postDelayed(() -> {
|
||||
if (TuTuGuideHelper.isNeedHiGuide(TuTuGuideHelper.KEY_GUIDE_MAIN_HOME)) {
|
||||
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
View rootView = activity.findViewById(android.R.id.content);
|
||||
if (!(rootView instanceof FrameLayout)) {
|
||||
return;
|
||||
}
|
||||
TuTuGuideHelper.setNoNeedHiGuide(TuTuGuideHelper.KEY_GUIDE_MAIN_HOME);
|
||||
FrameLayout contentView = (FrameLayout) rootView;
|
||||
View view = getLayoutInflater().inflate(R.layout.layout_home_guide, contentView, false);
|
||||
View skipView = view.findViewById(R.id.tv_skip);
|
||||
View logoIconView = view.findViewById(R.id.iv_logo_icon);
|
||||
ImageView bgView = view.findViewById(R.id.iv_bg);
|
||||
GlideApp.with(activity)
|
||||
.load(R.drawable.ic_guide_home_1)
|
||||
.apply(RequestOptions.bitmapTransform(new BitmapTransformation() {
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
Bitmap bitmap;
|
||||
bitmap = Bitmap.createBitmap(toTransform, 0, 0, outWidth, outHeight);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
}))
|
||||
.into(bgView);
|
||||
contentView.addView(view, -1, -1);
|
||||
skipView.setOnClickListener(v -> contentView.removeView(view));
|
||||
|
||||
view.setOnClickListener(v -> {
|
||||
if (v.getTag() == null) {
|
||||
GlideApp.with(activity)
|
||||
.load(R.drawable.ic_guide_home_2)
|
||||
.apply(RequestOptions.bitmapTransform(new BitmapTransformation() {
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
Bitmap bitmap;
|
||||
bitmap = Bitmap.createBitmap(toTransform, 0, 0, outWidth, outHeight);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
}))
|
||||
.into(bgView);
|
||||
|
||||
skipView.setVisibility(View.GONE);
|
||||
logoIconView.setVisibility(View.VISIBLE);
|
||||
v.setTag(1);
|
||||
|
||||
} else {
|
||||
contentView.removeView(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
private void setBanner(List<BannerInfo> bannerList) {
|
||||
//审核中状态,去掉跳转房间banner
|
||||
if (MarketVerifyModel.get().isMarketChecking()) {
|
||||
Iterator<BannerInfo> iterator = bannerList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BannerInfo bannerInfo = iterator.next();
|
||||
if (bannerInfo.getSkipType() == 2) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ListUtils.isListEmpty(bannerList)) {
|
||||
mBinding.rollView.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
mBinding.rollView.setVisibility(View.VISIBLE);
|
||||
if (bannerAdapter == null) {
|
||||
mBinding.rollView.setHintView(new ColorPointHintView(mContext, Color.WHITE, mContext.getResources().getColor(R.color.color_66FFFFFF)) {
|
||||
@Override
|
||||
public Drawable makeFocusDrawable() {
|
||||
GradientDrawable dotFocus = new GradientDrawable();
|
||||
dotFocus.setColor(Color.WHITE);
|
||||
dotFocus.setCornerRadius(Util.dip2px(getContext(), 2));
|
||||
dotFocus.setSize(Util.dip2px(getContext(), 9), Util.dip2px(getContext(), 4));
|
||||
return dotFocus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable makeNormalDrawable() {
|
||||
GradientDrawable dotNormal = new GradientDrawable();
|
||||
dotNormal.setColor(mContext.getResources().getColor(R.color.color_66FFFFFF));
|
||||
dotNormal.setCornerRadius(Util.dip2px(getContext(), 2));
|
||||
dotNormal.setSize(Util.dip2px(getContext(), 4), Util.dip2px(getContext(), 4));
|
||||
return dotNormal;
|
||||
}
|
||||
});
|
||||
|
||||
bannerAdapter = new BannerAdapter(bannerList, mContext);
|
||||
bannerAdapter.setRoundingRadius(ScreenUtil.dip2px(12));
|
||||
bannerAdapter.setHomeGame(true);
|
||||
mBinding.rollView.setAdapter(bannerAdapter);
|
||||
mBinding.rollView.setPlayDelay(3000);
|
||||
//设置透明度
|
||||
mBinding.rollView.setAnimationDurtion(500);
|
||||
}
|
||||
bannerAdapter.setBannerInfoList(bannerList);
|
||||
bannerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void loadHomPlay() {
|
||||
if (addFriendsAdapter == null) {
|
||||
mBinding.rvAddFriends.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
mBinding.rvAddFriends.setNestedScrollingEnabled(false);
|
||||
mBinding.rvAddFriends.setFocusable(false);
|
||||
addFriendsAdapter = new HomeAddFriendsAdapter();
|
||||
mBinding.rvAddFriends.setAdapter(addFriendsAdapter);
|
||||
}
|
||||
GameHomeModel.get().getHomePlay()
|
||||
.doOnError(throwable -> mBinding.tvAddFriends.setVisibility(View.GONE))
|
||||
.subscribe(homePlayList -> {
|
||||
if (ListUtils.isListEmpty(homePlayList)) {
|
||||
mBinding.tvAddFriends.setVisibility(View.GONE);
|
||||
mBinding.rvAddFriends.setVisibility(View.GONE);
|
||||
addFriendsAdapter.setNewData(null);
|
||||
} else {
|
||||
loopHomePlay(homePlayList, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void loopHomePlay(final List<HomePlayInfo> homePlayList, boolean refresh) {
|
||||
|
||||
if (addFriendsDisposable != null && !addFriendsDisposable.isDisposed()) {
|
||||
addFriendsDisposable.dispose();
|
||||
}
|
||||
mBinding.tvAddFriends.setVisibility(View.VISIBLE);
|
||||
mBinding.rvAddFriends.setVisibility(View.VISIBLE);
|
||||
if (refresh) {
|
||||
//两个以内直接setNewData并返回 不循环
|
||||
if (homePlayList.size() <= 2) {
|
||||
addFriendsAdapter.setNewData(homePlayList);
|
||||
return;
|
||||
} else {
|
||||
addFriendsAdapter.setNewData(new ArrayList<>(homePlayList.subList(0, 2)));
|
||||
}
|
||||
}
|
||||
|
||||
Observable<HomePlayInfo> listObservable = Observable.fromIterable(refresh ? new ArrayList<>(homePlayList.subList(2, homePlayList.size())) : homePlayList);
|
||||
|
||||
Observable<Long> timerObservable = Observable.interval(3000, TimeUnit.MILLISECONDS);
|
||||
|
||||
Observable.zip(listObservable, timerObservable, (homePlayInfo, aLong) -> homePlayInfo)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.filter(homePlayInfo -> isResumed() && isVisible())//不可见的时候停止循环,不然重新回来所有动画一起执行,模拟器可能ANR...
|
||||
.subscribe(new Observer<HomePlayInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
addFriendsDisposable = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull HomePlayInfo homePlayInfo) {
|
||||
addFriendsAdapter.remove(0);
|
||||
addFriendsAdapter.addData(homePlayInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
loopHomePlay(homePlayList, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,90 @@
|
||||
package com.yizhuan.erban.home.fragment
|
||||
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.RoomContributeListAdapter
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.databinding.FragmentHomeBinding
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.ui.search.SearchActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.OnPageSelectedListener
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 音游首页
|
||||
*/
|
||||
class HomeFragment : BaseFragment(), View.OnClickListener,
|
||||
MainMagicIndicatorAdapter.OnBottomItemSelectListener {
|
||||
private lateinit var mBinding: FragmentHomeBinding
|
||||
override fun onClick(v: View) {
|
||||
when (v.id) {
|
||||
R.id.tv_search_room -> {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_SEARCH, "进入搜索页")
|
||||
SearchActivity.start(activity)
|
||||
}
|
||||
|
||||
R.id.iv_ranking -> {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.Event.EVENT_HOME_RANK_CLICK, "首页_榜单")
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_home
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
mBinding.click = this
|
||||
}
|
||||
|
||||
override fun initiate() {
|
||||
initTitleTab()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化推荐和派对tab
|
||||
*/
|
||||
private fun initTitleTab() {
|
||||
val fragmentPos: MutableList<Fragment> = ArrayList()
|
||||
val tagList: MutableList<String> = ArrayList()
|
||||
tagList.add("推荐")
|
||||
tagList.add("派对")
|
||||
fragmentPos.add(RecommendFragment.newInstance())
|
||||
fragmentPos.add(PartyFragment.newInstance())
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = MainMagicIndicatorAdapter(context, tagList, false)
|
||||
magicIndicatorAdapter.setOnBottomItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
mBinding.viewPager.offscreenPageLimit = 5
|
||||
mBinding.viewPager.adapter =
|
||||
RoomContributeListAdapter(childFragmentManager, fragmentPos)
|
||||
mBinding.viewPager.addOnPageChangeListener(object : OnPageSelectedListener() {
|
||||
override fun onPageSelected(position: Int) {}
|
||||
})
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
}
|
||||
|
||||
override fun onBottomItemSelect(position: Int, view: TextView?) {
|
||||
mBinding.viewPager.currentItem = position
|
||||
}
|
||||
|
||||
}
|
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.base.BaseFragment;
|
||||
import com.yizhuan.erban.common.NoDataFragment;
|
||||
import com.yizhuan.erban.home.adapter.HomeRoomFragmentAdapter;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTabMapInfo;
|
||||
@@ -32,7 +33,7 @@ import java.util.concurrent.CancellationException;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class HomeTabHomeFragment extends LazyLoadFragment {
|
||||
public class HomeTabHomeFragment extends BaseFragment {
|
||||
public static final int ROWS = 3;
|
||||
private static final String PARAM_TAB_ID = "tabId";
|
||||
private RecyclerView recyclerView;
|
||||
@@ -232,14 +233,11 @@ public class HomeTabHomeFragment extends LazyLoadFragment {
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
// getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadData() {
|
||||
getData();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
|
@@ -1,175 +0,0 @@
|
||||
package com.yizhuan.erban.home.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.base.BaseMvpFragment;
|
||||
import com.yizhuan.erban.home.adapter.HomeRoomFragmentAdapter;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTabMapInfo;
|
||||
import com.yizhuan.erban.home.presenter.HomeTabMapPresenter;
|
||||
import com.yizhuan.xchat_android_core.home.IHomeTabMapView;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@CreatePresenter(HomeTabMapPresenter.class)
|
||||
public class HomeTabMapFragment extends BaseMvpFragment<IHomeTabMapView, HomeTabMapPresenter> implements IHomeTabMapView, BaseQuickAdapter.RequestLoadMoreListener {
|
||||
public static final int ROWS = 2;
|
||||
private static final String PARAM_TAB_ID = "tabId";
|
||||
private RecyclerView recyclerView;
|
||||
private SwipeRefreshLayout swipeRefresh;
|
||||
private String tabId;
|
||||
private HomeRoomFragmentAdapter mHomeRoomAdapter;
|
||||
|
||||
public static HomeTabMapFragment newInstance(int tabId) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PARAM_TAB_ID, String.valueOf(tabId));
|
||||
HomeTabMapFragment fragment = new HomeTabMapFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
tabId = getArguments().getString(PARAM_TAB_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRootLayoutId() {
|
||||
return R.layout.fragment_home_tab_map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindViews() {
|
||||
recyclerView = mView.findViewById(R.id.recycler_view);
|
||||
swipeRefresh = mView.findViewById(R.id.swipe_refresh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
swipeRefresh.setOnRefreshListener(() -> {
|
||||
mHomeRoomAdapter.setEnableLoadMore(true);
|
||||
loadData(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiate() {
|
||||
initRecyclerView();
|
||||
loadData(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新数据
|
||||
*/
|
||||
private void loadData(boolean isRefresh) {
|
||||
getMvpPresenter().loadData(isRefresh,tabId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View.OnClickListener getLoadMoreListener() {
|
||||
return super.getLoadMoreListener();
|
||||
}
|
||||
|
||||
private void initRecyclerView() {
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setItemAnimator(null);
|
||||
mHomeRoomAdapter = new HomeRoomFragmentAdapter(getContext(),null,false);
|
||||
mHomeRoomAdapter.setOnLoadMoreListener(this, recyclerView);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), ROWS);
|
||||
recyclerView.setLayoutManager(gridLayoutManager);
|
||||
recyclerView.setAdapter(mHomeRoomAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void homeTabMapSuccess(List<HomeTabMapInfo> list) {
|
||||
hideStatus();
|
||||
if (mHomeRoomAdapter != null) {
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
swipeRefresh.setRefreshing(false);
|
||||
|
||||
if (list == null || list.size() == 0) {
|
||||
showNoData();
|
||||
} else {
|
||||
mHomeRoomAdapter.setNewData(getMultipleItemData(list));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<HomeTabMapInfo> getMultipleItemData(List<HomeTabMapInfo> itemList) {
|
||||
if (null==itemList||itemList.size()<=0){
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemList.size(); i++) {
|
||||
itemList.get(i).setItemType(HomeTabMapInfo.TYPE_NORMAL);
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void homeTabMapFails(String error) {
|
||||
hideStatus();
|
||||
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
showNoData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void homeTabMapLoadMoreSuccess(List<HomeTabMapInfo> list) {
|
||||
if (ListUtils.isListEmpty(list)){
|
||||
mHomeRoomAdapter.loadMoreEnd();
|
||||
return;
|
||||
}
|
||||
mHomeRoomAdapter.addData(list);
|
||||
mHomeRoomAdapter.loadMoreComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void homeTabMapLoadMoreFails(String error) {
|
||||
hideStatus();
|
||||
int page = getMvpPresenter().getPage();
|
||||
if (page <= 1) {
|
||||
showNoData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadData() {
|
||||
super.onReloadData();
|
||||
loadData(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMoreRequested() {
|
||||
loadData(false);
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
package com.yizhuan.erban.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.coorchice.library.utils.LogUtils
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.RoomContributeListAdapter
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.databinding.FragmentPartyBinding
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* 音游首页
|
||||
*/
|
||||
class PartyFragment : BaseFragment(), MainMagicIndicatorAdapter.OnItemSelectListener {
|
||||
private lateinit var mBinding: FragmentPartyBinding
|
||||
private var isLoaded = false
|
||||
private val mFragments: ArrayList<Fragment> = ArrayList()
|
||||
private val mTabInfoList: ArrayList<CharSequence> = ArrayList()
|
||||
|
||||
companion object{
|
||||
fun newInstance(): PartyFragment {
|
||||
val args = Bundle()
|
||||
|
||||
val fragment = PartyFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_party
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
|
||||
}
|
||||
|
||||
override fun initiate() {
|
||||
if (AuthModel.get().currentUid != 0L) {
|
||||
tryLoadData(false)
|
||||
}
|
||||
}
|
||||
|
||||
//尝试加载不需要登录就可以加载的数据
|
||||
private fun tryLoadData(refresh: Boolean) {
|
||||
if (!isLoaded || refresh) {
|
||||
isLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun onGetHomeTagSuccess(info: List<HomeTagInfo>) {
|
||||
var changed = false
|
||||
val oldTabInfoList: List<CharSequence> = ArrayList<CharSequence>(mTabInfoList)
|
||||
for (tagInfo in info) {
|
||||
if (!oldTabInfoList.contains(tagInfo.name)) {
|
||||
changed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
//只有HomeTagInfo发生改变才刷新数据,否则刷新当前可见的那个Fragment
|
||||
if (changed) {
|
||||
LogUtils.e("$changed:oldTabInfoList")
|
||||
mTabInfoList.clear()
|
||||
mFragments.clear()
|
||||
for (i in info.indices) {
|
||||
//过滤对象是空和没有标签名同时也没有子标签的情况
|
||||
var title: CharSequence?
|
||||
var fragment: Fragment?
|
||||
var name = info[i].name
|
||||
if (name != null) {
|
||||
name = name.trim { it <= ' ' }
|
||||
}
|
||||
title = name
|
||||
mTabInfoList.add(title)
|
||||
val tabId: Int = info[i].id
|
||||
fragment = HomeTabHomeFragment.newInstance(tabId)
|
||||
mFragments.add(fragment)
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = MainMagicIndicatorAdapter(context, mTabInfoList, false)
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
mBinding.viewPager.offscreenPageLimit = 5
|
||||
mBinding.viewPager.adapter = RoomContributeListAdapter(
|
||||
childFragmentManager,
|
||||
mFragments
|
||||
)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
} else {
|
||||
for (fragment in mFragments) {
|
||||
if (fragment is LazyLoadFragment) {
|
||||
fragment.tryLoadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息更新
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
tryLoadData(true)
|
||||
}
|
||||
|
||||
override fun onItemSelect(position: Int, view: TextView?) {
|
||||
mBinding.viewPager.currentItem = position
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,245 @@
|
||||
package com.yizhuan.erban.home.fragment
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.scwang.smartrefresh.layout.internal.ProgressDrawable
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.RoomContributeListAdapter
|
||||
import com.yizhuan.erban.base.BaseFragment
|
||||
import com.yizhuan.erban.databinding.FragmentRecommendBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.BannerAdapter
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.home.adapter.MainMagicIndicatorAdapter.OnBottomItemSelectListener
|
||||
import com.yizhuan.erban.ui.widget.OnPageSelectedListener
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.Util
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import com.yizhuan.xchat_android_core.market_verify.MarketVerifyModel
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol
|
||||
import com.yizhuan.xchat_android_core.user.event.LoadLoginUserInfoEvent
|
||||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 音游首页
|
||||
*/
|
||||
class RecommendFragment : BaseFragment(), View.OnClickListener, OnBottomItemSelectListener {
|
||||
private lateinit var mBinding: FragmentRecommendBinding
|
||||
private var mFragmentsBottom: MutableList<Fragment> = ArrayList()
|
||||
private lateinit var bannerAdapter: BannerAdapter
|
||||
private var isLoaded = false
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RecommendFragment {
|
||||
val args = Bundle()
|
||||
|
||||
val fragment = RecommendFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
|
||||
}
|
||||
|
||||
override fun getRootLayoutId(): Int {
|
||||
return R.layout.fragment_recommend
|
||||
}
|
||||
|
||||
override fun onFindViews() {
|
||||
mBinding = DataBindingUtil.bind(mView)!!
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
mBinding.click = this
|
||||
}
|
||||
|
||||
override fun initiate() {
|
||||
initRefreshView()
|
||||
initTitleTab()
|
||||
if (AuthModel.get().currentUid != 0L) {
|
||||
tryLoadData(false)
|
||||
}
|
||||
childFragmentManager
|
||||
.beginTransaction()
|
||||
.replace(R.id.fg_recommend_room, HomeTabHomeFragment.newInstance(0))
|
||||
.commitAllowingStateLoss()
|
||||
|
||||
homeViewModel.getBannerInfo()
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
setBanner(it)
|
||||
}
|
||||
}
|
||||
|
||||
//尝试加载不需要登录就可以加载的数据
|
||||
private fun tryLoadData(refresh: Boolean) {
|
||||
if (!isLoaded || refresh) {
|
||||
isLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun initRefreshView() {
|
||||
mBinding.refreshLayout.setOnRefreshListener {
|
||||
mBinding.refreshLayout.finishRefresh()
|
||||
EventBus.getDefault().post(RefreshHomeDataEvent())
|
||||
}
|
||||
mBinding.refreshLayout.isEnableOverScrollBounce = false
|
||||
val themeColor = requireContext().resources.getColor(R.color.color_666666)
|
||||
mBinding.refreshHeader.lastUpdateText.setTextColor(themeColor)
|
||||
mBinding.refreshHeader.titleText.setTextColor(themeColor)
|
||||
mBinding.refreshHeader.setBackgroundColor(Color.TRANSPARENT)
|
||||
val progressDrawable = ProgressDrawable()
|
||||
progressDrawable.setColor(themeColor)
|
||||
mBinding.refreshHeader.progressView.setImageDrawable(progressDrawable)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化动态和聊天交友tab
|
||||
*/
|
||||
private fun initTitleTab() {
|
||||
val tagList: MutableList<String> = ArrayList()
|
||||
tagList.add("热门房间")
|
||||
tagList.add("组队开黑")
|
||||
mFragmentsBottom.add(RoomHotFragment.newInstance())
|
||||
mFragmentsBottom.add(HomePlayFragment.newInstance())
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = MainMagicIndicatorAdapter(context, tagList, false)
|
||||
magicIndicatorAdapter.setOnBottomItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
mBinding.magicIndicator.navigator = commonNavigator
|
||||
commonNavigator.titleContainer.showDividers = LinearLayout.SHOW_DIVIDER_MIDDLE
|
||||
mBinding.viewPager.offscreenPageLimit = 5
|
||||
mBinding.viewPager.adapter =
|
||||
RoomContributeListAdapter(childFragmentManager, mFragmentsBottom)
|
||||
ViewPagerHelper.bind(mBinding.magicIndicator, mBinding.viewPager)
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部动态聊天交友
|
||||
*
|
||||
* @param position
|
||||
* @param view
|
||||
*/
|
||||
override fun onBottomItemSelect(position: Int, view: TextView) {
|
||||
if (mFragmentsBottom.isEmpty()) {
|
||||
return
|
||||
}
|
||||
mBinding.viewPager.currentItem = position
|
||||
if (position == 1) {
|
||||
StatisticManager.Instance()
|
||||
.onEvent(StatisticsProtocol.Event.EVENT_HOME_SCREEN_DONG_TAI_CLICK, "首页_聊天交友切换到动态")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息更新
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun loadLoginUserInfoEvent(event: LoginUserInfoUpdateEvent?) {
|
||||
refreshData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息更新
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun loadLoginUserInfoEvent(event: LoadLoginUserInfoEvent?) {
|
||||
refreshData()
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
tryLoadData(false)
|
||||
}
|
||||
|
||||
private fun setBanner(bannerList: List<BannerInfo>) {
|
||||
if (ListUtils.isListEmpty(bannerList)) {
|
||||
mBinding.rollView.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
mBinding.rollView.visibility = View.VISIBLE
|
||||
if (!this::bannerAdapter.isInitialized) {
|
||||
mBinding.rollView.setHintView(object : ColorPointHintView(
|
||||
mContext, Color.WHITE, mContext.resources.getColor(
|
||||
R.color.color_66FFFFFF
|
||||
)
|
||||
) {
|
||||
override fun makeFocusDrawable(): Drawable {
|
||||
val dotFocus = GradientDrawable()
|
||||
dotFocus.setColor(Color.WHITE)
|
||||
dotFocus.cornerRadius = Util.dip2px(
|
||||
context, 2f
|
||||
).toFloat()
|
||||
dotFocus.setSize(
|
||||
Util.dip2px(context, 9f), Util.dip2px(
|
||||
context, 4f
|
||||
)
|
||||
)
|
||||
return dotFocus
|
||||
}
|
||||
|
||||
override fun makeNormalDrawable(): Drawable {
|
||||
val dotNormal = GradientDrawable()
|
||||
dotNormal.setColor(mContext.resources.getColor(R.color.color_66FFFFFF))
|
||||
dotNormal.cornerRadius = Util.dip2px(
|
||||
context, 2f
|
||||
).toFloat()
|
||||
dotNormal.setSize(
|
||||
Util.dip2px(context, 4f), Util.dip2px(
|
||||
context, 4f
|
||||
)
|
||||
)
|
||||
return dotNormal
|
||||
}
|
||||
})
|
||||
bannerAdapter = BannerAdapter(bannerList, mContext)
|
||||
bannerAdapter.setRoundingRadius(ScreenUtil.dip2px(12f))
|
||||
bannerAdapter.setHomeGame(true)
|
||||
mBinding.rollView.setAdapter(bannerAdapter)
|
||||
mBinding.rollView.setPlayDelay(3000)
|
||||
//设置透明度
|
||||
mBinding.rollView.setAnimationDurtion(500)
|
||||
}
|
||||
bannerAdapter.setBannerInfoList(bannerList)
|
||||
bannerAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.yizhuan.erban.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.FragmentHotRoomBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.HotRoomAdapter
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoom
|
||||
|
||||
|
||||
class RoomHotFragment : BaseViewBindingFragment<FragmentHotRoomBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): RoomHotFragment {
|
||||
val args = Bundle()
|
||||
val fragment = RoomHotFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val roomHotAdapter = HotRoomAdapter()
|
||||
private var page = 1
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoom>
|
||||
private val pageSize = 20
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
override fun init() {
|
||||
rvDelegate = RVDelegate.Builder<HomeRoom>()
|
||||
.setAdapter(roomHotAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setRefreshLayout(binding.refreshLayout)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyView(context, "暂无房间"))
|
||||
.setLayoutManager(LinearLayoutManager(mContext))
|
||||
.setPageSize(pageSize)
|
||||
.build()
|
||||
roomHotAdapter.setOnLoadMoreListener({ loadData(false) }, binding.recyclerView)
|
||||
binding.refreshLayout.setOnRefreshListener { loadData(true) }
|
||||
|
||||
homeViewModel.hotRoomLiveData.observe(this) {
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
binding.refreshLayout.isRefreshing = isRefresh
|
||||
if (isRefresh) {
|
||||
page = 1
|
||||
} else {
|
||||
page++
|
||||
}
|
||||
homeViewModel.getHotRoom(page, pageSize)
|
||||
}
|
||||
}
|
@@ -1,32 +1,18 @@
|
||||
package com.yizhuan.erban.home.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.yizhuan.erban.base.BaseMvpPresenter;
|
||||
import com.yizhuan.erban.home.view.IMainFragmentView;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo;
|
||||
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
|
||||
import com.yizhuan.xchat_android_core.market_verify.event.MarketVerifyUpdateEvent;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author jiajie
|
||||
@@ -88,7 +74,6 @@ public class MainFragmentPresenter extends BaseMvpPresenter<IMainFragmentView> {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMainFragmentView getMvpView() {
|
||||
if (super.getMvpView() == null) {
|
||||
@@ -98,81 +83,5 @@ public class MainFragmentPresenter extends BaseMvpPresenter<IMainFragmentView> {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMarketVerifyUpdateEvent(MarketVerifyUpdateEvent event) {
|
||||
getMvpView().showByMarketCheckingStatus(new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页banner
|
||||
*/
|
||||
public void getHomeBanner(String type) {
|
||||
GameHomeModel.get()
|
||||
.getHomeBanner(type)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(new SingleObserver<List<BannerInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BannerInfo> infos) {
|
||||
IMainFragmentView iMainFragmentView = getMvpView();
|
||||
if (iMainFragmentView != null)
|
||||
getMvpView().onGetHomeBannerSuccess(infos);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
LogUtil.e(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页tag
|
||||
*/
|
||||
public void getHomeTag() {
|
||||
GameHomeModel.get()
|
||||
.getHomeTag()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(new SingleObserver<List<HomeTagInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<HomeTagInfo> infos) {
|
||||
IMainFragmentView iMainFragmentView = getMvpView();
|
||||
if (iMainFragmentView != null)
|
||||
getMvpView().onGetHomeTagSuccess(infos);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
LogUtil.e(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void getHomeConcerns() {
|
||||
GameHomeModel.get().getHomeConcerns().compose(RxHelper.handleException())
|
||||
.subscribe((result, throwable) -> {
|
||||
if (throwable != null) {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.getFollowRoomFail();
|
||||
}
|
||||
} else {
|
||||
if (mMvpView != null) {
|
||||
mMvpView.getFollowRoomsSuccess(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class NewUserListPresenter extends BaseMvpPresenter<INewUserListActivityV
|
||||
|
||||
@Override
|
||||
public Single<List<UserInfo>> loadData(int curPage) {
|
||||
return HomeModel.get().loadNewUserList(
|
||||
return HomeModel.INSTANCE.loadNewUserList(
|
||||
String.valueOf(curPage),
|
||||
String.valueOf(Constants.PAGE_SIZE)
|
||||
)
|
||||
|
@@ -1,14 +1,8 @@
|
||||
package com.yizhuan.erban.home.view;
|
||||
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeConcernsInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.TagListInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiajie
|
||||
* @Description
|
||||
@@ -17,69 +11,22 @@ import java.util.List;
|
||||
|
||||
public interface IMainFragmentView extends IMvpBaseView {
|
||||
|
||||
|
||||
/**
|
||||
* 请求打开房间结果
|
||||
*
|
||||
* @param openRoomFailType
|
||||
* @param arg
|
||||
*/
|
||||
void requestOpenRoomResult(int openRoomFailType, Object... arg);
|
||||
|
||||
void showByMarketCheckingStatus(List<TagListInfo> tagListInfoList);
|
||||
|
||||
void getFollowRoomsSuccess(List<HomeConcernsInfo> infos);
|
||||
|
||||
void getFollowRoomFail();
|
||||
|
||||
/**
|
||||
* 退出房间
|
||||
*/
|
||||
void exitRoom(RoomInfo roomInfo);
|
||||
|
||||
void onGetHomeBannerSuccess(List<BannerInfo> bannerInfos);
|
||||
|
||||
void onGetHomeTagSuccess(List<HomeTagInfo> tagInfos);
|
||||
|
||||
/**
|
||||
* 假实现,用于在View销毁后 调用View方法导致空指针问题,的一种解决方案
|
||||
*/
|
||||
class FakeIMainFragmentView implements IMainFragmentView {
|
||||
|
||||
@Override
|
||||
public void requestOpenRoomResult(int openRoomFailType, Object... arg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showByMarketCheckingStatus(List<TagListInfo> tagListInfoList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFollowRoomsSuccess(List<HomeConcernsInfo> infos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFollowRoomFail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitRoom(RoomInfo roomInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetHomeBannerSuccess(List<BannerInfo> bannerInfos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetHomeTagSuccess(List<HomeTagInfo> tagInfos) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_library.rxbus.RxBus;
|
||||
import com.yizhuan.erban.luckymoney.view.LuckyMoneyDetailActivity;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyInfo;
|
||||
import com.yizhuan.xchat_android_core.family.model.FamilyModel;
|
||||
@@ -43,7 +43,7 @@ public class LuckyMoneyDialog extends AppCompatDialog implements View.OnClickLis
|
||||
private static final String TAG = "LuckyMoneyDialog";
|
||||
|
||||
private LuckyMoneyInfo luckyMoneyInfo;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private FamilyInfo myFamilyInfo;
|
||||
private String uuid;
|
||||
private Disposable disposable;
|
||||
@@ -68,7 +68,7 @@ public class LuckyMoneyDialog extends AppCompatDialog implements View.OnClickLis
|
||||
window.setAttributes(params);
|
||||
window.setWindowAnimations(R.style.ErbanCommonWindowAnimationStyle);
|
||||
super.onCreate(savedInstanceState);
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
myFamilyInfo = FamilyModel.Instance().getMyFamily();
|
||||
// dialogManager = new DialogManager(getContext());
|
||||
setCancelable(true);
|
||||
|
@@ -23,7 +23,7 @@ import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.utils.net.BalanceNotEnoughExeption;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyInfo;
|
||||
import com.yizhuan.xchat_android_core.family.model.FamilyModel;
|
||||
import com.yizhuan.xchat_android_core.share.bean.SessionType;
|
||||
@@ -51,7 +51,7 @@ public class LuckyMoneyCreationActivity extends BaseBindingActivity<ActivityLuck
|
||||
private static final int DECIMAL_DIGITS = 2;
|
||||
private FamilyInfo myFamilyInfo;
|
||||
private TeamInfo teamInfo;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private double redPacketRate;
|
||||
|
||||
public static void start(Context context) {
|
||||
@@ -64,7 +64,7 @@ public class LuckyMoneyCreationActivity extends BaseBindingActivity<ActivityLuck
|
||||
initTitleBar(getString(R.string.title_lucky_money_creation));
|
||||
|
||||
myFamilyInfo = FamilyModel.Instance().getMyFamily();
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
teamInfo = TeamModel.get().getCurrentTeamInfo();
|
||||
|
||||
redPacketRate = myFamilyInfo.getRedPacketRate() * 100;
|
||||
|
@@ -15,7 +15,7 @@ import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.utils.FormatUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.luckymoney.adapter.LuckyMoneyMemberListAdapter;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyInfo;
|
||||
import com.yizhuan.xchat_android_core.family.model.FamilyModel;
|
||||
@@ -36,7 +36,7 @@ public class LuckyMoneyDetailActivity extends BaseBindingActivity<ActivityLuckyM
|
||||
public static final String EXTRA_LUCKY_MONEY_ID = "EXTRA_LUCKY_MONEY_ID";
|
||||
|
||||
private LuckyMoneyMemberListAdapter adapter;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private FamilyInfo myFamilyInfo;
|
||||
private int luckyMoneyId;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class LuckyMoneyDetailActivity extends BaseBindingActivity<ActivityLuckyM
|
||||
protected void init() {
|
||||
initTitleBar(getString(R.string.action_red_packet));
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
myFamilyInfo = FamilyModel.Instance().getMyFamily();
|
||||
luckyMoneyId = getIntent().getIntExtra(EXTRA_LUCKY_MONEY_ID, -1);
|
||||
|
||||
|
@@ -1,31 +0,0 @@
|
||||
package com.yizhuan.erban.luckymoney.viewmodel;
|
||||
|
||||
import com.yizhuan.erban.base.BaseViewModel;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamMemberInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
/**
|
||||
* Created by MadisonRong on 05/06/2018.
|
||||
*/
|
||||
|
||||
public class LuckyMoneyViewModel extends BaseViewModel {
|
||||
|
||||
private static final String TAG = "LuckyMoneyViewModel";
|
||||
|
||||
public Single<List<TeamMemberInfo>> getLuckyMoneyMemberList() {
|
||||
return Single.create(e -> {
|
||||
ArrayList<TeamMemberInfo> memberInfoList = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
TeamMemberInfo memberInfo = new TeamMemberInfo();
|
||||
memberInfo.setUid(i);
|
||||
memberInfo.setNick("家族成员名字要限制在十个字以内" + i);
|
||||
memberInfoList.add(memberInfo);
|
||||
}
|
||||
e.onSuccess(memberInfoList);
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
package com.yizhuan.erban.monsterhunting.viewmodel;
|
||||
|
||||
import android.util.Log;
|
||||
import com.yizhuan.erban.base.BaseViewModel;
|
||||
import com.yizhuan.erban.monsterhunting.bean.AttackMonsterResultInfo;
|
||||
import com.yizhuan.erban.monsterhunting.bean.UpdateMyGoldInfo;
|
||||
import com.yizhuan.xchat_android_core.monsterhunting.bean.MonsterAttackInfo;
|
||||
import com.yizhuan.xchat_android_core.monsterhunting.model.MonsterHuntingModel;
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MonsterHuntingViewModel extends BaseViewModel{
|
||||
|
||||
private static final String TAG = "MonsterHuntingViewModel";
|
||||
public UpdateMyGoldInfo updateMyGoldInfo = new UpdateMyGoldInfo();
|
||||
public AttackMonsterResultInfo attackMonsterResultInfo = new AttackMonsterResultInfo();
|
||||
|
||||
|
||||
public void attackMonster(String monsterId,String roomUid,String magicId) {
|
||||
MonsterHuntingModel.get().attackMonster(monsterId, roomUid, magicId)
|
||||
.subscribe((serviceResult, throwable) -> {
|
||||
if (throwable != null) {
|
||||
// attack fail
|
||||
} else if (serviceResult != null && serviceResult.isSuccess()) {
|
||||
MonsterAttackInfo monsterAttackInfo = serviceResult.getData();
|
||||
// 扣钱,发送自定义消息,显示动画
|
||||
updateMyGold();
|
||||
|
||||
refreshAttackMonsterResultInfo(serviceResult.getCode(),null, monsterAttackInfo,1);
|
||||
|
||||
// 发送自定义消息,成功后显示动画
|
||||
MonsterHuntingModel.get().sendMonsterHuntingMagicMessage(monsterAttackInfo)
|
||||
.subscribe((chatRoomMessage, throwable1) ->{
|
||||
if (chatRoomMessage != null) {
|
||||
// 显示动画
|
||||
MonsterHuntingModel.get().onSendMonsterAttackMessageSuccess(chatRoomMessage);
|
||||
} else {
|
||||
throwable1.printStackTrace();
|
||||
}
|
||||
});
|
||||
} else if (serviceResult != null && !serviceResult.isSuccess()) {
|
||||
Log.e(TAG, String.format(Locale.getDefault(), "attackMonster: code:%s, message: %s",
|
||||
serviceResult.getCode(), serviceResult.getMessage()));
|
||||
refreshAttackMonsterResultInfo(serviceResult.getCode(), serviceResult.getErrorMessage(), null, 2);
|
||||
} else {
|
||||
refreshAttackMonsterResultInfo(-1, serviceResult.getErrorMessage(), null, 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void refreshAttackMonsterResultInfo(int code, String errorMessage, MonsterAttackInfo monsterAttackInfo, int status) {
|
||||
attackMonsterResultInfo.setCode(code);
|
||||
attackMonsterResultInfo.setErrorMessage(errorMessage);
|
||||
attackMonsterResultInfo.setMonsterAttackInfo(monsterAttackInfo);
|
||||
attackMonsterResultInfo.setStatus(status);
|
||||
}
|
||||
|
||||
public void updateMyGold() {
|
||||
PayModel.get().getMyRemoteWalletInfo()
|
||||
.subscribe((walletInfo, throwable) -> {
|
||||
if (walletInfo != null) {
|
||||
updateMyGoldInfo.setWalletInfo(walletInfo);
|
||||
updateMyGoldInfo.setSucceed(true);
|
||||
} else if (throwable != null) {
|
||||
updateMyGoldInfo.setSucceed(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -14,7 +14,7 @@ import com.yizhuan.erban.databinding.ActivityAddTeamMemberBinding;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.team.adapter.AddTeamMemberAdapter;
|
||||
import com.yizhuan.erban.team.viewmodel.FamilyMemberViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.FamilyMemberVM;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyMemberInfo;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class AddMemberActivity extends BaseBindingActivity<ActivityAddTeamMember
|
||||
public static final String EXTRA_TEAM_ID = "EXTRA_TEAM_ID";
|
||||
public static final String EXTRA_SELECTED_MEMBER = "EXTRA_SELECTED_MEMBER";
|
||||
|
||||
private FamilyMemberViewModel familyMemberViewModel;
|
||||
private FamilyMemberVM familyMemberViewModel;
|
||||
private AddTeamMemberAdapter addTeamMemberAdapter;
|
||||
private String teamId;
|
||||
private int page = FIRST_PAGE;
|
||||
@@ -71,7 +71,7 @@ public class AddMemberActivity extends BaseBindingActivity<ActivityAddTeamMember
|
||||
}
|
||||
}
|
||||
|
||||
familyMemberViewModel = new FamilyMemberViewModel();
|
||||
familyMemberViewModel = new FamilyMemberVM();
|
||||
addTeamMemberAdapter = new AddTeamMemberAdapter(this);
|
||||
mBinding.rvMember.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.rvMember.setAdapter(addTeamMemberAdapter);
|
||||
|
@@ -16,7 +16,7 @@ import com.yizhuan.erban.databinding.ActivityAddTeamMemberSearchListBinding;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.team.adapter.AddTeamMemberAdapter;
|
||||
import com.yizhuan.erban.team.viewmodel.FamilyMemberViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.FamilyMemberVM;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyMemberInfo;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
@@ -36,7 +36,7 @@ public class AddMemberSearchActivity extends BaseBindingActivity<ActivityAddTeam
|
||||
public static final String EXTRA_TEAM_SELECT_MEMBERS = "EXTRA_TEAM_SELECT_MEMBERS";
|
||||
public static final String EXTRA_SEARCH_MEMBER = "EXTRA_SEARCH_MEMBER";
|
||||
|
||||
private FamilyMemberViewModel familyMemberViewModel;
|
||||
private FamilyMemberVM familyMemberViewModel;
|
||||
private AddTeamMemberAdapter addTeamMemberAdapter;
|
||||
private String teamId;
|
||||
private ArrayList<FamilyMemberInfo> selectMembers = new ArrayList<>();
|
||||
@@ -59,7 +59,7 @@ public class AddMemberSearchActivity extends BaseBindingActivity<ActivityAddTeam
|
||||
}
|
||||
}
|
||||
|
||||
familyMemberViewModel = new FamilyMemberViewModel();
|
||||
familyMemberViewModel = new FamilyMemberVM();
|
||||
addTeamMemberAdapter = new AddTeamMemberAdapter(this);
|
||||
mBinding.rvMember.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.rvMember.setAdapter(addTeamMemberAdapter);
|
||||
|
@@ -14,7 +14,7 @@ import com.yizhuan.erban.base.BaseBindingTakePhotoActivity;
|
||||
import com.yizhuan.erban.databinding.ActivityCreateTeamMessageBinding;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.utils.KeyBoardUtils;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyMemberInfo;
|
||||
import com.yizhuan.xchat_android_core.family.model.FamilyModel;
|
||||
@@ -31,7 +31,7 @@ public class CreateTeamMessageActivity extends BaseBindingTakePhotoActivity<Acti
|
||||
|
||||
private static final String TAG = "CreateTeamMessageActivi";
|
||||
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private String url = "https://image.zhongjialx.com/default_group_avatar.png";
|
||||
private ArrayList<FamilyMemberInfo> members = new ArrayList<>();
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CreateTeamMessageActivity extends BaseBindingTakePhotoActivity<Acti
|
||||
protected void init() {
|
||||
initTitleBar(getString(R.string.title_create_team));
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
mBinding.etTeamName.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
|
@@ -2,7 +2,6 @@ package com.yizhuan.erban.team.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.View;
|
||||
|
||||
import com.netease.nim.uikit.business.session.helper.MessageListPanelHelper;
|
||||
@@ -14,7 +13,7 @@ import com.yizhuan.erban.base.TitleBar;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.databinding.ActivityTeamManagementBinding;
|
||||
import com.yizhuan.erban.friend.view.SelectFriendActivity;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem;
|
||||
import com.yizhuan.erban.ui.widget.ShareDialog;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
@@ -50,7 +49,7 @@ public class NimTeamManagementActivity extends BaseBindingTakePhotoActivity<Acti
|
||||
public static final String EXTRA_TEAM_ID = "EXTRA_TEAM_ID";
|
||||
|
||||
private String teamId;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private ShareDialog shareDialog;
|
||||
private TeamInfo teamInfo;
|
||||
|
||||
@@ -65,7 +64,7 @@ public class NimTeamManagementActivity extends BaseBindingTakePhotoActivity<Acti
|
||||
initTitleBar(getString(R.string.text_team_info_title));
|
||||
mBinding.setClick(this);
|
||||
setOnUploadListener(this);
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
if (getIntent() != null) {
|
||||
teamId = getIntent().getStringExtra(EXTRA_TEAM_ID);
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.SimpleCallback;
|
||||
@@ -32,7 +31,7 @@ import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.widget.DragLayout;
|
||||
import com.yizhuan.erban.family.view.activity.FamilyHomeActivity;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.ui.im.actions.FamilyGameAction;
|
||||
import com.yizhuan.erban.ui.im.actions.LuckyMoneyAction;
|
||||
import com.yizhuan.erban.ui.im.avtivity.BaseMessageActivity;
|
||||
@@ -81,7 +80,7 @@ public class NimTeamMessageActivity extends BaseMessageActivity {
|
||||
|
||||
private NimTeamMessageFragment fragment;
|
||||
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
|
||||
private DragLayout teamAvatarLayout;
|
||||
private ImageView teamAvatar;
|
||||
@@ -119,7 +118,7 @@ public class NimTeamMessageActivity extends BaseMessageActivity {
|
||||
|
||||
findViews();
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
openTeamManagementPage();
|
||||
|
||||
|
@@ -10,7 +10,7 @@ import com.yizhuan.erban.databinding.FragmentTeamListBinding;
|
||||
import com.yizhuan.erban.friend.action.AbstractSelectFriendAction;
|
||||
import com.yizhuan.erban.friend.view.SelectFriendActivity;
|
||||
import com.yizhuan.erban.team.adapter.TeamListAdapter;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamInfo;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
@@ -22,7 +22,7 @@ import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
public class TeamListFragment extends BaseBindingFragment<FragmentTeamListBinding> {
|
||||
|
||||
private TeamListAdapter adapter;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private int type;
|
||||
private SelectFriendActivity friendActivity;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class TeamListFragment extends BaseBindingFragment<FragmentTeamListBindin
|
||||
type = getArguments().getInt(AbstractSelectFriendAction.KEY_TYPE, AbstractSelectFriendAction.TYPE_NORMAL);
|
||||
}
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
adapter = new TeamListAdapter(getContext());
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
mBinding.recyclerView.setAdapter(adapter);
|
||||
|
@@ -23,7 +23,7 @@ import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.team.adapter.TeamMemberListAdapter;
|
||||
import com.yizhuan.erban.team.bean.NimTeamMember;
|
||||
import com.yizhuan.erban.team.event.TeamMemberUpdateEvent;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.family.bean.FamilyMemberInfo;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamInfo;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamMemberInfo;
|
||||
@@ -63,7 +63,7 @@ public class TeamMemberListActivity extends BaseBindingActivity<ActivityTeamMemb
|
||||
private int page = FIRST_PAGE;
|
||||
private boolean isLoading = false;
|
||||
private TeamMemberListAdapter teamMemberListAdapter;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private TeamInfo teamInfo;
|
||||
|
||||
private TitleBar.Action addMemberAction = new TitleBar.Action() {
|
||||
@@ -132,7 +132,7 @@ public class TeamMemberListActivity extends BaseBindingActivity<ActivityTeamMemb
|
||||
@Override
|
||||
protected void init() {
|
||||
initTitleBar(getString(R.string.title_team_member_list));
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
type = getIntent().getIntExtra(KEY_OPERATION_TYPE, OP_TEAM_MEMBER_NORMAL);
|
||||
chatId = getIntent().getStringExtra(EXTRA_ID);
|
||||
|
@@ -23,7 +23,7 @@ import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.team.adapter.TeamMemberListAdapter;
|
||||
import com.yizhuan.erban.team.bean.NimTeamMember;
|
||||
import com.yizhuan.erban.team.event.TeamMemberUpdateEvent;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamInfo;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamMemberInfo;
|
||||
import com.yizhuan.xchat_android_core.team.model.TeamModel;
|
||||
@@ -47,7 +47,7 @@ public class TeamMemberSearchListActivity extends BaseBindingActivity<ActivityTe
|
||||
private String tid;
|
||||
private int type;
|
||||
private TeamMemberListAdapter teamMemberListAdapter;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private TeamInfo teamInfo;
|
||||
|
||||
public static void start(Context context, String tid, int type) {
|
||||
@@ -59,7 +59,7 @@ public class TeamMemberSearchListActivity extends BaseBindingActivity<ActivityTe
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
type = getIntent().getIntExtra(KEY_OPERATION_TYPE, OP_TEAM_MEMBER_NORMAL);
|
||||
tid = getIntent().getStringExtra(EXTRA_ID);
|
||||
|
@@ -19,7 +19,7 @@ import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.utils.FormatUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.team.adapter.TeamWeeklyBillAdapter;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.family.model.FamilyModel;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamTransactionRecordInfo;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TeamWeeklyBillActivity extends BaseBindingActivity<ActivityTeamWeek
|
||||
public static final int PAGE_FIRST = 1;
|
||||
|
||||
private String chatId;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private TeamWeeklyBillAdapter teamWeeklyBillAdapter;
|
||||
private View headerView;
|
||||
private View emptyView;
|
||||
@@ -61,7 +61,7 @@ public class TeamWeeklyBillActivity extends BaseBindingActivity<ActivityTeamWeek
|
||||
mBinding.rvFamilyCurrency.setAdapter(teamWeeklyBillAdapter);
|
||||
mBinding.swipeRefresh.setOnRefreshLoadmoreListener(this);
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
mBinding.setClick(this);
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import com.yizhuan.erban.databinding.ActivityTeamWeeklyBillSearchBinding;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.erban.team.adapter.TeamWeeklyBillAdapter;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamTransactionRecordInfo;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TeamWeeklyBillSearchActivity extends BaseBindingActivity<ActivityTe
|
||||
|
||||
private String chatId;
|
||||
private TeamWeeklyBillAdapter teamWeeklyBillAdapter;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private int page = PAGE_FIRST;
|
||||
|
||||
public static void start(Context context, String chatId) {
|
||||
@@ -58,7 +58,7 @@ public class TeamWeeklyBillSearchActivity extends BaseBindingActivity<ActivityTe
|
||||
mBinding.rvFamilyCurrency.setAdapter(teamWeeklyBillAdapter);
|
||||
mBinding.swipeRefresh.setOnRefreshLoadmoreListener(this);
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
View headerView = LayoutInflater.from(this).inflate(R.layout.layout_search_header, null, false);
|
||||
teamWeeklyBillAdapter.addHeaderView(headerView);
|
||||
|
@@ -12,7 +12,7 @@ import com.yizhuan.erban.base.BaseBindingActivity;
|
||||
import com.yizhuan.erban.base.TitleBar;
|
||||
import com.yizhuan.erban.databinding.ActivityUpdateTeamNameBinding;
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.xchat_android_core.team.bean.TeamInfo;
|
||||
import com.yizhuan.xchat_android_core.team.model.TeamModel;
|
||||
|
||||
@@ -25,7 +25,7 @@ import static com.yizhuan.erban.team.view.NimTeamManagementActivity.EXTRA_TEAM_I
|
||||
public class UpdateTeamNameActivity extends BaseBindingActivity<ActivityUpdateTeamNameBinding> {
|
||||
|
||||
private EditText teamName;
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
private String tid;
|
||||
private TeamInfo teamInfo;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class UpdateTeamNameActivity extends BaseBindingActivity<ActivityUpdateTe
|
||||
protected void init() {
|
||||
tid = getIntent().getStringExtra(EXTRA_TEAM_ID);
|
||||
teamInfo = TeamModel.get().getTeamInfoCache(tid);
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
teamName = mBinding.etContentTeamName;
|
||||
teamName.setText(teamInfo.getName());
|
||||
teamName.setFilters(new InputFilter[]{new InputFilter.LengthFilter(15)});
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.yizhuan.erban.team.viewmodel;
|
||||
|
||||
import com.yizhuan.erban.base.BaseViewModel;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.erban.base.BaseVM;
|
||||
import com.yizhuan.xchat_android_core.family.bean.response.memberList.RespFamilymember;
|
||||
import com.yizhuan.xchat_android_core.family.model.FamilyModel;
|
||||
|
||||
@@ -12,7 +10,7 @@ import io.reactivex.Single;
|
||||
* Created by MadisonRong on 29/05/2018.
|
||||
*/
|
||||
|
||||
public class FamilyMemberViewModel extends BaseViewModel {
|
||||
public class FamilyMemberVM extends BaseVM {
|
||||
|
||||
|
||||
/**
|
@@ -1,6 +1,6 @@
|
||||
package com.yizhuan.erban.team.viewmodel;
|
||||
|
||||
import com.yizhuan.erban.base.BaseViewModel;
|
||||
import com.yizhuan.erban.base.BaseVM;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.luckymoney.LuckyMoneyInfo;
|
||||
import com.yizhuan.xchat_android_core.luckymoney.LuckyMoneyRecordsInfo;
|
||||
@@ -18,7 +18,7 @@ import io.reactivex.Single;
|
||||
* Created by MadisonRong on 29/05/2018.
|
||||
*/
|
||||
|
||||
public class TeamViewModel extends BaseViewModel {
|
||||
public class TeamVM extends BaseVM {
|
||||
|
||||
private static final String TAG = "TeamViewModel";
|
||||
|
@@ -40,7 +40,7 @@ public class FeedbackActivity extends BaseActivity {
|
||||
|
||||
private void SetListener() {
|
||||
btnCommit.setOnClickListener(v ->
|
||||
HomeModel.get().commitFeedback(AuthModel.get().getCurrentUid(),
|
||||
HomeModel.INSTANCE.commitFeedback(AuthModel.get().getCurrentUid(),
|
||||
edtContent.getText().toString(),
|
||||
edtContact.getText().toString()
|
||||
)
|
||||
|
@@ -10,6 +10,8 @@ import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.yizhuan.erban.base.IDataStatus;
|
||||
import com.yizhuan.erban.common.EmptyViewHelper;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ListResult;
|
||||
import com.yizhuan.xchat_android_core.utils.LogUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
|
||||
|
||||
@@ -41,6 +43,18 @@ public class RVDelegate<T> {
|
||||
adapter.bindToRecyclerView(recyclerView);
|
||||
}
|
||||
|
||||
public void loadData(ListResult<T> result) {
|
||||
if (result == null) {
|
||||
LogUtils.d("result == null,skip layout");
|
||||
return;
|
||||
}
|
||||
if (result.isSuccess()) {
|
||||
loadData(result.getData(), result.isRefresh());
|
||||
} else {
|
||||
loadErr(result.isSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadData(List<T> data, boolean isRefresh) {
|
||||
if (isRefresh) {
|
||||
setNewData(data);
|
||||
|
BIN
app/src/main/res/drawable-xhdpi/bg_home_top.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/bg_home_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 102 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -2,7 +2,7 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#40FFFFFF" />
|
||||
<solid android:color="#FFFFFF" />
|
||||
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
@@ -1,259 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
|
||||
<variable
|
||||
name="open_visible"
|
||||
type="Boolean" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg_normal_1c1b22"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_shape_home_top"
|
||||
android:gravity="center"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingBottom="@dimen/dp_10"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_search_room"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_home_search"
|
||||
android:drawableStart="@mipmap/ic_home_search"
|
||||
android:drawablePadding="@dimen/dp_7"
|
||||
android:gravity="center_vertical"
|
||||
android:onClick="@{click}"
|
||||
android:paddingStart="@dimen/dp_11"
|
||||
android:paddingEnd="5dp"
|
||||
android:text="@string/search_hint"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_13" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_ranking"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="@{click}"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_home_rank" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_to_sign_in"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_11"
|
||||
android:gravity="center"
|
||||
android:onClick="@{click}"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/icon_to_sign_in"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<com.scwang.smartrefresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.scwang.smartrefresh.layout.header.ClassicsHeader
|
||||
android:id="@+id/refresh_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
app:elevation="0dp"
|
||||
app:layout_behavior="com.yizhuan.erban.ui.widget.AppBarLayoutBehavior">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:contentScrim="@color/transparent"
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_follow_room"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:background="@drawable/bg_shape_home_top"
|
||||
android:paddingStart="@dimen/dp_15"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:visibility="visible" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/ll_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="5dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/rv_follow_room">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_bg_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="15dp"
|
||||
android:background="@drawable/bg_shape_home_top"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="15dp"
|
||||
android:background="@drawable/shape_home_bg_15dp"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="13dp"
|
||||
android:paddingEnd="@dimen/dp_10"
|
||||
android:paddingBottom="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/tv_room_more"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/view_bg_indicator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_room_more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableRight="@drawable/arrow_right_more_room"
|
||||
android:drawablePadding="@dimen/dp_3"
|
||||
android:gravity="bottom"
|
||||
android:onClick="@{click}"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingEnd="15dp"
|
||||
android:text="更多房间"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/magic_indicator"
|
||||
app:layout_constraintTop_toTopOf="@id/magic_indicator" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.yizhuan.erban.ui.widget.ContentWrapViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_add_friends"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="16dp"
|
||||
android:text="交友扩列"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_add_friends"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/dp_5"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_roll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:layout_marginBottom="15dp">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.rollviewpager.RollPagerView
|
||||
android:id="@+id/roll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintDimensionRatio="345:80"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:rollviewpager_hint_gravity="left"
|
||||
app:rollviewpager_hint_paddingBottom="8dp"
|
||||
tools:visibility="visible" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator_bottom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="13dp"
|
||||
android:paddingRight="10dp" />
|
||||
</FrameLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
85
app/src/main/res/layout/fragment_home.xml
Normal file
85
app/src/main/res/layout/fragment_home.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFF4F4FA">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="336dp"
|
||||
android:background="@drawable/bg_home_top" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingBottom="@dimen/dp_10"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_search_room"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="11dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/bg_home_search"
|
||||
android:drawableStart="@drawable/ic_home_search"
|
||||
android:drawablePadding="@dimen/dp_7"
|
||||
android:gravity="center_vertical"
|
||||
android:onClick="@{click}"
|
||||
android:paddingStart="@dimen/dp_11"
|
||||
android:paddingEnd="5dp"
|
||||
android:text="@string/search_hint"
|
||||
android:textColor="@color/color_999999"
|
||||
android:textSize="@dimen/sp_13" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_ranking"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="@{click}"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_home_rank" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</layout>
|
@@ -2,7 +2,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.yizhuan.erban.home.fragment.HomeOtherTabFragment">
|
||||
>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
|
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.yizhuan.erban.common.widget.StatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"/>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</com.yizhuan.erban.common.widget.StatusLayout>
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.yizhuan.erban.common.widget.StatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/status_layout"
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -9,6 +10,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
/>
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp" />
|
||||
|
||||
</com.yizhuan.erban.common.widget.StatusLayout>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
@@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/mi_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/white" />
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/vp_ktv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_F5F5F5" />
|
||||
|
||||
</LinearLayout>
|
@@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_home_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@drawable/bg_home_top_tab"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!--<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator-->
|
||||
<!--android:id="@+id/mi_home_indicator"-->
|
||||
<!--android:layout_width="0dp"-->
|
||||
<!--android:layout_weight="1"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:paddingLeft="5dp"-->
|
||||
<!--android:paddingRight="5dp" />-->
|
||||
|
||||
<!--<FrameLayout-->
|
||||
<!--android:layout_width="0dp"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:layout_weight="1">-->
|
||||
|
||||
<!--<com.yizhuan.erban.ui.widget.CustSlidingTabLayout-->
|
||||
<!--android:id="@+id/mi_home_indicator"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--app:tl_indicator_height="0dp"-->
|
||||
<!--app:tl_textSelectColor="@color/color_333333"-->
|
||||
<!--app:tl_textUnselectColor="@color/color_333333"-->
|
||||
<!--app:tl_textsize="18dp"-->
|
||||
<!--app:tl_textsize_normal="15dp"-->
|
||||
<!--app:tl_tab_width="56dp"-->
|
||||
<!--app:tl_textBold="SELECT"/>-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:src="@drawable/icon_tab_mask"-->
|
||||
<!--android:layout_gravity="center_vertical|right"/>-->
|
||||
|
||||
<!--</FrameLayout>-->
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/mi_home_indicator"
|
||||
android:layout_width="0dp"
|
||||
android:layout_marginStart="@dimen/dp_5"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="5dp"
|
||||
android:id="@+id/iv_search_room"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/ic_home_search" />
|
||||
|
||||
<ImageView
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="15dp"
|
||||
android:id="@+id/iv_open_room"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:src="@mipmap/ic_open_room" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/main_viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
63
app/src/main/res/layout/fragment_party.xml
Normal file
63
app/src/main/res/layout/fragment_party.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
app:elevation="0dp"
|
||||
app:layout_behavior="com.yizhuan.erban.ui.widget.AppBarLayoutBehavior">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:contentScrim="@color/transparent"
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="13dp"
|
||||
android:paddingRight="10dp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</layout>
|
@@ -1,24 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<com.yizhuan.erban.common.widget.StatusLayout
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="click"
|
||||
type="android.view.View.OnClickListener" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.scwang.smartrefresh.layout.SmartRefreshLayout
|
||||
android:id="@+id/refresh_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_refresh"
|
||||
<com.scwang.smartrefresh.layout.header.ClassicsHeader
|
||||
android:id="@+id/refresh_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_main_home"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</com.yizhuan.erban.common.widget.StatusLayout>
|
||||
android:background="@color/transparent"
|
||||
app:elevation="0dp"
|
||||
app:layout_behavior="com.yizhuan.erban.ui.widget.AppBarLayoutBehavior">
|
||||
|
||||
</LinearLayout>
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:contentScrim="@color/transparent"
|
||||
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_roll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:layout_marginBottom="15dp">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.rollviewpager.RollPagerView
|
||||
android:id="@+id/roll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintDimensionRatio="345:80"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:rollviewpager_hint_gravity="left"
|
||||
app:rollviewpager_hint_paddingBottom="8dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_recommend_room"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingStart="16dp"
|
||||
android:text="推荐房间"
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/fg_recommend_room"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/dp_5"
|
||||
android:visibility="visible"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_indicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<com.yizhuan.erban.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="13dp"
|
||||
android:paddingRight="10dp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
|
||||
|
||||
</layout>
|
95
app/src/main/res/layout/item_room_common.xml
Normal file
95
app/src/main/res/layout/item_room_common.xml
Normal file
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="98dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="10dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/view_bg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="15dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_room_image"
|
||||
android:layout_width="78dp"
|
||||
android:layout_height="78dp"
|
||||
android:src="@drawable/default_cover"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<View
|
||||
android:id="@+id/view_room_cover"
|
||||
android:layout_width="78dp"
|
||||
android:layout_height="78dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_room_image"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_room_image" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_room_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/text_primary"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_room_tag"
|
||||
app:layout_constraintLeft_toRightOf="@+id/iv_room_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="余生点唱歌曲交友房间" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_room_tag"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="15dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:textColor="#FFFCFD"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="@+id/iv_room_image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_room_title"
|
||||
tools:text="聊天" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_online_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:textColor="#5936383A"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_room_tag"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tv_room_tag"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_room_tag"
|
||||
tools:text="266人热聊中" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/iv_into_room"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="@drawable/common_btn_bg"
|
||||
android:gravity="center"
|
||||
android:text="进房"
|
||||
android:textColor="#80000000"
|
||||
android:textSize="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Binary file not shown.
Before Width: | Height: | Size: 908 B |
@@ -261,6 +261,7 @@
|
||||
<color name="color_ffc160">#ffc160</color>
|
||||
<color name="color_7ee7f6">#7ee7f6</color>
|
||||
<color name="color_999999">#999999</color>
|
||||
<color name="color_444444">#444444</color>
|
||||
<color name="color_4D4D4D">#4D4D4D</color>
|
||||
<color name="color_CCCCCC">#CCCCCC</color>
|
||||
<color name="color_99000000">#99000000</color>
|
||||
|
@@ -215,7 +215,7 @@ public class SquareFragment extends BaseFragment implements TopMagicIndicatorAd
|
||||
|
||||
@SuppressWarnings("CheckResult")
|
||||
private void getUnReadCount() {
|
||||
HomeModel.get().getUnreadCount(AuthModel.get().getCurrentUid())
|
||||
HomeModel.INSTANCE.getUnreadCount(AuthModel.get().getCurrentUid())
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(new BiConsumer<Integer, Throwable>() {
|
||||
@Override
|
||||
|
@@ -31,7 +31,7 @@ import com.yizhuan.erban.module_hall.team.HTeamDataManager;
|
||||
import com.yizhuan.erban.module_hall.team.adapter.HTeamMemberListAdapter;
|
||||
import com.yizhuan.erban.team.view.NimTeamManagementActivity;
|
||||
import com.yizhuan.erban.team.view.NimTeamMessageFragment;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.ui.im.avtivity.BaseMessageActivity;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.initial.bean.InitInfo;
|
||||
@@ -81,7 +81,7 @@ public class HallTeamMessageActivity extends BaseMessageActivity {
|
||||
|
||||
private NimTeamMessageFragment fragment;
|
||||
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
|
||||
private ImageView teamAvatar;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class HallTeamMessageActivity extends BaseMessageActivity {
|
||||
HTeamDataManager.get().init(sessionId);
|
||||
findViews();
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
openTeamManagementPage();
|
||||
|
||||
|
@@ -7,7 +7,6 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.api.model.SimpleCallback;
|
||||
@@ -30,7 +29,7 @@ import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.team.view.NimTeamMessageFragment;
|
||||
import com.yizhuan.erban.team.view.TeamMemberListActivity;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamViewModel;
|
||||
import com.yizhuan.erban.team.viewmodel.TeamVM;
|
||||
import com.yizhuan.erban.ui.im.actions.FamilyGameAction;
|
||||
import com.yizhuan.erban.ui.im.actions.LuckyMoneyAction;
|
||||
import com.yizhuan.erban.ui.im.avtivity.BaseMessageActivity;
|
||||
@@ -81,7 +80,7 @@ public class NimTeamRoomMessageActivity extends BaseMessageActivity {
|
||||
|
||||
private NimTeamMessageFragment fragment;
|
||||
|
||||
private TeamViewModel teamViewModel;
|
||||
private TeamVM teamViewModel;
|
||||
|
||||
private View rootView;
|
||||
|
||||
@@ -113,7 +112,7 @@ public class NimTeamRoomMessageActivity extends BaseMessageActivity {
|
||||
|
||||
findViews();
|
||||
|
||||
teamViewModel = new TeamViewModel();
|
||||
teamViewModel = new TeamVM();
|
||||
|
||||
registerTeamUpdateObserver(true);
|
||||
|
||||
|
@@ -100,7 +100,7 @@ dependencies {
|
||||
// RxJava support for Room
|
||||
api 'androidx.room:room-rxjava2:2.2.5'
|
||||
|
||||
api 'com.tencent.bugly:crashreport_upgrade:1.4.2'
|
||||
api 'com.tencent.bugly:crashreport_upgrade:1.5.23'
|
||||
|
||||
api project(':nim_uikit')
|
||||
api project(':library')
|
||||
|
@@ -67,7 +67,7 @@ public class GameHomeModel extends BaseModel {
|
||||
}
|
||||
|
||||
public Single<List<HomeTabMapInfo>> getHomeTabHome(String tabId) {
|
||||
return api.apiHomeTabHome(tabId, String.valueOf(AuthModel.get().getCurrentUid()),
|
||||
return api.apiHomeTabHome(null, String.valueOf(AuthModel.get().getCurrentUid()),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().getTicket())
|
||||
.compose(RxHelper.handleBeanData())
|
||||
@@ -171,7 +171,7 @@ public class GameHomeModel extends BaseModel {
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/tab/home")
|
||||
@GET("/home/tab/homeV2")
|
||||
Single<ServiceResult<List<HomeTabMapInfo>>> apiHomeTabHome(
|
||||
@Query("tabId") String tabId,
|
||||
@Query("uid") String uid,
|
||||
|
@@ -1,44 +1,23 @@
|
||||
package com.yizhuan.xchat_android_core.home.model;
|
||||
package com.yizhuan.xchat_android_core.home.model
|
||||
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel;
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
|
||||
import com.yizhuan.xchat_android_core.community.bean.UnReadCountInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.TabInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.base.BaseModel
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.community.CommunityConstant
|
||||
import com.yizhuan.xchat_android_core.community.bean.UnReadCountInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.*
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_core.utils.net.launchRequest
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Query
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
object HomeModel : BaseModel() {
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.functions.Function;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public class HomeModel extends BaseModel implements IHomeModel {
|
||||
private static final String TAG = "HomeModel";
|
||||
|
||||
private volatile static IHomeModel instance;
|
||||
private Api api;
|
||||
|
||||
private HomeModel() {
|
||||
api = RxNet.create(Api.class);
|
||||
}
|
||||
|
||||
public static IHomeModel get() {
|
||||
if (instance == null) {
|
||||
synchronized (HomeModel.class) {
|
||||
if (instance == null) {
|
||||
instance = new HomeModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
private val api = RxNet.create(Api::class.java)
|
||||
|
||||
/**
|
||||
* 提交反馈
|
||||
@@ -48,26 +27,21 @@ public class HomeModel extends BaseModel implements IHomeModel {
|
||||
* @param contact
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Single<String> commitFeedback(long uid, String feedbackDesc, String contact) {
|
||||
fun commitFeedback(uid: Long, feedbackDesc: String, contact: String): Single<String> {
|
||||
return api.commitFeedback(
|
||||
String.valueOf(uid),
|
||||
feedbackDesc,
|
||||
contact,
|
||||
AuthModel.get().getTicket()
|
||||
uid.toString(),
|
||||
feedbackDesc,
|
||||
contact,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
.flatMap(new Function<ServiceResult, SingleSource<String>>() {
|
||||
@Override
|
||||
public SingleSource<String> apply(ServiceResult serviceResult) throws Exception {
|
||||
if (serviceResult.isSuccess()) {
|
||||
return Single.just("反馈成功");
|
||||
|
||||
} else {
|
||||
return Single.error(new Throwable(serviceResult.getMessage()));
|
||||
}
|
||||
}
|
||||
})
|
||||
.compose(RxHelper.handleSchedulers());
|
||||
.flatMap { serviceResult ->
|
||||
if (serviceResult.isSuccess) {
|
||||
Single.just("反馈成功")
|
||||
} else {
|
||||
Single.error(Throwable(serviceResult.message))
|
||||
}
|
||||
}
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,49 +51,113 @@ public class HomeModel extends BaseModel implements IHomeModel {
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Single<List<UserInfo>> loadNewUserList(String page,
|
||||
String pageSize) {
|
||||
fun loadNewUserList(
|
||||
page: String,
|
||||
pageSize: String
|
||||
): Single<List<UserInfo>> {
|
||||
return api.loadNewUserList(
|
||||
page,
|
||||
pageSize
|
||||
page,
|
||||
pageSize
|
||||
)
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
.flatMap(listServiceResult -> {
|
||||
if (listServiceResult != null) {
|
||||
if (listServiceResult.isSuccess()) {
|
||||
return Single.just(listServiceResult.getData() != null ?
|
||||
listServiceResult.getData() : new ArrayList<>());
|
||||
} else {
|
||||
return Single.error(new Throwable(listServiceResult.getMessage()));
|
||||
}
|
||||
} else {
|
||||
return Single.error(new Throwable("发生异常"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Single<Integer> getUnreadCount(long uid) {
|
||||
return api.getUnreadCount(uid).flatMap(new Function<ServiceResult<UnReadCountInfo>, SingleSource<Integer>>() {
|
||||
@Override
|
||||
public SingleSource<Integer> apply(ServiceResult<UnReadCountInfo> unReadCountInfoServiceResult) throws Exception {
|
||||
if (unReadCountInfoServiceResult.isSuccess()) {
|
||||
UnReadCountInfo unReadCountInfo = unReadCountInfoServiceResult.getData();
|
||||
if (unReadCountInfo != null) {
|
||||
return Single.just(unReadCountInfoServiceResult.getData().getTotal());
|
||||
} else {
|
||||
return Single.just(0);
|
||||
}
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
.flatMap {
|
||||
if (it.isSuccess) {
|
||||
return@flatMap Single.just(it.data)
|
||||
} else {
|
||||
return Single.just(0);
|
||||
return@flatMap Single.error(Throwable(it.message))
|
||||
}
|
||||
}
|
||||
}).compose(RxHelper.handleSchAndExce());
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
fun getUnreadCount(uid: Long): Single<Int> {
|
||||
return api.getUnreadCount(uid)
|
||||
.flatMap { unReadCountInfoServiceResult ->
|
||||
if (unReadCountInfoServiceResult.isSuccess) {
|
||||
val unReadCountInfo = unReadCountInfoServiceResult.data
|
||||
if (unReadCountInfo != null) {
|
||||
Single.just(unReadCountInfoServiceResult.data?.total ?: 0)
|
||||
} else {
|
||||
Single.just(0)
|
||||
}
|
||||
} else {
|
||||
Single.just(0)
|
||||
}
|
||||
}.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
val homePlay: Single<List<HomePlayInfo>>
|
||||
get() = api.apiHomePlay()
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
|
||||
val homePlayV2: Single<List<HomePlayInfo>>
|
||||
get() = api.apiHomePlayV2()
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
|
||||
val homeTag: Single<List<HomeTagInfo>>
|
||||
get() = api.apiHomeTag(
|
||||
AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
|
||||
fun getHomeTabMap(tabId: String, page: Int, pageSize: Int): Single<List<HomeTabMapInfo>> {
|
||||
return api.apiHomeTabMap(
|
||||
tabId, page.toString(), pageSize.toString(), AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
}
|
||||
|
||||
fun getHomeTabHome(tabId: String): Single<List<HomeTabMapInfo>> {
|
||||
return api.apiHomeTabHome(
|
||||
tabId, AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
}
|
||||
|
||||
suspend fun getHomeBanner(type: String): List<BannerInfo>? =
|
||||
launchRequest {
|
||||
api.apiHomeBanner(
|
||||
type, AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun getHotRoom(pageNum: Int, pageSize: Int): List<HomeRoom>? =
|
||||
launchRequest {
|
||||
api.getHotRoom(pageNum, pageSize)
|
||||
}
|
||||
|
||||
|
||||
val homeConcerns: Single<List<HomeConcernsInfo>>
|
||||
get() = api.apiHomeConcerns(
|
||||
AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
|
||||
val roomShortcut: Single<String>
|
||||
get() = api.apiRoomShortcut(
|
||||
AuthModel.get().currentUid.toString(),
|
||||
CommunityConstant.VERSION_VALID_TYPE,
|
||||
AuthModel.get().ticket
|
||||
)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchedulers())
|
||||
|
||||
private interface Api {
|
||||
/**
|
||||
* 提交反馈
|
||||
*
|
||||
@@ -130,18 +168,20 @@ public class HomeModel extends BaseModel implements IHomeModel {
|
||||
* @return
|
||||
*/
|
||||
@POST("/feedback")
|
||||
Single<ServiceResult> commitFeedback(@Query("uid") String uid,
|
||||
@Query("feedbackDesc") String feedbackDesc,
|
||||
@Query("contact") String contact,
|
||||
@Query("ticket") String ticket);
|
||||
fun commitFeedback(
|
||||
@Query("uid") uid: String,
|
||||
@Query("feedbackDesc") feedbackDesc: String,
|
||||
@Query("contact") contact: String,
|
||||
@Query("ticket") ticket: String
|
||||
): Single<ServiceResult<*>>
|
||||
|
||||
/**
|
||||
* 获取首页tab数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("/room/tag/v3/top")
|
||||
Single<ServiceResult<List<TabInfo>>> getMainTabList();
|
||||
@get:GET("/room/tag/v3/top")
|
||||
val mainTabList: Single<ServiceResult<List<TabInfo>>>
|
||||
|
||||
/**
|
||||
* 获取新人列表
|
||||
@@ -151,8 +191,10 @@ public class HomeModel extends BaseModel implements IHomeModel {
|
||||
* @return
|
||||
*/
|
||||
@GET("/user/list/new")
|
||||
Single<ServiceResult<List<UserInfo>>> loadNewUserList(@Query("page") String page,
|
||||
@Query("pageSize") String pageSize);
|
||||
fun loadNewUserList(
|
||||
@Query("page") page: String,
|
||||
@Query("pageSize") pageSize: String
|
||||
): Single<ServiceResult<List<UserInfo>>>
|
||||
|
||||
/**
|
||||
* 获取互动消息未读数量
|
||||
@@ -161,6 +203,129 @@ public class HomeModel extends BaseModel implements IHomeModel {
|
||||
* @return
|
||||
*/
|
||||
@POST("interactive/unreadCount")
|
||||
Single<ServiceResult<UnReadCountInfo>> getUnreadCount(@Query("uid") long uid);
|
||||
fun getUnreadCount(@Query("uid") uid: Long): Single<ServiceResult<UnReadCountInfo>>
|
||||
|
||||
|
||||
/**
|
||||
* 首页交友扩列
|
||||
*
|
||||
* @return -
|
||||
*/
|
||||
@GET("/home/play")
|
||||
fun apiHomePlay(): Single<ServiceResult<List<HomePlayInfo>>>
|
||||
|
||||
/**
|
||||
* 首页聊天交友
|
||||
*
|
||||
* @return -
|
||||
*/
|
||||
@GET("/home/roomListV2")
|
||||
fun apiHomePlayV2(): Single<ServiceResult<List<HomePlayInfo>>>
|
||||
|
||||
/**
|
||||
* 首页推荐房间标签
|
||||
*
|
||||
* @param uid
|
||||
* @param types
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/tag")
|
||||
fun apiHomeTag(
|
||||
@Query("uid") uid: String,
|
||||
@Query("types") types: String,
|
||||
@Query("ticket") ticket: String
|
||||
): Single<ServiceResult<List<HomeTagInfo>>>
|
||||
|
||||
/**
|
||||
* 首页更多房间
|
||||
*
|
||||
* @param tabId
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @param uid
|
||||
* @param types
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/tab/map")
|
||||
fun apiHomeTabMap(
|
||||
@Query("tabId") tabId: String,
|
||||
@Query("page") page: String,
|
||||
@Query("pageSize") pageSize: String,
|
||||
@Query("uid") uid: String,
|
||||
@Query("types") types: String,
|
||||
@Query("ticket") ticket: String
|
||||
): Single<ServiceResult<List<HomeTabMapInfo>>>
|
||||
|
||||
/**
|
||||
* 首页推荐房间
|
||||
*
|
||||
* @param tabId
|
||||
* @param uid
|
||||
* @param types
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/tab/home")
|
||||
fun apiHomeTabHome(
|
||||
@Query("tabId") tabId: String,
|
||||
@Query("uid") uid: String,
|
||||
@Query("types") types: String,
|
||||
@Query("ticket") ticket: String
|
||||
): Single<ServiceResult<List<HomeTabMapInfo>>>
|
||||
|
||||
/**
|
||||
* 首页Banner
|
||||
*
|
||||
* @param type
|
||||
* @param uid
|
||||
* @param types
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/banner")
|
||||
suspend fun apiHomeBanner(
|
||||
@Query("type") type: String,
|
||||
@Query("uid") uid: String,
|
||||
@Query("types") types: String,
|
||||
@Query("ticket") ticket: String
|
||||
): ServiceResult<List<BannerInfo>>
|
||||
|
||||
/**
|
||||
* 首页热门房间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/hotRoom")
|
||||
suspend fun getHotRoom(
|
||||
@Query("pageNum") pageNum: Int,
|
||||
@Query("pageSize") pageSize: Int
|
||||
): ServiceResult<List<HomeRoom>>
|
||||
|
||||
|
||||
/**
|
||||
* 首页顶部收藏房间列表
|
||||
*
|
||||
* @param uid
|
||||
* @param types
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
@GET("/home/concerns")
|
||||
fun apiHomeConcerns(
|
||||
@Query("uid") uid: String,
|
||||
@Query("types") types: String,
|
||||
@Query("ticket") ticket: String
|
||||
): Single<ServiceResult<List<HomeConcernsInfo>>>
|
||||
|
||||
|
||||
@GET("/room/shortcut/recommend")
|
||||
fun apiRoomShortcut(
|
||||
@Query("uid") uid: String,
|
||||
@Query("types") types: String,
|
||||
@Query("ticket") ticket: String
|
||||
): Single<ServiceResult<String>>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
package com.yizhuan.xchat_android_core.home.model;
|
||||
|
||||
import com.yizhuan.xchat_android_core.base.IModel;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
|
||||
public interface IHomeModel extends IModel {
|
||||
|
||||
/**
|
||||
* 提交反馈
|
||||
*
|
||||
* @param uid
|
||||
* @param feedbackDesc
|
||||
* @param contact
|
||||
* @return
|
||||
*/
|
||||
Single<String> commitFeedback(long uid, String feedbackDesc, String contact);
|
||||
|
||||
/**
|
||||
* 获取新人列表
|
||||
*
|
||||
* @param page
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
Single<List<UserInfo>> loadNewUserList(String page,
|
||||
String pageSize);
|
||||
|
||||
|
||||
Single<Integer> getUnreadCount(long uid);
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.yizhuan.xchat_android_core.bean.response
|
||||
|
||||
data class ListResult<T>(
|
||||
val isSuccess: Boolean,
|
||||
val isRefresh: Boolean,
|
||||
val data: List<T>? = null
|
||||
) {
|
||||
companion object {
|
||||
|
||||
fun <T> success(data: List<T>?, pageNum: Int): ListResult<T> {
|
||||
return ListResult(true, pageNum == 1, data)
|
||||
}
|
||||
|
||||
fun <T> failed(pageNum: Int): ListResult<T> {
|
||||
return ListResult(false, pageNum == 1, null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -78,3 +78,21 @@ fun <T> Single<T>.io2main(): Single<T> {
|
||||
|
||||
}
|
||||
|
||||
suspend inline fun <reified T : Any> launchRequest(
|
||||
crossinline block: suspend () -> ServiceResult<T>
|
||||
): T? {
|
||||
return try {
|
||||
block()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
if (e is IOException) throw Throwable("网络异常,请检查你的网络再试")
|
||||
else throw e
|
||||
}.run {
|
||||
if (isSuccess) {
|
||||
data
|
||||
} else {
|
||||
throw ServerException(message, code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,7 @@ package com.yizhuan.xchat_android_core.community.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UnReadCountInfo implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -20,4 +18,44 @@ public class UnReadCountInfo implements Serializable {
|
||||
private int total;
|
||||
private int reply;
|
||||
private int like;
|
||||
|
||||
public int getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(int comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public int getShare() {
|
||||
return share;
|
||||
}
|
||||
|
||||
public void setShare(int share) {
|
||||
this.share = share;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public int getReply() {
|
||||
return reply;
|
||||
}
|
||||
|
||||
public void setReply(int reply) {
|
||||
this.reply = reply;
|
||||
}
|
||||
|
||||
public int getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(int like) {
|
||||
this.like = like;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user