修改 问题

master
wanghao 1 week ago
parent 812e872573
commit b876685f82

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name="org.litepal.LitePalApplication"
android:allowBackup="true"
@ -15,6 +17,9 @@
android:theme="@style/Theme.Astrak"
tools:ignore="MissingClass"
tools:targetApi="31">
<activity
android:name=".SettingActivity"
android:exported="false" />
<activity
android:name=".UnLoadActivity"
android:exported="false" />
@ -32,6 +37,7 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname value="AS_TRAK" />
<version value="2" />
<version value="4" />
<list>
<mapping class="com.example.as_trak.entity.LoadOperation"/>
<mapping class="com.example.as_trak.entity.CargoInfo"/>
<mapping class="com.example.as_trak.entity.FlightInfo" />
<mapping class="com.example.as_trak.entity.ContainerType" />
</list>
</litepal>

@ -20,6 +20,7 @@ import com.example.as_trak.base.BaseActivity;
import com.example.as_trak.databinding.ActivityLoadMainBinding;
import com.example.as_trak.dialog.AddFlightDialog;
import com.example.as_trak.entity.CargoInfo;
import com.example.as_trak.entity.ContainerType;
import com.example.as_trak.entity.FlightInfo;
import com.example.as_trak.entity.LoadOperation;
import com.example.as_trak.toast.LoadToast;
@ -70,6 +71,23 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
intent = new Intent(this, LoadScanActivity.class);
List<ContainerType> list = LitePal.findAll(ContainerType.class);
Log.e("TAG", "onCreate:" + list.toString());
if (list!=null){
int size = list.size();
List<String> list1 = new ArrayList<>(size);
List<String> list2 = new ArrayList<>(size);
list.forEach(t -> {
if (t.getType().equals("1")) {
list1.add(t.getTypeName());
} else {
list2.add(t.getTypeName());
}
});
binding.setList1(list1);
binding.setList2(list2);
}
}
@ -102,7 +120,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfo.setCount(0);
cargoInfo.setCargoCode(cargoCode);
cargoInfo.setFlightId(id);
cargoInfo.setState("装载");
cargoInfo.setState("装载");
cargoInfo.save();
cargoInfoList.add(cargoInfo);
cargoInfoAdapter.notifyDataSetChanged();
@ -203,7 +221,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
String.valueOf(flightInfoTag.getId())).find(CargoInfo.class);
if (!cargoInfoList.isEmpty()) {
cargoInfoList.forEach(cargoInfo -> {
int countNum = LitePal.where("cargoId = ? and type ='正常' and (state IS NULL or state = '修改')",String.valueOf(cargoInfo.getId())).count(LoadOperation.class);
int countNum = LitePal.where("cargoId = ? and type ='正常' and (state IS NULL or state = '修改')", String.valueOf(cargoInfo.getId())).count(LoadOperation.class);
cargoInfo.setCount(countNum);
});
}

