收藏房间

This commit is contained in:
oujunhui
2020-04-20 20:57:12 +08:00
parent f7f06a3ee9
commit 100e73555c
19 changed files with 138 additions and 54 deletions

View File

@@ -14,6 +14,7 @@ import android.support.v7.widget.AppCompatImageView;
import android.text.Html;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
@@ -95,6 +96,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import cn.sharesdk.framework.Platform;
@@ -147,6 +149,9 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
private ShareDialog shareDialog;
//收藏房间
private String FOLLOW_ROOM_TYPE = "";
//取消收藏房间
public static HomePartyFragment newInstance(long roomUid, boolean isRoomMin) {
HomePartyFragment homePartyFragment = new HomePartyFragment();
@@ -569,6 +574,11 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
roomTitle.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
}
// tvFollowRoom.setVisibility(AvRoomDataManager.get().isRoomOwner()?View.GONE:View.VISIBLE);
FOLLOW_ROOM_TYPE = AvRoomDataManager.get().isRoomFans?"2":"1";
tvFollowRoom.setText(AvRoomDataManager.get().isRoomFans?"已收藏":"收藏");
setIdOnlineData();
}
}
@@ -602,7 +612,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
break;
case R.id.room_back:
((AVRoomActivity) getActivity()).onBackPressed();
(Objects.requireNonNull(getActivity())).onBackPressed();
break;
case R.id.iv_room_share:
shareRoom();
@@ -618,14 +628,21 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi
* 收藏房间
*/
private void followRoom() {
CollectionRoomModel.get().followRoom(String.valueOf(mUserInfo.getErbanNo()))
RoomInfo currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (currentRoomInfo == null){
return;
}
CollectionRoomModel.get().followRoom(FOLLOW_ROOM_TYPE,mTargetRoomUid)
.compose(bindUntilEvent(FragmentEvent.DESTROY))
.doOnError(throwable -> {
toast(throwable.getMessage());
})
.subscribe(s -> {
AvRoomDataManager.get().isRoomFans = AvRoomDataManager.get().isRoomFans?false:true;
FOLLOW_ROOM_TYPE = AvRoomDataManager.get().isRoomFans?"2":"1";
tvFollowRoom.setText(AvRoomDataManager.get().isRoomFans?"已收藏":"收藏");
});
}
public void shareRoom() {

View File

@@ -125,6 +125,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
AvRoomDataManager.get().nick = roomInfo.getNick();
AvRoomDataManager.get().gender = roomInfo.getGender();
AvRoomDataManager.get().avatar = roomInfo.getAvatar();
AvRoomDataManager.get().isRoomFans = roomInfo.isRoomFans();
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_ROOM_LIST_TYPE,
"区分房间类型:" + roomInfo.getRoomTypeLable());

View File

