欢迎页面适配器
package com.bw.zhuangao4mvp_4fuxi.aplash;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;
import com.bumptech.glide.Glide;
import com.bw.zhuangao4mvp_4fuxi.R;
import retrofit2.http.GET;
public class SplashAdapter extends PagerAdapter {
private int[] reslds;
private Context context;
public SplashAdapter(int[] reslds, Context context) {
this.reslds = reslds;
this.context = context;
}
@Override
public int getCount() {
return reslds.length;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
View view=View.inflate(context, R.layout.imase,null);
ImageView imageView=view.findViewById(R.id.ima);
Glide.with(context).load(reslds[position]).into(imageView);
container.addView(view);
return view;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view==object;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((View) object);
}
}
欢迎页面
package com.bw.zhuangao4mvp_4fuxi.aplash;
import androidx.viewpager.widget.ViewPager;
import android.content.Intent;
import android.os.CountDownTimer;
import android.widget.TextView;
import com.blankj.utilcode.util.SPUtils;
import com.bw.lib_mvp.view.acivicty.BaseAciivity;
import com.bw.zhuangao4mvp_4fuxi.R;
public class MainActivity extends BaseAciivity {
private ViewPager rec;
private TextView textmiao;
private SplashAdapter splashAdapter;
private CountDownTimer countDownTimer;
@Override
protected void initData() {
}
@Override
protected void initView() {
rec = (ViewPager) findViewById(R.id.rec);
textmiao = (TextView) findViewById(R.id.textmiao);
int isFirst= SPUtils.getInstance().getInt("isFirst");
if(isFirst<0){
iunActity();
return;
}
int[] mEeslds=new int[]{
R.drawable.age1,
R.drawable.age2,
R.drawable.age3
};
splashAdapter=new SplashAdapter(mEeslds,getApplicationContext());
rec.setAdapter(splashAdapter);
rec.setCurrentItem(0);
rec.postDelayed(new Runnable() {
@Override
public void run() {
countDownTimer=new CountDownTimer(6000,1000) {
@Override
public void onTick(long l) {
int time= (int) (l/1000);
textmiao.setText(time+"秒");
rec.setCurrentItem(time%3);
if(time==1){
rec.postDelayed(new Runnable() {
@Override
public void run() {
textmiao.setText(0+"秒");
rec.setCurrentItem(0);
}
},800);
}
}
@Override
public void onFinish() {
iunActity();
}
};
countDownTimer.start();
}
},500);
}
private void iunActity() {
if(null!=countDownTimer){
countDownTimer.cancel();
}
SPUtils.getInstance().put("isFirst",1);
Intent intent=new Intent(this,MainActivity2.class);
startActivity(intent);
}
@Override
protected int getLayouid() {
return R.layout.activity_main;
}
}
主页面联动
package com.bw.zhuangao4mvp_4fuxi.aplash;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SPUtils;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.bw.zhuangao4mvp_4fuxi.constants.PathUrl;
import com.bw.zhuangao4mvp_4fuxi.fgA.BlankFragmentA;
import com.bw.zhuangao4mvp_4fuxi.fgA.BlankFragmentB;
import com.bw.zhuangao4mvp_4fuxi.fgA.BlankFragmentC;
import com.bw.zhuangao4mvp_4fuxi.fgA.BlankFragmentD;
import com.bw.zhuangao4mvp_4fuxi.fgA.BlankFragmentE;
import com.bw.zhuangao4mvp_4fuxi.gongju.VipFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;
import java.util.ArrayList;
import java.util.List;
@Route(path = PathUrl.Login_Activity)
public class MainActivity2 extends AppCompatActivity {
private ViewPager vip;
private BottomNavigationView bot;
private List<Fragment>fragmentList=new ArrayList<>();
private VipFragment vipFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
vip = (ViewPager) findViewById(R.id.vip);
bot = (BottomNavigationView) findViewById(R.id.bot);
fragmentList.add(new BlankFragmentA());
fragmentList.add(new BlankFragmentB());
fragmentList.add(new BlankFragmentC());
fragmentList.add(new BlankFragmentD());
fragmentList.add(new BlankFragmentE());
vipFragment=new VipFragment(getSupportFragmentManager(), FragmentPagerAdapter.BEHAVIOR_SET_USER_VISIBLE_HINT,fragmentList);
vip.setAdapter(vipFragment);
bot.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.menu1:
vip.setCurrentItem(0);
break;
case R.id.menu2:
vip.setCurrentItem(1);
break;
case R.id.menu3:
vip.setCurrentItem(2);
break;
case R.id.menu4:
vip.setCurrentItem(3);
break;
case R.id.menu5:
jumpLogin();
break;
}
return true;
}
});
vip.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
switch (position){
case 0:
bot.setSelectedItemId(R.id.menu1);
break;
case 1:
bot.setSelectedItemId(R.id.menu2);
break;
case 2:
bot.setSelectedItemId(R.id.menu3);
break;
case 3:
bot.setSelectedItemId(R.id.menu4);
break;
case 4:
bot.setSelectedItemId(R.id.menu5);
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
//登录
public void jumpLogin(){
String token1= SPUtils.getInstance().getString("token1");
if(TextUtils.isEmpty(token1)){
ARouter.getInstance()
.build(PathUrl.Login_LOIn)
.navigation();
}else {
vip.setCurrentItem(5);
}
}
}
两个适配器联动
package com.bw.zhuangao4mvp_4fuxi.gongju;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;
public class TablFragment extends FragmentPagerAdapter {
private List<String>stringList;
private List<Fragment>fragmentList;
public TablFragment(@NonNull FragmentManager fm, int behavior, List<String> stringList, List<Fragment> fragmentList) {
super(fm, behavior);
this.stringList = stringList;
this.fragmentList = fragmentList;
}
@NonNull
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentList.size();
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
return stringList.get(position);
}
}
package com.bw.zhuangao4mvp_4fuxi.gongju;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;
public class VipFragment extends FragmentPagerAdapter {
private List<Fragment>fragmentList;
public VipFragment(@NonNull FragmentManager fm, int behavior, List<Fragment> fragmentList) {
super(fm, behavior);
this.fragmentList = fragmentList;
}
@NonNull
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentList.size();
}
}
切换页面结合
package com.bw.zhuangao4mvp_4fuxi.constants;
public class PathUrl {
public static final String Login_LOIn="/activivty/login";
public static final String REGISER="/activivty/register";
public static final String Login_Activity="/activivty/MainActivity2";
}
关注购物视频联动
package com.bw.zhuangao4mvp_4fuxi.fgA;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.view.BlankFragment1;
import com.bw.zhuangao4mvp_4fuxi.fgB.shangpin.view.BlankFragment2;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.videLa.BlankFragment3;
import com.bw.zhuangao4mvp_4fuxi.gongju.TablFragment;
import com.google.android.material.tabs.TabLayout;
import java.util.ArrayList;
import java.util.List;
public class BlankFragmentA extends Fragment {
private TabLayout tabl;
private ViewPager vip;
private TablFragment tablFragment;
private List<String>stringList=new ArrayList<>();
private List<Fragment>fragmentList=new ArrayList<>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.fragment_blank_a, container, false);
tabl = (TabLayout) inflate.findViewById(R.id.tabl);
vip = (ViewPager)inflate. findViewById(R.id.vip);
stringList.clear();
stringList.add("关注");
stringList.add("购物");
stringList.add("视频");
fragmentList.clear();
fragmentList.add(new BlankFragment1());
fragmentList.add(new BlankFragment2());
fragmentList.add(new BlankFragment3());
tablFragment=new TablFragment(getChildFragmentManager(), FragmentPagerAdapter.BEHAVIOR_SET_USER_VISIBLE_HINT,stringList,fragmentList);
vip.setAdapter(tablFragment);
tabl.setupWithViewPager(vip);
return inflate;
}
}
视频器图片展示
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.adapter;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import java.util.List;
public class VideoAdapter extends BaseQuickAdapter<VideoEntiy, BaseViewHolder> {
public VideoAdapter(int layoutResId, @Nullable List<VideoEntiy> data) {
super(layoutResId, data);
}
@Override
protected void convert(@NonNull BaseViewHolder baseViewHolder, VideoEntiy videoEntiy) {
baseViewHolder.setText(R.id.name,videoEntiy.getAuthname());
ImageView imageView=baseViewHolder.getView(R.id.zhao);
Glide.with(getContext()).load(videoEntiy.getHeadpath()).into(imageView);
}
}
m层
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.model;
import com.bw.lib_common.apis.Apis;
import com.bw.lib_common.base.BaseR;
import com.bw.lib_common.ent.OkHttpResat;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.lib_mvp.model.BaseMdoel;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter.VideoIc;
import java.util.ArrayList;
import io.reactivex.Observable;
import okhttp3.RequestBody;
public class VideoModel extends BaseMdoel<Apis> implements VideoIc.M {
@Override
public Observable<BaseR<ArrayList<VideoEntiy>>> VideoList(int currentPage, int pageSize) {
return Smodel.VideoList(currentPage, pageSize);
}
//关注
@Override
public Observable<BaseR<String>> guanzhu(RequestBody body) {
return Smodel.guanzhu(body);
}
//点赞
@Override
public Observable<BaseR<String>> dainzan(int videoId) {
return Smodel.dainzan(videoId);
}
//取消点赞
@Override
public Observable<BaseR<String>> quxiaodianzan(int videoId) {
return Smodel.quxiaodianzan(videoId);
}
@Override
protected Apis creastsmodel() {
return OkHttpResat.getOkHttpResat()
.getRetrofit().create(Apis.class);
}
}
协议层
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter;
import com.bw.lib_common.base.BaseR;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.lib_mvp.view.BaseView;
import java.util.ArrayList;
import io.reactivex.Observable;
import okhttp3.RequestBody;
public interface VideoIc {
interface M{
Observable<BaseR<ArrayList<VideoEntiy>>> VideoList(int currentPage ,int pageSize);
//关注
Observable<BaseR<String>> guanzhu(RequestBody body);
//点赞
Observable<BaseR<String>> dainzan(int videoId);
//取消点赞
Observable<BaseR<String>> quxiaodianzan(int videoId);
}
interface P{
void getViewpresenter(int currentPage ,int pageSize);
//关注
void getViewpresenterguan(String authName);
//点赞
void getViewpreserendianzan(int videoId);
//取消点赞
void nogetViewpreserendianzan(int videoId );
}
interface V extends BaseView {
void VideogetViewCheng(ArrayList<VideoEntiy>videoEntiys);
void VideogetViewBai(String error);
//关注
void guanzhuCheng(String msg);
void guanzhuBai(String error);
//点赞
void dainzanCheng(String msg);
void dianzanBai(String error);
//取消点赞
void nodainzanCheng(String msg);
void nodianzanBai(String error);
}
}
p层
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter;
import com.bw.lib_common.base.BaseF;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.lib_mvp.presenter.BasePresenter;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.model.VideoModel;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class VideoPresenter extends BasePresenter<VideoIc.V, VideoModel> implements VideoIc.P {
@Override
public void getViewpresenter(int currentPage, int pageSize) {
basemodel.VideoList(currentPage, pageSize)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new BaseF<>())
.subscribe(new Observer<ArrayList<VideoEntiy>>() {
@Override
public void onSubscribe(Disposable d) {
if(d!=null){
disposable.add(d);
}
}
@Override
public void onNext(ArrayList<VideoEntiy> videoEntiys) {
if(isaters&&getview()!=null){
getview().VideogetViewCheng(videoEntiys);
}
}
@Override
public void onError(Throwable e) {
if(isaters&&getview()!=null){
getview().VideogetViewBai(e.getMessage());
}
}
@Override
public void onComplete() {
}
});
}
//关注
@Override
public void getViewpresenterguan(String authName) {
Map<String ,String> map=new HashMap<>();
map.put("authname",authName);
String json=new Gson().toJson(map);
RequestBody body = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), json);
basemodel.guanzhu(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new BaseF<>())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
if(null!=d){
disposable.add(d);
}
}
@Override
public void onNext(String s) {
if(isaters&&null!=getview()){
getview().guanzhuCheng(s);
}
}
@Override
public void onError(Throwable e) {
if(isaters&&null!=getview()){
getview().guanzhuBai(e.getMessage());
}
}
@Override
public void onComplete() {
}
});
}
//点赞
@Override
public void getViewpreserendianzan(int videoId) {
basemodel.dainzan(videoId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new BaseF<>())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
if(null!=d){
disposable.add(d);
}
}
@Override
public void onNext(String s) {
if(isaters&&null!=disposable){
getview().dainzanCheng(s);
}
}
@Override
public void onError(Throwable e) {
if(isaters&&null!=disposable){
getview().dainzanCheng(e.getMessage());
}
}
@Override
public void onComplete() {
}
});
}
//取消点赞
@Override
public void nogetViewpreserendianzan(int videoId) {
basemodel.quxiaodianzan(videoId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new BaseF<>())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
if(null!=d){
disposable.add(d);
}
}
@Override
public void onNext(String s) {
if(isaters&&null!=disposable){
getview().nodainzanCheng(s);
}
}
@Override
public void onError(Throwable e) {
if(isaters&&null!=disposable){
getview().nodainzanCheng(e.getMessage());
}
}
@Override
public void onComplete() {
}
});
}
@Override
protected VideoModel creastbasemodel() {
return new VideoModel();
}
}
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.videLa;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.lib_mvp.view.fragment.BaseMvpFragment;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter.VideoIc;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter.VideoPresenter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import java.util.ArrayList;
import java.util.List;
public class BlankFragment3 extends BaseMvpFragment<VideoPresenter> implements VideoIc.V {
private SpiLog spiLog;
private VideoAdapters videoAdapters;
private SmartRefreshLayout sm;
private List<VideoEntiy>videoEntiyslist=new ArrayList<>();
private RecyclerView rec;
private int a=1,b=10,currentPage=0;
@Override
protected void initData() {
presenter.getViewpresenter(currentPage,b);
}
@Override
protected void initView() {
sm = (SmartRefreshLayout)view. findViewById(R.id.sm);
rec = (RecyclerView) view.findViewById(R.id.rec);
spiLog=new SpiLog(getActivity());//初始化
rec.setLayoutManager(spiLog);//添加自定义布局
videoAdapters=new VideoAdapters(videoEntiyslist);//添加适配器
rec.setAdapter(videoAdapters);//适配器添加到布局中
rec.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
currentPage=spiLog.findFirstCompletelyVisibleItemPosition();//获取ID
StandardGSYVideoPlayer player=
(StandardGSYVideoPlayer) videoAdapters.getViewByPosition(currentPage,R.id.sta);//自动播放
if(null!=player){//判断
player.startPlayLogic();
}
}
});
sm.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
a++;
presenter.getViewpresenter(a,b);
sm.finishLoadMore();
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
a=1;
presenter.getViewpresenter(a,b);
sm.finishRefresh();
}
});
//添加事件ID图标
videoAdapters.addChildClickViewIds(
R.id.guanzhu,//关注
R.id.zan,//点赞
R.id.xiaoxi,//消息
R.id.shou,//收藏
R.id.guankan,//全屏观看
R.id.fenxiang,//分享
R.id.jinruzhibo);//收藏
//SH设置点击事件是设置子主健
videoAdapters.setOnItemChildClickListener(new OnItemChildClickListener() {
@Override
public void onItemChildClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
//获取当前ITEM的视频对象
VideoEntiy videoEntiy = videoAdapters.getData().get(currentPage);
switch (view.getId()){
case R.id.guanzhu://关注
addGuanzhu(videoEntiy);
break;
case R.id.zan://点赞
dianzhan(videoEntiy);
break;
case R.id.xiaoxi://消息
xiaoxi(videoEntiy);
break;
case R.id.shou://收藏
shoucang(videoEntiy);
break;
case R.id.fenxiang://收藏
fenxiang(videoEntiy);
break;
case R.id.guankan://全屏观看
quanping(videoEntiy);
break;
case R.id.jinruzhibo://直播
zhiboguan(videoEntiy);
break;
}
}
/**
* 分享
* @param videoEntiy
*/
private void fenxiang(VideoEntiy videoEntiy) {
onOk("分享下次更新");
}
/**
* 直播
*/
private void zhiboguan(VideoEntiy videoEntiy) {
}
/**
* 全屏观看
*/
private void quanping(VideoEntiy videoEntiy) {
StandardGSYVideoPlayer player = (StandardGSYVideoPlayer) videoAdapters.getViewByPosition(currentPage, R.id.sta);
if(null!=player){
player.setRotateViewAuto(true);
player.startWindowFullscreen(getContext(),false,true);
}
}
/**
* 收藏
*/
private void shoucang(VideoEntiy videoEntiy) {
onOk("敬情期待");
}
/**
* 消息
*/
private void xiaoxi(VideoEntiy videoEntiy) {
onOk("敬情期待");
}
/**
* {//点赞
*/
private void dianzhan(VideoEntiy videoEntiy) {
if(videoEntiy.getDianzan()==0){
presenter.getViewpreserendianzan(videoEntiy.getId());
}else {
presenter.nogetViewpreserendianzan(videoEntiy.getId());
}
}
/**
* //关注
*/
private void addGuanzhu(VideoEntiy videoEntiy) {
presenter.getViewpresenterguan(videoEntiy.getAuthname());
}
});
}
@Override
protected VideoPresenter creastpresenter() {
return new VideoPresenter();
}
@Override
protected int getLayouid() {
return R.layout.fragment_blank3;
}
@Override
public void VideogetViewCheng(ArrayList<VideoEntiy> videoEntiys) {
videoEntiyslist.addAll(videoEntiys);
videoAdapters.notifyDataSetChanged();
}
@Override
public void VideogetViewBai(String error) {
Toast.makeText(getActivity(), "没有数据", Toast.LENGTH_SHORT).show();
}
//关注成功
@Override
public void guanzhuCheng(String msg) {
onOk("关注成功");
VideoEntiy videoEntiy = videoAdapters.getData().get(currentPage);
videoEntiy.setGuanzhu(1);
//采用布局刷新
videoAdapters.notifyItemChanged(currentPage);
}
//关注失败
@Override
public void guanzhuBai(String error) {
Error("关注失败"+error);
}
//点赞成功
@Override
public void dainzanCheng(String msg) {
onOk("点赞成功");
VideoEntiy videoEntiy = videoAdapters.getData().get(currentPage);
videoEntiy.setDianzan(1);
//采用布局刷新
videoAdapters.notifyItemChanged(currentPage);
}
//点赞失败
@Override
public void dianzanBai(String error) {
Error("点赞失败"+error);
}
//取消点赞成功
@Override
public void nodainzanCheng(String msg) {
onOk("取消点赞成功");
VideoEntiy videoEntiy = videoAdapters.getData().get(currentPage);
videoEntiy.setDianzan(0);
//采用布局刷新
videoAdapters.notifyItemChanged(currentPage);
}
//取消点赞失败
@Override
public void nodianzanBai(String error) {
Error("取消点赞失败"+error);
}
}
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.videLa;
import android.content.Context;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;
public class SpiLog extends LinearLayoutManager {
private PagerSnapHelper pagerSnapHelper;
public SpiLog(Context context) {
super(context);
}
@Override
public void onAttachedToWindow(RecyclerView view) {
super.onAttachedToWindow(view);
pagerSnapHelper=new PagerSnapHelper();
pagerSnapHelper.attachToRecyclerView(view);
}
}
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.videLa;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.Rotate;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import com.tencent.liteav.base.util.Rotation;
import java.util.List;
public class VideoAdapters extends BaseMultiItemQuickAdapter<VideoEntiy, BaseViewHolder> {
public VideoAdapters(@Nullable List<VideoEntiy> data) {
super(data);
addItemType(0, R.layout.im_putong);
addItemType(1, R.layout.im_zhibo);
addItemType(2, R.layout.im_quan);
}
@Override
protected void convert(@NonNull BaseViewHolder baseViewHolder, VideoEntiy videoEntiy) {
//获取播放设置参数
StandardGSYVideoPlayer player=baseViewHolder.getView(R.id.sta);
player.setUp(videoEntiy.getVideopath(),false,"");
player.getBackButton().setVisibility(View.GONE);
switch (videoEntiy.getItemType()){
case 0://普通视频
case 2://全屏视频
quan(baseViewHolder,videoEntiy);
break;
case 1://直播
zhibo(baseViewHolder,videoEntiy);
break;
default:
break;
}
}
private void zhibo(BaseViewHolder baseViewHolder, VideoEntiy videoEntiy) {
baseViewHolder.setText(R.id.weizhi,videoEntiy.getAddress()+"");
baseViewHolder.setText(R.id.zuozhe,videoEntiy.getAuthname()+"");
baseViewHolder.setText(R.id.neirong,videoEntiy.getCaption()+"");
TextView paoView =baseViewHolder.getView(R.id.neirong);
paoView.requestFocus();
}
private void quan(BaseViewHolder baseViewHolder, VideoEntiy videoEntiy) {
baseViewHolder.setText(R.id.weizhi,videoEntiy.getAddress()+"");
baseViewHolder.setText(R.id.zuozhe,videoEntiy.getAuthname()+"");
baseViewHolder.setText(R.id.neirong,videoEntiy.getCaption()+"");
TextView paoView =baseViewHolder.getView(R.id.neirong);
paoView.requestFocus();
//是否关注
if(videoEntiy.getGuanzhu()==1){
baseViewHolder.getView(R.id.guanzhu).setVisibility(View.GONE);
}else {
baseViewHolder.getView(R.id.guanzhu).setVisibility(View.VISIBLE);
}
//设置是否点赞
if(videoEntiy.getDianzan()==1){
baseViewHolder.setImageResource(R.id.zan, R.drawable.ic_xihuanred);
}else {
baseViewHolder.setImageResource(R.id.zan, R.drawable.ic_xihuan);
}
//是否收藏
if(videoEntiy.getDianzan()==0){
baseViewHolder.setImageResource(R.id.shou, R.drawable.ic_shoucangyellow);
}else {
baseViewHolder.setImageResource(R.id.shou, R.drawable.ic_shoucang);
}
//关注图片
ImageView guan =baseViewHolder.getView(R.id.tubiao);
Glide.with(getContext()).load(videoEntiy.getHeadpath()).circleCrop().into(guan);
//点赞数量
int dainzan=videoEntiy.getLike_count()|1200;
baseViewHolder.setText(R.id.numzan,dainzan/1000+"W");
//消息
baseViewHolder.setText(R.id.numxiaox,"1.3W");
//收藏数
int cang=videoEntiy.getView_count()|1200;
baseViewHolder.setText(R.id.numshou,cang/1000+"W");
//碟盘旋转
ImageView imageView=baseViewHolder.getView(R.id.ci);
Glide.with(getContext()).load(videoEntiy.getHeadpath()).circleCrop().into(imageView);
ObjectAnimator animator=ObjectAnimator.ofFloat(imageView, "Rotation",0,360);
animator.setDuration(1500);
animator.setRepeatCount(ValueAnimator.INFINITE);
animator.start();
}
}
package com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.view;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.Toast;
import com.bw.lib_common.entiy.VideoEntiy;
import com.bw.lib_mvp.view.fragment.BaseMvpFragment;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.adapter.VideoAdapter;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter.VideoIc;
import com.bw.zhuangao4mvp_4fuxi.fgB.guanzhumvp.presenter.VideoPresenter;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import java.util.ArrayList;
import java.util.List;
public class BlankFragment1 extends BaseMvpFragment<VideoPresenter> implements VideoIc.V {
private int a=1;
private int b=10;
private SmartRefreshLayout sm;
private RecyclerView rec;
private List<VideoEntiy>entiyList=new ArrayList<>();
private VideoAdapter videoAdapter;
@Override
public void VideogetViewCheng(ArrayList<VideoEntiy> videoEntiys) {
entiyList.addAll(videoEntiys);
videoAdapter.notifyDataSetChanged();
}
@Override
public void VideogetViewBai(String error) {
Toast.makeText(getActivity(), "没有数据", Toast.LENGTH_SHORT).show();
}
@Override
public void guanzhuCheng(String msg) {
}
@Override
public void guanzhuBai(String error) {
}
@Override
public void dainzanCheng(String msg) {
}
@Override
public void dianzanBai(String error) {
}
@Override
public void nodainzanCheng(String msg) {
}
@Override
public void nodianzanBai(String error) {
}
@Override
protected void initData() {
presenter.getViewpresenter(a,b);
}
@Override
protected void initView() {
sm = (SmartRefreshLayout)view. findViewById(R.id.sm);
rec = (RecyclerView)view. findViewById(R.id.rec);
rec.setLayoutManager(new GridLayoutManager(getActivity(), 3));
videoAdapter=new VideoAdapter(R.layout.irem,entiyList);
rec.setAdapter(videoAdapter);
sm.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
a++;
presenter.getViewpresenter(a,30);
sm.finishLoadMore();
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
a=1;
entiyList.clear();
presenter.getViewpresenter(a,b);
sm.finishRefresh();
}
});
}
@Override
protected VideoPresenter creastpresenter() {
return new VideoPresenter();
}
@Override
protected int getLayouid() {
return R.layout.fragment_blank1;
}
}
登录
package com.bw.zhuangao4mvp_4fuxi.login.model;
import com.bw.lib_common.apis.Apis;
import com.bw.lib_common.base.BaseR;
import com.bw.lib_common.ent.OkHttpResat;
import com.bw.lib_common.entiy.UserEntiy;
import com.bw.lib_mvp.model.BaseMdoel;
import com.bw.zhuangao4mvp_4fuxi.login.presenter.LoginLc;
import io.reactivex.Observable;
import okhttp3.RequestBody;
public class LoginModel extends BaseMdoel<Apis> implements LoginLc.M {
@Override
public Observable<BaseR<UserEntiy>> login(RequestBody body) {
return creastsmodel().login(body);
}
@Override
protected Apis creastsmodel() {
return OkHttpResat.getOkHttpResat()
.getRetrofit()
.create(Apis.class);
}
}
package com.bw.zhuangao4mvp_4fuxi.login.presenter;
import com.bw.lib_common.base.BaseR;
import com.bw.lib_common.entiy.UserEntiy;
import com.bw.lib_mvp.view.BaseView;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
public interface LoginLc {
interface V extends BaseView {
void LoginCheng(UserEntiy userEntiy);
void LoginBai(String error);
}
interface P{
void Login(String userName, String password);
}
interface M{
Observable<BaseR<UserEntiy>> login( RequestBody body);
}
}
package com.bw.zhuangao4mvp_4fuxi.login.presenter;
import com.bw.lib_common.base.BaseF;
import com.bw.lib_common.entiy.UserEntiy;
import com.bw.lib_mvp.presenter.BasePresenter;
import com.bw.zhuangao4mvp_4fuxi.login.model.LoginModel;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.Map;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.MediaType;
import okhttp3.RequestBody;
public class Loginpresenter extends BasePresenter<LoginLc.V, LoginModel> implements LoginLc.P{
@Override
public void Login(String userName, String password) {
Map<String,String> map=new HashMap<>();
map.put("password",password);
map.put("username",userName);
String json =new Gson().toJson(map);
RequestBody body =RequestBody.create(MediaType.parse("application/json;charset=utf-8"),json);
//请求接口
basemodel.login(body)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMap(new BaseF<>())
.subscribe(new Observer<UserEntiy>() {
@Override
public void onSubscribe(Disposable d) {
if(d!=null){
disposable.add(d);
}
}
@Override
public void onNext(UserEntiy userEntiy) {
if(getview()!=null&&isaters){
getview().LoginCheng(userEntiy);
}
}
@Override
public void onError(Throwable e) {
if(getview()!=null&&isaters){
getview().LoginBai(e.getMessage());
}
}
@Override
public void onComplete() {
}
});
}
@Override
protected LoginModel creastbasemodel() {
return new LoginModel();
}
}
package com.bw.zhuangao4mvp_4fuxi.login.view;
import android.media.metrics.Event;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SPUtils;
import com.bw.lib_common.datbase.evtiy.User;
import com.bw.lib_common.ent.DButils;
import com.bw.lib_common.entiy.UserEntiy;
import com.bw.lib_mvp.view.acivicty.BaseMvpAcitvity;
import com.bw.zhuangao4mvp_4fuxi.R;
import com.bw.zhuangao4mvp_4fuxi.constants.PathUrl;
import com.bw.zhuangao4mvp_4fuxi.login.presenter.LoginLc;
import com.bw.zhuangao4mvp_4fuxi.login.presenter.Loginpresenter;
import org.greenrobot.eventbus.EventBus;
@Route(path = PathUrl.Login_LOIn)
public class LoginAcitivty extends BaseMvpAcitvity<Loginpresenter>implements LoginLc.V {
private EditText editText;
private EditText editText2;
private Button login;
private Button zhuce;
@Override
protected void initData() {
}
@Override
protected void initView() {
editText = (EditText) findViewById(R.id.editText);
editText2 = (EditText) findViewById(R.id.editText2);
login = (Button) findViewById(R.id.login);
zhuce = (Button) findViewById(R.id.zhuce);
//登录
login.setOnClickListener(view -> {
LoginToserver();
});
//注册
zhuce.setOnClickListener(view -> {
ARouter.getInstance()
.build(PathUrl.REGISER)
.navigation();
});
}
//登录方法
private void LoginToserver() {
//获取参数
String username = editText.getText().toString();
String password = editText2.getText().toString();
//判断参数长度
if(TextUtils.isEmpty(username)||TextUtils.isEmpty(password)){
Toast.makeText(this, "请输入账号或密码", Toast.LENGTH_SHORT).show();
return;
}
//请求数据
presenter.Login(username,password);
}
@Override
protected Loginpresenter creastpresenter() {
return new Loginpresenter();
}
@Override
protected int getLayouid() {
return R.layout.activity_login_acitivty;
}
@Override
public void LoginCheng(UserEntiy userEntiy) {
onOk("登录成功");
if(null!=userEntiy){
//存储userid和oken到SP
SPUtils.getInstance().put("userId",userEntiy.getId());
SPUtils.getInstance().put("token",userEntiy.getToken());
//提取用户信息存入数据库
User user=new User();
user.setId(userEntiy.getId());
user.setIcon(userEntiy.getIcon());
user.setNickname(userEntiy.getNickname());
user.setAddress(userEntiy.getAddress());
user.setBirth(userEntiy.getBirth());
user.setPublicName(userEntiy.getPublicName());
//登录成功保存导数据库
DButils.getInstance().adduser(user);
ARouter.getInstance().build(PathUrl.Login_Activity).navigation();
//登录环信
// lohinEmservert(user);
}else {
Toast.makeText(this, "登录成功", Toast.LENGTH_SHORT).show();
ARouter.getInstance().build(PathUrl.Login_Activity).navigation();
}
}
/**
* 登录环信
* @param user
*/
private void lohinEmservert(User user) {
}
@Override
public void LoginBai(String error) {
Toast.makeText(this, "登录失败", Toast.LENGTH_SHORT).show();
}
}
package com.bw.zhuangao4mvp_4fuxi;
import android.app.Application;
import androidx.appcompat.app.AppCompatActivity;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bw.lib_common.ent.DButils;
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
ARouter.openDebug();
ARouter.openLog();
ARouter.init(this);//注意!!!init放在后面
//初始化数据库
DButils.getInstance().init(this);
}
}
Base
package com.bw.lib_common.base;
import androidx.annotation.Nullable;
public class BaseE extends Throwable{
private int code;
protected String message;
public BaseE(int code, String message) {
this.code = code;
this.message = message;
}
@Nullable
@Override
public String getMessage() {
return message;
}
}
package com.bw.lib_common.base;
import androidx.lifecycle.Observer;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.functions.Function;
public class BaseF <T>implements Function<BaseR<T>, ObservableSource<T>> {
@Override
public ObservableSource<T> apply(BaseR<T> tBaseR) throws Exception {
if(tBaseR.getCode()!=200){
return Observable.error(
new BaseE(
tBaseR.getCode(),
tBaseR.getMessage()
)
);
}else {
return Observable.just(tBaseR.getData());
}
}
}
package com.bw.lib_common.base;
public class BaseR <T>{
private int code;
private T data;
private String message;
public BaseR(int code, T data, String message) {
this.code = code;
this.data = data;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
数据库
package com.bw.lib_common.ent;
import android.content.Context;
import android.widget.ImageView;
import com.bw.lib_common.datbase.DaoMaster;
import com.bw.lib_common.datbase.DaoSession;
import com.bw.lib_common.datbase.MeoyDao;
import com.bw.lib_common.datbase.UserDao;
import com.bw.lib_common.datbase.evtiy.Meoy;
import com.bw.lib_common.datbase.evtiy.User;
import java.util.List;
public class DButils {
private DaoSession daoSession;
private UserDao userDao;
private MeoyDao meoyDao;
private DButils (){}
private static DButils dButils=null;
public static DButils getInstance(){
if (dButils==null){
synchronized (DButils.class){
if(dButils==null){
dButils=new DButils();
}
}
}
return dButils;
}
public void init(Context context){
daoSession= DaoMaster.newDevSession(context,"22022a");
userDao=daoSession.getUserDao();
meoyDao=daoSession.getMeoyDao();
}
public void adduser(User user){
if(userDao!=null){
userDao.insert(user);
}
}
public void deleteuser(User user){
if(user!=null){
userDao.delete(user);
}
}
public void updateser(User user){
if(user!=null){
userDao.update(user);
}
}
public User queryuset(int usetld){
User user=null;
if(usetld!=0){
List<User>list=userDao.loadAll();
for (User users:list){
if(users.getId()==usetld){
user=users;
break;
}
}
}
return user;
}
public void addmeoy(Meoy meoy){
if(meoy!=null){
meoyDao.insert(meoy);
}
}
public void deletemeoy(Meoy meoy){
if(meoy!=null){
meoyDao.delete(meoy);
}
}
public void updatemeoy(Meoy meoy){
if(meoy!=null){
meoyDao.update(meoy);
}
}
public Meoy querymeoy(int meyotld){
Meoy meoy=null;
if(meyotld!=0){
List<Meoy>list=meoyDao.loadAll();
for (Meoy meoys:list){
if(meoy.getModey_id()==meyotld){
meoy=meoys;
break;
}
}
}
return meoy;
}
}
package com.bw.lib_mvp.event;
public class Envent {
private int code;
private Object data;
private String masge;
public Envent(int code, Object data, String masge) {
this.code = code;
this.data = data;
this.masge = masge;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getMasge() {
return masge;
}
public void setMasge(String masge) {
this.masge = masge;
}
}
package com.bw.lib_mvp.model;
public abstract class BaseMdoel <S> {
protected S Smodel;
public BaseMdoel() {
Smodel = creastsmodel();
}
protected abstract S creastsmodel();
}
package com.bw.lib_mvp.presenter;
import com.bw.lib_mvp.model.BaseMdoel;
import com.bw.lib_mvp.view.BaseView;
import java.lang.ref.WeakReference;
import io.reactivex.disposables.CompositeDisposable;
public abstract class BasePresenter <V extends BaseView,M extends BaseMdoel>{
private WeakReference<V> weakReference;
protected CompositeDisposable disposable=new CompositeDisposable();
protected boolean isaters=false;
protected M basemodel;
public BasePresenter() {
basemodel = creastbasemodel();
}
public void Chuang(V view){
if(weakReference==null){
weakReference=new WeakReference<>(view);
}
isaters=true;
}
public void Xiao(){
if(weakReference.get()!=null&&weakReference!=null){
weakReference.clear();
weakReference=null;
isaters=false;
}
if(disposable.isDisposed()&&disposable.size()>0&&disposable!=null){
disposable.clear();
disposable.dispose();
}
}
public V getview(){
return weakReference.get()!=null ?weakReference.get():null;
}
protected abstract M creastbasemodel();
}
package com.bw.lib_mvp.view.acivicty;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.bw.lib_mvp.event.Envent;
import com.bw.lib_mvp.presenter.BasePresenter;
import com.bw.lib_mvp.view.BaseView;
import com.jaeger.library.StatusBarUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public abstract class BaseMvpAcitvity<P extends BasePresenter> extends AppCompatActivity implements BaseView {
protected P presenter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayouid());
if(presenter==null){
presenter=creastpresenter();
}
presenter.Chuang(this);
StatusBarUtil.setTranslucent(this);
initView();
initData();
EventBus.getDefault().register(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onResatr(Envent event){
if(event==null|| TextUtils.isEmpty(event.getMasge()))return;
if(event.getMasge().equals(getClass().getSimpleName())){
hasresa(event);
}
}
private void hasresa(Envent event) {
}
@Override
protected void onDestroy() {
super.onDestroy();
if(presenter!=null){
presenter.Xiao();
}
EventBus.getDefault().unregister(this);
}
protected abstract void initData();
protected abstract void initView();
protected abstract P creastpresenter();
protected abstract int getLayouid();
@Override
public void onOk(String msg) {
if(TextUtils.isEmpty(msg))return;
ShiowToast( msg);
}
@Override
public void Error(String error) {
if(TextUtils.isEmpty(error))return;
ShiowToast( error);
}
public void ShiowToast(String masg){
Toast toast=Toast.makeText(this,masg,Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER,0,10);
toast.show();
}
}
package com.bw.lib_mvp.view.fragment;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.bw.lib_mvp.event.Envent;
import com.bw.lib_mvp.presenter.BasePresenter;
import com.bw.lib_mvp.view.BaseView;
import com.jaeger.library.StatusBarUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public abstract class BaseMvpFragment <P extends BasePresenter> extends Fragment implements BaseView {
protected P presenter;
protected View view;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view=inflater.inflate(getLayouid(),null);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if(presenter==null){
presenter=creastpresenter();
}
presenter.Chuang(this);
StatusBarUtil.setTranslucent(getActivity());
initView();
initData();
EventBus.getDefault().register(this);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onResatr(Envent event){
if(event==null|| TextUtils.isEmpty(event.getMasge()))return;
if(event.getMasge().equals(getClass().getSimpleName())){
hasresa(event);
}
}
private void hasresa(Envent event) {
}
@Override
public void onDestroyView() {
super.onDestroyView();
if(presenter!=null){
presenter.Xiao();
}
EventBus.getDefault().unregister(this);
}
protected abstract void initData();
protected abstract void initView();
protected abstract P creastpresenter();
protected abstract int getLayouid();
public void onOk(String msg) {
if(TextUtils.isEmpty(msg))return;
ShiowToast( msg);
}
@Override
public void Error(String error) {
if(TextUtils.isEmpty(error))return;
ShiowToast( error);
}
public void ShiowToast(String masg){
Toast toast=Toast.makeText(getActivity(),masg,Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER,0,10);
toast.show();
}
}