<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/mine/MineAccountManagerPre.java<|end_filename|>
package com.scj.beilu.app.mvp.mine;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.user.entity.UserInfoEntity;
import com.scj.beilu.app.mvp.user.model.IUserDetails;
import com.scj.beilu.app.mvp.user.model.UserDetailsImpl;

/**
 * @author Mingxun
 * @time on 2019/4/12 20:26
 */
public class MineAccountManagerPre extends BaseMvpPresenter<MineAccountManagerPre.MineAccountManagerView> {

    private IUserDetails mUserDetails;

    public MineAccountManagerPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mUserDetails = new UserDetailsImpl(mBuilder);
    }

    public void getUserInfo() {
        onceViewAttached(new ViewAction<MineAccountManagerView>() {
            @Override
            public void run(@NonNull final MineAccountManagerView mvpView) {
                mUserDetails.getUserInfoByToken()
                        .subscribe(new ObserverCallback<UserInfoEntity>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(UserInfoEntity userInfoEntity) {
                                mvpView.onUserInfo(userInfoEntity);
                            }
                        });
            }
        });
    }

    public void bindWxAccount(final String openId) {
        onceViewAttached(new ViewAction<MineAccountManagerView>() {
            @Override
            public void run(@NonNull final MineAccountManagerView mvpView) {
                mUserDetails.bindWxAccount(openId)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onBindResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public interface MineAccountManagerView extends MvpView {
        void onUserInfo(UserInfoEntity userInfo);

        void onBindResult(String result);
    }
}



<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/mine/FeedbackPre.java<|end_filename|>
package com.scj.beilu.app.mvp.mine;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.mine.model.IMine;
import com.scj.beilu.app.mvp.mine.model.MineImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Mingxun
 * @time on 2019/1/12 17:36
 */
public class FeedbackPre extends BaseMvpPresenter<FeedbackPre.FeedbackView> {
    private IMine mIMe;

    public FeedbackPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mIMe = new MineImpl(mBuilder);
    }

    /**
     * 提交反馈
     */

    public void addFeedBack(final String content, final String contact) {
        onceViewAttached(new ViewAction<FeedbackView>() {
            @Override
            public void run(@NonNull final FeedbackView mvpView) {
                Map<String, String> params = new HashMap<>();
                params.put("feedbackContent", content);
                if (contact != null && !(contact.isEmpty())) {
                    params.put("feedbackContact", contact);
                }
                mIMe.addFeedBack(params)
                        .subscribe(new ObserverCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(ResultMsgBean resultMsgBean) {
                                mvpView.onAddFeedBackResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public interface FeedbackView extends MvpView {
        void onAddFeedBackResult(String result);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/fit/FitRecordSexPre.java<|end_filename|>
package com.scj.beilu.app.mvp.fit;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.fit.model.FitRecordImpl;
import com.scj.beilu.app.mvp.fit.model.IFitRecord;

/**
 * @author Mingxun
 * @time on 2019/3/8 13:44
 */
public class FitRecordSexPre extends BaseMvpPresenter<FitRecordSexPre.FitRecordSexView> {

    private IFitRecord mFitRecord;

    public FitRecordSexPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mFitRecord = new FitRecordImpl(mBuilder);
    }

    public void setSex(final int sex) {
        onceViewAttached(new ViewAction<FitRecordSexView>() {
            @Override
            public void run(@NonNull final FitRecordSexView mvpView) {
                mFitRecord.setSex(sex)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {

                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.setResult(resultMsgBean);
                            }
                        });
            }
        });
    }

    public interface FitRecordSexView extends MvpView {
        void setResult(ResultMsgBean result);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/MerchantCoachAlbumListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.merchant;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewStub;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.MerchantAlbumPre;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoCoachPicInfoBean;
import com.scj.beilu.app.ui.preview.PicImagePreviewAct;
import com.scj.beilu.app.ui.merchant.adapter.MerchantCoachAlbumListAdapter;
import com.scj.beilu.app.util.ToastUtils;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/16 17:23
 */
public class MerchantCoachAlbumListFrag extends BaseMvpFragment<MerchantAlbumPre.MerchantAlbumView, MerchantAlbumPre>
        implements MerchantAlbumPre.MerchantAlbumView, OnItemClickListener<MerchantInfoCoachPicInfoBean> {

    private ViewStub mLoading;
    private ViewStub mViewEmpty;
    private LinearLayout mLLEmpty;
    private TextView mTvEmptyHint;

    private MerchantCoachAlbumListAdapter mMerchantCoachAlbumListAdapter;

    private static final String MERCHANT_ID = "merchant_id";
    private static final String COACH_ID = "coach_id";
    private int mMerchantId;
    private int mCoachId;
    private final ArrayList<MerchantInfoCoachPicInfoBean> mAlbumList = new ArrayList<>();

    public static MerchantCoachAlbumListFrag newInstance(int merchantId, int coachId) {
        Bundle args = new Bundle();
        args.putInt(MERCHANT_ID, merchantId);
        args.putInt(COACH_ID, coachId);
        MerchantCoachAlbumListFrag fragment = new MerchantCoachAlbumListFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mMerchantId = arguments.getInt(MERCHANT_ID);
            mCoachId = arguments.getInt(COACH_ID);
        }
    }

    @Override
    public MerchantAlbumPre createPresenter() {
        return new MerchantAlbumPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_merchant_coach_album_list;
    }

    @Override
    public void initView() {
        super.initView();

        mLLEmpty = findViewById(R.id.ll_load_empty_view);

        mMerchantCoachAlbumListAdapter = new MerchantCoachAlbumListAdapter(this);
        mMerchantCoachAlbumListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mMerchantCoachAlbumListAdapter);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getAlbumList(mMerchantId, mCoachId);
    }

    @Override
    public void onAlbumList(ArrayList<MerchantInfoCoachPicInfoBean> albumList) {
        mAlbumList.clear();
        if (albumList.size() == 0) {

            mRecyclerView.setVisibility(View.GONE);
            if (mViewEmpty == null) {
                mViewEmpty = findViewById(R.id.view_stu_empty);
                View inflate = mViewEmpty.inflate();
                TextView tvEmptyHint = inflate.findViewById(R.id.tv_empty_hint);
                tvEmptyHint.setText("暂无数据哦～");
            }
            mViewEmpty.setVisibility(View.VISIBLE);
        } else {
            if (mViewEmpty != null) {
                mViewEmpty.setVisibility(View.GONE);
            }
            mAlbumList.addAll(albumList);
            mRecyclerView.setVisibility(View.VISIBLE);
            mMerchantCoachAlbumListAdapter.setPicInfoBeans(mAlbumList);
        }
    }

    @Override
    public void showLoading(int loading, boolean isShow) {
        if (loading == ShowConfig.LOADING_STATE) {
            if (isShow) {
                mRecyclerView.setVisibility(View.GONE);
                if (mLoading == null) {
                    mLoading = findViewById(R.id.view_stu_loading);
                    mLoading.inflate();
                }
                mLoading.setVisibility(View.VISIBLE);
            } else {
                if (mLoading != null) {
                    mLoading.setVisibility(View.GONE);
                }
                mRecyclerView.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public void showError(int errorCode, String throwableContent) {
        if (mLoading != null) {
            mLoading.setVisibility(View.GONE);
        }
        ToastUtils.showToast(mFragmentActivity, throwableContent);
    }

    @Override
    public void onItemClick(int position, MerchantInfoCoachPicInfoBean entity, View view) {
        //查看大图
        PicImagePreviewAct.startPreview(mFragmentActivity, mAlbumList, position);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/user/UserHomePagePre.java<|end_filename|>
package com.scj.beilu.app.mvp.user;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.support.v4.app.Fragment;

import com.mx.pro.lib.album.AlbumManager;
import com.mx.pro.lib.album.GlideEngine;
import com.mx.pro.lib.album.MimeType;
import com.mx.pro.lib.album.internal.entity.CaptureStrategy;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.share.ShareInfoPre;
import com.scj.beilu.app.mvp.common.share.ShareInfoView;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.FindListBean;
import com.scj.beilu.app.mvp.find.bean.ModifyRecordBean;
import com.scj.beilu.app.mvp.find.model.FindImpl;
import com.scj.beilu.app.mvp.find.model.IFindInfo;
import com.scj.beilu.app.mvp.user.bean.AvatarResult;
import com.scj.beilu.app.mvp.user.bean.UserDetailsBean;
import com.scj.beilu.app.mvp.user.model.IUserDetails;
import com.scj.beilu.app.mvp.user.model.UserDetailsImpl;
import com.scj.beilu.app.ui.user.UserHomePageFrag;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;

import static com.scj.beilu.app.api.Constants.DIRECTORY;

/**
 * @author Mingxun
 * @time on 2019/3/4 18:45
 * 主页操作
 */
public class UserHomePagePre extends ShareInfoPre<UserHomePagePre.UserHomePageView> {

    private IUserDetails mUserDetails;
    private IFindInfo mFind;
    public static final int RESULT_POSITION = -123;
    private final List<FindInfoBean> mFindList = new ArrayList<>();

    public UserHomePagePre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mUserDetails = new UserDetailsImpl(mBuilder);
        mFind = new FindImpl(mBuilder);
    }

    public void getUserInfo(final int userId, final int currentPage) {
        mBuilder.setLoadType(ShowConfig.LOADING_REFRESH);
        onceViewAttached(mvpView -> Observable
                .zip(mUserDetails.getUserDetails(userId),
                        mFind.getUserDynamicList(userId, currentPage),
                        (userDetailsBean, findInfo) -> {
                            mvpView.onUserDetailsResult(userDetailsBean);
                            return findInfo;
                        })
                .subscribe(new BaseResponseCallback<FindListBean>(mBuilder.build(mvpView)) {
                    @Override
                    public void onRequestResult(FindListBean findInfo) {
                        List<FindInfoBean> list = null;
                        try {
                            list = findInfo.getPage().getList();
                            if (currentPage == 0) {
                                mFindList.clear();
                            }
                        } catch (Exception e) {
                            list = new ArrayList<>();
                        } finally {
                            mvpView.onCheckLoadMore(list);
                            mFindList.addAll(list);
                            mvpView.onFindListResult(mFindList);
                        }
                    }
                }));
    }

    public void getLoadMoreDynamicList(final int userId, final int currentPage) {
        mBuilder.setLoadType(ShowConfig.LOADING_REFRESH);
        onceViewAttached(mvpView -> mFind.getUserDynamicList(userId, currentPage)
                .subscribe(new ObserverCallback<FindListBean>(mBuilder.build(mvpView)) {
                    @Override
                    public void onNext(FindListBean findInfo) {
                        List<FindInfoBean> list = findInfo.getPage().getList();
                        if (currentPage == 0) {
                            mFindList.clear();
                        }
                        mvpView.onCheckLoadMore(list);
                        mFindList.addAll(list);
                        mvpView.onFindListResult(mFindList);
                    }
                }));
    }

    public void setAttention(final int userId) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(mvpView -> mFind.setAttentionParams(mFindList, userId)
                .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                    @Override
                    public void onRequestResult(final ResultMsgBean resultMsgBean) {
                        mvpView.onNotifyListChangeResult(resultMsgBean.getResult(), RESULT_POSITION);
                    }
                }));
    }

    public void setLike(final int dynamicId, final int position) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(mvpView -> mFind.setLikeParamsByList(mFindList, dynamicId, position)
                .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                    @Override
                    public void onRequestResult(ResultMsgBean resultMsgBean) {
                        mvpView.onNotifyListChangeResult(resultMsgBean.getResult(), position);
                    }
                }));
    }

    public void modifyRecord(final ModifyRecordBean record, final int position) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(mvpView -> mFind.updateFindDetailsResult(mFindList, position, record)
                .subscribe(new ObserverCallback<Integer>(mBuilder.build(mvpView)) {
                    @Override
                    public void onNext(Integer position1) {
                        mvpView.onModifyResult(position1);
                    }
                }));
    }

    public void startSelectPicture(Fragment fragment) {
        AlbumManager.from(fragment)
                .choose(MimeType.ofImage())
                .showSingleMediaType(true)
                .countable(true)
                .capture(true)
                .captureStrategy(new CaptureStrategy(true, mContext.getPackageName() + ".fileprovider", DIRECTORY))
                .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
                .thumbnailScale(0.85f)
                .imageEngine(new GlideEngine())  // for glide-V4
                .maxOriginalSize(10)
                .autoHideToolbarOnSingleTap(true)
                .forResult(UserHomePageFrag.REQUEST_PICTURE_CODE);
    }

    public void updatePicture(final String path) {
        mBuilder.setLoadType(ShowConfig.LOADING_DIALOG);
        onceViewAttached(mvpView -> mUserDetails.updateBackgroundImg(path)
                .subscribe(new BaseResponseCallback<AvatarResult>(mBuilder.build(mvpView)) {
                    @Override
                    public void onRequestResult(AvatarResult resultMsgBean) {
                        mvpView.onNotifyBackgroundImg(resultMsgBean);
                    }
                }));
    }

    public void getUserInfo(int userId) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(mvpView -> mUserDetails.getUserDetails(userId)
                .subscribe(new BaseResponseCallback<UserDetailsBean>(mBuilder.build(mvpView)) {
                    @Override
                    public void onRequestResult(UserDetailsBean userDetailsBean) {
                        mvpView.onUserDetailsResult(userDetailsBean);
                    }
                }));
    }

    public void delFind(int dynamicId) {
        super.delFind(mFindList, dynamicId);
    }

    public interface UserHomePageView extends ShareInfoView {
        void onUserDetailsResult(UserDetailsBean resultInfo);

        void onFindListResult(List<FindInfoBean> findList);

        void onNotifyListChangeResult(String result, int position);

        void onModifyResult(int position);

        void onNotifyBackgroundImg(AvatarResult result);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/store/ShoppingCartPre.java<|end_filename|>
package com.scj.beilu.app.mvp.store;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.delegate.LoadDelegate;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.store.model.IShoppingCar;
import com.scj.beilu.app.mvp.store.model.ShoppingCarImpl;

/**
 * @author Mingxun
 * @time on 2019/4/1 12:38
 */
public class ShoppingCartPre<View extends ShoppingCartPre.ShoppingCartView> extends BaseMvpPresenter<View> {
    protected IShoppingCar mShoppingCar;
    protected final LoadDelegate.Builder builder;

    public ShoppingCartPre(Context context, @ShowConfig.loading int loadType, @ShowConfig.error int loadErrType) {
        super(context, loadType, loadErrType);

        builder = new LoadDelegate.Builder()
                .setContext(mContext)
                .setCompositeDisposable(mCompositeDisposable);
        mShoppingCar = new ShoppingCarImpl(builder);
    }

    public void getCartCount() {
        onceViewAttached(new ViewAction<View>() {
            @Override
            public void run(@NonNull final View mvpView) {
                mShoppingCar.getCartCount()
                        .subscribe(new ObserverCallback<Integer>(builder.build(mvpView)) {
                            @Override
                            public void onNext(Integer integer) {
                                mvpView.onCartCount(integer);
                            }
                        });
            }
        });
    }

    public interface ShoppingCartView extends MvpView {
        void onCartCount(int count);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/CommentReplyAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/11
 * descriptin:消息回复
 */
public class CommentReplyAdapter extends RecyclerView.Adapter<CommentReplyAdapter.CommentReplyViewHolder> {
    @NonNull
    @Override
    public CommentReplyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        final View view;
        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_reply, parent, false);
        return new CommentReplyViewHolder(view);

    }

    @Override
    public void onBindViewHolder(@NonNull CommentReplyViewHolder holder, int position) {

    }


    @Override
    public int getItemCount() {
        return 2;
    }

    class CommentReplyViewHolder extends BaseViewHolder {
        public CommentReplyViewHolder(View itemView) {
            super(itemView);
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/adapter/LikeAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.mine.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * @author Mingxun
 * @time on 2019/1/14 21:44
 */
public class LikeAdapter extends RecyclerView.Adapter<LikeAdapter.LikeViewHolder> {
    @NonNull
    @Override
    public LikeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_like, parent, false);
        return new LikeViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull LikeViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 10;
    }

    class LikeViewHolder extends BaseViewHolder {


        public LikeViewHolder(View itemView) {
            super(itemView);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/MineFocusPeopleFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.MineFocusPre;
import com.scj.beilu.app.mvp.mine.bean.FocusUserInfoBean;
import com.scj.beilu.app.ui.mine.adapter.MeFocusAdapter;
import com.scj.beilu.app.ui.user.UserInfoHomePageAct;
import com.scj.beilu.app.util.ToastUtils;

import java.util.List;

/**
 * author: SunGuiLan
 * date:2019/3/2
 * descriptin:我关注的人
 */

public class MineFocusPeopleFrag extends BaseMvpFragment<MineFocusPre.MeAttentionView, MineFocusPre>
        implements MineFocusPre.MeAttentionView, OnItemClickListener<FocusUserInfoBean> {

    private RecyclerView mRvMeFocusPeople;
    private MeFocusAdapter mMeFocusAdapter;
    private int mPosition = -1;

    private static final int REQUEST_CODE = 0x001;

    @Override
    public void initView() {
        super.initView();
        mRvMeFocusPeople = findViewById(R.id.rv_me_focus_people);
        mMeFocusAdapter = new MeFocusAdapter(GlideApp.with(mFragmentActivity));
        mRvMeFocusPeople.setAdapter(mMeFocusAdapter);
        mRvMeFocusPeople.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));
        mMeFocusAdapter.setOnItemClickListener(this);
    }

    @Override
    public int getLayout() {
        return R.layout.frag_me_atttention_people;
    }

    @NonNull
    @Override
    public MineFocusPre createPresenter() {
        return new MineFocusPre(mFragmentActivity);
    }


    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getMyFocusNumberList(mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getMyFocusNumberList(mCurrentPage);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onMyFocusNumberList(List<FocusUserInfoBean> focusList) {
        mMeFocusAdapter.setFocusInfoList(focusList);
    }

    @Override
    public void onNotifyListChangeResult(String result) {
        ToastUtils.showToast(mFragmentActivity, result);
        if (mPosition >= 0) {
            mMeFocusAdapter.notifyItemChanged(mPosition);
        }
    }

    @Override
    public void onItemClick(int position, FocusUserInfoBean focusUserInfoBean, View view) {
        switch (view.getId()) {
            case R.id.tv_item_attention:
                mPosition = position;
                getPresenter().setAttentionUser(focusUserInfoBean.getUserId(), position);
                break;
            case R.id.iv_user_avatar:
                Intent intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, focusUserInfoBean.getUserId());
                startActivityForResult(intent, REQUEST_CODE);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            mRefreshLayout.autoRefresh();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/adapter/DescriptionFragAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.course.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.mx.pro.lib.fragmentation.support.SupportFragment;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/20 23:27
 */
public class DescriptionFragAdapter extends FragmentPagerAdapter {

    private List<SupportFragment> mFragments;

    public DescriptionFragAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setFragments(List<SupportFragment> fragments) {
        mFragments = fragments;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments == null ? 0 : mFragments.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/homeaction/HomeActionAct.java<|end_filename|>
package com.scj.beilu.app.ui.home.homeaction;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.NonNull;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.mvp.home.HomeAtionPre;

/**
 * author: SunGuiLan
 * date:2019/2/19
 * descriptin:动作库
 */
public class HomeActionAct extends BaseMvpActivity<HomeAtionPre.HomeActionView, HomeAtionPre> implements HomeAtionPre.HomeActionView {

    public static void startHomeActionAct(Activity activity) {
        Intent intent = new Intent(activity, HomeActionAct.class);
        activity.startActivity(intent);
    }

    @Override
    public int getLayout() {
        return R.layout.act_home_action;
    }

    @NonNull
    @Override
    public HomeAtionPre createPresenter() {
        return new HomeAtionPre();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/MerchantListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.merchant;

import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewStub;
import android.widget.ImageButton;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.MerchantListPre;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoBean;
import com.scj.beilu.app.ui.merchant.adapter.MerchantListAdapter;
import com.scj.beilu.app.widget.ClearEditText;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/13 18:23
 */
public class MerchantListFrag extends BaseMvpFragment<MerchantListPre.MerchantListView, MerchantListPre>
        implements MerchantListPre.MerchantListView, View.OnClickListener, OnItemClickListener<MerchantInfoBean>, TextWatcher {

    private ClearEditText mEtSearchContent;
    private ImageButton mBtnBack;
    private ViewStub mViewEmpty;

    private static final String CITY_NAME = "city_name";

    private String mCityName;
    private String mKeyName;

    private MerchantListAdapter mMerchantListAdapter;

    public static MerchantListFrag newInstance(String cityName) {

        Bundle args = new Bundle();
        args.putString(CITY_NAME, cityName);
        MerchantListFrag fragment = new MerchantListFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mCityName = arguments.getString(CITY_NAME);
        }
    }

    @Override
    public MerchantListPre createPresenter() {
        return new MerchantListPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_merchant_list;
    }

    @Override
    public void initView() {
        super.initView();

        ImmersionBar.with(this)
                .statusBarDarkFont(true,0.2f)
                .titleBar(R.id.top_view)
                .keyboardEnable(true)
                .init();

        mEtSearchContent = findViewById(R.id.et_search_content);
        mBtnBack = findViewById(R.id.btn_back);

        mMerchantListAdapter = new MerchantListAdapter(this);
        mMerchantListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mMerchantListAdapter);

        mBtnBack.setOnClickListener(this);
        mEtSearchContent.addTextChangedListener(this);

        mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(0, 10, 0, 10);
            }
        });
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getMerchantList(mCurrentPage, mKeyName, mCityName);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getMerchantList(mCurrentPage, mKeyName, mCityName);
    }

    @Override
    public void onMerchantList(List<MerchantInfoBean> merchantInfoList) {
        if (merchantInfoList.size() == 0) {
            mRecyclerView.setVisibility(View.GONE);
            if (mViewEmpty == null) {
                mViewEmpty = findViewById(R.id.view_stu_empty);
                View inflate = mViewEmpty.inflate();
                TextView tvEmptyHint = inflate.findViewById(R.id.tv_empty_hint);
                tvEmptyHint.setText("城市开通中～");
            }
            mViewEmpty.setVisibility(View.VISIBLE);
        } else {
            if (mViewEmpty != null) {
                mViewEmpty.setVisibility(View.GONE);
            }
            mRecyclerView.setVisibility(View.VISIBLE);
            mMerchantListAdapter.setMerchantInfoList(merchantInfoList);
        }
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_back:
                mFragmentActivity.onBackPressed();
                break;
        }
    }

    @Override
    public void onItemClick(int position, MerchantInfoBean entity, View view) {
        switch (view.getId()) {
            case R.id.cl_merchant_parent:
                Intent intent = new Intent(mFragmentActivity, MerchantAct.class);
                intent.putExtra(MerchantAct.MERCHANT_ID, entity.getMerchantId());
                startActivity(intent);
                break;
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        mKeyName = s.toString();
        mCurrentPage = 0;
        if (mKeyName.length() == 0) {
            mRefreshLayout.autoRefresh();
        } else {
            getPresenter().searchMerchant(mKeyName, mCityName);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/action/adapter/ActionDetailsContentPagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.action.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.scj.beilu.app.mvp.action.bean.ActionInfoBean;
import com.scj.beilu.app.ui.action.ActionDetailsContentFrag;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/3/18 21:16
 */
public class ActionDetailsContentPagerAdapter extends FragmentStatePagerAdapter {
    private ArrayList<ActionInfoBean> mActionSortInfoBeans;

    public ActionDetailsContentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setActionSortInfoBeans(ArrayList<ActionInfoBean> actionSortInfoBeans) {
        mActionSortInfoBeans = actionSortInfoBeans;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        ActionInfoBean infoBean = mActionSortInfoBeans.get(position);

        return ActionDetailsContentFrag.newInstance(infoBean.getActionId(), infoBean.getActionName());
    }

    @Override
    public int getCount() {
        return mActionSortInfoBeans == null ? 0 : mActionSortInfoBeans.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindDetailsImagePagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;
import com.scj.beilu.app.ui.find.FindDetailsFrag;

import java.util.List;

/**
 * date:2019/2/25
 * descriptin:动态详情的图片适配器
 * {@link FindDetailsFrag}
 */
public class FindDetailsImagePagerAdapter extends PagerAdapter {
    private List<FindImageBean> mFindImageBeanList;
    private GlideRequest<Drawable> mOriginalGlideRequest;
    private GlideRequest<Drawable> mThumbnailGlideRequests;

    private OnItemClickListener mItemClickListener;


    public FindDetailsImagePagerAdapter(GlideRequest<Drawable> originalGlideRequest,
                                        GlideRequest<Drawable> thumbnailGlideRequests) {
        mOriginalGlideRequest = originalGlideRequest;
        mThumbnailGlideRequests = thumbnailGlideRequests;
    }

    public void setFindImageBeanList(List<FindImageBean> findImageBeanList) {
        mFindImageBeanList = findImageBeanList;
        notifyDataSetChanged();
    }

    public void setItemClickListener(OnItemClickListener itemClickListener) {
        mItemClickListener = itemClickListener;
    }

    @Override
    public int getCount() {
        return mFindImageBeanList == null ? 0 : mFindImageBeanList.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, final int position) {
        ImageView imageView = new ImageView(container.getContext());
        imageView.setId(R.id.imageView);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        final FindImageBean imageBean = mFindImageBeanList.get(position);
        mOriginalGlideRequest
                .load(imageBean.getDynamicPicAddr())
                .thumbnail(mThumbnailGlideRequests.load(imageBean.getDynamicPicZip()).centerCrop())
                .centerCrop()
                .into(imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mItemClickListener != null) {
                    mItemClickListener.onItemClick(position, imageBean, view);
                }
            }
        });
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        (container).removeView(container);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/seller/HomeSellerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter.seller;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/14
 * descriptin:
 */
public class HomeSellerAdapter extends RecyclerView.Adapter<HomeSellerAdapter.HomeSellerViewHolder> {
    private OnItemClickListen onItemClickListen;

    public void setOnItemClickListener(OnItemClickListen onItemClickListener) {
        this.onItemClickListen = onItemClickListener;
    }

    public interface OnItemClickListen {
        void onItemClick(View view, int position);
    }

    @NonNull
    @Override
    public HomeSellerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_selller, parent, false);
        return new HomeSellerViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final HomeSellerViewHolder holder, final int position) {
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (onItemClickListen != null)
                    onItemClickListen.onItemClick(holder.itemView, position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return 2;
    }

    class HomeSellerViewHolder extends BaseViewHolder {

        public HomeSellerViewHolder(View itemView) {
            super(itemView);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/SearchFindFrag.java<|end_filename|>
package com.scj.beilu.app.ui.find;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewStub;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.entity.SearchHistoryEntity;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;
import com.scj.beilu.app.mvp.find.bean.ModifyRecordBean;
import com.scj.beilu.app.mvp.find.SearchInfoPre;
import com.scj.beilu.app.mvp.user.bean.RecommendUserInfoBean;
import com.scj.beilu.app.ui.preview.PicImagePreviewAct;
import com.scj.beilu.app.ui.find.adapter.FindInfoListAdapter;
import com.scj.beilu.app.ui.find.adapter.ReAttentionAdapter;
import com.scj.beilu.app.ui.news.adapter.HistoryListAdapter;
import com.scj.beilu.app.ui.user.UserInfoHomePageAct;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.FlowLayoutManager;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/10 18:02
 */
public class SearchFindFrag extends BaseMvpFragment<SearchInfoPre.SearchLoadHistoryView, SearchInfoPre>
        implements SearchInfoPre.SearchLoadHistoryView, OnItemClickListener,
        OnGroupItemClickListener<ArrayList<FindImageBean>>, TextWatcher {

    private EditText mEtSearchContent;
    private TextView mTvCancel;
    private RecyclerView mRvSearchHistoryList;
    private RecyclerView mRvRecommendList;
    private View mLoadingView;
    private LinearLayout mLLEmpty;
    private TextView mTvEmptyHint;
    private ViewStub mLoading;
    private LinearLayout mLlShowHistory;

    private HistoryListAdapter mHistoryListAdapter;
    private ReAttentionAdapter mAttentionAdapter;
    private FindInfoListAdapter mFindInfoListAdapter;

    private int mRecordPosition = -1;
    private static final int REQUEST_CODE = 0x001;
    private int mDynamicIdByIndex;
    private String mKeyName;


    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_find_search;
    }

    @Override
    public void initView() {
        super.initView();
        ImmersionBar.with(this)
                .statusBarDarkFont(true,0.2f)
                .titleBar(R.id.top_view)
                .keyboardEnable(true)
                .init();
        mRvSearchHistoryList = findViewById(R.id.rv_search_list);
        mRvRecommendList = findViewById(R.id.find_search_recycler);
        mEtSearchContent = findViewById(R.id.et_search_content);
        mTvCancel = findViewById(R.id.tv_cancel);
        mLlShowHistory = findViewById(R.id.ll_search_history_view);

        mAttentionAdapter = new ReAttentionAdapter(this);
        mAttentionAdapter.setOnItemClickListener(this);
        mRvRecommendList.setAdapter(mAttentionAdapter);

        mRvRecommendList.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(10, 10, 10, 0);
            }
        });

        FlowLayoutManager flowLayoutManager = new FlowLayoutManager();
        mRvSearchHistoryList.setLayoutManager(flowLayoutManager);
        mRvSearchHistoryList.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(10, 10, 10, 10);
            }
        });

        mHistoryListAdapter = new HistoryListAdapter();
        mRvSearchHistoryList.setAdapter(mHistoryListAdapter);
        mHistoryListAdapter.setItemClickListener(this);

        //***********************************************start search
        mLoading = findViewById(R.id.view_stu_loading);
        mLLEmpty = findViewById(R.id.ll_load_empty_view);
        mTvEmptyHint = findViewById(R.id.tv_empty_hint);

        mFindInfoListAdapter = new FindInfoListAdapter(GlideApp.with(this), mFragmentActivity);
        mFindInfoListAdapter.setOnItemClickListener(this);
        mFindInfoListAdapter.setOnGroupItemClickListener(this);
        mRecyclerView.setAdapter(mFindInfoListAdapter);

        final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
        mRecyclerView.getItemAnimator().setChangeDuration(0);

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            int firstVisibleItem, lastVisibleItem;

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
                lastVisibleItem = layoutManager.findLastVisibleItemPosition();
                //大于0说明有播放
                if (GSYVideoManager.instance().getPlayPosition() >= 0) {
                    //当前播放的位置
                    int position = GSYVideoManager.instance().getPlayPosition();
                    //对应的播放列表TAG
                    if (GSYVideoManager.instance().getPlayTag().equals(FindInfoListAdapter.TAG)
                            && (position < firstVisibleItem || position > lastVisibleItem)) {
                        //如果滑出去了上面和下面就是否，和今日头条一样
                        //是否全屏
                        if (!GSYVideoManager.isFullState(mFragmentActivity)) {
                            GSYVideoManager.releaseAllVideos();
                            mFindInfoListAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });
        mTvEmptyHint.setText("暂无搜索结果");

        mTvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mFragmentActivity.onBackPressed();
            }
        });

        mEtSearchContent.addTextChangedListener(this);
        mRefreshLayout.setVisibility(View.GONE);
        mLlShowHistory.setVisibility(View.VISIBLE);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getCurrentPageData();
    }


    @Override
    public SearchInfoPre createPresenter() {
        return new SearchInfoPre(mFragmentActivity);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().startSearch(mKeyName, mCurrentPage);
    }

    @Override
    public void onSearchHistoryList(List<SearchHistoryEntity> searchHistoryList) {
        mHistoryListAdapter.setHistoryList(searchHistoryList);
    }

    @Override
    public void onUserList(List<RecommendUserInfoBean> userInfoList) {
        mAttentionAdapter.setUserList(userInfoList);
    }

    @Override
    public void onFindListResult(List<FindInfoBean> findList) {

        if (findList.size() == 0) {
            mRecyclerView.setVisibility(View.GONE);
            mLLEmpty.setVisibility(View.VISIBLE);
        } else {
            hideSoftInput();
            mRecyclerView.setVisibility(View.VISIBLE);
            mLLEmpty.setVisibility(View.GONE);
            mFindInfoListAdapter.setFindInfoList(findList);
        }
    }

    @Override
    public void onAttentionResult(String result, int position) {
        ToastUtils.showToast(mFragmentActivity, result);
        mAttentionAdapter.notifyItemChanged(position);
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        Intent intent;

        FindInfoBean findInfo = null;
        if (entity instanceof FindInfoBean) {
            findInfo = (FindInfoBean) entity;
        }
        RecommendUserInfoBean userInfo = null;
        if (entity instanceof RecommendUserInfoBean) {
            userInfo = (RecommendUserInfoBean) entity;
        }

        switch (view.getId()) {
            case R.id.tv_history_tag://历史记录
                SearchHistoryEntity history = (SearchHistoryEntity) entity;
                mEtSearchContent.setText(history.getTagName());
                mEtSearchContent.setSelection(history.getTagName().length());
                break;
            case R.id.tv_item_attention://推荐 点击关注
                getPresenter().setAttention(userInfo.getUserId(), position);
                break;
            case R.id.iv_user_avatar://推荐 点击头像进入用户主页
                intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, (int) userInfo.getUserId());
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.ll_item_find_praise:
                getPresenter().setLike(findInfo.getDynamicId(), position);
                break;
            case R.id.ll_item_find_comment:
            case R.id.tv_item_find_txt:
                mRecordPosition = position;
                GSYVideoManager.releaseAllVideos();
                intent = new Intent(mFragmentActivity, FindDetailsAct.class);
                intent.putExtra(FindDetailsFrag.FIND_ID, findInfo.getDynamicId());
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.ll_item_find_share:
                if (!EventBus.getDefault().isRegistered(this)) {
                    EventBus.getDefault().register(this);
                }
                mRecordPosition = position;
                mDynamicIdByIndex = findInfo.getDynamicId();
                getPresenter().startShareFind(this, findInfo);
                break;
            case R.id.tv_item_find_attention:
                getPresenter().setFocusUser(findInfo.getUserId());
                break;
            case R.id.iv_item_find_avatar:
                intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                int userId = findInfo.getIsOwn() == 0 ? findInfo.getUserId() : -1;
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, userId);
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.iv_item_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, findInfo.getDynamicPic(), position);
                break;
        }
    }

    @Override
    public void onItemClick(int groupPosition, int childPosition, ArrayList<FindImageBean> object, View view) {
        switch (view.getId()) {
            case R.id.iv_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, object, childPosition);
                break;
        }
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onNotifyListChangeResult(String result, int position) {
        ToastUtils.showToast(mFragmentActivity, result);
        if (position != -1) {
            mFindInfoListAdapter.notifyItemChanged(position);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onModifyResult(int position) {
        if (position == mRecordPosition) {
            mFindInfoListAdapter.notifyItemChanged(mRecordPosition);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onAddForResult(int position) {
        //none
    }

    @Override
    public void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume(false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }

    @Override
    public boolean onBackPressedSupport() {
        if (GSYVideoManager.backFromWindowFull(mFragmentActivity)) {
            return true;
        }
        return super.onBackPressedSupport();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            GSYVideoManager.onPause();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
            ModifyRecordBean record = data.getParcelableExtra(FindDetailsFrag.EXTRA_MODIFY_RESULT);
            getPresenter().modifyRecord(record, mRecordPosition);
        }
    }


    @Subscribe
    public void onShareResult(BaseResp resp) {
        getPresenter().setFindShareCount(mDynamicIdByIndex);
    }

    @Override
    public void onFindDel() {
        getPresenter().delFind(mDynamicIdByIndex);
    }

    @Override
    public void onShareCountResult() {
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void onFindDelResult(ResultMsgBean result) {
        mFindInfoListAdapter.notifyItemRemoved(mRecordPosition);
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        mRecordPosition = -1;
    }

    @Override
    public void showLoading(int loading, boolean isShow) {
        if (loading == ShowConfig.LOADING_REFRESH) {
            if (mCurrentPage == 0) {
                if (isShow) {
                    mRecyclerView.setVisibility(View.GONE);
                    if (mLoadingView == null) {
                        mLoadingView = mLoading.inflate();
                    } else {
                        mLoading.setVisibility(View.VISIBLE);
                    }
                } else {
                    if (mLoadingView != null) {
                        mLoading.setVisibility(View.GONE);
                    }
                    mRecyclerView.setVisibility(View.VISIBLE);
                }
            }
        }
    }

    @Override
    public void showError(int errorCode, String throwableContent) {
        if (mLoadingView != null) {
            mLoading.setVisibility(View.GONE);
        }
        ToastUtils.showToast(mFragmentActivity, throwableContent);
    }


    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {

        if (s.length() == 0) {
            mLlShowHistory.setVisibility(View.VISIBLE);
            mRefreshLayout.setVisibility(View.GONE);
        } else {
            mLlShowHistory.setVisibility(View.GONE);
            mRefreshLayout.setVisibility(View.VISIBLE);
            mCurrentPage = 0;
            mKeyName = s.toString();
            getPresenter().startSearch(mKeyName);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/widget/ItemLayout.java<|end_filename|>
package com.scj.beilu.app.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.scj.beilu.app.R;

/**
 * @author Mingxun
 * @time on 2019/1/12 16:30
 */
public class ItemLayout extends LinearLayout {

    TextView leftTextView;
    TextView rightTextView;

    public ItemLayout(Context context) {
        this(context, null);
    }

    public ItemLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ItemLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        setGravity(Gravity.CENTER);
        LayoutInflater.from(context).inflate(R.layout.layout_item, this, true);
        leftTextView = findViewById(R.id.tv_item_left_text);
        rightTextView = findViewById(R.id.tv_item_right_text);

        if (attrs != null) {
            TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ItemLayout);
            if (array.hasValue(R.styleable.ItemLayout_left_text)) {
                if (leftTextView != null) {
                    setLeftText(array.getString(R.styleable.ItemLayout_left_text));
                }
            }

            if (array.hasValue(R.styleable.ItemLayout_right_text_hint)) {
                if (rightTextView != null) {
                    rightTextView.setHint(array.getString(R.styleable.ItemLayout_right_text_hint));
                }
            }
            if (array.hasValue(R.styleable.ItemLayout_right_text)) {
                if (rightTextView != null) {
                    setRightText(array.getString(R.styleable.ItemLayout_right_text));

                }
            }
            array.recycle();

        }
        setBackgroundColor(ContextCompat.getColor(context, android.R.color.white));
    }

    public void setLeftText(CharSequence text) {
        if (leftTextView != null) {
            leftTextView.setText(text);
        }
    }


    public void setRightText(CharSequence text) {
        if (rightTextView != null) {
            rightTextView.setText(text);
        }
    }


    public String getLeftText() {
        return leftTextView.getText().toString();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindDetailsCommentViewHolder.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.graphics.drawable.Drawable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.find.bean.FindCommentBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/23 17:50
 */
class FindDetailsCommentViewHolder extends BaseViewHolder {
    private RecyclerView mRvCommentList;
    private FindDetailsParentCommentAdapter mCommentAdapter;

    public FindDetailsCommentViewHolder(View itemView, GlideRequest<Drawable> glideRequest) {
        super(itemView);
        mRvCommentList = findViewById(R.id.rv_comment_list);
        mRvCommentList.addItemDecoration(new DividerItemDecoration(mRvCommentList.getContext(), DividerItemDecoration.VERTICAL));

        mCommentAdapter = new FindDetailsParentCommentAdapter(glideRequest);
        mRvCommentList.setAdapter(mCommentAdapter);

    }

    public void setBindData(List<FindCommentBean> commentList) {
        mCommentAdapter.setFindCommentBeans(commentList);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/act/AddedPreviewActivity.java<|end_filename|>
package com.scj.beilu.app.ui.act;


import android.content.Intent;
import android.net.Uri;
import android.support.v4.view.ViewPager;
import android.widget.Button;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.album.listener.OnFragmentInteractionListener;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseSupportAct;
import com.scj.beilu.app.ui.preview.adapter.AddedPreviewPagerAdapter;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/2/20 17:54
 */
public class AddedPreviewActivity extends BaseSupportAct implements OnFragmentInteractionListener {

    private ViewPager mViewPager;
    private AddedPreviewPagerAdapter mAddedPreviewPagerAdapter;

    public static final String POSITION = "position";
    public static final String IMAGE_LIST = "IMAGE_LIST";
    public static final String IMAGE_PATH_LIST = "image_path_list";
    private ArrayList<Uri> mUriArrayList;
    private ArrayList<String> mPathArrayList;

    @Override
    public int getLayout() {
        return R.layout.act_added_preview;
    }

    @Override
    protected void initView() {
        super.initView();
        ImmersionBar.with(this)
                .statusBarColor(android.R.color.black)
                .init();
        mViewPager = findViewById(R.id.view_pager);
        Button btnDel = findViewById(R.id.btn_del);
        Intent intent = getIntent();
        if (intent == null) return;
        mUriArrayList = intent.getParcelableArrayListExtra(IMAGE_LIST);
        mPathArrayList = intent.getStringArrayListExtra(IMAGE_PATH_LIST);
        int position = intent.getIntExtra(POSITION, 0);

        mAddedPreviewPagerAdapter = new AddedPreviewPagerAdapter(getSupportFragmentManager());
        mAddedPreviewPagerAdapter.setImagePathList(mUriArrayList);
        mViewPager.setAdapter(mAddedPreviewPagerAdapter);

        mViewPager.setCurrentItem(position, false);

        btnDel.setOnClickListener(view -> {
            int currentItem = mViewPager.getCurrentItem();
            mAddedPreviewPagerAdapter.remove(currentItem);
            mPathArrayList.remove(currentItem);
            mAddedPreviewPagerAdapter.notifyDataSetChanged();
            if (mAddedPreviewPagerAdapter.getCount() == 0) {
                setBackResult();
            }
        });

    }

    @Override
    public void onClick() {
        setBackResult();
    }

    private void setBackResult() {
        Intent data = new Intent();
        data.putParcelableArrayListExtra(IMAGE_LIST, mUriArrayList);
        data.putStringArrayListExtra(IMAGE_PATH_LIST, mPathArrayList);
        setResult(RESULT_OK, data);
        finish();
    }

    @Override
    public void onBackPressedSupport() {
        setBackResult();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/find/FindDetailsPre.java<|end_filename|>
package com.scj.beilu.app.mvp.find;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.share.ShareInfoPre;
import com.scj.beilu.app.mvp.common.share.ShareInfoView;
import com.scj.beilu.app.mvp.find.bean.FindCommentBean;
import com.scj.beilu.app.mvp.find.bean.FindCommentListBean;
import com.scj.beilu.app.mvp.find.bean.FindDetailsBean;
import com.scj.beilu.app.mvp.find.bean.FindDetailsViewBean;
import com.scj.beilu.app.mvp.find.model.FindImpl;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;

/**
 * @author Mingxun
 * @time on 2019/2/22 21:04
 */
public class FindDetailsPre extends ShareInfoPre<FindDetailsPre.FindDetailsView> {
    private FindImpl mFindImpl;
    private int mDynamicId;
    private FindDetailsBean mFindDetailsBean = null;
    private FindCommentListBean mCommentListBean = null;
    private final List<FindCommentBean> mFindCommentList = new ArrayList<>();

    public FindDetailsPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mFindImpl = new FindImpl(mBuilder);
    }

    public void getDetails(int dynamicId) {
        mDynamicId = dynamicId;
        onceViewAttached(new ViewAction<FindDetailsView>() {
            @Override
            public void run(@NonNull final FindDetailsView mvpView) {

                Observable.merge(mFindImpl.getFindDetailsById(mDynamicId), mFindImpl.getFindCommentList(mDynamicId, 0))
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean result) {
                                try {
                                    if (result instanceof FindCommentListBean) {
                                        mCommentListBean = (FindCommentListBean) result;
                                        List<FindCommentBean> commentBeanList = mCommentListBean.getList();
                                        mFindCommentList.clear();
                                        mvpView.onCheckLoadMore(commentBeanList);
                                        mFindCommentList.addAll(commentBeanList);
                                    } else if (result instanceof FindDetailsBean) {
                                        mFindDetailsBean = (FindDetailsBean) result;
                                    }
                                    FindDetailsViewBean findDetailsInfo = new FindDetailsViewBean(mFindDetailsBean, mCommentListBean);
                                    mvpView.onDetailsResult(findDetailsInfo, mFindCommentList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public void getCommentLit(final int currentPage) {
        onceViewAttached(new ViewAction<FindDetailsView>() {
            @Override
            public void run(@NonNull final FindDetailsView mvpView) {
                mFindImpl.getFindCommentList(mDynamicId, currentPage)
                        .subscribe(new BaseResponseCallback<FindCommentListBean>(
                                mBuilder.build(mvpView)
                        ) {
                            @Override
                            public void onRequestResult(FindCommentListBean findCommentListBean) {
                                List<FindCommentBean> findCommentBeanList =
                                        findCommentListBean.getPage().getList();
                                if (currentPage == 0) {
                                    mFindCommentList.clear();
                                }
                                mvpView.onCheckLoadMore(findCommentBeanList);
                                mFindCommentList.addAll(findCommentBeanList);
                                mvpView.onCommentListResult(mFindCommentList);
                            }
                        });

            }
        });
    }

    /**
     * 直接通过FindDetailsBean 获取动态id
     */
    public void setLike() {
        if (mFindDetailsBean == null) return;
        onceViewAttached(new ViewAction<FindDetailsView>() {
            @Override
            public void run(@NonNull final FindDetailsView mvpView) {
                mFindImpl.setLikeParamsByDetails(mFindDetailsBean)
                        .subscribe(new BaseResponseCallback<FindDetailsBean>(
                                mBuilder.build(mvpView)
                        ) {
                            @Override
                            public void onRequestResult(FindDetailsBean detailsBean) {
                                mvpView.onUpdateLikeResult(detailsBean);
                            }
                        });
            }
        });
    }

    public void setAttention() {
        if (mFindDetailsBean == null) return;
        onceViewAttached(new ViewAction<FindDetailsView>() {
            @Override
            public void run(@NonNull final FindDetailsView mvpView) {
                mFindImpl.setAttentionParamsByDetails(mFindDetailsBean)
                        .subscribe(new BaseResponseCallback<FindDetailsBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(final FindDetailsBean resultMsgBean) {
                                try {
                                    mvpView.onUpdateAttentionResult(resultMsgBean);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }


    public void checkIsOwn(final FindCommentBean commentInfo) {
        onceViewAttached(new ViewAction<FindDetailsView>() {
            @Override
            public void run(@NonNull final FindDetailsView mvpView) {
                mFindImpl.checkIsOwn(commentInfo)
                        .subscribe(new ObserverCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(ResultMsgBean s) {
                                mvpView.showEditTextHint(s);
                            }
                        });
            }
        });
    }

    public void createComment(final FindCommentBean comment,
                              final String comContent,
                              final int position) {
        if (mFindDetailsBean == null && mCommentListBean == null) return;
        onceViewAttached(new ViewAction<FindDetailsView>() {
            @Override
            public void run(@NonNull final FindDetailsView mvpView) {
                mFindImpl.createCommentParams(mDynamicId, comment, comContent, mFindCommentList, position).
                        subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onCommentResult(resultMsgBean.getResult(), mFindCommentList);
                            }
                        });

            }
        });
    }

    public void delFind(int dynamicId) {
        super.delFind(null, dynamicId);
    }

    public interface FindDetailsView extends ShareInfoView {
        void onDetailsResult(FindDetailsViewBean findDetailsInfo, List<FindCommentBean> commentList);

        void onCommentListResult(List<FindCommentBean> commentList);

        void onUpdateLikeResult(FindDetailsBean result);

        void onUpdateAttentionResult(FindDetailsBean result);

        void onCommentResult(String result, List<FindCommentBean> commentList);

        void showEditTextHint(ResultMsgBean result);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/NewsAttentionListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.news;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewStub;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.NewsAttentionPre;
import com.scj.beilu.app.mvp.news.bean.NewsAuthorInfoBean;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.ui.act.LoginAndRegisterAct;
import com.scj.beilu.app.ui.news.adapter.NewsAttentionAuthorListAdapter;
import com.scj.beilu.app.ui.news.adapter.NewsAuthorListAdapter;
import com.scj.beilu.app.ui.news.adapter.NewsListAdapter;
import com.scj.beilu.app.widget.DividerItemDecorationToPadding;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/5/11 17:43
 */
public class NewsAttentionListFrag extends BaseMvpFragment<NewsAttentionPre.NewsAttentionView, NewsAttentionPre>
        implements NewsAttentionPre.NewsAttentionView, OnItemClickListener {

    private ViewStub view_stu_not_attention_list, view_stu_attention_list;
    private View mViewAttentionList, mViewNoAttentionList;

    private NewsAuthorListAdapter mNewsRecommendAuthorListAdapter;
    private NewsAttentionAuthorListAdapter mNewsAttentionAuthorListAdapter;
    private NewsListAdapter mNewsListAdapter;

    private final int REQUEST_MY_ATTENTION_AUTHOR = 0xb1;
    private final int REQUEST_NEWS_CONTENT = 0xb2;

    private boolean isHaveAttention;


    @Override
    public NewsAttentionPre createPresenter() {
        return new NewsAttentionPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_news_my_attention_list;
    }

    @Override
    public void initView() {
        super.initView();
        view_stu_not_attention_list = findViewById(R.id.view_stu_not_attention_list);
        view_stu_attention_list = findViewById(R.id.view_stu_attention_list);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().checkUserIsLogin(0);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getRecommendNewsList(isHaveAttention ? 2 : 1, mCurrentPage);
    }

    @Override
    public void userIsLogin(boolean login, int id) {
        if (login) {
            getPresenter().getAttentionList();
        } else {
            getPresenter().getRecommendAuthorList();
        }
    }

    @Override
    public void onAttentionList(List<NewsAuthorInfoBean> authorInfoList) {
        initAttentionList();
        mNewsAttentionAuthorListAdapter.setAuthorInfoList(authorInfoList);
    }

    @Override
    public void onInitRecommendView() {
        initRecommendList();
    }

    @Override
    public void onNotAttentionList(List<NewsAuthorInfoBean> authorInfoList) {
        mNewsRecommendAuthorListAdapter.setAuthorInfoList(authorInfoList);
    }

    @Override
    public void onNewsList(List<NewsInfoBean> newsInfoList) {
        mNewsListAdapter.setNewsListEntityList(newsInfoList);
    }

    /**
     * 在有关注的情况下
     */
    private void initAttentionList() {
        isHaveAttention = true;
        view_stu_not_attention_list.setVisibility(View.GONE);
        if (mViewAttentionList == null) {
            mViewAttentionList = view_stu_attention_list.inflate();
            RecyclerView recyAuthorList = mViewAttentionList.findViewById(R.id.recycler_news_attention_list);
            RecyclerView recycler_news_author_content_list = mViewAttentionList.findViewById(R.id.recycler_news_author_content_list);

            mNewsAttentionAuthorListAdapter = new NewsAttentionAuthorListAdapter(this);
            mNewsAttentionAuthorListAdapter.setOnItemClickListener(this);
            recyAuthorList.setAdapter(mNewsAttentionAuthorListAdapter);

            mNewsListAdapter = new NewsListAdapter(mFragmentActivity, GlideApp.with(this));
            mNewsListAdapter.setOnItemClickListener(this);
            recycler_news_author_content_list.setAdapter(mNewsListAdapter);
            recycler_news_author_content_list.addItemDecoration(new DividerItemDecorationToPadding(mFragmentActivity, DividerItemDecoration.VERTICAL));
        } else {
            view_stu_attention_list.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 在没有关注的情况下
     */
    private void initRecommendList() {
        isHaveAttention = false;
        view_stu_attention_list.setVisibility(View.GONE);
        if (mViewNoAttentionList == null) {
            mViewNoAttentionList = view_stu_not_attention_list.inflate();
            RecyclerView recycler_news_recommend_author = mViewNoAttentionList.findViewById(R.id.recycler_news_recommend_author);
            RecyclerView recycler_news_recommend_list = mViewNoAttentionList.findViewById(R.id.recycler_news_recommend_list);
            mViewNoAttentionList.findViewById(R.id.fl_news_author_more)
                    .setOnClickListener(view -> startAuthorInfo(NewsAuthorInfoAct.LOAD_RECOMMEND_AUTHOR));

            mNewsRecommendAuthorListAdapter = new NewsAuthorListAdapter(this);
            mNewsRecommendAuthorListAdapter.setOnItemClickListener(this);
            recycler_news_recommend_author.setAdapter(mNewsRecommendAuthorListAdapter);
            recycler_news_recommend_author.getItemAnimator().setChangeDuration(0);

            mNewsListAdapter = new NewsListAdapter(mFragmentActivity, GlideApp.with(this));
            mNewsListAdapter.setOnItemClickListener(this);
            recycler_news_recommend_list.setAdapter(mNewsListAdapter);
            recycler_news_recommend_list.addItemDecoration(new DividerItemDecorationToPadding(mFragmentActivity, DividerItemDecoration.VERTICAL));
        } else {
            view_stu_not_attention_list.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onNotifyAttentionStatus(int position) {
        mNewsRecommendAuthorListAdapter.notifyItemChanged(position);
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        NewsAuthorInfoBean authorInfoBean = null;
        Intent intent;
        if (entity instanceof NewsAuthorInfoBean) {
            authorInfoBean = (NewsAuthorInfoBean) entity;
        }
        switch (view.getId()) {
            case R.id.tv_news_recommend_attention_status:
                getPresenter().setAttentionAuthor(authorInfoBean.getUserId());
                break;
            case R.id.iv_news_author_avatar:
                startAuthorInfo(authorInfoBean.getUserId());
                break;
            case R.id.iv_news_my_attention_author:
                if (position == 3) {
                    startAuthorInfo(NewsAuthorInfoAct.LOAD_ATTENTION_AUTHOR);
                } else {
                    startAuthorInfo(authorInfoBean.getUserId());
                }
                break;
            case R.id.item_news_view_id:
                NewsInfoBean infoBean = (NewsInfoBean) entity;
                intent = new Intent(mFragmentActivity, NewsDetailsAct.class);
                intent.putExtra(NewsDetailsAct.EXTRA_CONTENT, infoBean);
                startActivityForResult(intent, REQUEST_NEWS_CONTENT);
                break;
        }
    }

    private void startAuthorInfo(int authorId) {
        Intent intent = new Intent(mFragmentActivity, NewsAuthorInfoAct.class);
        intent.putExtra(NewsAuthorInfoAct.AUTHOR_ID, authorId);
        startActivityForResult(intent, REQUEST_MY_ATTENTION_AUTHOR);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if ((requestCode == REQUEST_MY_ATTENTION_AUTHOR || requestCode == REQUEST_NEWS_CONTENT) && resultCode == RESULT_OK) {
            mRefreshLayout.autoRefresh();
        } else if (requestCode == LoginAndRegisterAct.LOGIN_REQUEST) {
            mRefreshLayout.autoRefresh();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/mine/MinePre.java<|end_filename|>
package com.scj.beilu.app.mvp.mine;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.mine.bean.TotalCountBean;
import com.scj.beilu.app.mvp.mine.model.IMine;
import com.scj.beilu.app.mvp.mine.model.MineImpl;
import com.scj.beilu.app.mvp.user.entity.UserInfoEntity;

import io.reactivex.Observable;

/**
 * @author Mingxun
 * @time on 2019/2/20 11:09
 */
public class MinePre extends BaseMvpPresenter<MinePre.MineView> {
    private IMine mMine;

    public MinePre(Context context) {
        super(context, ShowConfig.NONE, ShowConfig.ERROR_TOAST);
        mMine = new MineImpl(mBuilder);
    }

    public void getMineInfo() {
        onceViewAttached(new ViewAction<MineView>() {
            @Override
            public void run(@NonNull final MineView mvpView) {
                Observable.merge(mMine.getUserInfoByToken(), mMine.getTotalCount())
                        .subscribe(new ObserverCallback<Object>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(Object o) {
                                if (o instanceof UserInfoEntity) {
                                    mvpView.onUserInfo((UserInfoEntity) o);
                                } else if (o instanceof TotalCountBean) {
                                    mvpView.onTotalCount((TotalCountBean) o);
                                }
                            }
                        });

//                Observable.zip(mMine.getUserInfoByToken(), mMine.getTotalCount(), new BiFunction<UserInfoEntity, TotalCountBean, TotalCountBean>() {
//                    @Override
//                    public TotalCountBean apply(UserInfoEntity userInfoEntity, TotalCountBean totalCountBean) throws Exception {
//                        totalCountBean.setUserInfoEntity(userInfoEntity);
//                        return totalCountBean;
//                    }
//                }).subscribe(new ObserverCallback<TotalCountBean>(mBuilder.build(mvpView)) {
//                    @Override
//                    public void onNext(TotalCountBean totalCountBean) {
//                        mvpView.onTotalCount(totalCountBean);
//                    }
//                });

            }
        });
    }


    public interface MineView extends MvpView {
        //        void onTotalCount(TotalCountBean totalCountBean);
        void onUserInfo(UserInfoEntity userInfo);

        void onTotalCount(TotalCountBean totalCountBean);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/base/BaseMvpActivity.java<|end_filename|>
package com.scj.beilu.app.base;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;

import com.mx.pro.lib.mvp.MvpActivity;
import com.mx.pro.lib.mvp.MvpPresenter;
import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.R;
import com.scj.beilu.app.ui.act.LoginAndRegisterAct;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.AppToolbar;

import permissions.dispatcher.PermissionRequest;

public abstract class BaseMvpActivity<V extends MvpView, P extends MvpPresenter<V>>
        extends MvpActivity<V, P> implements MvpView, Toolbar.OnMenuItemClickListener {
    private ProgressDialog mProgressDialog;
    protected AppToolbar mAppToolbar;

    @Override
    protected void initView() {
        super.initView();
        mAppToolbar = findViewById(R.id.toolbar);

        if (mAppToolbar != null) {
            mAppToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBackPressedSupport();
                }
            });
            mAppToolbar.setOnMenuItemClickListener(this);
        }

    }

    @Override
    public void showError(int errorCode, String throwableContent) {
        if (errorCode == ShowConfig.ERROR_TOAST) {
            ToastUtils.showToast(this, throwableContent);
        } else if (errorCode == ShowConfig.ERROR_USER) {
            Intent intent = new Intent(this, LoginAndRegisterAct.class);
            startActivityForResult(intent, LoginAndRegisterAct.LOGIN_REQUEST);
        }

        if (mProgressDialog != null && mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
    }

    @Override
    public void showLoading(int loading, boolean isShow) {
        switch (loading) {
            case ShowConfig.LOADING_DIALOG:
                if (isShow) {
                    if (mProgressDialog == null) {
                        mProgressDialog = ProgressDialog.show(this, "",
                                "请求中，请稍后...");
                        mProgressDialog.setCancelable(true);
                    } else {
                        mProgressDialog.show();
                    }
                } else {
                    mProgressDialog.dismiss();
                }
                break;
            case ShowConfig.LOADING_STATE:
                break;
            case ShowConfig.LOADING_REFRESH:
                break;
        }

    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        return false;
    }


    protected void showRationaleDialog(@StringRes int messageResId, final PermissionRequest request) {
        new AlertDialog.Builder(this)
                .setPositiveButton(R.string.button_allow, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(@NonNull DialogInterface dialog, int which) {
                        request.proceed();
                    }
                })
                .setNegativeButton(R.string.button_deny, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(@NonNull DialogInterface dialog, int which) {
                        request.cancel();
                    }
                })
                .setCancelable(false)
                .setMessage(messageResId)
                .show();
    }

    @Override
    public void userIsLogin(boolean login, int viewId) {
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/FindInfoAttentionListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.find;

import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewStub;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.find.FindInfoPre;
import com.scj.beilu.app.mvp.find.FindInfoView;
import com.scj.beilu.app.mvp.find.bean.EventAttentionNotify;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.ModifyRecordBean;
import com.scj.beilu.app.mvp.user.bean.RecommendUserInfoBean;
import com.scj.beilu.app.ui.preview.PicImagePreviewAct;
import com.scj.beilu.app.ui.find.adapter.FindInfoListAdapter;
import com.scj.beilu.app.ui.find.adapter.ReAttentionAdapter;
import com.scj.beilu.app.ui.user.UserInfoHomePageAct;
import com.scj.beilu.app.util.ToastUtils;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

/**
 * 发现-热门/关注
 */
public class FindInfoAttentionListFrag extends BaseMvpFragment<FindInfoView, FindInfoPre<FindInfoView>>
        implements FindInfoView, OnItemClickListener, OnGroupItemClickListener<ArrayList<FindImageBean>> {

    private int mRecordPosition = -1;
    private static final int REQUEST_CODE = 0x001;
    private int mDynamicIdByIndex;
    private ViewStub mFindInfoAttentionEmpty;
    private RecyclerView mRvRecommendList;

    private static final String FIND_INDEX = "INDEX";
    private int mIndex = 0;

    private FindInfoListAdapter mFindInfoListAdapter;
    private ReAttentionAdapter mAttentionAdapter;

    private AttentionListener mAttentionListener;
    private int mAttentionUserId = -1;

    public void setAttentionListener(AttentionListener attentionListener) {
        mAttentionListener = attentionListener;
    }

    public static FindInfoAttentionListFrag newInstance(int position) {

        Bundle args = new Bundle();
        args.putInt(FIND_INDEX, position);
        FindInfoAttentionListFrag fragment = new FindInfoAttentionListFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mIndex = arguments.getInt(FIND_INDEX, mIndex);
            if (!EventBus.getDefault().isRegistered(this)) {
                EventBus.getDefault().register(this);
            }
        }
    }

    @Override
    public FindInfoPre createPresenter() {
        return new FindInfoPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_find_main_rv;
    }

    @Override
    public void initView() {
        super.initView();
        mRecyclerView.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));
        mFindInfoListAdapter = new FindInfoListAdapter(GlideApp.with(this), mFragmentActivity);
        mFindInfoListAdapter.setOnItemClickListener(this);
        mFindInfoListAdapter.setOnGroupItemClickListener(this);
        mRecyclerView.setAdapter(mFindInfoListAdapter);
        final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
        mRecyclerView.getItemAnimator().setChangeDuration(0);

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            int firstVisibleItem, lastVisibleItem;

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
                lastVisibleItem = layoutManager.findLastVisibleItemPosition();
                //大于0说明有播放
                if (GSYVideoManager.instance().getPlayPosition() >= 0) {
                    //当前播放的位置
                    int position = GSYVideoManager.instance().getPlayPosition();
                    //对应的播放列表TAG
                    if (GSYVideoManager.instance().getPlayTag().equals(FindInfoListAdapter.TAG)
                            && (position < firstVisibleItem || position > lastVisibleItem)) {
                        //如果滑出去了上面和下面就是否，和今日头条一样
                        //是否全屏
                        if (!GSYVideoManager.isFullState(mFragmentActivity)) {
                            GSYVideoManager.releaseAllVideos();
                            mFindInfoListAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        if (mIndex == 0) {
            getPresenter().getHotList(mCurrentPage);
        } else {
            getPresenter().getAttentionFindList(mCurrentPage);
        }
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        if (mIndex == 0) {
            getPresenter().getHotList(mCurrentPage);
        } else {
            getPresenter().getAttentionFindList(mCurrentPage);
        }
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onFindListResult(List<FindInfoBean> findList) {

        if (mIndex == 0) {
            //none
        } else {

            //是否显示推荐
            if (findList.size() == 0) {

                if (mFindInfoAttentionEmpty == null) {
                    mFindInfoAttentionEmpty = findViewById(R.id.view_find_info_attention_empty);
                    View inflate = mFindInfoAttentionEmpty.inflate();
                    mRvRecommendList = inflate.findViewById(R.id.find_search_recycler);
                    mAttentionAdapter = new ReAttentionAdapter(this);
                    mAttentionAdapter.setOnItemClickListener(this);
                    mRvRecommendList.setAdapter(mAttentionAdapter);

                    mRvRecommendList.addItemDecoration(new RecyclerView.ItemDecoration() {
                        @Override
                        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                            super.getItemOffsets(outRect, view, parent, state);
                            outRect.set(10, 10, 10, 0);
                        }
                    });
                }
                mFindInfoAttentionEmpty.setVisibility(View.VISIBLE);
                getPresenter().getRecommendUserList();
            } else {
                if (mFindInfoAttentionEmpty != null) {
                    mFindInfoAttentionEmpty.setVisibility(View.GONE);
                    mRecyclerView.setVisibility(View.VISIBLE);
                }
            }

        }

        mFindInfoListAdapter.setFindInfoList(findList);

    }

    @Override
    public void onUserList(List<RecommendUserInfoBean> userInfoList) {
        mRecyclerView.setVisibility(View.GONE);
        mAttentionAdapter.setUserList(userInfoList);
    }

    @Override
    public void onAttentionResult(String result, int position) {
        ToastUtils.showToast(mFragmentActivity, result);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onNotifyListChangeResult(String result, int position) {

        if (mAttentionListener != null && mAttentionUserId != -1) {
            mAttentionListener.onAttention(mIndex, mAttentionUserId);
            mAttentionUserId = -1;
        }

        if (result != null) {
            ToastUtils.showToast(mFragmentActivity, result);
        }

        if (position != -1) {
            mFindInfoListAdapter.notifyItemChanged(position);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onModifyResult(int position) {
        if (position == mRecordPosition) {
            mFindInfoListAdapter.notifyItemChanged(mRecordPosition);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onAddForResult(int position) {
        mFindInfoListAdapter.notifyDataSetChanged();
        mRecyclerView.smoothScrollToPosition(position);
    }


    @Override
    public void onItemClick(int position, Object object, View view) {
        Intent intent;

        FindInfoBean entity = null;
        if (object instanceof FindInfoBean) {
            entity = (FindInfoBean) object;
            if (entity.getDynamicId() == 0 && view.getId() != R.id.iv_item_find_pic) {
                ToastUtils.showToast(mFragmentActivity, "文件正在上传中，请稍后再试");
                return;
            }
        }


        RecommendUserInfoBean userInfo = null;
        if (object instanceof RecommendUserInfoBean) {
            userInfo = (RecommendUserInfoBean) object;
        }

        switch (view.getId()) {

            case R.id.tv_item_attention://推荐 点击关注
                getPresenter().setAttention(userInfo.getUserId(), position);
                break;
            case R.id.iv_user_avatar://推荐 点击头像进入用户主页
                intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, (int) userInfo.getUserId());
                startActivityForResult(intent, REQUEST_CODE);
                break;

            case R.id.ll_item_find_praise:
                getPresenter().setLike(entity.getDynamicId(), position);
                break;
            case R.id.ll_item_find_comment:
            case R.id.tv_item_find_txt:
                mRecordPosition = position;
                GSYVideoManager.releaseAllVideos();
                intent = new Intent(mFragmentActivity, FindDetailsAct.class);
                intent.putExtra(FindDetailsFrag.FIND_ID, entity.getDynamicId());
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.ll_item_find_share:
                if (!EventBus.getDefault().isRegistered(this)) {
                    EventBus.getDefault().register(this);
                }
                mRecordPosition = position;
                mDynamicIdByIndex = entity.getDynamicId();
                getPresenter().startShareFind(this, entity);
                break;
            case R.id.tv_item_find_attention://设置关注状态:

                int attentionUserId = entity.getUserId();
                mAttentionUserId = attentionUserId;
                getPresenter().setFocusUser(attentionUserId);
                break;
            case R.id.iv_item_find_avatar:
                intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                int userId = entity.getIsOwn() == 0 ? entity.getUserId() : -1;
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, userId);
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.iv_item_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, entity.getDynamicPic(), position);
                break;

        }

    }

    @Override
    public void onItemClick(int groupPosition, int childPosition, ArrayList<FindImageBean> picList, View view) {
        switch (view.getId()) {
            case R.id.iv_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, picList, childPosition);
                break;
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume(false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }

    @Override
    public boolean onBackPressedSupport() {
        if (GSYVideoManager.backFromWindowFull(mFragmentActivity)) {
            return true;
        }
        return super.onBackPressedSupport();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            GSYVideoManager.onPause();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            ModifyRecordBean record = data.getParcelableExtra(FindDetailsFrag.EXTRA_MODIFY_RESULT);
            getPresenter().modifyRecord(record, mRecordPosition);
        }
    }


    @Subscribe
    public void onShareResult(BaseResp resp) {
        getPresenter().setFindShareCount(mDynamicIdByIndex);
    }

    @Override
    public void onFindDel() {
        getPresenter().delFind(mDynamicIdByIndex);
    }

    @Override
    public void onShareCountResult() {
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void onFindDelResult(ResultMsgBean result) {
        mFindInfoListAdapter.notifyItemRemoved(mRecordPosition);
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        mRecordPosition = -1;
    }

    @Override
    public void onSupportInvisible() {
        super.onSupportInvisible();
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void notifyAttention(EventAttentionNotify notify) {
        if (notify.actionAttentionIndex == 1) {
            mCurrentPage = 0;
            getPresenter().getAttentionFindList(mCurrentPage);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/news/NewsDetailsFragPre.java<|end_filename|>
package com.scj.beilu.app.mvp.news;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.share.ShareInfoPre;
import com.scj.beilu.app.mvp.common.share.ShareInfoView;
import com.scj.beilu.app.mvp.news.bean.CommentCountBean;
import com.scj.beilu.app.mvp.news.bean.NewsDetailsBean;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.mvp.news.model.INewsInfo;
import com.scj.beilu.app.mvp.news.model.NewsInfoImpl;

/**
 * @author Mingxun
 * @time on 2019/1/29 16:12
 */
public class NewsDetailsFragPre extends ShareInfoPre<NewsDetailsFragPre.NewsDetailsView> {

    private INewsInfo mINews;

    public NewsDetailsFragPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mINews = new NewsInfoImpl(mBuilder);
    }

    public void getDetailsById(final int newsId) {
        onceViewAttached(new ViewAction<NewsDetailsView>() {
            @Override
            public void run(@NonNull final NewsDetailsView mvpView) {
                mINews.getNewsDetailsById(newsId)
                        .subscribe(new BaseResponseCallback<NewsDetailsBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(NewsDetailsBean newsDetailsBean) {
                                mvpView.onNewsInfo(newsDetailsBean.getNewsDetail());
                            }
                        });
            }
        });
    }

    public void crateComment(final int newsId, final String content) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(new ViewAction<NewsDetailsView>() {
            @Override
            public void run(@NonNull final NewsDetailsView mvpView) {
                mINews.setParamsCreateComment(newsId, content)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onCommentResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public void getCommentCount(final int newsId) {
        onceViewAttached(new ViewAction<NewsDetailsView>() {
            @Override
            public void run(@NonNull final NewsDetailsView mvpView) {
                mINews.getCommentCountByNewsId(newsId)
                        .subscribe(new BaseResponseCallback<CommentCountBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(CommentCountBean commentCountBean) {
                                mvpView.onCommentCountResult(commentCountBean.getNewsCommentCount());
                            }
                        });
            }
        });
    }

    public void setAttentionAction(final int newsUserId, final int isFocus) {
        onceViewAttached(new ViewAction<NewsDetailsView>() {
            @Override
            public void run(@NonNull final NewsDetailsView mvpView) {
                mINews.setAttentionParams(newsUserId, isFocus)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onAttentionResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    /**
     * 收藏动作
     *
     * @param newsId        资讯Id
     * @param collectStatus 状态设置 1 0
     */
    public void setCollectAction(final int newsId, final int collectStatus) {
        onceViewAttached(new ViewAction<NewsDetailsView>() {
            @Override
            public void run(@NonNull final NewsDetailsView mvpView) {
                mINews.setNewsCollectAction(newsId, collectStatus)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onCollectResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public interface NewsDetailsView extends ShareInfoView {
        void onNewsInfo(NewsInfoBean infoBean);

        void onCommentResult(String result);

        void onCommentCountResult(int count);

        void onAttentionResult(String result);

        void onCollectResult(String msg);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/store/ShoppingCartInfoPre.java<|end_filename|>
package com.scj.beilu.app.mvp.store;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.store.entity.GoodsShoppingCarInfoBean;
import com.scj.beilu.app.mvp.store.model.ShoppingCarImpl;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/1 17:11
 */
public class ShoppingCartInfoPre extends ShoppingCartPre<ShoppingCartInfoPre.ShoppingCartInfoView> {

    private ShoppingCarImpl mShoppingCar;

    public ShoppingCartInfoPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mShoppingCar = new ShoppingCarImpl(builder);
    }


    public void getCartList() {
        onceViewAttached(new ViewAction<ShoppingCartInfoView>() {
            @Override
            public void run(@NonNull final ShoppingCartInfoView mvpView) {
                mShoppingCar.getCartListByToken()
                        .subscribe(new ObserverCallback<List<GoodsShoppingCarInfoBean>>(builder.build(mvpView)) {
                            @Override
                            public void onNext(List<GoodsShoppingCarInfoBean> goodsShoppingCarInfoBeans) {
                                mvpView.onCartListResult(goodsShoppingCarInfoBeans);
                            }
                        });
            }
        });
    }

    public void modifyGoodsNum(final int goodsNum, final int position) {
        onceViewAttached(new ViewAction<ShoppingCartInfoView>() {
            @Override
            public void run(@NonNull final ShoppingCartInfoView mvpView) {
                mShoppingCar.modifyCartNum(goodsNum, position)
                        .subscribe(new ObserverCallback<Integer>(builder.build(mvpView)) {
                            @Override
                            public void onNext(Integer integer) {
                                mvpView.modifyResult(position);
                            }
                        });
            }
        });
    }

    public void setSelectAll(final boolean isAll) {
        onceViewAttached(new ViewAction<ShoppingCartInfoView>() {
            @Override
            public void run(@NonNull final ShoppingCartInfoView mvpView) {
                mShoppingCar.setSelectAll(isAll)
                        .subscribe(new ObserverCallback<Integer>(builder.build(mvpView)) {
                            @Override
                            public void onNext(Integer integer) {
                                mvpView.onSelectCountResult(integer);
                            }
                        });
            }
        });
    }

    public void setSelectSingle(final int position) {
        onceViewAttached(new ViewAction<ShoppingCartInfoView>() {
            @Override
            public void run(@NonNull final ShoppingCartInfoView mvpView) {
                mShoppingCar.setSelectSingle(position)
                        .subscribe(new ObserverCallback<Integer>(builder.build(mvpView)) {
                            @Override
                            public void onNext(Integer integer) {
                                mvpView.onSelectCountResult(integer);
                            }
                        });
            }
        });
    }

    public void delCart() {
        onceViewAttached(new ViewAction<ShoppingCartInfoView>() {
            @Override
            public void run(@NonNull final ShoppingCartInfoView mvpView) {
                mShoppingCar.delCart()
                        .subscribe(new ObserverCallback<Integer>(builder.build(mvpView)) {
                            @Override
                            public void onNext(Integer integer) {
                                mvpView.onSelectCountResult(integer);
                            }
                        });
            }
        });
    }

    public interface ShoppingCartInfoView extends ShoppingCartPre.ShoppingCartView {

        void onCartListResult(List<GoodsShoppingCarInfoBean> cartList);

        void modifyResult(int position);

        void onSelectCountResult(Integer count);

    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/fit/adapter/FitRecordImgListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.fit.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgInfoBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/14 17:48
 */
public class FitRecordImgListAdapter extends RecyclerView.Adapter<FitRecordImgListAdapter.ImgListViewHolder> {

    private List<FitRecordImgInfoBean> mFitRecordImgInfoList;

    private GlideRequest<Drawable> mOriginalRequests;
    private GlideRequest<Drawable> mThumbnailRequest;
    private int mViewSize;
    private int mTotalCount;

    private OnItemClickListener<FitRecordImgInfoBean> mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener<FitRecordImgInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public FitRecordImgListAdapter(GlideRequests glideRequests, Context context) {
        mOriginalRequests = glideRequests.asDrawable().centerCrop();
        mThumbnailRequest = glideRequests.asDrawable().centerCrop();
        mViewSize = context.getResources().getDimensionPixelSize(R.dimen.grid_expected_size);
    }

    public void setTotalCount(int totalCount) {
        mTotalCount = totalCount;
    }

    public void setFitRecordImgInfoList(List<FitRecordImgInfoBean> fitRecordImgInfoList) {
        mFitRecordImgInfoList = fitRecordImgInfoList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ImgListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_fit_record_img, parent, false);
        view.post(new Runnable() {
            @Override
            public void run() {
                mViewSize = view.getWidth();
            }
        });
        return new ImgListViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ImgListViewHolder holder, int position) {
        FitRecordImgInfoBean imgInfoBean = mFitRecordImgInfoList.get(position);

        mOriginalRequests.load(imgInfoBean.getPicOrgAddr())
                .override(mViewSize)
                .thumbnail(mThumbnailRequest.load(imgInfoBean.getPicComAddr()).override(mViewSize))
                .into(holder.mIvImg);

        //显示透明度，并且显示图片总数量
        int index = position + 1;
        if (getItemCount() != 1 && (index == getItemCount())) {
            holder.mLlCount.setVisibility(View.VISIBLE);
            holder.mTvImgCount.setText(String.valueOf(mTotalCount));
            holder.mTvImgCount.setVisibility(View.VISIBLE);
            holder.mIvTranslucence.setVisibility(View.VISIBLE);
        } else {
            holder.mLlCount.setVisibility(View.GONE);
            holder.mIvTranslucence.setVisibility(View.GONE);
        }
    }

    @Override
    public int getItemCount() {
        if (mFitRecordImgInfoList == null) {
            return 0;
        } else if (mFitRecordImgInfoList.size() >= 3) {
            return 3;
        } else {
            return mFitRecordImgInfoList.size();
        }
    }

    class ImgListViewHolder extends BaseViewHolder {

        private ImageView mIvImg;
        private ImageView mIvTranslucence;
        private TextView mTvImgCount;
        private LinearLayout mLlCount;

        public ImgListViewHolder(View itemView) {
            super(itemView);
            mIvImg = findViewById(R.id.iv_fit_record_img);
            mIvTranslucence = findViewById(R.id.iv_fit_record_translucence);
            mTvImgCount = findViewById(R.id.tv_fit_record_img_count);
            mLlCount = findViewById(R.id.ll_fit_record_count);

            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    FitRecordImgInfoBean imgInfoBean = mFitRecordImgInfoList.get(getAdapterPosition());
                    if (mOnItemClickListener != null && imgInfoBean != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), imgInfoBean,
                                ((getAdapterPosition() + 1) == getItemCount()) ? null : v);
                    }
                }
            });
        }
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/MerchantPhotoPreviewManagerFrag.java<|end_filename|>
package com.scj.beilu.app.ui.merchant;

import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.common.bean.PicPreviewBean;
import com.scj.beilu.app.mvp.merchant.MerchantPicPreviewManagerPre;
import com.scj.beilu.app.mvp.merchant.bean.MerchantPicInfoBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantPicTypeBean;
import com.scj.beilu.app.ui.merchant.adapter.MerchantPicPreviewManagerListAdapter;
import com.scj.beilu.app.ui.preview.adapter.PicPreviewPagerAdapter;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/13 18:26
 */
public class MerchantPhotoPreviewManagerFrag extends BaseMvpFragment<MerchantPicPreviewManagerPre.MerchantPicPreViewManagerView, MerchantPicPreviewManagerPre>
        implements MerchantPicPreviewManagerPre.MerchantPicPreViewManagerView, OnItemClickListener, ViewPager.OnPageChangeListener {

    private ViewPager view_pager_merchant_photo_preview;

    private int mMerchantId;
    private int mParentPosition;
    private int mChildPosition;
    private ArrayList<PicPreviewBean> mImagePathList;
    private MerchantPicPreviewManagerListAdapter mMerchantPicPreviewManagerListAdapter;
    private PicPreviewPagerAdapter mPicPreviewPagerAdapter;

    public static MerchantPhotoPreviewManagerFrag newInstance(int parentPosition,
                                                              int childPosition,
                                                              ArrayList<? extends PicPreviewBean> imageList,
                                                              int merchantId) {
        Bundle args = new Bundle();
        args.putInt(MerchantPicPreviewAct.PARENT_POSITION, parentPosition);
        args.putInt(MerchantPicPreviewAct.CHILD_POSITION, childPosition);
        args.putParcelableArrayList(MerchantPicPreviewAct.EXTRA_DATA, imageList);
        args.putInt(MerchantPicPreviewAct.MERCHANT_ID, merchantId);
        MerchantPhotoPreviewManagerFrag fragment = new MerchantPhotoPreviewManagerFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mParentPosition = arguments.getInt(MerchantPicPreviewAct.PARENT_POSITION);
            mChildPosition = arguments.getInt(MerchantPicPreviewAct.CHILD_POSITION);
            mImagePathList = arguments.getParcelableArrayList(MerchantPicPreviewAct.EXTRA_DATA);
            mMerchantId = arguments.getInt(MerchantPicPreviewAct.MERCHANT_ID);
        }
    }

    @Override
    public MerchantPicPreviewManagerPre createPresenter() {
        return new MerchantPicPreviewManagerPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_merchant_photo_preview;
    }

    @Override
    public void initView() {
        super.initView();
        ImmersionBar.with(this)
                .hideBar(BarHide.FLAG_HIDE_STATUS_BAR)
                .init();
        mAppToolbar = findViewById(R.id.merchant_toolbar);
        view_pager_merchant_photo_preview = findViewById(R.id.view_pager_merchant_photo_preview);

        mMerchantPicPreviewManagerListAdapter = new MerchantPicPreviewManagerListAdapter();
        mMerchantPicPreviewManagerListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mMerchantPicPreviewManagerListAdapter);

        mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(5, 0, 5, 0);
            }
        });

        mPicPreviewPagerAdapter = new PicPreviewPagerAdapter(getChildFragmentManager());
        mPicPreviewPagerAdapter.setImagePathList(mImagePathList);
        view_pager_merchant_photo_preview.setAdapter(mPicPreviewPagerAdapter);
        view_pager_merchant_photo_preview.setCurrentItem(mChildPosition, true);

        view_pager_merchant_photo_preview.addOnPageChangeListener(this);

        setTitle(mChildPosition);

        mAppToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onToolbarNavClick();
            }
        });
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getMerchantPicTypeList(mParentPosition, true);
    }

    @Override
    public void onTypeList(ArrayList<MerchantPicTypeBean> typeList) {
        mMerchantPicPreviewManagerListAdapter.setMerchantPicTypeBeans(typeList);
        mRecyclerView.smoothScrollToPosition(mParentPosition);
    }

    @Override
    public void onSetSelectResult() {
        mMerchantPicPreviewManagerListAdapter.notifyDataSetChanged();
    }

    @Override
    public void onPicListResult(ArrayList<MerchantPicInfoBean> picInfoList) {
        mImagePathList.clear();
        mImagePathList.addAll(picInfoList);
        mPicPreviewPagerAdapter.setImagePathList(mImagePathList);
        setTitle(0);
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {

        if (entity instanceof MerchantPicTypeBean) {
            getPresenter().getMerchantPicTypeList(position, false);
            MerchantPicTypeBean picTypeBean = (MerchantPicTypeBean) entity;
            getPresenter().getPicList(mMerchantId, picTypeBean.getRegionId());
        }
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        setTitle(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    private void setTitle(int position) {
        String title = (position + 1) + "/" + mImagePathList.size();
        mAppToolbar.setToolbarTitle(title);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/store/ShoppingCarFrag.java<|end_filename|>
package com.scj.beilu.app.ui.store;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.store.ShoppingCartInfoPre;
import com.scj.beilu.app.mvp.store.entity.GoodsShoppingCarInfoBean;
import com.scj.beilu.app.ui.store.adapter.ShoppingCartListAdapter;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/1 13:24
 */
public class ShoppingCarFrag extends BaseMvpFragment<ShoppingCartInfoPre.ShoppingCartInfoView, ShoppingCartInfoPre>
        implements ShoppingCartInfoPre.ShoppingCartInfoView, OnItemClickListener<GoodsShoppingCarInfoBean>, View.OnClickListener {

    private TextView mTvSelect;
    private TextView mTvTotalPrice;
    private TextView mTvStartPay;
    private TextView mTvStartDel;

    private ShoppingCartListAdapter mShoppingCartListAdapter;

    private boolean mSelectAll = true;

    @Override
    public ShoppingCartInfoPre createPresenter() {
        return new ShoppingCartInfoPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_shopping_cart;
    }

    @Override
    public void initView() {
        super.initView();

        mTvSelect = findViewById(R.id.tv_cart_select);
        mTvTotalPrice = findViewById(R.id.tv_cart_total_price);
        mTvStartPay = findViewById(R.id.tv_cart_start_pay);
        mTvStartDel = findViewById(R.id.tv_cart_start_del);

        mShoppingCartListAdapter = new ShoppingCartListAdapter(this);
        mShoppingCartListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mShoppingCartListAdapter);

        mRecyclerView.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));

        mTvSelect.setOnClickListener(this);
        mTvStartDel.setOnClickListener(this);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getCartList();
    }

    @Override
    public void onCartCount(int count) {

    }

    @Override
    public void onCartListResult(List<GoodsShoppingCarInfoBean> cartList) {
        mShoppingCartListAdapter.setCarInfoBeanList(cartList);
    }

    @Override
    public void modifyResult(int position) {
        mShoppingCartListAdapter.notifyItemChanged(position);
    }

    @Override
    public void onSelectCountResult(Integer count) {
        count = count == -1 ? 0 : count;
        mTvSelect.setSelected(count != 0);
        mTvSelect.setText(String.format(getString(R.string.txt_cart_select), count));
        mShoppingCartListAdapter.notifyDataSetChanged();
        mFragmentActivity.setResult(RESULT_OK);
    }

    @Override
    public void onItemClick(int position, GoodsShoppingCarInfoBean entity, View view) {
        switch (view.getId()) {
            case R.id.btn_cart_minus:
                setGoodsNum(false, entity.getGoodsNum(), position);
                break;
            case R.id.btn_cart_add:
                setGoodsNum(true, entity.getGoodsNum(), position);
                break;
            case R.id.iv_cart_selector:
                getPresenter().setSelectSingle(position);
                break;
        }
    }

    private void setGoodsNum(boolean isAdd, int goodsNum, int position) {
        if (isAdd) {
            goodsNum++;
        } else {
            if (goodsNum > 1) {
                goodsNum--;
            } else {
                goodsNum = 1;
            }
        }
        getPresenter().modifyGoodsNum(goodsNum, position);
    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_shopping_edit:
                mAppToolbar.getMenu().clear();
                mAppToolbar.inflateMenu(R.menu.menu_done);
                mTvStartPay.setVisibility(View.GONE);
                mTvStartDel.setVisibility(View.VISIBLE);

                getPresenter().setSelectAll(false);

                break;
            case R.id.menu_done:
                mAppToolbar.getMenu().clear();
                mAppToolbar.inflateMenu(R.menu.menu_shopping_cart_edit);
                mTvStartDel.setVisibility(View.GONE);
                mTvStartPay.setVisibility(View.VISIBLE);
                break;
        }
        return super.onMenuItemClick(item);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_cart_start_del:
                getPresenter().delCart();
                break;
            case R.id.tv_cart_select:
                getPresenter().setSelectAll(mSelectAll);
                mSelectAll = !mSelectAll;
                break;
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/act/MsgManagerAct.java<|end_filename|>
package com.scj.beilu.app.ui.act;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.mvp.mine.message.MsgManagerActPre;
import com.scj.beilu.app.ui.mine.adapter.MsgManagerPagerAdapter;

/**
 * @author Mingxun
 * @time on 2019/1/14 19:50
 */
public class MsgManagerAct extends BaseMvpActivity<MsgManagerActPre.MsgManagerView, MsgManagerActPre>
        implements MsgManagerActPre.MsgManagerView {

    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private MsgManagerPagerAdapter mMsgManagerPagerAdapter;
    public static final String EXTRA_VAL = "type";
    private final String[] mTitles = {"回复", "喜欢", "评论"};

    public static void startMsgManagerAct(Activity activity) {
        Intent intent = new Intent(activity, MsgManagerAct.class);

        activity.startActivity(intent);
    }


    @Override
    public int getLayout() {
        return R.layout.act_msg_manager;
    }

    @Override
    public void initView() {
        super.initView();
        mViewPager = findViewById(R.id.view_pager_msg_manager);
        mTabLayout = findViewById(R.id.tab_msg_manager);
        mTabLayout.setupWithViewPager(mViewPager);

        mMsgManagerPagerAdapter = new MsgManagerPagerAdapter(getSupportFragmentManager());
        mMsgManagerPagerAdapter.setTitles(mTitles);
        mViewPager.setAdapter(mMsgManagerPagerAdapter);

        int tabCount = mTabLayout.getTabCount();
        for (int i = 0; i < tabCount; i++) {
            mTabLayout.getTabAt(i).setCustomView(getTabLayout(mTitles[i]));
        }

        setTabSelector(mTabLayout.getTabAt(0), true);

        mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                setTabSelector(tab, true);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                setTabSelector(tab, false);
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        mViewPager.setOffscreenPageLimit(3);

    }

    @NonNull
    @Override
    public MsgManagerActPre createPresenter() {
        return new MsgManagerActPre(this);
    }


    public View getTabLayout(CharSequence title) {
        View view = LayoutInflater.from(this).inflate(R.layout.layout_msg_tab_item, null);
        TextView tvTab = view.findViewById(R.id.tv_tab_item);
        tvTab.setText(title);
        return view;
    }

    public void setTabSelector(TabLayout.Tab tab, boolean selected) {
        View view = tab.getCustomView();
        if (view == null) return;
        TextView tvTab = view.findViewById(R.id.tv_tab_item);
        ImageView ivLine = view.findViewById(R.id.iv_tab_bottom_line);
        tvTab.setSelected(selected);
        ivLine.setSelected(selected);
        if (selected) {
            tvTab.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            tvTab.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        } else {
            tvTab.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            tvTab.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/mine/UserInfEditPre.java<|end_filename|>
package com.scj.beilu.app.mvp.mine;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.orhanobut.logger.Logger;
import com.scj.beilu.app.mvp.common.bean.DictrictOptionBean;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.mine.model.IMine;
import com.scj.beilu.app.mvp.mine.model.MineImpl;
import com.scj.beilu.app.mvp.user.entity.UserInfoEntity;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.ObservableSource;
import io.reactivex.functions.Function;

/**
 * @author Mingxun
 * @time on 2019/1/12 16:08
 */
public class UserInfEditPre extends BaseMvpPresenter<UserInfEditPre.UserInfoEditView> {
    private IMine mIMe;

    public UserInfEditPre(Context context) {
        super(context, ShowConfig.NONE, ShowConfig.ERROR_TOAST);
        mIMe = new MineImpl(mBuilder);
        getDistrictList();
    }

    public void getUserInfo() {
        onceViewAttached(new ViewAction<UserInfoEditView>() {
            @Override
            public void run(@NonNull final UserInfoEditView mvpView) {
                mIMe.getUserInfoByToken()
                        .subscribe(new ObserverCallback<UserInfoEntity>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(UserInfoEntity userInfoEntity) {
                                mvpView.onUserInfo(userInfoEntity);
                            }
                        });
            }
        });
    }

    /**
     * 修改性别 生日 所在地
     *
     * @param userInfoEntity
     */
    public void modifyUserInfo(final UserInfoEntity userInfoEntity) {
        onceViewAttached(new ViewAction<UserInfoEditView>() {
            @Override
            public void run(@NonNull final UserInfoEditView mvpView) {
                Map<String, Object> params = new HashMap<>();
                if (userInfoEntity.getUserNickName() != null) {
                    params.put("nickName", userInfoEntity.getUserNickName());
                }
                if (userInfoEntity.getUserSex() != null) {
                    params.put("userSex", userInfoEntity.getUserSex());
                }
                if (userInfoEntity.getUserBirth() != null) {
                    params.put("userBirth", userInfoEntity.getUserBirth());
                    Logger.e(userInfoEntity.getUserBirth() + "   -------------------- ");
                }
                if (userInfoEntity.getUserProvince() != null) {
                    params.put("userProvince", userInfoEntity.getUserProvince());
                }
                if (userInfoEntity.getUserCity() != null) {
                    params.put("userCity", userInfoEntity.getUserCity());
                }
                if (userInfoEntity.getUserBrief() != null) {
                    params.put("userBrief", userInfoEntity.getUserBrief());
                }
                mIMe.setUserInfoParams(params)
                        //更新缓存里面的数据
                        .flatMap(new Function<ResultMsgBean, ObservableSource<UserInfoEntity>>() {
                            @Override
                            public ObservableSource<UserInfoEntity> apply(ResultMsgBean result) throws Exception {
                                mvpView.onUpdateInfoResult(result.getResult());
                                return mIMe.updateUserInfo(userInfoEntity);
                            }
                        })

                        .subscribe(new ObserverCallback<UserInfoEntity>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(UserInfoEntity userInfoEntity) {
                                mvpView.onUpdateCacheResult(userInfoEntity);
                            }
                        });
            }
        });
    }


    public void setUserPhoto(final String photo) {
        onceViewAttached(new ViewAction<UserInfoEditView>() {
            @Override
            public void run(@NonNull final UserInfoEditView mvpView) {
                mIMe.setUserPhotoParam(photo)
                        .subscribe(new ObserverCallback<UserInfoEntity>
                                (mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(UserInfoEntity userInfoEntity) {
                                mvpView.onUserInfo(userInfoEntity);
                                mvpView.onUpdateInfoResult(userInfoEntity.getResult());
                            }
                        });
            }
        });
    }

    /**
     * 获取地区列表
     */
    private void getDistrictList() {
        onceViewAttached(new ViewAction<UserInfoEditView>() {
            @Override
            public void run(@NonNull final UserInfoEditView mvpView) {
                mIMe.dealWithDistrictData()
                        .subscribe(new ObserverCallback<DictrictOptionBean>
                                (mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(DictrictOptionBean result) {
                                mvpView.onDistrictListResult(result);
                            }
                        });
            }
        });
    }

    public interface UserInfoEditView extends MvpView {
        void onUserInfo(UserInfoEntity userInfoEntity);

        void onUpdateInfoResult(String resultMsg);

        void onUpdateCacheResult(UserInfoEntity userInfo);

        void onDistrictListResult(DictrictOptionBean optionBean);
    }
}



<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/common/pay/WXPayPre.java<|end_filename|>
package com.scj.beilu.app.mvp.common.pay;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.pay.bean.AliPayInfoResultBean;
import com.scj.beilu.app.mvp.common.pay.bean.PayResult;
import com.scj.beilu.app.mvp.common.pay.bean.WeChatPayResultBean;
import com.scj.beilu.app.mvp.common.pay.model.PayInfoImpl;
import com.scj.beilu.app.util.ToastUtils;

import java.util.Map;

import static com.scj.beilu.app.mvp.common.pay.model.PayInfoImpl.SDK_PAY_FLAG;

/**
 * @author Mingxun
 * @time on 2019/3/23 15:32
 */
public class WXPayPre<V extends WXPayView> extends BaseMvpPresenter<V> {
    private PayInfoImpl mPayInfo;
    private Activity mActivity;
    public WXPayPre(Activity activity) {
        super(activity, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mActivity = activity;
        mPayInfo = new PayInfoImpl(mBuilder);
    }

    public void startPayCourse(final int payType, final int courseVideoId, final int courseId) {
        mBuilder.setLoadType(ShowConfig.LOADING_DIALOG);
        onceViewAttached(new ViewAction<V>() {
            @Override
            public void run(@NonNull final V mvpView) {
                mPayInfo.startCoursePay(payType, courseVideoId, courseId)
                .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                    @Override
                    public void onRequestResult(ResultMsgBean resultMsgBean) {
                        if (resultMsgBean instanceof AliPayInfoResultBean) {
                            try {
                                AliPayInfoResultBean aliPayInfo = (AliPayInfoResultBean) resultMsgBean;
                                mPayInfo.setAliPay(mActivity, aliPayInfo, mHandler);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else if (resultMsgBean instanceof WeChatPayResultBean) {
                            try {
                                WeChatPayResultBean wxPayInfo = (WeChatPayResultBean) resultMsgBean;
                                mPayInfo.setWxPayInfo(wxPayInfo);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
            }
        });
    }

    @SuppressLint("HandlerLeak")
    private final Handler mHandler = new Handler() {
        @SuppressWarnings("unused")
        public void handleMessage(final Message msg) {
            switch (msg.what) {
                case SDK_PAY_FLAG: {
                    onceViewAttached(new ViewAction<V>() {
                        @Override
                        public void run(@NonNull V mvpView) {
                            @SuppressWarnings("unchecked")
                            PayResult payResult = new PayResult((Map<String, String>) msg.obj);
                            /**
                             * 对于支付结果，请商户依赖服务端的异步通知结果。同步通知结果，仅作为支付结束的通知。
                             */
                            String resultInfo = payResult.getResult();// 同步返回需要验证的信息
                            String resultStatus = payResult.getResultStatus();
                            // 判断resultStatus 为9000则代表支付成功
                            if (TextUtils.equals(resultStatus, "9000")) {
                                // 该笔订单是否真实支付成功，需要依赖服务端的异步通知。
                                mvpView.onAliPaySuccess();
                            } else {
                                // 该笔订单真实的支付结果，需要依赖服务端的异步通知。
                                ToastUtils.showToast(mActivity, "支付失败");
                            }
                        }
                    });
                    break;
                }

                default:
                    break;
            }
        }
    };
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/FeedBackFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.widget.EditText;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.mine.FeedbackPre;
import com.scj.beilu.app.util.CheckUtils;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.AppToolbar;

/**
 * author:SunGuiLan
 * date:2019/3/5
 * descriptin:意见反馈
 */
public class FeedBackFrag extends BaseMvpFragment<FeedbackPre.FeedbackView, FeedbackPre> implements FeedbackPre.FeedbackView {
    private EditText mEtContent;
    private EditText mEtContact;
    private AppToolbar mToolbar;


    @Override
    public FeedbackPre createPresenter() {
        return new FeedbackPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_feedback;
    }

    @Override
    public void initView() {
        super.initView();
        mEtContent = findViewById(R.id.et_content);
        mEtContact = findViewById(R.id.et_contact);
        mToolbar = findViewById(R.id.toolbar);
        mEtContent.addTextChangedListener(mTextWatcher);
        mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                try {
                    CheckUtils.checkStringIsNull(mEtContent.getText().toString(), "请输入内容");
                } catch (Exception e) {
                    ToastUtils.showToast(mFragmentActivity, e.getMessage());
                } finally {
                    getPresenter().addFeedBack(mEtContent.getText().toString(), mEtContact.getText().toString());
                }
                return false;
            }
        });


    }

    private TextWatcher mTextWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            int len = s.toString().length();
            if (len >= 120) {
                ToastUtils.showToast(mFragmentActivity, "字数不能超过120字");
            }
        }
    };

    @Override
    public void onAddFeedBackResult(String result) {
        ToastUtils.showToast(mFragmentActivity, result);
        mFragmentActivity.finish();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/adapter/MeFocusAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.mine.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.bean.FocusUserInfoBean;

import java.util.List;

/**
 * author: SunGuiLan
 * date:2019/2/1
 * descriptin:查找更多用户
 */
public class MeFocusAdapter extends RecyclerView.Adapter<MeFocusAdapter.FindMoreUserViewHolder> {
    private List<FocusUserInfoBean> mFocusInfoList;
    private GlideRequests mGlideRequests;
    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener<FocusUserInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public MeFocusAdapter(GlideRequests glideRequests) {
        mGlideRequests = glideRequests;
    }

    @NonNull
    @Override
    public FindMoreUserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_focus_user, parent, false);
        return new MeFocusAdapter.FindMoreUserViewHolder(view);
    }

    public void setFocusInfoList(List<FocusUserInfoBean> focusInfoList) {
        mFocusInfoList = focusInfoList;
        notifyDataSetChanged();
    }


    @Override
    public void onBindViewHolder(@NonNull FindMoreUserViewHolder holder, int position) {
        FocusUserInfoBean mFocusUserInfoBean = mFocusInfoList.get(position);
        holder.mTvUserName.setText(mFocusUserInfoBean.getUserNickName());
        if (mFocusUserInfoBean.getIsFans() == 1 && mFocusUserInfoBean.getIsFocus() == 1) {
            holder.mTvAttention.setSelected(true);
            holder.mTvAttention.setText("互相关注");
        } else if (mFocusUserInfoBean.getIsFocus() == 1) {
            holder.mTvAttention.setSelected(true);
            holder.mTvAttention.setText("已关注");
        } else {
            holder.mTvAttention.setSelected(false);
            holder.mTvAttention.setText("+ 关注");
        }

        mGlideRequests.
                load(mFocusUserInfoBean.getUserCompressionHead())
                .centerCrop()
                .transform(new CircleCrop())
                .into(holder.mIvUserAvatar);
    }

    @Override
    public int getItemCount() {
        return mFocusInfoList == null ? 0 : mFocusInfoList.size();
    }

    class FindMoreUserViewHolder extends BaseViewHolder {
        private ImageView mIvUserAvatar;
        private TextView mTvAttention;
        private TextView mTvUserName;

        public FindMoreUserViewHolder(View itemView) {
            super(itemView);
            mTvAttention = findViewById(R.id.tv_item_attention);
            mTvUserName = findViewById(R.id.tv_user_name);
            mIvUserAvatar = findViewById(R.id.iv_user_avatar);
            mTvAttention.setOnClickListener(mOnClickListener);
            mIvUserAvatar.setOnClickListener(mOnClickListener);
        }

        private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (mOnItemClickListener != null && mFocusInfoList != null) {
                    mOnItemClickListener.onItemClick(getAdapterPosition(), mFocusInfoList.get(getAdapterPosition()), v);
                }
            }
        };
    }
}


<|start_filename|>prolib/src/main/java/android/support/v4/app/BackstackAccessor.java<|end_filename|>
/*
 * Copyright 2016 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package android.support.v4.app;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * With this utility class one can access the fragment backstack
 */
public class BackstackAccessor {

  private BackstackAccessor() {
    throw new IllegalStateException("Not instantiatable");
  }

  /**
   * Checks whether or not a given fragment is on the backstack of the fragment manager (could also
   * be on top of the backstack and hence visible)
   *
   * @param fragment The fragment you want to check if its on the back stack
   * @return true, if the given Fragment is on the back stack, otherwise false (not on the back
   * stack)
   */
  public static boolean isFragmentOnBackStack(Fragment fragment) {
      try {
          return fragment.isInBackStack();
      } catch (IllegalAccessError e) {
          return isInBackStackAndroidX(fragment);
      }
  }

    /**
     * As of version 1.0 of AndroidX - fragment.isInBackStack() is package private which leads to
     * an IllegalAccessError being thrown when trying to use it.
     * This method is a temporary workaround until the issue is resolved in AndroidX.
     */
    private static boolean isInBackStackAndroidX(final Fragment fragment) {
        final StringWriter writer = new StringWriter();
        fragment.dump("", null, new PrintWriter(writer), null);
        final String dump = writer.toString();
        return !dump.contains("mBackStackNesting=0");
    }
/*
  public static boolean isFragmentOnBackStack(Fragment fragment) {

    FragmentManager fragmentManager = fragment.getFragmentManager();
    int backStackSize = fragmentManager.getBackStackEntryCount();
    for (int i = 0; i < backStackSize; i++) {
      BackStackRecord stackEntry = (BackStackRecord) fragmentManager.getBackStackEntryAt(i);
      int opsCount = stackEntry.mOps == null ? 0 : stackEntry.mOps.size();
      if (opsCount > 0) {
        BackStackRecord.Op op = stackEntry.mOps.get(opsCount-1);
        if (op.fragment == fragment) {
          return true;
        }
      }
    }

    return false;
  }
*/

/*
  private static boolean findNext(@NonNull Fragment toFind, @Nullable BackStackRecord.Op next) {
    if (next == null) {
      return false;
    }

    if (toFind == next.fragment) {
      return true;
    } else {
      return findNext(toFind, next.next);
    }
  }

  private static boolean findPrevious(@NonNull Fragment toFind,
      @Nullable BackStackRecord.Op previous) {
    if (previous == null) {
      return false;
    }

    if (toFind == previous.fragment) {
      return true;
    } else {
      return findPrevious(toFind, previous.prev);
    }
  }
  */
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/NewsDetailFrag.java<|end_filename|>
package com.scj.beilu.app.ui.news;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MenuItem;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.news.NewsDetailsFragPre;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.NewsDetailsWebView;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/15 21:22
 * 资讯详情
 */
public class NewsDetailFrag extends BaseMvpFragment<NewsDetailsFragPre.NewsDetailsView, NewsDetailsFragPre>
        implements NewsDetailsFragPre.NewsDetailsView, View.OnClickListener {

    private NewsDetailsWebView mWebView;
    private EditText mEtCommentContent;
    private Button mBtnStartComment;
    private TextView mTvCommentDetails;
    private View mViewStar;
    private ProgressBar progressBar;

    private static final String EXTRA_CONTENT = "CONTENT";
    private NewsInfoBean mNewsListBean;
    private int mCount;

    public static NewsDetailFrag newInstance(NewsInfoBean infoBean) {

        Bundle args = new Bundle();
        args.putParcelable(EXTRA_CONTENT, infoBean);
        NewsDetailFrag fragment = new NewsDetailFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mNewsListBean = arguments.getParcelable(EXTRA_CONTENT);
        }
    }


    @Override

    public int getLayout() {
        return R.layout.frag_news_details;
    }

    @Override
    public void initView() {
        super.initView();
        mWebView = findViewById(R.id.web_news_details);
        mEtCommentContent = findViewById(R.id.et_comment_content);
        mTvCommentDetails = findViewById(R.id.tv_comment_detail);
        mBtnStartComment = findViewById(R.id.btn_send_comment);
        progressBar = findViewById(R.id.progressBar);
        mViewStar = findViewById(R.id.menu_star);

        mTvCommentDetails.setOnClickListener(this);
        mBtnStartComment.setOnClickListener(this);
        mEtCommentContent.addTextChangedListener(mTextWatcher);
        mWebView.setProgressBar(progressBar);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getDetailsById(mNewsListBean.getNewsId());
    }

    @Override
    protected void onReLoad() {
        getPresenter().getDetailsById(mNewsListBean.getNewsId());
    }

    private final TextWatcher mTextWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0) {
                mTvCommentDetails.setVisibility(View.GONE);
                mBtnStartComment.setVisibility(View.VISIBLE);
            } else {
                mBtnStartComment.setVisibility(View.GONE);
                mTvCommentDetails.setVisibility(View.VISIBLE);
            }
        }
    };

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_comment_detail:
                start(NewsDetailsCommentListFrag.newInstance(mNewsListBean.getNewsId(), mCount));
                break;
            case R.id.btn_send_comment:
                String content = mEtCommentContent.getText().toString();
                getPresenter().crateComment(mNewsListBean.getNewsId(), content);
                break;
        }
    }

    @NonNull
    @Override
    public NewsDetailsFragPre createPresenter() {
        return new NewsDetailsFragPre(mFragmentActivity);
    }

    @Override
    public void onNewsInfo(NewsInfoBean infoBean) {
        mViewStar.setSelected(infoBean.getIsCollect() == 1);
        mCount = infoBean.getCommentCount();
        mTvCommentDetails.setText(String.valueOf(infoBean.getCommentCount()));
        mNewsListBean = infoBean;

        mWebView.setIsFocus(infoBean.getIsFocus());
        mWebView.loadDataWithBaseURL(null, infoBean.getNewsContent(), "text/html", "utf-8", null);
        //设置本地调用对象及其接口
        mWebView.addJavascriptInterface(new JsInteraction(), "app");
    }

    @Override
    public void onFindDel() {
        //do not
    }

    @Override
    public void onShareCountResult() {
        //do not
    }

    @Override
    public void onFindDelResult(ResultMsgBean result) {
        //do not
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        //do not
    }

    public class JsInteraction {
        @JavascriptInterface
        public void changeAttention() {   //提供给js调用的方法
            mWebView.post(() ->
                    getPresenter().setAttentionAction(mNewsListBean.getUserId(), mNewsListBean.getIsFocus()));
        }
    }

    @Override
    public void onCommentResult(String result) {
        ToastUtils.showToast(mFragmentActivity, result);
        mEtCommentContent.setText("");
        hideSoftInput();

        getPresenter().getCommentCount(mNewsListBean.getNewsId());
    }

    @Override
    public void onCommentCountResult(int count) {
        mCount = count;
        mTvCommentDetails.setText(String.valueOf(count));
    }

    @Override
    public void onAttentionResult(String result) {

        ToastUtils.showToast(mFragmentActivity, result);
        mFragmentActivity.setResult(Activity.RESULT_OK);
        mWebView.post(() -> {

            if (mNewsListBean.getIsFocus() == 1) {
                mNewsListBean.setIsFocus(0);
            } else {
                mNewsListBean.setIsFocus(1);
            }

            if (mNewsListBean.getIsFocus() == 1) {
                mWebView.loadUrl("javascript:changeAttention(false)");
            } else {
                //已关注
                mWebView.loadUrl("javascript:changeAttention(true)");
            }
        });

    }

    @Override
    public void onCollectResult(String msg) {
        ToastUtils.showToast(mFragmentActivity, msg);
        mFragmentActivity.setResult(Activity.RESULT_OK);
        if (mViewStar.isSelected()) {
            mViewStar.setSelected(false);
        } else {
            mViewStar.setSelected(true);
        }
    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        if (item.getItemId() == R.id.menu_star) {
            getPresenter().setCollectAction(mNewsListBean.getNewsId(), mViewStar.isSelected() ? 0 : 1);
        } else if (item.getItemId() == R.id.menu_share) {
            if (!EventBus.getDefault().isRegistered(this)) {
                EventBus.getDefault().register(this);
            }
            getPresenter().startShareNews(NewsDetailFrag.this, mNewsListBean);
        }
        return super.onMenuItemClick(item);
    }

    @Subscribe
    public void onShareResult(BaseResp resp) {
        ToastUtils.showToast(mFragmentActivity, "分享成功");
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/base/VideoMvpActivity.java<|end_filename|>
package com.scj.beilu.app.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;

import com.mx.pro.lib.mvp.MvpPresenter;
import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.delegate.ActivityMvpDelegate;
import com.mx.pro.lib.mvp.delegate.ActivityMvpDelegateImpl;
import com.mx.pro.lib.mvp.delegate.MvpDelegateCallback;
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer;

public abstract class VideoMvpActivity<V extends MvpView, P extends MvpPresenter<V>, Player extends GSYBaseVideoPlayer>
        extends VideoSupportActivity<Player> implements MvpView, MvpDelegateCallback<V, P> {

    protected ActivityMvpDelegate<V, P> mActivityMvpDelegate;
    protected P mPresenter;


    @NonNull
    protected ActivityMvpDelegate<V, P> getMvpDelegate() {
        if (mActivityMvpDelegate == null) {
            mActivityMvpDelegate = new ActivityMvpDelegateImpl(this, this, true);
        }
        return mActivityMvpDelegate;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getMvpDelegate().onCreate(savedInstanceState);
        initView();
    }

    protected void initView() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        getMvpDelegate().onDestroy();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        getMvpDelegate().onSaveInstanceState(outState);
    }

    @Override
    protected void onPause() {
        super.onPause();
        getMvpDelegate().onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        getMvpDelegate().onResume();
    }

    @Override
    protected void onStart() {
        super.onStart();
        getMvpDelegate().onStart();
    }

    @Override
    protected void onStop() {
        super.onStop();
        getMvpDelegate().onStop();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        getMvpDelegate().onRestart();
    }

    @Override
    protected void onPostCreate(@Nullable Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        getMvpDelegate().onPostCreate(savedInstanceState);
    }

    @NonNull
    public abstract P createPresenter();

    @Override
    public P getPresenter() {
        return mPresenter;
    }

    @Override
    public void setPresenter(P presenter) {
        mPresenter = presenter;
    }

    @Override
    public V getMvpView() {
        return (V) this;
    }


    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {

        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            View v = getCurrentFocus();
            if (isShouldHideInput(v, ev)) {

                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                }
            }
            return super.dispatchTouchEvent(ev);
        }
        // 必不可少，否则所有的组件都不会有TouchEvent了
        if (getWindow().superDispatchTouchEvent(ev)) {
            return true;
        }
        return onTouchEvent(ev);
    }

    public boolean isShouldHideInput(View v, MotionEvent event) {
        if (v != null && (v instanceof EditText)) {
            int[] leftTop = {0, 0};
            //获取输入框当前的location位置
            v.getLocationInWindow(leftTop);
            int left = leftTop[0];
            int top = leftTop[1];
            int bottom = top + v.getHeight();
            int right = left + v.getWidth();
            if (event.getX() > left && event.getX() < right
                    && event.getY() > top && event.getY() < bottom) {
                // 点击的是输入框区域，保留点击EditText的事件
                return false;
            } else {
                return true;
            }
        }
        return false;
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/adapter/CourseTagListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.course.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * @author Mingxun
 * @time on 2019/3/13 11:29
 */
public class CourseTagListAdapter extends RecyclerView.Adapter<CourseTagListAdapter.CourseTagViewHolder> {

    private String[] mLabels;

    public void setLabels(String labels) {
        try {
            if (labels.contains(",")) {
                mLabels = labels.split(",");
            } else {
                mLabels = new String[]{labels};
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            notifyDataSetChanged();
        }
    }

    @NonNull
    @Override
    public CourseTagViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_page_course_tag, parent, false);
        return new CourseTagViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CourseTagViewHolder holder, int position) {
        String label = mLabels[position];
        holder.mTvCourseTag.setText(label);
    }

    @Override
    public int getItemCount() {
        return mLabels == null ? 0 : mLabels.length;
    }

    class CourseTagViewHolder extends BaseViewHolder {
        private TextView mTvCourseTag;

        public CourseTagViewHolder(View itemView) {
            super(itemView);
            mTvCourseTag = findViewById(R.id.tv_home_page_goods_tag);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/seller/PopRightAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter.seller;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.home.bean.RightViewItemBean;

import java.util.List;


/**
 * @类名：
 * @描述：右侧列表适配器
 * @Created by lm on 2017/3/7.
 */

public class PopRightAdapter extends RecyclerView.Adapter<PopRightAdapter.RightViewHoler>{
    private Context context;
    private List<RightViewItemBean> list;//列表数据源
    private String selectedRightId = "";//右侧列表中被选中的Id，name有可能重复，id一般不会重复，因此使用id进行区分
    private OnItemClickListener mOnItemClickListener;//item的点击事件

    public PopRightAdapter(Context context, List<RightViewItemBean> list, String selectedRightId){
        this.context = context;
        this.list = list;
        this.selectedRightId = selectedRightId;
    }

    /**
     * @param设置被选中行的Id
     */
    public void setSelectedRightId(String selectedRightId) {
        this.selectedRightId = selectedRightId;
    }


    @NonNull
    @Override
    public RightViewHoler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_pop_right, parent,false);
        return new RightViewHoler(v);
    }

    @Override
    public void onBindViewHolder(@NonNull final RightViewHoler holder, int position) {
        RightViewHoler rightViewHoler = (RightViewHoler) holder;
        rightViewHoler.nameTV.setText(list.get(position).getName());
        if (selectedRightId.equals(list.get(position).getId())){
            rightViewHoler.nameTV.setTextColor(Color.parseColor("#32B9AA"));
        } else {
            rightViewHoler.nameTV.setTextColor(Color.parseColor("#7A7A7A"));
        }

        //判断是否设置了监听器
        if(mOnItemClickListener != null){
            //为ItemView设置监听器
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int position = holder.getLayoutPosition(); // 1
                    mOnItemClickListener.onItemClick(holder.itemView,position); // 2
                }
            });
        }
    }


    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class RightViewHoler extends BaseViewHolder {
        TextView nameTV;//名字
        public RightViewHoler(View itemView) {
            super(itemView);
            nameTV = findViewById(R.id.right_item_name);
        }
    }


    /**
     * 点击事件接口
     */
    public interface OnItemClickListener{
        void onItemClick(View view, int position);
    }

    public void setOnItemClickListener(OnItemClickListener mOnItemClickListener){
        this.mOnItemClickListener = mOnItemClickListener;
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/order/OrderInfoLogisticsPre.java<|end_filename|>
package com.scj.beilu.app.mvp.order;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.order.bean.OrderLogisticsInfoResultBean;
import com.scj.beilu.app.mvp.order.model.IOrderInfo;
import com.scj.beilu.app.mvp.order.model.OrderInfoImpl;

/**
 * @author Mingxun
 * @time on 2019/4/8 22:10
 */
public class OrderInfoLogisticsPre extends BaseMvpPresenter<OrderInfoLogisticsPre.OrderInfoLogisticsView> {

    private IOrderInfo mOrderInfo;

    public OrderInfoLogisticsPre(Context context, String orderNo) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mOrderInfo = new OrderInfoImpl(mBuilder, orderNo);
    }

    public void getLogisticsList() {
        onceViewAttached(new ViewAction<OrderInfoLogisticsView>() {
            @Override
            public void run(@NonNull final OrderInfoLogisticsView mvpView) {
                mOrderInfo.getLogisticsInfo()
                        .subscribe(new ObserverCallback<OrderLogisticsInfoResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(OrderLogisticsInfoResultBean orderLogisticsInfoResultBean) {
                                mvpView.onLogisticsList(orderLogisticsInfoResultBean);
                            }
                        });
            }
        });
    }

    public interface OrderInfoLogisticsView extends MvpView {
        void onLogisticsList(OrderLogisticsInfoResultBean logisticsInfo);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/widget/TabItem.java<|end_filename|>
package com.scj.beilu.app.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.TintTypedArray;
import android.util.AttributeSet;
import android.view.View;

import com.scj.beilu.app.R;

/**
 * @author Mingxun
 * @time on 2019/5/14 21:41
 */
public final class TabItem extends View {
    final CharSequence mText;
    final Drawable mIcon;
    final int mCustomLayout;

    public TabItem(Context context) {
        this(context, null);
    }

    public TabItem(Context context, AttributeSet attrs) {
        super(context, attrs);

        final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
                R.styleable.TabItem);
        mText = a.getText(R.styleable.TabItem_android_text);
        mIcon = a.getDrawable(R.styleable.TabItem_android_icon);
        mCustomLayout = a.getResourceId(R.styleable.TabItem_android_layout, 0);
        a.recycle();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/MerchantPhotoListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.merchant;

import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewStub;

import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.MerchantPicListPre;
import com.scj.beilu.app.mvp.merchant.bean.MerchantPicInfoBean;
import com.scj.beilu.app.ui.merchant.adapter.MerchantPhotoListAdapter;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/13 18:26
 */
public class MerchantPhotoListFrag extends BaseMvpFragment<MerchantPicListPre.MerchantPicListView, MerchantPicListPre>
        implements MerchantPicListPre.MerchantPicListView, OnItemClickListener<MerchantPicInfoBean> {

    private ViewStub mLoading;

    private static final String MERCHANT_ID = "merchant_id";
    private static final String REGION_ID = "regionId";
    private static final String POSITION = "position";
    private int mMerchantId;
    private int mRegionId;
    private int mParentPosition;

    private MerchantPhotoListAdapter mMerchantPhotoListAdapter;
    private final ArrayList<MerchantPicInfoBean> mPicInfoList = new ArrayList<>();

    public static MerchantPhotoListFrag newInstance(int merchantId, int regionId, int position) {

        Bundle args = new Bundle();
        args.putInt(MERCHANT_ID, merchantId);
        args.putInt(REGION_ID, regionId);
        args.putInt(POSITION, position);
        MerchantPhotoListFrag fragment = new MerchantPhotoListFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mMerchantId = arguments.getInt(MERCHANT_ID);
            mRegionId = arguments.getInt(REGION_ID);
            mParentPosition = arguments.getInt(POSITION);
        }
    }

    @Override
    public MerchantPicListPre createPresenter() {
        return new MerchantPicListPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_merchant_photo_list;
    }

    @Override
    public void initView() {
        super.initView();

        mMerchantPhotoListAdapter = new MerchantPhotoListAdapter(this);
        mMerchantPhotoListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mMerchantPhotoListAdapter);

        final int rectSize = getResources().getDimensionPixelOffset(R.dimen.hor_divider_size_7);
        mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(rectSize, rectSize, rectSize, rectSize);
            }
        });
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getPicList(mMerchantId, mRegionId);
    }

    @Override
    public void showLoading(int loading, boolean isShow) {
        if (loading == ShowConfig.LOADING_STATE) {
            if (isShow) {
                mRecyclerView.setVisibility(View.GONE);
                if (mLoading == null) {
                    mLoading = findViewById(R.id.view_stu_loading);
                    mLoading.inflate();
                }
                mLoading.setVisibility(View.VISIBLE);
            } else {
                if (mLoading != null) {
                    mLoading.setVisibility(View.GONE);
                }
                mRecyclerView.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public void onPicListResult(ArrayList<MerchantPicInfoBean> picInfoList) {
        mPicInfoList.clear();
        mPicInfoList.addAll(picInfoList);
        mMerchantPhotoListAdapter.setPicInfoBeans(mPicInfoList);
    }

    @Override
    public void onItemClick(int position, MerchantPicInfoBean entity, View view) {
        //传递当前分类数组
        //当前分类数组下标，用于默认选中
        //当前图片数组
        //当前点击图片下标，图片显示定位
        Intent intent = new Intent(mFragmentActivity, MerchantPicPreviewAct.class);
        intent.putExtra(MerchantPicPreviewAct.PARENT_POSITION, mParentPosition);
        intent.putExtra(MerchantPicPreviewAct.CHILD_POSITION, position);
        intent.putExtra(MerchantPicPreviewAct.EXTRA_DATA, mPicInfoList);
        intent.putExtra(MerchantPicPreviewAct.MERCHANT_ID, mMerchantId);
        startActivity(intent);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/login/SendVerifyCodeFrag.java<|end_filename|>
package com.scj.beilu.app.ui.login;

import android.Manifest;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.common.UserInfoPre;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.util.CheckUtils;
import com.scj.beilu.app.util.ToastUtils;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

/**
 * @author Mingxun
 * @time on 2019/2/13 15:08
 */
@RuntimePermissions
public class SendVerifyCodeFrag extends BaseMvpFragment<UserInfoPre.VerifyCodeView, UserInfoPre>
        implements UserInfoPre.VerifyCodeView, View.OnClickListener {
    private TextView mTvSendHint, mTvCountdown;
    private EditText mEtVerifyCode;
    private Button mBtnStartVerify, mBtnRestartSend;

    private static final String EXTRA_PHONE_NUMBER = "number";
    private static final String EXTRA_USE_TYPE = "login_register";

    private String mNumber = null;
    private boolean mIsLogin = true;
    private String mCode;

    public static SendVerifyCodeFrag newInstance(String number, boolean isLogin) {

        Bundle args = new Bundle();
        args.putString(EXTRA_PHONE_NUMBER, number);
        args.putBoolean(EXTRA_USE_TYPE, isLogin);
        SendVerifyCodeFrag fragment = new SendVerifyCodeFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mNumber = arguments.getString(EXTRA_PHONE_NUMBER);
            mIsLogin = arguments.getBoolean(EXTRA_USE_TYPE);
        }
    }

    @Override
    public int getLayout() {
        return R.layout.frag_input_code;
    }

    @Override
    public void initView() {
        super.initView();

        mTvSendHint = findViewById(R.id.tv_send_hint);
        mTvCountdown = findViewById(R.id.tv_countdown);
        mEtVerifyCode = findViewById(R.id.et_verify_code);
        mBtnStartVerify = findViewById(R.id.btn_start_verify);
        mBtnRestartSend = findViewById(R.id.btn_restart_send);

        mBtnStartVerify.setOnClickListener(this);
        mBtnRestartSend.setOnClickListener(this);
        hideSoftInput();

        try {
            CheckUtils.checkStringIsNull(mNumber, "");

            getPresenter().setHintNum(mNumber);
            if (mIsLogin) {
                getPresenter().startLoginSend(mNumber);
            } else {
                getPresenter().startRegSend(mNumber);
            }
            getPresenter().checkTxt(mEtVerifyCode);
            mBtnStartVerify.setEnabled(false);
            mBtnRestartSend.setEnabled(false);
        } catch (RuntimeException e) {

        }

    }


    private final CountDownTimer mTimer = new CountDownTimer(60000, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            String hint = String.format(getString(R.string.countdown_hint), (millisUntilFinished / 1000) + "s");
            mTvCountdown.setText(hint);
        }

        @Override
        public void onFinish() {
            String hint = String.format(getString(R.string.countdown_hint), "0s");
            mTvCountdown.setText(hint);
            mBtnRestartSend.setEnabled(true);
            mBtnRestartSend.setText("重新发送");
        }
    };

    @NonNull
    @Override
    public UserInfoPre createPresenter() {
        return new UserInfoPre(mFragmentActivity);
    }

    @Override
    public void showSendHint(String content) {
        mTvSendHint.setText(content);
    }

    @Override
    public void codeResult(ResultMsgBean result) {
        if (result.getCode() == 1004) {
            new AlertDialog.Builder(mFragmentActivity)
                    .setPositiveButton("切换", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            mIsLogin = true;
                            getPresenter().startLoginSend(mNumber);
                        }
                    })
                    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    })
                    .setCancelable(false)
                    .setMessage(result.getResult() + ",是否切换至登录?")
                    .show();
        } else {
            mTimer.start();
            ToastUtils.showToast(mFragmentActivity, result.getResult());
        }
    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        ImmersionBar.with(this).statusBarDarkFont(true,0.2f)
                .statusBarColor(android.R.color.white)
                .fitsSystemWindows(true)
                .init();
    }

    @Override
    public void onButtonEnable(boolean enable, String txt) {
        mCode = txt;
        mBtnStartVerify.setEnabled(enable);
    }

    @Override
    public void onLoginSuccess() {
        mFragmentActivity.finish();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_start_verify:
                SendVerifyCodeFragPermissionsDispatcher.NeedsPhoneStateWithPermissionCheck(this);
                break;
            case R.id.btn_restart_send:

                if (mIsLogin) {
                    getPresenter().startLoginSend(mNumber);
                } else {
                    getPresenter().startRegSend(mNumber);
                }
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mTimer.cancel();
    }

    @NeedsPermission(Manifest.permission.READ_PHONE_STATE)
    void NeedsPhoneState() {
        if (mIsLogin) {
            getPresenter().startLogin(mNumber, mCode);
        } else {
            getPresenter().startReg(mNumber, mCode);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        SendVerifyCodeFragPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

    @OnShowRationale(Manifest.permission.READ_PHONE_STATE)
    void OnShowRationalePhoneState(final PermissionRequest request) {
        showRationaleDialog(R.string.permission_phone_state_rationale, request);
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/adapter/CourseCommentListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.course.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.course.bean.CourseCommentInfoBean;
import com.scj.beilu.app.ui.course.CourseDetailsCommentFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/25 20:30
 */
public class CourseCommentListAdapter extends RecyclerView.Adapter<CourseCommentListAdapter.CommentListViewHolder> {

    private List<CourseCommentInfoBean> mCourseCommentInfoList;
    private GlideRequest<Drawable> mOriginalRequest;
    private GlideRequest<Drawable> mThumbnailRequest;

    public CourseCommentListAdapter(CourseDetailsCommentFrag frag) {
        mOriginalRequest = GlideApp.with(frag).asDrawable().circleCrop();
        mThumbnailRequest = GlideApp.with(frag).asDrawable().circleCrop();
    }

    public void setCourseCommentInfoList(List<CourseCommentInfoBean> courseCommentInfoList) {
        mCourseCommentInfoList = courseCommentInfoList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public CommentListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_course_comment_content, parent, false);
        return new CommentListViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CommentListViewHolder holder, int position) {
        try {
            CourseCommentInfoBean commentContent = mCourseCommentInfoList.get(position);
            mOriginalRequest.load(commentContent.getUserHead())
                    .thumbnail(mThumbnailRequest.load(commentContent.getUserHeadCompression()))
                    .into(holder.mIvAvatar);
            holder.mTvUserName.setText(commentContent.getUserName());
            holder.mTvContent.setText(commentContent.getComContent());
            holder.mTvTime.setText(commentContent.getDate());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mCourseCommentInfoList == null ? 0 : mCourseCommentInfoList.size();
    }

    public class CommentListViewHolder extends BaseViewHolder {
        private ImageView mIvAvatar;
        private TextView mTvUserName;
        private TextView mTvContent;
        private TextView mTvTime;

        public CommentListViewHolder(View itemView) {
            super(itemView);
            mIvAvatar = findViewById(R.id.iv_course_comment_avatar);
            mTvUserName = findViewById(R.id.tv_course_comment_user);
            mTvContent = findViewById(R.id.tv_course_comment_content);
            mTvTime = findViewById(R.id.tv_course_comment_time);
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/adapter/CourseTypeListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.course.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.course.bean.CourseTypeInfoBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/20 16:02
 */
public class CourseTypeListAdapter extends RecyclerView.Adapter<CourseTypeListAdapter.CourseTypeViewHolder> {

    private List<CourseTypeInfoBean> mCourseTypeInfoList;
    private OnItemClickListener<CourseTypeInfoBean> mOnItemClickListener;

    public void setCourseTypeInfoList(List<CourseTypeInfoBean> courseTypeInfoList) {
        mCourseTypeInfoList = courseTypeInfoList;
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnItemClickListener<CourseTypeInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public CourseTypeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_course_type_content, parent, false);
        return new CourseTypeViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CourseTypeViewHolder holder, int position) {
        try {
            CourseTypeInfoBean infoBean = mCourseTypeInfoList.get(position);

            holder.mTvCourseTypeVal.setText(infoBean.getCourseCateName());
            holder.mTvCourseTypeVal.setSelected(infoBean.isSelect());
            holder.mView.setVisibility(infoBean.isSelect() ? View.VISIBLE : View.GONE);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mCourseTypeInfoList == null ? 0 : mCourseTypeInfoList.size();
    }

    public class CourseTypeViewHolder extends BaseViewHolder {
        private TextView mTvCourseTypeVal;
        private View mView;

        public CourseTypeViewHolder(View itemView) {
            super(itemView);
            mTvCourseTypeVal = findViewById(R.id.tv_course_type_val);
            mView = findViewById(R.id.view_show_rect);
            mTvCourseTypeVal.setOnClickListener(v -> {
                if (mOnItemClickListener != null) {
                    try {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), mCourseTypeInfoList.get(getAdapterPosition()), v);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/adapter/CourseQ$AListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.course.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.course.bean.CourseDetailsQ$AInfoBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/22 18:33
 */
public class CourseQ$AListAdapter extends RecyclerView.Adapter<CourseQ$AListAdapter.QAViewHolder> {

    private List<CourseDetailsQ$AInfoBean> mDetailsQ$AInfoList;

    public CourseQ$AListAdapter(Context context) {
    }

    public void setDetailsQ$AInfoList(List<CourseDetailsQ$AInfoBean> detailsQ$AInfoList) {
        mDetailsQ$AInfoList = detailsQ$AInfoList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public QAViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_q_a_content, parent, false);
        return new QAViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull QAViewHolder holder, int position) {
        CourseDetailsQ$AInfoBean infoBean = mDetailsQ$AInfoList.get(position);
        holder.mTvQContent.setText(infoBean.getCourseQ());
        holder.mTvAContent.setText(infoBean.getCourseA());
    }

    @Override
    public int getItemCount() {
        return mDetailsQ$AInfoList == null ? 0 : mDetailsQ$AInfoList.size();
    }

    class QAViewHolder extends BaseViewHolder {
        private TextView mTvQContent, mTvAContent;


        public QAViewHolder(View itemView) {
            super(itemView);
            mTvQContent = findViewById(R.id.tv_q_content);
            mTvAContent = findViewById(R.id.tv_a_content);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/seller/CoachButtonAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter.seller;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/15
 * descriptin:
 */
public class CoachButtonAdapter extends RecyclerView.Adapter<CoachButtonAdapter.CoachButtonViewHolder> {
    @NonNull
    @Override
    public CoachButtonViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_coach_button, parent, false);
        return new CoachButtonViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CoachButtonViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 6;
    }

    public class CoachButtonViewHolder extends BaseViewHolder {

        public CoachButtonViewHolder(View itemView) {
            super(itemView);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/find/FindOrganizationPre.java<|end_filename|>
package com.scj.beilu.app.mvp.find;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.find.bean.OrganizationListBean;
import com.scj.beilu.app.mvp.find.model.FindImpl;

/**
 * author:SunGuiLan
 * date:2019/2/7
 * descriptin:
 */
public class FindOrganizationPre extends BaseMvpPresenter<FindOrganizationPre.FindOrganizationView> {
    private FindImpl mFind;

    public FindOrganizationPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mFind = new FindImpl(mBuilder);
    }

    /**
     * 获取组织动态
     */
    public void getOrganizationFindList() {

    }

    /**
     * 获取组织列表
     */
    public void getOrganizationList(final int currentPage) {
        onceViewAttached(new ViewAction<FindOrganizationView>() {
            @Override
            public void run(@NonNull FindOrganizationView mvpView) {
                mFind.getOrganization(currentPage)
                        .subscribe(new BaseResponseCallback<OrganizationListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(OrganizationListBean organizationListBean) {

                            }
                        });
            }
        });
    }

    public interface FindOrganizationView extends MvpView {

    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/adapter/MerchantInfoFacilityListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.merchant.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoFacilitiesBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/15 19:33
 * 设施
 */
public class MerchantInfoFacilityListAdapter extends RecyclerView.Adapter<MerchantInfoFacilityListAdapter.FacilityViewHolder> {

    private List<MerchantInfoFacilitiesBean> mFacilitiesBeans;

    public void setFacilitiesBeans(List<MerchantInfoFacilitiesBean> facilitiesBeans) {
        mFacilitiesBeans = facilitiesBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public FacilityViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_merchant_facility, parent, false);
        return new FacilityViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull FacilityViewHolder holder, int position) {
        try {
            MerchantInfoFacilitiesBean facilitiesBean = mFacilitiesBeans.get(position);
            holder.mIvFacility.setVisibility(facilitiesBean.getInstallName() == null ? View.INVISIBLE : View.VISIBLE);
            holder.mTvFacility.setText(facilitiesBean.getInstallName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mFacilitiesBeans == null ? 0 : mFacilitiesBeans.size();
    }

    public class FacilityViewHolder extends BaseViewHolder {
        private TextView mTvFacility;
        private ImageView mIvFacility;

        public FacilityViewHolder(View itemView) {
            super(itemView);
            mIvFacility = findViewById(R.id.iv_merchant_facility_);
            mTvFacility = findViewById(R.id.tv_facility_name);
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/HomeNewsAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter;

import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.scj.beilu.app.R;

import com.scj.beilu.app.base.BaseViewHolder;




/**
 * author: SunGuiLan
 * date:2019/2/13
 * descriptin:
 */
public class HomeNewsAdapter extends RecyclerView.Adapter {
    final int VIEW_TYPE_CONTENT1 = 0x002;
    final int VIEW_TYPE_CONTENT2 = 0x003;

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        final View view;
        switch (viewType) {
            case VIEW_TYPE_CONTENT1:
                view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_news_content1, parent, false);
                return new Content1ViewHolder(view);
            case VIEW_TYPE_CONTENT2:
                view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_news_content2, parent, false);
                return new Content2ViewHolder(view);
            default:
                view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_news_content2, parent, false);
                return new Content2ViewHolder(view);
        }

    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {

        if (holder instanceof Content1ViewHolder) {
            Content1ViewHolder content1ViewHolder = (Content1ViewHolder) holder;
            content1ViewHolder.mRvImgList.setAdapter(new HomeImageAdapter());
        }
    }


    @Override
    public int getItemCount() {
        return 2;
    }

    @Override
    public int getItemViewType(int position) {
        if (position % 2 == 0) {
            return VIEW_TYPE_CONTENT2;
        } else {
            return VIEW_TYPE_CONTENT1;
        }
    }


    class Content1ViewHolder extends BaseViewHolder {
        RecyclerView mRvImgList;

        public Content1ViewHolder(View itemView) {
            super(itemView);
            mRvImgList = findViewById(R.id.rv_news_img);
            mRvImgList.addItemDecoration(new RecyclerView.ItemDecoration() {
                @Override
                public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                    super.getItemOffsets(outRect, view, parent, state);
                    if (parent.getAdapter().getItemCount() == 10) {
                        outRect.set(5, 0, 0, 0);
                    } else {
                        outRect.set(5, 0, 5, 0);
                    }
                }
            });
        }
    }


    class Content2ViewHolder extends BaseViewHolder {
        public Content2ViewHolder(View itemView) {
            super(itemView);

        }
    }


}



<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/MinBindPhoneFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.scj.beilu.app.R;
import com.scj.beilu.app.util.InputValidate;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.AppToolbar;

/**
 * @author Mingxun
 * @time on 2019/4/16 22:12
 */
public class MinBindPhoneFrag extends SupportFragment {

    private AppToolbar mAppToolbar;
    private Button btn_code;
    private EditText et_phone;

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_bind_phone;
    }

    @Override
    public void initView() {
        super.initView();
        btn_code = findViewById(R.id.btn_code);
        et_phone = findViewById(R.id.et_phone);
        mAppToolbar = findViewById(R.id.toolbar);

        ImmersionBar.with(this)
                .titleBar(mAppToolbar)
                .statusBarDarkFont(true,0.2f)
                .keyboardEnable(true)
                .init();
        et_phone.addTextChangedListener(textWatcher);

        btn_code.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                start(MineStartBindPhoneFrag.newInstance(et_phone.getText().toString()));
            }
        });

        mAppToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mFragmentActivity.onBackPressed();
            }
        });
    }

    private final TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() == 11) {
                btnEnable(InputValidate.mobileFormat(s.toString()), s.toString());
            } else {
                btnEnable(false, null);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    };

    private void btnEnable(boolean enable, String text) {
        if (enable) {
            btn_code.setEnabled(true);
        } else {
            if (text != null) {
                ToastUtils.showToast(mFragmentActivity, "手机号码格式不正确");
            }
            if (btn_code.isEnabled()) {
                btn_code.setEnabled(false);
            }
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/CourseDetailsFrag.java<|end_filename|>
package com.scj.beilu.app.ui.course;

import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.course.CourseDetailsPre;
import com.scj.beilu.app.mvp.course.bean.CourseCommentInfoBean;
import com.scj.beilu.app.mvp.course.bean.CourseInfoBean;
import com.scj.beilu.app.mvp.course.bean.CourseVideoInfoBean;
import com.scj.beilu.app.mvp.course.bean.CourseVideoListBean;
import com.scj.beilu.app.ui.comment.SelectPaymentDialog;
import com.scj.beilu.app.ui.course.adapter.DescriptionFragAdapter;
import com.scj.beilu.app.util.ToastUtils;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

/**
 * @author Mingxun
 * @time on 2019/3/20 19:41
 */
@RuntimePermissions
public class CourseDetailsFrag extends BaseMvpFragment<CourseDetailsPre.CourseDetailsView, CourseDetailsPre>
        implements CourseDetailsPre.CourseDetailsView, TabLayout.OnTabSelectedListener,
        AppBarLayout.OnOffsetChangedListener, View.OnClickListener, TextWatcher,
        SelectPaymentDialog.onStartPay {

    private AppBarLayout mAppBarLayout;
    private TabLayout mTabCourseTitle;
    private ViewPager mViewPagerContent;
    private LinearLayout mLlStartPlay, mLlFreePlay, mLlBuy, mLlSingle;
    private ConstraintLayout mClComment;
    private TextView mTvStartPlay;
    private ImageView mIvBackground;
    private TextView mTvCourseName, mTvCourseSmallTitle;
    private TextView mTvTotalPrice, mTvDescription, mTvUnitPrice, mTvBuySingle, mTvCourseCount, mTvBuyCount;
    private TextView mTvFreePlay;
    private FrameLayout mFlConsult;
    private TextView mTvStartBuyAll;
    private EditText mEtCommentContent;
    private Button mBtnComment;

    private final String[] mTabTitles = {"老师简介", "课程简介", "课程目录", "评论"};

    private DescriptionFragAdapter mDescriptionFragAdapter;

    private final static String COURSE_ID = "course_id";
    private int mCourseId;

    //是否修改状态栏颜色为白色 默认true
    private boolean isChangeWhite = true;
    //是否修改状态栏颜色为黑色 默认false
    private boolean isChangeBlack = false;
    private String mRMB;
    private String phoneNum;
    private String mTotalPrice;

    private CourseDetailsDescFrag mCourseDetailsDescFrag;
    private CourseDetailsCatalogueFrag mCourseDetailsCatalogueFrag;
    private CourseDetailsCommentFrag mCourseDetailsCommentFrag;

    private List<CourseVideoInfoBean> mCourseVideoInfoBeans;
    private SelectPaymentDialog mSelectPaymentDialog;

    public static CourseDetailsFrag newInstance(int courseId) {

        Bundle args = new Bundle();
        args.putInt(COURSE_ID, courseId);
        CourseDetailsFrag fragment = new CourseDetailsFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mCourseId = arguments.getInt(COURSE_ID);
        }
        EventBus.getDefault().register(this);
    }

    @Override
    public CourseDetailsPre createPresenter() {
        return new CourseDetailsPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_course_details;
    }

    @Override
    public void initView() {
        super.initView();

        mIvBackground = findViewById(R.id.iv_course_background_img);

        mTvStartPlay = findViewById(R.id.tv_top_start_play);
        mAppBarLayout = findViewById(R.id.app_bar_layout_course);
        mTabCourseTitle = findViewById(R.id.tab_layout_course);
        mTvCourseName = findViewById(R.id.tv_course_name);
        mTvCourseSmallTitle = findViewById(R.id.tv_course_small_title);
        mTvTotalPrice = findViewById(R.id.tv_course_total_price);
        mTvDescription = findViewById(R.id.tv_course_desc);
        mTvUnitPrice = findViewById(R.id.tv_course_unit_price);
        mTvBuySingle = findViewById(R.id.tv_course_buy_single);
        mTvCourseCount = findViewById(R.id.tv_course_count);
        mTvBuyCount = findViewById(R.id.tv_course_buy_num);
        mViewPagerContent = findViewById(R.id.view_pager_course_description);
        mLlStartPlay = findViewById(R.id.ll_course_start_play);
        mLlFreePlay = findViewById(R.id.ll_course_free_play_video);
        mClComment = findViewById(R.id.cl_comment_layout);
        mLlBuy = findViewById(R.id.ll_course_buy);
        mLlSingle = findViewById(R.id.ll_course_single);
        mTvFreePlay = findViewById(R.id.tv_course_free_play);
        mFlConsult = findViewById(R.id.fl_course_consult);
        mTvStartBuyAll = findViewById(R.id.tv_course_buy_all);
        mEtCommentContent = findViewById(R.id.et_comment_content);
        mBtnComment = findViewById(R.id.btn_send_comment);

        initTabs();

        mAppBarLayout.addOnOffsetChangedListener(this);
        mTvStartPlay.setOnClickListener(this);
        mLlFreePlay.setOnClickListener(this);
        mTvBuySingle.setOnClickListener(this);
        mFlConsult.setOnClickListener(this);
        mTvStartBuyAll.setOnClickListener(this);
        mEtCommentContent.addTextChangedListener(this);
        mBtnComment.setOnClickListener(this);
    }

    private void initTabs() {
        if (isAdded()) {
            mRMB = getResources().getString(R.string.txt_rmb);
        }

        mTabCourseTitle.setupWithViewPager(mViewPagerContent);


        mCourseDetailsDescFrag = new CourseDetailsDescFrag();
        mCourseDetailsCatalogueFrag = new CourseDetailsCatalogueFrag();
        mCourseDetailsCommentFrag = CourseDetailsCommentFrag.newInstance(mCourseId);

        List<SupportFragment> fragments = new ArrayList<>();
        fragments.add(CourseDetailsTeacherDescFrag.newInstance(mCourseId));
        fragments.add(mCourseDetailsDescFrag);
        fragments.add(mCourseDetailsCatalogueFrag);
        fragments.add(mCourseDetailsCommentFrag);

        mTabCourseTitle.addOnTabSelectedListener(this);

        mDescriptionFragAdapter = new DescriptionFragAdapter(getChildFragmentManager());
        mDescriptionFragAdapter.setFragments(fragments);
        mViewPagerContent.setAdapter(mDescriptionFragAdapter);

        int count = mTabCourseTitle.getTabCount();
        for (int i = 0; i < count; i++) {
            mTabCourseTitle.getTabAt(i).setCustomView(getTabLayout(mTabTitles[i]));
        }

        setTabSelector(mTabCourseTitle.getTabAt(0), true);
        mViewPagerContent.setOffscreenPageLimit(count);


        LinearLayout linearLayout = (LinearLayout) mTabCourseTitle.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerPadding(60); // 设置分割线的pandding
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(getContext(),
                R.drawable.sp_exposure_select));
    }

    private View getTabLayout(CharSequence title) {
        View view = LayoutInflater.from(mFragmentActivity).inflate(R.layout.item_layout_tab_course, null);
        TextView tvTab = view.findViewById(R.id.tv_tab_item_title);
        tvTab.setText(title);
        return view;
    }

    private void setTabSelector(TabLayout.Tab tab, boolean selected) {
        View view = tab.getCustomView();
        if (view == null) return;
        TextView tvTab = view.findViewById(R.id.tv_tab_item_title);
        View indicator = view.findViewById(R.id.tv_tab_item_indicator);

        tvTab.setSelected(selected);
        indicator.setVisibility(selected ? View.VISIBLE : View.INVISIBLE);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getCourseDetails(mCourseId);
        getPresenter().getCourseVideoList(mCourseId);
    }

    @Override
    public void onCourseInfoResult(CourseInfoBean courseInfo) {
        try {


            mCourseDetailsDescFrag.setCourseInfo(courseInfo);

            GlideApp.with(this)
                    .load(courseInfo.getCourseBackPic())
                    .centerCrop()
                    .thumbnail(GlideApp.with(this)
                            .load(courseInfo.getCourseBackPicZip())
                            .centerCrop())
                    .into(mIvBackground);
            mTotalPrice = courseInfo.getCourseTotalPrice();
            mTvCourseName.setText(courseInfo.getCourseName());
            mTvCourseSmallTitle.setText(courseInfo.getCourseTitle());
            mTvTotalPrice.setText(String.format(mRMB, mTotalPrice));
            mTvDescription.setText(courseInfo.getCourseBrief());
            if (courseInfo.getCourseSinglePrice() != null) {
                mTvUnitPrice.setText(String.format(mRMB, courseInfo.getCourseSinglePrice()));
                mTvFreePlay.setText("首节免费");
                mLlSingle.setVisibility(View.VISIBLE);
            } else {
                mTvFreePlay.setText("全部免费");
                mLlSingle.setVisibility(View.GONE);
            }
            mTvCourseCount.setText("已更新：" + courseInfo.getCourseVideoCount() + "期");
            mTvBuyCount.setText("购买人：" + courseInfo.getCourseSaleCount() + "人");
            if (courseInfo.getCourseIsPurchase() == 0) {
                mTvStartBuyAll.setText("学习所有课程 ¥" + mTotalPrice);
            } else {
                mTvStartBuyAll.setVisibility(View.GONE);
                mLlSingle.setVisibility(View.GONE);
            }

            phoneNum = courseInfo.getCourseAdvisoryTel();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            mRefreshLayout.finishRefresh(true);
        }
    }

    @Override
    public void onVideoList(CourseVideoListBean courseVideoList) {
        try {
            mCourseVideoInfoBeans = courseVideoList.getCourseVideos();
            mCourseDetailsDescFrag.setCourseVideoInfoList(mCourseVideoInfoBeans);
            mCourseDetailsCatalogueFrag.setVideoInfoBeanList(mCourseVideoInfoBeans);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onCreateCommentResult(CourseCommentInfoBean result) {
        mCourseDetailsCommentFrag.getPresenter().createCommentNotify(result);
        hideSoftInput();
        mEtCommentContent.setText("");
        ToastUtils.showToast(mFragmentActivity, result.getResult());
    }

    @Override
    public void onClick(View v) {
        getPresenter().checkUserIsLogin(v.getId());
    }

    @Override
    protected void userStartAction(int viewId) {
        switch (viewId) {
            case R.id.tv_top_start_play:
            case R.id.ll_course_free_play_video:
                // 默认播放第一个视频
                if (mCourseVideoInfoBeans != null && mCourseVideoInfoBeans.size() > 0) {
                    CourseVideoInfoBean videoInfoBean = mCourseVideoInfoBeans.get(0);
                    Intent intent = new Intent(mFragmentActivity, CoursePlayAct.class);
                    intent.putExtra(CoursePlayAct.EXTRA_COURSE_ID, mCourseId);
                    intent.putExtra(CoursePlayAct.EXTRA_COURSE_VIDEO_ID, videoInfoBean.getCourseVideoId());
                    startActivity(intent);
                }
                break;
            case R.id.fl_course_consult:
                CourseDetailsFragPermissionsDispatcher.needCallPhoneWithPermissionCheck(this);
                break;
            case R.id.tv_course_buy_all:
                if (mSelectPaymentDialog != null) {
                    mSelectPaymentDialog = null;
                }
                mSelectPaymentDialog = SelectPaymentDialog.newInstance(String.valueOf(mTotalPrice));
                mSelectPaymentDialog.setOnStartPay(this);
                mSelectPaymentDialog.show(getChildFragmentManager(), mSelectPaymentDialog.getClass().getName());
                break;
            case R.id.tv_course_buy_single:
                mViewPagerContent.setCurrentItem(2);
                break;
            case R.id.btn_send_comment:
                getPresenter().createComment(mCourseId, mEtCommentContent.getText().toString());
                break;

        }
    }

    @Override
    public void startPay(boolean mSelectPayment) {
        getPresenter().startPayCourse(mSelectPayment ? 1 : 2, -1, mCourseId);
        if (mSelectPaymentDialog != null) {
            mSelectPaymentDialog.dismiss();
        }
    }

    @Subscribe
    public void payResult(BaseResp resp) {
        if (resp.errCode == 0) {
            ToastUtils.showToast(mFragmentActivity, "支付成功");
            mRefreshLayout.autoRefresh();
        } else {
            ToastUtils.showToast(mFragmentActivity, "支付失败");
        }
    }

    @Override
    public void onAliPaySuccess() {
        ToastUtils.showToast(mFragmentActivity, "支付成功");
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        if (tab.getPosition() == 3) {
            mLlBuy.setVisibility(View.GONE);
            mClComment.setVisibility(View.VISIBLE);
        } else {
            if (mLlBuy.getVisibility() == View.GONE) {
                mClComment.setVisibility(View.GONE);
                mLlBuy.setVisibility(View.VISIBLE);
            }
        }
        hideSoftInput();
        setTabSelector(tab, true);
    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {

        setTabSelector(tab, false);
    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }

    @Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        int totalScrollRange = -(appBarLayout.getTotalScrollRange() / 2);
        if (totalScrollRange >= verticalOffset) {
            if (isChangeWhite) {
                mFragmentActivity.runOnUiThread(() -> {
                    ImmersionBar.with(CourseDetailsFrag.this)
                            .statusBarDarkFont(true,0.2f)
                            .keyboardEnable(true)
                            .init();
                    isChangeBlack = true;
                    isChangeWhite = false;
                    mAppToolbar.setNavigationIcon(ContextCompat.getDrawable(mFragmentActivity, R.drawable.ic_back));
                    mLlStartPlay.setVisibility(View.VISIBLE);
                });
            }
        } else {
            if (isChangeBlack) {
                mFragmentActivity.runOnUiThread(() -> {
                    ImmersionBar.with(CourseDetailsFrag.this)
                            .statusBarDarkFont(false)
                            .keyboardEnable(true)
                            .init();

                    isChangeBlack = false;
                    isChangeWhite = true;
                    mAppToolbar.setNavigationIcon(ContextCompat.getDrawable(mFragmentActivity, R.drawable.ic_back_white));
                    mLlStartPlay.setVisibility(View.GONE);
                });
            }
        }
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        if (s.length() == 0) {
            mBtnComment.setEnabled(false);
        } else {
            if (!mBtnComment.isEnabled()) {
                mBtnComment.setEnabled(true);
            }
        }
    }

    @NeedsPermission(Manifest.permission.CALL_PHONE)
    void needCallPhone() {

        if (phoneNum != null) {
            new AlertDialog.Builder(mFragmentActivity)
                    .setPositiveButton("呼叫", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            Intent intent = new Intent(Intent.ACTION_CALL);
                            Uri data = Uri.parse("tel:" + phoneNum);
                            intent.setData(data);
                            startActivity(intent);
                        }
                    })
                    .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    })
                    .setCancelable(false)
                    .setMessage(phoneNum)
                    .show();
        } else {
            ToastUtils.showToast(mFragmentActivity, "暂时无法联系客服哦~");
        }

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        CourseDetailsFragPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

    @OnShowRationale(Manifest.permission.CALL_PHONE)
    void rationalePhone(final PermissionRequest request) {
        showRationaleDialog(R.string.permission_call_phone, request);
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/merchant/MerchantAlbumPre.java<|end_filename|>
package com.scj.beilu.app.mvp.merchant;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoCoachPicInfoBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoCoachPicInfoResultBean;
import com.scj.beilu.app.mvp.merchant.model.IMerchantInfo;
import com.scj.beilu.app.mvp.merchant.model.MerchantInfoImpl;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/16 17:21
 */
public class MerchantAlbumPre extends BaseMvpPresenter<MerchantAlbumPre.MerchantAlbumView> {
    private IMerchantInfo mMerchantInfo;

    public MerchantAlbumPre(Context context) {
        super(context, ShowConfig.LOADING_STATE, ShowConfig.ERROR_TOAST);
        mMerchantInfo = new MerchantInfoImpl(mBuilder);
    }

    public void getAlbumList(final int merchantId, final int coachId) {
        onceViewAttached(new ViewAction<MerchantAlbumView>() {
            @Override
            public void run(@NonNull final MerchantAlbumView mvpView) {
                mMerchantInfo.getCoachAlbumList(merchantId, coachId)
                        .subscribe(new BaseResponseCallback<MerchantInfoCoachPicInfoResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(MerchantInfoCoachPicInfoResultBean merchantInfoCoachPicInfoResultBean) {
                                try {
                                    ArrayList<MerchantInfoCoachPicInfoBean> coachPicList = merchantInfoCoachPicInfoResultBean.getCoachPicList();
                                    mvpView.onAlbumList(coachPicList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface MerchantAlbumView extends MvpView {
        void onAlbumList(ArrayList<MerchantInfoCoachPicInfoBean> albumList);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/CoursePlayAct.java<|end_filename|>
package com.scj.beilu.app.ui.course;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.orhanobut.logger.Logger;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseVideoMvpActivity;
import com.scj.beilu.app.mvp.course.CoursePlayerPre;
import com.scj.beilu.app.mvp.course.bean.CourseCommentInfoBean;
import com.scj.beilu.app.mvp.course.bean.CourseVideoInfoBean;
import com.scj.beilu.app.ui.course.adapter.DescriptionFragAdapter;
import com.scj.beilu.app.util.ToastUtils;
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Mingxun
 * @time on 2019/3/25 21:51
 */
public class CoursePlayAct extends BaseVideoMvpActivity<CoursePlayerPre.CoursePlayerView,
        CoursePlayerPre, StandardGSYVideoPlayer>
        implements CoursePlayerPre.CoursePlayerView,
        TabLayout.OnTabSelectedListener, TextWatcher, View.OnClickListener,
        CourseDetailsCatalogueFrag.onVideoPlayer {

    private StandardGSYVideoPlayer mDetailPlayer;
    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private ConstraintLayout mConstraintLayout;
    private EditText mEtCommentContent;
    private Button mBtnComment;

    public static final String EXTRA_COURSE_ID = "course_id";
    public static final String EXTRA_COURSE_VIDEO_ID = "video_id";

    private int mCourseId;
    private int mCourseVideoId;
    private final int defaultVal = -1;

    private DescriptionFragAdapter mDescriptionFragAdapter;

    private CourseDetailsCommentFrag mCourseDetailsCommentFrag;
    private CourseDetailsCatalogueFrag mCourseDetailsCatalogueFrag;

    private CourseVideoInfoBean mVideoInfoBean;
    private GlideRequest<Drawable> mOriginalRequest;
    private GlideRequest<Drawable> mThumbnailRequest;


    @NonNull
    @Override
    public CoursePlayerPre createPresenter() {
        return new CoursePlayerPre(this);
    }

    @Override
    public int getLayout() {
        return R.layout.act_course_play;
    }

    @Override
    protected void initView() {
        super.initView();

        mDetailPlayer = findViewById(R.id.course_detail_player);
        mViewPager = findViewById(R.id.view_pager_course_player);
        mTabLayout = findViewById(R.id.tab_layout_course);
        mConstraintLayout = findViewById(R.id.cl_comment_layout);
        mEtCommentContent = findViewById(R.id.et_comment_content);
        mBtnComment = findViewById(R.id.btn_send_comment);

        ImmersionBar.with(this)
                .reset()
                .statusBarColor(android.R.color.black)
                .titleBar(findViewById(R.id.view_top))
                .init();


        mTabLayout.setupWithViewPager(mViewPager);

        mDetailPlayer.getTitleTextView().setVisibility(View.VISIBLE);
        mDetailPlayer.getBackButton().setVisibility(View.VISIBLE);

        mTabLayout.addOnTabSelectedListener(this);

        Intent intent = getIntent();
        mCourseId = intent.getIntExtra(EXTRA_COURSE_ID, defaultVal);
        mCourseVideoId = intent.getIntExtra(EXTRA_COURSE_VIDEO_ID, defaultVal);

        List<SupportFragment> fragments = new ArrayList<>();
        mCourseDetailsCommentFrag = CourseDetailsCommentFrag.newInstance(mCourseId);
        mCourseDetailsCatalogueFrag = CourseDetailsCatalogueFrag.newInstance(mCourseId);
        mCourseDetailsCatalogueFrag.setOnVideoPlayer(this);
        fragments.add(mCourseDetailsCatalogueFrag);
        fragments.add(mCourseDetailsCommentFrag);

        mDescriptionFragAdapter = new DescriptionFragAdapter(getSupportFragmentManager());
        mDescriptionFragAdapter.setFragments(fragments);
        mViewPager.setAdapter(mDescriptionFragAdapter);

        int count = mTabLayout.getTabCount();
        final String[] mTabTitles = {"课程目录", "评论"};

        if (count == mTabTitles.length) {
            for (int i = 0; i < count; i++) {
                mTabLayout.getTabAt(i).setCustomView(getTabLayout(mTabTitles[i]));
            }
            setTabSelector(mTabLayout.getTabAt(0), true);
            mViewPager.setOffscreenPageLimit(count);
        }

        LinearLayout linearLayout = (LinearLayout) mTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerPadding(60); // 设置分割线的pandding
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(this,
                R.drawable.sp_exposure_select));

        mDetailPlayer.getBackButton().setOnClickListener(this);
        mEtCommentContent.addTextChangedListener(this);
        mBtnComment.setOnClickListener(this);

        getPresenter().getVideoInfo(mCourseVideoId);

        mOriginalRequest = GlideApp.with(this).asDrawable().centerCrop();
        mThumbnailRequest = GlideApp.with(this).asDrawable().circleCrop();
    }

    @Override
    public StandardGSYVideoPlayer getGSYVideoPlayer() {
        return mDetailPlayer;
    }

    @Override
    public GSYVideoOptionBuilder getGSYVideoOptionBuilder() {
        GSYVideoOptionBuilder gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
        try {
            ImageView imageView = new ImageView(this);

            mOriginalRequest
                    .load(mVideoInfoBean.getCourseVideoPic())
                    .thumbnail(mThumbnailRequest.load(mVideoInfoBean.getCourseVideoPicZip()))
                    .into(imageView);
            Logger.e(mVideoInfoBean.getCourseVideoAddr() + "=====" + mVideoInfoBean.getCourseVideoName());
            Map<String, String> header = new HashMap<>();
            header.put("Referer", "https://coursevideo.cqsanchaji.com");
            gsyVideoOptionBuilder
                    .setThumbImageView(imageView)
                    .setUrl(mVideoInfoBean.getCourseVideoAddr())
                    .setMapHeadData(header)
                    .setCacheWithPlay(true)
                    .setVideoTitle(mVideoInfoBean.getCourseVideoName())
                    .setIsTouchWiget(true)
                    .setRotateViewAuto(false)
                    .setLockLand(false)
                    .setAutoFullWithSize(true)
                    .setShowFullAnimation(true)//打开动画
                    .setNeedLockFull(true)
                    .setSeekRatio(1);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return gsyVideoOptionBuilder;
    }

    @Override
    public void clickForFullScreen() {

    }

    @Override
    public boolean getDetailOrientationRotateAuto() {
        return true;
    }

    private View getTabLayout(CharSequence title) {
        View view = LayoutInflater.from(this).inflate(R.layout.item_layout_tab_course, null);
        TextView tvTab = view.findViewById(R.id.tv_tab_item_title);
        tvTab.setText(title);
        return view;
    }

    private void setTabSelector(TabLayout.Tab tab, boolean selected) {
        View view = tab.getCustomView();
        if (view == null) return;
        TextView tvTab = view.findViewById(R.id.tv_tab_item_title);
        View indicator = view.findViewById(R.id.tv_tab_item_indicator);

        tvTab.setSelected(selected);
        indicator.setVisibility(selected ? View.VISIBLE : View.INVISIBLE);
    }

    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        if (tab.getPosition() == 1) {
            mConstraintLayout.setVisibility(View.VISIBLE);
        } else {
            if (mConstraintLayout.getVisibility() == View.VISIBLE) {
                mConstraintLayout.setVisibility(View.GONE);
            }
        }
        hideSoftInput();
        setTabSelector(tab, true);
    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {
        setTabSelector(tab, false);
    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }


    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        if (s.length() == 0) {
            mBtnComment.setEnabled(false);
        } else {
            if (!mBtnComment.isEnabled()) {
                mBtnComment.setEnabled(true);
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_send_comment:
                getPresenter().createComment(mCourseId, mEtCommentContent.getText().toString());
                break;
            case R.id.back:
                onBackPressedSupport();
                break;
        }
    }

    @Override
    public void onCreateCommentResult(CourseCommentInfoBean result) {
        mCourseDetailsCommentFrag.getPresenter().createCommentNotify(result);
        hideSoftInput();
        mEtCommentContent.setText("");
        ToastUtils.showToast(this, result.getResult());
    }

    @Override
    public void onVideoInfo(CourseVideoInfoBean videoInfo) {
        mVideoInfoBean = videoInfo;
        initVideoBuilderMode();
        getGSYVideoPlayer().getCurrentPlayer().startPlayLogic();
    }

    @Override
    public void onVideoInfoByCatalogue(int courseVideoId) {
        getPresenter().getVideoInfo(courseVideoId);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindDetailsParentCommentAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.find.bean.FindCommentBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/25 21:58
 * 动态详情评论列表适配器
 */
public class FindDetailsParentCommentAdapter extends RecyclerView.Adapter<FindDetailsParentCommentViewHolder> {
    private GlideRequest<Drawable> mGlideRequests;
    private OnItemClickListener mItemClickListener;
    private List<FindCommentBean> mFindCommentBeans;

    public FindDetailsParentCommentAdapter(GlideRequest<Drawable> glideRequests) {
        mGlideRequests = glideRequests;
    }

    public void setItemClickListener(OnItemClickListener itemClickListener) {
        mItemClickListener = itemClickListener;
    }

    public void setFindCommentBeans(List<FindCommentBean> findCommentBeans) {
        mFindCommentBeans = findCommentBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public FindDetailsParentCommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view =
                LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_news_comment_content, parent, false);
        return new FindDetailsParentCommentViewHolder(view, mGlideRequests, mItemClickListener);
    }

    @Override
    public void onBindViewHolder(@NonNull FindDetailsParentCommentViewHolder holder, int position) {
        holder.setBind(mFindCommentBeans.get(position));
    }

    @Override
    public int getItemCount() {
        return mFindCommentBeans == null ? 0 : mFindCommentBeans.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/store/adapter/GoodsImgAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.store.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.store.bean.GoodsImgInfoBean;
import com.scj.beilu.app.ui.store.GoodsDetailFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/28 18:32
 */
public class GoodsImgAdapter extends PagerAdapter {
    private List<GoodsImgInfoBean> mFindImageBeanList;
    private GlideRequest<Drawable> mOriginalGlideRequest;
    private GlideRequest<Drawable> mThumbnailGlideRequests;

    private OnItemClickListener mItemClickListener;

    public GoodsImgAdapter(GoodsDetailFrag frag) {
        mOriginalGlideRequest = GlideApp.with(frag).asDrawable().centerCrop();
        mThumbnailGlideRequests = GlideApp.with(frag).asDrawable().centerCrop();
    }

    public void setImgList(List<GoodsImgInfoBean> findImageBeanList) {
        mFindImageBeanList = findImageBeanList;
        notifyDataSetChanged();
    }

    public void setItemClickListener(OnItemClickListener itemClickListener) {
        mItemClickListener = itemClickListener;
    }

    @Override
    public int getCount() {
        return mFindImageBeanList == null ? 0 : mFindImageBeanList.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, final int position) {
        ImageView imageView = new ImageView(container.getContext());
        imageView.setId(R.id.imageView);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        final GoodsImgInfoBean imageBean = mFindImageBeanList.get(position);
        mOriginalGlideRequest
                .load(imageBean.getProductPicOriginalAddr())
                .thumbnail(mThumbnailGlideRequests.load(imageBean.getProductPicCompressionAddr()))
                .into(imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mItemClickListener != null) {
                    mItemClickListener.onItemClick(position, imageBean, view);
                }
            }
        });
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        (container).removeView(container);
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/delegate/MvpDelegateCallback.java<|end_filename|>
package com.mx.pro.lib.mvp.delegate;

import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpPresenter;
import com.mx.pro.lib.mvp.MvpView;

public interface MvpDelegateCallback<V extends MvpView, P extends MvpPresenter<V>> {
    @NonNull
    P createPresenter();

    P getPresenter();

    void setPresenter(P presenter);

    V getMvpView();
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/fit/FitRecordImgPreviewPre.java<|end_filename|>
package com.scj.beilu.app.mvp.fit;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.fit.model.FitRecordImpl;
import com.scj.beilu.app.mvp.fit.model.IFitRecord;

/**
 * @author Mingxun
 * @time on 2019/3/15 18:06
 */
public class FitRecordImgPreviewPre extends BaseMvpPresenter<FitRecordImgPreviewPre.FitRecordImgPreviewView> {
    private IFitRecord mFitRecord;

    public FitRecordImgPreviewPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mFitRecord = new FitRecordImpl(mBuilder);
    }

    public void deleteImg(final long recordId) {
        onceViewAttached(new ViewAction<FitRecordImgPreviewView>() {
            @Override
            public void run(@NonNull final FitRecordImgPreviewView mvpView) {
                mFitRecord.deleteImg(recordId)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onDelResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public interface FitRecordImgPreviewView extends MvpView {
        void onDelResult(String result);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/store/adapter/GoodsCategoryListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.store.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.store.bean.GoodsCategoryInfoBean;

import java.util.List;

/**
 * author:SunGuiLan
 * date:2019/2/13
 * descriptin: 首页--4个按钮
 */
public class GoodsCategoryListAdapter extends RecyclerView.Adapter<GoodsCategoryListAdapter.HomeButtonViewHolder> {

    private List<GoodsCategoryInfoBean> mGoodsCategoryInfoBeans;

    private OnItemClickListener mItemClickListener;

    private GlideRequest<Drawable> mOriginalRequest;
    private GlideRequest<Drawable> mThumbnailRequest;

    public GoodsCategoryListAdapter(SupportFragment fragment) {
        mOriginalRequest = GlideApp.with(fragment).asDrawable().fitCenter();
        mThumbnailRequest = GlideApp.with(fragment).asDrawable().fitCenter();
    }

    public void setItemClickListener(OnItemClickListener itemClickListener) {
        mItemClickListener = itemClickListener;
    }

    public void setGoodsCategoryInfoBeans(List<GoodsCategoryInfoBean> goodsCategoryInfoBeans) {
        mGoodsCategoryInfoBeans = goodsCategoryInfoBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public HomeButtonViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_button, parent, false);
        return new HomeButtonViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final HomeButtonViewHolder holder, final int position) {
        GoodsCategoryInfoBean categoryInfoBean = mGoodsCategoryInfoBeans.get(position);
        mOriginalRequest
                .load(categoryInfoBean.getProductCatePicOriginalAddr())
                .thumbnail(mThumbnailRequest.load(categoryInfoBean.getProductCatePicCompressadAddr()))
                .into(holder.iv_photo);

        holder.tv_name.setText(categoryInfoBean.getProductCateName());

    }

    @Override
    public int getItemCount() {
        return mGoodsCategoryInfoBeans == null ? 0 : mGoodsCategoryInfoBeans.size();
    }

    class HomeButtonViewHolder extends BaseViewHolder {
        private ImageView iv_photo;
        private TextView tv_name;

        public HomeButtonViewHolder(View itemView) {
            super(itemView);
            iv_photo = findViewById(R.id.iv_photo);
            tv_name = findViewById(R.id.tv_name);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    GoodsCategoryInfoBean categoryInfoBean = mGoodsCategoryInfoBeans.get(getAdapterPosition());
                    if (mItemClickListener != null && categoryInfoBean != null) {
                        mItemClickListener.onItemClick(getAdapterPosition(), categoryInfoBean, v);
                    }
                }
            });
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/MineCollectFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.MyCollectPre;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.ui.mine.adapter.CollectGoodsListAdapter;
import com.scj.beilu.app.ui.mine.adapter.CollectNewsListAdapter;
import com.scj.beilu.app.ui.news.NewsDetailsAct;
import com.scj.beilu.app.ui.store.StoreInfoAct;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/9 16:46
 */
public class MineCollectFrag extends BaseMvpFragment<MyCollectPre.MyCollectView, MyCollectPre>
        implements MyCollectPre.MyCollectView, OnItemClickListener {

    private static final String INDEX = "index";
    private int mIndex;
    private final int REQUEST_NEWS_DETAILS = 0x010;
    private final int REQUEST_GOODS = 0x011;

    private CollectNewsListAdapter mCollectNewsListAdapter;
    private CollectGoodsListAdapter mCollectGoodsListAdapter;

    public static MineCollectFrag newInstance(int index) {

        Bundle args = new Bundle();
        args.putInt(INDEX, index);
        MineCollectFrag fragment = new MineCollectFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mIndex = arguments.getInt(INDEX);
        }
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        if (mIndex == 0) {
            getPresenter().getMyCollectNews(mCurrentPage);
        } else {
            getPresenter().getMyCollectGoods(mCurrentPage);
        }
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        if (mIndex == 0) {
            getPresenter().getMyCollectNews(mCurrentPage);
        } else {
            getPresenter().getMyCollectGoods(mCurrentPage);
        }
    }

    @Override
    public MyCollectPre createPresenter() {
        return new MyCollectPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_collect_list;
    }

    @Override
    public void initView() {
        super.initView();

        if (mIndex == 0) {
            mCollectNewsListAdapter = new CollectNewsListAdapter(this);
            mCollectNewsListAdapter.setOnItemClickListener(this);
            mRecyclerView.setAdapter(mCollectNewsListAdapter);
        } else {
            mCollectGoodsListAdapter = new CollectGoodsListAdapter(this);
            mCollectGoodsListAdapter.setOnItemClickListener(this);
            mRecyclerView.setAdapter(mCollectGoodsListAdapter);
        }

        mRecyclerView.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));
    }

    @Override
    public void onNewsList(List<NewsInfoBean> newsList) {
        mCollectNewsListAdapter.setNewsInfoList(newsList);
    }

    @Override
    public void onGoodsList(List<GoodsInfoBean> goodsInfoBeanList) {
        mCollectGoodsListAdapter.setGoodsInfoList(goodsInfoBeanList);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        if (entity instanceof NewsInfoBean) {
            NewsInfoBean infoBean = (NewsInfoBean) entity;
//            NewsDetailsAct.startNewsDetailsAct(mFragmentActivity, infoBean);
            Intent intent = new Intent(mFragmentActivity, NewsDetailsAct.class);
            intent.putExtra(NewsDetailsAct.EXTRA_CONTENT, infoBean);
            startActivityForResult(intent, REQUEST_NEWS_DETAILS);
        } else if (entity instanceof GoodsInfoBean) {
            GoodsInfoBean info = (GoodsInfoBean) entity;
            Intent intent = new Intent(mFragmentActivity, StoreInfoAct.class);
            intent.putExtra(StoreInfoAct.PRODUCT_ID, info.getProductId());
            startActivityForResult(intent, REQUEST_GOODS);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_OK) {
            mRefreshLayout.autoRefresh();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/comment/SelectPaymentDialog.java<|end_filename|>
package com.scj.beilu.app.ui.comment;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.ui.dialog.MyBottomSheetDialog;

/**
 * @author Mingxun
 * @time on 2019/4/2 21:02
 */
public class SelectPaymentDialog extends AppCompatDialogFragment implements View.OnClickListener {

    private TextView mTvTotalPrice;
    private TextView mTvStartPay;
    private FrameLayout mFlWxPay, mFlAliPay, mFlBgView;
    private ImageView mIvWxPay, mIvAliPay;
    private ImageButton mBtnClose;

    private static final String TOTAL_PRICE = "total_price";
    private String mPrice;
    private boolean mSelectPayment;//true wx false alipay
    private onStartPay mOnStartPay;

    public interface onStartPay {
        /**
         * @param mSelectPayment true wx false alipay
         */
        void startPay(boolean mSelectPayment);
    }

    public void setOnStartPay(onStartPay onStartPay) {
        mOnStartPay = onStartPay;
    }

    public static SelectPaymentDialog newInstance(String price) {

        Bundle args = new Bundle();
        args.putString(TOTAL_PRICE, price);
        SelectPaymentDialog fragment = new SelectPaymentDialog();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mPrice = arguments.getString(TOTAL_PRICE);
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new MyBottomSheetDialog(getContext());
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_select_payment, container);
        initView(view);
        return view;
    }

    private void initView(View view) {

        mTvTotalPrice = view.findViewById(R.id.tv_pay_total_price);
        mFlWxPay = view.findViewById(R.id.fl_payment_wx);
        mFlAliPay = view.findViewById(R.id.fl_payment_alipay);
        mFlBgView = view.findViewById(R.id.fl_dialog_bg_view);
        mIvWxPay = view.findViewById(R.id.iv_payment_select_wx);
        mIvAliPay = view.findViewById(R.id.iv_payment_select_alipay);
        mBtnClose = view.findViewById(R.id.btn_payment_close);
        mTvStartPay = view.findViewById(R.id.tv_payment_start);

        mBtnClose.setOnClickListener(this);
        mTvStartPay.setOnClickListener(this);
        mFlBgView.setOnClickListener(this);
        mFlWxPay.setOnClickListener(this);
        mFlAliPay.setOnClickListener(this);

        mTvTotalPrice.setText(mPrice);

        mIvWxPay.setSelected(true);
        mSelectPayment = true;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case R.id.fl_payment_wx:
                mIvWxPay.setSelected(true);
                mIvAliPay.setSelected(false);
                mSelectPayment = true;
                break;
            case R.id.fl_payment_alipay:
                mIvAliPay.setSelected(true);
                mIvWxPay.setSelected(false);
                mSelectPayment = false;
                break;
            case R.id.tv_payment_start:
                if (mOnStartPay != null) {
                    mOnStartPay.startPay(mSelectPayment);
                }
                break;
            case R.id.btn_payment_close:
            case R.id.fl_dialog_bg_view:
                dismiss();
                break;

        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/mine/MyCollectPre.java<|end_filename|>
package com.scj.beilu.app.mvp.mine;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.base.BaseCheckArrayView;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.mvp.news.bean.NewsListBean;
import com.scj.beilu.app.mvp.news.model.INewsInfo;
import com.scj.beilu.app.mvp.news.model.NewsInfoImpl;
import com.scj.beilu.app.mvp.store.bean.CollectGoodsListResultBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.mvp.store.model.GoodsInfoImpl;
import com.scj.beilu.app.mvp.store.model.IGoodsInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/9 17:03
 */
public class MyCollectPre extends BaseMvpPresenter<MyCollectPre.MyCollectView> {

    private IGoodsInfo mGoodsInfo;
    private INewsInfo mNewsInfo;

    private final List<GoodsInfoBean> mGoodsInfoList = new ArrayList<>();
    private final List<NewsInfoBean> mNewsInfoList = new ArrayList<>();

    public MyCollectPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mGoodsInfo = new GoodsInfoImpl(mBuilder);
        mNewsInfo = new NewsInfoImpl(mBuilder);
    }
    public void getMyCollectNews(final int currentPage) {
        onceViewAttached(new ViewAction<MyCollectView>() {
            @Override
            public void run(@NonNull final MyCollectView mvpView) {
                mNewsInfo.getMyCollectNews(currentPage)
                        .subscribe(new BaseResponseCallback<NewsListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(NewsListBean newsListBean) {
                                try {
                                    List<NewsInfoBean> list = newsListBean.getPage().getList();
                                    if (currentPage == 0) {
                                        mNewsInfoList.clear();
                                    }

                                    mvpView.onCheckLoadMore(list);
                                    mNewsInfoList.addAll(list);
                                    mvpView.onNewsList(mNewsInfoList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public void getMyCollectGoods(final int currentPage) {
        onceViewAttached(new ViewAction<MyCollectView>() {
            @Override
            public void run(@NonNull final MyCollectView mvpView) {
                mGoodsInfo.getMyCollectGoodsList(currentPage)
                        .subscribe(new BaseResponseCallback<CollectGoodsListResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(CollectGoodsListResultBean goodsListResultBean) {
                                try {

                                    if (currentPage == 0) {
                                        mGoodsInfoList.clear();
                                    }
                                    List<GoodsInfoBean> list = goodsListResultBean.getCollectionPage().getList();

                                    mGoodsInfoList.addAll(list);
                                    mvpView.onCheckLoadMore(list);
                                    mvpView.onGoodsList(mGoodsInfoList);

                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface MyCollectView extends BaseCheckArrayView {
        void onNewsList(List<NewsInfoBean> newsList);

        void onGoodsList(List<GoodsInfoBean> goodsInfoBeanList);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/adapter/NewsAuthorListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.news.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.bean.NewsAuthorInfoBean;
import com.scj.beilu.app.ui.news.NewsMyAttentionAuthorListFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/5/11 17:46
 * 作者列表
 */
public class NewsAuthorListAdapter extends RecyclerView.Adapter<NewsAuthorListAdapter.RecommendAuthorViewHolder> {

    private List<NewsAuthorInfoBean> authorInfoList;
    private GlideRequest<Drawable> mOriginalRequest;
    private GlideRequest<Drawable> mThumbnailRequest;
    private OnItemClickListener mOnItemClickListener;
    private int mResLayout = R.layout.item_news_recommend_attention_author;
    private boolean isRecommend = true;

    public NewsAuthorListAdapter(BaseMvpFragment frag) {
        if (frag instanceof NewsMyAttentionAuthorListFrag) {
            mResLayout = R.layout.item_news_my_attention_author_content;
            isRecommend = false;
        }
        mOriginalRequest = GlideApp.with(frag).asDrawable().optionalCircleCrop();
        mThumbnailRequest = GlideApp.with(frag).asDrawable().optionalCircleCrop();
    }

    public void setAuthorInfoList(List<NewsAuthorInfoBean> authorInfoList) {
        this.authorInfoList = authorInfoList;
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public RecommendAuthorViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(mResLayout, parent, false);
        return new RecommendAuthorViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull RecommendAuthorViewHolder holder, int position) {
        try {
            NewsAuthorInfoBean authorInfoBean = authorInfoList.get(position);
            mOriginalRequest.load(authorInfoBean.getUserOriginalHead())
                    .thumbnail(mThumbnailRequest.load(authorInfoBean.getUserCompressionHead()))
                    .into(holder.iv_news_author_avatar);
            holder.tv_news_author_name.setText(authorInfoBean.getUserNickName());
            String desc = "无";
            if (authorInfoBean.getUserBrief() != null && authorInfoBean.getUserBrief().length() > 0) {
                desc = authorInfoBean.getUserBrief();
            }
            holder.tv_news_content.setText(desc);
            int count = authorInfoBean.getFansCount();
            int fansOut = count / 10000;
            String countStr;
            if (fansOut > 0) {
                countStr = fansOut + "万";
            } else {
                countStr = count + "";
            }
            holder.tv_news_fans.setText(countStr + "粉丝");
            holder.tv_news_recommend_attention_status.setText(authorInfoBean.getIsFocus() == 1 ? "已关注" : "+ 关注");
            holder.tv_news_recommend_attention_status.setSelected(authorInfoBean.getIsFocus() == 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        if (authorInfoList == null) {
            return 0;
        } else if (isRecommend && authorInfoList.size() >= 3) {
            return 3;
        } else {
            return authorInfoList.size();
        }
    }

    class RecommendAuthorViewHolder extends BaseViewHolder {
        private ImageView iv_news_author_avatar;
        private TextView tv_news_author_name, tv_news_content, tv_news_fans, tv_news_recommend_attention_status;

        public RecommendAuthorViewHolder(View itemView) {
            super(itemView);
            iv_news_author_avatar = findViewById(R.id.iv_news_author_avatar);
            tv_news_author_name = findViewById(R.id.tv_news_author_name);
            tv_news_content = findViewById(R.id.tv_news_content);
            tv_news_fans = findViewById(R.id.tv_news_fans);
            tv_news_recommend_attention_status = findViewById(R.id.tv_news_recommend_attention_status);
            tv_news_recommend_attention_status.setOnClickListener(onItemClick);
            iv_news_author_avatar.setOnClickListener(onItemClick);
        }

        final View.OnClickListener onItemClick = view -> {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClick(getAdapterPosition(), authorInfoList.get(getAdapterPosition()), view);
            }
        };
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/common/share/model/IShareInfo.java<|end_filename|>
package com.scj.beilu.app.mvp.common.share.model;

import android.support.annotation.IntDef;

import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import io.reactivex.Observable;

/**
 * @author Mingxun
 * @time on 2019/4/10 11:07
 */
public interface IShareInfo {
    void WXShareWebPage(String url, String title, String description, @shareType int scene);

    @IntDef({SendMessageToWX.Req.WXSceneSession, SendMessageToWX.Req.WXSceneTimeline})
    @Retention(RetentionPolicy.SOURCE)
    @interface shareType {
    }

    Observable<ResultMsgBean> setShareFindCount(int dynamicId);
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/widget/CommentDialog/CommentDialogFragment.java<|end_filename|>
package com.scj.beilu.app.widget.CommentDialog;

import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.scj.beilu.app.R;


/**
 * Created by showzeng on 17-8-11.
 * Email: <EMAIL>
 * GitHub: https://github.com/showzeng
 */

public class CommentDialogFragment extends DialogFragment implements View.OnClickListener {

    private EditText commentEditText;
    private ImageView photoButton;
    private ImageView atButton;
    private ImageView sendButton;
    private InputMethodManager inputMethodManager;
    private DialogFragmentDataCallback dataCallback;

    @Override
    public void onAttach(Context context) {
        if (!(getActivity() instanceof DialogFragmentDataCallback)) {
            throw new IllegalStateException("DialogFragment 所在的 activity 必须实现 DialogFragmentDataCallback 接口");
        }
        super.onAttach(context);
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        Dialog mDialog = new Dialog(getActivity(), R.style.dialog_style);
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setContentView(R.layout.dialog_fragment_comment);
        mDialog.setCanceledOnTouchOutside(true);

        Window window = mDialog.getWindow();
        WindowManager.LayoutParams layoutParams;
        if (window != null) {
            layoutParams = window.getAttributes();
            layoutParams.gravity = Gravity.BOTTOM;
            layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
            window.setAttributes(layoutParams);
        }

        commentEditText = (EditText) mDialog.findViewById(R.id.edit_comment);
        photoButton = (ImageView) mDialog.findViewById(R.id.image_btn_photo);
        atButton = (ImageView) mDialog.findViewById(R.id.image_btn_at);
        sendButton = (ImageView) mDialog.findViewById(R.id.image_btn_comment_send);

        fillEditText();
        setSoftKeyboard();

        commentEditText.addTextChangedListener(mTextWatcher);
        photoButton.setOnClickListener(this);
        atButton.setOnClickListener(this);

        sendButton.setOnClickListener(this);

        return mDialog;
    }

    private void fillEditText() {
        dataCallback = (DialogFragmentDataCallback) getActivity();
        commentEditText.setText(dataCallback.getCommentText());
        commentEditText.setSelection(dataCallback.getCommentText().length());
        if (dataCallback.getCommentText().length() == 0) {
            sendButton.setEnabled(false);
            sendButton.setColorFilter(ContextCompat.getColor(getActivity(), R.color.colorAccent));
        }
    }

    private void setSoftKeyboard() {
        commentEditText.setFocusable(true);
        commentEditText.setFocusableInTouchMode(true);
        commentEditText.requestFocus();

        //为 commentEditText 设置监听器，在 DialogFragment 绘制完后立即呼出软键盘，呼出成功后即注销
        commentEditText.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                if (inputMethodManager != null) {
                    if (inputMethodManager.showSoftInput(commentEditText, 0)) {
                        commentEditText.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                    }
                }
            }
        });
    }

    private TextWatcher mTextWatcher = new TextWatcher() {

        private CharSequence temp;

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            temp = s;
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (temp.length() > 0) {
                sendButton.setEnabled(true);
                sendButton.setClickable(true);
                sendButton.setColorFilter(ContextCompat.getColor(getActivity(), R.color.colorAccent));
            } else {
                sendButton.setEnabled(false);
                sendButton.setColorFilter(ContextCompat.getColor(getActivity(), R.color.colorAccent));
            }
        }
    };

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.image_btn_photo:
                Toast.makeText(getActivity(), "Pick photo Activity", Toast.LENGTH_SHORT).show();
                break;
            case R.id.image_btn_at:
                Toast.makeText(getActivity(), "Pick people you want to at Activity", Toast.LENGTH_SHORT).show();
                break;
            case R.id.image_btn_comment_send:
                Toast.makeText(getActivity(), commentEditText.getText().toString(), Toast.LENGTH_SHORT).show();
                commentEditText.setText("");
                dismiss();
                break;
            default:
                break;
        }
    }

    @Override
    public void onDismiss(DialogInterface dialog) {
        dataCallback.setCommentText(commentEditText.getText().toString());
        super.onDismiss(dialog);
    }

    @Override
    public void onCancel(DialogInterface dialog) {
        dataCallback.setCommentText(commentEditText.getText().toString());
        super.onCancel(dialog);
    }
}

<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/MvpFragment.java<|end_filename|>
package com.mx.pro.lib.mvp;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.mx.pro.lib.mvp.delegate.FragmentMvpDelegate;
import com.mx.pro.lib.mvp.delegate.FragmentMvpDelegateImpl;
import com.mx.pro.lib.mvp.delegate.MvpDelegateCallback;

public abstract class MvpFragment<V extends MvpView, P extends MvpPresenter<V>>
        extends SupportFragment implements MvpView, MvpDelegateCallback<V, P> {

    protected FragmentMvpDelegate<V, P> mFragmentMvpDelegate;

    protected P mPresenter;

    public abstract P createPresenter();

    @Override
    public P getPresenter() {
        return mPresenter;
    }

    @Override
    public void setPresenter(P presenter) {
        mPresenter = presenter;
    }

    @Override
    public V getMvpView() {
        return (V) this;
    }

    public FragmentMvpDelegate<V, P> getMvpDelegate() {
        if (mFragmentMvpDelegate == null) {
            mFragmentMvpDelegate = new FragmentMvpDelegateImpl<>(this, this, true, true);
        }
        return mFragmentMvpDelegate;
    }


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getMvpDelegate().onViewCreated(view, savedInstanceState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        getMvpDelegate().onDestroyView();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getMvpDelegate().onCreate(savedInstanceState);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        getMvpDelegate().onDestroy();
    }

    @Override
    public void onPause() {
        super.onPause();
        getMvpDelegate().onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        getMvpDelegate().onResume();
    }

    @Override
    public void onStart() {
        super.onStart();
        getMvpDelegate().onStart();
    }

    @Override
    public void onStop() {
        super.onStop();
        getMvpDelegate().onStop();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        getMvpDelegate().onActivityCreated(savedInstanceState);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        getMvpDelegate().onAttach(activity);
    }

    @Override
    public void onDetach() {
        super.onDetach();
        getMvpDelegate().onDetach();
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        getMvpDelegate().onSaveInstanceState(outState);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/fit/FitRecordGeneratePictureFrag.java<|end_filename|>
package com.scj.beilu.app.ui.fit;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.api.Constants;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.fit.FitRecordGeneratePicturePre;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgResultBean;
import com.scj.beilu.app.util.ToastUtils;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.io.Serializable;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/15 13:26
 * 生成对比照
 */
public class FitRecordGeneratePictureFrag extends BaseMvpFragment<FitRecordGeneratePicturePre.FitRecordGeneratePictureView, FitRecordGeneratePicturePre>
        implements FitRecordGeneratePicturePre.FitRecordGeneratePictureView, View.OnClickListener {

    private static final String IMG_PATH_LIST = "img_list";
    private List<String> mImgList;
    private ImageView mIvLeftImg, mIvRightImg;
    private LinearLayout mLlGenerateView;
    private TextView tv_share_to_wechat, tv_share_to_wechat_firend, mTvSave;
    private boolean mUseWaterMark = false;
    private IWXAPI mIWXAPI;

    public static FitRecordGeneratePictureFrag newInstance(List<String> imgList) {

        Bundle args = new Bundle();
        args.putSerializable(IMG_PATH_LIST, (Serializable) imgList);
        FitRecordGeneratePictureFrag fragment = new FitRecordGeneratePictureFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mImgList = (List<String>) arguments.getSerializable(IMG_PATH_LIST);
        }
        mIWXAPI = WXAPIFactory.createWXAPI(mFragmentActivity, Constants.WXAPPID);
    }

    @Override
    public FitRecordGeneratePicturePre createPresenter() {
        return new FitRecordGeneratePicturePre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_fit_record_generate_contrast;
    }

    @Override
    public void initView() {
        super.initView();
        mIvLeftImg = findViewById(R.id.iv_left_img);
        mIvRightImg = findViewById(R.id.iv_right_img);
        mLlGenerateView = findViewById(R.id.ll_generate_view);
        mTvSave = findViewById(R.id.tv_save);
        tv_share_to_wechat = findViewById(R.id.tv_share_to_wechat);
        tv_share_to_wechat_firend = findViewById(R.id.tv_share_to_wechat_firend);

        try {
            if (mImgList.size() == 0) return;
            GlideApp.with(this)
                    .load(mImgList.get(0))
                    .centerCrop()
                    .into(mIvLeftImg);
            GlideApp.with(this)
                    .load(mImgList.get(1))
                    .centerCrop()
                    .listener(new RequestListener<Drawable>() {
                        @Override
                        public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                            mUseWaterMark = false;
                            getPresenter().startGenerate(mLlGenerateView, mUseWaterMark);
                            return false;
                        }
                    })
                    .into(mIvRightImg);
        } catch (Exception e) {
            e.printStackTrace();
        }

        mTvSave.setOnClickListener(this);
        tv_share_to_wechat.setOnClickListener(this);
        tv_share_to_wechat_firend.setOnClickListener(this);
    }

    @Override
    public void onGenerateResult(FitRecordImgResultBean result) {

        if (result.getReq() == null) {
            if (!mUseWaterMark) {
                setFragmentResult(RESULT_OK, null);
            }
            ToastUtils.showToast(mFragmentActivity, result.getResult());
        } else {
            if (!EventBus.getDefault().isRegistered(this)) {
                EventBus.getDefault().register(this);
            }
            mIWXAPI.sendReq(result.getReq());
        }

    }


    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.tv_save:
                mUseWaterMark = true;
                getPresenter().startGenerate(mLlGenerateView, mUseWaterMark);
                break;
            case R.id.tv_share_to_wechat:
                getPresenter().shareToImage(mLlGenerateView, SendMessageToWX.Req.WXSceneSession);
                break;
            case R.id.tv_share_to_wechat_firend:
                getPresenter().shareToImage(mLlGenerateView, SendMessageToWX.Req.WXSceneTimeline);
                break;
        }
    }

    @Subscribe
    public void onShareResult(BaseResp resp) {
        ToastUtils.showToast(mFragmentActivity, "分享成功");
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindDetailsParentCommentViewHolder.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.find.bean.FindCommentBean;

/**
 * @author Mingxun
 * @time on 2019/2/25 21:58
 * 动态详情评论列表适配器
 */
public class FindDetailsParentCommentViewHolder extends BaseViewHolder {
    private TextView mTvUserName, mTvCommentContent, mTvCommentDate;
    private ImageView mIvAvatar;
    private RecyclerView mRvCommentReplyList;
    private GlideRequest<Drawable> mGlideRequests;
    private OnItemClickListener mOnItemClickListener;
    private FindCommentBean mCommentBean;

    private FindDetailsChildCommentAdapter mChildCommentAdapter;

    public FindDetailsParentCommentViewHolder(View itemView, GlideRequest<Drawable> glideRequest,
                                              OnItemClickListener itemClickListener) {
        super(itemView);
        mGlideRequests = glideRequest;
        mOnItemClickListener = itemClickListener;

        mTvUserName = findViewById(R.id.tv_news_user_name);
        mTvCommentContent = findViewById(R.id.tv_news_comment_content);
        mTvCommentDate = findViewById(R.id.tv_news_comment_date);
        mIvAvatar = findViewById(R.id.iv_news_comment_avatar);
        mRvCommentReplyList = findViewById(R.id.rv_child_comment_list);
        mTvCommentContent.setOnClickListener(mClickListener);
        mIvAvatar.setOnClickListener(mClickListener);

        mChildCommentAdapter = new FindDetailsChildCommentAdapter(itemView.getContext());
        mChildCommentAdapter.setOnItemClickListener(mOnItemClickListener);
        mRvCommentReplyList.setAdapter(mChildCommentAdapter);
    }

    public void setBind(FindCommentBean commentInfo) {
        mCommentBean = commentInfo;
        String userHead = commentInfo.getComUserHead();
        mGlideRequests.load(userHead == null ? R.drawable.ic_default_avatar : userHead)
                .thumbnail(0.2f)
                .centerCrop()
                .transform(new CircleCrop())
                .into(mIvAvatar);
        mTvUserName.setText(commentInfo.getComUserName());
        mTvCommentContent.setText(commentInfo.getComContent());
        mTvCommentDate.setText(commentInfo.mFormatDate);

        if (commentInfo.getComReplies() == null ||
                (commentInfo.getComReplies() != null && commentInfo.getComReplies().size() == 0)) {
            mRvCommentReplyList.setVisibility(View.GONE);
        } else {
            mRvCommentReplyList.setVisibility(View.VISIBLE);
            mChildCommentAdapter.setReplayCommentList(commentInfo.getComReplies());
        }
    }

    private final View.OnClickListener mClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mOnItemClickListener != null) {
                mOnItemClickListener.onItemClick(getAdapterPosition(), mCommentBean, v);
            }
        }
    };
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/HomeImageAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.widget.RectImageView;

/**
 * @author Mingxun
 * @time on 2019/1/24 18:10
 */
class HomeImageAdapter extends RecyclerView.Adapter<HomeImageAdapter.ImageViewHolder> {
    String[] imgs = {"https://imgsa.baidu.com/news/q%3D100/sign=57cb26cb4c34970a4173142fa5cbd1c0/7a899e510fb30f24bdbf02e7c595d143ad4b0329.jpg",
            "https://imgsa.baidu.com/news/q%3D100/sign=c32a60d741086e066ca83b4b32097b5a/d8f9d72a6059252daf99e1e2399b033b5ab5b94e.jpg",
//            "https://imgsa.baidu.com/news/q%3D100/sign=3d0e4ad457afa40f3ac6cadd9b66038c/1c950a7b02087bf4442faa0fffd3572c10dfcf11.jpg",
//            "https://imgsa.baidu.com/news/q%3D100/sign=3d0e4ad457afa40f3ac6cadd9b66038c/1c950a7b02087bf4442faa0fffd3572c10dfcf11.jpg",
//            "https://imgsa.baidu.com/news/q%3D100/sign=57cb26cb4c34970a4173142fa5cbd1c0/7a899e510fb30f24bdbf02e7c595d143ad4b0329.jpg",
            "https://imgsa.baidu.com/news/q%3D100/sign=57cb26cb4c34970a4173142fa5cbd1c0/7a899e510fb30f24bdbf02e7c595d143ad4b0329.jpg"};

    @NonNull
    @Override
    public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        final View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_img, parent, false);
        return new ImageViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
        GlideApp.with(holder.mIvImg.getContext())
                .load(imgs[position])
                .into(holder.mIvImg);
    }

    @Override
    public int getItemCount() {
        return imgs.length;
    }

    class ImageViewHolder extends BaseViewHolder {
        private RectImageView mIvImg;

        public ImageViewHolder(View itemView) {
            super(itemView);
            mIvImg = findViewById(R.id.iv_find_img);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/HomeButtonAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;

/**
 * author:SunGuiLan
 * date:2019/2/13
 * descriptin: 首页--4个按钮
 */
public class HomeButtonAdapter extends RecyclerView.Adapter<HomeButtonAdapter.HomeButtonViewHolder> {

    private String[] name = {"附近商家", "动作库", "商城", "健身记录"};
    private int[] image = {R.drawable.ic_shop, R.drawable.ic_action, R.drawable.ic_buy, R.drawable.ic_record};

    private OnItemClickListener mItemClickListener;

    private GlideRequest<Drawable> mGlideRequest;

    public HomeButtonAdapter(GlideRequests with) {
        mGlideRequest = with.asDrawable().fitCenter();
    }

    public void setItemClickListener(OnItemClickListener itemClickListener) {
        mItemClickListener = itemClickListener;
    }

    @NonNull
    @Override
    public HomeButtonViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_button, parent, false);
        return new HomeButtonViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull final HomeButtonViewHolder holder, final int position) {
        mGlideRequest.load(image[position]).into(holder.iv_photo);
        holder.tv_name.setText(name[position]);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mItemClickListener != null) {
                    mItemClickListener.onItemClick(position, null, view);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return 4;
    }

    class HomeButtonViewHolder extends BaseViewHolder {
        private ImageView iv_photo;
        private TextView tv_name;

        public HomeButtonViewHolder(View itemView) {
            super(itemView);
            itemView.setId(R.id.home_nav_button);
            iv_photo = findViewById(R.id.iv_photo);
            tv_name = findViewById(R.id.tv_name);
        }
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/smartrefresh/layout/api/RefreshContent.java<|end_filename|>
package com.mx.pro.lib.smartrefresh.layout.api;

import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.support.annotation.NonNull;
import android.view.MotionEvent;
import android.view.View;

/**
 * 刷新内容组件
 * Created by SCWANG on 2017/5/26.
 */
public interface RefreshContent {

    @NonNull
    View getView();
    @NonNull
    View getScrollableView();

    void onActionDown(MotionEvent e);

    void setUpComponent(RefreshKernel kernel, View fixedHeader, View fixedFooter);
    void setScrollBoundaryDecider(ScrollBoundaryDecider boundary);

    void setEnableLoadMoreWhenContentNotFull(boolean enable);

    void moveSpinner(int spinner, int headerTranslationViewId, int footerTranslationViewId);

    boolean canRefresh();
    boolean canLoadMore();

    AnimatorUpdateListener scrollContentWhenFinished(int spinner);
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/MerchantCoachInfoFrag.java<|end_filename|>
package com.scj.beilu.app.ui.merchant;

import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.merchant.MerchantInfoCoachPre;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoCoachBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoCoachResultBean;
import com.scj.beilu.app.ui.act.adapter.ImageSelectedListAdapter;
import com.scj.beilu.app.ui.merchant.adapter.MerchantCoachAdvantageCourseListAdapter;
import com.scj.beilu.app.ui.merchant.adapter.MerchantCoachInfoPicListPagerAdapter;
import com.scj.beilu.app.util.ToastUtils;

import java.util.List;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

/**
 * @author Mingxun
 * @time on 2019/4/13 18:27
 */
@RuntimePermissions
public class MerchantCoachInfoFrag extends BaseMvpFragment<MerchantInfoCoachPre.MerchantInfoCoachView, MerchantInfoCoachPre>
        implements MerchantInfoCoachPre.MerchantInfoCoachView, ViewPager.OnPageChangeListener {

    private static final String MERCHANT_ID = "merchantId";
    private static final String COACH_ID = "coachId";

    private ViewPager view_pager_merchant_img;
    private RecyclerView rv_image_selected_list;
    private TextView tv_coach_name;
    private TextView tv_coach_authentication;
    private TextView tv_coach_info_description;
    private RecyclerView rv_advantage_course_list;
    private ImageView iv_authentication;
    private ImageView iv_coach_avatar;
    private TextView tv_coach_img_count;
    private LinearLayout ll_merchant_img;
    private TextView tv_consult;

    private int mMerchantId;
    private int mCoachId;

    private String phoneNum;

    private MerchantCoachInfoPicListPagerAdapter mMerchantCoachInfoPicListPagerAdapter;
    private MerchantCoachAdvantageCourseListAdapter mMerchantCoachAdvantageCourseListAdapter;
    private ImageSelectedListAdapter mImageSelectedListAdapter;//用于显示底部圆点

    public static MerchantCoachInfoFrag newInstance(int merchantId, int coachId) {

        Bundle args = new Bundle();
        args.putInt(MERCHANT_ID, merchantId);
        args.putInt(COACH_ID, coachId);
        MerchantCoachInfoFrag fragment = new MerchantCoachInfoFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mMerchantId = arguments.getInt(MERCHANT_ID);
            mCoachId = arguments.getInt(COACH_ID);
        }
    }

    @Override
    public MerchantInfoCoachPre createPresenter() {
        return new MerchantInfoCoachPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_merchant_coach_info;
    }

    @Override
    public void initView() {
        super.initView();

        ImmersionBar.with(this).statusBarView(R.id.top_view)
                .addTag("PicAndColor")
                .statusBarDarkFont(false)
                .keyboardEnable(true)
                .init();

        ll_merchant_img = findViewById(R.id.ll_merchant_img);
        view_pager_merchant_img = findViewById(R.id.view_pager_merchant_img);
        rv_image_selected_list = findViewById(R.id.rv_image_selected_list);
        tv_coach_name = findViewById(R.id.tv_coach_name);
        tv_coach_authentication = findViewById(R.id.tv_coach_authentication);
        tv_coach_info_description = findViewById(R.id.tv_coach_info_description);
        rv_advantage_course_list = findViewById(R.id.rv_advantage_course_list);
        iv_authentication = findViewById(R.id.iv_authentication);
        tv_coach_img_count = findViewById(R.id.tv_coach_img_count);
        iv_coach_avatar = findViewById(R.id.iv_coach_avatar);
        tv_consult = findViewById(R.id.tv_consult);

        mMerchantCoachInfoPicListPagerAdapter = new MerchantCoachInfoPicListPagerAdapter(this);
        view_pager_merchant_img.setAdapter(mMerchantCoachInfoPicListPagerAdapter);

        mMerchantCoachAdvantageCourseListAdapter = new MerchantCoachAdvantageCourseListAdapter();
        rv_advantage_course_list.setAdapter(mMerchantCoachAdvantageCourseListAdapter);

        mImageSelectedListAdapter = new ImageSelectedListAdapter();
        rv_image_selected_list.setAdapter(mImageSelectedListAdapter);

        view_pager_merchant_img.addOnPageChangeListener(this);

        final int size = getResources().getDimensionPixelSize(R.dimen.rect_5);

        rv_image_selected_list.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(size, 0, size, 0);
            }
        });
        ll_merchant_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                start(MerchantCoachAlbumListFrag.newInstance(mMerchantId, mCoachId));
            }
        });

        rv_advantage_course_list.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(size, 0, size, 0);
            }
        });

        tv_consult.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MerchantCoachInfoFragPermissionsDispatcher.needsCallPhoneWithPermissionCheck(MerchantCoachInfoFrag.this);
            }
        });
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getCoachInfo(mMerchantId, mCoachId);
    }

    @Override
    public void onCoachInfo(MerchantInfoCoachResultBean coachInfo) {
        try {
            MerchantInfoCoachBean coachEntity = coachInfo.getCoachEntity();
            tv_coach_img_count.setText(String.valueOf(coachInfo.getCountAlbum()));
            getPresenter().initSelectorList(coachEntity.getCoachPicList());
            mMerchantCoachInfoPicListPagerAdapter.setInfoCoachPicInfoBeans(coachEntity.getCoachPicList());
            GlideApp.with(this)
                    .load(coachEntity.getCoachHead())
                    .thumbnail(GlideApp.with(this).load(coachEntity.getCoachHeadZip()).optionalCircleCrop())
                    .optionalCircleCrop()
                    .into(iv_coach_avatar);
            tv_coach_name.setText(coachEntity.getCoachName());
            String coachCertifiDec = coachEntity.getCoachCertifiDec();
            coachCertifiDec = (coachCertifiDec == null) ? "无" : coachCertifiDec;
            tv_coach_authentication.setText(coachCertifiDec);
            tv_coach_info_description.setText(coachEntity.getCoachSummary());

            GlideApp.with(this)
                    .load(coachEntity.getCoachCertifi())
                    .thumbnail(GlideApp.with(this).load(coachEntity.getCoachCertifiZip()).optionalCenterCrop())
                    .optionalCenterCrop()
                    .into(iv_authentication);

            mMerchantCoachAdvantageCourseListAdapter.setCoachExperts(coachEntity.getCoachExpert());
            // TODO: 2019/4/17
            phoneNum = coachEntity.getCoachCertifi();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onImgSelectedListResult(List<Boolean> imageSelectorList) {
        mImageSelectedListAdapter.setImageSelectedList(imageSelectorList);
        getPresenter().setSelectedByPosition(0);
    }

    @Override
    public void onNotify(int position) {
        mImageSelectedListAdapter.notifyDataSetChanged();
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        getPresenter().setSelectedByPosition(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    @NeedsPermission(Manifest.permission.CALL_PHONE)
    void needsCallPhone() {
        if (phoneNum != null) {
            new AlertDialog.Builder(mFragmentActivity)
                    .setPositiveButton("呼叫", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            Intent intent = new Intent(Intent.ACTION_CALL);
                            Uri data = Uri.parse("tel:" + phoneNum);
                            intent.setData(data);
                            startActivity(intent);
                        }
                    })
                    .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    })
                    .setCancelable(false)
                    .setMessage(phoneNum)
                    .show();
        } else {
            ToastUtils.showToast(mFragmentActivity, "暂时无法拨打电话～");
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        MerchantCoachInfoFragPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

    @OnShowRationale(Manifest.permission.CALL_PHONE)
    void rationaleCallPhone(final PermissionRequest request) {
        showRationaleDialog(R.string.permission_call_phone, request);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/adapter/SystemListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.mine.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * @author Mingxun
 * @time on 2019/1/15 20:57
 */
public class SystemListAdapter extends RecyclerView.Adapter {
    private final int VIEW_TYPE_ORDER = 1;

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        if (viewType == VIEW_TYPE_ORDER) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_system_msg_order, parent, false);
            return new OrderViewHolder(view);
        } else {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_system_msg_other, parent, false);
            return new OtherViewHolder(view);
        }
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        if (position == 0) {

        }
    }

    @Override
    public int getItemCount() {
        return 10;
    }

    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return VIEW_TYPE_ORDER;
        } else {
            return super.getItemViewType(position);
        }
    }

    class OrderViewHolder extends BaseViewHolder {
        public OrderViewHolder(View itemView) {
            super(itemView);
        }
    }

    class OtherViewHolder extends BaseViewHolder {
        public OtherViewHolder(View itemView) {
            super(itemView);
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/store/GoodsListBySearchPre.java<|end_filename|>
package com.scj.beilu.app.mvp.store;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.base.BaseCheckArrayView;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsListResultBean;
import com.scj.beilu.app.mvp.store.model.GoodsInfoImpl;
import com.scj.beilu.app.mvp.store.model.IGoodsInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/3 16:56
 */
public class GoodsListBySearchPre extends BaseMvpPresenter<GoodsListBySearchPre.GoodsListBySearchView> {

    private IGoodsInfo mGoodsInfo;

    private final List<GoodsInfoBean> mGoodsInfoList = new ArrayList<>();


    public GoodsListBySearchPre(Context context) {
        super(context, ShowConfig.LOADING_STATE, ShowConfig.ERROR_TOAST);
        mGoodsInfo = new GoodsInfoImpl(mBuilder);
    }

    public void startSearch(final String content, final int currentPage) {
        onceViewAttached(new ViewAction<GoodsListBySearchView>() {
            @Override
            public void run(@NonNull final GoodsListBySearchView mvpView) {
                mGoodsInfo.searchGoodsList(content, currentPage)
                        .subscribe(new BaseResponseCallback<GoodsListResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(GoodsListResultBean goodsListResultBean) {
                                try {

                                    if (currentPage == 0) {
                                        mGoodsInfoList.clear();
                                    }
                                    List<GoodsInfoBean> list = goodsListResultBean.getPage().getList();

                                    mGoodsInfoList.addAll(list);
                                    mvpView.onCheckLoadMore(list);
                                    mvpView.onGoodsList(mGoodsInfoList);

                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface GoodsListBySearchView extends BaseCheckArrayView {
        void onGoodsList(List<GoodsInfoBean> goodsInfoBeanList);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/adapter/MsgCommentListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.mine.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.message.bean.MsgCommentInfoBean;
import com.scj.beilu.app.ui.mine.MineMsgFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/9 20:55
 */
public class MsgCommentListAdapter extends RecyclerView.Adapter<MsgCommentListAdapter.CommentViewHolder> {

    private List<MsgCommentInfoBean> mCommentInfoBeans;
    private GlideRequest<Drawable> mOriginal;
    private GlideRequest<Drawable> mThumbnail;
    private OnItemClickListener mOnItemClickListener;
    private final String mTipContent;

    public MsgCommentListAdapter(MineMsgFrag frag) {
        mOriginal = GlideApp.with(frag).asDrawable().circleCrop();
        mThumbnail = GlideApp.with(frag).asDrawable().circleCrop();
        mTipContent = frag.getString(R.string.txt_item_comment_tip);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setCommentInfoBeans(List<MsgCommentInfoBean> commentInfoBeans) {
        mCommentInfoBeans = commentInfoBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public CommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_msg_reply_content, parent, false);
        return new CommentViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CommentViewHolder holder, int position) {
        try {
            MsgCommentInfoBean msgCommentInfoBean = mCommentInfoBeans.get(position);
            mOriginal.load(msgCommentInfoBean.getUserHead())
                    .thumbnail(mThumbnail.load(msgCommentInfoBean.getUserHeadZip()))
                    .into(holder.mIvHeader);
            holder.mTvUserName.setText(msgCommentInfoBean.getUserName());
            holder.mTvTip.setText(String.format(mTipContent, msgCommentInfoBean.getComContent(), msgCommentInfoBean.mFormatDate));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mCommentInfoBeans == null ? 0 : mCommentInfoBeans.size();
    }

    public class CommentViewHolder extends BaseViewHolder {
        private ImageView mIvHeader;
        private TextView mTvUserName;
        private TextView mTvTip;

        public CommentViewHolder(View itemView) {
            super(itemView);
            mIvHeader = findViewById(R.id.iv_comment_header);
            mTvUserName = findViewById(R.id.tv_comment_user_name);
            mTvTip = findViewById(R.id.tv_reply_tip);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), mCommentInfoBeans.get(getAdapterPosition()), v);
                    }
                }
            });
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/action/adapter/ActionSecondTypeListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.action.adapter;

import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.action.bean.ActionSecondTypeBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/16 19:11
 */
public class ActionSecondTypeListAdapter extends RecyclerView.Adapter<ActionSecondTypeListAdapter.SecondViewHolder> {

    private List<ActionSecondTypeBean> mSecondTypeBeans;
    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setSecondTypeBeans(List<ActionSecondTypeBean> secondTypeBeans) {
        mSecondTypeBeans = secondTypeBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public SecondViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_action_second_type, parent, false);
        return new SecondViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull SecondViewHolder holder, int position) {
        ActionSecondTypeBean secondTypeBean = mSecondTypeBeans.get(position);
        holder.mTvSecond.setText(secondTypeBean.getActionDesPartName());
        holder.mTvSecond.setTypeface(Typeface.defaultFromStyle(secondTypeBean.isSelect() ? Typeface.BOLD : Typeface.NORMAL));
        holder.mTvSecond.setSelected(secondTypeBean.isSelect());
    }

    @Override
    public int getItemCount() {
        return mSecondTypeBeans == null ? 0 : mSecondTypeBeans.size();
    }

    class SecondViewHolder extends BaseViewHolder {
        private TextView mTvSecond;

        public SecondViewHolder(View itemView) {
            super(itemView);
            mTvSecond = findViewById(R.id.tv_action_second_type);
            mTvSecond.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ActionSecondTypeBean bean = mSecondTypeBeans.get(getAdapterPosition());
                    if (mOnItemClickListener != null && bean != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), bean, v);
                    }
                }
            });
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindListContentImageAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/2/21 15:37
 */
class FindListContentImageAdapter extends RecyclerView.Adapter<FindListContentImageAdapter.ImageViewHolder> {
    private ArrayList<FindImageBean> mFindImageList;

    private GlideRequest<Drawable> mThumbnailRequest;
    private GlideRequest<Drawable> mOriginalRequest;


    private OnGroupItemClickListener mOnGroupItemClickListener;
    private int mGroupPosition;

    public FindListContentImageAdapter(GlideRequests glideRequests, int groupPosition) {
        mThumbnailRequest = glideRequests.asDrawable().centerCrop();
        mOriginalRequest = glideRequests.asDrawable().centerCrop();
        mGroupPosition = groupPosition;
    }

    public void setOnGroupItemClickListener(OnGroupItemClickListener onGroupItemClickListener) {
        mOnGroupItemClickListener = onGroupItemClickListener;
    }

    public void setFindImageList(ArrayList<FindImageBean> findImageList) {
        mFindImageList = findImageList;

    }

    @NonNull
    @Override
    public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        final View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_find_pic_img, parent, false);
        return new ImageViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
        FindImageBean image = mFindImageList.get(position);
        mOriginalRequest
                .load(image.getDynamicPicAddr())
                .thumbnail(mThumbnailRequest.load(image.getDynamicPicZip()))
                .into(holder.mIvPic);
    }

    @Override
    public int getItemCount() {
        return mFindImageList == null ? 0 : mFindImageList.size();
    }

    public class ImageViewHolder extends BaseViewHolder {
        private ImageView mIvPic;

        public ImageViewHolder(View itemView) {
            super(itemView);
            mIvPic = findViewById(R.id.iv_find_pic);
            mIvPic.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnGroupItemClickListener != null) {
                        mOnGroupItemClickListener.onItemClick(mGroupPosition, getAdapterPosition(), mFindImageList, v);
                    }
                }
            });
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/fit/model/FitRecordImpl.java<|end_filename|>
package com.scj.beilu.app.mvp.fit.model;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.net.Uri;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.view.View;

import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import com.github.mikephil.charting.utils.ColorTemplate;
import com.mx.pro.lib.mvp.exception.UserException;
import com.scj.beilu.app.R;
import com.scj.beilu.app.api.FitApi;
import com.scj.beilu.app.mvp.base.user.BaseLoadUserInfoDelegate;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordGirthInfoBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordGirthListBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordGirthValBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgInfoBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgListBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgResultBean;
import com.scj.beilu.app.mvp.fit.bean.FitRecordInfoResultBean;
import com.scj.beilu.app.mvp.fit.bean.FitUserSexBean;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.ObservableSource;
import io.reactivex.functions.Function;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

/**
 * @author Mingxun
 * @time on 2019/3/11 14:49
 */
public class FitRecordImpl extends BaseLoadUserInfoDelegate implements IFitRecord {

    private FitApi mFitApi;
//    private String mGenerateImgPath;//生成后的图片路径，用于上传到服务器成功后，删除当前图片

    public FitRecordImpl(Builder builder) {
        super(builder);
        mFitApi = create(FitApi.class);
    }

    @Override
    public Observable<ResultMsgBean> setSex(final int sex) {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<ResultMsgBean>>) header ->
                        createObservable(mFitApi.setSexOfFitRecord(header, sex)));
    }

    @Override
    public Observable<FitUserSexBean> getSexInfo() {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<FitUserSexBean>>) header -> {
                    if (header.size() == 0) {
                        throw new UserException();
                    } else {
                        return createObservable(mFitApi.getFitSexInfo(header));
                    }
                });
    }

    @Override
    public Observable<FitRecordGirthListBean> getUserRecord() {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<FitRecordGirthListBean>>) header -> {
                    if (header.size() == 0) {
                        throw new UserException();
                    } else {
                        return createObservable(mFitApi.getUserFitRecord(header));
                    }
                })
                .flatMap((Function<FitRecordGirthListBean, ObservableSource<FitRecordGirthListBean>>) fitRecordGirthListBean ->
                        dealWithLineChart(fitRecordGirthListBean));
    }

    @Override
    public Observable<ResultMsgBean> addFitRecord(final FitRecordGirthInfoBean girthInfoBean, final String recordKey, final float recordVal) {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<ResultMsgBean>>) token -> {
                    if (token.size() == 0) {
                        throw new UserException();
                    } else {
                        Map<String, Float> params = new HashMap<>();
                        params.put(recordKey, recordVal);
                        return createObservable(mFitApi.addFitRecord(token, params));
                    }
                })
                .flatMap((Function<ResultMsgBean, ObservableSource<ResultMsgBean>>) resultMsgBean ->
                        addForResult(girthInfoBean, resultMsgBean, recordVal));
    }

    @Override
    public Observable<FitRecordInfoResultBean> getRecentFitRecord() {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<FitRecordInfoResultBean>>) header -> {
                    if (header.size() == 0) {
                        throw new UserException();
                    } else {
                        return createObservable(mFitApi.getRecentFitRecord(header));
                    }
                });
    }

    @Override
    public Observable<FitRecordImgResultBean> addFitRecordImg(File filePath) {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<FitRecordImgResultBean>>) tokens -> {
                    if (tokens.size() == 0) {
                        throw new UserException();
                    } else {
                        RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), filePath);
                        String fileName = URLEncoder.encode(filePath.getName(), "UTF-8");
                        MultipartBody.Part filePart = MultipartBody.Part.createFormData("file", fileName, requestBody);
                        return createObservable(mFitApi.addFitRecordForImg(tokens, filePart));
                    }
                });
    }

    @Override
    public Observable<FitRecordImgListBean> getFitRecordImgList(final int currentPage) {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<FitRecordImgListBean>>) tokens -> {
                    if (tokens.size() == 0) {
                        throw new UserException();
                    } else {
                        return createObservable(mFitApi.getFitRecordImgList(tokens, currentPage));
                    }
                });
    }

    @Override
    public Observable<FitRecordImgResultBean> generatePicture(View view, boolean isWaterMark) {
        if (isWaterMark) {//添加水印保存到本地
            return generate(view, true);
        } else {//上传到服务器，不添加水印
            return generate(view, false)
                    .flatMap((Function<FitRecordImgResultBean, ObservableSource<FitRecordImgResultBean>>) generateResultBean ->
                            addFitRecordImg(new File(generateResultBean.getOrgFile())))
                    .map(fitRecordImgResultBean -> {//上传成功后删除本地
                        if (fitRecordImgResultBean.getOrgFile() != null) {
                            File imgFile = new File(fitRecordImgResultBean.getOrgFile());
                            if (imgFile.exists()) {
                                imgFile.delete();
                            }
                        }
                        return fitRecordImgResultBean;
                    });
        }
    }

    @Override
    public Observable<ResultMsgBean> deleteImg(final long recordPicId) {
        return getHeader()
                .flatMap((Function<Map<String, String>, ObservableSource<ResultMsgBean>>) header -> {
                    if (header.size() == 0) {
                        throw new UserException();
                    } else {
                        return createObservable(mFitApi.deleteImg(header, recordPicId));
                    }
                });

    }

    @Override
    public Observable<FitRecordImgResultBean> shareToImg(View view, int scene) {
        return generate(view, true)
                .flatMap((Function<FitRecordImgResultBean, ObservableSource<FitRecordImgResultBean>>) fitRecordImgResultBean -> {
                    return generateImg(fitRecordImgResultBean, scene);
                });
    }

    private final int THUMB_SIZE = 150;

    private Observable<FitRecordImgResultBean> generateImg(FitRecordImgResultBean recordImgResultBean, int scene) {
        ObservableOnSubscribe<FitRecordImgResultBean> onSubscribe = emitter -> {
            String path = recordImgResultBean.getOrgFile();
            File file = new File(path);
            if (!file.exists()) {
                return;
            }

            WXImageObject imgObj = new WXImageObject();
            imgObj.setImagePath(path);

            WXMediaMessage msg = new WXMediaMessage();
            msg.mediaObject = imgObj;

            Bitmap bmp = BitmapFactory.decodeFile(path);
            Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
            bmp.recycle();
            msg.thumbData = bmpToByteArray(thumbBmp, true);

            SendMessageToWX.Req req = new SendMessageToWX.Req();
            req.transaction = "img" + System.currentTimeMillis();
            req.message = msg;
            req.scene = scene;
            recordImgResultBean.setReq(req);
            emitter.onNext(recordImgResultBean);
            emitter.onComplete();
        };
        return createObservableOnSubscribe(onSubscribe);
    }


    byte[] bmpToByteArray(final Bitmap bmp, final boolean needRecycle) {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 100, output);
        if (needRecycle) {
            bmp.recycle();
        }

        byte[] result = output.toByteArray();
        try {
            output.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }

    /**
     * 添加水印
     *
     * @param view        当前显示的View
     * @param isWaterMark 是否添加水印
     * @return
     */
    private Observable<FitRecordImgResultBean> generate(final View view, final boolean isWaterMark) {
        ObservableOnSubscribe<FitRecordImgResultBean> onSubscribe =
                emitter -> {
                    FitRecordImgResultBean generate = new FitRecordImgResultBean();
                    try {
                        view.buildDrawingCache();

                        Bitmap bitmap = view.getDrawingCache();
                        Bitmap bitmapFromView = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
                        Canvas canvas = new Canvas(bitmapFromView);
                        canvas.drawBitmap(bitmap, 0, 0, null);

                        if (isWaterMark) {
                            Bitmap waterMark = BitmapFactory.decodeResource(context.getResources(), R.drawable.logo_mark);
                            int left = bitmapFromView.getWidth() - waterMark.getWidth() - 20;
                            int top = bitmapFromView.getHeight() - waterMark.getHeight() - 20;
                            //在画布上绘制水印图片
                            canvas.drawBitmap(waterMark, left, top, null);
                        }

//                            canvas.save(Canvas.ALL_SAVE_FLAG);
                        canvas.save();
                        // 存储
                        canvas.restore();

                        // 保存图片到本地
                        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
                        Date curTime = new Date();
                        String fileName = new StringBuilder("beilu").append(dateFormat.format(curTime)).append(".jpg").toString();
                        String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/beilu";
                        String mGenerateImgPath = saveImage(filePath, fileName, bitmapFromView, isWaterMark);
                        generate.setOrgFile(mGenerateImgPath);
                        generate.setComFile(mGenerateImgPath);
                        generate.setResult("保存成功");
                    } catch (Exception e) {
                        e.printStackTrace();
                        generate.setResult("保存失败");
                    } finally {
                        generate.setCode(2000);

                        emitter.onNext(generate);
                        emitter.onComplete();
                    }
                };
        return createObservableOnSubscribe(onSubscribe);
    }

    /**
     * 根据路径和文件名保存文件
     *
     * @param folderName
     * @param fileName
     * @param bm
     */
    private String saveImage(String folderName, String fileName, Bitmap bm, boolean isWaterMark) {
        if (null == bm) {
            // 保存失败，直接返回
            return null;
        }
        // 先判断文件夹是否存在，不存在要先创建
        File dir = new File(folderName);
        if (!dir.exists() && !dir.mkdirs()) {
            return null;
        }
        File file = new File(dir, fileName);
        OutputStream out = null;
        try {
            // 封装输出流
            out = new BufferedOutputStream(new FileOutputStream(file));
            if (!bm.compress(Bitmap.CompressFormat.JPEG, 100, out)) {
                return null;
            }

            // 转换为数据流后回收bitmap
            if (!bm.isRecycled()) {
                bm.recycle();
            }

            if (isWaterMark) {
                // 扫描新增图片文件
                Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                final Uri fileContentUri = Uri.fromFile(file);
                mediaScannerIntent.setData(fileContentUri);
                context.sendBroadcast(mediaScannerIntent);
            }

            return file.getAbsolutePath();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (null != out) {
                    // 关闭输出流
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    private Observable<FitRecordGirthListBean> dealWithLineChart(final FitRecordGirthListBean recordInfo) {
        ObservableOnSubscribe<FitRecordGirthListBean> onSubscribe =
                emitter -> {
                    List<FitRecordGirthInfoBean> commons = recordInfo.getRecordCommons();
                    try {
                        final String pattern = "yyyy-MM-dd HH:mm:ss";
                        final SimpleDateFormat df = new SimpleDateFormat(pattern);
                        final String pattern1 = "MM/dd#yyyy";
                        final SimpleDateFormat format = new SimpleDateFormat(pattern1);

                        int size = commons.size();
                        for (int i = 0; i < size; i++) {
                            FitRecordGirthInfoBean girthInfoBean = commons.get(i);
                            List<FitRecordGirthValBean> recordData = girthInfoBean.getRecordData();
                            int count = recordData.size();
                            if (count > 0) {
                                ArrayList<Entry> values = new ArrayList<>();
                                for (int j = 0; j < count; j++) {//添加值
                                    FitRecordGirthValBean valBean = recordData.get(j);
                                    Date parse = df.parse(valBean.getRecordDate());
                                    valBean.setRecordDate(format.format(parse));//转换时间格式
                                    recordData.set(j, valBean);
                                    values.add(new Entry(j, valBean.getRecordData()));
                                }
                                // 添加折线
                                List<ILineDataSet> dataSets = new ArrayList<>();
                                dataSets.add(getLineDataSet(values));
                                // 绘制折线
                                LineData data = new LineData(dataSets);

                                girthInfoBean.setRecordData(recordData);//重新保存设置的时间格式
                                girthInfoBean.setLineData(data);

                                commons.set(i, girthInfoBean);//保存到对象
                            }
                        }


                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        //将数据重组
                        recordInfo.setRecordCommons(commons);
                        emitter.onNext(recordInfo);
                        emitter.onComplete();
                    }
                };
        return createObservableOnSubscribe(onSubscribe);
    }

    @NonNull
    private LineDataSet getLineDataSet(ArrayList<Entry> values) {
        LineDataSet lineDataSet = new LineDataSet(values, "");
        lineDataSet.setAxisDependency(YAxis.AxisDependency.RIGHT);
        lineDataSet.setColor(ColorTemplate.getHoloBlue());
        lineDataSet.setCircleColor(ContextCompat.getColor(context, R.color.chart_val_color));
        lineDataSet.setLineWidth(2f);
        lineDataSet.setFillAlpha(65);
        lineDataSet.setDrawFilled(true);
        lineDataSet.setFillColor(ColorTemplate.getHoloBlue());
        lineDataSet.setHighLightColor(Color.rgb(244, 117, 117));
        lineDataSet.setValueTextColor(ContextCompat.getColor(context, R.color.chart_val_color));
        lineDataSet.setValueTextSize(13f);
        lineDataSet.setDrawValues(true);
        return lineDataSet;
    }

    @NonNull
    private Observable<ResultMsgBean> addForResult(final FitRecordGirthInfoBean girthInfoBean,
                                                   final ResultMsgBean resultMsgBean,
                                                   final float val) {

        ObservableOnSubscribe<ResultMsgBean> onSubscribe =
                new ObservableOnSubscribe<ResultMsgBean>() {
                    @Override
                    public void subscribe(ObservableEmitter<ResultMsgBean> emitter) throws Exception {
                        final String pattern = "MM/dd#yyyy";
                        List<FitRecordGirthValBean> recordData = girthInfoBean.getRecordData();
                        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
                        String date = dateFormat.format(new Date());

                        FitRecordGirthValBean girthValBean = new FitRecordGirthValBean();
                        girthValBean.setRecordData(val);
                        girthValBean.setRecordDate(date);
                        recordData.add(girthValBean);
                        int count = recordData.size();
                        girthInfoBean.setRecordData(recordData);

                        ArrayList<Entry> values = new ArrayList<>();
                        for (int j = 0; j < count; j++) {//添加值
                            values.add(new Entry(j, recordData.get(j).getRecordData()));
                        }
                        // 添加折线
                        List<ILineDataSet> dataSets = new ArrayList<>();
                        dataSets.add(getLineDataSet(values));

                        // 绘制折线
                        LineData data = new LineData(dataSets);
                        girthInfoBean.setLineData(data);
                        emitter.onNext(resultMsgBean);
                        emitter.onComplete();
                    }
                };

        return createObservableOnSubscribe(onSubscribe);
    }

    public Observable<List<FitRecordImgInfoBean>> startShowSelector(final List<FitRecordImgInfoBean> imgList, final boolean isShow) {
        ObservableOnSubscribe<List<FitRecordImgInfoBean>> onSubscribe =
                new ObservableOnSubscribe<List<FitRecordImgInfoBean>>() {
                    @Override
                    public void subscribe(ObservableEmitter<List<FitRecordImgInfoBean>> emitter) throws Exception {
                        try {
                            int size = imgList.size();
                            for (int i = 0; i < size; i++) {
                                FitRecordImgInfoBean infoBean = imgList.get(i);
                                infoBean.setShow(isShow);
                                infoBean.setSelected(false);
                                imgList.set(i, infoBean);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        } finally {
                            emitter.onNext(imgList);
                            emitter.onComplete();
                        }
                    }
                };
        return createObservableOnSubscribe(onSubscribe);
    }

    public Observable<String> setSelector(final List<String> imgPathList, final List<FitRecordImgInfoBean> imgList, final int position) {
        ObservableOnSubscribe<String> onSubscribe =
                new ObservableOnSubscribe<String>() {
                    @Override
                    public void subscribe(ObservableEmitter<String> emitter) throws Exception {
                        String hint = "";
                        try {
                            int size = imgList.size();
                            for (int i = 0; i < size; i++) {
                                if (i == position) {
                                    FitRecordImgInfoBean infoBean = imgList.get(position);
                                    String path = infoBean.getPicOrgAddr();
                                    if (imgPathList.contains(path)) {//已添加
                                        imgPathList.remove(path);
                                        infoBean.setSelected(false);
                                    } else {
                                        if (imgPathList.size() == 2) {
                                            hint = "最多只能添加2张图片哦";
                                        } else {
                                            imgPathList.add(path);
                                            infoBean.setSelected(true);
                                        }
                                    }
                                    imgList.set(position, infoBean);
                                    break;
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        } finally {
                            emitter.onNext(hint);
                            emitter.onComplete();
                        }
                    }
                };
        return createObservableOnSubscribe(onSubscribe);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/homesearch/HomeSearchCityAct.java<|end_filename|>
package com.scj.beilu.app.ui.home.homesearch;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.mvp.home.HomeSearchCityPre;
import com.scj.beilu.app.ui.home.adapter.HomeSearchCityAdapter;

/**
 * author: SunGuiLan
 * date:2019/2/14
 * descriptin:定位城市
 */
public class HomeSearchCityAct extends BaseMvpActivity<HomeSearchCityPre.HomeSearchCityView, HomeSearchCityPre> implements HomeSearchCityPre.HomeSearchCityView {
    private RecyclerView m_city;

    public static void startHomeSearchCityAct(Activity activity) {
        Intent intent = new Intent(activity, HomeSearchCityAct.class);
        activity.startActivity(intent);
    }

    @Override
    public void initView() {
        super.initView();
        m_city = findViewById(R.id.mRecyclerView);
        m_city.setAdapter(new HomeSearchCityAdapter());
        m_city.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(0, 15, 0, 15);
            }
        });
    }

    @NonNull
    @Override
    public HomeSearchCityPre createPresenter() {
        return new HomeSearchCityPre();
    }

    @Override
    public int getLayout() {
        return R.layout.act_home_search_city;
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/HomeSearchFindInfoFrag.java<|end_filename|>
package com.scj.beilu.app.ui.home;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewStub;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.entity.SearchHistoryEntity;
import com.scj.beilu.app.mvp.find.SearchInfoPre;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.ModifyRecordBean;
import com.scj.beilu.app.mvp.home.bean.EventSearchTypeBean;
import com.scj.beilu.app.mvp.user.bean.RecommendUserInfoBean;
import com.scj.beilu.app.ui.preview.PicImagePreviewAct;
import com.scj.beilu.app.ui.find.FindDetailsAct;
import com.scj.beilu.app.ui.find.FindDetailsFrag;
import com.scj.beilu.app.ui.find.adapter.FindInfoListAdapter;
import com.scj.beilu.app.ui.user.UserInfoHomePageAct;
import com.scj.beilu.app.util.ToastUtils;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/12 02:07
 */
public class HomeSearchFindInfoFrag extends BaseMvpFragment<SearchInfoPre.SearchLoadHistoryView, SearchInfoPre>
        implements SearchInfoPre.SearchLoadHistoryView, OnGroupItemClickListener<ArrayList<FindImageBean>>,
        OnItemClickListener {

    private View mLoadingView;
    private LinearLayout mLLEmpty;
    private TextView mTvEmptyHint;
    private ViewStub mLoading;

    private String mKeyName;

    private FindInfoListAdapter mFindInfoListAdapter;

    private int mRecordPosition = -1;
    private static final int REQUEST_CODE = 0x001;
    private int mDynamicIdByIndex;

    @Override
    public SearchInfoPre createPresenter() {
        return new SearchInfoPre(mFragmentActivity);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        EventBus.getDefault().register(this);
    }

    @Override
    public void onSupportInvisible() {
        super.onSupportInvisible();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe
    public void onKeyName(EventSearchTypeBean eventSearch) {
        mCurrentPage = 0;
        mKeyName = eventSearch.keyName;
        getPresenter().startSearch(mKeyName, mCurrentPage);
    }


    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_home_search_list;
    }

    @Override
    public void initView() {
        super.initView();

        mLoading = findViewById(R.id.view_stu_loading);
        mLLEmpty = findViewById(R.id.ll_load_empty_view);
        mTvEmptyHint = findViewById(R.id.tv_empty_hint);

        mLoading = findViewById(R.id.view_stu_loading);
        mLLEmpty = findViewById(R.id.ll_load_empty_view);
        mTvEmptyHint = findViewById(R.id.tv_empty_hint);

        mFindInfoListAdapter = new FindInfoListAdapter(GlideApp.with(this), mFragmentActivity);
        mFindInfoListAdapter.setOnItemClickListener(this);
        mFindInfoListAdapter.setOnGroupItemClickListener(this);
        mRecyclerView.setAdapter(mFindInfoListAdapter);

        final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
        mRecyclerView.getItemAnimator().setChangeDuration(0);

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            int firstVisibleItem, lastVisibleItem;

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
                lastVisibleItem = layoutManager.findLastVisibleItemPosition();
                //大于0说明有播放
                if (GSYVideoManager.instance().getPlayPosition() >= 0) {
                    //当前播放的位置
                    int position = GSYVideoManager.instance().getPlayPosition();
                    //对应的播放列表TAG
                    if (GSYVideoManager.instance().getPlayTag().equals(FindInfoListAdapter.TAG)
                            && (position < firstVisibleItem || position > lastVisibleItem)) {
                        //如果滑出去了上面和下面就是否，和今日头条一样
                        //是否全屏
                        if (!GSYVideoManager.isFullState(mFragmentActivity)) {
                            GSYVideoManager.releaseAllVideos();
                            mFindInfoListAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });
        mTvEmptyHint.setText("暂无搜索结果");

    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().startSearch(mKeyName, mCurrentPage);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }


    @Override
    public void onItemClick(int groupPosition, int childPosition, ArrayList<FindImageBean> object, View view) {
        switch (view.getId()) {
            case R.id.iv_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, object, childPosition);
                break;
        }
    }

    @Override
    public void onItemClick(int position, Object object, View view) {

        Intent intent;

        FindInfoBean findInfo = null;
        if (object instanceof FindInfoBean) {
            findInfo = (FindInfoBean) object;
        }

        switch (view.getId()) {

            case R.id.ll_item_find_praise:
                getPresenter().setLike(findInfo.getDynamicId(), position);
                break;
            case R.id.ll_item_find_comment:
            case R.id.tv_item_find_txt:
                mRecordPosition = position;
                GSYVideoManager.releaseAllVideos();
                intent = new Intent(mFragmentActivity, FindDetailsAct.class);
                intent.putExtra(FindDetailsFrag.FIND_ID, findInfo.getDynamicId());
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.ll_item_find_share:
                if (!EventBus.getDefault().isRegistered(this)) {
                    EventBus.getDefault().register(this);
                }
                mRecordPosition = position;
                mDynamicIdByIndex = findInfo.getDynamicId();
                getPresenter().startShareFind(this, findInfo);
                break;
            case R.id.tv_item_find_attention:
                getPresenter().setFocusUser(findInfo.getUserId());
                break;
            case R.id.iv_item_find_avatar:
                intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                int userId = findInfo.getIsOwn() == 0 ? findInfo.getUserId() : -1;
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, userId);
                startActivityForResult(intent, REQUEST_CODE);
                break;
            case R.id.iv_item_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, findInfo.getDynamicPic(), position);
                break;
        }
    }

    @Override
    public void onSearchHistoryList(List<SearchHistoryEntity> searchHistoryList) {
        //none
    }

    @Override
    public void onFindListResult(List<FindInfoBean> findList) {
        if (findList.size() == 0) {
            mRecyclerView.setVisibility(View.GONE);
            mLLEmpty.setVisibility(View.VISIBLE);
        } else {
            hideSoftInput();
            mRecyclerView.setVisibility(View.VISIBLE);
            mLLEmpty.setVisibility(View.GONE);
            mFindInfoListAdapter.setFindInfoList(findList);
        }
    }

    @Override
    public void onUserList(List<RecommendUserInfoBean> userInfoList) {
        //none
    }

    @Override
    public void onNotifyListChangeResult(String result, int position) {
        ToastUtils.showToast(mFragmentActivity, result);
        if (position != -1) {
            mFindInfoListAdapter.notifyItemChanged(position);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onModifyResult(int position) {
        if (position == mRecordPosition) {
            mFindInfoListAdapter.notifyItemChanged(mRecordPosition);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onAddForResult(int position) {
        //none
    }

    @Override
    public void onAttentionResult(String result, int position) {
        //none
    }

    @Override
    public void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume(false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }

    @Override
    public boolean onBackPressedSupport() {
        if (GSYVideoManager.backFromWindowFull(mFragmentActivity)) {
            return true;
        }
        return super.onBackPressedSupport();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            GSYVideoManager.onPause();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
            ModifyRecordBean record = data.getParcelableExtra(FindDetailsFrag.EXTRA_MODIFY_RESULT);
            getPresenter().modifyRecord(record, mRecordPosition);
        }
    }


    @Subscribe
    public void onShareResult(BaseResp resp) {
        getPresenter().setFindShareCount(mDynamicIdByIndex);
    }

    @Override
    public void onFindDel() {
        getPresenter().delFind(mDynamicIdByIndex);
    }

    @Override
    public void onShareCountResult() {
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void onFindDelResult(ResultMsgBean result) {
        mFindInfoListAdapter.notifyItemRemoved(mRecordPosition);
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        mRecordPosition = -1;
    }

    @Override
    public void showLoading(int loading, boolean isShow) {
        if (loading == ShowConfig.LOADING_REFRESH) {
            if (mCurrentPage == 0) {
                mLLEmpty.setVisibility(View.GONE);
                if (isShow) {
                    mRecyclerView.setVisibility(View.GONE);
                    if (mLoadingView == null) {
                        mLoadingView = mLoading.inflate();
                    } else {
                        mLoading.setVisibility(View.VISIBLE);
                    }
                } else {
                    if (mLoadingView != null) {
                        mLoading.setVisibility(View.GONE);
                    }
                    mRecyclerView.setVisibility(View.VISIBLE);
                }
            }
        }
    }

    @Override
    public void showError(int errorCode, String throwableContent) {
        if (mLoadingView != null) {
            mLoading.setVisibility(View.GONE);
        }
        ToastUtils.showToast(mFragmentActivity, throwableContent);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/common/UserInfoPre.java<|end_filename|>
package com.scj.beilu.app.mvp.common;

import android.content.Context;
import android.support.annotation.NonNull;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.user.IUser;
import com.scj.beilu.app.mvp.common.user.UserImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Mingxun
 * @time on 2019/2/13 15:13
 */
public class UserInfoPre extends BaseMvpPresenter<UserInfoPre.VerifyCodeView> {
    private IUser mIUser;

    public UserInfoPre(Context context) {
        super(context);
        initLoad(ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mIUser = new UserImpl(mBuilder);
    }


    public void setHintNum(final String num) {
        onceViewAttached(new ViewAction<VerifyCodeView>() {
            @Override
            public void run(@NonNull VerifyCodeView mvpView) {
                String phoneNumber = num.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
                phoneNumber = String.format(mContext.getResources().getString(R.string.msg_send_hint), phoneNumber);
                mvpView.showSendHint(phoneNumber);
            }
        });
    }

    public void checkTxt(final EditText editText) {
        onceViewAttached(new ViewAction<VerifyCodeView>() {
            @Override
            public void run(@NonNull final VerifyCodeView mvpView) {
                final TextWatcher textWatcher = new TextWatcher() {
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {
                        if (s.length() == 6) {
                            mvpView.onButtonEnable(true, s.toString());
                        } else {
                            mvpView.onButtonEnable(false, null);
                        }
                    }

                    @Override
                    public void afterTextChanged(Editable s) {

                    }
                };
                editText.addTextChangedListener(textWatcher);


            }

        });
    }

    public void startRegSend(final String num) {
        onceViewAttached(new ViewAction<VerifyCodeView>() {
            @Override
            public void run(@NonNull final VerifyCodeView mvpView) {
                Map<String, Object> params = new HashMap<>();
                params.put("userTel", num);
                mIUser.setSendRegCodeParams(params)
                        .subscribe(new BaseResponseCallback(
                                mBuilder.build(mvpView)
                        ) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.codeResult(resultMsgBean);
                            }
                        });

            }
        });
    }

    public void startLoginSend(final String num) {
        onceViewAttached(new ViewAction<VerifyCodeView>() {
            @Override
            public void run(@NonNull final VerifyCodeView mvpView) {
                Map<String, Object> params = new HashMap<>();
                params.put("userTel", num);
                mIUser.setSendLoginCodeParams(params)
                        .subscribe(new BaseResponseCallback(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.codeResult(resultMsgBean);
                            }
                        });
            }
        });
    }

    public void startReg(final String number, final String code) {
        onceViewAttached(new ViewAction<VerifyCodeView>() {
            @Override
            public void run(@NonNull final VerifyCodeView mvpView) {
                Map<String, Object> params = new HashMap<>();
                params.put("userTel", Encrypt(number));
                params.put("userPassword", Encrypt("<PASSWORD>0"));
                params.put("code", code);
                params.put("userAppKey", "25307800");
                params.put("userTargetValue", Encrypt(PushServiceFactory.getCloudPushService().getDeviceId()));
                mIUser.setRegParams(params)
                        .subscribe(new BaseResponseCallback(
                                mBuilder.build(mvpView)
                        ) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onLoginSuccess();
                            }
                        });
            }
        });
    }

    public void startLogin(final String number, final String code) {

        onceViewAttached(new ViewAction<VerifyCodeView>() {
            @Override
            public void run(@NonNull VerifyCodeView mvpView) {
                Map<String, Object> params = new HashMap<>();
                params.put("userTel", Encrypt(number));
                params.put("code", code);
                params.put("userAppKey", "25307800");
                params.put("targetValue", Encrypt(PushServiceFactory.getCloudPushService().getDeviceId()));
                mIUser.setLoginParams(params)
                        .subscribe(new BaseResponseCallback(
                                mBuilder.build(mvpView)
                        ) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                onceViewAttached(new ViewAction<VerifyCodeView>() {
                                    @Override
                                    public void run(@NonNull VerifyCodeView mvpView) {
                                        mvpView.onLoginSuccess();
                                    }
                                });
                            }
                        });
            }
        });
    }


    public interface VerifyCodeView extends MvpView {
        void showSendHint(String content);

        void codeResult(ResultMsgBean result);

        void onButtonEnable(boolean enable, String txt);

        void onLoginSuccess();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/store/StorePre.java<|end_filename|>
package com.scj.beilu.app.mvp.store;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.store.bean.GoodsBannerInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsBannerResultBean;
import com.scj.beilu.app.mvp.store.bean.GoodsCategoryInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsCategoryListBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsListResultBean;
import com.scj.beilu.app.mvp.store.model.GoodsInfoImpl;
import com.scj.beilu.app.mvp.store.model.IGoodsInfo;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Observable;

/**
 * @author Mingxun
 * @time on 2019/3/26 03:25
 */
public class StorePre extends ShoppingCartPre<StorePre.StoreView> {

    private IGoodsInfo mGoodsInfo;


    public StorePre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mGoodsInfo = new GoodsInfoImpl(mBuilder);
    }

    public void getCurrentPageData() {
        onceViewAttached(new ViewAction<StoreView>() {
            @Override
            public void run(@NonNull final StoreView mvpView) {
                Observable.merge(mGoodsInfo.getBannerList(), mGoodsInfo.getGoodsCategoryList(),
                        mGoodsInfo.getGoodsList(0))
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                try {
                                    if (resultMsgBean instanceof GoodsBannerResultBean) {
                                        GoodsBannerResultBean bannerResultBean = (GoodsBannerResultBean) resultMsgBean;
                                        mvpView.onBannerList(bannerResultBean.getBanner());
                                    } else if (resultMsgBean instanceof GoodsCategoryListBean) {
                                        GoodsCategoryListBean goodsCategoryList = (GoodsCategoryListBean) resultMsgBean;
                                        mvpView.onCategoryList((ArrayList<GoodsCategoryInfoBean>) goodsCategoryList.getCates());
                                    } else if (resultMsgBean instanceof GoodsListResultBean) {
                                        GoodsListResultBean goodsList = (GoodsListResultBean) resultMsgBean;
                                        mvpView.onGoodsList(goodsList.getPage().getList());
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface StoreView extends ShoppingCartPre.ShoppingCartView {
        void onBannerList(List<GoodsBannerInfoBean> bannerList) throws Exception;

        void onCategoryList(ArrayList<GoodsCategoryInfoBean> categoryList) throws Exception;

        void onGoodsList(List<GoodsInfoBean> goodsList) throws Exception;

    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/course/CoursePre.java<|end_filename|>
package com.scj.beilu.app.mvp.course;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.course.bean.CourseTypeInfoBean;
import com.scj.beilu.app.mvp.course.bean.CourseTypeListBean;
import com.scj.beilu.app.mvp.course.model.CourseInfoImpl;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/1/11 15:37
 */
public class CoursePre extends BaseMvpPresenter<CoursePre.CourseView> {

    private CourseInfoImpl mCourseInfo;
    private List<CourseTypeInfoBean> mCourseTypeInfoBeans;

    public CoursePre(Context context) {
        super(context, ShowConfig.LOADING_STATE, ShowConfig.ERROR_TOAST);
        mCourseInfo = new CourseInfoImpl(mBuilder);
    }

    public void getCourseTypeList() {
        mBuilder.setLoadType(ShowConfig.LOADING_STATE);
        onceViewAttached(new ViewAction<CourseView>() {
            @Override
            public void run(@NonNull final CourseView mvpView) {
                mCourseInfo.getCourseTypeList()
                        .subscribe(new BaseResponseCallback<CourseTypeListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(CourseTypeListBean courseTypeListBean) {
                                mCourseTypeInfoBeans = courseTypeListBean.getCates();
                                mvpView.onCourseTypeListResult(mCourseTypeInfoBeans);
                            }
                        });
            }
        });
    }

    public void setSelectCourseType(final int position) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(new ViewAction<CourseView>() {
            @Override
            public void run(@NonNull final CourseView mvpView) {
                mCourseInfo.setSelect(mCourseTypeInfoBeans, position)
                        .subscribe(new ObserverCallback<CourseTypeInfoBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(CourseTypeInfoBean courseTypeInfoBean) {
                                mvpView.onSelectResult(courseTypeInfoBean);
                            }
                        });
            }
        });
    }

    public interface CourseView extends MvpView {

        void onCourseTypeListResult(List<CourseTypeInfoBean> courseTypeInfoList);

        void onSelectResult(CourseTypeInfoBean courseTypeInfo);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindManagerPagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.mx.pro.lib.fragmentation.support.SupportFragment;

import java.util.List;

public class FindManagerPagerAdapter extends FragmentPagerAdapter {

    private List<SupportFragment> mFindInfoListFrags;

    public FindManagerPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setFindInfoListFrags(List<SupportFragment> findInfoListFrags) {
        mFindInfoListFrags = findInfoListFrags;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return mFindInfoListFrags.get(position);
    }

    @Override
    public int getCount() {
        return mFindInfoListFrags == null ? 0 : mFindInfoListFrags.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/fit/FitRecordMyAlbumFrag.java<|end_filename|>
package com.scj.beilu.app.ui.fit;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.mx.pro.lib.album.AlbumManager;
import com.mx.pro.lib.album.GlideEngine;
import com.mx.pro.lib.album.MimeType;
import com.mx.pro.lib.album.internal.entity.CaptureStrategy;
import com.mx.pro.lib.album.utils.MediaStoreCompat;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.fit.FitRecordMyAlbumPre;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgInfoBean;
import com.scj.beilu.app.ui.dialog.SelectPictureDialog;
import com.scj.beilu.app.ui.fit.adapter.FitRecordMyAlbumListAdapter;
import com.scj.beilu.app.util.ToastUtils;

import java.util.ArrayList;
import java.util.List;

import static com.scj.beilu.app.api.Constants.DIRECTORY;

/**
 * @author Mingxun
 * @time on 2019/3/14 21:10
 */
public class FitRecordMyAlbumFrag extends BaseMvpFragment<FitRecordMyAlbumPre.FitRecordMyAlbumView, FitRecordMyAlbumPre>
        implements FitRecordMyAlbumPre.FitRecordMyAlbumView, View.OnClickListener, SelectPictureDialog.onSelectPhoto,
        OnItemClickListener<FitRecordImgInfoBean> {

    private FrameLayout mFlSelectPicture;
    private TextView mTvCustomPhoto;
    private TextView mTvPictureRange;
    private MediaStoreCompat mMediaStoreCompat;
    private static final int REQUEST_CODE_CAPTURE = 0x01;
    private static final int REQUEST_CODE_ALBUM = 0x02;
    private static final int REQUEST_CODE_PREVIEW = 0x03;
    private static final int REQUEST_CODE_GENERATE = 0x04;

    private FitRecordMyAlbumListAdapter mFitRecordMyAlbumListAdapter;

    private int mRectSize = 0;
    private boolean isShowSelector = false;
    private boolean isClickBack = false;
    private final List<String> mGeneratePic = new ArrayList<>();

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_fit_record_my_album;
    }

    @Override
    public void initView() {
        super.initView();
        mFlSelectPicture = findViewById(R.id.fl_add_picture);
        mTvCustomPhoto = findViewById(R.id.tv_custom_photo);
        mTvPictureRange = findViewById(R.id.tv_picture_range);

        if (isAdded()) {
            mRectSize = getResources().getDimensionPixelSize(R.dimen.padding_15);
        }

        mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(0, mRectSize, mRectSize, 0);
            }
        });

        mFlSelectPicture.setOnClickListener(this);
        mTvCustomPhoto.setOnClickListener(this);
        mFitRecordMyAlbumListAdapter = new FitRecordMyAlbumListAdapter(GlideApp.with(this), mFragmentActivity);
        mFitRecordMyAlbumListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mFitRecordMyAlbumListAdapter);
        mRecyclerView.getItemAnimator().setChangeDuration(0);

        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getAlbumList(mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getAlbumList(mCurrentPage);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public FitRecordMyAlbumPre createPresenter() {
        return new FitRecordMyAlbumPre(mFragmentActivity);
    }

    @Override
    public void onAlbumListResult(List<FitRecordImgInfoBean> albumList) {
        mFitRecordMyAlbumListAdapter.setFitRecordImgInfoBeans(albumList);
    }

    @Override
    public void onAddForResult(String result) {
        isShowSelector = false;
        isClickBack = true;
        ToastUtils.showToast(mFragmentActivity, result);
        mRecyclerView.scrollToPosition(0);
        mFitRecordMyAlbumListAdapter.notifyItemInserted(0);
        setFragmentResult(RESULT_OK, null);
    }

    @Override
    public void onShowSelector(List<String> selectedImg, int position, String hint) {
        if (mTvPictureRange.getVisibility() == View.GONE) {
            mTvPictureRange.setVisibility(View.VISIBLE);
        }
        if (position == -1) {
            mFitRecordMyAlbumListAdapter.notifyDataSetChanged();
            if (isShowSelector) {
                mTvCustomPhoto.setText("完成（0/2）张图");
                mTvCustomPhoto.setEnabled(false);
            } else {
                if (!isClickBack) {
                    startForResult(FitRecordGeneratePictureFrag.newInstance(mGeneratePic), REQUEST_CODE_GENERATE);
                }
                mTvPictureRange.setVisibility(View.GONE);
                mTvCustomPhoto.setText("制作对比照");
                mTvCustomPhoto.setEnabled(true);
            }
        } else {
            isClickBack = false;
            mGeneratePic.clear();
            mGeneratePic.addAll(selectedImg);
            mFitRecordMyAlbumListAdapter.notifyItemChanged(position);
            mTvCustomPhoto.setEnabled(mGeneratePic.size() == 2);
            mTvCustomPhoto.setText("完成（" + mGeneratePic.size() + "/2）张图");
        }

        if (!TextUtils.isEmpty(hint)) {
            ToastUtils.showToast(mFragmentActivity, hint);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.fl_add_picture:
                SelectPictureDialog dialog = new SelectPictureDialog();
                dialog.setOnSelectPhoto(this);
                dialog.show(getChildFragmentManager(), dialog.getClass().getName());
                break;
            case R.id.tv_custom_photo://制作对比照
                isShowSelector = !isShowSelector;
                getPresenter().showSelector(isShowSelector);
                break;
        }
    }


    @Override
    public void selectPhoto(boolean isTakePhoto) {
        if (isTakePhoto) {
            if (mMediaStoreCompat == null) {
                mMediaStoreCompat = new MediaStoreCompat(mFragmentActivity, this);
                mMediaStoreCompat.setCaptureStrategy(new CaptureStrategy(true,
                        mFragmentActivity.getPackageName() + ".fileprovider", DIRECTORY));
            }
            if (!MediaStoreCompat.hasCameraFeature(getContext())) {
                return;
            }
            mMediaStoreCompat.dispatchCaptureIntent(mFragmentActivity, REQUEST_CODE_CAPTURE);
        } else {
            selectAlbum();
        }
    }

    private void selectAlbum() {
        AlbumManager.from(this)
                .choose(MimeType.ofImage(), false)
                .showSingleMediaType(true)
                .countable(true)
                .capture(true)
                .captureStrategy(
                        new CaptureStrategy(false,
                                mFragmentActivity.getPackageName() + ".fileprovider", "test"))
                .maxSelectable(1)
                .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
                .thumbnailScale(0.85f)
                .imageEngine(new GlideEngine())  // for glide-V4
                .maxOriginalSize(10)
                .autoHideToolbarOnSingleTap(true)
                .forResult(REQUEST_CODE_ALBUM);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && requestCode == REQUEST_CODE_ALBUM) {
            List<String> imgList = AlbumManager.obtainPathResult(data);
            String imgPath = imgList.get(0);
            getPresenter().addFitRecordImg(imgPath);
        } else if (resultCode == RESULT_OK && requestCode == REQUEST_CODE_CAPTURE) {
            String imgPath = mMediaStoreCompat.getCurrentPhotoPath();
            getPresenter().addFitRecordImg(imgPath);
        } else if (resultCode == RESULT_OK && requestCode == REQUEST_CODE_PREVIEW) {
            setFragmentResult(RESULT_OK, null);
            mRefreshLayout.autoRefresh();
        }
    }

    @Override
    public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
        super.onFragmentResult(requestCode, resultCode, data);
        if (REQUEST_CODE_GENERATE == requestCode) {
            mRefreshLayout.autoRefresh();
        }
    }

    @Override
    public void onItemClick(int position, FitRecordImgInfoBean entity, View view) {
        switch (view.getId()) {
            case R.id.iv_album_selector:
                getPresenter().setSelector(position);
                break;
            case R.id.iv_fit_record_my_album:
                Intent intent = new Intent(mFragmentActivity, FitRecordAlbumPreviewAct.class);
                intent.putParcelableArrayListExtra(FitRecordAlbumPreviewAct.EXTRA_IMAGE_LIST, getPresenter().getImgList());
                intent.putExtra(FitRecordAlbumPreviewAct.EXTRA_IMAGE_POSITION, position);
                startActivityForResult(intent, REQUEST_CODE_PREVIEW);
                break;
        }
    }

    @Override
    protected void onToolbarNavClick() {
        if (isShowSelector) {
            isShowSelector = false;
            isClickBack = true;
            getPresenter().showSelector(isShowSelector);
        } else {
            mFragmentActivity.onBackPressed();
        }
    }

    @Override
    public boolean onBackPressedSupport() {
        if (isShowSelector) {
            isShowSelector = false;
            isClickBack = true;
            getPresenter().showSelector(isShowSelector);
            return true;
        } else {
            return super.onBackPressedSupport();
        }
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/find/FindPublishPre.java<|end_filename|>
package com.scj.beilu.app.mvp.find;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.find.model.FindImpl;
import com.scj.beilu.app.mvp.find.model.IFindInfo;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/19 16:24
 */
public class FindPublishPre extends BaseMvpPresenter<FindPublishPre.FindPublishView> {
    private IFindInfo mIFind;

    public FindPublishPre(Context context) {
        super(context);
        mIFind = new FindImpl(mBuilder);
    }


    public void startCreate(final List<String> paths, final boolean ofImage, final String description) {
        onceViewAttached(new ViewAction<FindPublishView>() {
            @Override
            public void run(@NonNull FindPublishView mvpView) {
                mIFind.createDynamicParams(paths, ofImage, description)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                // TODO: 2019/2/19
                            }
                        });
            }
        });
    }

    public interface FindPublishView extends MvpView {

    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/MerchantDetailFrag.java<|end_filename|>
package com.scj.beilu.app.ui.merchant;

import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.location.LoctionNavigationUtil;
import com.scj.beilu.app.mvp.merchant.MerchantInfoPre;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoCoachBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoDetailsListBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoMemberShipListBean;
import com.scj.beilu.app.ui.merchant.adapter.MerchantInfoDetailListAdapter;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.DividerDecoration;

import java.util.List;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

/**
 * @author Mingxun
 * @time on 2019/4/13 18:23
 */
@RuntimePermissions
public class MerchantDetailFrag extends BaseMvpFragment<MerchantInfoPre.MerchantInfoView, MerchantInfoPre>
        implements MerchantInfoPre.MerchantInfoView, NestedScrollView.OnScrollChangeListener, View.OnClickListener, OnItemClickListener {

    private static final String MERCHANT_ID = "merchant_id";
    private int mMerchantId;

    private AppBarLayout mAppBarLayout;
    private NestedScrollView mNestedScrollView;
    private ImageView mIvMerchantImg;
    private LinearLayout mLlMerchantImgCount;
    private TextView mTvMerchantImgCount, mTvMerchantName,
            mTvMerchantAreaTime,
            mTvMerchantContact, mTvMerchantStartNav,
            mTvMerchantAddress,
            mTvMerchantDescription;
    private RecyclerView mRvMerchantInfoList;

    private MerchantInfoDetailListAdapter mMerchantInfoDetailListAdapter;
    private int mPicHeight = 0;
    private boolean isChangeWhite = true;
    private GlideRequest<Drawable> mOriginal, mThumbnail;
    private String phoneNum;
    private String mMerchantPhone;
    private double[] mLocation;

    public static MerchantDetailFrag newInstance(int merchantId) {

        Bundle args = new Bundle();
        args.putInt(MERCHANT_ID, merchantId);
        MerchantDetailFrag fragment = new MerchantDetailFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mMerchantId = arguments.getInt(MERCHANT_ID, mMerchantId);
        }
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getMerchantInfo(mMerchantId);
    }

    @Override
    public MerchantInfoPre createPresenter() {
        return new MerchantInfoPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_merchant_info;
    }

    @Override
    public void initView() {
        super.initView();

        ImmersionBar.with(this).statusBarView(R.id.top_view)
                .addTag("PicAndColor")
                .statusBarDarkFont(false)
                .keyboardEnable(true)
                .init();

        mLlMerchantImgCount = findViewById(R.id.ll_merchant_img);
        mAppBarLayout = findViewById(R.id.app_bar_layout_merchant);
        mNestedScrollView = findViewById(R.id.nested_scroll_view);
        mIvMerchantImg = findViewById(R.id.iv_merchant_img);
        mTvMerchantImgCount = findViewById(R.id.tv_merchant_img_count);
        mTvMerchantName = findViewById(R.id.tv_merchant_name);
        mTvMerchantAreaTime = findViewById(R.id.tv_merchant_area_time);
        mTvMerchantContact = findViewById(R.id.tv_merchant_contact);
        mTvMerchantStartNav = findViewById(R.id.tv_merchant_start_nav);
        mTvMerchantAddress = findViewById(R.id.tv_merchant_address);
        mTvMerchantDescription = findViewById(R.id.tv_merchant_description);
        mRvMerchantInfoList = findViewById(R.id.rv_merchant_info_list);

        try {
            mPicHeight = getResources().getDimensionPixelOffset(R.dimen.merchant_pic_height);
            final int actionBarSize = getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_default_height_material);
            mPicHeight = mPicHeight - actionBarSize - ImmersionBar.getStatusBarHeight(mFragmentActivity);
            mNestedScrollView.setOnScrollChangeListener(this);
        } catch (Exception e) {
            e.printStackTrace();
        }
        ViewCompat.setElevation(mAppBarLayout, 0);

        mLlMerchantImgCount.setOnClickListener(this);
        mTvMerchantContact.setOnClickListener(this);
        mTvMerchantStartNav.setOnClickListener(this);

        mMerchantInfoDetailListAdapter = new MerchantInfoDetailListAdapter(this);
        mMerchantInfoDetailListAdapter.setOnItemClickListener(this);
        mRvMerchantInfoList.setAdapter(mMerchantInfoDetailListAdapter);

        mRvMerchantInfoList.addItemDecoration(new DividerDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL, getResources().getDimensionPixelOffset(R.dimen.padding_20)));
    }

    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
        if (scrollY >= mPicHeight) {
            if (isChangeWhite) {
                mFragmentActivity.runOnUiThread(() -> {
                    ImmersionBar.with(MerchantDetailFrag.this)
                            .statusBarDarkFont(true,0.2f)
                            .init();
                    isChangeWhite = false;
                    mAppToolbar.setNavigationIcon(R.drawable.ic_back);
                    mAppBarLayout.setBackgroundColor(ContextCompat.getColor(mFragmentActivity, android.R.color.white));
                    ViewCompat.setElevation(mAppBarLayout, 10);
                });

            }
        } else {
            if (!isChangeWhite) {
                mFragmentActivity.runOnUiThread(() -> {
                    ImmersionBar.with(MerchantDetailFrag.this).statusBarDarkFont(false)
                            .init();
                    isChangeWhite = true;
                    mAppToolbar.setNavigationIcon(R.drawable.ic_back_white);
                    mAppBarLayout.setBackgroundColor(ContextCompat.getColor(mFragmentActivity, android.R.color.transparent));
                    ViewCompat.setElevation(mAppBarLayout, 0);
                });
            }
        }
    }

    @Override
    public void onMerchantInfo(MerchantInfoBean merchantInfo) {
        try {
            if (mOriginal == null) {
                mOriginal = GlideApp.with(this).asDrawable().optionalCenterCrop();
                mThumbnail = GlideApp.with(this).asDrawable().optionalCenterCrop();
            }

            mOriginal.load(merchantInfo.getMerchantPicAddr())
                    .thumbnail(mThumbnail.load(merchantInfo.getMerchantPicAddrZip()))
                    .into(mIvMerchantImg);
            mTvMerchantImgCount.setText(String.valueOf(merchantInfo.getCountMerchantAlbum()));
            mTvMerchantName.setText(merchantInfo.getMerchantName());
            String areaTime = getResources().getString(R.string.txt_merchant_area_time);
            String area = merchantInfo.getMerchantArea();
            area = (area == null) ? "无" : area + "㎡";
            String openShop = merchantInfo.getMerchantOpenShop();
            String closeShop = merchantInfo.getMerchantCloseShop();
            openShop = (openShop == null) ? "00:00" : openShop;
            closeShop = (closeShop == null) ? "00:00" : closeShop;
            mTvMerchantAreaTime.setText(String.format(areaTime, area, openShop, closeShop));
            String description = merchantInfo.getMerchantDec();
            description = (description == null) ? "无" : description;
            mTvMerchantAddress.setText(merchantInfo.getMerchantAddr());
            mTvMerchantDescription.setText(description);

            mMerchantPhone = merchantInfo.getMerchantTel();

            mLocation = new double[]{Double.parseDouble(merchantInfo.getMerchantLatitude()), Double.parseDouble(merchantInfo.getMerchantLongitude())};
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onMerchantInfoList(List<MerchantInfoDetailsListBean> detailInfo) {
        mMerchantInfoDetailListAdapter.setDetailsList(detailInfo);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_merchant_img:
                start(MerchantPhotoManagerFrag.newInstance(mMerchantId));
                break;
            case R.id.tv_merchant_contact:
                phoneNum = mMerchantPhone;
                MerchantDetailFragPermissionsDispatcher.needsCallPhoneWithPermissionCheck(this);
                break;
            case R.id.tv_merchant_start_nav:
                LoctionNavigationUtil.gaodeGuide(mFragmentActivity, mLocation);
                break;
        }
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        if (entity instanceof MerchantInfoCoachBean) {
            MerchantInfoCoachBean coachInfo = (MerchantInfoCoachBean) entity;
            start(MerchantCoachInfoFrag.newInstance(coachInfo.getMerchantId(), coachInfo.getCoachId()));
        } else if ((entity instanceof MerchantInfoMemberShipListBean)) {
            //call phone
            MerchantInfoMemberShipListBean info = (MerchantInfoMemberShipListBean) entity;
            phoneNum = info.getMemberShipTel();
            MerchantDetailFragPermissionsDispatcher.needsCallPhoneWithPermissionCheck(this);
        }
    }

    @NeedsPermission(Manifest.permission.CALL_PHONE)
    void needsCallPhone() {
        if (phoneNum != null) {
            new AlertDialog.Builder(mFragmentActivity)
                    .setPositiveButton("呼叫", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(@NonNull DialogInterface dialog, int which) {
                            Intent intent = new Intent(Intent.ACTION_CALL);
                            Uri data = Uri.parse("tel:" + phoneNum);
                            intent.setData(data);
                            startActivity(intent);
                        }
                    })
                    .setNegativeButton(R.string.button_cancel, (dialog, which) -> dialog.cancel())
                    .setCancelable(false)
                    .setMessage(phoneNum)
                    .show();
        } else {
            ToastUtils.showToast(mFragmentActivity, "暂时无法拨打电话～");
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        MerchantDetailFragPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

    @OnShowRationale(Manifest.permission.CALL_PHONE)
    void rationaleCallPhone(final PermissionRequest request) {
        showRationaleDialog(R.string.permission_call_phone, request);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/home/HomeSearchFindInfoPre.java<|end_filename|>
package com.scj.beilu.app.mvp.home;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.scj.beilu.app.mvp.find.FindInfoPre;
import com.scj.beilu.app.mvp.find.FindInfoView;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.FindListBean;
import com.scj.beilu.app.mvp.find.model.FindImpl;
import com.scj.beilu.app.mvp.find.model.IFindInfo;
import com.scj.beilu.app.mvp.home.model.HomeInfoImpl;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;
import io.reactivex.subjects.PublishSubject;

/**
 * @author Mingxun
 * @time on 2019/4/12 02:07
 */
public class HomeSearchFindInfoPre extends FindInfoPre<FindInfoView> {

    private PublishSubject<String> mPublishSubject;

    private IFindInfo mFindInfo;
    private HomeInfoImpl mHomeInfo;

    private List<FindInfoBean> mFindInfoList;

    public HomeSearchFindInfoPre(Context context) {
        super(context);
        mFindInfo = new FindImpl(mBuilder);
        mHomeInfo = new HomeInfoImpl(mBuilder);
    }


    public void startSearch(final String keyName, final int currentPage) {

        onceViewAttached(new ViewAction<FindInfoView>() {
            @Override
            public void run(@NonNull FindInfoView mvpView) {
                if (mPublishSubject == null) {
                    mPublishSubject = PublishSubject.create();
                    mPublishSubject.debounce(1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
                            .filter(new Predicate<String>() {
                                @Override
                                public boolean test(String s) throws Exception {
                                    return s.length() > 0;
                                }
                            })

                            .switchMap(new Function<String, Observable<String>>() {
                                @Override
                                public Observable<String> apply(String s) throws Exception {
                                    return mHomeInfo.content(s);
                                }
                            })
                            .subscribe(new ObserverCallback<String>(mBuilder.build(mvpView)) {
                                @Override
                                public void onNext(String keyName) {
                                    searchFindInfoList(keyName, currentPage);
                                }
                            });

                }

                mPublishSubject.onNext(keyName);
            }
        });
    }


    private void searchFindInfoList(final String keyName, final int currentPage) {
        onceViewAttached(new ViewAction<FindInfoView>() {
            @Override
            public void run(@NonNull final FindInfoView mvpView) {
                mFindInfo.startSearchFind(currentPage, keyName)
                        .subscribe(new ObserverCallback<FindListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(FindListBean findListBean) {
                                try {
                                    List<FindInfoBean> list = findListBean.getPage().getList();
                                    if (currentPage == 0) {
                                        if (mFindInfoList == null) {
                                            mFindInfoList = new ArrayList<>();
                                        }
                                        mFindInfoList.clear();
                                    }
                                    if (list == null) {
                                        list = new ArrayList<>();
                                    }
                                    mFindInfoList.addAll(list);
                                    mvpView.onCheckLoadMore(list);

                                    mvpView.onFindListResult(mFindInfoList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }

                        });
            }
        });
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/order/OrderInfoStatusFrag.java<|end_filename|>
package com.scj.beilu.app.ui.order;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.order.OrderInfoStatusPre;
import com.scj.beilu.app.mvp.order.bean.OrderInfoBean;
import com.scj.beilu.app.mvp.order.bean.OrderLogisticsInfoBean;
import com.scj.beilu.app.mvp.order.bean.OrderLogisticsInfoResultBean;
import com.scj.beilu.app.ui.comment.SelectPaymentDialog;
import com.scj.beilu.app.util.ToastUtils;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/2 22:59"
 * 订单状态
 */
public class OrderInfoStatusFrag extends BaseMvpFragment<OrderInfoStatusPre.OrderInfoStatusView, OrderInfoStatusPre>
        implements OrderInfoStatusPre.OrderInfoStatusView, View.OnClickListener, SelectPaymentDialog.onStartPay, ApplyRefundDialog.onRefundContent {


    private TextView tv_order_info_status_name, tv_order_info_count_down, tv_order_info_tip;
    private ConstraintLayout cl_order_info_address_info;
    private TextView tv_order_info_logistics_val, tv_order_logistics_time;
    private TextView tv_order_info_consignee, tv_order_info_consignee_phone, tv_order_info_consignee_address;
    private ImageView iv_order_info_goods_img;
    private TextView tv_order_info_goods_name, tv_goods_num, tv_order_info_goods_specification, tv_order_info_goods_price;
    private TextView tv_order_info_price, tv_order_no, tv_order_create_date, tv_order_payment_type;
    private TextView tv_order_info_app_refund;
    private TextView tv_order_info_not_buy, tv_order_info_start_pay;
    private LinearLayout ll_pay_status;
    private TextView tv_order_info_status_not_send;

    private String mOrderNo;
    private static final String ORDER_NO = "order_no";

    private SelectPaymentDialog mSelectPaymentDialog;
    private OrderInfoBean mOrderInfo;

    public static OrderInfoStatusFrag newInstance(String orderNo) {

        Bundle args = new Bundle();
        args.putString(ORDER_NO, orderNo);
        OrderInfoStatusFrag fragment = new OrderInfoStatusFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Bundle arguments = getArguments();
        if (arguments != null) {
            mOrderNo = arguments.getString(ORDER_NO);
        }
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    public OrderInfoStatusPre createPresenter() {
        return new OrderInfoStatusPre(mFragmentActivity, mOrderNo);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getOrderInfo();
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_order_status;
    }

    @Override
    public void initView() {
        super.initView();

        tv_order_info_status_name = findViewById(R.id.tv_order_info_status_name);
        tv_order_info_count_down = findViewById(R.id.tv_order_info_count_down);
        tv_order_info_tip = findViewById(R.id.tv_order_info_tip);

        tv_order_info_logistics_val = findViewById(R.id.tv_order_info_logistics_val);
        tv_order_logistics_time = findViewById(R.id.tv_order_logistics_time);

        cl_order_info_address_info = findViewById(R.id.cl_order_info_address_info);
        tv_order_info_consignee = findViewById(R.id.tv_order_info_consignee);
        tv_order_info_consignee_phone = findViewById(R.id.tv_order_info_consignee_phone);
        tv_order_info_consignee_address = findViewById(R.id.tv_order_info_consignee_address);

        iv_order_info_goods_img = findViewById(R.id.iv_order_info_goods_img);
        tv_order_info_goods_name = findViewById(R.id.tv_order_info_goods_name);
        tv_goods_num = findViewById(R.id.tv_goods_num);
        tv_order_info_goods_specification = findViewById(R.id.tv_order_info_goods_specification);
        tv_order_info_goods_price = findViewById(R.id.tv_order_info_goods_price);

        tv_order_info_price = findViewById(R.id.tv_order_info_price);
        tv_order_no = findViewById(R.id.tv_order_no);
        tv_order_create_date = findViewById(R.id.tv_order_create_date);
        tv_order_payment_type = findViewById(R.id.tv_order_payment_type);

        tv_order_info_app_refund = findViewById(R.id.tv_order_info_app_refund);
        tv_order_info_status_not_send = findViewById(R.id.tv_order_info_status_not_send);

        ll_pay_status = findViewById(R.id.ll_pay_status);
        tv_order_info_not_buy = findViewById(R.id.tv_order_info_not_buy);
        tv_order_info_start_pay = findViewById(R.id.tv_order_info_start_pay);

        cl_order_info_address_info.setOnClickListener(this);
        tv_order_info_app_refund.setOnClickListener(this);
        tv_order_info_not_buy.setOnClickListener(this);
        tv_order_info_start_pay.setOnClickListener(this);
    }

    @Override
    public void onOrderInfoResult(OrderInfoBean orderInfo) {
        try {
            mOrderInfo = orderInfo;

            int payStatus = orderInfo.getOrderStatusId();
            tv_order_info_count_down.setVisibility(View.GONE);
            tv_order_info_tip.setVisibility(View.GONE);
            tv_order_info_status_name.setText(orderStatus(payStatus));

            tv_order_info_consignee.setText(String.format(getString(R.string.txt_consignee), orderInfo.getUserName()));
            tv_order_info_consignee_phone.setText(orderInfo.getUserTel());
            tv_order_info_consignee_address.setText(String.format(getString(R.string.txt_consignee_address), orderInfo.getUserDetailAddr()));

            GlideRequest<Drawable> Original = GlideApp.with(this).asDrawable().optionalCenterCrop();
            GlideRequest<Drawable> thumbnail = GlideApp.with(this).asDrawable().optionalCenterCrop();

            Original.load(orderInfo.getProductPicOriginalAddr())
                    .thumbnail(thumbnail.load(orderInfo.getProductPicCompressionAddr()))
                    .into(iv_order_info_goods_img);
            tv_order_info_goods_name.setText(orderInfo.getProductName());
            tv_goods_num.setText("x" + orderInfo.getProductCount());
            tv_order_info_goods_specification.setText(orderInfo.getDescription());
            tv_order_info_goods_price.setText(String.format(getString(R.string.txt_rmb), "" + orderInfo.getProductDiscountPrice()));
            tv_order_info_price.setText(String.valueOf(orderInfo.getTotalPrice()));
            tv_order_no.setText("订单号：" + orderInfo.getOrderNo());
            String payType = "支付方式：" + (orderInfo.getOrderPayId() == 1 ? "微信" : "支付宝");
            tv_order_payment_type.setText(payType);
            String orderDate = orderInfo.getOrderDate();
            tv_order_create_date.setText("创建时间：" + orderDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private String orderStatus(int orderStatus) {
        ll_pay_status.setVisibility(View.GONE);
        tv_order_info_app_refund.setVisibility(View.GONE);
        switch (orderStatus) {
            case 1:
                ll_pay_status.setVisibility(View.VISIBLE);
                tv_order_info_app_refund.setVisibility(View.GONE);
                return "待付款";
            case 2:
                ll_pay_status.setVisibility(View.GONE);
                tv_order_info_app_refund.setVisibility(View.VISIBLE);
                return "支付成功";
            case 3:
                ll_pay_status.setVisibility(View.GONE);
                tv_order_info_app_refund.setVisibility(View.VISIBLE);
                cl_order_info_address_info.setVisibility(View.GONE);
                tv_order_info_status_not_send.setVisibility(View.VISIBLE);
                return "待发货";
            case 4:
                ll_pay_status.setVisibility(View.GONE);
                tv_order_info_app_refund.setVisibility(View.VISIBLE);
                tv_order_info_app_refund.setTag(orderStatus);
                tv_order_info_app_refund.setBackgroundColor(ContextCompat.getColor(mFragmentActivity, R.color.colorF2F2F2));
                return "已发货";
            case 6:
            case 7:
                tv_order_info_status_not_send.setVisibility(View.GONE);
                return "退款申请中";
            case 8:
                return "同意退款";
            case 9:
                return "已完成";
            default:
                return "";
        }
    }

    @Override
    public void onLogisticsInfo(OrderLogisticsInfoResultBean logisticsInfo) {
        try {
            if (logisticsInfo.getObject() == null) return;
            cl_order_info_address_info.setVisibility(View.VISIBLE);
            List<OrderLogisticsInfoBean> list = logisticsInfo.getObject().getList();
            OrderLogisticsInfoBean orderLogisticsInfo = list.get(list.size() - 1);
            tv_order_info_logistics_val.setText(orderLogisticsInfo.getRemark());
            tv_order_logistics_time.setText(orderLogisticsInfo.getDatetime());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.cl_order_info_address_info:
                intent = new Intent(mFragmentActivity, OrderInfoAct.class);
                intent.putExtra(OrderInfoAct.ORDER_NO, mOrderNo);
                intent.putExtra(OrderInfoAct.LOAD_PAGE, OrderInfoAct.ORDER_LOGISTICS);
                startActivity(intent);
                break;
            case R.id.tv_order_info_app_refund://申请退款:
                Object tag = tv_order_info_app_refund.getTag();
                if (tag != null && tag.equals(4)) {
                    ToastUtils.showToast(mFragmentActivity, "商品正在运输中，不能申请退款哦~");
                } else {
                    ApplyRefundDialog dialog = new ApplyRefundDialog();
                    dialog.setOnRefundContent(this);
                    dialog.show(getChildFragmentManager(), dialog.getClass().getName());
                }
                break;
            case R.id.tv_order_info_not_buy://取消订单
                new AlertDialog.Builder(mFragmentActivity)
                        .setPositiveButton(R.string.button_sure, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(@NonNull DialogInterface dialog, int which) {
                                getPresenter().setCancelOrder();
                            }
                        })
                        .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(@NonNull DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        })
                        .setCancelable(false)
                        .setMessage("是否确认不支付此订单？")
                        .show();
                break;
            case R.id.tv_order_info_start_pay:
                if (mOrderInfo == null) return;
                if (mSelectPaymentDialog == null) {
                    mSelectPaymentDialog = SelectPaymentDialog.newInstance(String.valueOf(mOrderInfo.getTotalPrice()));
                    mSelectPaymentDialog.setOnStartPay(this);
                }
                mSelectPaymentDialog.show(getChildFragmentManager(), mSelectPaymentDialog.getClass().getName());
                break;
        }
    }

    @Override
    public void startPay(boolean mSelectPayment) {
        try {
            if (mOrderInfo == null) return;
            getPresenter().startPay(mOrderInfo.getOrderNo(),
                    mOrderInfo.getProductId(), mOrderInfo.getProductCount(),
                    mSelectPayment ? 1 : 2, mOrderInfo.getProductName(),
                    mOrderInfo.getAddrId(), mOrderInfo.getDescription());
            if (mSelectPaymentDialog != null) {
                mSelectPaymentDialog.dismiss();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @Override
    public void onAliPaySuccess() {
        ToastUtils.showToast(mFragmentActivity, "支付成功");
        if (mOrderInfo == null) return;
        Intent intent = new Intent(mFragmentActivity, OrderInfoAct.class);
        intent.putExtra(OrderInfoAct.PAY_PRICE, String.valueOf(mOrderInfo.getTotalPrice()));
        intent.putExtra(OrderInfoAct.ORDER_NO, mOrderNo);
        intent.putExtra(OrderInfoAct.LOAD_PAGE, OrderInfoAct.PAY_SUCCESS);
        startActivityForResult(intent, 0x01);
        mFragmentActivity.finish();
    }

    @Override
    public void onOrderNoResult(String orderNo) {
        mOrderNo = orderNo;
    }

    @Override
    public void onCancelResult(ResultMsgBean result) {
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        ll_pay_status.setVisibility(View.GONE);
        tv_order_info_status_not_send.setVisibility(View.VISIBLE);
        tv_order_info_status_not_send.setEnabled(false);
        tv_order_info_status_not_send.setText("订单已失效");
        mFragmentActivity.setResult(RESULT_OK);
        mFragmentActivity.finish();
    }

    @Override
    public void onRefundResult(ResultMsgBean result) {
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        mFragmentActivity.setResult(RESULT_OK);
        getPresenter().getOrderInfo();
    }

    @Override
    public void onContent(String content) {
        getPresenter().applyRefund(content);
    }

    @Subscribe
    public void payResult(BaseResp resp) {
        if (resp.errCode == 0) {
            onAliPaySuccess();
        } else {
            ToastUtils.showToast(mFragmentActivity, "支付失败");
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/address/AddressManagerAct.java<|end_filename|>
package com.scj.beilu.app.ui.mine.address;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.LinearLayout;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.address.AddressManagerPre;
import com.scj.beilu.app.mvp.mine.address.bean.AddressInfoBean;
import com.scj.beilu.app.ui.mine.adapter.AddressManagerAdapter;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/1/18 15:48
 * 地址列表
 */
public class AddressManagerAct extends BaseMvpActivity<AddressManagerPre.AddressManagerView,
        AddressManagerPre> implements AddressManagerPre.AddressManagerView, OnItemClickListener {
    private List<AddressInfoBean> mAddressList;
    private RecyclerView mRvAddressList;
    private AddressManagerAdapter mAddressManagerAdapter;
    private LinearLayout mLlEmpty;
    private Toolbar mToolbar;
    public static final int UPDATE_REQUEST_CODE = 0x001;
    public static final int ADD_REQUEST_CODE = 0x002;
    public static final String EXTRA_ADDRESS_INFO = "address_info";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayout() {
        return R.layout.act_address_manager;
    }

    @Override
    public void initView() {
        super.initView();
        mToolbar = findViewById(R.id.toolbar);
        mLlEmpty = findViewById(R.id.il_empty);
        mRvAddressList = findViewById(R.id.rv_address_list);
        mRvAddressList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
        mAddressManagerAdapter = new AddressManagerAdapter();
        mRvAddressList.setAdapter(mAddressManagerAdapter);
        getPresenter().getAllAddress();

        mToolbar.setOnMenuItemClickListener(item -> {
            Intent intent = new Intent(AddressManagerAct.this, AddressAddAct.class);
            startActivityForResult(intent, ADD_REQUEST_CODE);
            return false;
        });
        mAddressManagerAdapter.setOnItemClickListener(this);
    }

    @NonNull
    @Override
    public AddressManagerPre createPresenter() {
        return new AddressManagerPre(this);
    }


    @Override
    public void onAllAddressInfoResult(List<AddressInfoBean> addressList) {
        mAddressManagerAdapter.setAddressList(addressList);
        mAddressList = addressList;
        //列表有无数据
        if (mAddressList.size() == 0) {
            mRvAddressList.setVisibility(View.GONE);
            mLlEmpty.setVisibility(View.VISIBLE);
        } else {
            mRvAddressList.setVisibility(View.VISIBLE);
            mLlEmpty.setVisibility(View.GONE);
        }
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        AddressInfoBean userAddressBean = mAddressList.get(position);
        switch (view.getId()) {
            case R.id.tv_edit:
                Intent intent = new Intent(AddressManagerAct.this, AddressUpdateAct.class);
                intent.putExtra(EXTRA_ADDRESS_INFO, userAddressBean);
                startActivityForResult(intent, UPDATE_REQUEST_CODE);
                break;
            case R.id.address_item_content:
                Intent data = getIntent();
                if (data == null) return;
                if (data.getStringExtra("address") == null) return;
                data.putExtra(EXTRA_ADDRESS_INFO, userAddressBean);
                setResult(RESULT_OK, data);
                finish();
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if ((resultCode == RESULT_OK) && (requestCode == UPDATE_REQUEST_CODE) && (data != null)) {
            getPresenter().getAllAddress();
        } else if ((resultCode == RESULT_OK) && (requestCode == ADD_REQUEST_CODE) && (data != null)) {
            getPresenter().getAllAddress();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/adapter/MerchantInfoDetailListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.merchant.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoDetailsListBean;
import com.scj.beilu.app.ui.merchant.MerchantDetailFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/15 17:15
 */
public class MerchantInfoDetailListAdapter extends RecyclerView.Adapter {

    private List<MerchantInfoDetailsListBean> mDetailsList;

    public static final int TYPE_COACH = 0x001;
    public static final int TYPE_SHIP = 0x002;
    private final int TYPE_BASE = 0x003;
    public static final int TYPE_FACILITY = 0x004;
    private MerchantDetailFrag mDetailFrag;
    private OnItemClickListener mOnItemClickListener;

    public MerchantInfoDetailListAdapter(MerchantDetailFrag frag) {
        mDetailFrag = frag;
    }

    public void setDetailsList(List<MerchantInfoDetailsListBean> detailsList) {
        mDetailsList = detailsList;
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @Override
    public int getItemCount() {
        return mDetailsList == null ? 0 : mDetailsList.size();
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view;
        if (viewType == TYPE_BASE) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_merchant_info_base_content, parent, false);
            return new MerchantInfoBaseInfoViewHolder(view);
        } else {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_merchant_info_content, parent, false);
            return new MerchantInfoContentViewHolder(mDetailFrag, view, viewType, mOnItemClickListener);
        }
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        MerchantInfoDetailsListBean details = mDetailsList.get(position);
        if (holder instanceof MerchantInfoBaseInfoViewHolder) {
            MerchantInfoBaseInfoViewHolder baseInfoViewHolder = (MerchantInfoBaseInfoViewHolder) holder;
            try {
                baseInfoViewHolder.mTvName1.setText("开店：" + details.getStartTime());
                baseInfoViewHolder.mTvName2.setText("关店：" + details.getEndTime());
                baseInfoViewHolder.mTvName3.setText("开业：" + details.getStartBusinessTime());
                baseInfoViewHolder.mTvName4.setText("装修：" + details.getFitmentTime());
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (holder instanceof MerchantInfoContentViewHolder) {
            MerchantInfoContentViewHolder contentInfoViewHolder = (MerchantInfoContentViewHolder) holder;

            try {
                contentInfoViewHolder.onBindData(details, getItemViewType(position));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public int getItemViewType(int position) {
        if (mDetailsList.get(position).getCoachList() != null) {
            return TYPE_COACH;
        } else if (mDetailsList.get(position).getMemberShipList() != null) {
            return TYPE_SHIP;
        } else if (mDetailsList.get(position).getInstallList() != null) {
            return TYPE_FACILITY;
        } else {
            return TYPE_BASE;
        }
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/HomeGoodsAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/13
 * descriptin:
 */
public class HomeGoodsAdapter extends RecyclerView.Adapter<HomeGoodsAdapter.HomeGoodsViewHolder> {
    @NonNull
    @Override
    public HomeGoodsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_goods, parent, false);
        return new HomeGoodsViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull HomeGoodsViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 5;
    }

    class HomeGoodsViewHolder extends BaseViewHolder {

        public HomeGoodsViewHolder(View itemView) {
            super(itemView);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/preview/adapter/AddedPreviewPagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.preview.adapter;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.scj.beilu.app.ui.preview.AddedPreviewItemFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/20 18:05
 */
public class AddedPreviewPagerAdapter extends FragmentStatePagerAdapter {

    private List<Uri> mImagePathList;


    public AddedPreviewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setImagePathList(List<Uri> imagePathList) {
        mImagePathList = imagePathList;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return AddedPreviewItemFrag.newInstance(mImagePathList.get(position));
    }

    public void remove(int position) {
        mImagePathList.remove(position);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mImagePathList == null ? 0 : mImagePathList.size();
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return POSITION_NONE;
    }

}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/album/internal/entity/IncapableCause.java<|end_filename|>
package com.mx.pro.lib.album.internal.entity;

import android.content.Context;
import android.support.annotation.IntDef;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;

import com.mx.pro.lib.album.internal.ui.widget.IncapableDialog;

import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.SOURCE;

@SuppressWarnings("unused")
public class IncapableCause {
    public static final int TOAST = 0x00;
    public static final int DIALOG = 0x01;
    public static final int NONE = 0x02;

    @Retention(SOURCE)
    @IntDef({TOAST, DIALOG, NONE})
    public @interface Form {
    }

    private int mForm = TOAST;
    private String mTitle;
    private String mMessage;

    public IncapableCause(String message) {
        mMessage = message;
    }

    public IncapableCause(String title, String message) {
        mTitle = title;
        mMessage = message;
    }

    public IncapableCause(@Form int form, String message) {
        mForm = form;
        mMessage = message;
    }

    public IncapableCause(@Form int form, String title, String message) {
        mForm = form;
        mTitle = title;
        mMessage = message;
    }

    public static void handleCause(Context context, IncapableCause cause) {
        if (cause == null)
            return;

        switch (cause.mForm) {
            case NONE:
                // do nothing.
                break;
            case DIALOG:
                IncapableDialog incapableDialog = IncapableDialog.newInstance(cause.mTitle, cause.mMessage);
                incapableDialog.show(((FragmentActivity) context).getSupportFragmentManager(),
                        IncapableDialog.class.getName());
                break;
            case TOAST:
            default:
                Toast.makeText(context, cause.mMessage, Toast.LENGTH_SHORT).show();
                break;
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/store/adapter/ShoppingCartListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.store.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.store.entity.GoodsShoppingCarInfoBean;
import com.scj.beilu.app.ui.store.ShoppingCarFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/1 17:24
 */
public class ShoppingCartListAdapter extends RecyclerView.Adapter<ShoppingCartListViewHolder> {
    private OnItemClickListener<GoodsShoppingCarInfoBean> mOnItemClickListener;
    private ShoppingCarFrag mShoppingCarFrag;
    private List<GoodsShoppingCarInfoBean> mCarInfoBeanList;

    public ShoppingCartListAdapter(ShoppingCarFrag shoppingCarFrag) {
        mShoppingCarFrag = shoppingCarFrag;
    }

    public void setOnItemClickListener(OnItemClickListener<GoodsShoppingCarInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setCarInfoBeanList(List<GoodsShoppingCarInfoBean> carInfoBeanList) {
        mCarInfoBeanList = carInfoBeanList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ShoppingCartListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_shopping_cart_content, parent, false);
        return new ShoppingCartListViewHolder(view, mShoppingCarFrag, mOnItemClickListener);
    }

    @Override
    public void onBindViewHolder(@NonNull ShoppingCartListViewHolder holder, int position) {
        GoodsShoppingCarInfoBean carInfoBean = mCarInfoBeanList.get(position);
        holder.bindData(carInfoBean);
    }

    @Override
    public int getItemCount() {
        return mCarInfoBeanList == null ? 0 : mCarInfoBeanList.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/adapter/MsgReplyListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.mine.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.message.bean.MsgReplyInfoBean;
import com.scj.beilu.app.ui.mine.MineMsgFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/9 20:55
 */
public class MsgReplyListAdapter extends RecyclerView.Adapter<MsgReplyListAdapter.ReplyViewHolder> {
    private List<MsgReplyInfoBean> mMsgReplyInfoBeans;
    private GlideRequest<Drawable> mOriginal;
    private GlideRequest<Drawable> mThumbnail;
    private OnItemClickListener mOnItemClickListener;
    private final String mTipContent;

    public MsgReplyListAdapter(MineMsgFrag frag) {
        mOriginal = GlideApp.with(frag).asDrawable().circleCrop();
        mThumbnail = GlideApp.with(frag).asDrawable().circleCrop();
        mTipContent = frag.getString(R.string.txt_item_reply_content);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setMsgReplyInfoBeans(List<MsgReplyInfoBean> msgReplyInfoBeans) {
        mMsgReplyInfoBeans = msgReplyInfoBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ReplyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_msg_reply_content, parent, false);
        return new ReplyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ReplyViewHolder holder, int position) {
        try {
            MsgReplyInfoBean msgReplyInfoBean = mMsgReplyInfoBeans.get(position);
            mOriginal.load(msgReplyInfoBean.getUserHead())
                    .thumbnail(mThumbnail.load(msgReplyInfoBean.getUserHeadZip()))
                    .into(holder.mIvHeader);
            holder.mTvUserName.setText(msgReplyInfoBean.getUserName());
            holder.mTvTip.setText(String.format(mTipContent, msgReplyInfoBean.getReplyContent(), msgReplyInfoBean.mFormatDate));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mMsgReplyInfoBeans == null ? 0 : mMsgReplyInfoBeans.size();
    }

    public class ReplyViewHolder extends BaseViewHolder {
        private ImageView mIvHeader;
        private TextView mTvUserName;
        private TextView mTvTip;

        public ReplyViewHolder(View itemView) {
            super(itemView);
            mIvHeader = findViewById(R.id.iv_comment_header);
            mTvUserName = findViewById(R.id.tv_comment_user_name);
            mTvTip = findViewById(R.id.tv_reply_tip);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), mMsgReplyInfoBeans.get(getAdapterPosition()), v);
                    }
                }
            });
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/MyApplication.java<|end_filename|>
package com.scj.beilu.app;

import android.content.Context;
import android.util.Log;

import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.mx.pro.lib.LibApplication;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.scj.beilu.app.dao.DaoMaster;
import com.scj.beilu.app.dao.DaoSession;
import com.scj.beilu.app.helper.MySQLiteOpenHelper;
import com.tencent.smtt.sdk.QbSdk;


/**
 * @author Mingxun
 * @time on 2018/12/21 15:09
 */
public class MyApplication extends LibApplication {

    private DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        Logger.addLogAdapter(new AndroidLogAdapter());

        initDao();

        initCloudChannel(this);

        //在使用SDK各组件之前初始化context信息，传入ApplicationContext
        SDKInitializer.initialize(this);
        //自4.3.0起，百度地图SDK所有接口均支持百度坐标和国测局坐标，用此方法设置您使用的坐标类型.
        //包括BD09LL和GCJ02两种坐标，默认是BD09LL坐标。
        SDKInitializer.setCoordType(CoordType.BD09LL);

        initTBS();
    }

    private void initDao() {
        MySQLiteOpenHelper helper = new MySQLiteOpenHelper(this, "beilu_db", null);
        daoSession = new DaoMaster(helper.getWritableDatabase()).newSession();
        helper.onUpgrade(helper.getWritableDatabase(), 1, 7);
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }

    /**
     * 初始化云推送通道
     *
     * @param applicationContext
     */
    private void initCloudChannel(final Context applicationContext) {
        PushServiceFactory.init(applicationContext);
        PushServiceFactory.getCloudPushService().setDebug(true);
        final CloudPushService pushService = PushServiceFactory.getCloudPushService();
        pushService.register(applicationContext, new CommonCallback() {
            @Override
            public void onSuccess(String response) {

            }

            @Override
            public void onFailed(String errorCode, String errorMessage) {
            }
        });

    }

    private void initTBS() {
        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

            @Override
            public void onViewInitFinished(boolean arg0) {
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.d("app", " onViewInitFinished is " + arg0);
            }

            @Override
            public void onCoreInitFinished() {
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(), cb);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/common/pay/GoodsPayPre.java<|end_filename|>
package com.scj.beilu.app.mvp.common.pay;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.common.pay.bean.AliPayInfoResultBean;
import com.scj.beilu.app.mvp.common.pay.bean.PayResult;
import com.scj.beilu.app.mvp.common.pay.bean.WeChatPayResultBean;
import com.scj.beilu.app.mvp.common.pay.model.PayInfoImpl;
import com.scj.beilu.app.util.ToastUtils;

import java.util.Map;

import static com.scj.beilu.app.mvp.common.pay.model.PayInfoImpl.SDK_PAY_FLAG;

/**
 * @author Mingxun
 * @time on 2019/4/9 12:38
 */
public class GoodsPayPre<View extends GoodsPayView> extends BaseMvpPresenter<View> {

    private PayInfoImpl mPayInfo;
    private Activity mActivity;

    public GoodsPayPre(Activity activity) {
        super(activity, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mActivity = activity;
        mPayInfo = new PayInfoImpl(mBuilder);
    }

    public void startPay(final int productId, final int productCount, final int orderPayId, final String productName,
                         final int addrId, final String description) {
        startPay(null, productId, productCount, orderPayId, productName, addrId, description);
    }


    public void startPay(final String orderNo, final int productId, final int productCount, final int orderPayId, final String productName,
                         final int addrId, final String description) {
        mBuilder.setLoadType(ShowConfig.LOADING_DIALOG);
        onceViewAttached(new ViewAction<View>() {
            @Override
            public void run(@NonNull final View mvpView) {
                mPayInfo.startGoodsPay(orderNo, productId, productCount, orderPayId, productName, addrId, description)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                if (resultMsgBean instanceof AliPayInfoResultBean) {
                                    try {
                                        AliPayInfoResultBean aliPayInfo = (AliPayInfoResultBean) resultMsgBean;
                                        mvpView.onOrderNoResult(aliPayInfo.getOut_trade_no());
                                        mPayInfo.setAliPay(mActivity, aliPayInfo, mHandler);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                } else if (resultMsgBean instanceof WeChatPayResultBean) {
                                    try {
                                        WeChatPayResultBean wxPayInfo = (WeChatPayResultBean) resultMsgBean;
                                        mvpView.onOrderNoResult(wxPayInfo.getOut_trade_no());
                                        mPayInfo.setWxPayInfo(wxPayInfo);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        });
            }
        });
    }


    @SuppressLint("HandlerLeak")
    private final Handler mHandler = new Handler() {
        @SuppressWarnings("unused")
        public void handleMessage(final Message msg) {
            switch (msg.what) {
                case SDK_PAY_FLAG: {
                    onceViewAttached(new ViewAction<View>() {
                        @Override
                        public void run(@NonNull View mvpView) {
                            @SuppressWarnings("unchecked")
                            PayResult payResult = new PayResult((Map<String, String>) msg.obj);
                            /**
                             * 对于支付结果，请商户依赖服务端的异步通知结果。同步通知结果，仅作为支付结束的通知。
                             */
                            String resultInfo = payResult.getResult();// 同步返回需要验证的信息
                            String resultStatus = payResult.getResultStatus();
                            // 判断resultStatus 为9000则代表支付成功
                            if (TextUtils.equals(resultStatus, "9000")) {
                                // 该笔订单是否真实支付成功，需要依赖服务端的异步通知。
                                mvpView.onAliPaySuccess();
                            } else {
                                // 该笔订单真实的支付结果，需要依赖服务端的异步通知。
                                ToastUtils.showToast(mActivity, "支付失败");
                            }
                        }
                    });
                    break;
                }

                default:
                    break;
            }
        }
    };
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/preview/adapter/PicPreviewPagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.preview.adapter;

import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.scj.beilu.app.mvp.common.bean.PicPreviewBean;
import com.scj.beilu.app.ui.preview.PicPreviewItemFrag;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/2/20 18:05
 */
public class PicPreviewPagerAdapter extends FragmentStatePagerAdapter {

    private ArrayList<PicPreviewBean> mImagePathList;

    public PicPreviewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void setImagePathList(ArrayList<PicPreviewBean> imagePathList) {
        mImagePathList = imagePathList;
        notifyDataSetChanged();
    }

    @Override
    public Fragment getItem(int position) {
        return PicPreviewItemFrag.newInstance(mImagePathList.get(position));
    }


    @Override
    public int getCount() {
        return mImagePathList == null ? 0 : mImagePathList.size();
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return POSITION_NONE;
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/HomeFrag.java<|end_filename|>
package com.scj.beilu.app.ui.home;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.mx.pro.lib.banner.Banner;
import com.mx.pro.lib.banner.loader.ImageLoader;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.banner.GlideImageLoader;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.common.bean.BannerInfoBean;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.course.bean.CourseInfoBean;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.ModifyRecordBean;
import com.scj.beilu.app.mvp.home.HomePre;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.ui.act.FitRecordAct;
import com.scj.beilu.app.ui.act.MsgManagerAct;
import com.scj.beilu.app.ui.action.ActionInfoAct;
import com.scj.beilu.app.ui.course.CourseInfoAct;
import com.scj.beilu.app.ui.find.FindDetailsAct;
import com.scj.beilu.app.ui.find.FindDetailsFrag;
import com.scj.beilu.app.ui.find.adapter.FindInfoListAdapter;
import com.scj.beilu.app.ui.home.adapter.HomeButtonAdapter;
import com.scj.beilu.app.ui.home.adapter.HomeCourseListAdapter;
import com.scj.beilu.app.ui.home.adapter.HomeGoodsListAdapter;
import com.scj.beilu.app.ui.merchant.MerchantAct;
import com.scj.beilu.app.ui.news.NewsDetailsAct;
import com.scj.beilu.app.ui.news.adapter.NewsListAdapter;
import com.scj.beilu.app.ui.preview.PicImagePreviewAct;
import com.scj.beilu.app.ui.store.StoreInfoAct;
import com.scj.beilu.app.ui.user.UserInfoHomePageAct;
import com.scj.beilu.app.util.ToastUtils;
import com.scj.beilu.app.widget.DividerItemDecorationToPadding;
import com.scj.beilu.app.widget.FindDivider;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;
import java.util.List;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

/**
 * date:2019/2/13
 * descriptin:首页
 */
@RuntimePermissions
public class HomeFrag extends BaseMvpFragment<HomePre.HomeView, HomePre>
        implements HomePre.HomeView, View.OnClickListener, OnItemClickListener,
        OnGroupItemClickListener<ArrayList<FindImageBean>> {

    private Banner mBanner;
    private RecyclerView mRvButton;
    private TextView mTvCity;
    private ImageButton mIbtnMessage;
    private TextView mTvMoreCourse, mTvMoreGoods, mTvMoreNews, mTvMoreFind;
    private RecyclerView mRvCourse, mRvGoods, mRvNews, mRvFind;
    private FrameLayout mFlSearch;
    private LinearLayout ll_content;

    private HomeCourseListAdapter mHomeCourseListAdapter;
    private HomeGoodsListAdapter mHomeGoodsListAdapter;
    private NewsListAdapter mHomeNewsListAdapter;
    private FindInfoListAdapter mHomeFindInfoListAdapter;

    private int mRecordPosition = -1;
    private static final int REQUEST_FIND_DETAILS_CODE = 0x001;
    private int mDynamicIdByIndex = -1;
    private onChangeBottomListener mOnChangeBottomListener;

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        HomeFragPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

    @NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE})
    void needsPermission() {
        getPresenter().getHomePageList();
        initLocationInfo();
    }

    @OnShowRationale({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.READ_PHONE_STATE})
    void onShowRationale(final PermissionRequest request) {
        request.proceed();
    }


    public interface onChangeBottomListener {
        void onBottomNavIndex(@IdRes int itemId);
    }

    private LocationClient mLocationClient = null;
    private LocationClientOption mLocationClientOption;

    private void initLocationInfo() {
        mLocationClient = new LocationClient(mFragmentActivity);
        mLocationClientOption = new LocationClientOption();
        mLocationClientOption.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);//可选，默认高精度，设置定位模式，高精度，低功耗，仅设备
        mLocationClientOption.setCoorType("bd09ll");//可选，默认gcj02，设置返回的定位结果坐标系，如果配合百度地图使用，建议设置为bd09ll;
        mLocationClientOption.setScanSpan(3000);//可选，默认0，即仅定位一次，设置发起连续定位请求的间隔需要大于等于1000ms才是有效的
        mLocationClientOption.setIsNeedAddress(true);//可选，设置是否需要地址信息，默认不需要

        synchronized (this) {
            if (mLocationClient != null && mLocationClient.isStarted()) {
                mLocationClient.stop();
            }
        }
        mLocationClient.start();// 定位SDK
        mLocationClient.registerLocationListener(mListener);

        if (mLocationClient.isStarted())
            mLocationClient.stop();
        mLocationClient.setLocOption(mLocationClientOption);
    }


    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof onChangeBottomListener) {
            mOnChangeBottomListener = (onChangeBottomListener) activity;
        }
    }

    @Override
    public HomePre createPresenter() {
        return new HomePre(mFragmentActivity);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        HomeFragPermissionsDispatcher.needsPermissionWithPermissionCheck(this);
    }

    @Override
    protected void onReLoad() {
        HomeFragPermissionsDispatcher.needsPermissionWithPermissionCheck(this);
    }

    @Override
    public void onSupportVisible() {
        super.onSupportVisible();
        if (mHomeCourseListAdapter != null && mHomeCourseListAdapter.getItemCount() == 0) {
            getPresenter().getHomePageList();
        }
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_home;
    }

    @Override
    public void initView() {
        super.initView();

        mBanner = findViewById(R.id.banner_home);
        mRvButton = findViewById(R.id.rv_home_nav_list);
        mTvCity = findViewById(R.id.tv_city);
        mIbtnMessage = findViewById(R.id.iv_msg);
        mTvMoreCourse = findViewById(R.id.tv_home_page_list_load_more_course);
        mTvMoreGoods = findViewById(R.id.tv_home_page_list_load_more_goods);
        mTvMoreNews = findViewById(R.id.tv_home_page_list_load_more_news);
        mTvMoreFind = findViewById(R.id.tv_home_page_list_load_more_find);
        mRvCourse = findViewById(R.id.rv_home_page_course_content_list);
        mRvGoods = findViewById(R.id.rv_home_page_goods_content_list);
        mRvNews = findViewById(R.id.rv_home_page_news_content_list);
        mRvFind = findViewById(R.id.rv_home_page_find_content_list);
        mFlSearch = findViewById(R.id.fl_search);
        ll_content = findViewById(R.id.ll_content);

        mBanner.setImageLoader(new GlideImageLoader());

        HomeButtonAdapter homeButtonAdapter = new HomeButtonAdapter(GlideApp.with(this));
        homeButtonAdapter.setItemClickListener(this);
        mRvButton.setAdapter(homeButtonAdapter);

        initCourseAdapter();
        initGoodsAdapter();
        initNewsListAdapter();
        initFindInfoAdapter();

        mIbtnMessage.setOnClickListener(this);
        mTvCity.setOnClickListener(this);
        mFlSearch.setOnClickListener(this);
        mTvMoreCourse.setOnClickListener(this);
        mTvMoreGoods.setOnClickListener(this);
        mTvMoreNews.setOnClickListener(this);
        mTvMoreFind.setOnClickListener(this);
    }

    private void initCourseAdapter() {

        LinearLayoutManager layoutManager = new LinearLayoutManager(mFragmentActivity, LinearLayoutManager.HORIZONTAL, false);
        mRvCourse.setLayoutManager(layoutManager);
        DividerItemDecorationToPadding itemDecorationToPadding = new DividerItemDecorationToPadding(mFragmentActivity, DividerItemDecoration.HORIZONTAL);
        itemDecorationToPadding.setDrawable(ContextCompat.getDrawable(mFragmentActivity, R.drawable.item_divider_course_hor));
        mRvCourse.addItemDecoration(itemDecorationToPadding);

        mHomeCourseListAdapter = new HomeCourseListAdapter(this);
        mHomeCourseListAdapter.setOnItemClickListener(this);
        mRvCourse.setAdapter(mHomeCourseListAdapter);
    }

    private void initGoodsAdapter() {

        final int offset = getResources().getDimensionPixelOffset(R.dimen.hor_divider_size_2);
        LinearLayoutManager layoutManager = new LinearLayoutManager(mFragmentActivity, LinearLayoutManager.HORIZONTAL, false);
        mRvGoods.setLayoutManager(layoutManager);
        mRvGoods.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(offset, 0, offset, 0);
            }
        });

        mHomeGoodsListAdapter = new HomeGoodsListAdapter(this);
        mHomeGoodsListAdapter.setItemClickListener(this);
        mRvGoods.setAdapter(mHomeGoodsListAdapter);

    }

    private void initNewsListAdapter() {

        LinearLayoutManager layoutManager = new LinearLayoutManager(mFragmentActivity, LinearLayoutManager.VERTICAL, false);
        mRvNews.setLayoutManager(layoutManager);
        mRvNews.addItemDecoration(new DividerItemDecorationToPadding(mFragmentActivity, DividerItemDecoration.VERTICAL));

        mHomeNewsListAdapter = new NewsListAdapter(mFragmentActivity, GlideApp.with(this));
        mHomeNewsListAdapter.setOnItemClickListener(this);
        mRvNews.setAdapter(mHomeNewsListAdapter);
    }

    private void initFindInfoAdapter() {

        LinearLayoutManager layoutManager = new LinearLayoutManager(mFragmentActivity, LinearLayoutManager.VERTICAL, false);
        mRvFind.setLayoutManager(layoutManager);
        mRvFind.addItemDecoration(new FindDivider(mFragmentActivity, DividerItemDecoration.VERTICAL));
        mRvFind.getItemAnimator().setChangeDuration(0);

        mHomeFindInfoListAdapter = new FindInfoListAdapter(GlideApp.with(this), mFragmentActivity);
        mHomeFindInfoListAdapter.setOnItemClickListener(this);
        mHomeFindInfoListAdapter.setOnGroupItemClickListener(this);
        mRvFind.setAdapter(mHomeFindInfoListAdapter);
    }

    @Override
    public void showError(int errorCode, String throwableContent) {
        super.showError(errorCode, throwableContent);
        if (errorCode == ShowConfig.ERROR_NET) {
            ll_content.setVisibility(View.GONE);
        }
    }

    @Override
    public void onStart() {
        super.onStart();
        if (mBanner != null)
            mBanner.startAutoPlay();
    }

    @Override
    public void onStop() {
        if (mLocationClient != null && mListener != null) {
            mLocationClient.unRegisterLocationListener(mListener);//注销掉监听
            mLocationClient.stop(); //停止定位服务
        }
        super.onStop();
        if (mBanner != null)
            mBanner.stopAutoPlay();
    }

    @Override
    public void onShowContent() {
        if (ll_content.getVisibility() == View.GONE) {
            ll_content.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public void onBannerList(List<BannerInfoBean> images) {
        final GlideRequests mGlideOriginal = GlideApp.with(HomeFrag.this);
        final GlideRequests mGlideThumbnail = GlideApp.with(HomeFrag.this);

        mBanner.setImageLoader(new ImageLoader() {
            @Override
            public void displayImage(Context context, Object path, View imageView) {
                BannerInfoBean bannerPath = (BannerInfoBean) path;
                ImageView image = imageView.findViewById(R.id.banner_image);
                mGlideOriginal
                        .load(bannerPath.getAdverPicAddr())
                        .thumbnail(mGlideThumbnail.load(bannerPath.getAdverPicZip()))
                        .dontAnimate()
                        .into(image);
            }

        });
        mBanner.setImages(images);
        mBanner.start();
    }

    @Override
    public void onCourseList(List<CourseInfoBean> courseInfoList) {
        mHomeCourseListAdapter.setCourseInfoList(courseInfoList);
    }

    @Override
    public void onGoodsList(List<GoodsInfoBean> goodsInfoList) {
        mHomeGoodsListAdapter.setGoodsInfoList(goodsInfoList);
    }

    @Override
    public void onNewsList(List<NewsInfoBean> newsInfoList) {
        mHomeNewsListAdapter.setNewsListEntityList(newsInfoList);
    }

    @Override
    public void onFindInfoList(List<FindInfoBean> findInfoList) {
        mHomeFindInfoListAdapter.setFindInfoList(findInfoList);
    }

    @Override
    public void onModifyResult(String result) {
        if (result != null) {
            ToastUtils.showToast(mFragmentActivity, result);
        }
        mHomeFindInfoListAdapter.notifyItemChanged(mRecordPosition);
        mRecordPosition = -1;
    }

    @Override
    public void onNotifyListChangeResult(String result, int position) {
        if (result != null) {
            ToastUtils.showToast(mFragmentActivity, result);
        }

        if (position != -1) {
            mHomeFindInfoListAdapter.notifyItemChanged(position);
        } else {
            mHomeFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onFindDel() {
        getPresenter().delFind(mDynamicIdByIndex);
    }

    @Override
    public void onShareCountResult() {
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void onFindDelResult(ResultMsgBean result) {
        mHomeFindInfoListAdapter.notifyItemChanged(mRecordPosition);
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        mRecordPosition = -1;
    }

    @Subscribe
    public void onShareResult(BaseResp resp) {
        getPresenter().setFindShareCount(mDynamicIdByIndex);
    }

    @Override
    public void onClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.tv_city:
//                HomeSearchCityAct.startHomeSearchCityAct(mFragmentActivity);
                break;
            case R.id.iv_msg:
                getPresenter().checkUserIsLogin(view.getId());
                break;
            case R.id.tv_home_page_list_load_more_course:
                mOnChangeBottomListener.onBottomNavIndex(R.id.nav_course);
                break;
            case R.id.tv_home_page_list_load_more_goods:
                intent = new Intent(mFragmentActivity, StoreInfoAct.class);
                startActivity(intent);
                break;
            case R.id.tv_home_page_list_load_more_news:
                mOnChangeBottomListener.onBottomNavIndex(R.id.nav_news);
                break;
            case R.id.tv_home_page_list_load_more_find:
                mOnChangeBottomListener.onBottomNavIndex(R.id.nav_find);
                break;
            case R.id.fl_search:
                intent = new Intent(mFragmentActivity, HomeSearchAct.class);
                startActivity(intent);
                break;
        }
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        Intent intent;
        FindInfoBean findBean = null;

        if (entity instanceof FindInfoBean) {
            findBean = (FindInfoBean) entity;
        }

        if (entity == null) {
            switch (position) {
                case 0:
                    intent = new Intent(mFragmentActivity, MerchantAct.class);
                    intent.putExtra(MerchantAct.CITY_NAME, mTvCity.getText().toString());
                    startActivity(intent);
                    break;
                case 1:
                    intent = new Intent(mFragmentActivity, ActionInfoAct.class);
                    startActivity(intent);
                    break;
                case 2:
                    intent = new Intent(mFragmentActivity, StoreInfoAct.class);
                    startActivity(intent);
                    break;
                case 3:
                    getPresenter().checkUserIsLogin(view.getId());
                    break;
            }
            return;
        }

        switch (view.getId()) {

            case R.id.item_news_view_id:
                NewsInfoBean newsInfoBean = null;
                if (entity instanceof NewsInfoBean) {
                    newsInfoBean = (NewsInfoBean) entity;
                }
                if (newsInfoBean == null) break;
                NewsDetailsAct.startNewsDetailsAct(mFragmentActivity, newsInfoBean);
                break;
            case R.id.ll_item_find_praise:
                getPresenter().setLike(findBean.getDynamicId(), position);
                break;
            case R.id.ll_item_find_comment:
            case R.id.tv_item_find_txt:
                mRecordPosition = position;
                GSYVideoManager.releaseAllVideos();
                intent = new Intent(mFragmentActivity, FindDetailsAct.class);
                intent.putExtra(FindDetailsFrag.FIND_ID, findBean.getDynamicId());
                startActivityForResult(intent, REQUEST_FIND_DETAILS_CODE);
                break;
            case R.id.ll_item_find_share:
                if (!EventBus.getDefault().isRegistered(this)) {
                    EventBus.getDefault().register(this);
                }
                mRecordPosition = position;
                mDynamicIdByIndex = findBean.getDynamicId();
                getPresenter().startShareFind(this, findBean);
                break;
            case R.id.tv_item_find_attention:
                getPresenter().setAttentionUser(findBean.getUserId());
                break;
            case R.id.iv_item_find_avatar:
                intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                int userId = findBean.getIsOwn() == 0 ? findBean.getUserId() : -1;
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, userId);
                startActivityForResult(intent, REQUEST_FIND_DETAILS_CODE);
                break;
            case R.id.ll_item_course_content:
                if (entity instanceof CourseInfoBean) {
                    CourseInfoBean info = (CourseInfoBean) entity;
                    intent = new Intent(mFragmentActivity, CourseInfoAct.class);
                    intent.putExtra(CourseInfoAct.EXTRA_COURSE_ID, info.getCourseId());
                    startActivity(intent);
                }
                break;
            case R.id.card_view_goods_info:
                if (entity instanceof GoodsInfoBean) {
                    GoodsInfoBean info = (GoodsInfoBean) entity;
                    intent = new Intent(mFragmentActivity, StoreInfoAct.class);
                    intent.putExtra(StoreInfoAct.PRODUCT_ID, info.getProductId());
                    startActivity(intent);
                }
                break;
            case R.id.iv_item_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, findBean.getDynamicPic(), position);
                break;
        }
    }

    @Override
    public void onItemClick(int groupPosition, int childPosition, ArrayList<FindImageBean> object, View view) {
        switch (view.getId()) {
            case R.id.iv_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, object, childPosition);
                break;
        }
    }

    @Override
    protected void userStartAction(int viewId) {
        Intent intent;
        switch (viewId) {
            case R.id.iv_msg:
                MsgManagerAct.startMsgManagerAct(mFragmentActivity);
                break;
            case R.id.home_nav_button:
                intent = new Intent(mFragmentActivity, FitRecordAct.class);
                startActivity(intent);
                break;
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume(false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }

    @Override
    public boolean onBackPressedSupport() {
        if (GSYVideoManager.backFromWindowFull(mFragmentActivity)) {
            return true;
        }
        return super.onBackPressedSupport();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            GSYVideoManager.onPause();
            mBanner.stopAutoPlay();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == REQUEST_FIND_DETAILS_CODE && resultCode == RESULT_OK && data != null) {
            ModifyRecordBean record = data.getParcelableExtra(FindDetailsFrag.EXTRA_MODIFY_RESULT);
            getPresenter().modifyRecord(record, mRecordPosition);
        }
    }

    /*****
     *
     * 定位结果回调，重写onReceiveLocation方法，可以直接拷贝如下代码到自己工程中修改
     *
     */
    private BDAbstractLocationListener mListener = new BDAbstractLocationListener() {

        @Override
        public void onReceiveLocation(BDLocation location) {

            if (null != location && location.getLocType() != BDLocation.TypeServerError) {

                if (mTvCity != null) {

                    String city = location.getCity().replace("市", "");
                    mTvCity.setText(city);
                }

                if (location.getLocType() == BDLocation.TypeNetWorkException) {
                    ToastUtils.showToast(mFragmentActivity, "网络不同导致定位失败，请检查网络是否通畅");
                } else if (location.getLocType() == BDLocation.TypeCriteriaException) {
                    ToastUtils.showToast(mFragmentActivity, "无法获取有效定位依据，定位失败，请检查运营商网络或者WiFi网络是否正常开启，尝试重新请求定位");
                }
            }
        }

    };
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/action/ActionDetailsFrag.java<|end_filename|>
package com.scj.beilu.app.ui.action;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.scj.beilu.app.R;
import com.scj.beilu.app.mvp.action.bean.ActionInfoBean;
import com.scj.beilu.app.ui.action.adapter.ActionDetailsContentPagerAdapter;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/3/18 21:12
 */
public class ActionDetailsFrag extends SupportFragment implements ViewPager.OnPageChangeListener, View.OnClickListener {

    private ViewPager mViewPager;
    private TextView mTvPreviousPage, mTvNextPage;
    private TextView mTvCurrentPage, mTvTotalPage;

    private static final String EXTRA_ACTION_LIST = "action_list";
    private static final String EXTRA_ACTION_POSITION = "action_position";

    private ActionDetailsContentPagerAdapter mActionDetailsContentPagerAdapter;
    private ArrayList<ActionInfoBean> mActionInfoList;
    private int mPosition;
    private int mTotalSize;

    public static ActionDetailsFrag newInstance(ArrayList<ActionInfoBean> actionList, int positoin) {

        Bundle args = new Bundle();
        args.putParcelableArrayList(EXTRA_ACTION_LIST, actionList);
        args.putInt(EXTRA_ACTION_POSITION, positoin);
        ActionDetailsFrag fragment = new ActionDetailsFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mActionInfoList = arguments.getParcelableArrayList(EXTRA_ACTION_LIST);
            mTotalSize = mActionInfoList.size();
            mPosition = arguments.getInt(EXTRA_ACTION_POSITION);
        }
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_action_details_viewpager;
    }

    @Override
    public void initView() {
        super.initView();
        mViewPager = findViewById(R.id.action_view_pager);
        mTvPreviousPage = findViewById(R.id.tv_previous_page);
        mTvNextPage = findViewById(R.id.tv_next_page);
        mTvCurrentPage = findViewById(R.id.tv_current_page);
        mTvTotalPage = findViewById(R.id.tv_total_page);

        mActionDetailsContentPagerAdapter = new ActionDetailsContentPagerAdapter(getChildFragmentManager());
        mActionDetailsContentPagerAdapter.setActionSortInfoBeans(mActionInfoList);
        mViewPager.setAdapter(mActionDetailsContentPagerAdapter);

        mViewPager.addOnPageChangeListener(this);
        mViewPager.setCurrentItem(mPosition, false);

        setPage(mPosition);
        mTvPreviousPage.setOnClickListener(this);
        mTvNextPage.setOnClickListener(this);
        mViewPager.setOffscreenPageLimit(mTotalSize);
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        setPage(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    private void setPage(int position) {
        int positionSize = position + 1;
        mTvCurrentPage.setText(String.valueOf(positionSize));
        mTvTotalPage.setText("/" + mTotalSize);

        if (mTotalSize == 1) {//有且只有1页
            mTvPreviousPage.setVisibility(View.INVISIBLE);
            mTvNextPage.setVisibility(View.INVISIBLE);
        } else if (mTotalSize == positionSize) {//最后一页 并且显示上一页
            mTvNextPage.setVisibility(View.INVISIBLE);
            mTvPreviousPage.setVisibility(View.VISIBLE);
            mTvPreviousPage.setText(mActionInfoList.get(position).getActionName());
        } else if (position == 0) {//第一页 显示下一页
            mTvPreviousPage.setVisibility(View.INVISIBLE);
            if (positionSize < mTotalSize) {//显示下一页
                mTvNextPage.setText(mActionInfoList.get(positionSize).getActionName());
            }
        } else if (position > 0) {//显示上一页 并显示下一页
            mTvPreviousPage.setVisibility(View.VISIBLE);
            mTvNextPage.setVisibility(View.VISIBLE);
            if (positionSize < mTotalSize) {//显示下一页
                mTvNextPage.setText(mActionInfoList.get(positionSize).getActionName());
            }
            mTvPreviousPage.setText(mActionInfoList.get(positionSize - 1).getActionName());
        }
    }

    @Override
    public void onClick(View v) {
        int position = mViewPager.getCurrentItem();
        switch (v.getId()) {
            case R.id.tv_previous_page:
                if (position != 0) position = position - 1;
                mViewPager.setCurrentItem(position, true);
                break;
            case R.id.tv_next_page:
                position += 1;
                if (mTotalSize > position) mViewPager.setCurrentItem(position, true);
                break;
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/adapter/MerchantInfoContentViewHolder.java<|end_filename|>
package com.scj.beilu.app.ui.merchant.adapter;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoDetailsListBean;
import com.scj.beilu.app.ui.merchant.MerchantDetailFrag;

/**
 * @author Mingxun
 * @time on 2019/4/15 19:20
 */
class MerchantInfoContentViewHolder extends BaseViewHolder {

    public TextView mTvGroupName;
    public RecyclerView mRvChildList;

    private MerchantInfoCoachListAdapter mCoachListAdapter;//教练
    private MerchantInfoMemberConsultantListAdapter mMemberConsultantListAdapter;//顾问
    private MerchantInfoFacilityListAdapter mFacilityListAdapter;//设施

    public MerchantInfoContentViewHolder(MerchantDetailFrag frag, View itemView, int viewType, OnItemClickListener onItemClickListener) {
        super(itemView);
        mTvGroupName = findViewById(R.id.tv_merchant_info_group_name);
        mRvChildList = findViewById(R.id.rv_merchant_info_child_list);
        LinearLayoutManager linearLayoutManager;
        switch (viewType) {
            case MerchantInfoDetailListAdapter.TYPE_COACH:
                mCoachListAdapter = new MerchantInfoCoachListAdapter(frag);
                mCoachListAdapter.setOnItemClickListener(onItemClickListener);
                mRvChildList.setAdapter(mCoachListAdapter);
                linearLayoutManager = new LinearLayoutManager(mRvChildList.getContext(), LinearLayoutManager.HORIZONTAL, false);
                mRvChildList.setLayoutManager(linearLayoutManager);
                break;
            case MerchantInfoDetailListAdapter.TYPE_SHIP:
                mMemberConsultantListAdapter = new MerchantInfoMemberConsultantListAdapter(frag);
                mMemberConsultantListAdapter.setOnItemClickListener(onItemClickListener);
                mRvChildList.setAdapter(mMemberConsultantListAdapter);
                linearLayoutManager = new LinearLayoutManager(mRvChildList.getContext(), LinearLayoutManager.HORIZONTAL, false);
                mRvChildList.setLayoutManager(linearLayoutManager);
                break;
            case MerchantInfoDetailListAdapter.TYPE_FACILITY:
                mFacilityListAdapter = new MerchantInfoFacilityListAdapter();
                mRvChildList.setAdapter(mFacilityListAdapter);
                GridLayoutManager gridLayoutManager = new GridLayoutManager(mRvChildList.getContext(), 3);
                mRvChildList.setLayoutManager(gridLayoutManager);
                break;
        }

    }

    public void onBindData(MerchantInfoDetailsListBean detailsListBean, int viewType) {
        try {
            mTvGroupName.setText(detailsListBean.getGroupName());
            switch (viewType) {
                case MerchantInfoDetailListAdapter.TYPE_COACH:
                    mCoachListAdapter.setCoachBeans(detailsListBean.getCoachList());
                    break;
                case MerchantInfoDetailListAdapter.TYPE_SHIP:
                    mMemberConsultantListAdapter.setMemberShipListBeans(detailsListBean.getMemberShipList());
                    break;
                case MerchantInfoDetailListAdapter.TYPE_FACILITY:
                    mFacilityListAdapter.setFacilitiesBeans(detailsListBean.getInstallList());
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/store/GoodsDetailPre.java<|end_filename|>
package com.scj.beilu.app.mvp.store;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoResultBean;
import com.scj.beilu.app.mvp.store.model.GoodsInfoImpl;
import com.scj.beilu.app.mvp.store.model.IGoodsInfo;

/**
 * @author Mingxun
 * @time on 2019/3/28 13:37
 */
public class GoodsDetailPre extends ShoppingCartPre<GoodsDetailPre.GoodsDetailView> {

    private IGoodsInfo mGoodsInfo;


    public GoodsDetailPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mGoodsInfo = new GoodsInfoImpl(mBuilder);
    }

    public void getGoodsInfoById(final int productId) {
        onceViewAttached(new ViewAction<GoodsDetailView>() {
            @Override
            public void run(@NonNull final GoodsDetailView mvpView) {
                mGoodsInfo.getGoodsInfoById(productId)
                        .subscribe(new BaseResponseCallback<GoodsInfoResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(GoodsInfoResultBean goodsInfoResultBean) {
                                mvpView.onGoodsInfoResult(goodsInfoResultBean.getProductInfo());
                            }
                        });
            }
        });
    }

    public void setCollect(final int productId) {
        onceViewAttached(new ViewAction<GoodsDetailView>() {
            @Override
            public void run(@NonNull final GoodsDetailView mvpView) {
                mGoodsInfo.setCollect(productId)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onCollectResult(resultMsgBean);
                            }
                        });
            }
        });
    }

    public void addToCart(final GoodsInfoBean goodsInfo, final int goodsNum, final String goodsSpecification) {
        onceViewAttached(new ViewAction<GoodsDetailView>() {
            @Override
            public void run(@NonNull final GoodsDetailView mvpView) {
                mShoppingCar.addCart(goodsInfo, goodsNum, goodsSpecification)
                        .subscribe(new ObserverCallback<Integer>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(Integer integer) {
                                mvpView.onCartCount(integer);
                            }
                        });
            }
        });
    }


    public interface GoodsDetailView extends ShoppingCartPre.ShoppingCartView {
        void onGoodsInfoResult(GoodsInfoBean goodsInfo);

        void onCollectResult(ResultMsgBean result);

    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/act/adapter/ImageSelectedListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.act.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/26 15:21
 */
public class ImageSelectedListAdapter extends RecyclerView.Adapter<ImageSelectedListAdapter.ImageViewHolder> {

    private List<Boolean> mImageSelectedList;

    public void setImageSelectedList(List<Boolean> imageSelectedList) {
        mImageSelectedList = imageSelectedList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_img_selected, parent, false);
        return new ImageViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
        holder.mImageView.setSelected(mImageSelectedList.get(position));
    }

    @Override
    public int getItemCount() {
        return mImageSelectedList == null ? 0 : mImageSelectedList.size();
    }

    class ImageViewHolder extends BaseViewHolder {
        private ImageView mImageView;

        public ImageViewHolder(View itemView) {
            super(itemView);
            mImageView = findViewById(R.id.iv_image_selected);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/NewsMyAttentionAuthorListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.news;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.NewsMyAttentionAuthorListPre;
import com.scj.beilu.app.mvp.news.bean.NewsAuthorInfoBean;
import com.scj.beilu.app.ui.act.LoginAndRegisterAct;
import com.scj.beilu.app.ui.news.adapter.NewsAuthorListAdapter;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/5/13 11:03
 */
public class NewsMyAttentionAuthorListFrag extends BaseMvpFragment<NewsMyAttentionAuthorListPre.NewsMyAttentionAuthorListView,
        NewsMyAttentionAuthorListPre> implements NewsMyAttentionAuthorListPre.NewsMyAttentionAuthorListView, OnItemClickListener {

    private RecyclerView recy_attention_author_list;

    private NewsAuthorListAdapter mNewsAuthorListAdapter;

    private final int REQUEST_MY_ATTENTION_AUTHOR = 0xb1;

    private static final String LOAD_TYPE = "load_type";
    private int mLoadType;

    public static NewsMyAttentionAuthorListFrag newInstance(int load) {

        Bundle args = new Bundle();
        args.putInt(LOAD_TYPE, load);
        NewsMyAttentionAuthorListFrag fragment = new NewsMyAttentionAuthorListFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mLoadType = arguments.getInt(LOAD_TYPE);
        }
    }

    @Override
    public NewsMyAttentionAuthorListPre createPresenter() {
        return new NewsMyAttentionAuthorListPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_news_my_attention_author_list;
    }

    @Override
    public void initView() {
        super.initView();
        recy_attention_author_list = findViewById(R.id.recy_attention_author_list);
        mNewsAuthorListAdapter = new NewsAuthorListAdapter(this);
        recy_attention_author_list.setAdapter(mNewsAuthorListAdapter);
        mNewsAuthorListAdapter.setOnItemClickListener(this);

        mRefreshLayout.autoRefresh();
        if (mLoadType == NewsAuthorInfoAct.LOAD_ATTENTION_AUTHOR) {
            mAppToolbar.setToolbarTitle("我的关注");
        } else {
            mAppToolbar.setToolbarTitle("更多推荐");
        }
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        if (mLoadType == NewsAuthorInfoAct.LOAD_ATTENTION_AUTHOR) {
            getPresenter().getMyAttentionAuthorList(mCurrentPage);
        } else {
            getPresenter().getRecommendAuthorList(mCurrentPage);
        }
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        if (mLoadType == NewsAuthorInfoAct.LOAD_ATTENTION_AUTHOR) {
            getPresenter().getMyAttentionAuthorList(mCurrentPage);
        } else {
            getPresenter().getRecommendAuthorList(mCurrentPage);
        }
    }

    @Override
    public void onMyAttentionAuthorList(List<NewsAuthorInfoBean> authorInfoList) {
        mNewsAuthorListAdapter.setAuthorInfoList(authorInfoList);
    }

    @Override
    public void onNotifyAttentionStatus(int position) {
        mNewsAuthorListAdapter.notifyItemChanged(position);
        mFragmentActivity.setResult(Activity.RESULT_OK);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        NewsAuthorInfoBean authorInfoBean = null;
        if (entity instanceof NewsAuthorInfoBean) {
            authorInfoBean = (NewsAuthorInfoBean) entity;
        }
        switch (view.getId()) {
            case R.id.tv_news_recommend_attention_status:
                getPresenter().setAttentionAuthor(authorInfoBean.getUserId());
                break;
            case R.id.iv_news_author_avatar:
                Intent intent = new Intent(mFragmentActivity, NewsAuthorInfoAct.class);
                intent.putExtra(NewsAuthorInfoAct.AUTHOR_ID, authorInfoBean.getUserId());
                startActivityForResult(intent, REQUEST_MY_ATTENTION_AUTHOR);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_MY_ATTENTION_AUTHOR && resultCode == RESULT_OK) {
            mRefreshLayout.autoRefresh();
        }
        if (requestCode == LoginAndRegisterAct.LOGIN_REQUEST) {
            mRefreshLayout.autoRefresh();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/action/adapter/ActionSortListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.action.adapter;

import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.mvp.action.bean.ActionInfoBean;
import com.scj.beilu.app.mvp.action.bean.ActionSortInfoBean;
import com.scj.beilu.app.ui.action.ActionListFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/18 16:07
 * {@link ActionContentListAdapter}
 */
public class ActionSortListAdapter extends RecyclerView.Adapter<ActionSortListAdapter.ActionSortViewHolder> {
    private List<ActionSortInfoBean> mSortInfoBeans;
    private OnGroupItemClickListener<ActionInfoBean> mOnItemClickListener;
    private ActionListFrag mActionListFrag;
    private final int mRectSize;

    public ActionSortListAdapter(ActionListFrag actionListFrag) {
        mActionListFrag = actionListFrag;
        mRectSize = actionListFrag.getResources().getDimensionPixelSize(R.dimen.hor_divider_size_5);
    }

    public void setSortInfoBeans(List<ActionSortInfoBean> sortInfoBeans) {
        mSortInfoBeans = sortInfoBeans;
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnGroupItemClickListener<ActionInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public ActionSortViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_action_content, parent, false);
        return new ActionSortViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ActionSortViewHolder holder, int position) {
        try {
            ActionSortInfoBean infoBean = mSortInfoBeans.get(position);
            holder.mTvSortTitle.setText(infoBean.getActionName());
            List<ActionInfoBean> actions = infoBean.getActions();
            holder.mTvSortTitle.setVisibility(actions.size() == 0 ? View.GONE : View.VISIBLE);
//            ActionContentListAdapter contentListAdapter = new ActionContentListAdapter(mActionListFrag,position);
//            contentListAdapter.setOnItemClickListener(mOnItemClickListener);
//            contentListAdapter.setActionInfoList(actions);
//            holder.mRvActionInfoList.setAdapter(contentListAdapter);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mSortInfoBeans == null ? 0 : mSortInfoBeans.size();
    }

    class ActionSortViewHolder extends BaseViewHolder {
        private TextView mTvSortTitle;
        private RecyclerView mRvActionInfoList;

        public ActionSortViewHolder(View itemView) {
            super(itemView);
            mTvSortTitle = findViewById(R.id.tv_action_sort_txt);
            mRvActionInfoList = findViewById(R.id.rv_action_info_list);

            mRvActionInfoList.addItemDecoration(new RecyclerView.ItemDecoration() {
                @Override
                public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                    super.getItemOffsets(outRect, view, parent, state);
                    outRect.set(mRectSize, mRectSize, mRectSize, mRectSize);
                }
            });

        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/fit/FitRecordAlbumPreviewAct.java<|end_filename|>
package com.scj.beilu.app.ui.fit;

import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.support.v7.app.AlertDialog;
import android.view.MenuItem;
import android.view.View;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.mvp.fit.FitRecordImgPreviewPre;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgInfoBean;
import com.scj.beilu.app.ui.preview.FitRecordAlbumPreviewFrag;
import com.scj.beilu.app.ui.preview.adapter.FitRecordAlbumPreviewPagerAdapter;
import com.scj.beilu.app.util.TimeUtil;
import com.scj.beilu.app.util.ToastUtils;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/3/15 17:35
 */
public class FitRecordAlbumPreviewAct extends BaseMvpActivity<FitRecordImgPreviewPre.FitRecordImgPreviewView, FitRecordImgPreviewPre>
        implements FitRecordAlbumPreviewFrag.onViewClickListener, FitRecordImgPreviewPre.FitRecordImgPreviewView, ViewPager.OnPageChangeListener {

    private ViewPager mViewPager;
    private FitRecordAlbumPreviewPagerAdapter mFitRecordAlbumPreviewPagerAdapter;
    public static final String EXTRA_IMAGE_LIST = "image_list";
    public static final String EXTRA_IMAGE_POSITION = "images_position";
    private ArrayList<FitRecordImgInfoBean> mImgInfoBeans;
    private boolean mIsToolbarHide;

    @Override
    public int getLayout() {
        return R.layout.act_fit_record_album_preview;
    }

    @Override
    protected void initView() {
        super.initView();
        mViewPager = findViewById(R.id.view_pager);
        ImmersionBar.with(this)
                .hideBar(BarHide.FLAG_HIDE_STATUS_BAR)
                .statusBarDarkFont(true,0.2f)
                .init();
        Intent intent = getIntent();
        if (intent == null) return;
        mImgInfoBeans = intent.getParcelableArrayListExtra(EXTRA_IMAGE_LIST);
        int position = intent.getIntExtra(EXTRA_IMAGE_POSITION, 0);
        mAppToolbar.setToolbarTitle(TimeUtil.getDate(mImgInfoBeans.get(position).getRecordDate(), "yyyy-MM-dd"));

        mFitRecordAlbumPreviewPagerAdapter = new FitRecordAlbumPreviewPagerAdapter(getSupportFragmentManager());
        mFitRecordAlbumPreviewPagerAdapter.setImagePathList(mImgInfoBeans);
        mViewPager.setAdapter(mFitRecordAlbumPreviewPagerAdapter);

        mViewPager.setCurrentItem(position, false);
        mViewPager.addOnPageChangeListener(this);
        mAppToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @NonNull
    @Override
    public FitRecordImgPreviewPre createPresenter() {
        return new FitRecordImgPreviewPre(this);
    }

    @Override
    public void onClick(int position) {
        if (mIsToolbarHide) {
            mAppToolbar.animate()
                    .setInterpolator(new FastOutSlowInInterpolator())
                    .translationYBy(mAppToolbar.getMeasuredHeight())
                    .start();

        } else {
            mAppToolbar.animate()
                    .setInterpolator(new FastOutSlowInInterpolator())
                    .translationYBy(-mAppToolbar.getMeasuredHeight())
                    .start();

        }

        mIsToolbarHide = !mIsToolbarHide;
    }



    @Override
    public void onDelResult(String result) {
        setResult(RESULT_OK);
        ToastUtils.showToast(this, result);
        try {
            int position = mViewPager.getCurrentItem();
            mImgInfoBeans.remove(position);
            mFitRecordAlbumPreviewPagerAdapter.notifyDataSetChanged();
            if (mFitRecordAlbumPreviewPagerAdapter.getCount() == 0) {
                finish();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        mAppToolbar.setToolbarTitle(TimeUtil.getDate(mImgInfoBeans.get(position).getRecordDate(), "yyyy-MM-dd"));
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }

    @Override
    public boolean onMenuItemClick(MenuItem item) {
        new AlertDialog.Builder(this)
                .setPositiveButton(R.string.button_sure, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(@NonNull DialogInterface dialog, int which) {
                        getPresenter().deleteImg(mImgInfoBeans.get(mViewPager.getCurrentItem()).getRecordPicId());
                    }
                })
                .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(@NonNull DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                })
                .setCancelable(false)
                .setMessage("确定删除当前图片吗？")
                .show();
        return super.onMenuItemClick(item);
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/CourseBoughtFrag.java<|end_filename|>
package com.scj.beilu.app.ui.course;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.course.CourseBoughtPre;
import com.scj.beilu.app.mvp.course.bean.CourseVideoInfoBean;
import com.scj.beilu.app.ui.course.adapter.CourseCatalogueListAdapter;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/26 02:03
 * 已购课程
 */
public class CourseBoughtFrag extends BaseMvpFragment<CourseBoughtPre.CourseBoughtView, CourseBoughtPre>
        implements CourseBoughtPre.CourseBoughtView, OnItemClickListener<CourseVideoInfoBean> {

    private CourseCatalogueListAdapter mCourseCatalogueListAdapter;

    @Override
    public CourseBoughtPre createPresenter() {
        return new CourseBoughtPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_course_bought;
    }

    @Override
    public void initView() {
        super.initView();
        mCourseCatalogueListAdapter = new CourseCatalogueListAdapter(this);
        mCourseCatalogueListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mCourseCatalogueListAdapter);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getBoughtCourseList(mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getBoughtCourseList(mCurrentPage);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onItemClick(int position, CourseVideoInfoBean entity, View view) {
        Intent intent = new Intent(mFragmentActivity, CoursePlayAct.class);
        intent.putExtra(CoursePlayAct.EXTRA_COURSE_ID, entity.getCourseId());
        intent.putExtra(CoursePlayAct.EXTRA_COURSE_VIDEO_ID, entity.getCourseVideoId());
        startActivity(intent);

    }

    @Override
    public void onVideoListResult(List<CourseVideoInfoBean> courseVideoList) {
        mCourseCatalogueListAdapter.setVideoInfoBeanList(courseVideoList);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/home/HomeSearchGoodsPre.java<|end_filename|>
package com.scj.beilu.app.mvp.home;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.base.BaseCheckArrayView;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.FindListBean;
import com.scj.beilu.app.mvp.find.model.FindImpl;
import com.scj.beilu.app.mvp.find.model.IFindInfo;
import com.scj.beilu.app.mvp.home.model.HomeInfoImpl;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.mvp.store.bean.GoodsInfoBean;
import com.scj.beilu.app.mvp.user.bean.RecommendUserInfoBean;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;
import io.reactivex.subjects.PublishSubject;

/**
 * @author Mingxun
 * @time on 2019/4/12 02:07
 */
public class HomeSearchGoodsPre extends BaseMvpPresenter<HomeSearchGoodsPre.HomeSearchView> {

    private PublishSubject<String> mPublishSubject;

    private IFindInfo mFindInfo;
    private HomeInfoImpl mHomeInfo;

    private List<FindInfoBean> mFindInfoList;

    public HomeSearchGoodsPre(Context context) {
        super(context, ShowConfig.LOADING_STATE, ShowConfig.ERROR_TOAST);
        mFindInfo = new FindImpl(mBuilder);
        mHomeInfo = new HomeInfoImpl(mBuilder);
    }


    public void startSearch(final int indexType, final String keyName, final int currentPage) {

        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull HomeSearchView mvpView) {
                if (mPublishSubject == null) {
                    mPublishSubject = PublishSubject.create();
                    mPublishSubject.debounce(1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
                            .filter(new Predicate<String>() {
                                @Override
                                public boolean test(String s) throws Exception {
                                    return s.length() > 0;
                                }
                            })

                            .switchMap(new Function<String, Observable<String>>() {
                                @Override
                                public Observable<String> apply(String s) throws Exception {
                                    return mHomeInfo.content(s);
                                }
                            })
                            .subscribe(new ObserverCallback<String>(mBuilder.build(mvpView)) {
                                @Override
                                public void onNext(String keyName) {
                                    switch (indexType) {
                                        case 0:
                                            searchFindInfoList(keyName, currentPage);
                                            break;
                                        case 1:
                                            searchNewsInfoList(keyName, currentPage);
                                            break;
                                        case 2:
                                            searchGoodsInfoList(keyName, currentPage);
                                            break;
                                        case 3:
                                            searchUserInfoList(keyName, currentPage);
                                            break;
                                    }
                                }
                            });

                }

                mPublishSubject.onNext(keyName);
            }
        });
    }

    public void startSearchNextPage(final int indexType, final String keyName, final int currentPage) {
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull HomeSearchView mvpView) {
                switch (indexType) {
                    case 0:
                        searchFindInfoList(keyName, currentPage);
                        break;
                    case 1:
                        searchNewsInfoList(keyName, currentPage);
                        break;
                    case 2:
                        searchGoodsInfoList(keyName, currentPage);
                        break;
                    case 3:
                        searchUserInfoList(keyName, currentPage);
                        break;
                }
            }
        });
    }

    private void searchFindInfoList(final String keyName, final int currentPage) {
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull final HomeSearchView mvpView) {
                mFindInfo.startSearchFind(currentPage, keyName)
                        .subscribe(new ObserverCallback<FindListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(FindListBean findListBean) {
                                try {
                                    List<FindInfoBean> list = findListBean.getPage().getList();
                                    if (currentPage == 0) {
                                        if (mFindInfoList == null) {
                                            mFindInfoList = new ArrayList<>();
                                        }
                                        mFindInfoList.clear();
                                    }
                                    if (list == null) {
                                        list = new ArrayList<>();
                                    }
                                    mFindInfoList.addAll(list);
                                    mvpView.onCheckLoadMore(list);

                                    mvpView.onFindInfoList(mFindInfoList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }

                        });
            }
        });
    }

    private void searchNewsInfoList(String keyName, int currentPage) {
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull HomeSearchView mvpView) {

            }
        });
    }

    private void searchGoodsInfoList(String keyName, int currentPage) {
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull HomeSearchView mvpView) {

            }
        });
    }

    private void searchUserInfoList(String keyName, int currentPage) {
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull HomeSearchView mvpView) {

            }
        });
    }

    public interface HomeSearchView extends BaseCheckArrayView {
        void onFindInfoList(List<FindInfoBean> findInfoList);

        void onNewsInfoList(List<NewsInfoBean> newsInfoList);

        void onGoodsInfoList(List<GoodsInfoBean> goodsInfoList);

        void onUserInfoList(List<RecommendUserInfoBean> userInfoList);
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/fragmentation/support/SupportFragment.java<|end_filename|>
package com.mx.pro.lib.fragmentation.support;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;

import com.mx.pro.lib.fragmentation.ExtraTransaction;
import com.mx.pro.lib.fragmentation.ISupportFragment;
import com.mx.pro.lib.fragmentation.SupportFragmentDelegate;
import com.mx.pro.lib.fragmentation.SupportHelper;
import com.mx.pro.lib.fragmentation.anim.FragmentAnimator;
import com.umeng.analytics.MobclickAgent;

import static android.view.View.NO_ID;


/**
 * @author Charlie
 * supportFragment implements ISupportFragment,
 */
public abstract class SupportFragment extends Fragment implements ISupportFragment {
    final SupportFragmentDelegate mDelegate = new SupportFragmentDelegate(this);

    protected FragmentActivity mFragmentActivity;
    protected View mView;

    @Override
    public SupportFragmentDelegate getSupportDelegate() {
        return mDelegate;
    }

    @Override
    public ExtraTransaction extraTransaction() {
        return mDelegate.extraTransaction();
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mDelegate.onAttach(activity);
        mFragmentActivity = mDelegate.getActivity();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mDelegate.onCreate(savedInstanceState);
    }

    @Override
    public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
        return mDelegate.onCreateAnimation(transit, enter, nextAnim);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mDelegate.onActivityCreated(savedInstanceState);
    }


    @Override
    public void onSaveInstanceState(@NonNull Bundle outState) {
        super.onSaveInstanceState(outState);
        mDelegate.onSaveInstanceState(outState);
    }

    @Override
    public void onResume() {
        super.onResume();
        mDelegate.onResume();
        MobclickAgent.onResume(mFragmentActivity);

    }


    @Override
    public void onPause() {
        super.onPause();
        hideSoftInput();
        mDelegate.onPause();
        MobclickAgent.onPause(mFragmentActivity);

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        mDelegate.onDestroyView();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mDelegate.onDestroy();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        mDelegate.onHiddenChanged(hidden);
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        mDelegate.setUserVisibleHint(isVisibleToUser);
    }


    @Override
    public void enqueueAction(Runnable runnable) {
        mDelegate.enqueueAction(runnable);
    }

    @Override
    public void post(Runnable runnable) {
        mDelegate.post(runnable);
    }

    @Override
    public void onEnterAnimationEnd(@Nullable Bundle savedInstanceState) {
        mDelegate.onEnterAnimationEnd(savedInstanceState);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        mDelegate.onLazyInitView(savedInstanceState);
    }

    @Override
    public void onSupportVisible() {
        mDelegate.onSupportVisible();
    }

    @Override
    public void onSupportInvisible() {
        mDelegate.onSupportInvisible();
    }

    @Override
    public boolean isSupportVisible() {
        return mDelegate.isSupportVisible();
    }

    @Override
    public FragmentAnimator onCreateFragmentAnimator() {
        return mDelegate.onCreateFragmentAnimator();
    }

    @Override
    public FragmentAnimator getFragmentAnimator() {
        return mDelegate.getFragmentAnimator();
    }

    @Override
    public void setFragmentAnimator(FragmentAnimator fragmentAnimator) {
        mDelegate.setFragmentAnimator(fragmentAnimator);
    }

    @Override
    public void setFragmentResult(int resultCode, Bundle bundle) {
        mDelegate.setFragmentResult(resultCode, bundle);
    }

    @Override
    public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
        mDelegate.onFragmentResult(requestCode, resultCode, data);
    }

    @Override
    public void onNewBundle(Bundle args) {
        mDelegate.onNewBundle(args);
    }

    @Override
    public void putNewBundle(Bundle newBundle) {
        mDelegate.putNewBundle(newBundle);
    }

    @Override
    public boolean onBackPressedSupport() {
        return mDelegate.onBackPressedSupport();
    }

    /**
     * 隐藏软键盘
     */
    protected void hideSoftInput() {
        mDelegate.hideSoftInput();
    }

    /**
     * 显示软键盘,调用该方法后,会在onPause时自动隐藏软键盘
     */
    protected void showSoftInput(final View view) {
        mDelegate.showSoftInput(view);
    }

    /**
     * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment
     *
     * @param containerId 容器id
     * @param toFragment  目标Fragment
     */
    public void loadRootFragment(int containerId, ISupportFragment toFragment) {
        mDelegate.loadRootFragment(containerId, toFragment);
    }

    public void loadRootFragment(int containerId, ISupportFragment toFragment, boolean addToBackStack, boolean allowAnim) {
        mDelegate.loadRootFragment(containerId, toFragment, addToBackStack, allowAnim);
    }

    /**
     * 加载多个同级根Fragment,类似Wechat, QQ主页的场景
     */
    public void loadMultipleRootFragment(int containerId, int showPosition, ISupportFragment... toFragments) {
        mDelegate.loadMultipleRootFragment(containerId, showPosition, toFragments);
    }

    /**
     * show一个Fragment,hide其他同栈所有Fragment
     * 使用该方法时，要确保同级栈内无多余的Fragment,(只有通过loadMultipleRootFragment()载入的Fragment)
     * <p>
     * 建议使用更明确的{@link #showHideFragment(ISupportFragment, ISupportFragment)}
     *
     * @param showFragment 需要show的Fragment
     */
    public void showHideFragment(ISupportFragment showFragment) {
        mDelegate.showHideFragment(showFragment);
    }

    /**
     * show一个Fragment,hide一个Fragment ; 主要用于类似微信主页那种 切换tab的情况
     */
    public void showHideFragment(ISupportFragment showFragment, ISupportFragment hideFragment) {
        mDelegate.showHideFragment(showFragment, hideFragment);
    }

    public void start(ISupportFragment toFragment) {
        mDelegate.start(toFragment);
    }

    /**
     * @param launchMode Similar to Activity's LaunchMode.
     */
    public void start(final ISupportFragment toFragment, @LaunchMode int launchMode) {
        mDelegate.start(toFragment, launchMode);
    }

    /**
     * Launch an fragment for which you would like a result when it poped.
     */
    public void startForResult(ISupportFragment toFragment, int requestCode) {
        mDelegate.startForResult(toFragment, requestCode);
    }

    /**
     * Start the target Fragment and pop itself
     */
    public void startWithPop(ISupportFragment toFragment) {
        mDelegate.startWithPop(toFragment);
    }

    /**
     * @see #popTo(Class, boolean)
     * +
     * @see #start(ISupportFragment)
     */
    public void startWithPopTo(ISupportFragment toFragment, Class<?> targetFragmentClass, boolean includeTargetFragment) {
        mDelegate.startWithPopTo(toFragment, targetFragmentClass, includeTargetFragment);
    }


    public void replaceFragment(ISupportFragment toFragment, boolean addToBackStack) {
        mDelegate.replaceFragment(toFragment, addToBackStack);
    }

    public void pop() {
        mDelegate.pop();
    }

    /**
     * Pop the child fragment.
     */
    public void popChild() {
        mDelegate.popChild();
    }

    /**
     * Pop the last fragment transition from the manager's fragment
     * back stack.
     * <p>
     * 出栈到目标fragment
     *
     * @param targetFragmentClass   目标fragment
     * @param includeTargetFragment 是否包含该fragment
     */
    public void popTo(Class<?> targetFragmentClass, boolean includeTargetFragment) {
        mDelegate.popTo(targetFragmentClass, includeTargetFragment);
    }

    /**
     * If you want to begin another FragmentTransaction immediately after popTo(), use this method.
     * 如果你想在出栈后, 立刻进行FragmentTransaction操作，请使用该方法
     */
    public void popTo(Class<?> targetFragmentClass, boolean includeTargetFragment, Runnable afterPopTransactionRunnable) {
        mDelegate.popTo(targetFragmentClass, includeTargetFragment, afterPopTransactionRunnable);
    }

    public void popTo(Class<?> targetFragmentClass, boolean includeTargetFragment, Runnable afterPopTransactionRunnable, int popAnim) {
        mDelegate.popTo(targetFragmentClass, includeTargetFragment, afterPopTransactionRunnable, popAnim);
    }

    public void popToChild(Class<?> targetFragmentClass, boolean includeTargetFragment) {
        mDelegate.popToChild(targetFragmentClass, includeTargetFragment);
    }

    public void popToChild(Class<?> targetFragmentClass, boolean includeTargetFragment, Runnable afterPopTransactionRunnable) {
        mDelegate.popToChild(targetFragmentClass, includeTargetFragment, afterPopTransactionRunnable);
    }

    public void popToChild(Class<?> targetFragmentClass, boolean includeTargetFragment, Runnable afterPopTransactionRunnable, int popAnim) {
        mDelegate.popToChild(targetFragmentClass, includeTargetFragment, afterPopTransactionRunnable, popAnim);
    }

    /**
     * 得到位于栈顶Fragment
     */
    public ISupportFragment getTopFragment() {
        return SupportHelper.getTopFragment(getFragmentManager());
    }

    public ISupportFragment getTopChildFragment() {
        return SupportHelper.getTopFragment(getChildFragmentManager());
    }

    /**
     * @return 位于当前Fragment的前一个Fragment
     */
    public ISupportFragment getPreFragment() {
        return SupportHelper.getPreFragment(this);
    }

    /**
     * 获取栈内的fragment对象
     */
    public <T extends ISupportFragment> T findFragment(Class<T> fragmentClass) {
        return SupportHelper.findFragment(getFragmentManager(), fragmentClass);
    }

    /**
     * 获取栈内的fragment对象
     */
    public <T extends ISupportFragment> T findChildFragment(Class<T> fragmentClass) {
        return SupportHelper.findFragment(getChildFragmentManager(), fragmentClass);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mView = inflater.inflate(getLayout(), container, false);
        return mView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
    }

    public void initView() {

    }

    @Nullable
    public abstract int getLayout();

    @NonNull
    public final <T extends View> T findViewById(@IdRes int id) {
        if (mView == null || id == NO_ID) {
            return null;
        }
        return mView.findViewById(id);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/user/UserHomePageFrag.java<|end_filename|>
package com.scj.beilu.app.ui.user;

import android.Manifest;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.album.AlbumManager;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnGroupItemClickListener;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.find.bean.FindImageBean;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;
import com.scj.beilu.app.mvp.find.bean.ModifyRecordBean;
import com.scj.beilu.app.mvp.user.UserHomePagePre;
import com.scj.beilu.app.mvp.user.bean.AvatarResult;
import com.scj.beilu.app.mvp.user.bean.UserDetailsBean;
import com.scj.beilu.app.mvp.user.entity.UserInfoEntity;
import com.scj.beilu.app.ui.act.UserInfoEditAct;
import com.scj.beilu.app.ui.dialog.UserHomePageDialog;
import com.scj.beilu.app.ui.find.FindDetailsAct;
import com.scj.beilu.app.ui.find.FindDetailsFrag;
import com.scj.beilu.app.ui.find.adapter.FindInfoListAdapter;
import com.scj.beilu.app.ui.preview.PicImagePreviewAct;
import com.scj.beilu.app.util.ToastUtils;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.yalantis.ucrop.UCrop;
import com.yalantis.ucrop.UCropActivity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

import static com.scj.beilu.app.ui.act.UserInfoEditAct.getDiskCacheDir;
import static com.scj.beilu.app.ui.user.UserInfoHomePageAct.EXTRA_USER_ID;

/**
 * @author Mingxun
 * @time on 2019/3/4 18:45
 * 我的主页信息</p>
 * 其他人的主页信息
 */
@RuntimePermissions
public class UserHomePageFrag extends BaseMvpFragment<UserHomePagePre.UserHomePageView, UserHomePagePre>
        implements UserHomePagePre.UserHomePageView, View.OnClickListener,
        AppBarLayout.OnOffsetChangedListener, OnItemClickListener<FindInfoBean>,
        UserHomePageDialog.onClickListener, OnGroupItemClickListener<ArrayList<FindImageBean>> {

    private final int REQUEST_COMMENT_CODE = 0x058;
    public static final int REQUEST_PICTURE_CODE = 0x025;
    private final int REQUEST_USER_EDIT = 0xb1;

    private AppBarLayout mAppBarLayout;
    private LinearLayout mLlTopUserInfo;
    private ImageView mIvAvatarLarge, mIvAvatarSmall;
    private ImageView mIvUserBackground;
    private TextView mTvUserNameSmall, mTvUserNameLarge;
    private TextView mTvUserInfoAction;
    private TextView mTvUserDescription;
    private LinearLayout mLlUserPraise, mLlUserMyAttention, mLlUserAttentionToMy, mLlUserDynamic;
    private TextView mTvPraiseCount, mTvMyAttentionCount, mTvAttentionToMyCount, mTvDynamicCount;
    private TextView mTvPraiseTitle, mTvMyAttentionTitle, mTvAttentionToMyTitle, mTvDynamicTitle;
    private TextView mTvDynamicHeader;
    private View mViewElevation;
    private View mViewTransparent;
    private LinearLayout mLlEmptyView;
    private TextView mTvEmptyHint;

    // 详情查看效果图
    private Drawable mDefDrawable;
    private int mWhiteColor;
    //滑动到顶部，白色背景添加阴影的高度
    private int mElevationHeight;

    private Drawable mDrawableBtnAction;
    private int mTextViewActionHeight = 0;
    private int mTextViewActionTextColor;

    private int mUserId = -1;

    private int mAttentionCode = 0;//关注状态码
    private FindInfoListAdapter mFindInfoListAdapter;
    private int mRecordPosition = -1;
    private UserHomePageDialog mUserHomePageDialog;
    private int mDynamicIdByIndex;

    public static UserHomePageFrag newInstance(int userId) {

        Bundle args = new Bundle();
        args.putInt(EXTRA_USER_ID, userId);
        UserHomePageFrag fragment = new UserHomePageFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mUserId = arguments.getInt(EXTRA_USER_ID);
        }
    }

    @Override
    public UserHomePagePre createPresenter() {
        return new UserHomePagePre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_user_info_home_page;
    }

    @Override
    public void initView() {
        super.initView();
        mAppBarLayout = findViewById(R.id.app_bar_layout_user_home_page);
        mLlTopUserInfo = findViewById(R.id.ll_user_home_page_top_user_info);
        mIvUserBackground = findViewById(R.id.iv_user_home_page_background);
        mIvAvatarSmall = findViewById(R.id.iv_user_home_page_avatar_small);
        mTvUserNameSmall = findViewById(R.id.tv_user_home_page_user_name_small);
        mIvAvatarLarge = findViewById(R.id.iv_user_home_page_avatar_large);
        mTvUserNameLarge = findViewById(R.id.tv_user_home_page_user_name_large);
        mTvUserInfoAction = findViewById(R.id.tv_user_home_page_action);
        mTvUserDescription = findViewById(R.id.tv_user_home_page_description);
        mTvPraiseCount = findViewById(R.id.tv_user_home_page_praise_count);
        mTvMyAttentionCount = findViewById(R.id.tv_user_home_page_my_attention_count);
        mTvAttentionToMyCount = findViewById(R.id.tv_user_home_page_attention_to_my_count);
        mTvDynamicCount = findViewById(R.id.tv_user_home_page_dynamic_count);
        mTvPraiseTitle = findViewById(R.id.tv_user_home_page_praise_title);
        mTvMyAttentionTitle = findViewById(R.id.tv_user_home_page_my_attention_title);
        mTvAttentionToMyTitle = findViewById(R.id.tv_user_home_page_attention_to_my_title);
        mTvDynamicTitle = findViewById(R.id.tv_user_home_page_dynamic_title);
        mViewElevation = findViewById(R.id.view_elevation);
        mTvDynamicHeader = findViewById(R.id.tv_user_home_page_dynamic_header);
        mLlUserMyAttention = findViewById(R.id.ll_user_home_page_attention);
        mLlUserAttentionToMy = findViewById(R.id.ll_user_home_page_attention_to_my);
        mViewTransparent = findViewById(R.id.view_transparent);
        mLlEmptyView = findViewById(R.id.ll_load_empty_view);
        mTvEmptyHint = findViewById(R.id.tv_empty_hint);

        mAppBarLayout.addOnOffsetChangedListener(this);
        mTvUserInfoAction.setOnClickListener(this);
        mLlUserMyAttention.setOnClickListener(this);
        mLlUserAttentionToMy.setOnClickListener(this);

        ImmersionBar.with(this)
                .titleBar(mAppToolbar)
                .statusBarDarkFont(false).init();

        initResource();

        initRecyclerView();

        if (checkIsOwn()) {
            mViewTransparent.setOnClickListener(this);
        }
    }

    private void initResource() {
        if (isAdded()) {
            mElevationHeight = mFragmentActivity.getResources().getDimensionPixelOffset(R.dimen.rect_5);
            mDefDrawable = ContextCompat.getDrawable(mFragmentActivity, R.drawable.shape_dialog_white_bg);
            mWhiteColor = ContextCompat.getColor(mFragmentActivity, android.R.color.white);
            mTextViewActionHeight = mFragmentActivity.getResources().getDimensionPixelOffset(R.dimen.text_view_height);
        }
    }

    private void initRecyclerView() {
        mRecyclerView.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));
        mFindInfoListAdapter = new FindInfoListAdapter(GlideApp.with(this), mFragmentActivity);
        mFindInfoListAdapter.setOnItemClickListener(this);
        mFindInfoListAdapter.setOnGroupItemClickListener(this);
        mRecyclerView.setAdapter(mFindInfoListAdapter);
        final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
        mRecyclerView.getItemAnimator().setChangeDuration(0);

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            int firstVisibleItem, lastVisibleItem;

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
                lastVisibleItem = layoutManager.findLastVisibleItemPosition();
                //大于0说明有播放
                if (GSYVideoManager.instance().getPlayPosition() >= 0) {
                    //当前播放的位置
                    int position = GSYVideoManager.instance().getPlayPosition();
                    //对应的播放列表TAG
                    if (GSYVideoManager.instance().getPlayTag().equals(FindInfoListAdapter.TAG)
                            && (position < firstVisibleItem || position > lastVisibleItem)) {
                        //是否全屏
                        if (!GSYVideoManager.isFullState(mFragmentActivity)) {
                            GSYVideoManager.releaseAllVideos();
                            mFindInfoListAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });
    }

    @Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        //垂直方向偏移量
        int offset = Math.abs(verticalOffset);
        //最大偏移距离
        int scrollRange = appBarLayout.getTotalScrollRange();
        if (offset <= scrollRange / 2) {
            if (mLlTopUserInfo.getVisibility() == View.VISIBLE) {
                mLlTopUserInfo.setVisibility(View.GONE);
                mAppToolbar.setNavigationIcon(R.drawable.ic_back_white);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    mAppBarLayout.setElevation(0);
                }
                mViewElevation.setBackground(mDefDrawable);
                ImmersionBar.with(UserHomePageFrag.this).statusBarDarkFont(false).init();
            }

        } else {

            if (offset == scrollRange) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    mAppBarLayout.setElevation(mElevationHeight);
                }
                mViewElevation.setBackgroundColor(mWhiteColor);
            }
            if (mLlTopUserInfo.getVisibility() == View.GONE) {
                mLlTopUserInfo.setVisibility(View.VISIBLE);
                mAppToolbar.setNavigationIcon(R.drawable.ic_back);
                ImmersionBar.with(UserHomePageFrag.this).statusBarDarkFont(true,0.2f).init();

            }
        }
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getUserInfo(mUserId, mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getLoadMoreDynamicList(mUserId, mCurrentPage);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onUserDetailsResult(UserDetailsBean resultInfo) {
        BindVal(resultInfo);
    }

    @Override
    public void onFindListResult(List<FindInfoBean> findList) {
        if (findList.size() == 0) {
            mRecyclerView.setVisibility(View.GONE);
            mLlEmptyView.setVisibility(View.VISIBLE);
            if (checkIsOwn()) {
                mTvEmptyHint.setText("你还没有发布任何动态～");
            } else {
                mTvEmptyHint.setText("TA还没有发布任何动态～");
            }
        } else {
            if (mLlEmptyView.getVisibility() == View.VISIBLE) {
                mLlEmptyView.setVisibility(View.GONE);
                mRecyclerView.setVisibility(View.VISIBLE);
            }
            mFindInfoListAdapter.setFindInfoList(findList);
        }
    }

    @Override
    public void onNotifyListChangeResult(String result, int position) {

        ToastUtils.showToast(mFragmentActivity, result);

        if (position != UserHomePagePre.RESULT_POSITION) {//点赞后进入
            mFindInfoListAdapter.notifyItemChanged(position);
        } else {//修改关注状态后进入
            //重新设置关注状态
            mAttentionCode = mAttentionCode == 1 ? 0 : 1;
            setAttentionVal();
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onModifyResult(int position) {
        if (position == mRecordPosition) {
            mFindInfoListAdapter.notifyItemChanged(mRecordPosition);
        } else {
            mFindInfoListAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onNotifyBackgroundImg(AvatarResult result) {
        GlideApp.with(this)
                .load(result.getImgPath())
                .thumbnail(GlideApp.with(this).load(result.getZipFileName()).centerCrop())
                .centerCrop()
                .into(mIvUserBackground);
    }

    private void BindVal(UserDetailsBean userInfo) {

        UserInfoEntity user = userInfo.getUser();

        String avatarPath = user.getUserCompressionHead();
        String nickName = user.getUserNickName();
        String description = user.getUserBrief();
        mAttentionCode = userInfo.getIsFocus();

        GlideApp.with(this)
                .load(user.getUserBackImg())
                .centerCrop()
                .into(mIvUserBackground);


        GlideApp.with(UserHomePageFrag.this)
                .load(avatarPath)
                .error(R.drawable.ic_default_avatar)
                .centerCrop()
                .transform(new CircleCrop())
                .into(mIvAvatarLarge);
        GlideApp.with(UserHomePageFrag.this)
                .load(avatarPath)
                .error(R.drawable.ic_default_avatar)
                .centerCrop()
                .transform(new CircleCrop())
                .into(mIvAvatarSmall);

        mIvAvatarLarge.setVisibility(View.VISIBLE);
        mViewTransparent.setVisibility(View.VISIBLE);

        mTvUserNameLarge.setText(nickName);
        mTvUserNameSmall.setText(nickName);
        initBtnActionVal();
        mTvUserDescription.setText(description == null ? "这个人很懒，什么都没有写~" : description);
        initNavVal(userInfo);
    }

    private void initBtnActionVal() {
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mTvUserInfoAction.getLayoutParams();
        if (mDrawableBtnAction == null) {
            if (checkIsOwn()) {//证明是查看自己，
                mDrawableBtnAction = ContextCompat.getDrawable(mFragmentActivity, R.drawable.shape_btn_edit_info);
                layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
                layoutParams.height = mTextViewActionHeight;
                mTextViewActionTextColor = ContextCompat.getColor(mFragmentActivity, android.R.color.white);
            } else {//查看他人的详情
                mDrawableBtnAction = ContextCompat.getDrawable(mFragmentActivity, R.drawable.attention_selector);
                layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
                layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
                mTextViewActionTextColor = ContextCompat.getColor(mFragmentActivity, R.color.attention_txt_color);
            }
            mTvUserInfoAction.setTextColor(mTextViewActionTextColor);
            mTvUserInfoAction.setLayoutParams(layoutParams);
            mTvUserInfoAction.setBackground(mDrawableBtnAction);
            mTvUserInfoAction.setVisibility(View.VISIBLE);
        }
        if (!checkIsOwn()) {
            setAttentionVal();
        }
    }

    /**
     * 设置关注状态
     */
    private void setAttentionVal() {
        mTvUserInfoAction.setSelected(mAttentionCode == 1);
        mTvUserInfoAction.setText(mAttentionCode == 1 ? "已关注" : "+ 关注");
    }

    private void initNavVal(UserDetailsBean details) {
        mTvPraiseTitle.setText("获得的赞");
        mTvMyAttentionTitle.setText(checkIsOwn() ? "我关注的人" : "TA关注的人");
        mTvAttentionToMyTitle.setText(checkIsOwn() ? "关注我的人" : "关注TA的人");
        mTvDynamicTitle.setText(checkIsOwn() ? "我的动态" : "TA的动态");
        mTvDynamicHeader.setText(mTvDynamicTitle.getText());

        mTvPraiseCount.setText(String.valueOf(details.getUserLikeCount()));
        mTvMyAttentionCount.setText(String.valueOf(details.getUserFocusCount()));
        mTvAttentionToMyCount.setText(String.valueOf(details.getUserFansCount()));
        mTvDynamicCount.setText(String.valueOf(details.getUserDynamicCount()));

    }

    private final boolean checkIsOwn() {
        return mUserId == -1;
    }

    @Override
    public void onItemClick(int position, FindInfoBean entity, View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.ll_item_find_praise:
                getPresenter().setLike(entity.getDynamicId(), position);
                break;
            case R.id.ll_item_find_comment:
            case R.id.tv_item_find_txt:
                mRecordPosition = position;
                GSYVideoManager.releaseAllVideos();
                intent = new Intent(mFragmentActivity, FindDetailsAct.class);
                intent.putExtra(FindDetailsFrag.FIND_ID, entity.getDynamicId());
                startActivityForResult(intent, REQUEST_COMMENT_CODE);
                break;
            case R.id.ll_item_find_share:
                if (!EventBus.getDefault().isRegistered(this)) {
                    EventBus.getDefault().register(this);
                }
                mRecordPosition = position;
                mDynamicIdByIndex = entity.getDynamicId();
                getPresenter().startShareFind(this, entity);
                break;
            case R.id.tv_item_find_attention:
                getPresenter().setAttention(entity.getUserId());
                break;
            case R.id.iv_item_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, entity.getDynamicPic(), position);
                break;
        }
    }

    @Override
    public void onItemClick(int groupPosition, int childPosition, ArrayList<FindImageBean> object, View view) {
        switch (view.getId()) {
            case R.id.iv_find_pic:
                //查看大图
                PicImagePreviewAct.startPreview(mFragmentActivity, object, childPosition);
                break;
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_edit_user_info:
            case R.id.tv_user_home_page_action:
                if (checkIsOwn()) {
                    //edit user info
//                    UserInfoEditAct.startUserInfoEditAct(mFragmentActivity);
                    Intent intent = new Intent(mFragmentActivity, UserInfoEditAct.class);
                    startActivityForResult(intent, REQUEST_USER_EDIT);
                } else {
                    //set attention status
                    getPresenter().setAttention(mUserId);
                }
                break;
            case R.id.ll_user_home_page_attention:
                break;
            case R.id.ll_user_home_page_attention_to_my:
                break;
            case R.id.view_transparent:
                if (mUserHomePageDialog == null) {
                    mUserHomePageDialog = new UserHomePageDialog();
                    mUserHomePageDialog.setOnClickListener(this);
                }
                mUserHomePageDialog.show(getChildFragmentManager(), mUserHomePageDialog.getClass().getName());
                break;
            case R.id.tv_edit_picture:
                UserHomePageFragPermissionsDispatcher.NeedsPermissionWithPermissionCheck(this);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_COMMENT_CODE && resultCode == RESULT_OK && data != null) {
            ModifyRecordBean record = data.getParcelableExtra(FindDetailsFrag.EXTRA_MODIFY_RESULT);
            getPresenter().modifyRecord(record, mRecordPosition);
        }
        if (requestCode == REQUEST_PICTURE_CODE && resultCode == RESULT_OK) {
            UCrop.Options options = new UCrop.Options();

            options.setStatusBarColor(ContextCompat.getColor(mFragmentActivity, android.R.color.black));
            options.setToolbarColor(ContextCompat.getColor(mFragmentActivity, android.R.color.black));
            options.setShowCropFrame(true);

            options.setAllowedGestures(UCropActivity.SCALE, UCropActivity.ROTATE, UCropActivity.ALL);
            UCrop.of(AlbumManager.obtainResult(data).get(0), Uri.fromFile(new File(getDiskCacheDir(mFragmentActivity),
                    System.currentTimeMillis() + ".jpg")))
                    .withOptions(options)
                    .withAspectRatio(3, 2)
                    .start(mFragmentActivity, UserHomePageFrag.this);
        } else if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
            final Uri resultUri = UCrop.getOutput(data);
            String path = resultUri.getPath();
            getPresenter().updatePicture(path);
        } else if (resultCode == UCrop.RESULT_ERROR) {
            final Throwable cropError = UCrop.getError(data);
            cropError.printStackTrace();
        }
        if (requestCode == REQUEST_USER_EDIT) {
            getPresenter().getUserInfo(mUserId);
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume(false);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
    }

    @Override
    public boolean onBackPressedSupport() {
        if (GSYVideoManager.backFromWindowFull(mFragmentActivity)) {
            return true;
        }
        return super.onBackPressedSupport();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (hidden) {
            GSYVideoManager.onPause();
        }
    }

    @NeedsPermission({Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    void NeedsPermission() {
        getPresenter().startSelectPicture(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        UserHomePageFragPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }

    @OnShowRationale({Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    void onShowRationale(final PermissionRequest request) {
        showRationaleDialog(R.string.permission_camera_rationale, request);
    }

    @Subscribe
    public void onShareResult(BaseResp resp) {
        getPresenter().setFindShareCount(mDynamicIdByIndex);
    }

    @Override
    public void onFindDel() {
        getPresenter().delFind(mDynamicIdByIndex);
    }

    @Override
    public void onShareCountResult() {
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }

    @Override
    public void onFindDelResult(ResultMsgBean result) {
        mFindInfoListAdapter.notifyItemRemoved(mRecordPosition);
        ToastUtils.showToast(mFragmentActivity, result.getResult());
        mRecordPosition = -1;
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/merchant/MerchantPicListPre.java<|end_filename|>
package com.scj.beilu.app.mvp.merchant;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.merchant.bean.MerchantPicInfoBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantPicInfoResultBean;
import com.scj.beilu.app.mvp.merchant.model.IMerchantInfo;
import com.scj.beilu.app.mvp.merchant.model.MerchantInfoImpl;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/15 23:37
 */
public class MerchantPicListPre extends BaseMvpPresenter<MerchantPicListPre.MerchantPicListView> {
    private IMerchantInfo mMerchantInfo;

    public MerchantPicListPre(Context context) {
        super(context, ShowConfig.LOADING_STATE, ShowConfig.ERROR_TOAST);
        mMerchantInfo = new MerchantInfoImpl(mBuilder);
    }

    public void getPicList(final int merchantId, final int regionId) {
        onceViewAttached(new ViewAction<MerchantPicListView>() {
            @Override
            public void run(@NonNull final MerchantPicListView mvpView) {
                mMerchantInfo.getMerchantPicListById(merchantId, regionId)
                        .subscribe(new BaseResponseCallback<MerchantPicInfoResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(MerchantPicInfoResultBean merchantPicInfoResultBean) {
                                try {
                                    ArrayList<MerchantPicInfoBean> regionPicList = merchantPicInfoResultBean.getRegionList();
                                    mvpView.onPicListResult(regionPicList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface MerchantPicListView extends MvpView {
        void onPicListResult(ArrayList<MerchantPicInfoBean> picInfoList);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/MineAccountManagerFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.mx.pro.lib.mvp.network.config.AppConfig;
import com.scj.beilu.app.R;
import com.scj.beilu.app.api.Constants;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.mine.MineAccountManagerPre;
import com.scj.beilu.app.mvp.user.entity.UserInfoEntity;
import com.scj.beilu.app.mvp.wechat.bean.WeChatTokenBean;
import com.scj.beilu.app.ui.act.SetSystemAct;
import com.scj.beilu.app.util.ToastUtils;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

/**
 * @author Mingxun
 * @time on 2019/4/12 20:49
 */
public class MineAccountManagerFrag extends BaseMvpFragment<MineAccountManagerPre.MineAccountManagerView,
        MineAccountManagerPre> implements MineAccountManagerPre.MineAccountManagerView, View.OnClickListener {

    private TextView mTvAccountTel, mTvWxName;
    private Button mButton, mButton1;
    private TextView mTvLogout;
    private boolean bindTel, bindWx;

    private IWXAPI api;
    public static final int REQUEST_CODE = 1010;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EventBus.getDefault().register(this);
    }

    @Override
    public MineAccountManagerPre createPresenter() {
        return new MineAccountManagerPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_account_manager;
    }

    @Override
    public void initView() {
        super.initView();
        mTvAccountTel = findViewById(R.id.tv_account_name);
        mTvWxName = findViewById(R.id.tv_account_name1);
        mButton = findViewById(R.id.button);
        mButton1 = findViewById(R.id.button1);
        mTvLogout = findViewById(R.id.tv_log_out);

        mButton.setOnClickListener(this);
        mButton1.setOnClickListener(this);
        mTvLogout.setOnClickListener(this);

    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getUserInfo();
    }

    @Override
    public void onUserInfo(UserInfoEntity userInfo) {
        String userTel = userInfo.getUserTel();
        if (userTel != null && userTel.length() != 0) {
            mTvAccountTel.setText(userTel);
            bindTel = true;
            mButton.setText("已绑定");
        } else {
            mTvAccountTel.setText("未绑定");
            mButton.setText("立即绑定");
            bindTel = false;
        }
        String openId = userInfo.getOpenId();
        if (openId != null && openId.length() != 0) {
            mTvWxName.setText(userInfo.getUserNickName());
            bindWx = true;
            mButton1.setText("已绑定");
        } else {
            mTvWxName.setText("未绑定");
            mButton1.setText("立即绑定");
            bindWx = false;
        }
    }

    @Override
    public void onBindResult(String result) {
        ToastUtils.showToast(mFragmentActivity, result);
        getPresenter().getUserInfo();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:
                if (bindTel) {

                } else {
                    Intent intent = new Intent(mFragmentActivity, MineBindPhoneAct.class);
                    startActivityForResult(intent, REQUEST_CODE);
                }
                break;
            case R.id.button1:

                if (bindWx) {

                } else {

                    if (api == null) {
                        api = WXAPIFactory.createWXAPI(mFragmentActivity, Constants.WXAPPID, false);
                    }

                    final SendAuth.Req req = new SendAuth.Req();
                    req.scope = "snsapi_userinfo";
                    req.state = "none";
                    api.sendReq(req);
                }
                break;
            case R.id.tv_log_out:
                new AlertDialog.Builder(mFragmentActivity)
                        .setPositiveButton(R.string.button_sure, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(@NonNull DialogInterface dialog, int which) {
                                SharedPreferences sharedPreferences = mFragmentActivity.getSharedPreferences(AppConfig.PREFS_NAME, Context.MODE_PRIVATE);
                                SharedPreferences.Editor clear = sharedPreferences.edit().clear();
                                clear.apply();
                                mFragmentActivity.setResult(SetSystemAct.LOGIN_OUT);
                                mFragmentActivity.finish();
                            }
                        })
                        .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(@NonNull DialogInterface dialog, int which) {
                                dialog.cancel();
                            }
                        })
                        .setCancelable(false)
                        .setMessage("确认退出登录？")
                        .show();
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe
    public void startBindingWxInfo(WeChatTokenBean tokenBean) {
        getPresenter().bindWxAccount(tokenBean.getOpenid());
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == requestCode) {
            getPresenter().getUserInfo();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/preview/FitRecordAlbumPreviewFrag.java<|end_filename|>
package com.scj.beilu.app.ui.preview;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.mvp.fit.bean.FitRecordImgInfoBean;

import it.sephiroth.android.library.imagezoom.ImageViewTouch;
import it.sephiroth.android.library.imagezoom.ImageViewTouchBase;

/**
 * @author Mingxun
 * @time on 2019/3/15 17:14
 */
public class FitRecordAlbumPreviewFrag extends SupportFragment {

    private onViewClickListener mListener;
    private FitRecordImgInfoBean mImgInfoBean;
    private static final String IMG_INFO = "IMG_INFO";

    public interface onViewClickListener {
        void onClick(int position);
    }

    public static FitRecordAlbumPreviewFrag newInstance(FitRecordImgInfoBean imgInfo) {

        Bundle args = new Bundle();
        args.putParcelable(IMG_INFO, imgInfo);
        FitRecordAlbumPreviewFrag fragment = new FitRecordAlbumPreviewFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof onViewClickListener) {
            mListener = (onViewClickListener) context;
        } else {
            throw new RuntimeException(context.toString()
                    + " must implement onViewClickListener");
        }
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mImgInfoBean = arguments.getParcelable(IMG_INFO);
        }
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_fit_record_album_preview;
    }

    @Override
    public void initView() {
        super.initView();

        ImageViewTouch image = findViewById(R.id.image_view);
        image.setDisplayType(ImageViewTouchBase.DisplayType.FIT_TO_SCREEN);

        if (mImgInfoBean == null) return;
        image.setSingleTapListener(new ImageViewTouch.OnImageViewTouchSingleTapListener() {
            @Override
            public void onSingleTapConfirmed() {
                if (mListener != null) {
                    mListener.onClick(-1);
                }
            }
        });

        GlideRequest<Bitmap> thumbnail = GlideApp.with(this)
                .asBitmap();
        GlideRequest<Bitmap> original = GlideApp.with(this)
                .asBitmap();

        original
                .load(mImgInfoBean.getPicOrgAddr())
                .thumbnail(thumbnail.load(mImgInfoBean.getPicComAddr()))
                .apply(new RequestOptions()
                        .priority(Priority.HIGH)
                        .fitCenter())
                .into(image);

    }


    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/order/OrderManagerAct.java<|end_filename|>
package com.scj.beilu.app.ui.order;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.mvp.mine.order.OrderManagerPre;
import com.scj.beilu.app.ui.order.adapter.OrderManagerPagerAdapter;

/**
 * @author Mingxun
 * @time on 2019/1/15 21:11
 */
public class OrderManagerAct extends BaseMvpActivity<OrderManagerPre.OrderManagerView, OrderManagerPre>
        implements OrderManagerPre.OrderManagerView {

    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private OrderManagerPagerAdapter mOrderManagerPagerAdapter;

    private static final String[] mTabs = {"全部", "待付款", "退款中", "已完成"};

    public static void startOrderManagerAct(Activity activity) {
        Intent intent = new Intent(activity, OrderManagerAct.class);
        activity.startActivity(intent);
    }

    @Override
    public int getLayout() {
        return R.layout.act_order_manager;
    }

    @Override
    public void initView() {
        super.initView();
        mViewPager = findViewById(R.id.view_pager_order_manager);
        mTabLayout = findViewById(R.id.tab_order_manager);
        mTabLayout.setupWithViewPager(mViewPager);


        mOrderManagerPagerAdapter = new OrderManagerPagerAdapter(getSupportFragmentManager());
        mOrderManagerPagerAdapter.setTabs(mTabs);
        mViewPager.setAdapter(mOrderManagerPagerAdapter);

        mTabLayout.getTabAt(0).setCustomView(getPresenter().getTabLayout("全部"));
        mTabLayout.getTabAt(1).setCustomView(getPresenter().getTabLayout("待付款"));
        mTabLayout.getTabAt(2).setCustomView(getPresenter().getTabLayout("退款"));
        mTabLayout.getTabAt(3).setCustomView(getPresenter().getTabLayout("已完成"));


        getPresenter().setTabSelector(mTabLayout.getTabAt(0), true);

        mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                getPresenter().setTabSelector(tab, true);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                getPresenter().setTabSelector(tab, false);
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        mViewPager.setOffscreenPageLimit(4);
    }

    @NonNull
    @Override
    public OrderManagerPre createPresenter() {
        return new OrderManagerPre(this);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/store/adapter/GoodsListPagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.store.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.scj.beilu.app.mvp.store.bean.GoodsCategoryInfoBean;
import com.scj.beilu.app.ui.store.StoreGoodsListFrag;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/3 16:53
 */
public class GoodsListPagerAdapter extends FragmentPagerAdapter {

    private ArrayList<GoodsCategoryInfoBean> mGoodsCategoryInfoBeans;

    public void setGoodsCategoryInfoBeans(ArrayList<GoodsCategoryInfoBean> goodsCategoryInfoBeans) {
        mGoodsCategoryInfoBeans = goodsCategoryInfoBeans;
        notifyDataSetChanged();
    }

    public GoodsListPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        return StoreGoodsListFrag.newInstance(mGoodsCategoryInfoBeans.get(i).getProductCateId());
    }

    @Override
    public int getCount() {
        return mGoodsCategoryInfoBeans == null ? 0 : mGoodsCategoryInfoBeans.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/adapter/NewsAttentionAuthorListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.news.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.bean.NewsAuthorInfoBean;
import com.scj.beilu.app.ui.news.NewsAttentionListFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/5/11 17:46
 * 關注的作者列表
 */
public class NewsAttentionAuthorListAdapter extends RecyclerView.Adapter<NewsAttentionAuthorListAdapter.AuthorViewHolder> {
    private List<NewsAuthorInfoBean> authorInfoList;
    private GlideRequest<Drawable> mOriginalRequest;
    private GlideRequest<Drawable> mThumbnailRequest;
    private OnItemClickListener mOnItemClickListener;

    public NewsAttentionAuthorListAdapter(NewsAttentionListFrag frag) {
        mOriginalRequest = GlideApp.with(frag).asDrawable().optionalCircleCrop();
        mThumbnailRequest = GlideApp.with(frag).asDrawable().optionalCircleCrop();
    }

    public void setAuthorInfoList(List<NewsAuthorInfoBean> authorInfoList) {
        this.authorInfoList = authorInfoList;
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public AuthorViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_news_my_attention_content, parent, false);
        return new AuthorViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull AuthorViewHolder holder, int position) {
        try {
            if (position == 3) {
                mOriginalRequest.load(R.drawable.ic_my_attiontion_more)
                        .into(holder.iv_news_my_attention_author);
                holder.tv_news_author_name.setText("我的关注");
            } else {
                NewsAuthorInfoBean authorInfoBean = authorInfoList.get(position);
                mOriginalRequest.load(authorInfoBean.getUserOriginalHead())
                        .thumbnail(mThumbnailRequest.load(authorInfoBean.getUserCompressionHead()))
                        .into(holder.iv_news_my_attention_author);
                holder.tv_news_author_name.setText(authorInfoBean.getUserNickName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        if (authorInfoList == null) {
            return 0;
        } else if (authorInfoList.size() > 3) {
            return 4;
        } else {
            return authorInfoList.size();
        }
    }

    class AuthorViewHolder extends BaseViewHolder {
        ImageView iv_news_my_attention_author;
        TextView tv_news_author_name;

        public AuthorViewHolder(View itemView) {
            super(itemView);
            iv_news_my_attention_author = findViewById(R.id.iv_news_my_attention_author);
            tv_news_author_name = findViewById(R.id.tv_news_author_name);
            iv_news_my_attention_author.setOnClickListener(view -> {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClick(getAdapterPosition(), authorInfoList.get(getAdapterPosition()), view);
                }
            });
        }
    }


}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/delegate/FragmentMvpDelegate.java<|end_filename|>
package com.mx.pro.lib.mvp.delegate;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;

import com.mx.pro.lib.mvp.MvpPresenter;
import com.mx.pro.lib.mvp.MvpView;


/**
 * A delegate for Fragments to attach them to project mvp.
 * <p>
 * The following methods must be invoked from the corresponding Fragments lifecycle methods:
 *
 * <ul>
 * <li>{@link #onCreate(Bundle)}</li>
 * <li>{@link #onDestroy()}</li>
 * <li>{@link #onPause()} </li>
 * <li>{@link #onResume()} </li>
 * <li>{@link #onStart()} </li>
 * <li>{@link #onStop()} </li>
 * <li>{@link #onViewCreated(View, Bundle)} </li>
 * <li>{@link #onActivityCreated(Bundle)} </li>
 * <li>{@link #onSaveInstanceState(Bundle)} </li>
 * <li>{@link #onAttach(Activity)} </li>
 * <li>{@link #onDetach()}</li>
 * <li></li>
 * </ul>
 * </p>
 */
public interface FragmentMvpDelegate<V extends MvpView, P extends MvpPresenter<V>> {
    /**
     * Must be called from {@link Fragment#onCreate(Bundle)}
     */
    void onCreate(Bundle savedInstanceState);

    /**
     * {@link Fragment#onDestroy()}
     */
    void onDestroy();

    /**
     * {@link Fragment#onViewCreated(View, Bundle)}
     */
    void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState);

    /**
     * {@link Fragment#onDestroyView()}
     */
    void onDestroyView();

    /**
     * {@link Fragment#onPause()}
     */
    void onPause();

    /**
     * {@link Fragment#onResume()}
     */
    void onResume();

    /**
     * {@link Fragment#onStart()}
     */
    void onStart();

    /**
     * {@link Fragment#onStop()}
     */
    void onStop();

    /**
     * {@link Fragment#onActivityCreated(Bundle)}
     */
    void onActivityCreated(@Nullable Bundle savedInstanceState);

    /**
     * {@link Fragment#onAttach(Activity)}
     */
    void onAttach(Activity activity);

    /**
     * {@link Fragment#onDetach()}
     */
    void onDetach();

    /**
     * {@link Fragment#onSaveInstanceState(Bundle)}
     */
    void onSaveInstanceState(@NonNull Bundle outState);
}



<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/MoreIssueAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/7
 * descriptin:
 */
public class MoreIssueAdapter extends RecyclerView.Adapter<MoreIssueAdapter.FindIssueHolder> {
    @NonNull
    @Override
    public FindIssueHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_issue, parent, false);
        return new FindIssueHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull FindIssueHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 2;
    }

    class FindIssueHolder extends BaseViewHolder {
        public FindIssueHolder(View itemView) {
            super(itemView);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/HomeSearchParentFrag.java<|end_filename|>
package com.scj.beilu.app.ui.home;

import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.home.HomeSearchTabPre;
import com.scj.beilu.app.mvp.home.bean.EventSearchTypeBean;
import com.scj.beilu.app.ui.home.adapter.HomeSearchPagerAdapter;
import com.scj.beilu.app.widget.ClearEditText;

/**
 * @author Mingxun
 * @time on 2019/4/12 02:48
 */
public class HomeSearchParentFrag extends BaseMvpFragment<HomeSearchTabPre.HomeSearchTabView, HomeSearchTabPre>
        implements HomeSearchTabPre.HomeSearchTabView, TextWatcher, ViewPager.OnPageChangeListener {

    private ClearEditText mClearEditText;
    private TextView mTvCancel;
    private ViewPager mViewPager;
    private TabLayout mTabLayout;
    private HomeSearchPagerAdapter mHomeSearchPagerAdapter;

    private final String[] mTitles = {"动态", "资讯", "商品", "用户"};
    private final String[] mEtHint = {"搜索动态", "搜索资讯", "搜索商品", "搜索用户"};
    private int mPosition = 0;

    @Override
    public HomeSearchTabPre createPresenter() {
        return new HomeSearchTabPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_home_search;
    }

    @Override
    public void initView() {
        super.initView();
        ImmersionBar.with(this)
                .statusBarDarkFont(true,0.2f)
                .titleBar(R.id.top_view)
                .keyboardEnable(true)
                .init();
        mViewPager = findViewById(R.id.view_pager_search_content);
        mTabLayout = findViewById(R.id.tab_msg_manager);
        mClearEditText = findViewById(R.id.et_search_content);
        mTvCancel = findViewById(R.id.tv_cancel);

        mTabLayout.setupWithViewPager(mViewPager);

        mHomeSearchPagerAdapter = new HomeSearchPagerAdapter(getChildFragmentManager());
        mHomeSearchPagerAdapter.setTitles(mTitles);
        mViewPager.setAdapter(mHomeSearchPagerAdapter);

        mViewPager.setOffscreenPageLimit(mTabLayout.getTabCount());

        int count = mTabLayout.getTabCount();
        for (int i = 0; i < count; i++) {
            mTabLayout.getTabAt(i).setCustomView(getPresenter().getTabLayout(mTitles[i]));
        }

        getPresenter().setTabSelector(mTabLayout.getTabAt(0), true);

        mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                getPresenter().setTabSelector(tab, true);
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                getPresenter().setTabSelector(tab, false);
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        mClearEditText.addTextChangedListener(this);
        mTvCancel.setOnClickListener(v -> mFragmentActivity.onBackPressed());
        mViewPager.addOnPageChangeListener(this);
        mClearEditText.setHint(mEtHint[0]);
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        getPresenter().startSearch(new EventSearchTypeBean(mPosition, s.toString()));
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        mPosition = position;
        mClearEditText.setHint(mEtHint[position]);
        getPresenter().startSearch(new EventSearchTypeBean(mPosition, mClearEditText.getText().toString()));
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/fit/FitRecordGirthFrag.java<|end_filename|>
package com.scj.beilu.app.ui.fit;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.fit.FitRecordGirthPre;
import com.scj.beilu.app.mvp.fit.bean.FitRecordGirthInfoBean;
import com.scj.beilu.app.ui.dialog.RuleViewDialog;
import com.scj.beilu.app.ui.fit.adapter.FitRecordGirthListAdapter;
import com.scj.beilu.app.util.ToastUtils;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/11 20:11
 * 添加围度
 */
public class FitRecordGirthFrag extends BaseMvpFragment<FitRecordGirthPre.FitRecordGirthView, FitRecordGirthPre>
        implements FitRecordGirthPre.FitRecordGirthView, OnItemClickListener<FitRecordGirthInfoBean>, RuleViewDialog.OnGirth {

    private FitRecordGirthListAdapter mFitRecordGirthListAdapter;
    private FitRecordGirthInfoBean mGirthInfoBean;
    private int mPosition = -1;
    public static final int GIRTH_REQUEST = 0x001;
    public static final int GIRTH_ADD_RESULT_OK = 0x100;

    @Override
    public FitRecordGirthPre createPresenter() {
        return new FitRecordGirthPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_fit_record_girth;
    }

    @Override
    public void initView() {
        super.initView();

        mFitRecordGirthListAdapter = new FitRecordGirthListAdapter(mFragmentActivity);
        mFitRecordGirthListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mFitRecordGirthListAdapter);

        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getFitRecordInfo();
    }

    @Override
    public void onGirthListResult(List<FitRecordGirthInfoBean> girthInfoBeans) {
        mFitRecordGirthListAdapter.setFitRecordGirthInfoBeanList(girthInfoBeans);
    }

    @Override
    public void onAddResult(String result) {
        ToastUtils.showToast(mFragmentActivity, result);
        setFragmentResult(GIRTH_ADD_RESULT_OK, null);
        if (mPosition != -1) {
            mFitRecordGirthListAdapter.notifyItemChanged(mPosition);
        }
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onItemClick(int position, FitRecordGirthInfoBean entity, View view) {
        mPosition = position;
        mGirthInfoBean = entity;
        RuleViewDialog dialog = RuleViewDialog.newInstance(mGirthInfoBean.getUnit());
        dialog.setOnGirth(this);
        dialog.show(getChildFragmentManager(), "tag");
    }

    @Override
    public void onGirthVal(float val) {
        if (mGirthInfoBean == null) return;
        getPresenter().addFitRecord(mPosition, mGirthInfoBean.getRecordKey(), val);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/widget/SquareCardView.java<|end_filename|>
package com.scj.beilu.app.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;
import android.util.AttributeSet;

/**
 * @author Mingxun
 * @time on 2019/2/19 16:41
 */
public class SquareCardView extends CardView {
    public SquareCardView(@NonNull Context context) {
        this(context, null);
    }

    public SquareCardView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SquareCardView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, widthMeasureSpec);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/EditPhotoAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;

import java.util.List;

/**
 * author:SunGuiLan
 * date:2019/2/2
 * descriptin:编辑
 */
public class EditPhotoAdapter extends RecyclerView.Adapter<EditPhotoAdapter.EditPhotoHolder> {

    private List<Uri> mImagePath = null;
    private GlideRequests mGlideRequests;
    private OnItemClickListener mOnItemClickListener;
    private final int mMaxCount;
    private onNotifyListener mOnNotifyListener;

    public interface onNotifyListener {
        void onImageSize(int size);
    }

    public EditPhotoAdapter(onNotifyListener notifyListener, GlideRequests requests, int maxCount) {
        mOnNotifyListener = notifyListener;
        mGlideRequests = requests;
        this.mMaxCount = maxCount;
    }

    public void setImagePath(List<Uri> imagePath) {
        mImagePath = imagePath;
        if (mOnNotifyListener != null) {
            mOnNotifyListener.onImageSize(imagePath.size());
        }
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public EditPhotoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_editephoto, parent, false);
        return new EditPhotoHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull EditPhotoHolder holder, int position) {
        int size = position + 1;
        if (mImagePath == null || ((mImagePath != null && getItemCount() == (size)))) {
            if (mImagePath.size() == mMaxCount) {
                holder.mIvDel.setVisibility(View.VISIBLE);
                mGlideRequests.load(mImagePath.get(position))
                        .optionalCenterCrop()
                        .into(holder.mIvImage);
            } else {
                holder.mIvDel.setVisibility(View.GONE);
                mGlideRequests.load(R.drawable.ic_add)
                        .optionalCenterCrop()
                        .into(holder.mIvImage);
            }
        } else {
            holder.mIvDel.setVisibility(View.VISIBLE);
            mGlideRequests.load(mImagePath.get(position))
                    .optionalCenterCrop()
                    .into(holder.mIvImage);
        }
    }

    @Override
    public int getItemCount() {
        int size = mImagePath.size();
        if (mImagePath == null) {
            return 1;
        } else if (size == mMaxCount) {
            return size;
        } else {
            return size + 1;
        }
    }


    class EditPhotoHolder extends BaseViewHolder {
        private ImageView mIvImage;
        private ImageView mIvDel;

        public EditPhotoHolder(View itemView) {
            super(itemView);
            mIvImage = findViewById(R.id.iv_publish_image);
            mIvDel = findViewById(R.id.iv_del_image);
            mIvDel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), null, v);
                    }
                }
            });
            mIvImage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener == null) return;
                    if (mImagePath == null || (mImagePath != null && getItemCount() == (getAdapterPosition() + 1)) && getItemCount() != 9) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), null, v);
                    } else {
                        if (mImagePath.size() == getAdapterPosition()) {
                            mOnItemClickListener.onItemClick(getAdapterPosition(), null, v);
                        } else {
                            Uri uri = mImagePath.get(getAdapterPosition());
                            mOnItemClickListener.onItemClick(getAdapterPosition(), uri, v);
                        }
                    }
                }
            });
        }
    }
}



<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/seller/PopLeftAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter.seller;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.home.bean.LeftViewItemBean;

import java.util.List;


/**
 * @类名：
 * @描述：左边列表适配器
 * @Created by lm on 2017/3/7.
 */

public class PopLeftAdapter extends RecyclerView.Adapter<PopLeftAdapter.LeftHolder> {
    private Context context;
    private List<LeftViewItemBean> list;//数据源
    private int selectedPosition = 0;//选中第几行，默认选中第0行
    private OnItemClickListener mOnItemClickListener;//item的点击事件

    public PopLeftAdapter(Context context, List<LeftViewItemBean> list) {
        this.context = context;
        this.list = list;
    }


    @NonNull
    @Override
    public LeftHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_pop_left, parent,false);
        return new LeftHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull final LeftHolder holder, int position) {
        LeftHolder leftHolder = (LeftHolder) holder;
        //选中和没选中时，设置不同的颜色
        if (position == selectedPosition) {
            leftHolder.itemView.setBackgroundColor(Color.parseColor("#fff9f9f9"));

            leftHolder.nameTV.setTextColor(Color.parseColor("#32B9AA"));
            leftHolder.left_line.setVisibility(View.VISIBLE);
        } else {
            leftHolder.itemView.setBackgroundColor(Color.parseColor("#ffffff"));

            leftHolder.nameTV.setTextColor(Color.parseColor("#7A7A7A"));
            leftHolder.left_line.setVisibility(View.INVISIBLE);
        }

        leftHolder.nameTV.setText(list.get(position).getName());
        //判断是否设置了监听器
        if (mOnItemClickListener != null) {
            //为ItemView设置监听器
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int position = holder.getLayoutPosition(); // 1
                    mOnItemClickListener.onItemClick(holder.itemView, position); // 2
                }
            });
        }
    }


    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }


    /**
     * @param设置选中第几行
     */
    public void setSelectedPosition(int selectedPosition) {
        this.selectedPosition = selectedPosition;
    }

    /**
     * @return获取左侧列表选中的是哪一行
     */
    public int getSelectedPosition() {
        return selectedPosition;
    }

    public class LeftHolder extends BaseViewHolder {
        private TextView nameTV;//名字
        private ImageView left_line;

        public LeftHolder(View itemView) {
            super(itemView);
            nameTV = findViewById(R.id.left_item_name);
            left_line = findViewById(R.id.left_color);

        }
    }
    /**
     * 点击事件接口
     */
    public interface OnItemClickListener {
        void onItemClick(View view, int position);
    }

    public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
        this.mOnItemClickListener = mOnItemClickListener;
    }

}



<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/NewsAuthorInfoFrag.java<|end_filename|>
package com.scj.beilu.app.ui.news;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.NewsAuthorInfoPre;
import com.scj.beilu.app.mvp.news.bean.NewsAuthorInfoBean;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.ui.news.adapter.NewsListAdapter;
import com.scj.beilu.app.widget.DividerItemDecorationToPadding;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/5/13 12:08
 */
public class NewsAuthorInfoFrag extends BaseMvpFragment<NewsAuthorInfoPre.NewsAuthorInfoView, NewsAuthorInfoPre>
        implements NewsAuthorInfoPre.NewsAuthorInfoView, OnItemClickListener, View.OnClickListener,
        NestedScrollView.OnScrollChangeListener {

    private NestedScrollView nested_scroll_view;
    private ImageView iv_news_author_avatar;
    private TextView tv_news_author_name, tv_news_author_fans_count, tv_news_author_attention_status, tv_news_author_desc;
    private TextView menu_tv_news_author_attention_status;
    private RecyclerView recy_author_news_list;
    private View view_divider;
    private NewsListAdapter mNewsListAdapter;
    private int mDividerLocation;

    private static final String AUTHOR_ID = "author_id";
    private int mAuthorId;

    public static NewsAuthorInfoFrag newInstance(int authorId) {

        Bundle args = new Bundle();
        args.putInt(AUTHOR_ID, authorId);
        NewsAuthorInfoFrag fragment = new NewsAuthorInfoFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mAuthorId = arguments.getInt(AUTHOR_ID);
        }
    }

    @Override
    public NewsAuthorInfoPre createPresenter() {
        return new NewsAuthorInfoPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_news_author_info;
    }

    @Override
    public void initView() {
        super.initView();
        nested_scroll_view = findViewById(R.id.nested_scroll_view);
        iv_news_author_avatar = findViewById(R.id.iv_news_author_avatar);
        tv_news_author_name = findViewById(R.id.tv_news_author_name);
        tv_news_author_fans_count = findViewById(R.id.tv_news_author_fans_count);
        tv_news_author_attention_status = findViewById(R.id.tv_news_author_attention_status);
        tv_news_author_desc = findViewById(R.id.tv_news_author_desc);
        recy_author_news_list = findViewById(R.id.recy_author_news_list);
        view_divider = findViewById(R.id.view_divider);
        mNewsListAdapter = new NewsListAdapter(mFragmentActivity, GlideApp.with(this));
        mNewsListAdapter.setOnItemClickListener(this);
        recy_author_news_list.setAdapter(mNewsListAdapter);

        tv_news_author_attention_status.setOnClickListener(this);
        recy_author_news_list.addItemDecoration(new DividerItemDecorationToPadding(mFragmentActivity, DividerItemDecoration.VERTICAL));

        getPresenter().getAuthorInfo(mAuthorId);
        nested_scroll_view.setOnScrollChangeListener(this);
    }

    @Override
    public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
        if (mDividerLocation <= scrollY) {
            if (mAppToolbar.mTitleTextView.getVisibility() == View.GONE) {
                mAppToolbar.mTitleTextView.setVisibility(View.VISIBLE);
                menu_tv_news_author_attention_status.setVisibility(View.VISIBLE);
                mAppToolbar.setToolbarTitle(tv_news_author_name.getText());
            }
        } else {
            if (mAppToolbar.mTitleTextView.getVisibility() == View.VISIBLE) {
                menu_tv_news_author_attention_status.setVisibility(View.GONE);
                mAppToolbar.mTitleTextView.setVisibility(View.GONE);
            }
        }
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getNewsList(mAuthorId, mCurrentPage);
    }

    @Override
    public void onAuthorInfo(NewsAuthorInfoBean authorInfoBean) {
        try {
            GlideApp.with(this)
                    .load(authorInfoBean.getUserOriginalHead())
                    .thumbnail(GlideApp.with(this).load(authorInfoBean.getUserCompressionHead()).optionalCircleCrop())
                    .optionalCircleCrop()
                    .into(iv_news_author_avatar);
            tv_news_author_name.setText(authorInfoBean.getUserNickName());
            int count = authorInfoBean.getFansCount();
            int fansOut = count / 10000;
            String countStr;
            if (fansOut > 0) {
                countStr = fansOut + "万";
            } else {
                countStr = count + "";
            }
            tv_news_author_fans_count.setText(countStr);
            tv_news_author_attention_status.setVisibility(View.VISIBLE);
            tv_news_author_attention_status.setText(authorInfoBean.getIsFocus() == 1 ? "已关注" : "+ 关注");
            tv_news_author_attention_status.setSelected(authorInfoBean.getIsFocus() == 1);
            String desc = "无";
            if (authorInfoBean.getUserBrief() != null && authorInfoBean.getUserBrief().length() > 0) {
                desc = authorInfoBean.getUserBrief();
            }
            tv_news_author_desc.setText(desc);

            view_divider.post(() -> {
                int[] location = new int[2];
                view_divider.getLocationInWindow(location);
                mDividerLocation = location[1] - mAppToolbar.getHeight();
            });

            mAppToolbar.inflateMenu(R.menu.menu_attention_status);
            if (menu_tv_news_author_attention_status == null) {
                menu_tv_news_author_attention_status = mAppToolbar.findViewById(R.id.menu_tv_news_author_attention_status);
            }

            menu_tv_news_author_attention_status.setVisibility(View.GONE);
            menu_tv_news_author_attention_status.setText(authorInfoBean.getIsFocus() == 1 ? "已关注" : "+ 关注");
            menu_tv_news_author_attention_status.setSelected(authorInfoBean.getIsFocus() == 1);
            menu_tv_news_author_attention_status.setOnClickListener(this);
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

    @Override
    public void onNewsList(List<NewsInfoBean> newsInfoList) {
        mNewsListAdapter.setNewsListEntityList(newsInfoList);
    }

    @Override
    public void onAttentionResult(String result) {
        boolean selected = tv_news_author_attention_status.isSelected();
        tv_news_author_attention_status.setSelected(!selected);
        tv_news_author_attention_status.setText(!selected ? "已关注" : "+ 关注");

        menu_tv_news_author_attention_status.setSelected(!selected);
        menu_tv_news_author_attention_status.setText(!selected ? "已关注" : "+ 关注");
        mFragmentActivity.setResult(Activity.RESULT_OK);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        NewsInfoBean infoBean = (NewsInfoBean) entity;
        NewsDetailsAct.startNewsDetailsAct(mFragmentActivity, infoBean);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_news_author_attention_status:
            case R.id.menu_tv_news_author_attention_status:
                getPresenter().setAttentionAuthor(mAuthorId);
                break;

        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/adapter/MerchantListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.merchant.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.constraint.ConstraintLayout;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoBean;
import com.scj.beilu.app.ui.merchant.MerchantListFrag;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/13 19:11
 */
public class MerchantListAdapter extends RecyclerView.Adapter<MerchantListAdapter.MerchantInfoViewHolder> {

    private List<MerchantInfoBean> mMerchantInfoList;
    private OnItemClickListener<MerchantInfoBean> mOnItemClickListener;
    private GlideRequest<Drawable> mOriginal;
    private GlideRequest<Drawable> mThumbnail;

    public MerchantListAdapter(MerchantListFrag frag) {
        mOriginal = GlideApp.with(frag).asDrawable().optionalCenterCrop();
        mThumbnail = GlideApp.with(frag).asDrawable().optionalCenterCrop();
    }

    public void setOnItemClickListener(OnItemClickListener<MerchantInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setMerchantInfoList(List<MerchantInfoBean> merchantInfoList) {
        mMerchantInfoList = merchantInfoList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public MerchantInfoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_merchant_content, parent, false);
        return new MerchantInfoViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MerchantInfoViewHolder holder, int position) {
        try {
            MerchantInfoBean merchantInfo = mMerchantInfoList.get(position);
            mOriginal.load(merchantInfo.getMerchantPicAddr())
                    .thumbnail(mThumbnail.load(merchantInfo.getMerchantPicAddrZip()))
                    .into(holder.mIvMerchantImg);
            holder.mTvMerchantName.setText(merchantInfo.getMerchantName());
            holder.mTvMerchantAddress.setText(merchantInfo.getMerchantAddr());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mMerchantInfoList == null ? 0 : mMerchantInfoList.size();
    }

    public class MerchantInfoViewHolder extends BaseViewHolder {

        private ConstraintLayout mClMerchantParent;
        private ImageView mIvMerchantImg;
        private TextView mTvMerchantName, mTvMerchantAddress;

        public MerchantInfoViewHolder(View itemView) {
            super(itemView);
            mClMerchantParent = findViewById(R.id.cl_merchant_parent);
            mIvMerchantImg = findViewById(R.id.iv_merchant_img);
            mTvMerchantName = findViewById(R.id.tv_merchant_name);
            mTvMerchantAddress = findViewById(R.id.tv_merchant_address);
            mClMerchantParent.setOnClickListener(v -> {

                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClick(getAdapterPosition(), mMerchantInfoList.get(getAdapterPosition()), v);
                }
            });
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/order/adapter/OrderLogisticsListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.order.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.mvp.order.bean.OrderLogisticsInfoBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/8 22:27
 */
public class OrderLogisticsListAdapter extends RecyclerView.Adapter<OrderLogisticsListAdapter.LogisticsViewHolder> {

    private List<OrderLogisticsInfoBean> mLogisticsInfoBeans;

    public void setLogisticsInfoBeans(List<OrderLogisticsInfoBean> logisticsInfoBeans) {
        mLogisticsInfoBeans = logisticsInfoBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public LogisticsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_logistics_content, parent, false);
        return new LogisticsViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull LogisticsViewHolder holder, int position) {
        try {
            OrderLogisticsInfoBean infoBean = mLogisticsInfoBeans.get(position);
            holder.mTvLogisticName.setText(infoBean.getRemark());
            holder.mTvLogisticDate.setText(infoBean.getDatetime());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mLogisticsInfoBeans == null ? 0 : mLogisticsInfoBeans.size();
    }

    public class LogisticsViewHolder extends BaseViewHolder {
        private TextView mTvLogisticName;
        private TextView mTvLogisticDate;

        public LogisticsViewHolder(View itemView) {
            super(itemView);
            mTvLogisticName = findViewById(R.id.tv_logistic_name);
            mTvLogisticDate = findViewById(R.id.tv_logistic_date);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/home/adapter/seller/HomeFacilityAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.home.adapter.seller;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/16
 * descriptin:
 */
public class HomeFacilityAdapter extends RecyclerView.Adapter<HomeFacilityAdapter.HomeFacilityViewHolder> {
    @NonNull
    @Override
    public HomeFacilityViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_seller_facility, parent, false);
        return new HomeFacilityViewHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull HomeFacilityViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 8;
    }

    public class HomeFacilityViewHolder extends BaseViewHolder {

        public HomeFacilityViewHolder(View itemView) {
            super(itemView);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/home/HomeSearchUserPre.java<|end_filename|>
package com.scj.beilu.app.mvp.home;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.base.BaseCheckArrayView;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.home.model.HomeInfoImpl;
import com.scj.beilu.app.mvp.mine.bean.FocusUserInfoBean;
import com.scj.beilu.app.mvp.mine.bean.MeFocusListBean;
import com.scj.beilu.app.mvp.mine.model.IMine;
import com.scj.beilu.app.mvp.mine.model.MineImpl;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;
import io.reactivex.subjects.PublishSubject;

/**
 * @author Mingxun
 * @time on 2019/4/12 02:07
 */
public class HomeSearchUserPre extends BaseMvpPresenter<HomeSearchUserPre.HomeSearchView> {

    private PublishSubject<String> mPublishSubject;

    private HomeInfoImpl mHomeInfo;
    private IMine mIMe;
    private final List<FocusUserInfoBean> mFocusList = new ArrayList<>();

    public HomeSearchUserPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mHomeInfo = new HomeInfoImpl(mBuilder);
        mIMe = new MineImpl(mBuilder);
    }

    public void startSearch(final String keyName, final int currentPage) {
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull HomeSearchView mvpView) {
                if (mPublishSubject == null) {
                    mPublishSubject = PublishSubject.create();
                    mPublishSubject.debounce(1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
                            .filter(new Predicate<String>() {
                                @Override
                                public boolean test(String s) throws Exception {
                                    return s.length() > 0;
                                }
                            })

                            .switchMap(new Function<String, Observable<String>>() {
                                @Override
                                public Observable<String> apply(String s) throws Exception {
                                    return mHomeInfo.content(s);
                                }
                            })
                            .subscribe(new ObserverCallback<String>(mBuilder.build(mvpView)) {
                                @Override
                                public void onNext(String keyName) {
                                    searchUserInfoList(keyName, currentPage);
                                }
                            });

                }

                mPublishSubject.onNext(keyName);
            }
        });
    }


    public void searchUserInfoList(final String keyName, final int currentPage) {
        mBuilder.setLoadType(ShowConfig.LOADING_REFRESH);

        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull final HomeSearchView mvpView) {
                mHomeInfo.startSearchUser(currentPage, keyName)
                        .subscribe(new BaseResponseCallback<MeFocusListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(MeFocusListBean meFocusBean) {
                                try {
                                    List<FocusUserInfoBean> list = meFocusBean.getPage().getList();
                                    if (currentPage == 0) {
                                        mFocusList.clear();
                                    }
                                    mvpView.onCheckLoadMore(list);
                                    mFocusList.addAll(list);
                                    mvpView.onUserInfoList(mFocusList);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    /**
     * 关注人-取消关注
     */
    public void setAttentionUser(final int focusUser, final int position) {
        mBuilder.setLoadType(ShowConfig.LOADING_DIALOG);
        onceViewAttached(new ViewAction<HomeSearchView>() {
            @Override
            public void run(@NonNull final HomeSearchView mvpView) {
                mIMe.setAttentionParams(mFocusList, position, focusUser)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(final ResultMsgBean resultMsgBean) {
                                mvpView.onNotifyListChangeResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public interface HomeSearchView extends BaseCheckArrayView {

        void onUserInfoList(List<FocusUserInfoBean> userInfoList);

        void onNotifyListChangeResult(String result);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/adapter/AddressManagerAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.mine.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.address.bean.AddressInfoBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/1/18 16:19
 */
public class AddressManagerAdapter extends RecyclerView.Adapter<AddressManagerAdapter.AddressManagerViewHolder> {
    private List<AddressInfoBean> mAllAddressList;
    private OnItemClickListener mOnItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setAddressList(List<AddressInfoBean> addressList) {
        mAllAddressList = addressList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public AddressManagerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_address, parent, false);
        return new AddressManagerViewHolder(view);
    }

    /**
     * 进行item数据绑定
     *
     * @param holder
     * @param position
     */
    @Override
    public void onBindViewHolder(@NonNull AddressManagerViewHolder holder, int position) {
        AddressInfoBean meAllAddressBean = mAllAddressList.get(position);
        holder.mTvName.setText(meAllAddressBean.getUserAddrName());
        holder.mTvTelePhone.setText(meAllAddressBean.getUserAddrTel());
        holder.mTvPlace.setText(meAllAddressBean.getUserAddrProvince() + meAllAddressBean.getUserAddrCity()
                + meAllAddressBean.getUserAddrDetail());
        holder.mTvEdit.setText("编辑");
        if (meAllAddressBean.getUserAddrDefault() == 1) {
            holder.mTvDefault.setVisibility(View.VISIBLE);
        } else {
            holder.mTvDefault.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public int getItemCount() {
        return mAllAddressList == null ? 0 : mAllAddressList.size();
    }


    public class AddressManagerViewHolder extends BaseViewHolder {
        private TextView mTvName;
        private TextView mTvTelePhone;
        private TextView mTvPlace;
        private TextView mTvEdit;
        private TextView mTvDefault;

        public AddressManagerViewHolder(View itemView) {
            super(itemView);
            mTvName = findViewById(R.id.tv_name);
            mTvTelePhone = findViewById(R.id.tv_telephone);
            mTvPlace = findViewById(R.id.tv_place);
            mTvEdit = findViewById(R.id.tv_edit);
            mTvDefault = findViewById(R.id.tv_default);
            itemView.setId(R.id.address_item_content);
            mTvEdit.setOnClickListener(view -> {
                if (mOnItemClickListener != null && mAllAddressList != null) {
                    mOnItemClickListener.onItemClick(getAdapterPosition(), mAllAddressList, view);
                }
            });
            itemView.setOnClickListener(v -> {
                if (mOnItemClickListener != null && mAllAddressList != null) {
                    mOnItemClickListener.onItemClick(getAdapterPosition(), mAllAddressList, v);
                }
            });
        }

    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/receiver/MuPushReceiver.java<|end_filename|>
package com.scj.beilu.app.receiver;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.v4.app.NotificationCompat;

import com.alibaba.sdk.android.push.MessageReceiver;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import com.google.gson.Gson;
import com.scj.beilu.app.R;
import com.scj.beilu.app.mvp.notify.MsgContentBean;
import com.scj.beilu.app.ui.act.MsgManagerAct;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

import static android.support.v4.app.NotificationCompat.FLAG_AUTO_CANCEL;

/**
 * @author Mingxun
 * @time on 2019/4/8 16:36
 */
public class MuPushReceiver extends MessageReceiver {
    private int clickNotificationCode = 100;

    @Override
    protected void onMessage(final Context context, final CPushMessage cPushMessage) {
        super.onMessage(context, cPushMessage);

        ObservableOnSubscribe<MsgContentBean> onSubscribe =
                new ObservableOnSubscribe<MsgContentBean>() {
                    @Override
                    public void subscribe(ObservableEmitter<MsgContentBean> emitter) throws Exception {
                        try {
                            MsgContentBean msgContentBean = new Gson().fromJson(cPushMessage.getContent(), MsgContentBean.class);
                            emitter.onNext(msgContentBean);
                            emitter.onComplete();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                };

        Observable.create(onSubscribe)
                .subscribeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<MsgContentBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(MsgContentBean msgContentBean) {
                        createNotificationChannel(context, cPushMessage, msgContentBean);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });


    }

    public PendingIntent buildClickContent(Context context, MsgContentBean content) {
        Intent clickIntent = new Intent(context, MsgManagerAct.class);
        clickIntent.putExtra(MsgManagerAct.EXTRA_VAL, content.getMsgType());
        return PendingIntent.getActivity(context, clickNotificationCode, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    private void createNotificationChannel(Context context, CPushMessage message, MsgContentBean content) {
        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        // 通知渠道的id
        String id = "1";
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

            // 用户可以看到的通知渠道的名字.
            CharSequence name = "notification channel";
            // 用户可以看到的通知渠道的描述
            String description = "notification description";
            int importance = NotificationManager.IMPORTANCE_HIGH;
            NotificationChannel mChannel = new NotificationChannel(id, name, importance);
            mChannel.setDescription(description);
            mChannel.enableLights(true);
            mChannel.setLightColor(Color.RED);
            mChannel.enableVibration(true);
            mNotificationManager.createNotificationChannel(mChannel);
        }


        Notification notification = new NotificationCompat.Builder(context, id)
                .setContentTitle(message.getTitle())
                .setContentText(content.getMsgContent())
                .setSmallIcon(R.mipmap.ic_launcher)
                .setDefaults(Notification.DEFAULT_VIBRATE)
                .build();

        notification.flags = FLAG_AUTO_CANCEL;
        notification.contentIntent = buildClickContent(context, content);
//            notification.deleteIntent = buildDeleteContent(context, message);
        mNotificationManager.notify(message.hashCode(), notification);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/mine/address/AddressUpdatePre.java<|end_filename|>
package com.scj.beilu.app.mvp.mine.address;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.common.bean.DictrictOptionBean;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.mine.address.bean.AddressInfoBean;
import com.scj.beilu.app.mvp.mine.model.MineImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * author:SunGuiLan
 * date:2019/2/28
 * descriptin:
 */
public class AddressUpdatePre extends BaseMvpPresenter<AddressUpdatePre.AddressUpdateView> {

    private MineImpl mIMe;

    public AddressUpdatePre(Context context) {
        super(context, ShowConfig.NONE, ShowConfig.ERROR_TOAST);
        mIMe = new MineImpl(mBuilder);
        getDistirctList();
    }

    /**
     * 修改个人地址
     *
     * @param userAddressBean
     */
    public void modifyUserInfo(final AddressInfoBean userAddressBean) {
        onceViewAttached(new ViewAction<AddressUpdateView>() {
            @Override
            public void run(@NonNull final AddressUpdateView mvpView) {
                Map<String, Object> params = new HashMap<>();
                params.put("addrId", userAddressBean.getAddrId());
                params.put("userAddrName", userAddressBean.getUserAddrName());
                params.put("userAddrTel", userAddressBean.getUserAddrTel());
                params.put("userAddrProvince", userAddressBean.getUserAddrProvince());
                params.put("userAddrCity", userAddressBean.getUserAddrCity());
                params.put("userAddrDetail", userAddressBean.getUserAddrDetail());
                params.put("userAddrDefault", userAddressBean.getUserAddrDefault());
                mIMe.modifyUserShipAddr(params)
                        .subscribe(new ObserverCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(ResultMsgBean resultMsgBean) {
                                mvpView.onUpdateResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }


    /**
     * 删除地址
     *
     * @param addrId
     */
    public void delUserAddrById(final int addrId) {
        onceViewAttached(new ViewAction<AddressUpdateView>() {
            @Override
            public void run(@NonNull final AddressUpdateView mvpView) {
                Map<String, Object> params = new HashMap<>();
                params.put("addrId", addrId);
                mIMe.delUserAddrById(params)
                        .subscribe(new ObserverCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(ResultMsgBean resultMsgBean) {
                                mvpView.onUpdateResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    /**
     * 获取地区列表
     */
    private void getDistirctList() {
        onceViewAttached(new ViewAction<AddressUpdateView>() {
            @Override
            public void run(@NonNull final AddressUpdateView mvpView) {
                mIMe.dealWithDistrictData()
                        .subscribe(new ObserverCallback<DictrictOptionBean>
                                (mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(DictrictOptionBean result) {
                                mvpView.onDistrictListResult(result);
                            }
                        });
            }
        });
    }

    public interface AddressUpdateView extends MvpView {
        void onUpdateResult(String result);

        void onDistrictListResult(DictrictOptionBean optionBean);

    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/order/OrderListFragment.java<|end_filename|>
package com.scj.beilu.app.ui.order;

import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.order.OrderListPre;
import com.scj.beilu.app.mvp.order.bean.OrderInfoBean;
import com.scj.beilu.app.ui.comment.SelectPaymentDialog;
import com.scj.beilu.app.ui.order.adapter.OrderStatusListAdapter;
import com.scj.beilu.app.util.ToastUtils;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/1/15 21:15
 */
public class OrderListFragment extends BaseMvpFragment<OrderListPre.OrderListView, OrderListPre>
        implements OrderListPre.OrderListView, OnItemClickListener<OrderInfoBean>, SelectPaymentDialog.onStartPay {

    private RecyclerView mRvOrderList;
    private OrderStatusListAdapter mOrderStatusListAdapter;
    private static final String TAB_INDEX = "tab_index";
    private final int ORDER_LIST = 0x01;
    private int mIndex = 0;

    private SelectPaymentDialog mSelectPaymentDialog;
    private String mOrderNo;
    private OrderInfoBean mOrderInfo;

    public static OrderListFragment newInstance(int index) {

        Bundle args = new Bundle();
        args.putInt(TAB_INDEX, index);
        OrderListFragment fragment = new OrderListFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mIndex = arguments.getInt(TAB_INDEX);
        }
        EventBus.getDefault().register(this);
    }

    @Override
    public OrderListPre createPresenter() {
        return new OrderListPre(mFragmentActivity);
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_order_list;
    }

    @Override
    public void initView() {
        super.initView();

        mRvOrderList = findViewById(R.id.rv_order_list);
        int size = 0;
        if (isAdded()) {
            size = getResources().getDimensionPixelSize(R.dimen.padding_15);
        }
        int finalSize = size;
        mRvOrderList.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(0, 0, 0, finalSize);
            }
        });
        mOrderStatusListAdapter = new OrderStatusListAdapter(this);
        mOrderStatusListAdapter.setOnItemClickListener(this);
        mRvOrderList.setAdapter(mOrderStatusListAdapter);
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getOrderStatusList(mIndex, mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getOrderStatusList(mIndex, mCurrentPage);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onOrderList(List<OrderInfoBean> orderInfoBeanList) {
        mOrderStatusListAdapter.setOrderInfoList(orderInfoBeanList);
    }

    @Override
    public void onAliPaySuccess() {
        ToastUtils.showToast(mFragmentActivity, "支付成功");
        if (mOrderInfo == null) return;
        Intent intent = new Intent(mFragmentActivity, OrderInfoAct.class);
        intent.putExtra(OrderInfoAct.PAY_PRICE, String.valueOf(mOrderInfo.getTotalPrice()));
        intent.putExtra(OrderInfoAct.ORDER_NO, mOrderNo);
        intent.putExtra(OrderInfoAct.LOAD_PAGE, OrderInfoAct.PAY_SUCCESS);
        startActivity(intent);
    }

    @Override
    public void onOrderNoResult(String orderNo) {
        mOrderNo = orderNo;
    }

    @Override
    public void onItemClick(int position, OrderInfoBean entity, View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.ll_order_info_content:
                intent = new Intent(mFragmentActivity, OrderInfoAct.class);
                intent.putExtra(OrderInfoAct.ORDER_NO, entity.getOrderNo());
                intent.putExtra(OrderInfoAct.LOAD_PAGE, OrderInfoAct.ORDER_STATUS);
                startActivityForResult(intent, ORDER_LIST);
                break;
            case R.id.btn_order_info_click:

                switch (entity.getOrderStatusId()) {
                    case 1:
                        if (mSelectPaymentDialog == null) {
                            mSelectPaymentDialog = SelectPaymentDialog.newInstance(String.valueOf(entity.getTotalPrice()));
                            mSelectPaymentDialog.setOnStartPay(this);
                        }
                        mOrderInfo = entity;
                        mSelectPaymentDialog.show(getChildFragmentManager(), mSelectPaymentDialog.getClass().getName());
                        break;
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 7:
                    case 8:
                        intent = new Intent(mFragmentActivity, OrderInfoAct.class);
                        intent.putExtra(OrderInfoAct.ORDER_NO, entity.getOrderNo());
                        intent.putExtra(OrderInfoAct.LOAD_PAGE, OrderInfoAct.ORDER_LOGISTICS);
                        startActivityForResult(intent, ORDER_LIST);
                        break;
                    case 6:
                    case 9:
                        intent = new Intent(mFragmentActivity, OrderInfoAct.class);
                        intent.putExtra(OrderInfoAct.ORDER_NO, entity.getOrderNo());
                        intent.putExtra(OrderInfoAct.LOAD_PAGE, OrderInfoAct.ORDER_STATUS);
                        startActivityForResult(intent, ORDER_LIST);
                        break;

                }

                break;
        }
    }

    @Subscribe
    public void payResult(BaseResp resp) {
        if (resp.errCode == 0) {
            onAliPaySuccess();
        } else {
            ToastUtils.showToast(mFragmentActivity, "支付失败");
        }
    }

    @Override
    public void startPay(boolean mSelectPayment) {
        if (mOrderInfo == null) return;
        getPresenter().startPay(mOrderInfo.getOrderNo(), mOrderInfo.getProductId(), mOrderInfo.getProductCount(),
                mSelectPayment ? 1 : 2, mOrderInfo.getProductName(),
                mOrderInfo.getAddrId(), mOrderInfo.getDescription());
        if (mSelectPaymentDialog != null) {
            mSelectPaymentDialog.dismiss();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/FindPublishFrag.java<|end_filename|>
package com.scj.beilu.app.ui.find;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.mx.pro.lib.album.AlbumManager;
import com.mx.pro.lib.album.GlideEngine;
import com.mx.pro.lib.album.MimeType;
import com.mx.pro.lib.album.filter.Filter;
import com.mx.pro.lib.album.internal.entity.CaptureStrategy;
import com.mx.pro.lib.album.internal.ui.widget.MediaGridInset;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.api.Constants;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.find.FindPublishPre;
import com.scj.beilu.app.mvp.find.GifSizeFilter;
import com.scj.beilu.app.service.UploadService;
import com.scj.beilu.app.ui.act.AddedPreviewActivity;
import com.scj.beilu.app.ui.find.adapter.EditPhotoAdapter;

import java.util.ArrayList;

import static com.mx.pro.lib.album.ui.AlbumActivity.EXTRA_RESULT_SELECTION_PATH;
import static com.scj.beilu.app.api.Constants.DIRECTORY;
import static com.scj.beilu.app.ui.act.AddedPreviewActivity.IMAGE_LIST;

/**
 * @author Mingxun
 * @time on 2019/2/19 16:24
 */
public class FindPublishFrag extends BaseMvpFragment<FindPublishPre.FindPublishView, FindPublishPre>
        implements FindPublishPre.FindPublishView, OnItemClickListener, EditPhotoAdapter.onNotifyListener {

    private EditText mEtDescription;
    private TextView mTvPublish;
    private RecyclerView mRvImageList;
    public static final String FILE_DATA = "file_date";
    public static final String MIME_TYPE = "mine_type";
    public static final String DESCRIPTION = "description";
    private Intent mData = null;
    private EditPhotoAdapter mEditPhotoAdapter;
    private final ArrayList<Uri> mUriList = new ArrayList<>();
    private final ArrayList<String> mPathList = new ArrayList<>();
    private int mPublishType = 1;
    private boolean ofImage = true;
    private final int REQUEST_SELECT = 0x0101;

    public static FindPublishFrag newInstance(Intent data, int publishType) {

        Bundle args = new Bundle();
        args.putParcelable(FILE_DATA, data);
        args.putInt(MIME_TYPE, publishType);
        FindPublishFrag fragment = new FindPublishFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mPublishType = arguments.getInt(MIME_TYPE);
            mData = arguments.getParcelable(FILE_DATA);
            ArrayList<Uri> uriList = (ArrayList<Uri>) AlbumManager.obtainResult(mData);
            ArrayList<String> pathList = (ArrayList<String>) AlbumManager.obtainPathResult(mData);
            if (uriList != null && pathList != null) {
                mUriList.addAll(uriList);
                mPathList.addAll(pathList);
            }
        }
    }

    @Override
    public FindPublishPre createPresenter() {
        return new FindPublishPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_publish_edit;
    }

    @Override
    public void initView() {
        super.initView();
        mEtDescription = findViewById(R.id.et_description);
        mRvImageList = findViewById(R.id.rv_editPhoto);
        mTvPublish = findViewById(R.id.tv_publish);

        int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
        mRvImageList.addItemDecoration(new MediaGridInset(3, spacing, false));
        int count = 9;
        if (mPublishType == 0) {
            count= 1;
            ofImage = false;
        }
        GlideRequests requests = GlideApp.with(this);
        mEditPhotoAdapter = new EditPhotoAdapter(this, requests, count);
        mEditPhotoAdapter.setOnItemClickListener(this);
        mRvImageList.setAdapter(mEditPhotoAdapter);
        mEditPhotoAdapter.setImagePath(mUriList);
        mTvPublish.setOnClickListener(v -> {
            String content = mEtDescription.getText().toString();
            //通过Service 上传
            Intent intent = new Intent(mFragmentActivity, UploadService.class);
            intent.putExtra(FILE_DATA, mData);
            intent.putExtra(MIME_TYPE, ofImage);
            intent.putExtra(DESCRIPTION, content);
            mFragmentActivity.startService(intent);
            mFragmentActivity.setResult(RESULT_OK, intent);
            mFragmentActivity.onBackPressed();
        });
        mTvPublish.setEnabled(mPathList.size() > 0);

        mEtDescription.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (mPathList.size() > 0 || s.length() > 0) {
                    mTvPublish.setEnabled(true);
                } else {
                    mTvPublish.setEnabled(false);
                }
            }
        });

    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        switch (view.getId()) {
            case R.id.iv_del_image:
                mPathList.remove(position);
                mUriList.remove(position);
                mEditPhotoAdapter.notifyItemRemoved(position);

                onImageSize(mPathList.size());
                break;
            case R.id.iv_publish_image:
                selectSource(position, entity);
                break;
        }
    }

    private void selectSource(int position, Object entity) {
        if (entity == null) {
            int maxSize;
            if (ofImage) {
                maxSize = 9 - mUriList.size();
            } else {
                maxSize = 1;
            }

            AlbumManager.from(this)
                    .choose(ofImage ? MimeType.ofImage() : MimeType.ofVideo(), false)
                    .showSingleMediaType(true)
                    .countable(true)
                    .capture(true)
                    .captureStrategy(
                            new CaptureStrategy(true, mFragmentActivity.getPackageName() + ".fileprovider", DIRECTORY))
                    .maxSelectable(maxSize)
                    .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
                    .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
                    .thumbnailScale(0.85f)
                    .imageEngine(new GlideEngine())  // for glide-V4
                    .maxOriginalSize(10
                    )
                    .autoHideToolbarOnSingleTap(true)
                    .forResult(REQUEST_SELECT);
        } else {
            Intent intent = new Intent(mFragmentActivity, AddedPreviewActivity.class);
            intent.putParcelableArrayListExtra(AddedPreviewActivity.IMAGE_LIST, mUriList);
            intent.putStringArrayListExtra(AddedPreviewActivity.IMAGE_PATH_LIST, mPathList);
            intent.putExtra(AddedPreviewActivity.POSITION, position);
            startActivityForResult(intent, Constants.REQUEST_CODE_CHOOSE);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && requestCode == Constants.REQUEST_CODE_CHOOSE) {//点击预览后，返回的数据

            mUriList.clear();
            mPathList.clear();

            ArrayList<Uri> uriList = data.getParcelableArrayListExtra(IMAGE_LIST);
            mUriList.addAll(uriList);
            ArrayList<String> pathList = data.getStringArrayListExtra(AddedPreviewActivity.IMAGE_PATH_LIST);
            mPathList.addAll(pathList);

        } else if (resultCode == RESULT_OK && requestCode == REQUEST_SELECT) {

            ArrayList<Uri> uris = (ArrayList<Uri>) AlbumManager.obtainResult(data);
            ArrayList<String> pathList = (ArrayList<String>) AlbumManager.obtainPathResult(data);
            mUriList.addAll(uris);
            mPathList.addAll(pathList);
        }
        mData.putStringArrayListExtra(EXTRA_RESULT_SELECTION_PATH, mPathList);
        mEditPhotoAdapter.setImagePath(mUriList);
    }

    @Override
    public void onImageSize(int size) {
        if (size > 0 || mEtDescription.getText().toString().length() > 0) {
            mTvPublish.setEnabled(true);
        } else {
            mTvPublish.setEnabled(false);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/action/ActionPayDescriptionFrag.java<|end_filename|>
package com.scj.beilu.app.ui.action;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.action.ActionPayDescPre;

import java.math.BigDecimal;

public class ActionPayDescriptionFrag extends BaseMvpFragment<ActionPayDescPre.ActionPayDescView, ActionPayDescPre>
        implements ActionPayDescPre.ActionPayDescView {
    private ImageView iv_action_lock_photo, iv_qr_code;
    private TextView tv_action_price_pay;

    private static final String TOTAL_PRICE = "price";

    private double mPrice;

    public static ActionPayDescriptionFrag newInstance(double price) {

        Bundle args = new Bundle();
        args.putDouble(TOTAL_PRICE, price);
        ActionPayDescriptionFrag fragment = new ActionPayDescriptionFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mPrice = arguments.getDouble(TOTAL_PRICE);
        }
    }

    @Override
    public ActionPayDescPre createPresenter() {
        return new ActionPayDescPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_action_pay_description;
    }

    @Override
    public void initView() {
        super.initView();
        tv_action_price_pay = findViewById(R.id.tv_action_price_pay);
        if (isAdded()) {
            BigDecimal b = BigDecimal.valueOf(mPrice);
            b.setScale(2, BigDecimal.ROUND_HALF_UP);
            String price = getResources().getString(R.string.action_pay_price);
            price = String.format(price, b);
            tv_action_price_pay.setText(price);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/NewsListFrag.java<|end_filename|>
package com.scj.beilu.app.ui.news;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.view.View;
import android.widget.ImageView;

import com.mx.pro.lib.banner.Banner;
import com.mx.pro.lib.banner.loader.ImageLoader;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.NewsListPre;
import com.scj.beilu.app.mvp.news.bean.NewsBannerBean;
import com.scj.beilu.app.mvp.news.bean.NewsInfoBean;
import com.scj.beilu.app.mvp.news.bean.NewsNavBean;
import com.scj.beilu.app.ui.news.adapter.NewsListAdapter;
import com.scj.beilu.app.widget.DividerItemDecorationToPadding;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/11 14:12
 * 新闻列表 只有推荐带Banner
 */
public class NewsListFrag extends BaseMvpFragment<NewsListPre.NewsListView, NewsListPre>
        implements NewsListPre.NewsListView, OnItemClickListener {

    private Banner mBanner;

    private NewsListAdapter mNewsListAdapter;

    private static final String NAV_BEAN = "NAV_BEAN";
    private NewsNavBean mNewsNavBean;
    private boolean mLoadBanner;
    private GlideRequests mGlideOriginal;
    private GlideRequests mGlideThumbnail;

    public static NewsListFrag newInstance(NewsNavBean navContent) {

        Bundle args = new Bundle();
        args.putParcelable(NAV_BEAN, navContent);
        NewsListFrag fragment = new NewsListFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mNewsNavBean = arguments.getParcelable(NAV_BEAN);
            mLoadBanner = mNewsNavBean.getNewsCateId() == 1;
        }
    }

    @Override
    public NewsListPre createPresenter() {
        return new NewsListPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return mLoadBanner ? R.layout.frag_news_banner_list : R.layout.frag_news_list;
    }

    @Override
    public void initView() {
        super.initView();

        if (mLoadBanner) {
            mBanner = findViewById(R.id.banner_news);
        }

        mGlideOriginal = GlideApp.with(this);
        mGlideThumbnail = GlideApp.with(this);

        mRecyclerView.addItemDecoration(new DividerItemDecorationToPadding(mFragmentActivity, DividerItemDecoration.VERTICAL));
        mNewsListAdapter = new NewsListAdapter(mFragmentActivity, mGlideOriginal);
        mNewsListAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mNewsListAdapter);

        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setNestedScrollingEnabled(false);

        mRefreshLayout.autoRefresh();
        mRefreshLayout.setEnableLoadMore(true);

    }

    @Override
    public void showError(int errorCode, String throwableContent) {
        mRefreshLayout.finishRefresh(false);
    }

    @Override
    public void onStart() {
        super.onStart();
        if (mBanner != null) {
            mBanner.startAutoPlay();
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        if (mBanner != null) {
            mBanner.stopAutoPlay();
        }
    }


    @Override
    public void onNewsList(List<NewsInfoBean> newsList) {
        mRefreshLayout.finishRefresh(true);
        mNewsListAdapter.setNewsListEntityList(newsList);
    }


    @Override
    public void onBannerList(List<NewsBannerBean> bannerBeanList) {
        mRefreshLayout.finishRefresh(true);
        if (bannerBeanList == null) return;
        mBanner.setImages(bannerBeanList);
        mBanner.setImageLoader(new ImageLoader() {
            @Override
            public void displayImage(Context context, Object path, View imageView) {
                NewsBannerBean bannerPath = (NewsBannerBean) path;
                ImageView image = imageView.findViewById(R.id.banner_image);
                mGlideOriginal
                        .load(bannerPath.getAdverPicAddr())
                        .thumbnail(mGlideThumbnail.load(bannerPath.getAdverPicZip()))
                        .dontAnimate()
                        .into(image);
            }

        });
        mBanner.start();
    }

    @Override
    public void onItemClick(int position, Object entity, View view) {
        NewsInfoBean infoBean = (NewsInfoBean) entity;
        NewsDetailsAct.startNewsDetailsAct(mFragmentActivity, infoBean);
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getNewsList(mNewsNavBean, mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getNewsList(mNewsNavBean, mCurrentPage);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/FindMListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.scj.beilu.app.GlideRequests;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.find.bean.FindInfoBean;

import java.util.List;

/**
 * author:SunGuiLan
 * date:2019/1/30
 * descriptin: 发现
 */
public class FindMListAdapter extends RecyclerView.Adapter {
    //图片+内容+文字
    final int VIEW_TYPE_TXT_IMG = 0x001;
    //视频+文字
    final int VIEW_TYPE_VIDEO = 0x003;

    private List<FindInfoBean> mFindInfoList;

    private OnItemClickListener<FindInfoBean> mOnItemClickListener;
    private GlideRequests mGlideRequests;

    public FindMListAdapter(GlideRequests glideRequests) {
        this.mGlideRequests = glideRequests;
    }

    public void setOnItemClickListener(OnItemClickListener<FindInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setFindInfoList(List<FindInfoBean> findInfoList) {
        mFindInfoList = findInfoList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view;
        if (viewType == VIEW_TYPE_TXT_IMG) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_hot_txt_img, parent, false);
            return new ContentTxtImgViewHolder(view);
        } else {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_hot_video, parent, false);
            return new ContentVideoViewHolder(view);
        }

    }


    @Override
    public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {
        FindInfoBean infoFind = mFindInfoList.get(position);
        if (holder instanceof ContentTxtImgViewHolder) {
            ContentTxtImgViewHolder txtImgViewHolder = (ContentTxtImgViewHolder) holder;

            mGlideRequests
                    .load(infoFind.getUserHead())
                    .transform(new CircleCrop())
                    .into(txtImgViewHolder.mIvAvatar);

            txtImgViewHolder.mTvUserName.setText(infoFind.getUserNickName());
            txtImgViewHolder.mTvFindContent.setText(infoFind.getDynamicDec());
        } else if (holder instanceof ContentVideoViewHolder) {

        }
    }

    @Override
    public int getItemCount() {
        return mFindInfoList == null ? 0 : mFindInfoList.size();
    }

    class ContentTxtImgViewHolder extends BaseViewHolder {

        private ImageView mIvAvatar;
        private TextView mTvUserName, mTvFindContent;

        RecyclerView mRvImgList;

        public ContentTxtImgViewHolder(View itemView) {
            super(itemView);
            mIvAvatar = findViewById(R.id.iv_item_find_avatar);
            mTvUserName = findViewById(R.id.tv_item_find_user_name);
            mTvFindContent = findViewById(R.id.tv_item_find_txt);
            mRvImgList = findViewById(R.id.rv_item_find_pic);

        }
    }


    class ContentVideoViewHolder extends BaseViewHolder {
        public ContentVideoViewHolder(View itemView) {
            super(itemView);
        }
    }


    @Override
    public int getItemViewType(int position) {
        FindInfoBean findInfo = mFindInfoList.get(position);
        if (findInfo.getDynamicVideoAddr() != null) {
            return VIEW_TYPE_VIDEO;
        } else {
            return VIEW_TYPE_TXT_IMG;
        }

    }
}

<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/merchant/adapter/MerchantPicPreviewManagerListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.merchant.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.merchant.bean.MerchantPicTypeBean;

import java.util.ArrayList;

/**
 * @author Mingxun
 * @time on 2019/4/16 14:17
 */
public class MerchantPicPreviewManagerListAdapter extends RecyclerView.Adapter<MerchantPicPreviewManagerListAdapter.PreviewTypeViewHolder> {

    private ArrayList<MerchantPicTypeBean> mMerchantPicTypeBeans;
    private OnItemClickListener mOnItemClickListener;

    public void setMerchantPicTypeBeans(ArrayList<MerchantPicTypeBean> merchantPicTypeBeans) {
        mMerchantPicTypeBeans = merchantPicTypeBeans;
        notifyDataSetChanged();
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public PreviewTypeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pic_pre_view_type, parent, false);
        return new PreviewTypeViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull PreviewTypeViewHolder holder, int position) {
        try {
            MerchantPicTypeBean typeBean = mMerchantPicTypeBeans.get(position);
            holder.mTvName.setText(typeBean.getRegionName());
            holder.mTvName.setSelected(typeBean.isSelected());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return mMerchantPicTypeBeans == null ? 0 : mMerchantPicTypeBeans.size();
    }

    public class PreviewTypeViewHolder extends BaseViewHolder {

        private TextView mTvName;

        public PreviewTypeViewHolder(View itemView) {
            super(itemView);
            mTvName = findViewById(R.id.tv_pre_view_type);
            mTvName.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), mMerchantPicTypeBeans.get(getAdapterPosition()), v);
                    }
                }
            });
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/MineFansFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.mine.MineFansPre;
import com.scj.beilu.app.mvp.mine.bean.MeFansInfoBean;
import com.scj.beilu.app.ui.mine.adapter.MeFansAdapter;
import com.scj.beilu.app.ui.user.UserInfoHomePageAct;
import com.scj.beilu.app.util.ToastUtils;

import java.util.List;

public class MineFansFrag extends BaseMvpFragment<MineFansPre.MeFansView, MineFansPre> implements MineFansPre.MeFansView, OnItemClickListener<MeFansInfoBean> {

    private RecyclerView mRvMeFans;
    private MeFansAdapter mMeFansAdapter;
    private int mPosition=-1;

    private static final int REQUEST_CODE = 0x001;

    @Override
    public MineFansPre createPresenter() {
        return new MineFansPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_me_fans;
    }

    @Override
    public void initView() {
        super.initView();
        mRvMeFans = findViewById(R.id.rv_me_fans);
        mMeFansAdapter = new MeFansAdapter(GlideApp.with(mFragmentActivity));
        mRvMeFans.setAdapter(mMeFansAdapter);
        mMeFansAdapter.setOnItemClickListener(this);
        mRvMeFans.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        super.onRefresh(refreshLayout);
        getPresenter().getMyFansList(mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getMyFansList(mCurrentPage);
    }

    @Override
    public void onMyFansResult(List<MeFansInfoBean> fansList) {
        mMeFansAdapter.setFansInfoList(fansList);
    }

    @Override
    public void onNotifyListChangeResult(String result) {
        ToastUtils.showToast(mFragmentActivity,result);
        if (mPosition >= 0) {
            mMeFansAdapter.notifyItemChanged(mPosition);
        }
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        mRefreshLayout.autoRefresh();
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }

    @Override
    public void onItemClick(int position, MeFansInfoBean meFansInfoBean, View view) {
        switch (view.getId()) {
            case R.id.tv_item_attention:
                mPosition = position;
                getPresenter().setAttentionUser(meFansInfoBean.getUserId(), mPosition);
                break;
            case R.id.iv_user_avatar:
                Intent intent = new Intent(mFragmentActivity, UserInfoHomePageAct.class);
                intent.putExtra(UserInfoHomePageAct.EXTRA_USER_ID, meFansInfoBean.getUserId());
                startActivityForResult(intent, REQUEST_CODE);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            mRefreshLayout.autoRefresh();
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/FindPublishWayAct.java<|end_filename|>
package com.scj.beilu.app.ui.find;

import android.os.Bundle;
import android.support.annotation.NonNull;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpActivity;
import com.scj.beilu.app.mvp.find.publishstatus.PublishWayPre;

/**
 * date:2019/1/31
 * descriptin:选择发布方式
 */
public class FindPublishWayAct extends BaseMvpActivity<PublishWayPre.PublishWayView, PublishWayPre>
        implements PublishWayPre.PublishWayView {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initView() {
        super.initView();
        loadRootFragment(R.id.fl_content, new FindPublishTypeFrag(),false,true);

    }

    @Override
    public int getLayout() {
        return R.layout.act_content;
    }

    @NonNull
    @Override
    public PublishWayPre createPresenter() {
        return new PublishWayPre();
    }


}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/CourseDetailsTeacherDescFrag.java<|end_filename|>
package com.scj.beilu.app.ui.course;

import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.gyf.immersionbar.ImmersionBar;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.course.CourseDetailsTeacherDescPre;
import com.scj.beilu.app.mvp.course.bean.CourseTeacherBean;
import com.scj.beilu.app.ui.course.adapter.CourseTagListAdapter;
import com.scj.beilu.app.ui.course.adapter.CourseTeacherImgListAdapter;
import com.scj.beilu.app.widget.FlowLayoutManager;

/**
 * @author Mingxun
 * @time on 2019/3/20 23:21
 */
public class CourseDetailsTeacherDescFrag extends BaseMvpFragment<CourseDetailsTeacherDescPre.CourseDetailsTeacherDescView, CourseDetailsTeacherDescPre>
        implements CourseDetailsTeacherDescPre.CourseDetailsTeacherDescView {

    private ImageView mIvAvatar;
    private TextView mTvTeacherName;
    private RecyclerView mRvTeacherTagList;
    private TextView mTvTeacherDescription;
    private RecyclerView mRvTeacherImgList;
    private TextView mTvTeacherSay;

    private static final String COURSE_ID = "course_id";
    private int mCourseId;

    private CourseTagListAdapter mCourseTagListAdapter;
    private CourseTeacherImgListAdapter mCourseTeacherImgListAdapter;

    public static CourseDetailsTeacherDescFrag newInstance(int courseId) {

        Bundle args = new Bundle();
        args.putInt(COURSE_ID, courseId);
        CourseDetailsTeacherDescFrag fragment = new CourseDetailsTeacherDescFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mCourseId = arguments.getInt(COURSE_ID);
        }
    }

    @Override
    public CourseDetailsTeacherDescPre createPresenter() {
        return new CourseDetailsTeacherDescPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_course_teacher_desc;
    }

    @Override
    public void initView() {
        super.initView();
        ImmersionBar.with(this).statusBarDarkFont(false)
                .keyboardEnable(true)
                .init();
        mIvAvatar = findViewById(R.id.iv_course_teacher_avatar);
        mTvTeacherName = findViewById(R.id.tv_course_teacher_name);
        mRvTeacherTagList = findViewById(R.id.rv_course_teacher_tag_list);
        mTvTeacherDescription = findViewById(R.id.tv_course_teacher_description);
        mRvTeacherImgList = findViewById(R.id.rv_course_teacher_img_list);
        mTvTeacherSay = findViewById(R.id.tv_course_teacher_say);

        mCourseTeacherImgListAdapter = new CourseTeacherImgListAdapter(this);
        mRvTeacherImgList.setAdapter(mCourseTeacherImgListAdapter);

        int rectSize = 0;
        if (isAdded()) {
            rectSize = getResources().getDimensionPixelOffset(R.dimen.hor_divider_size_6);
        }

        final int finalRectSize = rectSize;
        mRvTeacherImgList.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(0, 0, finalRectSize, 0);
            }
        });

        mCourseTagListAdapter = new CourseTagListAdapter();
        mRvTeacherTagList.setAdapter(mCourseTagListAdapter);

        FlowLayoutManager layoutManager = new FlowLayoutManager();
        mRvTeacherTagList.setLayoutManager(layoutManager);
        mRvTeacherTagList.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(5, 5, 5, 5);
            }
        });

    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getTeacherInfo(mCourseId);
    }

    @Override
    public void onTeacherInfo(CourseTeacherBean teacherBean) {
        try {

            GlideApp.with(this)
                    .load(teacherBean.getCourseTeacherHead())
                    .thumbnail(GlideApp.with(this).load(teacherBean.getCourseTeacherHeadZip()).centerCrop())
                    .placeholder(R.drawable.ic_default_avatar)
                    .circleCrop()
                    .into(mIvAvatar);

            mTvTeacherName.setText(teacherBean.getCourseTeacherName());
            mTvTeacherDescription.setText(teacherBean.getCourseTeacherBrief());
            mTvTeacherSay.setText(teacherBean.getCourseTeacherWords());

            mCourseTagListAdapter.setLabels(teacherBean.getCourseTeacherLabel());
            mCourseTeacherImgListAdapter.setCourseTeacherImgList(teacherBean.getPics());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/fragmentation/anim/FragmentAnimator.java<|end_filename|>
package com.mx.pro.lib.fragmentation.anim;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.AnimRes;

/**
 * Fragment动画实体类
 * Created by YoKeyword on 16/2/4.
 */
public class FragmentAnimator implements Parcelable {
    @AnimRes
    protected int enter;
    @AnimRes
    protected int exit;
    @AnimRes
    protected int popEnter;
    @AnimRes
    protected int popExit;

    public FragmentAnimator() {
    }

    public FragmentAnimator(int enter, int exit) {
        this.enter = enter;
        this.exit = exit;
    }

    public FragmentAnimator(int enter, int exit, int popEnter, int popExit) {
        this.enter = enter;
        this.exit = exit;
        this.popEnter = popEnter;
        this.popExit = popExit;
    }

    public FragmentAnimator copy() {
        return new FragmentAnimator(getEnter(), getExit(), getPopEnter(), getPopExit());
    }

    protected FragmentAnimator(Parcel in) {
        enter = in.readInt();
        exit = in.readInt();
        popEnter = in.readInt();
        popExit = in.readInt();
    }

    public static final Creator<FragmentAnimator> CREATOR = new Creator<FragmentAnimator>() {
        @Override
        public FragmentAnimator createFromParcel(Parcel in) {
            return new FragmentAnimator(in);
        }

        @Override
        public FragmentAnimator[] newArray(int size) {
            return new FragmentAnimator[size];
        }
    };

    public int getEnter() {
        return enter;
    }

    public FragmentAnimator setEnter(int enter) {
        this.enter = enter;
        return this;
    }

    public int getExit() {
        return exit;
    }

    /**
     * enter animation
     */
    public FragmentAnimator setExit(int exit) {
        this.exit = exit;
        return this;
    }

    public int getPopEnter() {
        return popEnter;
    }

    public FragmentAnimator setPopEnter(int popEnter) {
        this.popEnter = popEnter;
        return this;
    }

    public int getPopExit() {
        return popExit;
    }

    public FragmentAnimator setPopExit(int popExit) {
        this.popExit = popExit;
        return this;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(enter);
        dest.writeInt(exit);
        dest.writeInt(popEnter);
        dest.writeInt(popExit);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/act/LoginAndRegisterAct.java<|end_filename|>
package com.scj.beilu.app.ui.act;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.mx.pro.lib.fragmentation.support.SupportActivity;
import com.scj.beilu.app.R;
import com.scj.beilu.app.ui.login.LoginAndRegisterFrag;

/**
 * @author Mingxun
 * @time on 2019/1/22 15:32
 */

public class LoginAndRegisterAct extends SupportActivity {

    public static final int LOGIN_REQUEST = 0x1001;
    public static final int LOGIN_RESULT_OK = 0x1000;

    public static void startLoginAndRegisterAct(Activity activity) {
        Intent intent = new Intent(activity, LoginAndRegisterAct.class);
        activity.startActivityForResult(intent, 200);
    }

    @Override
    public int getLayout() {
        return R.layout.act_content;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }


    protected void initView() {
        loadRootFragment(R.id.fl_content, new LoginAndRegisterFrag());
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/fragmentation/helper/internal/VisibleDelegate.java<|end_filename|>
package com.mx.pro.lib.fragmentation.helper.internal;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentationMagician;

import com.mx.pro.lib.fragmentation.ISupportFragment;

import java.util.List;


public class VisibleDelegate {
    private static final String FRAGMENTATION_STATE_SAVE_IS_INVISIBLE_WHEN_LEAVE = "fragmentation_invisible_when_leave";
    private static final String FRAGMENTATION_STATE_SAVE_COMPAT_REPLACE = "fragmentation_compat_replace";

    // SupportVisible相关
    private boolean mIsSupportVisible;
    private boolean mNeedDispatch = true;
    private boolean mInvisibleWhenLeave;
    private boolean mIsFirstVisible = true;
    private boolean mFirstCreateViewCompatReplace = true;

    private Handler mHandler;
    private Bundle mSaveInstanceState;

    private ISupportFragment mSupportF;
    private Fragment mFragment;

    public VisibleDelegate(ISupportFragment fragment) {
        this.mSupportF = fragment;
        this.mFragment = (Fragment) fragment;
    }

    public void onCreate(@Nullable Bundle savedInstanceState) {
        if (savedInstanceState != null) {
            mSaveInstanceState = savedInstanceState;
            // setUserVisibleHint() may be called before onCreate()
            mInvisibleWhenLeave = savedInstanceState.getBoolean(FRAGMENTATION_STATE_SAVE_IS_INVISIBLE_WHEN_LEAVE);
            mFirstCreateViewCompatReplace = savedInstanceState.getBoolean(FRAGMENTATION_STATE_SAVE_COMPAT_REPLACE);
        }
    }

    public void onSaveInstanceState(Bundle outState) {
        outState.putBoolean(FRAGMENTATION_STATE_SAVE_IS_INVISIBLE_WHEN_LEAVE, mInvisibleWhenLeave);
        outState.putBoolean(FRAGMENTATION_STATE_SAVE_COMPAT_REPLACE, mFirstCreateViewCompatReplace);
    }

    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        if (!mFirstCreateViewCompatReplace && mFragment.getTag() != null && mFragment.getTag().startsWith("android:switcher:")) {
            return;
        }

        if (mFirstCreateViewCompatReplace) {
            mFirstCreateViewCompatReplace = false;
        }

        if (!mInvisibleWhenLeave && !mFragment.isHidden() && mFragment.getUserVisibleHint()) {
            if ((mFragment.getParentFragment() != null && isFragmentVisible(mFragment.getParentFragment()))
                    || mFragment.getParentFragment() == null) {
                mNeedDispatch = false;
                safeDispatchUserVisibleHint(true);
            }
        }
    }

    public void onResume() {
        if (!mIsFirstVisible) {
            if (!mIsSupportVisible && !mInvisibleWhenLeave && isFragmentVisible(mFragment)) {
                mNeedDispatch = false;
                dispatchSupportVisible(true);
            }
        }
    }

    public void onPause() {
        if (mIsSupportVisible && isFragmentVisible(mFragment)) {
            mNeedDispatch = false;
            mInvisibleWhenLeave = false;
            dispatchSupportVisible(false);
        } else {
            mInvisibleWhenLeave = true;
        }
    }

    public void onHiddenChanged(boolean hidden) {
        if (!hidden && !mFragment.isResumed()) {
            //if fragment is shown but not resumed, ignore...
            mInvisibleWhenLeave = false;
            return;
        }
        if (hidden) {
            safeDispatchUserVisibleHint(false);
        } else {
            enqueueDispatchVisible();
        }
    }

    public void onDestroyView() {
        mIsFirstVisible = true;
    }

    public void setUserVisibleHint(boolean isVisibleToUser) {
        if (mFragment.isResumed() || (!mFragment.isAdded() && isVisibleToUser)) {
            if (!mIsSupportVisible && isVisibleToUser) {
                safeDispatchUserVisibleHint(true);
            } else if (mIsSupportVisible && !isVisibleToUser) {
                dispatchSupportVisible(false);
            }
        }
    }

    private void safeDispatchUserVisibleHint(boolean visible) {
        if (mIsFirstVisible) {
            if (!visible) return;
            enqueueDispatchVisible();
        } else {
            dispatchSupportVisible(visible);
        }
    }

    private void enqueueDispatchVisible() {
        getHandler().post(new Runnable() {
            @Override
            public void run() {
                dispatchSupportVisible(true);
            }
        });
    }

    private void dispatchSupportVisible(boolean visible) {
        if (visible && isParentInvisible()) return;

        if (mIsSupportVisible == visible) {
            mNeedDispatch = true;
            return;
        }

        mIsSupportVisible = visible;

        if (visible) {
            if (checkAddState()) return;
            mSupportF.onSupportVisible();

            if (mIsFirstVisible) {
                mIsFirstVisible = false;
                mSupportF.onLazyInitView(mSaveInstanceState);
            }
            dispatchChild(true);
        } else {
            dispatchChild(false);
            mSupportF.onSupportInvisible();
        }
    }

    private void dispatchChild(boolean visible) {
        if (!mNeedDispatch) {
            mNeedDispatch = true;
        } else {
            if (checkAddState()) return;
            FragmentManager fragmentManager = mFragment.getChildFragmentManager();
            List<Fragment> childFragments = FragmentationMagician.getActiveFragments(fragmentManager);
            if (childFragments != null) {
                for (Fragment child : childFragments) {
                    if (child instanceof ISupportFragment && !child.isHidden() && child.getUserVisibleHint()) {
                        ((ISupportFragment) child).getSupportDelegate().getVisibleDelegate().dispatchSupportVisible(visible);
                    }
                }
            }
        }
    }

    private boolean isParentInvisible() {
        ISupportFragment fragment = (ISupportFragment) mFragment.getParentFragment();
        return fragment != null && !fragment.isSupportVisible();
    }

    private boolean checkAddState() {
        if (!mFragment.isAdded()) {
            mIsSupportVisible = !mIsSupportVisible;
            return true;
        }
        return false;
    }

    private boolean isFragmentVisible(Fragment fragment) {
        return !fragment.isHidden() && fragment.getUserVisibleHint();
    }

    public boolean isSupportVisible() {
        return mIsSupportVisible;
    }

    private Handler getHandler() {
        if (mHandler == null) {
            mHandler = new Handler(Looper.getMainLooper());
        }
        return mHandler;
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/course/CourseDetailsCommentFrag.java<|end_filename|>
package com.scj.beilu.app.ui.course;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.DividerItemDecoration;
import android.view.View;
import android.widget.LinearLayout;

import com.gyf.immersionbar.ImmersionBar;
import com.mx.pro.lib.smartrefresh.layout.api.RefreshLayout;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.course.CourseDetailsCommentPre;
import com.scj.beilu.app.mvp.course.bean.CourseCommentInfoBean;
import com.scj.beilu.app.ui.course.adapter.CourseCommentListAdapter;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/20 23:21
 */
public class CourseDetailsCommentFrag extends BaseMvpFragment<CourseDetailsCommentPre.CourseDetailsCommentView, CourseDetailsCommentPre>
        implements CourseDetailsCommentPre.CourseDetailsCommentView {

    private LinearLayout mLlLoadEmpty;

    private static final String COURSE_ID = "course_id";
    private int mCourseId;
    private CourseCommentListAdapter mCourseCommentListAdapter;

    public static CourseDetailsCommentFrag newInstance(int courseId) {

        Bundle args = new Bundle();
        args.putInt(COURSE_ID, courseId);
        CourseDetailsCommentFrag fragment = new CourseDetailsCommentFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mCourseId = arguments.getInt(COURSE_ID);
        }
    }

    @Override
    public CourseDetailsCommentPre createPresenter() {
        return new CourseDetailsCommentPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_course_comment_list;
    }

    @Override
    public void initView() {
        super.initView();
        ImmersionBar.with(this)
                .statusBarDarkFont(false)
                .keyboardEnable(true)
                .init();
        mLlLoadEmpty = findViewById(R.id.ll_load_empty_view);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(mFragmentActivity, DividerItemDecoration.VERTICAL));

        mCourseCommentListAdapter = new CourseCommentListAdapter(this);
        mRecyclerView.setAdapter(mCourseCommentListAdapter);

    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        getPresenter().getCommentList(mCourseId, mCurrentPage);
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        super.onLoadMore(refreshLayout);
        getPresenter().getCommentList(mCourseId, mCurrentPage);
    }

    @Override
    public void onCommentList(List<CourseCommentInfoBean> commentList) {

        if (commentList.size() == 0) {
            mLlLoadEmpty.setVisibility(View.VISIBLE);
            mRecyclerView.setVisibility(View.GONE);
        } else {
            mRecyclerView.setVisibility(View.VISIBLE);
            mLlLoadEmpty.setVisibility(View.GONE);
            mCourseCommentListAdapter.setCourseCommentInfoList(commentList);
        }

    }

    @Override
    public void onCreateNotifyResult() {
        if (mRecyclerView.getVisibility() == View.GONE) {
            mRecyclerView.setVisibility(View.VISIBLE);
            mLlLoadEmpty.setVisibility(View.GONE);
        }
        mCourseCommentListAdapter.notifyItemInserted(0);
    }

    @Override
    public void onCheckLoadMore(List<?> list) {
        checkIsLoadMore(list);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/merchant/MerchantInfoPre.java<|end_filename|>
package com.scj.beilu.app.mvp.merchant;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoDetailsListBean;
import com.scj.beilu.app.mvp.merchant.bean.MerchantInfoDetailsListResultBean;
import com.scj.beilu.app.mvp.merchant.model.IMerchantInfo;
import com.scj.beilu.app.mvp.merchant.model.MerchantInfoImpl;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/4/13 19:52
 */
public class MerchantInfoPre extends BaseMvpPresenter<MerchantInfoPre.MerchantInfoView> {

    private IMerchantInfo mMerchantInfo;

    public MerchantInfoPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mMerchantInfo = new MerchantInfoImpl(mBuilder);
    }

    public void getMerchantInfo(final int merchantId) {
        onceViewAttached(new ViewAction<MerchantInfoView>() {
            @Override
            public void run(@NonNull final MerchantInfoView mvpView) {
                mMerchantInfo.getMerchantInfo(merchantId)
                        .subscribe(new ObserverCallback<MerchantInfoDetailsListResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(MerchantInfoDetailsListResultBean detailsListBean) {
                                try {
                                    mvpView.onMerchantInfo(detailsListBean.getMerchantInfoBean());
                                    mvpView.onMerchantInfoList(detailsListBean.getDetailsListBeans());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface MerchantInfoView extends MvpView {
        void onMerchantInfo(MerchantInfoBean merchantInfo);

        void onMerchantInfoList(List<MerchantInfoDetailsListBean> detailInfo);
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/MvpQueuingBasePresenter.java<|end_filename|>
package com.mx.pro.lib.mvp;

import android.support.annotation.MainThread;
import android.support.annotation.NonNull;

import java.lang.ref.WeakReference;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @param <V>
 * @author Charlie
 */
public class MvpQueuingBasePresenter<V extends MvpView> implements MvpPresenter<V> {

    public interface ViewAction<V> {
        void run(@NonNull V mvpView);
    }


    private Queue<ViewAction<V>> mViewActionQueue = new ConcurrentLinkedQueue<>();
    private WeakReference<V> mViewRef;
    private boolean mPresenterDestroyed;

    private void runQueueActions() {
        V view = mViewRef == null ? null : mViewRef.get();
        if (view != null) {
            while (!mViewActionQueue.isEmpty()) {
                ViewAction<V> action = mViewActionQueue.poll();
                action.run(view);
            }
        }

    }

    @Override
    public void attachView(@NonNull V view) {
        mPresenterDestroyed = false;
        mViewRef = new WeakReference<>(view);
        runQueueActions();
    }

    @Override
    public void detachView() {
        mViewRef.clear();
    }

    @Override
    public void destroy() {
        mViewActionQueue.clear();
        mPresenterDestroyed = false;
    }


    @MainThread
    protected void onceViewAttached(ViewAction<V> action) {
        mViewActionQueue.add(action);
        runQueueActions();
    }

    @MainThread
    private final void ifViewAttached(boolean exceptionIfViewNotAttached, ViewAction<V> action) {
        final V view = mViewRef == null ? null : mViewRef.get();
        if (view != null) {
            action.run(view);
        } else if (exceptionIfViewNotAttached) {
            throw new IllegalStateException("No View attached to Presenter. Presenter destroyed = " + mPresenterDestroyed);
        }
    }

    protected final void ifViewAttached(ViewAction<V> action) {
        ifViewAttached(false, action);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/MyIssueAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/9
 * descriptin:我的组织
 */
public class MyIssueAdapter extends RecyclerView.Adapter<MyIssueAdapter.MyIssueHolder> {
    @NonNull
    @Override
    public MyIssueHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_issuename, parent, false);
        return new MyIssueHolder(v);
    }

    @Override
    public void onBindViewHolder(@NonNull MyIssueHolder holder, int position) {
    }


    @Override
    public int getItemCount() {
        return 3;
    }

    class MyIssueHolder extends BaseViewHolder {
        private RecyclerView mRecyclerView;
        public MyIssueHolder(View itemView) {
            super(itemView);
            mRecyclerView=findViewById(R.id.rv_myIssue);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/news/adapter/NewsCommentChildAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.news.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.news.bean.NewsReplyCommentBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/16 14:55
 */
public class NewsCommentChildAdapter extends RecyclerView.Adapter<CommentChildViewHolder> {

    private List<NewsReplyCommentBean> mNewsReplyCommentBeans;
    private Context mContext;
    private OnItemClickListener<NewsReplyCommentBean> mOnItemClickListener;

    public NewsCommentChildAdapter(Context context) {
        mContext = context;
    }

    public void setOnItemClickListener(OnItemClickListener<NewsReplyCommentBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setNewsReplyCommentBeans(List<NewsReplyCommentBean> newsReplyCommentBeans) {
        mNewsReplyCommentBeans = newsReplyCommentBeans;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public CommentChildViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_news_comment_reply_content, parent, false);
        return new CommentChildViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull CommentChildViewHolder holder, final int position) {
        final NewsReplyCommentBean commentContent = mNewsReplyCommentBeans.get(position);
        String format = mContext.getResources().getString(R.string.txt_reply_content);
        String html = String.format(format, "<font color='#999999'>" + commentContent.getFromUserName() + "</font>",
                "<font color='#999999'>" + commentContent.getToUserName() + "</font>", commentContent.getNewsReplyContent());
        holder.mTvReplyCommentContent.setText(Html.fromHtml(html));
        holder.mTvReplyCommentContent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.onItemClick(position, commentContent, v);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return mNewsReplyCommentBeans == null ? 0 : mNewsReplyCommentBeans.size();
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/dialog/RuleViewDialog.java<|end_filename|>
package com.scj.beilu.app.ui.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.widget.RuleView;

/**
 * @author Mingxun
 * @time on 2019/3/12 15:26
 */
public class RuleViewDialog extends AppCompatDialogFragment implements RuleView.OnValueChangedListener, View.OnClickListener {


    private TextView mTvRuleVal;
    private TextView mTvUnit;
    private RuleView mRuleView;
    private TextView mTvCancel, mTvSave;
    private static final String UNIT = "unit";
    private String mUnit;

    private OnGirth mOnGirth;
    private float mVal;

    public interface OnGirth {
        void onGirthVal(float val);
    }

    public static RuleViewDialog newInstance(String unit) {

        Bundle args = new Bundle();
        args.putString(UNIT, unit);
        RuleViewDialog fragment = new RuleViewDialog();
        fragment.setArguments(args);
        return fragment;
    }

    public void setOnGirth(OnGirth onGirth) {
        mOnGirth = onGirth;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mUnit = arguments.getString(UNIT);
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new MyBottomSheetDialog(getContext());
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_rule_view, container);
        mRuleView = view.findViewById(R.id.rule_view);
        mTvRuleVal = view.findViewById(R.id.tv_rule_val);
        mTvUnit = view.findViewById(R.id.tv_unit);
        mTvCancel = view.findViewById(R.id.tv_cancel);
        mTvSave = view.findViewById(R.id.tv_save);
        mRuleView.setOnValueChangedListener(this);
        mTvSave.setOnClickListener(this);
        mTvCancel.setOnClickListener(this);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (mUnit.equals("kg")) {
            mRuleView.setValue(0, 200, 50, 0.1f, 10);
        } else if (mUnit.equals("%")) {
            mRuleView.setValue(0, 100, 1, 0.1f, 10);
        } else {
            mRuleView.setValue(0, 150, 30, 0.1f, 10);
        }
        mTvRuleVal.setText(Float.toString(mRuleView.getCurrentValue()));
        mTvUnit.setText(mUnit);
    }

    @Override
    public void onValueChanged(float value) {
        mVal = value;
        mTvRuleVal.setText(Float.toString(value));
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_cancel:
                dismiss();
                break;
            case R.id.tv_save:
                if (mOnGirth != null) {
                    mOnGirth.onGirthVal(mVal);
                }
                dismiss();
                break;
        }
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/find/adapter/CommentContentAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.find.adapter;

import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;

/**
 * author:SunGuiLan
 * date:2019/2/11
 * descriptin:  消息
 */
public class CommentContentAdapter extends RecyclerView.Adapter<CommentContentAdapter.CommentContentViewHolder> {

    @NonNull
    @Override
    public CommentContentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_find_comment_three, parent, false);
        return new CommentContentViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull CommentContentViewHolder holder, int position) {
        holder.mRecyclerView.setAdapter(new CommentReplyAdapter());
        holder.mRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                super.getItemOffsets(outRect, view, parent, state);
                outRect.set(0, 10, 0, 30);
            }
        });
    }


    @Override
    public int getItemCount() {
        return 5;
    }

    class CommentContentViewHolder extends BaseViewHolder {
        private RecyclerView mRecyclerView;

        public CommentContentViewHolder(View itemView) {
            super(itemView);
            mRecyclerView = findViewById(R.id.rv_reply);
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/news/NewsCommentPre.java<|end_filename|>
package com.scj.beilu.app.mvp.news;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.callback.ObserverCallback;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.base.BaseCheckArrayView;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.news.bean.NewsCommentBean;
import com.scj.beilu.app.mvp.news.bean.NewsDetailsCommentBean;
import com.scj.beilu.app.mvp.news.bean.NewsReplyCommentBean;
import com.scj.beilu.app.mvp.news.model.INewsInfo;
import com.scj.beilu.app.mvp.news.model.NewsInfoImpl;
import com.scj.beilu.app.mvp.user.entity.UserInfoEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/2/15 21:54
 */
public class NewsCommentPre extends BaseMvpPresenter<NewsCommentPre.NewsCommentView> {
    private INewsInfo mINews;

    //评论列表数据
    private final List<NewsCommentBean> mCommentBeans = new ArrayList<NewsCommentBean>();
    private int mCurrentPage;

    public NewsCommentPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mINews = new NewsInfoImpl(mBuilder);
    }

    public void getCommentList(final int newsId, final int currentPage) {
        mCurrentPage = currentPage;
        onceViewAttached(new ViewAction<NewsCommentView>() {
            @Override
            public void run(@NonNull final NewsCommentView mvpView) {
                mINews.setParamsNewsDetailsCommentByNewsId(newsId, currentPage)
                        .subscribe(new BaseResponseCallback<NewsDetailsCommentBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(NewsDetailsCommentBean newsDetailsCommentBean) {
                                List<NewsCommentBean> commentList = newsDetailsCommentBean.getPage().getList();
                                if (mCurrentPage == 0) {
                                    mCommentBeans.clear();
                                }
                                mvpView.onCheckLoadMore(commentList);
                                mCommentBeans.addAll(commentList);
                                mvpView.onCommentList(mCommentBeans);
                            }
                        });
            }
        });
    }


    public void crateComment(final int newsId, final String content) {
        mBuilder.setLoadType(ShowConfig.NONE);
        onceViewAttached(new ViewAction<NewsCommentView>() {
            @Override
            public void run(@NonNull final NewsCommentView mvpView) {
                mINews.setParamsCreateComment(newsId, content)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onCommentResult(resultMsgBean.getResult());
                            }
                        });
            }
        });
    }

    public void replyCommentContent(final int newsComId, final int toUserId, final String commentContent) {
        onceViewAttached(new ViewAction<NewsCommentView>() {
            @Override
            public void run(@NonNull final NewsCommentView mvpView) {
                mINews.setReplyCommentContent(newsComId, toUserId, commentContent)
                        .subscribe(new BaseResponseCallback<ResultMsgBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ResultMsgBean resultMsgBean) {
                                mvpView.onReplyResult(resultMsgBean.getResult());

                            }
                        });
            }
        });
    }

    /**
     * 将回复的评论内容显示到列表中
     */
    public void notifyReplyContentChanged(final int position, final NewsCommentBean replyToUser,
                                          final NewsReplyCommentBean replyChild, final String commentContent) {
        onceViewAttached(new ViewAction<NewsCommentView>() {
            @Override
            public void run(@NonNull final NewsCommentView mvpView) {
                mINews.getUserInfoByToken()
                        .subscribe(new ObserverCallback<UserInfoEntity>(mBuilder.build(mvpView)) {
                            @Override
                            public void onNext(UserInfoEntity userInfoEntity) {
                                NewsReplyCommentBean replyCommentBean = null;
                                if (replyToUser != null) {//创建评论时
                                    replyCommentBean = setReplyContent(replyToUser.getComId(), (int) userInfoEntity.getUserId(),
                                            userInfoEntity.getUserNickName(), replyToUser.getUserId(),
                                            replyToUser.getUserName(), commentContent);
                                } else if (replyChild != null) {//回复评论时
                                    replyCommentBean = setReplyContent(replyChild.getNewsComId(), (int) userInfoEntity.getUserId(),
                                            userInfoEntity.getUserNickName(),
                                            replyChild.getToUserId(), replyChild.getToUserName(), commentContent);
                                }

                                if (replyCommentBean != null) {
                                    List<NewsReplyCommentBean> replyList = mCommentBeans.get(position).getNewsComReplyList();
                                    replyList.add(replyCommentBean);

                                    mvpView.notifyItemChange(position);
                                }
                            }
                        });
            }
        });
    }

    private NewsReplyCommentBean setReplyContent(int newsComId, int fromUserId, String fromUserName, int toUserId, String toUserName, String commentContent) {
        NewsReplyCommentBean replyBean = new NewsReplyCommentBean();
        replyBean.setFromUserId(fromUserId);
        replyBean.setFromUserName(fromUserName);
        replyBean.setToUserName(toUserName);
        replyBean.setToUserId(toUserId);
        replyBean.setNewsComId(newsComId);
        replyBean.setNewsReplyContent(commentContent);
        return replyBean;
    }

    public interface NewsCommentView extends BaseCheckArrayView {

        void onCommentList(List<NewsCommentBean> commentList);

        void onReplyResult(String result);

        void onCommentResult(String result);

        void notifyItemChange(int position);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/action/ActionDetailsContentPre.java<|end_filename|>
package com.scj.beilu.app.mvp.action;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.action.bean.ActionInfoBean;
import com.scj.beilu.app.mvp.action.bean.ActionInfoResultBean;
import com.scj.beilu.app.mvp.action.model.ActionInfoImpl;
import com.scj.beilu.app.mvp.action.model.IActionInfo;

/**
 * @author Mingxun
 * @time on 2019/3/18 21:17
 */
public class ActionDetailsContentPre extends BaseMvpPresenter<ActionDetailsContentPre.ActionDetailsContentView> {
    private IActionInfo mActionInfo;

    public ActionDetailsContentPre(Context context) {
        super(context, ShowConfig.LOADING_DIALOG, ShowConfig.ERROR_TOAST);
        mActionInfo = new ActionInfoImpl(mBuilder);
    }

    public void getActionDetailsById(final int actionId) {
        onceViewAttached(new ViewAction<ActionDetailsContentView>() {
            @Override
            public void run(@NonNull final ActionDetailsContentView mvpView) {
                mActionInfo.getActionInfo(actionId)
                        .subscribe(new BaseResponseCallback<ActionInfoResultBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(ActionInfoResultBean actionInfoBean) {
                                mvpView.onActionInfoResult(actionInfoBean.getAction());
                            }
                        });
            }
        });
    }

    public interface ActionDetailsContentView extends MvpView {
        void onActionInfoResult(ActionInfoBean actionInfo);
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/order/adapter/OrderStatusListAdapter.java<|end_filename|>
package com.scj.beilu.app.ui.order.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mx.pro.lib.fragmentation.support.SupportFragment;
import com.scj.beilu.app.GlideApp;
import com.scj.beilu.app.GlideRequest;
import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseViewHolder;
import com.scj.beilu.app.listener.OnItemClickListener;
import com.scj.beilu.app.mvp.order.bean.OrderInfoBean;

import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/1/17 16:04
 */
public class OrderStatusListAdapter extends RecyclerView.Adapter<OrderStatusListAdapter.OrderStatusViewHolder> {

    private List<OrderInfoBean> mOrderInfoList;
    private GlideRequest<Drawable> mOriginalRequest;
    private GlideRequest<Drawable> mThumbnailRequest;
    private final String mRMB;
    private OnItemClickListener<OrderInfoBean> mOnItemClickListener;

    public OrderStatusListAdapter(SupportFragment frag) {
        mOriginalRequest = GlideApp.with(frag).asDrawable().centerCrop();
        mThumbnailRequest = GlideApp.with(frag).asDrawable().centerCrop();
        mRMB = frag.getString(R.string.txt_rmb);
    }

    public void setOnItemClickListener(OnItemClickListener<OrderInfoBean> onItemClickListener) {
        mOnItemClickListener = onItemClickListener;
    }

    public void setOrderInfoList(List<OrderInfoBean> orderInfoList) {
        mOrderInfoList = orderInfoList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public OrderStatusViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_order_status, parent, false);
        return new OrderStatusViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull OrderStatusViewHolder holder, int position) {
        try {
            OrderInfoBean orderInfoBean = mOrderInfoList.get(position);
            holder.mTvGoodsName.setText(orderInfoBean.getProductName());
            mOriginalRequest.load(orderInfoBean.getProductPicOriginalAddr())
                    .thumbnail(mThumbnailRequest.load(orderInfoBean.getProductPicCompressionAddr()))
                    .into(holder.mIvGoodsImg);
            holder.mTvGoodsUnitPrice.setText(String.format(mRMB, orderInfoBean.getProductDiscountPrice()));
            holder.mTvGoodsNum.setText("x" + orderInfoBean.getProductCount());
            holder.mTvGoodsNumDesc.setText(String.format("共%d件商品", orderInfoBean.getProductCount()));
            holder.mTvGoodsTotalPrice.setText("合计: " + String.format(mRMB, orderInfoBean.getTotalPrice()));
            int orderStatusId = orderInfoBean.getOrderStatusId();
            holder.mTvStatus.setText(orderStatus(orderStatusId));
            holder.mBtnOrderInfo.setText(clickTxt(orderStatusId));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private String orderStatus(int orderStatus) {
        switch (orderStatus) {
            case 1:
                return "待付款";
            case 2:
                return "支付成功";
            case 3:
                return "待发货";
            case 4:
                return "已发货";
            case 6:
            case 7:
                return "退款中";
            case 8:
                return "同意退款";
            case 9:
                return "已完成";
            default:
                return "";
        }
    }

    private String clickTxt(int orderStatus) {
        switch (orderStatus) {
            case 1:
                return "去付款";
            case 2:
            case 3:
            case 4:
            case 5:
                return "查看物流";
            case 8:
                return "查看详情";
            case 6:
            case 7:
                return "查看退款进度";
            default:
                return "去付款";
        }

    }

    @Override
    public int getItemCount() {
        return mOrderInfoList == null ? 0 : mOrderInfoList.size();
    }

    public class OrderStatusViewHolder extends BaseViewHolder {
        private TextView mTvStatus, mTvGoodsName, mTvGoodsUnitPrice,
                mTvGoodsNum, mTvGoodsNumDesc, mTvGoodsTotalPrice;
        private ImageView mIvGoodsImg;
        private LinearLayout mLlOrderInfo;
        private Button mBtnOrderInfo;

        public OrderStatusViewHolder(View itemView) {
            super(itemView);
            mTvStatus = findViewById(R.id.tv_order_info_status_name);
            mTvGoodsName = findViewById(R.id.tv_order_info_goods_name);
            mTvGoodsUnitPrice = findViewById(R.id.tv_unit_price);
            mTvGoodsNum = findViewById(R.id.tv_course_order_by_num);
            mTvGoodsNumDesc = findViewById(R.id.tv_course_order_by_num_desc);
            mTvGoodsTotalPrice = findViewById(R.id.tv_order_info_goods_total_price);
            mIvGoodsImg = findViewById(R.id.iv_order_info_goods_img);
            mLlOrderInfo = findViewById(R.id.ll_order_info_content);
            mBtnOrderInfo = findViewById(R.id.btn_order_info_click);
            mLlOrderInfo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), mOrderInfoList.get(getAdapterPosition()), v);
                    }
                }
            });
            mBtnOrderInfo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnItemClickListener != null) {
                        mOnItemClickListener.onItemClick(getAdapterPosition(), mOrderInfoList.get(getAdapterPosition()), v);
                    }
                }
            });
        }
    }
}


<|start_filename|>app/src/main/java/com/scj/beilu/app/mvp/course/CourseListPre.java<|end_filename|>
package com.scj.beilu.app.mvp.course;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mx.pro.lib.mvp.network.config.BaseMvpPresenter;
import com.mx.pro.lib.mvp.network.config.ShowConfig;
import com.scj.beilu.app.base.BaseResponseCallback;
import com.scj.beilu.app.mvp.base.BaseCheckArrayView;
import com.scj.beilu.app.mvp.course.bean.CourseInfoBean;
import com.scj.beilu.app.mvp.course.bean.CourseListBean;
import com.scj.beilu.app.mvp.course.model.CourseInfoImpl;
import com.scj.beilu.app.mvp.course.model.ICourseInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mingxun
 * @time on 2019/3/20 17:15
 */
public class CourseListPre extends BaseMvpPresenter<CourseListPre.CourseListView> {


    private ICourseInfo mCourseInfo;
    private final List<CourseInfoBean> mCourseInfoBeans = new ArrayList<>();

    public CourseListPre(Context context) {
        super(context, ShowConfig.LOADING_REFRESH, ShowConfig.ERROR_TOAST);
        mCourseInfo = new CourseInfoImpl(mBuilder);
    }

    public void getCourseList(final int courseTypeId, final int currentPage) {
        onceViewAttached(new ViewAction<CourseListView>() {
            @Override
            public void run(@NonNull final CourseListView mvpView) {
                mCourseInfo.getCourseList(courseTypeId, currentPage)
                        .subscribe(new BaseResponseCallback<CourseListBean>(mBuilder.build(mvpView)) {
                            @Override
                            public void onRequestResult(CourseListBean courseListBean) {
                                try {
                                    List<CourseInfoBean> courses = courseListBean.getPage().getList();
                                    if (currentPage == 0) {
                                        mCourseInfoBeans.clear();
                                    }
                                    mCourseInfoBeans.addAll(courses);
                                    mvpView.onCheckLoadMore(courses);
                                    mvpView.onCourseListResult(mCourseInfoBeans);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        });
            }
        });
    }

    public interface CourseListView extends BaseCheckArrayView {
        void onCourseListResult(List<CourseInfoBean> courseInfoBeanList);
    }
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/MvpPresenter.java<|end_filename|>
package com.mx.pro.lib.mvp;

import android.support.annotation.NonNull;
import android.support.annotation.UiThread;

public interface MvpPresenter<V extends MvpView> {

    @UiThread
    void attachView(@NonNull V view);

    @UiThread
    void detachView();

    @UiThread
    void destroy();
}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/network/config/BaseMvpPresenter.java<|end_filename|>
package com.mx.pro.lib.mvp.network.config;

import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.util.Base64;

import com.mx.pro.lib.mvp.MvpQueuingBasePresenter;
import com.mx.pro.lib.mvp.MvpView;
import com.mx.pro.lib.mvp.delegate.LoadDelegate;
import com.mx.pro.lib.mvp.network.callback.ObserverCallback;

import java.util.Map;

import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;

import io.reactivex.disposables.CompositeDisposable;

/**
 * @author Mingxun
 * @time on 2018/12/24 18:33
 */
public class BaseMvpPresenter<V extends MvpView> extends MvpQueuingBasePresenter<V> {

    protected Context mContext;

    protected final CompositeDisposable mCompositeDisposable = new CompositeDisposable();

    protected LoadDelegate.Builder mBuilder;


    public BaseMvpPresenter() {
        this(null);
    }

    public BaseMvpPresenter(Context context) {
        mContext = context;
        initLoad(ShowConfig.NONE, ShowConfig.ERROR_TOAST);
    }

    public BaseMvpPresenter(Context context, @ShowConfig.loading int loadType, @ShowConfig.error int loadErrType) {
        mContext = context;
        initLoad(loadType, loadErrType);
    }

    protected void initLoad(@ShowConfig.loading int loadType, @ShowConfig.error int loadErrType) {
        mBuilder = new LoadDelegate.Builder()
                .setLoadType(loadType)
                .setLoadErrType(loadErrType)
                .setContext(mContext)
                .setCompositeDisposable(mCompositeDisposable);
    }


    @Override
    public void detachView() {
        super.detachView();
        cancel();
    }

    public void cancel() {
        if (mCompositeDisposable == null) return;
        mCompositeDisposable.clear();
    }


    // 加密
    public static String Encrypt(String val) {
        try {
            byte[] raw = "chongqinsanchaji".getBytes("utf-8");
            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式"
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
            byte[] encrypted = cipher.doFinal(val.getBytes("utf-8"));
            return Base64.encodeToString(encrypted, android.util.Base64.DEFAULT);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }


    public void checkUserIsLogin(final @IdRes int resId) {
        onceViewAttached(new ViewAction<V>() {
            @Override
            public void run(@NonNull final V mvpView) {
                mBuilder.build().getHeader()
                        .subscribe(new ObserverCallback<Map<String, String>>(mBuilder.build()) {
                            @Override
                            public void onNext(Map<String, String> token) {
                                mvpView.userIsLogin(token.size() > 0, resId);
                            }
                        });
            }
        });
    }

}


<|start_filename|>app/src/main/java/com/scj/beilu/app/ui/mine/MineStartBindPhoneFrag.java<|end_filename|>
package com.scj.beilu.app.ui.mine;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.scj.beilu.app.R;
import com.scj.beilu.app.base.BaseMvpFragment;
import com.scj.beilu.app.mvp.common.bean.ResultMsgBean;
import com.scj.beilu.app.mvp.mine.MinePhoneBindPre;
import com.scj.beilu.app.util.CheckUtils;
import com.scj.beilu.app.util.ToastUtils;

/**
 * @author Mingxun
 * @time on 2019/4/16 22:26
 */
public class MineStartBindPhoneFrag extends BaseMvpFragment<MinePhoneBindPre.MinePhoneBindView, MinePhoneBindPre>
        implements MinePhoneBindPre.MinePhoneBindView, View.OnClickListener {

    private static final String PHONE = "phone";
    private String mPhone;
    private TextView mTvSendHint, mTvCountdown;
    private EditText mEtVerifyCode;
    private Button mBtnStartVerify, mBtnRestartSend;

    private String mCode;

    public static MineStartBindPhoneFrag newInstance(String phone) {

        Bundle args = new Bundle();
        args.putString(PHONE, phone);
        MineStartBindPhoneFrag fragment = new MineStartBindPhoneFrag();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mPhone = arguments.getString(PHONE);
        }
    }

    @Override
    public MinePhoneBindPre createPresenter() {
        return new MinePhoneBindPre(mFragmentActivity);
    }

    @Nullable
    @Override
    public int getLayout() {
        return R.layout.frag_input_code;
    }

    @Override
    public void initView() {
        super.initView();
        mTvSendHint = findViewById(R.id.tv_send_hint);
        mTvCountdown = findViewById(R.id.tv_countdown);
        mEtVerifyCode = findViewById(R.id.et_verify_code);
        mBtnStartVerify = findViewById(R.id.btn_start_verify);
        mBtnRestartSend = findViewById(R.id.btn_restart_send);

        mBtnStartVerify.setOnClickListener(this);
        mBtnRestartSend.setOnClickListener(this);
        hideSoftInput();

        try {
            CheckUtils.checkStringIsNull(mPhone, "");

            getPresenter().setHintNum(mPhone);
            getPresenter().startSendCode(mPhone);

            mEtVerifyCode.addTextChangedListener(textWatcher);
            mBtnStartVerify.setEnabled(false);
            mBtnRestartSend.setEnabled(false);
        } catch (RuntimeException e) {

        }
    }

    private final TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() == 6) {
                onButtonEnable(true, s.toString());
            } else {
                onButtonEnable(false, null);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    };


    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_start_verify:
                getPresenter().startBind(mCode, mPhone);
                break;
            case R.id.btn_restart_send:
                getPresenter().startSendCode(mPhone);
                break;
        }
    }

    private void onButtonEnable(boolean enable, String text) {
        mCode = text;
        mBtnStartVerify.setEnabled(enable);
    }

    @Override
    public void showSendHint(String content) {
        mTvSendHint.setText(content);
    }

    @Override
    public void codeResult(ResultMsgBean result) {
        mTimer.start();
        ToastUtils.showToast(mFragmentActivity, result.getResult());
    }

    @Override
    public void onBindResult(String result) {
        mFragmentActivity.setResult(MineAccountManagerFrag.REQUEST_CODE);
        ToastUtils.showToast(mFragmentActivity, result);
        mFragmentActivity.finish();
    }

    private final CountDownTimer mTimer = new CountDownTimer(60000, 1000) {

        @Override
        public void onTick(long millisUntilFinished) {
            String hint = String.format(getString(R.string.countdown_hint), (millisUntilFinished / 1000) + "s");
            mTvCountdown.setText(hint);
        }

        @Override
        public void onFinish() {
            String hint = String.format(getString(R.string.countdown_hint), "0s");
            mTvCountdown.setText(hint);
            mBtnRestartSend.setEnabled(true);
            mBtnRestartSend.setText("重新发送");
        }
    };

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mTimer != null)
            mTimer.cancel();
    }


}


<|start_filename|>prolib/src/main/java/com/mx/pro/lib/mvp/manager/ActivityScopedCache.java<|end_filename|>
package com.mx.pro.lib.mvp.manager;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.mx.pro.lib.BuildConfig;
import com.mx.pro.lib.mvp.MvpPresenter;
import com.mx.pro.lib.mvp.MvpView;
import com.orhanobut.logger.Logger;

import java.util.HashMap;
import java.util.Map;

/**
 * This class basically represents a Map for View Id to the Presenter / ViewState.
 * One instance of this class is also associated by {@link PresenterManager} to one Activity (kept
 * across screen orientation changes)
 */
class ActivityScopedCache {

    private final Map<String, PresenterHolder> mPresenterHolderMap = new HashMap<>();

    public ActivityScopedCache() {
    }

    public void clear() {
        for (PresenterHolder holder : mPresenterHolderMap.values()) {
            if (holder.mPresenter != null) {
                holder.mPresenter.detachView();
            }

            if (BuildConfig.LOG_DEBUG) {
                Logger.d("Found a Presenter that is still alive. This should never happen." +
                        " It seems that a MvpDelegate / MviDelegate didn't work correctly because this" +
                        " Delegate should have removed the presenter. The Presenter was "
                        + holder.mPresenter);
            }
        }
        mPresenterHolderMap.clear();
    }

    /**
     * Get the Presenter for a given {@link MvpView} if exists or <code>null</code>
     *
     * @param viewId The mosby internal view id
     * @param <P>    The type tof the {@link MvpPresenter}
     * @return The Presenter for the given view id or <code>null</code>
     */
    @Nullable
    public <P> P getPresenter(@NonNull String viewId) {
        PresenterHolder holder = mPresenterHolderMap.get(viewId);
        return holder == null ? null : (P) holder.mPresenter;
    }

    /**
     * Get the ViewState for a given {@link MvpView} if exists or <code>null</code>
     *
     * @param viewId The mosby internal view id
     * @param <VS>   The type tof the {@link MvpPresenter}
     * @return The ViewState for the given view id or <code>null</code>
     */
    @Nullable
    public <VS> VS getViewState(@NonNull String viewId) {
        PresenterHolder holder = mPresenterHolderMap.get(viewId);
        return holder == null ? null : (VS) holder.mViewState;
    }

    /**
     * Put the presenter in the internal cache
     *
     * @param viewId    The mosby internal View id of the {@link MvpView} which the presenter is
     *                  associated to.
     * @param presenter The Presenter
     */
    public void putPresenter(@NonNull String viewId,
                             @NonNull MvpPresenter<? extends MvpView> presenter) {
        if (viewId == null) {
            throw new NullPointerException("viewId is null");
        }
        if (presenter == null) {
            throw new NullPointerException("presenter is null");
        }

        PresenterHolder holder = mPresenterHolderMap.get(viewId);
        if (holder == null) {
            holder = new PresenterHolder();
            holder.mPresenter = presenter;
            mPresenterHolderMap.put(viewId, holder);
        } else {
            holder.mPresenter = presenter;
        }

        if (BuildConfig.LOG_DEBUG) {
            Logger.d("presenter Map save success");
        }
    }

    /**
     * Removes the Presenter (and ViewState) from the internal storage
     *
     * @param viewId The msoby internal view id
     */
    public void remove(@NonNull String viewId) {
        if (viewId == null) {
            throw new NullPointerException("viewId is null");
        }
        mPresenterHolderMap.remove(viewId);

        if (BuildConfig.LOG_DEBUG) {
            Logger.d("presenterMap remove success");
        }
    }

    /**
     * Put the viewstate in the internal cache
     *
     * @param viewId    The mosby internal View id of the {@link MvpView} which the presenter is
     *                  associated to.
     * @param viewState The Viewstate
     */
    public void putViewState(@NonNull String viewId, @NonNull Object viewState) {
        if (viewId == null) {
            throw new NullPointerException("viewId is null");
        }
        if (viewState == null) {
            throw new NullPointerException("viewState is null");
        }

        PresenterHolder holder = mPresenterHolderMap.get(viewId);
        if (holder == null) {
            holder = new PresenterHolder();
            holder.mViewState = viewState;
            mPresenterHolderMap.put(viewId, holder);
        } else {
            holder.mViewState = viewState;
        }
        if (BuildConfig.LOG_DEBUG) {
            Logger.w("putViewState is save success");
        }
    }

    static final class PresenterHolder {
        private MvpPresenter<?> mPresenter;
        private Object mViewState;
    }
}
