修改 问题3

master
wanghao 5 days ago
parent 63f04c9f65
commit a45040d9df

@ -4,7 +4,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:name="org.litepal.LitePalApplication"
android:allowBackup="true"

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

@ -45,7 +45,8 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
private ActivityLoadMainBinding binding;
private ObservableInt cargoQty;
private ObservableInt loadQty;
private androidx.appcompat.app.AlertDialog.Builder alertDialog;
private String[] loadStateList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -66,6 +67,22 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
builder = new AlertDialog.Builder(this);
builder.setTitle("删除确认").setMessage("是否确定删除装载单元").setNegativeButton("取消", null);
initAlertDialog();
}
private void initAlertDialog() {
loadStateList = getResources().getStringArray(R.array.loadState);
alertDialog = new androidx.appcompat.app.AlertDialog.Builder(this);
alertDialog.setTitle("选择装载量")
.setItems(loadStateList, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(LoadMainActivity.this, "装载完成", Toast.LENGTH_SHORT).show();
}
}).setNegativeButton("取消", null).create();
}
// 初始化航班添加
@ -147,6 +164,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
public void saveNumber(View view) {
flightInfoTag.setJieguiQty(binding.loadMainJieguiQty.getText().toString());
flightInfoTag.update(flightInfoTag.getId());
Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show();
}
// 关闭货箱添加
public void loadCloseEdit(View view) {

@ -19,6 +19,7 @@ import com.example.as_trak.adapter.CargoListAdapter;
import com.example.as_trak.adapter.LoadInfoAdapter;
import com.example.as_trak.base.BaseActivity;
import com.example.as_trak.databinding.ActivityLoadScanBinding;
import com.example.as_trak.dialog.TipDialog;
import com.example.as_trak.dialog.UpdataDialog;
import com.example.as_trak.entity.CargoInfo;
import com.example.as_trak.entity.FlightInfo;
@ -37,39 +38,41 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
private List<LoadOperation> loadOperations;
private CargoInfo cargoInfoTag;
private FlightInfo flightInfo;
private LoadToast loadToast;
// private LoadToast loadToast;
private LoadInfoAdapter loadInfoAdapter;
// 定义时间格式
private DateTimeFormatter formatter;
private UpdataDialog updataDialog;
// 装载完成对话框
private TipDialog tipDialog;
private AlertDialog.Builder alertDialog;
private String[] loadStateList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
com.example.as_trak.databinding.ActivityLoadScanBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan);
ActivityLoadScanBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan);
initScan();
int id = getIntent().getIntExtra("id", 0);
flightInfo = LitePal.where("id= ?", String.valueOf(id)).findFirst(FlightInfo.class);
binding.setData(flightInfo);
cargoInfoList = LitePal.where("flightId = ?", String.valueOf(id)).find(CargoInfo.class);
adapter = new CargoListAdapter(this, this);
adapter.setList(cargoInfoList);
binding.setAdapter1(adapter);
formatter = DateTimeFormatter.ofPattern("HH:mm");
loadToast = new LoadToast(this);
// loadToast = new LoadToast(this);
loadInfoAdapter = new LoadInfoAdapter(this, this);
binding.setAdapter2(loadInfoAdapter);
binding.loadScanSubmit.setOnLongClickListener(this);
initDialog();
}
// 初始化弹窗
@SuppressLint("NotifyDataSetChanged")
private void initDialog() {
loadStateList = getResources().getStringArray(R.array.loadState);
updataDialog = new UpdataDialog(this);
updataDialog.setUpdataDialogCall((code, index) -> {
LoadOperation loadOperation = loadOperations.get(index);
@ -79,23 +82,22 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
loadOperation.update(loadOperation.getId());
loadInfoAdapter.notifyDataSetChanged();
});
alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("装载完成,选择装载量")
// .setIcon(R.mipmap.ic_launcher)
.setItems(loadStateList, new DialogInterface.OnClickListener() {
tipDialog = new TipDialog(this);
alertDialog=new AlertDialog.Builder(this);
alertDialog.setTitle("装载完成提示")
.setMessage("是否全部修改状态为装载完成")
.setNegativeButton("取消",null)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(LoadScanActivity.this,"装载完成" , Toast.LENGTH_SHORT).show();
cargoInfoTag.setState("装载完成");
cargoInfoTag.update(cargoInfoTag.getId());
cargoInfoTag.setLoadState(loadStateList[which]);
adapter.notifyDataSetChanged();
cargoInfoTag = null;
cargoInfoList.forEach(t -> {
t.setState("装载完成");
t.update(t.getId());
});
Toast.makeText(LoadScanActivity.this, "成功", Toast.LENGTH_SHORT).show();
finish();
}
}).setNegativeButton("取消", null).create();
}).create();
}
// 扫码结果
@ -107,11 +109,17 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
Toast.makeText(this, "没有选择装载单元", Toast.LENGTH_SHORT).show();
return;
}
if (cargoInfoTag.getState().equals("装载完成")) {
Toast.makeText(this, "装载单元已经装载完成", Toast.LENGTH_SHORT).show();
return;
}
int count = LitePal.where("flightId= ? and luggageCode=? and (state IS NULL or state = '修改') ", String.valueOf(flightInfo.getId()), code).count(LoadOperation.class);
if (count > 0) {
loadToast.show("行李条码重复");
tipDialog.showError("行李条码:" + code + "重复");
return;
}
tipDialog.showSuccess("绑定成功");
LoadOperation loadOperation = new LoadOperation();
loadOperation.setFlightCode(flightInfo.getFlightCode());
loadOperation.setFlightId(flightInfo.getId());
@ -125,7 +133,8 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
loadOperation.setLoadTime(formattedTime);
loadOperation.setType("装载");
loadOperation.save();
loadOperations.add(loadOperation);
loadOperations.add(0, loadOperation);
Log.e("TAG", "sanCodeResult:" + loadOperations.toString());
loadInfoAdapter.notifyDataSetChanged();
int size = loadOperations.size();
Log.e("TAG", "更新的id:" + cargoInfoTag.getId() + "数量:" + size);
@ -135,12 +144,12 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
}
// 点击箱子
// 点击装载单元
@Override
public void clickCargoInfo(int index) {
cargoInfoTag = cargoInfoList.get(index);
// Log.e("TAG", "clickCargoInfo:" + cargoInfoTag.toString());
loadOperations = LitePal.where("cargoId =? and type = ? and (state IS NULL or state = '修改') ", String.valueOf(cargoInfoTag.getId()), "正常").find(LoadOperation.class);
loadOperations = LitePal.where("cargoId =? and type = ? and (state IS NULL or state = '修改') ", String.valueOf(cargoInfoTag.getId()), "装载").find(LoadOperation.class);
loadInfoAdapter.setList(loadOperations);
loadInfoAdapter.notifyDataSetChanged();
}
@ -169,21 +178,10 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
}
public void loadOverupdate(View view) {
CargoInfo cargoInfo = new CargoInfo();
cargoInfo.setState("装载中");
cargoInfo.updateAll();
}
// 装载完毕
@Override
@SuppressLint("NotifyDataSetChanged")
public boolean onLongClick(View v) {
if (cargoInfoTag == null) {
return false;
}
alertDialog.show();
return true;
}

