保存会议签到码至相册
This commit is contained in:
parent
94cd6f3341
commit
4caa142484
@ -3,6 +3,7 @@ package com.tenlionsoft.baselib.core.widget.views;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
@ -51,7 +52,14 @@ public class QrDialog extends Dialog {
|
||||
Glide.with(context)
|
||||
.load(BaseUrlApi.BASE_IMG_URL + mQr)
|
||||
.into(mIvQr);
|
||||
View content = view.findViewById(R.id.ll_content);
|
||||
view.findViewById(R.id.tv_confirm).setOnClickListener(v -> this.dismiss());
|
||||
view.findViewById(R.id.tv_save).setOnClickListener(v -> {
|
||||
if (mChangeListener != null) {
|
||||
Bitmap viewBitmap = getViewBitmap(content);
|
||||
mChangeListener.doChange(viewBitmap);
|
||||
}
|
||||
});
|
||||
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
||||
Window window = this.getWindow();
|
||||
window.setGravity(Gravity.CENTER);
|
||||
@ -63,14 +71,6 @@ public class QrDialog extends Dialog {
|
||||
window.setBackgroundDrawable(new ColorDrawable());
|
||||
}
|
||||
|
||||
private void doConfirm() {
|
||||
if (checkParams()) {
|
||||
if (mChangeListener != null) {
|
||||
String content = mEtContent.getText().toString().trim();
|
||||
mChangeListener.doChange(content, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HideSoftKeyBoardDialog(Activity activity) {
|
||||
try {
|
||||
@ -85,7 +85,29 @@ public class QrDialog extends Dialog {
|
||||
}
|
||||
|
||||
public interface OnChangeListener {
|
||||
void doChange(String org, float level);
|
||||
void doChange(Bitmap b);
|
||||
}
|
||||
|
||||
private Bitmap getViewBitmap(View v) {
|
||||
v.clearFocus();
|
||||
v.setPressed(false);
|
||||
boolean b = v.willNotCacheDrawing();
|
||||
v.setWillNotCacheDrawing(false);
|
||||
int color = v.getDrawingCacheBackgroundColor();
|
||||
v.setDrawingCacheBackgroundColor(0);
|
||||
if (color != 0) {
|
||||
v.destroyDrawingCache();
|
||||
}
|
||||
v.buildDrawingCache();
|
||||
Bitmap drawingCache = v.getDrawingCache();
|
||||
if (drawingCache == null) {
|
||||
return null;
|
||||
}
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawingCache);
|
||||
v.destroyDrawingCache();
|
||||
v.setWillNotCacheDrawing(b);
|
||||
v.setDrawingCacheBackgroundColor(color);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,12 +15,30 @@
|
||||
android:textSize="18sp" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_qr"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="250dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="5dp" />
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_qr"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="250dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="center"
|
||||
android:text="打开App点击扫码\n扫描上方二维码进行签到"
|
||||
android:textColor="@color/gray_text"
|
||||
android:textSize="10sp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
@ -29,6 +47,17 @@
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="10dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="10dp"
|
||||
android:text="保存到相册"
|
||||
android:textColor="@color/red_ff" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_confirm"
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.tenlionsoft.oamodule.activity.meeting;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
@ -29,6 +35,10 @@ import com.tenlionsoft.oamodule.beans.MeetingRoomRecordBean;
|
||||
import com.tenlionsoft.oamodule.beans.PersonShowBean;
|
||||
import com.tenlionsoft.oamodule.net.OAApi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -76,6 +86,7 @@ public class MeetingDetailActivity extends BaseActivity {
|
||||
private List<PersonShowBean> mJoinPerson;
|
||||
private BasePersonShowAdapter mPersonShowAdapter;
|
||||
private String mQr;
|
||||
private String mQrName;
|
||||
|
||||
@Override
|
||||
protected int setLayoutId() {
|
||||
@ -185,10 +196,59 @@ public class MeetingDetailActivity extends BaseActivity {
|
||||
QrDialog dialog = new QrDialog.DialogBuilder(mActivity)
|
||||
.setQr(mQr)
|
||||
.build();
|
||||
dialog.addOnChangeListener(b -> {
|
||||
if (null != b) {
|
||||
dialog.dismiss();
|
||||
doSaveBitMapToMedia(b);
|
||||
} else {
|
||||
ToastUtils.show("保存失败");
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存图片到相册
|
||||
*
|
||||
* @param b
|
||||
*/
|
||||
private void doSaveBitMapToMedia(Bitmap b) {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "保存中...");
|
||||
dialog.show();
|
||||
String imageName = mQrName + "code.png";
|
||||
File f = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||
File file = new File(f.getPath() + "/" + imageName);
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
b.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
Log.e("写入成功!位置目录", f.getPath() + "/" + imageName);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("保存失败");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("保存失败");
|
||||
}
|
||||
try {
|
||||
MediaStore.Images.Media.insertImage(getContentResolver(),
|
||||
file.getAbsolutePath(), imageName, null);
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("保存成功");
|
||||
} catch (FileNotFoundException e) {
|
||||
if (dialog.isShowing()) dialog.dismiss();
|
||||
ToastUtils.show("保存失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
// 最后通知图库更新
|
||||
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
|
||||
Uri.fromFile(new File(file.getPath()))));
|
||||
}
|
||||
|
||||
private void doGetQr() {
|
||||
ProgressDialog dialog = UIUtil.initDialog(mActivity, "获取中...");
|
||||
dialog.show();
|
||||
@ -209,6 +269,7 @@ public class MeetingDetailActivity extends BaseActivity {
|
||||
ToastUtils.show("未获取到签到码,请稍后重试");
|
||||
} else {
|
||||
mQr = meetingQrBean.getQrId();
|
||||
mQrName = meetingQrBean.getQrName();
|
||||
onShowQr();
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,14 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.tenlionsoft.baselib.constant.PathConfig;
|
||||
import com.tenlionsoft.baselib.core.retrofit_net.BaseUrlApi;
|
||||
import com.tenlionsoft.baselib.core.widget.base.BaseFragment;
|
||||
import com.tenlionsoft.baselib.utils.LogUtils;
|
||||
import com.tenlionsoft.baselib.utils.UserLgUtils;
|
||||
import com.tenlionsoft.oamodule.R;
|
||||
import com.tenlionsoft.oamodule.R2;
|
||||
|
||||
@ -47,6 +52,8 @@ public class EmailFragment extends BaseFragment {
|
||||
TextView mTvRecycleBox;
|
||||
@BindView(R2.id.ll_content)
|
||||
LinearLayout mLlContent;
|
||||
@BindView(R2.id.iv_user_icon)
|
||||
ImageView mIvUserIcon;
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
@ -67,6 +74,12 @@ public class EmailFragment extends BaseFragment {
|
||||
super.onResume();
|
||||
//获取焦点
|
||||
LogUtils.e("email获取了焦点");
|
||||
Glide.with(mActivity)
|
||||
.load(BaseUrlApi.BASE_IMG_URL + UserLgUtils.getAvatar())
|
||||
.apply(RequestOptions.bitmapTransform(new CircleCrop())
|
||||
.error(R.drawable.ic_user_default)
|
||||
.placeholder(R.drawable.ic_user_default))
|
||||
.into(mIvUserIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,6 +14,7 @@
|
||||
android:paddingRight="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_user_icon"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_centerVertical="true"
|
||||
|
Loading…
Reference in New Issue
Block a user