增加 - 切换工位
parent
b7a63ab1f7
commit
3471f2779f
@ -0,0 +1,70 @@
|
||||
package com.example.aucma_mes;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.aucma_mes.base.BaseActivity;
|
||||
import com.example.aucma_mes.databinding.ActivityChangeBinding;
|
||||
import com.example.aucma_mes.entity.DefectBeen;
|
||||
import com.example.aucma_mes.entity.Result;
|
||||
import com.example.aucma_mes.entity.TeamBeen;
|
||||
import com.example.aucma_mes.utils.MyRecultCall;
|
||||
import com.example.aucma_mes.utils.SharedPreferencesUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChangeActivity extends BaseActivity {
|
||||
private List<DefectBeen> list;
|
||||
public List<String> tagList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ActivityChangeBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_change);
|
||||
tagList = new ArrayList<>();
|
||||
binding.setVm(this);
|
||||
OkGo.<Result>get(url + "/base/productLine/findProductLineList?productLineType=2&stationType=2").tag(this)
|
||||
.headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) {
|
||||
@Override
|
||||
public void onSuccess(Response<Result> response) {
|
||||
var body = response.body();
|
||||
if (body.getCode() == 200) {
|
||||
list = gson.fromJson(gson.toJson(body.getData()), new TypeToken<List<DefectBeen>>() {
|
||||
}.getType());
|
||||
list.forEach(t -> tagList.add(t.getProductLineName()));
|
||||
binding.setList(tagList);
|
||||
}
|
||||
Toast.makeText(ChangeActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sanInfo(String code) {
|
||||
|
||||
}
|
||||
private String tag;
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
tag = tagList.get(position);
|
||||
|
||||
productLineCode = list.get(position).getProductLineCode();
|
||||
Log.e("TAG", "选中工位:" + tag);
|
||||
}
|
||||
private String productLineCode;
|
||||
public void changeSubmit(View view){
|
||||
SharedPreferencesUtils.putstring("stationName",tag);
|
||||
SharedPreferencesUtils.putstring("stationCode",productLineCode);
|
||||
finish();
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout 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">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="vm"
|
||||
type="com.example.aucma_mes.ChangeActivity" />
|
||||
<variable
|
||||
name="list"
|
||||
type="java.util.List" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/grey"
|
||||
tools:context=".ChangeActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="43dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:background="@color/white"
|
||||
android:layout_marginEnd="4dp">
|
||||
|
||||
<TextView
|
||||
style="@style/text_style1"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/grey"
|
||||
android:text="选择工位:" />
|
||||
|
||||
|
||||
<Spinner
|
||||
android:textAlignment="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:entries="@{list}"
|
||||
android:onItemSelected="@{vm.onItemClick}"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Button
|
||||
style="@style/button_true_style"
|
||||
android:layout_width="370dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="50dp"
|
||||
android:onClick="changeSubmit"
|
||||
android:text="提交"/>
|
||||
</LinearLayout>
|
||||
</layout>
|
Loading…
Reference in New Issue