@ -6,6 +6,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.example.as_trak.dialog.TipDialog;
import com.example.as_trak.toast.LoadToast;
public class MainActivity extends AppCompatActivity {
@ -14,7 +15,6 @@ public class MainActivity extends AppCompatActivity {
private Intent intent3;
private Intent intent4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -23,6 +23,8 @@ public class MainActivity extends AppCompatActivity {
intent2 = new Intent(this, UnLoadActivity.class);
intent3 = new Intent(this, InfoActivity.class);
intent4 = new Intent(this, SettingActivity.class);
}

@ -64,9 +64,10 @@ public class CargoListAdapter extends RecyclerView.Adapter<CargoListAdapter.MyVi
} else {
if (cargoInfo.getState().equals("装载完成")) {
itemCargoCode.setBackgroundResource(R.drawable.item_over);
return;
// return;
}else {
itemCargoCode.setBackgroundResource(R.drawable.select_bg);
}
itemCargoCode.setBackgroundResource(R.drawable.select_bg);
}
itemCargoCode.setOnClickListener(v -> {
if (tag != -1) {

@ -1,8 +1,16 @@
package com.example.as_trak.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
@ -41,11 +49,14 @@ public class LoadInfoAdapter extends RecyclerView.Adapter<LoadInfoAdapter.MyView
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
ItemLoadInfoBinding binding = holder.binding;
LoadOperation data = list.get(position);
data.setOrderNum(position+1);
data.setOrderNum(list.size()-position);
binding.setData(data);
binding.itemLoadD.setOnClickListener(v -> call.deleteCargoInfo(position));
// binding.itemLoadD.setOnClickListener(v -> call.deleteCargoInfo(position));
binding.itemLoadU.setOnLongClickListener(v -> {
call.updateCargoInfo(position);
// call.updateCargoInfo(position);
showPopupMenu(v, position);
// showPopupWindow(v);
return true;
});
}
@ -69,8 +80,30 @@ public class LoadInfoAdapter extends RecyclerView.Adapter<LoadInfoAdapter.MyView
public interface LoadInfoCall {
void updateCargoInfo(int index);
void deleteCargoInfo(int index);
}
private void showPopupMenu(View view, int index) {
PopupMenu popupMenu = new PopupMenu(view.getContext(), view);
popupMenu.getMenuInflater().inflate(R.menu.popup_menu, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@SuppressLint("NonConstantResourceId")
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
int itemId = menuItem.getItemId();
// 处理删除操作
if (itemId == R.id.action_delete) {
call.deleteCargoInfo(index);
return true;
} else if (itemId == R.id.action_edit) {
call.updateCargoInfo(index);
return true;
}
return false;
}
});
popupMenu.show();
}
}

