天天看點

Android viewpage 設定上一頁下一頁按鈕

目錄

​​Android viewpage 設定上一頁下一頁按鈕​​

​​接口回調回去目前viewpage 頁碼​​

Viewpager介紹

1.Viewpager,視圖翻頁工具,提供了多頁面切換的效果。Android 3.0後引入的一個UI控件,位于v4包中。低版本使用需要導入v4包,但是現在我們開發的APP一般不再相容3.0及以下的系統版本,另外現在大多數使用Android studio進行開發,預設導入v7包,v7包含了v4,是以不用導包,越來越友善了。

2.Viewpager使用起來就是我們通過建立adapter給它填充多個view,左右滑動時,切換不同的view。Google官方是建議我們使用Fragment來填充ViewPager的,這樣 可以更加友善的生成每個Page,以及管理每個Page的生命周期。

3.ViewPager 直接繼承了** ViewGroup**,所有它是一個容器類,可以在其中添加其他的 view 類。

ViewPager 需要一個** PagerAdapter 擴充卡類給它提供資料**。

ViewPager 經常和 Fragment 一起使用,并且提供了專門的 FragmentPagerAdapter 和 FragmentStatePagerAdapter 類供 Fragment 中的 ViewPager 使用。

RecyclerView加載Fragment這裡涉及到細節非常的多,因為Fragment本身有生命周期,是以我們如何通過​

​Adapter​

​​來有效維護​

​Fragment​

​的生命周期,這本身就是一種挑戰。\

2. ViewPager2的基本結構

 ViewPager2的源碼中我們知道,ViewPager2繼承ViewGroup,其内部包含有一個RecyclerView控件,其他部分都是圍繞着這個​

​RecyclerView​

​​來實作的。總之,​

​ViewPager2​

​​是以一個組合的方式來實作的。

這其中,​​

​ScrollEventAdapter​

​​的作用是将​

​RecyclerView.OnScrollListener​

​​事件轉變為​

​ViewPager2.OnPageChangeCallback​

​​事件;​

​FakeDrag​

​​的作用是用來實作模拟拖動的效果;​

​PageTransformerAdapter​

​​的作用是将頁面的滑動事件轉變為比率變化,比如說,一個頁面從左到右滑動,變化規則是從0~1,關于這個元件,我相信熟悉​

​ViewPager2​

​​的同學都應該都知道。

最後就是最重要的東西--​​

​FragmentStateAdapter​

​​,這個​

​Adapter​

​​在為了加載Fragment,花費了很多的功夫,為我們想要使用​

​Adapter​

​​加載​

​Fragment​

​提供了非常權威的參考。

Android viewpage 設定上一頁下一頁按鈕

Android viewpage 設定上一頁下一頁按鈕

​編輯

Android viewpage 設定上一頁下一頁按鈕

​編輯

接口回調回去目前viewpage 頁碼

package com.base.emergency_bureau.ui.module.question.fragment;

/**
 * @ProjectName: emergency_bureau
 * @Package: com.base.emergency_bureau.ui.module.question.fragment
 * @ClassName: getCurrentPage
 * @Description: java類作用描述
 * @Author: liys
 * @CreateDate: 2021/5/17 14:55
 * @UpdateUser: 更新者
 * @UpdateDate: 2021/5/17 14:55
 * @UpdateRemark: 更新說明
 * @Version: 1.0
 */
