管灌系统巡查员智能手机App
app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java
@@ -3,15 +3,18 @@
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.dayu.pipirrapp.MyApplication;
import com.dayu.pipirrapp.R;
import com.dayu.pipirrapp.activity.OrderDetailActivity;
import com.dayu.pipirrapp.adapter.OrderAdapter;
@@ -27,8 +30,6 @@
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,7 +43,7 @@
 * 备注:首页
 */
public class OrderFragment extends BaseFragment {
    public static final int RESULT_REFRESH = 1001;
    private final int STATE_DONE = 2;
    private final int STATE_UNDONE = 1;
@@ -55,6 +56,16 @@
    int state = 1;
    List<OrderListResult.Data> recordsListDone = new ArrayList<>();
    List<OrderListResult.Data> recordsList = new ArrayList<>();
    RefreshLayout myRefreshLayout;
    private ActivityResultLauncher<Intent> activityResultLauncher =
            registerForActivityResult(
                    new ActivityResultContracts.StartActivityForResult(),
                    result -> {
                        if (result.getResultCode() == RESULT_REFRESH) {
                            myRefreshLayout.autoRefresh();
                        }
                    });
    /**
     * 设置天气相关信息
@@ -84,9 +95,7 @@
        initView();
        //获取定位服务传过来的坐标点
        LiveEventBus.get(CommonKeyName.MQTTData).observeForever(o -> {
        });
        return binding.getRoot();
    }
@@ -105,7 +114,7 @@
            state = STATE_DONE;//1 未开始 2 已完成
        });
        //未完成
        RefreshLayout myRefreshLayout = (RefreshLayout) binding.refreshLayout;
        myRefreshLayout = (RefreshLayout) binding.refreshLayout;
        myRefreshLayout.setRefreshHeader(new ClassicsHeader(this.getContext()));
        myRefreshLayout.setRefreshFooter(new ClassicsFooter(this.getContext()));
@@ -169,7 +178,7 @@
        params.put("pageSize", pageSize);
        params.put("pageCurr", page);
        params.put("state", state);
//        params.put("inspectorId", MyApplication.myApplication.userId);
        params.put("inspectorId", MyApplication.myApplication.userId);
        ApiManager.getInstance().requestGetHideLoading(this.getContext(), Constants.BASE_URL + "/app/workOrder/getWorkOrders", OrderListResult.class, params, new SubscriberListener<BaseResponse<OrderListResult>>() {
            @Override
@@ -182,7 +191,7 @@
                            } else {
                                recordsListDone.addAll(t.getContent().getObj());
                            }
                            if (t.getContent().getObj().size() < pageSize) {
                            if (t.getContent().getPageTotal() == page) {
                                refreshlayout.finishLoadMoreWithNoMoreData();
                            }
                        } else {
@@ -203,17 +212,18 @@
                } else {
                    mDoneAdapter.notifyDataSetChanged();
                }
            }
        });
    }
    public void startDetail(String id) {
    public void startDetail(String workOrderId, String proResultId) {
        Intent intent = new Intent(this.getContext(), OrderDetailActivity.class);
        intent.putExtra("workOrderId", id);
        startActivity(intent);
        intent.putExtra("workOrderId", workOrderId);
        if (!TextUtils.isEmpty(proResultId)) {
            intent.putExtra("proResultId", proResultId);
        }
        activityResultLauncher.launch(intent);
    }
@@ -225,20 +235,20 @@
    void chooseStateView(boolean state) {
        if (state) {
            binding.manageStateProgress.setTextColor(getResources().getColor(R.color.title_color));
            binding.manageStateProgress.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit));
            binding.manageStateProgress.setTextColor(getResources().getColor(R.color.title_color,null));
            binding.manageStateProgress.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit,null));
            binding.manageStateProgress.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            binding.manageStateFinish.setTextColor(getResources().getColor(R.color.black));
            binding.manageStateFinish.setBackground(getResources().getDrawable(R.color.title_choose_bg));
            binding.manageStateFinish.setTextColor(getResources().getColor(R.color.black,null));
            binding.manageStateFinish.setBackground(getResources().getDrawable(R.color.title_choose_bg,null));
            binding.manageStateFinish.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            binding.refreshLayout.setVisibility(View.VISIBLE);
            binding.refreshLayoutDone.setVisibility(View.GONE);
        } else {
            binding.manageStateFinish.setTextColor(getResources().getColor(R.color.title_color));
            binding.manageStateFinish.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit));
            binding.manageStateFinish.setTextColor(getResources().getColor(R.color.title_color,null));
            binding.manageStateFinish.setBackground(getResources().getDrawable(R.drawable.ic_choose_bg_whit,null));
            binding.manageStateFinish.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
            binding.manageStateProgress.setTextColor(getResources().getColor(R.color.black));
            binding.manageStateProgress.setBackground(getResources().getDrawable(R.color.title_choose_bg));
            binding.manageStateProgress.setTextColor(getResources().getColor(R.color.black,null));
            binding.manageStateProgress.setBackground(getResources().getDrawable(R.color.title_choose_bg,null));
            binding.manageStateProgress.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            binding.refreshLayout.setVisibility(View.GONE);
            binding.refreshLayoutDone.setVisibility(View.VISIBLE);