@ -12,6 +12,7 @@ public class MainActivity extends AppCompatActivity {
private Intent intent1;
private Intent intent2;
private Intent intent3;
private Intent intent4;
@Override
@ -21,17 +22,21 @@ public class MainActivity extends AppCompatActivity {
intent1 = new Intent(this, LoadMainActivity.class);
intent2 = new Intent(this, UnLoadActivity.class);
intent3 = new Intent(this, InfoActivity.class);
intent4 = new Intent(this, SettingActivity.class);
}
public void homeLoad(View view) {
startActivity(intent1);
}
public void homeUnLoad(View view) {
startActivity(intent2);
}
public void homeinfo(View view) {
startActivity(intent3);
}
public void homeUnLoad(View view) {
startActivity(intent2);
public void homeSetting(View view) {
startActivity(intent4);
}
public void homeClose(View view) {

@ -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 + '\'' +
'}';
}
}

@ -28,12 +28,13 @@ import org.litepal.LitePal;
import java.util.List;
import java.util.stream.IntStream;
public class LuggageFragment extends Fragment implements View.OnClickListener {
public class LuggageFragment extends Fragment implements View.OnLongClickListener {
private FragmentLuggageBinding binding;
private LuggageBeen luggageBeen;
private LoadOperation loadOperationFrist;
private AlertDialog.Builder builder;
@SuppressLint("ClickableViewAccessibility")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -48,9 +49,8 @@ public class LuggageFragment extends Fragment implements View.OnClickListener {
luggageBeen.setVisbleState(true);
}
}
builder=new AlertDialog.Builder(getContext());
builder.setTitle("拉下确认")
.setMessage("是否确定拉下行李").setNegativeButton("取消", null);
builder = new AlertDialog.Builder(getContext());
builder.setTitle("拉下确认").setMessage("是否确定拉下行李").setNegativeButton("取消", null);
binding.setData(luggageBeen);
@ -74,14 +74,16 @@ public class LuggageFragment extends Fragment implements View.OnClickListener {
return false;
});
binding.luggageUnLoad.setOnClickListener(this);
binding.luggageUnLoad.setOnLongClickListener(this);
return binding.getRoot();
}
private void selectInfo(String code) {
loadOperationFrist = LitePal.where("luggageCode=? and (state IS NULL or state = '修改')", code).findFirst(LoadOperation.class);
loadOperationFrist = LitePal
.where("luggageCode like ? and (state IS NULL or state = '修改')", code+"%")
.order("loadTime desc").findFirst(LoadOperation.class);
if (loadOperationFrist == null) {
Toast.makeText(getContext(), "查询失败,条码错误", Toast.LENGTH_SHORT).show();
luggageBeen.clear();
@ -91,6 +93,7 @@ public class LuggageFragment extends Fragment implements View.OnClickListener {
luggageBeen.setCargoCode(loadOperationFrist.getCargoCode());
luggageBeen.setState(loadOperationFrist.getType());
luggageBeen.setLoadTime(loadOperationFrist.getLoadTime());
luggageBeen.setLuggageCode(loadOperationFrist.getLuggageCode());
List<LoadOperation> loadOperationList = LitePal.where("flightId = ? and cargoId = ? and (state IS NULL or state = '修改') ", String.valueOf(loadOperationFrist.getFlightId()), String.valueOf(loadOperationFrist.getCargoId())).order("id asc").find(LoadOperation.class);
Log.e("TAG", "全部数据:" + loadOperationList.toString());
FlightInfo flightInfo = LitePal.where("id=?", String.valueOf(loadOperationFrist.getFlightId())).findFirst(FlightInfo.class);
@ -99,12 +102,11 @@ public class LuggageFragment extends Fragment implements View.OnClickListener {
}
@Override
public void onClick(View v) {
public boolean onLongClick(View v) {
if (loadOperationFrist == null) {
return;
return false;
}
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
@ -115,6 +117,6 @@ public class LuggageFragment extends Fragment implements View.OnClickListener {
luggageBeen.setState("拉下");
}
}).show();
return true;
}
}

@ -25,6 +25,21 @@ public class LuggageBeen extends BaseObservable {
private String State;
private boolean visbleState = false;
/**
*
*/
private String luggageCode;
public String getLuggageCode() {
return luggageCode;
}
public void setLuggageCode(String luggageCode) {
this.luggageCode = luggageCode;
notifyChange();
}
public boolean isVisbleState() {
return visbleState;
}

@ -16,6 +16,11 @@
<variable
name="adapter"
type="com.example.as_trak.adapter.CargoInfoAdapter" />
<variable
name="list1"
type="java.util.List" /> <variable
name="list2"
type="java.util.List" />
</data>
<LinearLayout
@ -74,7 +79,13 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="51dp">
<Spinner
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}"
android:entries="@{list1}"
/>
<EditText
android:id="@+id/load_main_cargo_code"
android:layout_width="match_parent"
@ -87,7 +98,13 @@
android:layout_weight="1"
android:visibility="@{visibState?View.GONE:View.VISIBLE}"
android:gravity="center" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAlignment="center"
android:visibility="@{visibState?View.GONE:View.VISIBLE}"
android:entries="@{list2}"
/>
<TextView
android:layout_width="55dp"
android:layout_height="30dp"
@ -102,7 +119,7 @@
android:onClick="loadAddCargo"/>
<ImageButton
android:layout_width="55dp"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginStart="10dp"

@ -150,7 +150,10 @@
style="@style/TabRadioButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
android:layout_weight="1"
android:onClick="homeSetting"
android:drawableTop="@mipmap/icon_setting"
android:text="信息维护"/>
</RadioGroup>

@ -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>

@ -60,6 +60,30 @@
android:layout_height="61dp"
android:background="@drawable/main_menu_bg">
<TextView
android:layout_width="82dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="行李号"
android:textSize="18sp" />
<TextView
style="@style/text_title"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_gravity="center"
android:layout_marginEnd="10dp"
android:text="@{data.luggageCode}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="61dp"
android:layout_marginTop="1dp"
android:background="@drawable/main_menu_bg">
<TextView
android:layout_width="82dp"
android:layout_height="match_parent"

@ -39,12 +39,6 @@
android:text='@{data.count+""}'
android:textSize="15sp" />
<TextView
android:layout_width="25dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="件"
android:textSize="15sp" />
<View
android:layout_width="1dp"

@ -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…
Cancel
Save