kotlin转化完结
This commit is contained in:
@@ -4,6 +4,7 @@ import android.app.Activity;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.dahe.mylibrary.weight.GlideEngine;
|
||||
import com.luck.picture.lib.PictureSelector;
|
||||
import com.luck.picture.lib.config.PictureConfig;
|
||||
import com.luck.picture.lib.entity.LocalMedia;
|
||||
@@ -16,15 +17,16 @@ public class PicturlUtil {
|
||||
//(Activity) ctx 图片选择器
|
||||
PictureSelector.create(activity)
|
||||
.openGallery(PictureConfig.TYPE_IMAGE)
|
||||
.imageEngine(GlideEngine.createGlideEngine())
|
||||
.maxSelectNum(maxNum)
|
||||
.minSelectNum(1)
|
||||
.imageSpanCount(4)// 每行显示个数
|
||||
.selectionMode(PictureConfig.MULTIPLE)//多选
|
||||
.previewImage(true)//预览图片
|
||||
.compress(true)//压缩
|
||||
.isPreviewImage(true)//预览图片
|
||||
.isCompress(true)//压缩
|
||||
.isCamera(true)// 是否显示拍照按钮 true or false
|
||||
.minimumCompressSize(100)// 小于100kb的图片不压缩
|
||||
.selectionMedia(imgs)
|
||||
.selectionData(imgs)
|
||||
.forResult(PictureConfig.CHOOSE_REQUEST);//回调请求码
|
||||
}
|
||||
|
||||
|
||||
+13
-18
@@ -14,7 +14,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.permissionx.guolindev.PermissionX;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -55,32 +55,27 @@ public class GetCarImageAlert {
|
||||
//请按照如图所示拍摄回单照片,回单照片必须保持清晰完整,能看清具体吨数,便于结算运费时核查,感谢配合。
|
||||
}
|
||||
btn_xiangce.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
//ImageGetUtil.AlbumGetImage(act);
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
PicturlUtil.selectPicter(act, new ArrayList<>(), 1);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_paizhao.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.CAMERA
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.CAMERA)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
file=ImageGetUtil.createImageFile(act);
|
||||
ImageGetUtil.cameraAlbumGetImage(act,file);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_quxiao.setOnClickListener(v -> popupWindow.dismiss());
|
||||
//popupWindow消失屏幕变为不透明
|
||||
|
||||
@@ -11,11 +11,12 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
||||
import com.luck.picture.lib.permissions.RxPermissions;
|
||||
import com.arpa.hndahesudintocctmsdriver.R;
|
||||
import com.permissionx.guolindev.PermissionX;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hlh
|
||||
@@ -27,46 +28,44 @@ public class GetImageAlert {
|
||||
|
||||
File file;
|
||||
PopupWindow popupWindow;
|
||||
public void showPopueWindow(AppCompatActivity act){
|
||||
View popView = View.inflate(act, R.layout.choice_img,null);
|
||||
Button btn_xiangce =popView.findViewById(R.id.btn_xiangce);
|
||||
|
||||
public void showPopueWindow(AppCompatActivity act) {
|
||||
View popView = View.inflate(act, R.layout.choice_img, null);
|
||||
Button btn_xiangce = popView.findViewById(R.id.btn_xiangce);
|
||||
Button btn_paizhao = popView.findViewById(R.id.btn_paizhao);
|
||||
Button btn_quxiao = popView.findViewById(R.id.btn_quxiao);
|
||||
Button btn_quxiao = popView.findViewById(R.id.btn_quxiao);
|
||||
//获取屏幕宽高
|
||||
int weight =act.getResources().getDisplayMetrics().widthPixels;
|
||||
int height = act.getResources().getDisplayMetrics().heightPixels*1/3;
|
||||
popupWindow = new PopupWindow(popView,weight,height);
|
||||
int weight = act.getResources().getDisplayMetrics().widthPixels;
|
||||
int height = act.getResources().getDisplayMetrics().heightPixels * 1 / 3;
|
||||
popupWindow = new PopupWindow(popView, weight, height);
|
||||
//popupWindow.setAnimationStyle(R.style.anim_popup_dir);
|
||||
popupWindow.setFocusable(true);
|
||||
//点击外部popueWindow消失
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
|
||||
btn_xiangce.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
PicturlUtil.selectPicter(act, new ArrayList<>(), 1);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_paizhao.setOnClickListener(v -> {
|
||||
RxPermissions rp=new RxPermissions(act);
|
||||
rp.request(
|
||||
Manifest.permission.CAMERA
|
||||
).subscribe(b -> {
|
||||
if (b) {
|
||||
file=ImageGetUtil.createImageFile(act);
|
||||
ImageGetUtil.cameraAlbumGetImage(act,file);
|
||||
|
||||
PermissionX.init(act)
|
||||
.permissions(Manifest.permission.CAMERA)
|
||||
.request((allGranted, grantedList, deniedList) -> {
|
||||
if (allGranted) {
|
||||
file = ImageGetUtil.createImageFile(act);
|
||||
ImageGetUtil.cameraAlbumGetImage(act, file);
|
||||
} else {
|
||||
Toast.makeText(act.getBaseContext(),"开启权限失败,请手动开启权限",Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(act.getBaseContext(), "开启权限失败,请手动开启权限", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
btn_quxiao.setOnClickListener(v -> popupWindow.dismiss());
|
||||
//popupWindow消失屏幕变为不透明
|
||||
@@ -79,14 +78,14 @@ public class GetImageAlert {
|
||||
WindowManager.LayoutParams lp = act.getWindow().getAttributes();
|
||||
lp.alpha = 0.5f;
|
||||
act.getWindow().setAttributes(lp);
|
||||
popupWindow.showAtLocation(popView, Gravity.BOTTOM,0,50);
|
||||
popupWindow.showAtLocation(popView, Gravity.BOTTOM, 0, 50);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void dis(){
|
||||
public void dis() {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user