空格
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public abstract class BasePresenter<V extends IView> implements IPresenter {
|
||||
protected CompositeDisposable mDisposables = new CompositeDisposable();
|
||||
protected RetrofitClient api = RetrofitClient.getInstance();
|
||||
protected Reference<V> MvpRef;
|
||||
protected Context mContext;
|
||||
|
||||
@Deprecated
|
||||
public BasePresenter(V view) {
|
||||
attachView(view);
|
||||
}
|
||||
|
||||
public BasePresenter(V view, Context context) {
|
||||
attachView(view);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
private void attachView(V view) {
|
||||
MvpRef = new WeakReference<V>(view);
|
||||
}
|
||||
|
||||
protected V getView() {
|
||||
if (MvpRef != null) {
|
||||
return MvpRef.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 主要用于判断IView的生命周期是否结束,防止出现内存泄露状况
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isViewAttach() {
|
||||
return MvpRef != null && MvpRef.get() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachView() {
|
||||
cancelRequest();
|
||||
if (MvpRef != null) {
|
||||
MvpRef.clear();
|
||||
MvpRef = null;
|
||||
}
|
||||
if (api != null) {
|
||||
api = null;
|
||||
}
|
||||
unBindView();
|
||||
}
|
||||
|
||||
|
||||
public void unBindView() {
|
||||
if (MvpRef != null) {
|
||||
MvpRef.clear();
|
||||
}
|
||||
mContext=null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入订阅对象
|
||||
*
|
||||
* @param disposable
|
||||
*/
|
||||
public void addDisposable(Disposable disposable) {
|
||||
mDisposables.add(disposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除订阅对象
|
||||
*
|
||||
* @param disposable
|
||||
*/
|
||||
public void removeDisposable(Disposable disposable) {
|
||||
mDisposables.remove(disposable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消所有请求
|
||||
*/
|
||||
public void cancelRequest() {
|
||||
if (mDisposables != null) {
|
||||
mDisposables.clear(); // clear时网络请求会随即cancel
|
||||
mDisposables = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommentContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getCommentList(List<CircleListBean.LikeList> likeLists);
|
||||
|
||||
}
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void getCommentList(String id);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class CommentPresenter extends BasePresenter<CommentContacts.View> implements CommentContacts.IIndexPre{
|
||||
public CommentPresenter(CommentContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getCommentList(String id) {
|
||||
api.getLikeList(id, new BaseObserver<List<CircleListBean.LikeList>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<CircleListBean.LikeList> likeLists) {
|
||||
MvpRef.get().getCommentList(likeLists);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.AppPay;
|
||||
import com.xscm.moduleutil.bean.BindType;
|
||||
import com.xscm.moduleutil.bean.RechargeBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RechargeDialogContacts {
|
||||
|
||||
public interface View extends IView<Activity> {
|
||||
void setRechargeData(List<RechargeBean> rechargeData);
|
||||
void bindType(BindType bindType);
|
||||
void appPay(AppPay appPay);
|
||||
}
|
||||
|
||||
public interface IRechargePre extends IPresenter {
|
||||
void recharge();//可选充值金额列表
|
||||
void bindType(String userId);
|
||||
void appPay(String user_id,String money,String coin,String type);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.AppPay;
|
||||
import com.xscm.moduleutil.bean.BindType;
|
||||
import com.xscm.moduleutil.bean.RechargeBean;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RechargeDialogPresenter extends BasePresenter<RechargeDialogContacts.View> implements RechargeDialogContacts.IRechargePre{
|
||||
public RechargeDialogPresenter(RechargeDialogContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recharge() {
|
||||
api.recharge(new BaseObserver<List<RechargeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RechargeBean> rechargeBeans) {
|
||||
MvpRef.get().setRechargeData(rechargeBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindType(String userId) {
|
||||
api.bindType(userId, new BaseObserver<BindType>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BindType bindType) {
|
||||
MvpRef.get().bindType(bindType);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appPay(String user_id, String money, String coin, String type) {
|
||||
api.appPay(user_id, money, coin, type, new BaseObserver<AppPay>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(AppPay appPay) {
|
||||
MvpRef.get().appPay(appPay);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RewardGiftContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
void getRewardList(List<RewardUserBean> rewardUserBeanList);
|
||||
|
||||
void getGiftLabel(List<GiftLabelBean> giftLabelBeans);
|
||||
|
||||
void setGiftList(List<RoonGiftModel> roonGiftModels, int type);
|
||||
|
||||
void giveGift();
|
||||
void wallet(WalletBean walletBean);
|
||||
|
||||
void reward_zone();
|
||||
void roomAuctionJoin(RoomAuction.AuctionListBean auctionListBean);
|
||||
void giftPack(List<GiftPackBean> giftPackBean);
|
||||
}
|
||||
|
||||
public interface IIndexPre extends IPresenter {
|
||||
void getRewardList(String id, int page, int page_limit);
|
||||
|
||||
void getGiftLabel(String have_hot);
|
||||
|
||||
void getGiftList(String id, int type);
|
||||
|
||||
void giveGift(String user_id, String gid, String num, String to_uid, String gift_type);
|
||||
|
||||
void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number);
|
||||
|
||||
void wallet();
|
||||
|
||||
void reward_zone(String id,String gift_id,String num,String is_pack);
|
||||
|
||||
void setRoomApply(String room_id, String gift_id,String gift_price);
|
||||
|
||||
void roomAuctionJoin(String auction_id,String user_id, String gift_id, String num,String type);
|
||||
void giftPack();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.xscm.moduleutil.presenter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class RewardGiftPresenter extends BasePresenter<RewardGiftContacts.View> implements RewardGiftContacts.IIndexPre {
|
||||
RewardGiftContacts.View mView;
|
||||
public RewardGiftPresenter(RewardGiftContacts.View view, Context context) {
|
||||
super(view, context);
|
||||
mView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(String id, int page, int page_limit) {
|
||||
api.getRewardList(id, page, page_limit, new BaseObserver<List<RewardUserBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RewardUserBean> rewardUserBeans) {
|
||||
MvpRef.get().getRewardList(rewardUserBeans);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(String have_hot) {
|
||||
api.getGiftLabel(have_hot, new BaseObserver<List<GiftLabelBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftLabelBean> giftLabelBeans) {
|
||||
MvpRef.get().getGiftLabel(giftLabelBeans);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftList(String id, int type) {
|
||||
api.getGiftList(Integer.parseInt(id), new BaseObserver<List<RoonGiftModel>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<RoonGiftModel> roonGiftModels) {
|
||||
MvpRef.get().setGiftList(roonGiftModels, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveGift(String user_id, String gid, String num, String to_uid, String gift_type) {
|
||||
api.giveGift(user_id, gid, num, to_uid, gift_type, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().giveGift();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number) {
|
||||
api.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
if (MvpRef==null){
|
||||
MvpRef = new WeakReference<>(mView);
|
||||
}
|
||||
MvpRef.get().giveGift();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet() {
|
||||
api.wallet(new BaseObserver<WalletBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(WalletBean walletBean) {
|
||||
MvpRef.get().wallet(walletBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reward_zone(String id, String gift_id, String num, String is_pack) {
|
||||
api.reward_zone(id, gift_id, num, is_pack, new BaseObserver<String>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().reward_zone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRoomApply(String room_id, String gift_id, String gift_price) {
|
||||
api.setRoomApply(room_id, gift_id, gift_price, new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
MvpRef.get().reward_zone();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionJoin(String auction_id, String user_id, String gift_id, String num, String type) {
|
||||
api.roomAuctionJoin(auction_id, user_id, gift_id, num, type, new BaseObserver<RoomAuction.AuctionListBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomAuction.AuctionListBean auctionListBean) {
|
||||
MvpRef.get().roomAuctionJoin(auctionListBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giftPack() {
|
||||
api.giftPack(new BaseObserver<List<GiftPackBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
addDisposable(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<GiftPackBean> giftPackBeans) {
|
||||
MvpRef.get().giftPack(giftPackBeans);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user