public interface getCurrentPage {
    int getPage( int;
}      
public class AnswerActivity extends FragmentActivity implements getCurrentPage{      
currentPage = getPage;
        switch (getPage) {
            case 1:
                tvSubmit.setVisibility(View.GONE);
                btNext.setVisibility(View.VISIBLE);
                llQuestionNextLast.setVisibility(View.VISIBLE);
                btLast.setVisibility(View.GONE);
                break;
            case 2:
                tvSubmit.setVisibility(View.GONE);
                btNext.setVisibility(View.VISIBLE);
                btLast.setVisibility(View.VISIBLE);
                llQuestionNextLast.setVisibility(View.VISIBLE);
                break;
            case 3:
                tvSubmit.setVisibility(View.GONE);
                btNext.setVisibility(View.VISIBLE);
                btLast.setVisibility(View.VISIBLE);
                llQuestionNextLast.setVisibility(View.VISIBLE);
                break;
            case 4:
                tvSubmit.setVisibility(View.GONE);
                btNext.setVisibility(View.VISIBLE);
                btLast.setVisibility(View.VISIBLE);
                llQuestionNextLast.setVisibility(View.VISIBLE);
                break;
            case 5:
                btNext.setVisibility(View.GONE);
                btLast.setVisibility(View.GONE);
                llQuestionNextLast.setVisibility(View.GONE);
                tvSubmit.setVisibility(View.VISIBLE);
                break;
            default:
                break;
        }
        return 0;      

在Fragment 中設定事件觸發(重寫方法:setUserVisibleHint 在目前頁面可見情況下)

@Override
    public void setUserVisibleHint(boolean) {
        super.setUserVisibleHint(isVisibleToUser);
        if(isVisibleToUser){
            getCurrentPage.getPage(5);
        } else      

\

android 簡單實作 recycleview,adapter 展示item

Intent傳遞參數,需要進行本地的執行個體化;

Android viewpage 設定上一頁下一頁按鈕

public static class ListDTO implements Serializable {

Android viewpage 設定上一頁下一頁按鈕
setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                    Intent intent = new Intent(mcontext,DangerAcceptanceActivity.class);
                    intent.putExtra("data",list.get(position));
                    startActivity(intent);


            }
        });      

activity 展示list

package com.base.emergency_bureau.ui.module.hidden_trouble;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.base.emergency_bureau.R;
import com.base.emergency_bureau.base.BaseActivity;
import com.base.emergency_bureau.base.BaseRequestCallBack;
import com.base.emergency_bureau.base.BaseRequestParams;
import com.base.emergency_bureau.base.Config;
import com.base.emergency_bureau.base.UserInfoSP;
import com.base.emergency_bureau.base.XHttpUtils;
import com.base.emergency_bureau.ui.bean.DangerCountBean;
import com.base.emergency_bureau.ui.bean.LurkingPerilCheckList;
import com.base.emergency_bureau.ui.module.adpter.DangerAccountListAdapter;
import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;

//隐患核實清單
public class DangeAccountListActivity extends BaseActivity {

    @BindView(R.id.back)
    RelativeLayout back;
    @BindView(R.id.list_item_recycler)
    RecyclerView list_item_recycler;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout mRefreshlayout;


    private int pageNum = 1,pageSize = 20;
    private List<DangerCountBean.DataDTO.ListDTO> list = new ArrayList<>();
    private DangerAccountListAdapter adapter;
    private int status;//0 待核實清單 1 待整改清單 2 待驗收清單
    @Override
    protected void initWindow() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_danger_account;
    }

