修改 太多了

master
wanghao 4 months ago
parent 008dade658
commit 4274ff4825

@ -2,32 +2,60 @@ package com.example.as_trak;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import com.example.as_trak.adapter.MyFragmentStateAdapter; import com.example.as_trak.adapter.MyFragmentStateAdapter;
import com.example.as_trak.base.BaseActivity; import com.example.as_trak.base.BaseActivity;
import com.example.as_trak.databinding.ActivityInfoBinding; import com.example.as_trak.databinding.ActivityInfoBinding;
import com.example.as_trak.fragment.FlightInfoFragment;
import com.example.as_trak.fragment.LuggageFragment;
import com.google.android.material.tabs.TabLayoutMediator; import com.google.android.material.tabs.TabLayoutMediator;
public class InfoActivity extends BaseActivity { import java.util.ArrayList;
import java.util.List;
public class InfoActivity extends BaseActivity {
private List<Fragment> fragments;
private LuggageFragment luggageFragment;
private ActivityInfoBinding binding;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ActivityInfoBinding binding=DataBindingUtil. setContentView(this,R.layout.activity_info); binding = DataBindingUtil.setContentView(this, R.layout.activity_info);
binding.viewPager2.setAdapter(new MyFragmentStateAdapter(this)); fragments = new ArrayList<>();
// luggageFragment = new LuggageFragment();
new TabLayoutMediator(binding.infoTabLayout, binding.viewPager2, (tab, position) -> { fragments.add(luggageFragment);
fragments.add(new FlightInfoFragment());
MyFragmentStateAdapter adapter = new MyFragmentStateAdapter(this);
adapter.setFragments(fragments);
binding.viewPager2.setAdapter(adapter);
new TabLayoutMediator(binding.infoTabLayout, binding.viewPager2, (tab, position) -> {
switch (position) { switch (position) {
case 0: case 0:
tab.setText("行李信息"); tab.setText("行李信息");
break; break;
case 1: case 1:
tab.setText("航班信息"); tab.setText("航班信息");
break; break;
} }
}).attach(); }).attach();
initScan();
}
@Override
public void sanCodeResult(String code) {
super.sanCodeResult(code);
int currentItem = binding.viewPager2.getCurrentItem();
if (currentItem==0){ //只有第一个页面的时候使用
luggageFragment.sanCode(code);
}
} }
} }

