增加 巡检拍照

idata
wanghao 7 months ago
parent f896ff9d90
commit 0b7833ac35

@ -39,8 +39,10 @@ android {
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
implementation 'androidx.appcompat:appcompat:1.6.1'
//noinspection GradleCompatible
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('libs\\App_Demo_API.jar')
implementation files('libs\\DeviceAPIver20150204.jar')
implementation files('libs\\logutil-1.5.1.1.jar')
@ -68,5 +70,12 @@ dependencies {
// implementation 'com.lzy.net:okhttputils:1.6.0' //使
// implementation 'com.lzy.net:okhttpserver:0.1.7' //
// implementation 'com.jakewharton:butterknife:10.2.0'
// annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
// implementation 'com.github.bumptech.glide:glide:4.8.0'
// annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
// https://mvnrepository.com/artifact/com.github.bumptech.glide/glide
implementation 'com.github.bumptech.glide:glide:4.16.0'
}

@ -2,16 +2,26 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <!-- //震动权限 -->
<uses-permission android:name="android.permission.VIBRATE" /> <!-- //外部存储器权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.CAMERA" /> <!-- 相机权限 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name=".base.MyApplication"
android:allowBackup="true"
@ -24,12 +34,30 @@
android:theme="@style/Theme.Beijingdaxing"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.beijing_daxing"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<activity
android:name=".SetingPowerActivity"
android:exported="false" />
<activity
android:name=".CheckListActivity"
android:exported="false" />
<receiver
android:name=".base.BaseActivity$MyReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.rfid.FUN_KEY"/>
<action android:name="android.rfid.FUN_KEY" />
</intent-filter>
</receiver>
@ -61,13 +89,10 @@
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".HomePageActivity"
android:exported="true">
</activity>
android:exported="true" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

@ -5,6 +5,7 @@ import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@ -20,12 +21,14 @@ import com.example.beijing_daxing.base.MyResult;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ActivityCheckBinding;
import com.example.beijing_daxing.dialog.InPutDialog;
import com.example.beijing_daxing.dialog.TakePictureDialog;
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -34,7 +37,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import cn.pda.serialport.Tools;
public class CheckActivity extends BaseActivity implements AdapterClickCall, InPutDialog.InPutDialogCall {
public class CheckActivity extends BaseActivity implements AdapterClickCall, InPutDialog.InPutDialogCall, TakePictureDialog.dialogReturnListSizeCall {
private ActivityCheckBinding binding;
private CheckAdapter adapter;
private List<Stock> list;
@ -43,6 +46,7 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
private ObservableBoolean checkState;
private InPutDialog inputDialog;
private boolean sanType;
private TakePictureDialog takeDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -71,6 +75,8 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
inputDialog = new InPutDialog(this);
inputDialog.setInPutDialogCall(this);
tagList = new ArrayList<>();
takeDialog=new TakePictureDialog(this);
takeDialog.setCall(this);
}
// 初始化数据
@ -204,4 +210,28 @@ public class CheckActivity extends BaseActivity implements AdapterClickCall, InP
handler.postDelayed(runnable, 1000);
}
};
// 拍照
public void check_tackPhoto(View view){
teke_photo();
}
// 显示拍的照片
public void check_showPhoto(View view){
takeDialog.setBitmaps(bitmaps, files);
takeDialog.show();
}
private List<File> files=new ArrayList<>();
private List<Bitmap> bitmaps=new ArrayList<>();
@Override
public void takePhotoCall(File outputImage, Bitmap bitmap) {
files.add(outputImage);
bitmaps.add(bitmap);
binding. confirmPictureNumber2.setText(bitmaps.size() + "");
}
@Override
public void returnListSize(int size) {
binding. confirmPictureNumber2.setText(bitmaps.size() + "");
}
}

