diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5965732..2bf3234 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,10 @@ + + + @@ -32,6 +37,7 @@ android:exported="true"> + diff --git a/app/src/main/assets/litepal.xml b/app/src/main/assets/litepal.xml index 95bd173..4c80f3e 100644 --- a/app/src/main/assets/litepal.xml +++ b/app/src/main/assets/litepal.xml @@ -1,10 +1,11 @@ - + + \ No newline at end of file diff --git a/app/src/main/java/com/example/as_trak/LoadMainActivity.java b/app/src/main/java/com/example/as_trak/LoadMainActivity.java index efeea4b..485788e 100644 --- a/app/src/main/java/com/example/as_trak/LoadMainActivity.java +++ b/app/src/main/java/com/example/as_trak/LoadMainActivity.java @@ -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 list = LitePal.findAll(ContainerType.class); + Log.e("TAG", "onCreate:" + list.toString()); + if (list!=null){ + int size = list.size(); + List list1 = new ArrayList<>(size); + List 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); }); } diff --git a/app/src/main/java/com/example/as_trak/MainActivity.java b/app/src/main/java/com/example/as_trak/MainActivity.java index 8687a8c..5214de3 100644 --- a/app/src/main/java/com/example/as_trak/MainActivity.java +++ b/app/src/main/java/com/example/as_trak/MainActivity.java @@ -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) { diff --git a/app/src/main/java/com/example/as_trak/SettingActivity.java b/app/src/main/java/com/example/as_trak/SettingActivity.java new file mode 100644 index 0000000..c32a4c2 --- /dev/null +++ b/app/src/main/java/com/example/as_trak/SettingActivity.java @@ -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 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(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/as_trak/adapter/ContainerTypesAdapter.java b/app/src/main/java/com/example/as_trak/adapter/ContainerTypesAdapter.java new file mode 100644 index 0000000..7dde01b --- /dev/null +++ b/app/src/main/java/com/example/as_trak/adapter/ContainerTypesAdapter.java @@ -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 { + private Context context; + private LayoutInflater inflater; + private List list; + private ContainerTypesAdapterCall call; + public ContainerTypesAdapter(Context context, ContainerTypesAdapterCall call) { + this.context = context; + inflater=LayoutInflater.from(context); + this.call=call; + } + + public void setList(List 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); + } +} diff --git a/app/src/main/java/com/example/as_trak/dialog/EditDialog.java b/app/src/main/java/com/example/as_trak/dialog/EditDialog.java new file mode 100644 index 0000000..e840c9b --- /dev/null +++ b/app/src/main/java/com/example/as_trak/dialog/EditDialog.java @@ -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); + } +} diff --git a/app/src/main/java/com/example/as_trak/entity/ContainerType.java b/app/src/main/java/com/example/as_trak/entity/ContainerType.java new file mode 100644 index 0000000..32d789b --- /dev/null +++ b/app/src/main/java/com/example/as_trak/entity/ContainerType.java @@ -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 + '\'' + + '}'; + } +} diff --git a/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java b/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java index 2782959..0b7194e 100644 --- a/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java +++ b/app/src/main/java/com/example/as_trak/fragment/LuggageFragment.java @@ -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 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; } } \ No newline at end of file diff --git a/app/src/main/java/com/example/as_trak/fragment/been/LuggageBeen.java b/app/src/main/java/com/example/as_trak/fragment/been/LuggageBeen.java index 703f5b1..9513211 100644 --- a/app/src/main/java/com/example/as_trak/fragment/been/LuggageBeen.java +++ b/app/src/main/java/com/example/as_trak/fragment/been/LuggageBeen.java @@ -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; } diff --git a/app/src/main/res/layout/activity_load_main.xml b/app/src/main/res/layout/activity_load_main.xml index 2553863..4c2c35c 100644 --- a/app/src/main/res/layout/activity_load_main.xml +++ b/app/src/main/res/layout/activity_load_main.xml @@ -16,6 +16,11 @@ + - + - + + android:layout_weight="1" + android:onClick="homeSetting" + android:drawableTop="@mipmap/icon_setting" + android:text="信息维护"/> diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml new file mode 100644 index 0000000..acf5ac5 --- /dev/null +++ b/app/src/main/res/layout/activity_setting.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_edit.xml b/app/src/main/res/layout/dialog_edit.xml new file mode 100644 index 0000000..bbcc67a --- /dev/null +++ b/app/src/main/res/layout/dialog_edit.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_luggage.xml b/app/src/main/res/layout/fragment_luggage.xml index d9e71b0..9b6049f 100644 --- a/app/src/main/res/layout/fragment_luggage.xml +++ b/app/src/main/res/layout/fragment_luggage.xml @@ -60,6 +60,30 @@ android:layout_height="61dp" android:background="@drawable/main_menu_bg"> + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-xhdpi/ic_user.png b/app/src/main/res/mipmap-xhdpi/ic_user.png new file mode 100644 index 0000000..538be38 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_user.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_setting.png b/app/src/main/res/mipmap-xhdpi/icon_setting.png new file mode 100644 index 0000000..4a1124c Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_setting.png differ diff --git a/app/src/main/res/mipmap-xhdpi/icon_tip.png b/app/src/main/res/mipmap-xhdpi/icon_tip.png new file mode 100644 index 0000000..9c52e02 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_tip.png differ diff --git a/app/src/main/res/mipmap-xhdpi/info_add.png b/app/src/main/res/mipmap-xhdpi/info_add.png new file mode 100644 index 0000000..83082aa Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/info_add.png differ