@ -1,10 +1,5 @@
package com.example.as_trak; package com.example.as_trak;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import androidx.databinding.ObservableInt;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -14,8 +9,14 @@ import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ListPopupWindow; import android.widget.ListPopupWindow;
import android.widget.Spinner;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import androidx.databinding.ObservableInt;
import com.example.as_trak.adapter.CargoInfoAdapter; import com.example.as_trak.adapter.CargoInfoAdapter;
import com.example.as_trak.adapter.FlightInfoAdapter; import com.example.as_trak.adapter.FlightInfoAdapter;
import com.example.as_trak.base.BaseActivity; import com.example.as_trak.base.BaseActivity;
@ -47,6 +48,9 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
private ObservableInt loadQty; private ObservableInt loadQty;
private androidx.appcompat.app.AlertDialog.Builder alertDialog; private androidx.appcompat.app.AlertDialog.Builder alertDialog;
private String[] loadStateList; private String[] loadStateList;
private AlertDialog.Builder builder; // 长按删除
private AlertDialog.Builder selectCargoType;//
private Intent intent; // 跳转扫描界面
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -60,13 +64,12 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
binding.setAdapter(cargoInfoAdapter); binding.setAdapter(cargoInfoAdapter);
initAddFlight(); // 航班添加框 initAddFlight(); // 航班添加框
intent = new Intent(this, LoadScanActivity.class); intent = new Intent(this, LoadScanActivity.class);
initInputCargo();
cargoQty = new ObservableInt(); cargoQty = new ObservableInt();
loadQty = new ObservableInt(); loadQty = new ObservableInt();
binding.setQty1(cargoQty); binding.setQty1(cargoQty);
binding.setQty2(loadQty); binding.setQty2(loadQty);
initAlertDialog(); initAlertDialog();
initScan();
} }
private void initAlertDialog() { private void initAlertDialog() {
@ -74,8 +77,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
builder.setTitle("删除确认").setMessage("是否确定删除装载单元").setNegativeButton("取消", null); builder.setTitle("删除确认").setMessage("是否确定删除装载单元").setNegativeButton("取消", null);
loadStateList = getResources().getStringArray(R.array.loadState); loadStateList = getResources().getStringArray(R.array.loadState);
alertDialog = new androidx.appcompat.app.AlertDialog.Builder(this); alertDialog = new androidx.appcompat.app.AlertDialog.Builder(this);
alertDialog.setTitle("选择装载量") alertDialog.setTitle("选择装载量").setNegativeButton("取消", null).create();
.setNegativeButton("取消", null).create();
} }
// 初始化航班添加 // 初始化航班添加
@ -96,6 +98,12 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
}); });
} }
@Override
protected void onResume() {
super.onResume();
initInputCargo();
}
// 初始化添加货箱 // 初始化添加货箱
private void initInputCargo() { private void initInputCargo() {
List<ContainerType> list = LitePal.findAll(ContainerType.class); List<ContainerType> list = LitePal.findAll(ContainerType.class);
@ -111,8 +119,14 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
list2.add(t.getTypeName()); list2.add(t.getTypeName());
} }
}); });
if (list1.isEmpty() || list2.isEmpty()) {
Toast.makeText(this, "基础信息未维护", Toast.LENGTH_SHORT).show();
Intent intent1 = new Intent(this, SettingActivity.class);
startActivity(intent1);
}
binding.setList1(list1); binding.setList1(list1);
binding.setList2(list2); binding.setList2(list2);
} }
} }
@ -128,14 +142,23 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
// 添加货箱 // 添加货箱
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
public void loadAddCargo1(View view) {
if (flightInfoTag == null) return;
String code0 = binding.loadMainCargoSanCode.getText().toString();
addCargo(code0,binding.loadMainSanTypeSpinner.getSelectedItem().toString() );
}
public void loadAddCargo(View view) { public void loadAddCargo(View view) {
if (flightInfoTag == null) return; if (flightInfoTag == null) return;
String cargoCode = binding.loadMainCargoCode.getText().toString(); String cargoCode = binding.loadMainCargoCode.getText().toString();
if (cargoCode.isEmpty()) return; if (cargoCode.isEmpty()) return;
String cargoCode0 = binding.loadMainCargoCode0.getSelectedItem().toString(); String cargoCode0 = binding.loadMainCargoCode0.getSelectedItem().toString();
cargoCode = cargoCode0 + cargoCode;
addCargo(cargoCode, binding.loadMainCargoCode2.getSelectedItem().toString());
}
@SuppressLint("NotifyDataSetChanged")
private void addCargo(String cargoCode,String type){
int id = flightInfoTag.getId(); int id = flightInfoTag.getId();
cargoCode = cargoCode0 + cargoCode ;
int countTag = LitePal.where("cargoCode= ? and flightId=?", cargoCode, String.valueOf(id)).count(CargoInfo.class); int countTag = LitePal.where("cargoCode= ? and flightId=?", cargoCode, String.valueOf(id)).count(CargoInfo.class);
if (countTag > 0) { if (countTag > 0) {
Toast.makeText(this, "装载单元已经绑定", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "装载单元已经绑定", Toast.LENGTH_SHORT).show();
@ -146,12 +169,14 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfo.setCargoCode(cargoCode); cargoInfo.setCargoCode(cargoCode);
cargoInfo.setFlightId(id); cargoInfo.setFlightId(id);
cargoInfo.setState("未装载"); cargoInfo.setState("未装载");
cargoInfo.setCargoType(binding.loadMainCargoCode2.getSelectedItem().toString()); cargoInfo.setCargoType(type);
cargoInfo.save(); cargoInfo.save();
cargoInfoList.add(cargoInfo); cargoInfoList.add(cargoInfo);
cargoInfoAdapter.notifyDataSetChanged(); int size = cargoInfoList.size();
cargoQty.set(cargoInfoList.size()); cargoQty.set(size);
cargoInfoAdapter.notifyItemInserted(size-1);
binding.loadMainCargoCode.setText(null); binding.loadMainCargoCode.setText(null);
binding.loadMainCargoSanCode.setText(null);
Toast.makeText(this, "绑定成功", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "绑定成功", Toast.LENGTH_SHORT).show();
} }
@ -188,11 +213,7 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
flightList.add(flightInfo); flightList.add(flightInfo);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
// 删除装载单元
// 长按删除
private AlertDialog.Builder builder;
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@Override @Override
public void longClickCargoInfo(int index) { public void longClickCargoInfo(int index) {
@ -228,7 +249,6 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
}).show(); }).show();
} }
// 选中航班 // 选中航班
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@ -241,14 +261,14 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
Toast.makeText(this, "查询成功", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "查询成功", Toast.LENGTH_SHORT).show();
lpw.dismiss(); lpw.dismiss();
} }
// 返回时调
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
Log.e("TAG", "onActivityResult:重加载"); Log.e("TAG", "onActivityResult:重加载");
selectCargo(); selectCargo();
} }
// 查询装载单元 内 数量
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
private void selectCargo() { private void selectCargo() {
cargoInfoList = LitePal.where("flightId = ? ", cargoInfoList = LitePal.where("flightId = ? ",
@ -267,8 +287,6 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
cargoInfoAdapter.notifyDataSetChanged(); cargoInfoAdapter.notifyDataSetChanged();
} }
private Intent intent; // 跳转扫描界面
public void clickCargoInfo(View view) { public void clickCargoInfo(View view) {
if (flightInfoTag == null) { if (flightInfoTag == null) {
Toast.makeText(this, "没有选择航班", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "没有选择航班", Toast.LENGTH_SHORT).show();
@ -281,4 +299,16 @@ public class LoadMainActivity extends BaseActivity implements AddFlightDialog.Ad
intent.putExtra("id", flightInfoTag.getId()); intent.putExtra("id", flightInfoTag.getId());
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
} }
// 扫描装载单元
@Override
public void sanCodeResult(String code) {
super.sanCodeResult(code);
if (code.length()<8) {
Toast.makeText(this, "扫描数据:"+code+" 异常", Toast.LENGTH_SHORT).show();
return;
}
String substring = code.substring(0, 8);
binding.loadMainCargoSanCode.setText(substring);
}
} }

@ -1,22 +1,19 @@
package com.example.as_trak; package com.example.as_trak;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.util.Log; import android.util.Log;
import android.view.PixelCopy;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.as_trak.adapter.CargoListAdapter; import com.example.as_trak.adapter.CargoListAdapter;
import com.example.as_trak.adapter.LoadInfoAdapter; import com.example.as_trak.adapter.LoadInfoAdapter;
import com.example.as_trak.base.BaseActivity; import com.example.as_trak.base.BaseActivity;
@ -26,14 +23,14 @@ import com.example.as_trak.dialog.UpdataDialog;
import com.example.as_trak.entity.CargoInfo; import com.example.as_trak.entity.CargoInfo;
import com.example.as_trak.entity.FlightInfo; import com.example.as_trak.entity.FlightInfo;
import com.example.as_trak.entity.LoadOperation; import com.example.as_trak.entity.LoadOperation;
import com.example.as_trak.toast.LoadToast;
import org.litepal.LitePal; import org.litepal.LitePal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LoadScanActivity extends BaseActivity implements CargoListAdapter.CargoInfoCall, LoadInfoAdapter.LoadInfoCall, View.OnLongClickListener { public class LoadScanActivity extends BaseActivity implements CargoListAdapter.CargoInfoCall, LoadInfoAdapter.LoadInfoCall, View.OnLongClickListener {
private List<CargoInfo> cargoInfoList; private List<CargoInfo> cargoInfoList;
@ -50,12 +47,11 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
private ActivityLoadScanBinding binding; private ActivityLoadScanBinding binding;
private TipDialog tipDialog; private TipDialog tipDialog;
private AlertDialog.Builder alertDialog; private AlertDialog.Builder alertDialog;
private Handler handler = new Handler(Looper.getMainLooper());
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan); binding = DataBindingUtil.setContentView(this, R.layout.activity_load_scan);
initScan(); initScan();
int id = getIntent().getIntExtra("id", 0); int id = getIntent().getIntExtra("id", 0);
@ -79,7 +75,6 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
// 初始化弹窗 // 初始化弹窗
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
private void initDialog() { private void initDialog() {
updataDialog = new UpdataDialog(this); updataDialog = new UpdataDialog(this);
updataDialog.setUpdataDialogCall((code, index) -> { updataDialog.setUpdataDialogCall((code, index) -> {
LoadOperation loadOperation = loadOperations.get(index); LoadOperation loadOperation = loadOperations.get(index);
@ -92,42 +87,62 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
}); });
tipDialog = new TipDialog(this); tipDialog = new TipDialog(this);
alertDialog = new AlertDialog.Builder(this); alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("装载完成提示") alertDialog.setTitle("装载完成提示").setMessage("确认装载完成").setNegativeButton("取消", null).setPositiveButton("确认", new DialogInterface.OnClickListener() {
.setMessage("确认装载完成") @Override
.setNegativeButton("取消", null) public void onClick(DialogInterface dialog, int which) {
.setPositiveButton("确认", new DialogInterface.OnClickListener() { if (cargoInfoTag == null) {
@Override Toast.makeText(LoadScanActivity.this, "没有选择装载单元", Toast.LENGTH_SHORT).show();
public void onClick(DialogInterface dialog, int which) { return;
if (cargoInfoTag == null) { }
Toast.makeText(LoadScanActivity.this, "没有选择装载单元", Toast.LENGTH_SHORT).show(); cargoInfoTag.setState("装载完成");
return; cargoInfoTag.update(cargoInfoTag.getId());
} adapter.notifyDataSetChanged();
cargoInfoTag.setState("装载完成"); Toast.makeText(LoadScanActivity.this, "装载完成", Toast.LENGTH_SHORT).show();
cargoInfoTag.update(cargoInfoTag.getId()); }
adapter.notifyDataSetChanged(); }).create();
Toast.makeText(LoadScanActivity.this, "装载完成", Toast.LENGTH_SHORT).show();
}
}).create();
} }
// 点击装载单元 // 点击装载单元
@Override @Override
public void clickCargoInfo(int index) { public void clickCargoInfo(int index) {
cargoInfoTag = cargoInfoList.get(index); cargoInfoTag = cargoInfoList.get(index);
// Log.e("TAG", "clickCargoInfo:" + cargoInfoTag.toString()); // Log.e("TAG", "clickCargoInfo:" + cargoInfoTag.toString());
loadOperations = LitePal.where("cargoId =? and type = ? and (state IS NULL or state = '修改') ", String.valueOf(cargoInfoTag.getId()), "装载") loadOperations = LitePal.where("cargoId =? and type = ? and (state IS NULL or state = '修改') ", String.valueOf(cargoInfoTag.getId()), "装载").order("id desc").find(LoadOperation.class);
.order("id desc").find(LoadOperation.class);
Log.e("TAG", "clickCargoInfo:" + loadOperations); Log.e("TAG", "clickCargoInfo:" + loadOperations);
loadInfoAdapter.setList(loadOperations); loadInfoAdapter.setList(loadOperations);
loadInfoAdapter.notifyDataSetChanged(); loadInfoAdapter.notifyDataSetChanged();
} }
// 扫码结果 // 扫码结果
@SuppressLint("NotifyDataSetChanged")
@Override @Override
public void sanCodeResult(String code) { public void sanCodeResult(String code) {
super.sanCodeResult(code); super.sanCodeResult(code);
binding.loadSanInfoCode.setText(code);
// 先验证扫描情况
String regex = "^[A-Za-z]{3}\\d{5}";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(code);
if (matcher.find()) {
String group = matcher.group();
// Log.e("TAG", "sanCodeResult:" + matcher.group());
for (int i = 0; i < cargoInfoList.size(); i++) {
if (cargoInfoList.get(i).getCargoCode().equals(group)){
RecyclerView.LayoutManager layoutManager = binding.scanR1.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
View itemView = layoutManager.findViewByPosition(i);
if (itemView != null) {
itemView.performClick(); //
Log.e("TAG", "触发点击事件:"+i );
}
}
return;
}
}
}
addInfo(code); addInfo(code);
} }
@ -167,7 +182,7 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
loadOperation.setLoadTime(formattedTime); loadOperation.setLoadTime(formattedTime);
loadOperation.setType("装载"); loadOperation.setType("装载");
loadOperation.save(); loadOperation.save();
loadOperations.add(0, loadOperation);//列表 loadOperations.add(0, loadOperation);// 列表
loadInfoAdapter.notifyItemInserted(0); loadInfoAdapter.notifyItemInserted(0);
binding.loadInfoRecyclerview.scrollToPosition(0); binding.loadInfoRecyclerview.scrollToPosition(0);
loadOperation.setBg(true); loadOperation.setBg(true);
@ -179,13 +194,14 @@ public class LoadScanActivity extends BaseActivity implements CargoListAdapter.C
cargoInfoTag.setState("装载中"); cargoInfoTag.setState("装载中");
cargoInfoTag.update(cargoInfoTag.getId()); cargoInfoTag.update(cargoInfoTag.getId());
} }
private Handler handler = new Handler(Looper.getMainLooper());
private void changeBackgroundColorAfterDelay(LoadOperation loadOperation) { private void changeBackgroundColorAfterDelay(LoadOperation loadOperation) {
handler.postDelayed(() -> { handler.postDelayed(() -> {
loadOperation.setBg(false); loadOperation.setBg(false);
loadInfoAdapter.notifyDataSetChanged(); loadInfoAdapter.notifyDataSetChanged();
}, 3000); }, 3000);
} }
// 修改行李号 // 修改行李号
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@Override @Override