@@ -6,14 +6,20 @@ import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.base.BaseActivity;
import com.yizhuan.erban.home.adapter.CollectionRoomAdapter;
import com.yizhuan.erban.home.bean.CollectionRoomInfo;
import com.yizhuan.erban.home.model.CollectionRoomModel;
import com.yizhuan.erban.ui.relation.AttentionListActivity;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.user.bean.AttentionInfo;
import com.yizhuan.xchat_android_core.user.bean.AttentionItem;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import java.util.List;
@@ -21,7 +27,7 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class CollectionRoomActivity extends BaseActivity {
public class CollectionRoomActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener,BaseQuickAdapter.RequestLoadMoreListener{
@BindView(R.id.recycler_view)
@@ -42,7 +48,12 @@ public class CollectionRoomActivity extends BaseActivity {
ButterKnife.bind(this);
initTitleBar("我收藏的房间");
initRecyclerView();
initSwipRefresh();
swipeRefresh.setOnRefreshListener(this);
}
@Override
protected void onResume() {
super.onResume();
loadData();
}
@@ -54,37 +65,53 @@ public class CollectionRoomActivity extends BaseActivity {
private void initRecyclerView() {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
roomAdapter = new CollectionRoomAdapter();
roomAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
CollectionRoomInfo.FansRoomListBean fansRoomListBean = (CollectionRoomInfo.FansRoomListBean) adapter.getItem(position);
switch (view.getId()){
case R.id.cl_root:
AVRoomActivity.start(CollectionRoomActivity.this,fansRoomListBean.getRoomUid() );
break;
default:
break;
}
}
});
recyclerView.setAdapter(roomAdapter);
}
private void initSwipRefresh() {
swipeRefresh.setOnRefreshListener(() -> loadData());
}
private boolean isLoading = false;
private void loadData() {
if (isLoading) {
return;
}
isLoading = true;
CollectionRoomModel.get().getCollectionRoomList(AuthModel.get().getCurrentUid(),page,pageSize)
.subscribe((serviceResult, throwable) -> {
if (throwable != null) {
swipeRefresh.setRefreshing(false);
} else {
swipeRefresh.setRefreshing(false);
List<CollectionRoomInfo.FansRoomListBean> info = serviceResult.getFansRoomList();
if (ListUtils.isListEmpty(info)) {
showNoData(R.drawable.icon_common_failure, "亲爱的用户,你还没有收藏哦!");
return;
}else {
hideStatus();
}
roomAdapter.setNewData(info);
roomAdapter.notifyDataSetChanged();
swipeRefresh.setRefreshing(false);
isLoading = false;
}
});
}
@Override
public void onLoadMoreRequested() {
}
@Override
public void onRefresh() {
loadData();
}
}

View File

@@ -23,10 +23,13 @@ public class CollectionRoomAdapter extends BaseQuickAdapter<CollectionRoomInfo.F
protected void convert(BaseViewHolder helper, CollectionRoomInfo.FansRoomListBean item) {
helper.setText(R.id.tv_room_name,item.getRoomName())
.setText(R.id.room_id,"ID:"+item.getId())
.setText(R.id.tv_room_online_num,item.getRoomOnlineNum());
.setText(R.id.tv_room_id,"ID:"+item.getRoomUid())
.setText(R.id.tv_room_online_num,item.getRoomOnlineNum() +"");
ImageView imageView = helper.getView(R.id.rriv_room_img);
ImageLoadUtilsV2.loadImage(imageView, item.getRoomAvatar());
helper.addOnClickListener(R.id.cl_root);
}
}

View File

