修改 液体称量
parent
9faa3c70be
commit
ac63b55a89
@ -0,0 +1,89 @@
|
||||
package com.example.pulit;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.example.pulit.adapter.PlanAdapter;
|
||||
import com.example.pulit.entity.AxPlan;
|
||||
import com.example.pulit.util.MyOkGoCallback;
|
||||
import com.example.pulit.util.Resust;
|
||||
import com.example.pulit.util.SharedPreferencesUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
public class PlanActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.plan_type)
|
||||
Spinner planType;
|
||||
@BindView(R.id.plan_recycler)
|
||||
RecyclerView planRecycler;
|
||||
private PlanAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_plan);
|
||||
ButterKnife.bind(this);
|
||||
planRecycler.setLayoutManager(new LinearLayoutManager(this));
|
||||
adapter = new PlanAdapter(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanInfo(String info) {
|
||||
|
||||
}
|
||||
|
||||
@OnClick({R.id.info_title_back, R.id.plan_select})
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.info_title_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.plan_select:
|
||||
String type = planType.getSelectedItem().toString();
|
||||
String url = null;
|
||||
if (type.equals("小料")) {
|
||||
url = "/api/xl_material/GetXlPlanInfo";
|
||||
} else {
|
||||
url = "/api/Solvent/GetSolventPlanInfo";
|
||||
}
|
||||
dialog.show();
|
||||
OkGo.<Resust>get("http://"+SharedPreferencesUtils.getstring("ip", null)+url).execute(new MyOkGoCallback(){
|
||||
@Override
|
||||
public void onSuccess(Response<Resust> response) {
|
||||
super.onSuccess(response);
|
||||
dialog.dismiss();
|
||||
List<AxPlan> list= JSON.parseArray(response.body().getData(),AxPlan.class);
|
||||
Log.e("TAG", "onSuccess:" + list.toString());
|
||||
adapter.setList(list);
|
||||
planRecycler.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<Resust> response) {
|
||||
super.onError(response);
|
||||
dialog.dismiss();
|
||||
Toast.makeText(PlanActivity.this, "网络连接错误", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.example.pulit.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.pulit.R;
|
||||
import com.example.pulit.entity.AxPlan;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/3 10:59
|
||||
*/
|
||||
public class PlanAdapter extends RecyclerView.Adapter<PlanAdapter.vm> {
|
||||
private Context context;
|
||||
private List<AxPlan> list;
|
||||
|
||||
public PlanAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setList(List<AxPlan> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public vm onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View inflate = LayoutInflater.from(context).inflate(R.layout.item_plan, parent, false);
|
||||
return new vm(inflate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PlanAdapter.vm holder, int position) {
|
||||
AxPlan axPlan = list.get(position);
|
||||
holder.index.setText(String.valueOf(position + 1));
|
||||
holder.planID.setText(axPlan.getPlan_Id());
|
||||
holder.planState.setText(axPlan.getPlan_StateText());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public int getItemCount() {
|
||||
return Optional.ofNullable(list).map(List::size).orElse(0);
|
||||
}
|
||||
|
||||
public class vm extends RecyclerView.ViewHolder {
|
||||
private TextView index, planID, planState;
|
||||
|
||||
public vm(View view) {
|
||||
super(view);
|
||||
index = view.findViewById(R.id.item_plan_index);
|
||||
planID = view.findViewById(R.id.item_plan_id);
|
||||
planState = view.findViewById(R.id.item_plan_state);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".PlanActivity">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="55dp"
|
||||
android:background="@color/blue"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
style="@style/title_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="计划工单" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/info_title_back"
|
||||
android:layout_width="55dp"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="15dp"
|
||||
android:src="@mipmap/icon_back" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginTop="68dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteX="16dp">
|
||||
|
||||
<TextView
|
||||
style="@style/text_view"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="选择查询:" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/plan_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:entries="@array/plan"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/plan_select"
|
||||
style="@style/button_style1"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="搜索" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/plan_recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:padding="5dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue