修改 问题
parent
812e872573
commit
b876685f82
@ -1,10 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<litepal>
|
<litepal>
|
||||||
<dbname value="AS_TRAK" />
|
<dbname value="AS_TRAK" />
|
||||||
<version value="2" />
|
<version value="4" />
|
||||||
<list>
|
<list>
|
||||||
<mapping class="com.example.as_trak.entity.LoadOperation"/>
|
<mapping class="com.example.as_trak.entity.LoadOperation"/>
|
||||||
<mapping class="com.example.as_trak.entity.CargoInfo"/>
|
<mapping class="com.example.as_trak.entity.CargoInfo"/>
|
||||||
<mapping class="com.example.as_trak.entity.FlightInfo" />
|
<mapping class="com.example.as_trak.entity.FlightInfo" />
|
||||||
|
<mapping class="com.example.as_trak.entity.ContainerType" />
|
||||||
</list>
|
</list>
|
||||||
</litepal>
|
</litepal>
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.example.as_trak;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
|
||||||
|
import com.example.as_trak.adapter.ContainerTypesAdapter;
|
||||||
|
import com.example.as_trak.base.BaseActivity;
|
||||||
|
import com.example.as_trak.databinding.ActivitySettingBinding;
|
||||||
|
import com.example.as_trak.dialog.EditDialog;
|
||||||
|
import com.example.as_trak.entity.ContainerType;
|
||||||
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
import org.litepal.LitePal;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SettingActivity extends BaseActivity implements EditDialog.EditDialogCall, ContainerTypesAdapter.ContainerTypesAdapterCall {
|
||||||
|
private EditDialog editDialog;
|
||||||
|
private List<ContainerType> list;
|
||||||
|
private ContainerTypesAdapter adapter;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
ActivitySettingBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_setting);
|
||||||
|
editDialog = new EditDialog(this);
|
||||||
|
editDialog.setCall(this);
|
||||||
|
adapter = new ContainerTypesAdapter(this, this);
|
||||||
|
adapterSetList("1");
|
||||||
|
binding.setAdapter(adapter);
|
||||||
|
|
||||||
|
binding.infoTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
@Override
|
||||||
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
|
String string = tab.getText().toString();
|
||||||
|
type = string.equals("种类维护") ? "1" : "2";
|
||||||
|
adapterSetList(type);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabUnselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
private void adapterSetList(String type) {
|
||||||
|
list = LitePal.where("type = ?", type).find(ContainerType.class);
|
||||||
|
if (list==null) {
|
||||||
|
list=new ArrayList<>();
|
||||||
|
}
|
||||||
|
adapter.setList(list);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
@Override
|
||||||
|
public void saveInfo(String info) {
|
||||||
|
ContainerType containerType = new ContainerType();
|
||||||
|
containerType.setTypeName(info);
|
||||||
|
containerType.setType(type);
|
||||||
|
containerType.save();
|
||||||
|
list.add(containerType);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
editDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
@Override
|
||||||
|
public void deleteCargoInfo(int index) {
|
||||||
|
ContainerType containerType = list.get(index);
|
||||||
|
containerType.delete();
|
||||||
|
list.remove(index);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
public void settingAdd(View view){
|
||||||
|
editDialog.show();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package com.example.as_trak.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.as_trak.R;
|
||||||
|
import com.example.as_trak.databinding.ItemCargoBinding;
|
||||||
|
import com.example.as_trak.databinding.ItemInfoAddBinding;
|
||||||
|
import com.example.as_trak.entity.CargoInfo;
|
||||||
|
import com.example.as_trak.entity.ContainerType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ContainerTypesAdapter extends RecyclerView.Adapter<ContainerTypesAdapter.MyViewHolder> {
|
||||||
|
private Context context;
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
private List<ContainerType> list;
|
||||||
|
private ContainerTypesAdapterCall call;
|
||||||
|
public ContainerTypesAdapter(Context context, ContainerTypesAdapterCall call) {
|
||||||
|
this.context = context;
|
||||||
|
inflater=LayoutInflater.from(context);
|
||||||
|
this.call=call;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List<ContainerType> list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
ItemInfoAddBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_info_add, parent, false, null);
|
||||||
|
return new MyViewHolder(binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||||
|
ContainerType containerType = list.get(position);
|
||||||
|
containerType.setTag(position+1);
|
||||||
|
ItemInfoAddBinding binding = holder.binding;
|
||||||
|
binding.setData(containerType);
|
||||||
|
binding.itemCargoD.setOnClickListener(v -> call.deleteCargoInfo(position));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return list == null ? 0 : list.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static class MyViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
private ItemInfoAddBinding binding;
|
||||||
|
|
||||||
|
public MyViewHolder(ItemInfoAddBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ContainerTypesAdapterCall {
|
||||||
|
void deleteCargoInfo(int index);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.example.as_trak.dialog;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
import androidx.databinding.ViewDataBinding;
|
||||||
|
|
||||||
|
import com.example.as_trak.R;
|
||||||
|
import com.example.as_trak.databinding.DialogEditBinding;
|
||||||
|
|
||||||
|
public class EditDialog extends Dialog {
|
||||||
|
private String info;
|
||||||
|
private EditDialogCall call;
|
||||||
|
private DialogEditBinding binding;
|
||||||
|
public void setCall(EditDialogCall call) {
|
||||||
|
this.call = call;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditDialog(@NonNull Context context) {
|
||||||
|
super(context, R.style.dialog_style);
|
||||||
|
|
||||||
|
binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_edit, null, false);
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
binding.editFalse.setOnClickListener(v -> dismiss());
|
||||||
|
binding.editTrue.setOnClickListener(v -> call.saveInfo(binding.editInfo.getText().toString()));
|
||||||
|
}
|
||||||
|
public interface EditDialogCall{
|
||||||
|
void saveInfo(String info);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
super.show();
|
||||||
|
binding.editInfo.setText(null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package com.example.as_trak.entity;
|
||||||
|
|
||||||
|
import org.litepal.crud.LitePalSupport;
|
||||||
|
|
||||||
|
public class ContainerType extends LitePalSupport {
|
||||||
|
private int id;
|
||||||
|
private int tag;
|
||||||
|
private String typeName;
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(int tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeName() {
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeName(String typeName) {
|
||||||
|
this.typeName = typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ContainerType{" +
|
||||||
|
"id=" + id +
|
||||||
|
", typeName='" + typeName + '\'' +
|
||||||
|
", type='" + type + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
<?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="title"
|
||||||
|
type="String" />
|
||||||
|
<variable
|
||||||
|
name="adapter"
|
||||||
|
type="com.example.as_trak.adapter.ContainerTypesAdapter" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".SettingActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
app:title='@{title??"信息维护"}' />
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/info_tabLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:background="@drawable/tablayout_bg"
|
||||||
|
app:tabBackground="@drawable/tab_background_selector"
|
||||||
|
app:tabGravity="fill"
|
||||||
|
app:tabSelectedTextColor="@color/white"
|
||||||
|
|
||||||
|
app:tabTextColor="@color/blue">
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
|
||||||
|
android:text="种类维护" />
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabItem
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="舱位代码" />
|
||||||
|
|
||||||
|
|
||||||
|
</com.google.android.material.tabs.TabLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
android:adapter="@{adapter}"
|
||||||
|
android:background="@color/white" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="62dp"
|
||||||
|
android:layout_height="62dp"
|
||||||
|
android:src="@mipmap/info_add"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:onClick="settingAdd"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/main_menu_bg"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="85dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:drawableStart="@mipmap/icon_tip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="22dp"
|
||||||
|
android:text="填写信息" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edit_info"
|
||||||
|
android:layout_width="350dp"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:lines="1"
|
||||||
|
android:inputType="text"
|
||||||
|
android:maxLines="1" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/edit_false"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="取 消"
|
||||||
|
android:textColor="#858585"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="#e1e1e1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/edit_true"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="确 定"
|
||||||
|
android:textColor="#02CC02"
|
||||||
|
android:textSize="22sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<variable
|
||||||
|
name="data"
|
||||||
|
type="com.example.as_trak.entity.ContainerType" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="51dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="50dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="45dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text='@{data.tag+""}'
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:background="#e1e1e1" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@{data.typeName}"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/item_cargo_d"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="@drawable/button_delete"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="删除"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_marginEnd="5dp"
|
||||||
|
android:background="#EEEEEE" />
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
Binary file not shown.
After Width: | Height: | Size: 877 B |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
Loading…
Reference in New Issue