@ -1,28 +1,39 @@
package com.example.as_trak; package com.example.as_trak;
import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle;
import android.util.Log;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
import android.os.Bundle;
import com.example.as_trak.base.BaseActivity; import com.example.as_trak.base.BaseActivity;
import com.example.as_trak.databinding.ActivityUnLoadBinding; import com.example.as_trak.databinding.ActivityUnLoadBinding;
import com.example.as_trak.fragment.LuggageFragment; import com.example.as_trak.fragment.LuggageFragment;
public class UnLoadActivity extends BaseActivity { public class UnLoadActivity extends BaseActivity {
private LuggageFragment luggageFragment;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ActivityUnLoadBinding binding=DataBindingUtil.setContentView(this,R.layout.activity_un_load); ActivityUnLoadBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_un_load);
luggageFragment = new LuggageFragment();
LuggageFragment luggageFragment = new LuggageFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("data", "true"); bundle.putString("data", "true");
luggageFragment.setArguments(bundle); luggageFragment.setArguments(bundle);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.un_load_frame, luggageFragment); transaction.replace(R.id.un_load_frame, luggageFragment);
transaction.commit(); transaction.commit();
initScan();
} }
@Override
public void sanCodeResult(String code) {
super.sanCodeResult(code);
Log.e("TAG", "传值:" + code);
luggageFragment.sanCode(code);
}
} }