    @Override
    protected void initView() {
        status = getIntent().getIntExtra("status",0);
        back.setOnClickListener(v -> finish());

        mRefreshlayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
                pageNum = 1;
                getData();
            }
        });
        mRefreshlayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                pageNum++;
                getDataRf();
            }
        });
        getData();
    }

    private void getDataRf() {

        Map<String, Object> map = new HashMap<>();
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);
        map.put("userId", UserInfoSP.getId(mcontext));
        map.put("status", status);
        BaseRequestParams requestParams = new BaseRequestParams(Config.LurkingPerilCheckList,  map);
        XHttpUtils.getInstance().doHttpPost(requestParams, new BaseRequestCallBack() {
            @Override
            public void successEnd(String result) {
                mRefreshlayout.finishRefresh();
                mRefreshlayout.finishLoadMore();
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    int status = jsonObject.getInt("status");
                    if (status == 0){
                        list.addAll(GsonUtils.fromJson(result, DangerCountBean.class).getData().getList());
                        adapter.notifyDataSetChanged();
                    }else {
                        ToastUtils.showShort(jsonObject.getString("msg"));
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                mRefreshlayout.finishRefresh();
                mRefreshlayout.finishLoadMore();
            }

        });


    }

    private void getData() {

        Map<String, Object> map = new HashMap<>();
        map.put("pageNum", pageNum);
        map.put("pageSize", pageSize);
        map.put("userId", UserInfoSP.getId(mcontext));
        map.put("status", status);
        BaseRequestParams requestParams = new BaseRequestParams(Config.LurkingPerilCheckList,  map);
        XHttpUtils.getInstance().doHttpPost(requestParams, new BaseRequestCallBack() {
            @Override
            public void successEnd(String result) {
                mRefreshlayout.finishRefresh();
                mRefreshlayout.finishLoadMore();
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    int status = jsonObject.getInt("status");
                    if (status == 0){
                        list = GsonUtils.fromJson(result, DangerCountBean.class).getData().getList();
                        bindData();
                    }else {
                        ToastUtils.showShort(jsonObject.getString("msg"));
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
                mRefreshlayout.finishRefresh();
                mRefreshlayout.finishLoadMore();
            }

        });


    }

    private void bindData(){
        LinearLayoutManager gridLayoutManager = new LinearLayoutManager(mcontext);
        list_item_recycler.setLayoutManager(gridLayoutManager);
        adapter = new DangerAccountListAdapter(R.layout.item_danger_verification,list);
        list_item_recycler.setAdapter(adapter);

        View emptyView = LayoutInflater.from(mcontext).inflate(R.layout.common_nodata_layout, null);
        adapter.setEmptyView(emptyView);

        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

                    Intent intent = new Intent(mcontext,DangerAcceptanceActivity.class);
                    intent.putExtra("data",list.get(position));
                    startActivity(intent);


            }
        });
    }
    @Override
    protected void onResumeAction() {
        pageNum=1;
        getData();      

Bean 類不寫了,太大

layout

version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ui.module.hidden_trouble.DangerVerificationListActivity">

    <FrameLayout
        android:id="@+id/f_title"
        android:background="@color/white"
        android:layout_width="match_parent"
        android:layout_height="@dimen/size_big_40">

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:text="隐患清單"
            android:textColor="@color/black"
            android:textSize="18sp" />

        <RelativeLayout
            android:id="@+id/back"
            android:layout_width="@dimen/size_big_40"
            android:layout_height="@dimen/size_big_40"

            >

            <ImageView
                android:layout_width="@dimen/size_big"
                android:layout_height="@dimen/size_big"
                android:layout_centerInParent="true"
                android:src="@mipmap/back_lift" />
        </RelativeLayout>

    </FrameLayout>

    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:id="@+id/refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.scwang.smartrefresh.layout.header.ClassicsHeader
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </com.scwang.smartrefresh.layout.header.ClassicsHeader>

        <androidx.recyclerview.widget.RecyclerView
            android:padding="@dimen/dp_10"
            android:id="@+id/list_item_recycler"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:overScrollMode="never" />

        <com.scwang.smartrefresh.layout.footer.ClassicsFooter
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </com.scwang.smartrefresh.layout.footer.ClassicsFooter>

    </com.scwang.smartrefresh.layout.SmartRefreshLayout>


</LinearLayout>      
[在這裡插入圖檔描述](https://img-blog.csdnimg.cn/20210528142909412.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM4OTk4MjEz,size_16,color_FFFFFF,t_70)

```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:background="@drawable/white_roundrect_10dp_shape"
    android:orientation="vertical"
    android:padding="15dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="隐患描述:"
            android:textColor="@color/tc_gray_999"
            />

        <TextView
            android:id="@+id/tv_des"
            android:layout_width="0dp"
            android:layout_height="wrap_content"

            android:layout_weight="1"
            android:text=""
            android:textColor="@color/text_balck" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="隐患狀态:"
            android:textColor="@color/tc_gray_999" />

        <TextView
            android:id="@+id/tv_status"
            android:layout_width="0dp"
            android:layout_height="wrap_content"

            android:layout_weight="1"
            android:text=""
            android:textColor="@color/text_balck" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="級别:"
            android:textColor="@color/tc_gray_999" />

        <TextView
            android:id="@+id/tv_level"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text=""
            android:textColor="@color/text_balck" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="類别:"
            android:textColor="@color/tc_gray_999"
            />

        <TextView
            android:id="@+id/tv_type"
            android:layout_width="0dp"
            android:layout_height="wrap_content"

            android:layout_weight="1"
            android:text=""
            android:textColor="@color/text_balck" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="登記時間:"
            android:textColor="@color/tc_gray_999" />

        <TextView
            android:id="@+id/tv_time"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text=""
            android:textColor="@color/text_balck"      
package com.base.emergency_bureau.ui.module.adpter;

import androidx.annotation.Nullable;

import com.base.emergency_bureau.R;
import com.base.emergency_bureau.ui.bean.DangerCountBean;
import com.base.emergency_bureau.ui.bean.LurkingPerilCheckList;
import com.base.emergency_bureau.utils.Utils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class DangerAccountListAdapter extends BaseQuickAdapter<DangerCountBean.DataDTO.ListDTO, BaseViewHolder>{
    public DangerAccountListAdapter(int layoutResId, @Nullable List<DangerCountBean.DataDTO.ListDTO> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DangerCountBean.DataDTO.ListDTO item) {

        helper.setText(R.id.tv_des,item.getDescription())
                .setText(R.id.tv_type,item.getTypeName())
                .setText(R.id.tv_time,item.getCheckDate())
        .setText(R.id.tv_status, Utils.rtStatusSt(item.getStatus()));
    }
}      
.base.emergency_bureau.ui.module.hidden_trouble;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.base.emergency_bureau.R;
import com.base.emergency_bureau.base.BaseActivity;
import com.base.emergency_bureau.base.BaseRequestCallBack;
import com.base.emergency_bureau.base.BaseRequestParams;
import com.base.emergency_bureau.base.Config;
import com.base.emergency_bureau.base.UserInfoSP;
import com.base.emergency_bureau.base.XHttpUtils;
import com.base.emergency_bureau.ui.bean.DangerCountBean;
import com.base.emergency_bureau.ui.bean.LurkingPerilCheckList;
import com.base.emergency_bureau.ui.module.web.PdfActivity;
import com.base.emergency_bureau.utils.Utils;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.blankj.utilcode.util.ClickUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;

import org.angmarch.views.NiceSpinner;
import org.angmarch.views.OnSpinnerItemSelectedListener;
import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

//隐患驗收
public class DangerAcceptanceActivity extends BaseActivity {

    @BindView(R.id.tv_des)
    TextView tv_des;
    @BindView(R.id.iv_pic)
    ImageView iv_pic;
    @BindView(R.id.iv_pic_change)
    ImageView iv_pic_change;
    @BindView(R.id.sp_is_pass)
    NiceSpinner sp_is_pass;
    @BindView(R.id.ed_result)
    EditText ed_result;
    @BindView(R.id.tv_time_yanshou)
    TextView tv_time_yanshou;
    @BindView(R.id.tv_submit)
    Button tv_submit;
    @BindView(R.id.tv_zhenggai)
    TextView tv_zhenggai;
    @BindView(R.id.ed_standard)
    EditText ed_standard;
    @BindView(R.id.tv_organization)
    TextView tv_organization;
    @BindView(R.id.iv_pic_1)
    ImageView ivPic1;
    @BindView(R.id.iv_pic_2)
    ImageView ivPic2;
    @BindView(R.id.iv_pic_1_1)
    ImageView ivPic11;
    @BindView(R.id.iv_pic_2_2)
    ImageView ivPic22;

    @BindView(R.id.tv_standard)
    TextView tvStandard;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_time)
    TextView tvTime;
    @BindView(R.id.tv_jibie)
    TextView tvJibie;
    @BindView(R.id.tv_leibie)
    TextView tvLeibie;
    @BindView(R.id.tv_paicha)
    TextView tvPaicha;
    @BindView(R.id.tv_change_type)
    TextView tvChangeType;
    @BindView(R.id.tv_time_limit)
    TextView tvTimeLimit;
    @BindView(R.id.tv_time_change)
    TextView tvTimeChange;

    private DangerCountBean.DataDTO.ListDTO data;

    private List<String> list2 = new LinkedList<>(Arrays.asList("通過", "不通過"));
    private int status = 3;

    @Override
    protected void initWindow() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_danger_acceptance;
    }

    @Override
    protected void initView() {

        data = (DangerCountBean.DataDTO.ListDTO) getIntent().getSerializableExtra("data");

        tvName.setText(data.getCheckUser());
        tvTime.setText(data.getCheckDate());
        if (data.getLurkingPerilLevel().equals("0")){
            tvJibie.setText(R.string.Generate);
        }else {
            tvJibie.setText(R.string.significant);
        }
        tvLeibie.setText(data.getTypeName());

        if (data.getSort().equals("0")){
            tvPaicha.setText("自查自糾");
        }else if(data.getSort().equals("1")){
            tvPaicha.setText("政法下發隐患");
        }else {
            tvPaicha.setText("政法三方機構下發隐患");
        }

        if (data.getCorrectType().equals("0")){
            tvChangeType.setText("立即整改");
        }else {
            tvChangeType.setText("期限整改");
        }
        tvTimeLimit.setText((String)data.getCorrectLimitDate());
        tvTimeChange.setText((String)data.getCorrectDate());


        if (data != null) {
            tv_des.setText(data.getDescription());

            //以逗号分割,得出的資料存到 result 裡面
            String[] result = data.getLurkingPerilUrl().split(",");
            if (result.length == 1) {
                iv_pic.setVisibility(View.VISIBLE);
                ivPic1.setVisibility(View.GONE);
                ivPic2.setVisibility(View.GONE);
                Glide.with(mcontext).load(result[0]).override(240, 240).into(iv_pic);
            } else if (result.length == 2) {
                iv_pic.setVisibility(View.VISIBLE);
                ivPic1.setVisibility(View.VISIBLE);
                ivPic2.setVisibility(View.GONE);
                Glide.with(mcontext).load(result[0]).override(240, 240).into(iv_pic);
                Glide.with(mcontext).load(result[1]).override(240, 240).into(ivPic1);
            } else {
                iv_pic.setVisibility(View.VISIBLE);
                ivPic1.setVisibility(View.VISIBLE);
                ivPic2.setVisibility(View.VISIBLE);
                Glide.with(mcontext).load(result[0]).override(240, 240).into(iv_pic);
                Glide.with(mcontext).load(result[1]).override(240, 240).into(ivPic1);
                Glide.with(mcontext).load(result[2]).override(240, 240).into(ivPic2);
            }


            //以逗号分割,得出的資料存到 result 裡面
            String[] resultChange = data.getCorrectUrl().toString().split(",");
            if (resultChange.length == 1) {
                iv_pic_change.setVisibility(View.VISIBLE);
                ivPic11.setVisibility(View.GONE);
                ivPic22.setVisibility(View.GONE);
                Glide.with(mcontext).load(resultChange[0]).override(240, 240).into(iv_pic_change);
            } else if (resultChange.length == 2) {
                iv_pic_change.setVisibility(View.VISIBLE);
                ivPic11.setVisibility(View.VISIBLE);
                ivPic22.setVisibility(View.GONE);
                Glide.with(mcontext).load(resultChange[0]).override(240, 240).into(iv_pic_change);
                Glide.with(mcontext).load(resultChange[1]).override(240, 240).into(ivPic11);
            } else {
                iv_pic_change.setVisibility(View.VISIBLE);
                ivPic11.setVisibility(View.VISIBLE);
                ivPic22.setVisibility(View.VISIBLE);
                Glide.with(mcontext).load(resultChange[0]).override(240, 240).into(iv_pic_change);
                Glide.with(mcontext).load(resultChange[1]).override(240, 240).into(ivPic11);
                Glide.with(mcontext).load(resultChange[2]).override(240, 240).into(ivPic22);
            }


            tv_zhenggai.setText(data.getCorrectStep()+"");
            ed_standard.setText(data.getLurkingPerilStandard());
            tv_organization.setText(Utils.rtOrganizationSt(data.getOrganizationType()));

            int type = getIntent().getIntExtra("type",-1);
            if (type == 1){
                tv_submit.setVisibility(View.GONE);
                ed_result.setEnabled(false);
                ed_result.setText(data.getCorrectOpinion()+"");
                sp_is_pass.setEnabled(false);
                tv_time_yanshou.setEnabled(false);
                tv_time_yanshou.setText(data.getReceptionDate()+"");

            }
        }

        sp_is_pass.attachDataSource(list2);
        sp_is_pass.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener() {
            @Override
            public void onItemSelected(NiceSpinner parent, View view, int position, long id) {
                if (position == 0) {
                    status = 3;
                } else if (position == 1) {
                    status = 4;
                }
            }
        });


        ClickUtils.applySingleDebouncing(tv_submit, v -> {
            submit();
        });

    }

    @OnClick(R.id.tv_standard)
    public void intentStandardPdf() {
        Intent intent = new Intent(mcontext, PdfActivity.class);
        intent.putExtra("url", UserInfoSP.getSetListingStandardUrl(mcontext));
        startActivity(intent);
    }

    @OnClick(R.id.back)
    public void onBack() {
        finish();
    }

    @Override
    protected void onResumeAction() {

    }

    private void submit() {

        if (StringUtils.isEmpty(ed_result.getText().toString())) {
            ToastUtils.showShort("請上傳驗收結果");
            return;
        }
        if ("選擇時間".equals(tv_time_yanshou.getText().toString())) {
            ToastUtils.showShort("請選擇驗收時間");
            return;
        }

        Map<String, Object> map = new HashMap<>();
        map.put("id", data.getId());

        map.put("correctOpinion", Utils.replaceBlank(ed_result.getText().toString().trim()));
        map.put("receptionDate", tv_time_yanshou.getText().toString());

        map.put("status", status);


        BaseRequestParams requestParams = new BaseRequestParams(Config.UpdateReceptionLurkingPerilCheck, map);
        XHttpUtils.getInstance().doHttpPost(requestParams, new BaseRequestCallBack() {
            @Override
            public void successEnd(String result) {
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    int status = jsonObject.getInt("status");
                    if (status == 0) {
                        finish();
                    }
                    ToastUtils.showShort(jsonObject.getString("msg"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                super.onError(ex, isOnCallback);
            }

        });

    }

    @OnClick(R.id.tv_time_yanshou)
    public void showTimePick() {
        //時間選擇器
        TimePickerView pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {//選中事件回調
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                tv_time_yanshou.setText(simpleDateFormat.format(date));
                data.setCorrectDate(simpleDateFormat.format(date));
            }
        }).build();
        // pvTime.setDate(Calendar.getInstance());//注:根據需求來決定是否使用該方法(一般是精确到秒的情況),此項可以在彈出選擇器的時候重新設定目前時間,避免在初始化之後由于時間已經設定,導緻選中時間與目前時間不比對的問題。
        pvTime.show();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO:
        ButterKnife.bind(this);
    }
}