@@ -43,6 +43,15 @@ public class CollectionRoomInfo {
private String roomAvatar;
private String roomName;
private int roomOnlineNum;
private int roomUid;
public int getRoomUid() {
return roomUid;
}
public void setRoomUid(int roomUid) {
this.roomUid = roomUid;
}
public int getId() {
return id;

View File

@@ -53,8 +53,8 @@ public class RoomListFragment extends BaseMvpFragment<IRoomListFragmentView, Roo
@Override
public void onFindViews() {
swipeRefresh = (SwipeRefreshLayout) getView().findViewById(R.id.swipe_refresh);
recyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
swipeRefresh = getView().findViewById(R.id.swipe_refresh);
recyclerView = getView().findViewById(R.id.recycler_view);
}

View File

@@ -52,22 +52,22 @@ public class CollectionRoomModel extends BaseModel {
*
* @return
*/
public Single<String> followRoom(String roomId){
public Single<String> followRoom(String type,long roomUid){
long uid = AuthModel.get().getCurrentUid();
String ticket = AuthModel.get().getTicket();
return api.followRoom(String.valueOf(uid),roomId,ticket)
return api.followRoom(String.valueOf(uid),String.valueOf(roomUid),type,ticket)
.flatMap(new Function<ServiceResult<String>, SingleSource<String>>() {
@Override
public SingleSource<String> apply(ServiceResult<String> stringServiceResult) throws Exception {
if (stringServiceResult.isSuccess()) {
return Single.just("收藏成功");
return Single.just(stringServiceResult.getMessage());
}else {
return Single.error(new Throwable(stringServiceResult.getMessage()));
}
}
})
.doOnSuccess(s -> {
SingleToastUtil.showToast("收藏成功");
})
.compose(RxHelper.handleSchedulers());
}
@@ -89,7 +89,8 @@ public class CollectionRoomModel extends BaseModel {
@POST("fans/fansRoom")
Single<ServiceResult<String>> followRoom(@Query("uid") String uid,
@Query("roomId") String roomId,
@Query("ticket") String ticket);
@Query("roomUid") String roomUid,
@Query("type") String type,
@Query("ticket") String ticket);
}
}

View File

@@ -226,7 +226,7 @@ public class LoginCodeActivity extends BaseLoginAct {
String shuMeiDeviceId = SmAntiFraud.getDeviceId();
AuthModel.get().login(
mPhone,
"123456aa",
"",
smsCode,
yiDunLoginToken,
shuMeiDeviceId)

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<com.yizhuan.erban.common.widget.StatusLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/status_layout"
android:background="@color/white"
android:orientation="vertical"
>
<com.yizhuan.erban.base.TitleBar
@@ -19,13 +19,20 @@
android:layout_below="@id/title_bar"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
<com.yizhuan.erban.common.widget.StatusLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:id="@+id/status_layout">
</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</android.support.v7.widget.RecyclerView>
</com.yizhuan.erban.common.widget.StatusLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</com.yizhuan.erban.common.widget.StatusLayout>
</LinearLayout>

View File

@@ -102,6 +102,8 @@
<color name="primary_disabled">#bdbdbd</color>
<!--字体颜色-->
<color name="text_color_primary">#333333</color>
<color name="text_color_nim_msg_rec">#5F45D6</color>
<color name="text_color_nim_msg_send">#666666</color>
<!-- 列表次要-->
<color name="text_color_secondary">#999999</color><!-- 绑定区服列表主要-->
<!-- 添加关注-->

View File

@@ -4,6 +4,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_root"
android:background="@color/white">
<com.yizhuan.erban.common.widget.RectRoundImageView
@@ -72,7 +73,7 @@
android:id="@+id/tv_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="人在玩"
android:text="人在玩"
android:textColor="@color/color_999999"
android:textSize="@dimen/sp_12"
app:layout_constraintEnd_toEndOf="parent"

View File

@@ -24,6 +24,7 @@ import com.yizhuan.erban.base.BaseMvpFragment;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.community.helper.ShareDynamicHelper;
import com.yizhuan.erban.community.square.adapter.SquareDynamicAdapter;
import com.yizhuan.erban.home.activity.CollectionRoomActivity;
import com.yizhuan.erban.miniworld.activity.AllTopicActivity;
import com.yizhuan.erban.miniworld.activity.TopicMainActivity;
import com.yizhuan.erban.miniworld.adapter.RecommendTopicListAdapter;
@@ -220,7 +221,8 @@ public class SquareDynamicFragment extends BaseMvpFragment<IMiniWorldCategoryVie
"分享动态-区分-动态广场");
new ShareDynamicHelper(getActivity()).share(bean);
} else if (view.getId() == R.id.iv_in_room){
openRoom(bean.getUid());
// openRoom(bean.getUid());
AVRoomActivity.start(mContext,bean.getUid());
}
});

View File

@@ -3,23 +3,26 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.yizhuan.erban.common.widget.StatusLayout
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:focusableInTouchMode="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:focusableInTouchMode="true"
android:focusable="true"
<com.yizhuan.erban.common.widget.StatusLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:id="@+id/status_layout">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent" />
</android.support.v4.widget.SwipeRefreshLayout>
</com.yizhuan.erban.common.widget.StatusLayout>
</com.yizhuan.erban.common.widget.StatusLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.constraint.ConstraintLayout>