@ -22,7 +22,6 @@ public class EditDialog extends Dialog {
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());

@ -0,0 +1,54 @@
package com.example.as_trak.dialog;
import android.app.Dialog;
import android.content.Context;
import android.database.Observable;
import android.media.MediaPlayer;
import android.os.Vibrator;
import android.view.LayoutInflater;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import androidx.databinding.ViewDataBinding;
import com.example.as_trak.R;
import com.example.as_trak.databinding.DialogTipBinding;
public class TipDialog extends Dialog {
private MediaPlayer music;
private MediaPlayer musicSuccess;
private Vibrator vibrator;
private ObservableBoolean state;
private DialogTipBinding binding;
public TipDialog(@NonNull Context context) {
super(context, R.style.dialog_style);
music = MediaPlayer.create(context, R.raw.error);
musicSuccess = MediaPlayer.create(context, R.raw.success);
vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_tip, null, false);
setContentView(binding.getRoot());
state = new ObservableBoolean();
setCanceledOnTouchOutside(false);
binding.setState(state);
binding.tipDialogOver.setOnClickListener(v -> dismiss());
}
public void showError(String msg) {
super.show();
music.start();
vibrator.vibrate(500); // 震动1/2秒
state.set(false);
binding.toastMsg.setText(msg);
}
public void showSuccess(String msg) {
super.show();
musicSuccess.start();
state.set(true);
binding.toastMsg.setText(msg);
}
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp"
/>
<solid android:color="#2AA515"/>
</shape>

@ -51,7 +51,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@{data.takeoffDate + data.takeoffTime}"
android:text='@{data.takeoffDate+" "+data.takeoffTime}'
android:textSize="20sp" />
<TextView
android:layout_width="match_parent"
@ -99,9 +99,8 @@
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
@ -114,34 +113,19 @@
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
android:layout_width="60dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="装载时间"
android:textSize="14sp" />
<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="60dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="操作"
android:textSize="15sp" />
</LinearLayout>
@ -172,45 +156,31 @@
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_above="@+id/load_scan_submit"
android:layout_alignTop="@+id/scan_r1"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="1dp"
android:layout_marginBottom="10dp"
android:layout_toEndOf="@+id/scan_r1"
android:adapter="@{adapter2}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<Button
android:id="@+id/load_scan_submit"
android:layout_width="150dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginEnd="62dp"
android:layout_marginBottom="13dp"
android:letterSpacing="0.1"
android:text="装载完毕"
android:textSize="19sp"
android:textStyle="bold" />
</RelativeLayout>
<Button
android:layout_width="300dp"
android:id="@+id/load_scan_submit"
android:layout_width="150dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:letterSpacing="0.5"
android:onClick="loadOverupdate"
android:text="update"
android:layout_marginBottom="13dp"
android:letterSpacing="0.1"
android:text="装载完成"
android:textSize="19sp"
android:textStyle="bold"
android:visibility="gone" />
android:textStyle="bold" />
</LinearLayout>
</layout>

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="state"
type="androidx.databinding.ObservableBoolean" />
<import type="android.view.View" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@{state?@drawable/bg_suecss:@drawable/button_delete}"
android:orientation="vertical"
android:theme="@android:style/Theme.DeviceDefault.Light">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:src="@mipmap/ic_yes"
android:visibility="@{state?View.VISIBLE:View.GONE}" />
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:src="@mipmap/ic_no"
android:visibility="@{state?View.GONE:View.VISIBLE}" />
<TextView
android:id="@+id/toast_msg"
android:layout_width="400dp"
android:layout_height="315dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="28sp" />
<Button
android:id="@+id/tip_dialog_over"
android:layout_width="250dp"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:backgroundTint="@color/white"
android:text="关闭"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="20sp"
android:letterSpacing="0.5"/>
</LinearLayout>
</layout>

@ -16,7 +16,7 @@
android:background="@drawable/select_bg"
android:textStyle="bold"
android:gravity="center"
android:textSize="16sp"
android:textSize="18sp"
android:textColor="@color/black"/>
</LinearLayout>
</layout>

@ -26,9 +26,8 @@
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
<TextView
@ -42,9 +41,8 @@
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:background="#e1e1e1" />
@ -52,29 +50,11 @@
android:layout_width="60dp"
android:layout_height="match_parent"
android:gravity="center"
android:text='@{data.loadTime}'
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:id="@+id/item_load_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>

@ -22,4 +22,5 @@
android:textColor="@color/white"
android:gravity="center"
android:textSize="28sp" />
</LinearLayout>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<item
android:id="@+id/action_delete"
android:title="删除" />
<item
android:id="@+id/action_edit"
android:title="修改" />
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

@ -47,6 +47,7 @@
<!-- 遮罩层 -->
<item name="android:backgroundDimAmount">0.5</item>
<!--对话框动画-->
<!-- <item name="android:windowAnimationStyle">@style/dialog_anim_bottom2top</item>-->
</style>

Loading…
Cancel
Save