@ -0,0 +1,63 @@
package com.example.beijing_daxing;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.example.beijing_daxing.adapter.CheckListAdapter;
import com.example.beijing_daxing.base.BaseActivity;
import com.example.beijing_daxing.base.MyRecultCall;
import com.example.beijing_daxing.base.MyResult;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ActivityCheckListBinding;
import com.example.beijing_daxing.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.uhf.api.cls.Reader;
import java.util.List;
public class CheckListActivity extends BaseActivity {
private CheckListAdapter checkListAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityCheckListBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_check_list);
checkListAdapter = new CheckListAdapter(this);
binding.setAdapter(checkListAdapter);
}
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {
}
public void check_start(View view) {
OkGo.<MyResult>post(url + "/xj/createTask")
.params("user", SharedPreferencesUtils.getstring("user", ""))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
// list = gson.fromJson(body.getData().toString(), new TypeToken<List<Stock>>() {
// }.getType());
// if (list == null || list.isEmpty()) {
// Toast.makeText(CheckActivity.this, "没有维护巡检区域", Toast.LENGTH_SHORT).show();
// return;
// }
// adapter.setList(list);
// adapter.notifyDataSetChanged();
return;
}
// Toast.makeText(this, body.getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
}

@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
@ -64,6 +65,7 @@ public class HomePageActivity extends AppCompatActivity {
uhfLongerManager.asyncStopReading();
uhfLongerManager.close();
MyApplication.uhfLongerManager = null;
Log.e("TAG", "关闭" );
// unregisterReceiver(myNetWorkReceiver);
}
@ -77,6 +79,7 @@ public class HomePageActivity extends AppCompatActivity {
list.add(new HomeIcon(R.mipmap.home_bf, "轮挡报废", BFActivity.class));
list.add(new HomeIcon(R.mipmap.home_in, "废品入库", FpInActivity.class));
list.add(new HomeIcon(R.mipmap.home_out, "废品出库", FpOutActivity.class));
// list.add(new HomeIcon(R.mipmap.home_out, "功率设置", FpOutActivity.class));
var intent = getIntent();
try {
if (!intent.getStringExtra("user").equals("admin")) {

@ -50,11 +50,17 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
adapter.setList(epcList);
adapter.setAdapterClickCall(this);
binding.setAdapter(adapter);
setPower(33);
checkState=new ObservableBoolean();
binding.setCheckState(checkState);
}
@Override
protected void onResume() {
super.onResume();
setPower(33);
}
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {
// Log.e("TAG", "sanRfid:" + epcs);
@ -128,7 +134,7 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
// Log.e("TAG", "发送广播读取RFID");
// sendBroadcast(broadcastIntent);
sanEpc();
handler.postDelayed(runnable, 0);
handler.postDelayed(runnable, 50);
}
};
public void instore_check(View view) {
@ -136,11 +142,12 @@ public class InActivity extends BaseActivity implements AdapterClickCall {
if (b) {
handler.removeCallbacks(runnable);
} else {
handler.postDelayed(runnable, 100);
handler.postDelayed(runnable, 0);
}
checkState.set(!b);
}
@Override
protected void onDestroy() {
super.onDestroy();

@ -40,9 +40,13 @@ public class OutActivity extends BaseActivity implements AdapterClickCall {
outVm=new OutStoreVm();
binding.setVm(outVm);
initRequest();
}
@Override
protected void onResume() {
super.onResume();
setPower(17);
}
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {
epcs.stream().forEach(t -> {

@ -0,0 +1,14 @@
package com.example.beijing_daxing;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class SetingPowerActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seting_power);
}
}

@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.Bindable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import androidx.databinding.ObservableInt;
import android.annotation.SuppressLint;
import android.os.Bundle;
@ -39,16 +40,22 @@ public class StoreCheckActivity extends BaseActivity {
private ObservableBoolean checkState;
private List<Stock> list;
private StoreCheckAdapter checkAdapter;
private int checkNumber;
private ActivityStoreCheckBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityStoreCheckBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_store_check);
binding = DataBindingUtil.setContentView(this, R.layout.activity_store_check);
checkState = new ObservableBoolean();
binding.setCheckState(checkState);
checkAdapter = new StoreCheckAdapter(this);
binding.setAdapter(checkAdapter);
initRequest();
checkNumber=0;
binding.setCheckNumber(checkNumber);
setPower(33);
}
@ -57,7 +64,6 @@ public class StoreCheckActivity extends BaseActivity {
@Override
protected void sanRfid(List<Reader.TAGINFO> epcs) {
if (tagList == null) return;
Log.e("TAG", "sanRfid:");
epcs.forEach(t -> {
var epc = Tools.Bytes2HexString(t.EpcId, t.EpcId.length);
if (tagList.contains(epc)) {
@ -70,9 +76,12 @@ public class StoreCheckActivity extends BaseActivity {
var index = list.indexOf(stock);
if (index != -1) {
list.get(index).setState("Y");
checkNumber--;
binding.setCheckNumber(checkNumber);
checkAdapter.notifyDataSetChanged();
}
});
checkAdapter.notifyDataSetChanged();
}
private void initRequest() {
@ -86,6 +95,10 @@ public class StoreCheckActivity extends BaseActivity {
}.getType());
tagList = new ArrayList<>();
checkAdapter.setList(list);
checkNumber=list.size();
binding.setCheckNumber(checkNumber);
binding.setListNumber(checkNumber);
checkAdapter.notifyDataSetChanged();
} else {
Toast.makeText(StoreCheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
@ -99,7 +112,7 @@ public class StoreCheckActivity extends BaseActivity {
if (b) {
handler.removeCallbacks(runnable);
} else {
handler.postDelayed(runnable, 100);
handler.postDelayed(runnable, 0);
}
checkState.set(!b);
}

@ -0,0 +1,67 @@
package com.example.beijing_daxing.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.example.beijing_daxing.BR;
import com.example.beijing_daxing.R;
import com.example.beijing_daxing.base.AdapterClickCall;
import com.example.beijing_daxing.been.Stock;
import com.example.beijing_daxing.databinding.ItemCheckBinding;
import java.util.List;
/**
* @author wanghao
* @date 2024/1/19 14:32
*/
public class CheckListAdapter extends RecyclerView.Adapter<CheckListAdapter.MyViewHoder> {
private Context context;
private List<Stock> list;
private LayoutInflater inflater;
private AdapterClickCall call;
public CheckListAdapter(Context context) {
this.context = context;
inflater = LayoutInflater.from(context);
this.call=call;
}
public void setList(List<Stock> list) {
this.list = list;
}
@Override
public MyViewHoder onCreateViewHolder(ViewGroup parent, int viewType) {
ItemCheckBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_check, parent, false);
return new MyViewHoder(binding);
}
@Override
public void onBindViewHolder(MyViewHoder holder, int position) {
var binding = holder.getBinding();
binding.setVariable(BR.item,list.get(position));
binding.itemCheckClick.setOnClickListener(v -> call.clickItem(position));
}
@Override
public int getItemCount() {
return list==null?0:list.size();
}
public class MyViewHoder extends RecyclerView.ViewHolder {
private ItemCheckBinding binding;
public MyViewHoder( ItemCheckBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
public ItemCheckBinding getBinding() {
return binding;
}
}
}

@ -0,0 +1,78 @@
package com.example.beijing_daxing.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
// import com.bumptech.glide.Glide;
import com.bumptech.glide.Glide;
import com.example.beijing_daxing.R;
import java.util.List;
/**
* Created by wangh on 2021/1/28-14:02
*/
public class PictureAdapter extends RecyclerView.Adapter<PictureAdapter.MyViewHolder> {
private Context context;
private List<Bitmap> list;
private LayoutInflater inflater;
private ViewOnClickCall call;
public interface ViewOnClickCall{
void onclickCall(int position);
}
public PictureAdapter(Context context, ViewOnClickCall call) {
this.context = context;
this.call=call;
inflater=LayoutInflater.from(context);
}
public void setList(List<Bitmap> list) {
this.list = list;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v=inflater.inflate(R.layout.item_photo,parent,false);
return new MyViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, @SuppressLint("RecyclerView") int position) {
Bitmap info=list.get(position);
// holder.img.setImageBitmap(info);
Glide.with(context).load(info).into( holder.img);
holder.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
call.onclickCall(position);
}
});
}
@Override
public int getItemCount() {
return list.size();
}
class MyViewHolder extends RecyclerView.ViewHolder{
private ImageView img;
private TextView button;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
img=itemView.findViewById(R.id.item_photoImg);
button=itemView.findViewById(R.id.item_photoButton);
}
}
}

@ -1,5 +1,6 @@
package com.example.beijing_daxing.base;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
@ -7,20 +8,37 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Window;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import com.example.beijing_daxing.R;
import com.google.gson.Gson;
import com.handheld.uhfr.*;
import com.uhf.api.cls.Reader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import okhttp3.MediaType;
@ -46,9 +64,7 @@ public abstract class BaseActivity extends AppCompatActivity {
initSan();
broadcastIntent = new Intent("android.rfid.FUN_KEY");
broadcastIntent.putExtra("keydown", false);
// broadcastIntent.setComponent(new ComponentName("com.example.beijing_daxing",".base.BaseActivity$MyReceiver"));
}
// private long readTime = 0;
public class MyReceiver extends BroadcastReceiver {
@ -64,7 +80,8 @@ public abstract class BaseActivity extends AppCompatActivity {
}
}
}
public void sanEpc(){
public void sanEpc() {
List<Reader.TAGINFO> strings = uhfLongerManager.tagInventoryRealTime();
// Log.e("TAG", "驱动" + (uhfLongerManager == null));
if (strings == null || strings.isEmpty()) {
@ -74,6 +91,7 @@ public abstract class BaseActivity extends AppCompatActivity {
mediaPlayer.start();
sanRfid(strings);
}
private void initDialog() {
dialog = new ProgressDialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
@ -95,12 +113,14 @@ public abstract class BaseActivity extends AppCompatActivity {
mediaPlayer = MediaPlayer.create(this, R.raw.msg);
}
public void setPower(int power){
public void setPower(int power) {
try {
Reader.READER_ERR readerErr = uhfLongerManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr.name());
// Log.e("TAG", "readPower:" + uhfLongerManager.getPower()[0]);
}catch (Exception e){
int[] power1 = uhfLongerManager.getPower();
Log.e("TAG", "readPower:" + power1[0] + "," + power1[1]);
} catch (Exception e) {
}
@ -114,4 +134,98 @@ public abstract class BaseActivity extends AppCompatActivity {
protected abstract void sanRfid(List<Reader.TAGINFO> epcs);
public static final int CAMERA_PHOTO = 0X02;
public File outputImage;
public Uri img_uri;
public SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
// 拍照
public void teke_photo() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
}
outputImage = new File(getExternalCacheDir(), "output_imgage" + format.format(new Date()) + ".jpg");
// if (outputImage.exists()) {
// outputImage.delete();
// }
try {
outputImage.createNewFile();
} catch (IOException e) {
Log.e("TAG", "teke_photo:文件创建错误");
e.printStackTrace();
}
if (Build.VERSION.SDK_INT >= 24) {
img_uri = FileProvider.getUriForFile(this, "com.example.beijing_daxing", outputImage);
Log.e("TAG", "teke_photo1"+img_uri.toString() );
} else {
img_uri = Uri.fromFile(outputImage);
Log.e("TAG", "teke_photo2" );
}
if (
PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, img_uri);
startActivityForResult(intent, CAMERA_PHOTO);
} else {
// 提示用户开户权限 拍照和读写sd卡权限
String[] perms = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA};
ActivityCompat.requestPermissions(this, perms, CAMERA_PHOTO);
}
}
public void takePhotoCall(File outputImage, Bitmap bitmap) {
}
// 拍照的回调
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
/*
try {
Bitmap bitmap;
InputStream inputStream = getContentResolver().openInputStream(img_uri);
if (inputStream!= null) {
bitmap = BitmapFactory.decodeStream(inputStream);
FileOutputStream outputStream = new FileOutputStream(outputImage);
if (bitmap!= null) {
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, outputStream);
takePhotoCall(outputImage, bitmap);
outputStream.close();
} else {
Log.e("Error", "Bitmap is null after decoding.");
}
} else {
Log.e("Error", "InputStream is null.");
}
} catch (IOException e) {
Log.e("Error", "Error reading or writing file.", e);
}
*/
Bitmap bitmap = null;
try {
Log.e("TAG", "onActivityResult:" + img_uri.getPath());
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(img_uri));
FileOutputStream outputStream = new FileOutputStream(outputImage);
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, outputStream);
takePhotoCall(outputImage, bitmap);
outputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@ -0,0 +1,100 @@
package com.example.beijing_daxing.dialog;
import android.Manifest;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.beijing_daxing.adapter.PictureAdapter;
import com.example.beijing_daxing.R;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author wanghao
* @date 2023/2/1 17:06
*/
public class TakePictureDialog extends Dialog implements PictureAdapter.ViewOnClickCall {
RecyclerView pictureRecyclerview;
private Context context;
private List<Bitmap> bitmaps;
private List<File> files;
private PictureAdapter adapter;
private dialogReturnListSizeCall call;
public TakePictureDialog(@NonNull Context context) {
super(context, R.style.dialog);
this.context = context;
adapter = new PictureAdapter(context, this);
}
public void setCall(dialogReturnListSizeCall call) {
this.call = call;
}
public void setBitmaps(List<Bitmap> bitmaps, List<File> files) {
this.bitmaps = bitmaps;
this.files = files;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_picture);
pictureRecyclerview = findViewById(R.id.picture_recyclerview);
findViewById(R.id.confirm_back).setOnClickListener(v -> {
call.returnListSize(bitmaps.size());
dismiss();
});
pictureRecyclerview.setLayoutManager(new GridLayoutManager(context, 3));
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
// linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
// pictureRecyclerview.setLayoutManager(linearLayoutManager);
}
@Override
public void show() {
super.show();
adapter.setList(bitmaps);
pictureRecyclerview.setAdapter(adapter);
Log.e("TAG", "show");
}
@Override
public void onclickCall(int position) {
Log.e("TAG", "在dialog中删除的id:" + position);
bitmaps.remove(position);
files.get(position).delete();
files.remove(position);
adapter.notifyDataSetChanged();
}
public interface dialogReturnListSizeCall {
public void returnListSize(int size);
}
}

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

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

@ -132,7 +132,8 @@
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="20dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:backgroundTint="@{checkState?@color/yellow:@color/black}"
android:onClick="offCheckRead"
@ -141,14 +142,40 @@
android:textSize="20sp" />
<Button
style="@style/button_style"
style="@style/button_style1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:backgroundTint="#009688"
android:onClick="check_submit"
android:text="完成巡检" />
<FrameLayout
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/icon_cromer"
android:onClick="check_tackPhoto"/>
<TextView
android:id="@+id/confirm_picture_number2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:background="@drawable/bg_number"
android:gravity="center"
android:text="0"
android:textColor="@color/white"
android:textSize="18sp"
android:onClick="check_showPhoto"/>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</layout>

@ -0,0 +1,95 @@
<?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="adapter"
type="com.example.beijing_daxing.adapter.CheckListAdapter" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".CheckListActivity">
<TextView
style="@style/title_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:letterSpacing="0"
android:text="待巡检机位列表" />
<LinearLayout
android:layout_width="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_height="45dp">
<TextView
android:id="@+id/item_index"
style="@style/item_text_style"
android:layout_width="40dp"
android:layout_height="match_parent"
android:text="序号"
/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="机位码"
/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="match_parent"
android:text="状态" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="match_parent"
android:textColor="#E71717" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="450dp"
android:adapter="@{adapter}"
android:padding="10dp"
android:layout_weight="1"
android:background="@color/white"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="15dp"
android:onClick="check_start"
android:text="开始巡检" />
</LinearLayout>
</layout>

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SetingPowerActivity">
<!-- <TextView
style="@style/title_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text="废品入库" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="入库功率:" />
<EditText
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="@={vm.epc}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="出库功率:" />
<TextView
style="@style/info_text1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="@={vm.bichCode}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="轮挡位置:" />
<TextView
style="@style/info_text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@={vm.location}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="位置代码:" />
<TextView
style="@style/info_text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@={vm.locationCode}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="轮挡状态:" />
<TextView
style="@style/info_text1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="@={vm.state}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="报废时间:" />
<TextView
style="@style/info_text1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="@={vm.time}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="8dp"
android:background="@color/white">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:background="@color/bg1"
android:text="选择库位:" />
<Spinner
android:layout_width="match_parent"
android:layout_height="45dp"
android:entries="@{vm.list}"
android:onItemSelected="@{vm.selectLocation}"
android:textAlignment="center" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="20dp"
android:onClick="fpin_submit"
android:text="废品入库" />-->
</LinearLayout>

@ -4,20 +4,31 @@
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="checkState"
type="androidx.databinding.ObservableBoolean" />
<variable
name="adapter"
type="com.example.beijing_daxing.adapter.StoreCheckAdapter" />
<variable
name="checkNumber"
type="Integer" />
<variable
name="listNumber"
type="Integer" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StoreCheckActivity"
android:background="@color/bg1"
android:orientation="vertical">
android:orientation="vertical"
tools:context=".StoreCheckActivity">
<TextView
style="@style/title_text"
android:layout_width="match_parent"
@ -28,33 +39,62 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:background="@color/white"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_weight="1"
android:adapter="@{adapter}"
android:background="@color/white"
android:padding="10dp"
android:layout_weight="1"/>
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="轮挡总数量:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{listNumber+""}' />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="未盘点数量:" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{checkNumber+""}' />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_marginBottom="15dp"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@{checkState?@color/yellow:@color/black}"
android:layout_marginStart="20dp"
android:text='@{checkState?"停止读取":"开始盘点"}'
android:textSize="20sp"
android:layout_weight="1"
android:backgroundTint="@{checkState?@color/yellow:@color/black}"
android:onClick="check_read"
android:layout_weight="1"/>
<Button
android:text='@{checkState?"停止读取":"开始盘点"}'
android:textSize="20sp" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="store_check_submit"
style="@style/button_style"
android:text="提交"/>
android:layout_weight="1"
android:onClick="store_check_submit"
android:text="提交" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="450dp"
android:background="@drawable/info_text_bg"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/picture_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="12dp" />
<Button
android:id="@+id/confirm_back"
style="@style/button_style2"
android:layout_width="150dp"
android:layout_height="48dp"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="关闭" />
</LinearLayout>

@ -0,0 +1,63 @@
<?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_marginTop="5dp"
android:layout_height="45dp"
android:background="#EAEDFD">
<TextView
android:id="@+id/item_index"
style="@style/item_text_style"
android:layout_width="40dp"
android:layout_height="match_parent"
android:text="序号"
/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="机位码"
/>
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="@drawable/state_y_bg"
android:textColor="@color/white"
android:text="状态" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="match_parent"
android:textColor="#E71717" />
</LinearLayout>
</layout>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="200dp"
android:layout_height="200dp">
<ImageView
android:id="@+id/item_photoImg"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView
android:id="@+id/item_photoButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="right"
android:gravity="center"
android:textSize="29sp"
android:text="×" />
</FrameLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.Beijingdaxing" parent="Theme.Material3.DayNight.NoActionBar">
<style name="Base.Theme.Beijingdaxing" parent="Theme.Material3.Light.NoActionBar">
<!-- Customize your light theme here. -->
<item name="colorPrimary">@color/blue</item>
</style>
@ -33,6 +33,11 @@
<item name="android:layout_marginStart">20dp</item>
<item name="android:layout_marginEnd">20dp</item>
</style>
<style name="button_style1">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:gravity">center</item>
</style>
<style name="info_text">
<item name="android:textColor">@color/black</item>
@ -76,4 +81,11 @@
<item name="android:windowMinWidthMinor">95%</item><!--宽度铺满全屏-->
</style>
<style name="button_style2">
<item name="android:textSize">18sp</item>
<!-- <item name="android:background">@drawable/bg_button2</item>>-->
<!-- <item name="android:textColor">@color/purple_700</item>-->
<item name="android:letterSpacing">0.033</item>
</style>
</resources>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path
name="my_images"
path="."/>
<!-- <files-path name="my_images" path="images/"/>-->
</paths>
Loading…
Cancel
Save