@ -57,6 +57,7 @@ public class CargoListAdapter extends RecyclerView.Adapter<CargoListAdapter.MyVi
public void onBindViewHolder(@NonNull MyViewHolder holder, @SuppressLint("RecyclerView") int position) { public void onBindViewHolder(@NonNull MyViewHolder holder, @SuppressLint("RecyclerView") int position) {
ItemCargoListBinding binding = holder.binding; ItemCargoListBinding binding = holder.binding;
TextView itemCargoCode = binding.itemCargoCode; TextView itemCargoCode = binding.itemCargoCode;
CargoInfo cargoInfo = list.get(position); CargoInfo cargoInfo = list.get(position);
itemCargoCode.setText(cargoInfo.getCargoCode()); itemCargoCode.setText(cargoInfo.getCargoCode());
if (bgList.get(position)) { if (bgList.get(position)) {
@ -69,7 +70,7 @@ public class CargoListAdapter extends RecyclerView.Adapter<CargoListAdapter.MyVi
itemCargoCode.setBackgroundResource(R.drawable.select_bg); itemCargoCode.setBackgroundResource(R.drawable.select_bg);
} }
} }
itemCargoCode.setOnClickListener(v -> { binding.itemCargoLinear.setOnClickListener(v -> {
if (tag != -1) { if (tag != -1) {
bgList.set(tag, false); bgList.set(tag, false);
notifyItemChanged(tag); notifyItemChanged(tag);

@ -14,12 +14,14 @@ import java.util.List;
public class MyFragmentStateAdapter extends FragmentStateAdapter { public class MyFragmentStateAdapter extends FragmentStateAdapter {
private List<Fragment> fragments; private List<Fragment> fragments;
public void setFragments(List<Fragment> fragments) {
this.fragments = fragments;
}
public MyFragmentStateAdapter(@NonNull FragmentActivity fragmentActivity) { public MyFragmentStateAdapter(@NonNull FragmentActivity fragmentActivity) {
super(fragmentActivity); super(fragmentActivity);
fragments=new ArrayList<>();
fragments.add(new LuggageFragment());
fragments.add(new FlightInfoFragment());
} }
@NonNull @NonNull

@ -24,8 +24,8 @@ public class BaseActivity extends AppCompatActivity {
public void initScan() { public void initScan() {
myReceiver = new MyScanCodeBroad(); myReceiver = new MyScanCodeBroad();
IntentFilter intentFilter = new IntentFilter(); IntentFilter intentFilter = new IntentFilter();
// intentFilter.addAction("android.intent.ACTION_DECODE_DATA"); intentFilter.addAction("android.intent.ACTION_DECODE_DATA");
intentFilter.addAction("com.rfid.SCAN"); // intentFilter.addAction("com.rfid.SCAN");
registerReceiver(myReceiver, intentFilter); registerReceiver(myReceiver, intentFilter);
} }
@ -39,9 +39,9 @@ public class BaseActivity extends AppCompatActivity {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String value = intent.getStringExtra("barcode_string"); String value = intent.getStringExtra("barcode_string");
String scannerdata = intent.getStringExtra("scannerdata");
Log.e("TAG", "onReceive:" + value); Log.e("TAG", "onReceive:" + value);
sanCodeResult(scannerdata); sanCodeResult(value);
} }
} }
public void sanCodeResult(String code){} public void sanCodeResult(String code){}

@ -5,20 +5,17 @@ import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ListPopupWindow;
import android.widget.Toast; import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import com.example.as_trak.R; import com.example.as_trak.R;
import com.example.as_trak.databinding.FragmentLuggageBinding; import com.example.as_trak.databinding.FragmentLuggageBinding;
import com.example.as_trak.entity.FlightInfo; import com.example.as_trak.entity.FlightInfo;
@ -27,19 +24,17 @@ import com.example.as_trak.fragment.been.LuggageBeen;
import org.litepal.LitePal; import org.litepal.LitePal;
import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.IntStream; import java.util.stream.IntStream;
public class LuggageFragment extends Fragment implements View.OnLongClickListener { public class LuggageFragment extends Fragment implements View.OnLongClickListener/*, SanCodeCall*/ {
private LuggageBeen luggageBeen; private LuggageBeen luggageBeen;
private LoadOperation loadOperationFrist; private LoadOperation loadOperationFrist;
private AlertDialog.Builder builder; private AlertDialog.Builder builder;
private EditText loadMainFlightCode;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
@ -58,7 +53,8 @@ public class LuggageFragment extends Fragment implements View.OnLongClickListene
builder = new AlertDialog.Builder(context); builder = new AlertDialog.Builder(context);
builder.setTitle("拉下确认").setMessage("是否确定拉下行李").setNegativeButton("取消", null); builder.setTitle("拉下确认").setMessage("是否确定拉下行李").setNegativeButton("取消", null);
binding.setData(luggageBeen); binding.setData(luggageBeen);
EditText loadMainFlightCode = binding.loadMainFlightCode;
loadMainFlightCode = binding.loadMainFlightCode;
loadMainFlightCode.setOnTouchListener((v, event) -> { loadMainFlightCode.setOnTouchListener((v, event) -> {
final int DRAWABLE_RIGHT = 2; final int DRAWABLE_RIGHT = 2;
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
@ -122,4 +118,12 @@ public class LuggageFragment extends Fragment implements View.OnLongClickListene
}).show(); }).show();
return true; return true;
} }
// @Override
public void sanCode(String code) {
Log.e("TAG", "接收:" + code);
loadMainFlightCode.setText(code);
selectInfo(code);// 查询
}
} }

@ -87,8 +87,9 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="51dp" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:minHeight="51dp"
android:background="@drawable/main_menu_bg"> android:background="@drawable/main_menu_bg">
<Spinner <Spinner
@ -110,6 +111,7 @@
android:gravity="center" android:gravity="center"
android:inputType="text" android:inputType="text"
android:maxLines="1" android:maxLines="1"
android:textSize="17sp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}" /> android:visibility="@{visibState?View.GONE:View.VISIBLE}" />
<Spinner <Spinner
@ -155,6 +157,56 @@
android:visibility="@{visibState?View.VISIBLE:View.GONE}" android:visibility="@{visibState?View.VISIBLE:View.GONE}"
app:drawableEndCompat="@mipmap/icon_right" /> app:drawableEndCompat="@mipmap/icon_right" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:minHeight="51dp"
android:visibility="@{visibState?View.GONE:View.VISIBLE}"
android:background="@drawable/main_menu_bg">
<TextView
android:layout_width="90dp"
android:layout_height="match_parent"
android:text="扫描添加:"
style="@style/text_title"/>
<TextView
android:id="@+id/load_main_cargo_san_code"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:background="@drawable/select_bg"
android:gravity="center"
android:textSize="17sp"
android:maxLines="1" />
<Spinner
android:id="@+id/load_main_san_type_spinner"
android:layout_width="90dp"
android:layout_height="match_parent"
android:entries="@{list2}"
android:textAlignment="center"/>
<TextView
android:layout_width="55dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:background="@drawable/button_add"
android:gravity="center"
android:onClick="loadAddCargo1"
android:layout_marginEnd="55dp"
android:text="添加"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout> </LinearLayout>

@ -52,7 +52,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center"
android:text='@{data.flightCode+" "+data.takeoffDate}' android:text='@{data.flightCode+"\n"+data.takeoffDate}'
android:textSize="20sp" /> android:textSize="20sp" />
<TextView <TextView
@ -74,9 +74,9 @@
<TextView <TextView
style="@style/text_title" style="@style/text_title"
android:layout_width="110dp" android:layout_width="135dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="扫描或输入:" /> android:text="扫描/输入行李:" />
<EditText <EditText
android:id="@+id/load_san_info_code" android:id="@+id/load_san_info_code"
@ -89,7 +89,7 @@
android:textSize="18sp" /> android:textSize="18sp" />
<ImageButton <ImageButton
android:layout_width="60dp" android:layout_width="80dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginEnd="0dp" android:layout_marginEnd="0dp"
android:background="@color/white" android:background="@color/white"

@ -45,7 +45,7 @@
<com.google.android.material.tabs.TabItem <com.google.android.material.tabs.TabItem
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="舱位代码" /> android:text="类型代码" />
</com.google.android.material.tabs.TabLayout> </com.google.android.material.tabs.TabLayout>

@ -86,14 +86,11 @@
android:textSize="18sp" /> android:textSize="18sp" />
<TextView <TextView
android:id="@+id/load_main_flight_number" android:id="@+id/load_main_flight_number"
style="@style/text_title" style="@style/text_title"
android:layout_width="85dp" android:layout_width="85dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center" /> android:layout_gravity="center" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -155,7 +152,6 @@ android:id="@+id/load_main_flight_number"
android:background="#e1e1e1" /> android:background="#e1e1e1" />
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
@ -169,7 +165,6 @@ android:id="@+id/load_main_flight_number"
android:background="#e1e1e1" /> android:background="#e1e1e1" />
<TextView <TextView
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
@ -187,8 +182,6 @@ android:id="@+id/load_main_flight_number"
android:gravity="center" android:gravity="center"
android:text="时间" android:text="时间"
android:textSize="18sp" /> android:textSize="18sp" />
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

@ -6,9 +6,11 @@
</data> </data>
<LinearLayout <LinearLayout
android:id="@+id/item_cargo_linear"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp" android:layout_height="50dp"
android:padding="1dp"> android:padding="1dp"
android:clickable="true">
<TextView <TextView
android:id="@+id/item_cargo_code" android:id="@+id/item_cargo_code"
android:layout_width="match_parent" android:layout_width="match_parent"

Loading…
Cancel
Save