|
|
|
@ -1,21 +1,38 @@
|
|
|
|
|
package com.example.stlink.activitys.fragmentChild.activityTeaHome;
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.app.Dialog;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.pm.ApplicationInfo;
|
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
|
import android.graphics.PixelFormat;
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
import android.provider.MediaStore;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
|
|
|
import androidx.activity.result.contract.ActivityResultContracts;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.core.content.FileProvider;
|
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
|
|
|
|
|
|
import com.example.stlink.BuildConfig;
|
|
|
|
|
import com.example.stlink.R;
|
|
|
|
|
import com.example.stlink.activitys.fragmentChild.activityStuClassList.CourseSignIn;
|
|
|
|
|
import com.example.stlink.fragments.DidNotSignListFragment;
|
|
|
|
|
import com.example.stlink.fragments.LeaveListFragment;
|
|
|
|
|
import com.example.stlink.fragments.SignListFragment;
|
|
|
|
@ -32,6 +49,7 @@ import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
|
import com.google.gson.internal.LinkedTreeMap;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
@ -55,6 +73,11 @@ public class CheckCourseSign extends AppCompatActivity {
|
|
|
|
|
private Bundle bundle;
|
|
|
|
|
private Handler handler;
|
|
|
|
|
|
|
|
|
|
private Handler shareImageHandler;
|
|
|
|
|
private static ActivityResultLauncher<Intent> intentActivityResultLauncher;
|
|
|
|
|
|
|
|
|
|
Dialog dialog;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
@ -67,6 +90,7 @@ public class CheckCourseSign extends AppCompatActivity {
|
|
|
|
|
private void initView(){
|
|
|
|
|
CommonUtils.changeStatusBar(CheckCourseSign.this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ivCode = findViewById(R.id.iv_code);
|
|
|
|
|
abIvTitle = findViewById(R.id.ab_iv_title);
|
|
|
|
|
aTvCourseName = findViewById(R.id.ab_tv_course_name);
|
|
|
|
@ -78,22 +102,42 @@ public class CheckCourseSign extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
checkCourseSignUtil = new CheckCourseSignUtil(this.getWindow().getDecorView(),CheckCourseSign.this);
|
|
|
|
|
|
|
|
|
|
dialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
|
|
|
|
|
|
|
|
|
setClickListener();
|
|
|
|
|
|
|
|
|
|
refreshData();
|
|
|
|
|
|
|
|
|
|
handler = new Handler(new Handler.Callback() {
|
|
|
|
|
handler = new Handler(msg -> {
|
|
|
|
|
if(msg.arg1 == 200){
|
|
|
|
|
aTvCourseName.setText(courseSignMsg.getCourseName());
|
|
|
|
|
tvCourseStuAmountMsg.setText(String.valueOf(courseSignMsg.getCourseNum()));
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
getCourseSignMsg();
|
|
|
|
|
|
|
|
|
|
shareImageHandler = new Handler(new Handler.Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean handleMessage(@NonNull Message msg) {
|
|
|
|
|
if(msg.arg1 == 200){
|
|
|
|
|
aTvCourseName.setText(courseSignMsg.getCourseName());
|
|
|
|
|
tvCourseStuAmountMsg.setText(String.valueOf(courseSignMsg.getCourseNum()));
|
|
|
|
|
Intent shareIntent = (Intent) msg.obj;
|
|
|
|
|
System.out.println("Here...............shareImageHandler.....");
|
|
|
|
|
startActivity(Intent.createChooser(shareIntent, "分享图片"));
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
getCourseSignMsg();
|
|
|
|
|
|
|
|
|
|
// 意图函数加载器
|
|
|
|
|
intentActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
|
|
|
|
Intent data = result.getData();
|
|
|
|
|
int resultCode = result.getResultCode();
|
|
|
|
|
System.out.println("registerForActivityResult...........................");
|
|
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
|
|
System.out.println("图片分享成功。。。。");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void refreshData(){
|
|
|
|
@ -117,11 +161,28 @@ public class CheckCourseSign extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setClickListener(){
|
|
|
|
|
abIvTitle.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
abIvTitle.setOnClickListener(v -> finish());
|
|
|
|
|
ivCode.setOnClickListener(v -> {
|
|
|
|
|
ivCode.setVisibility(View.INVISIBLE);
|
|
|
|
|
View view = LayoutInflater.from(CheckCourseSign.this).inflate(R.layout.dialog_image, null);
|
|
|
|
|
ImageView ivCodeBig = view.findViewById(R.id.iv_code_big);
|
|
|
|
|
ivCodeBig.setImageDrawable(ivCode.getDrawable());
|
|
|
|
|
dialog.setContentView(view);
|
|
|
|
|
dialog.show();
|
|
|
|
|
ivCodeBig.setOnClickListener(v1 -> {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
ivCode.setVisibility(View.VISIBLE);
|
|
|
|
|
});
|
|
|
|
|
ivCodeBig.setOnLongClickListener(v12 -> {
|
|
|
|
|
Toast.makeText(CheckCourseSign.this, "长按", Toast.LENGTH_SHORT).show();
|
|
|
|
|
shareImage();
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
ivCode.setOnLongClickListener(v -> {
|
|
|
|
|
Toast.makeText(CheckCourseSign.this, "长按", Toast.LENGTH_SHORT).show();
|
|
|
|
|
shareImage();
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -182,4 +243,39 @@ public class CheckCourseSign extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分享二维码图片
|
|
|
|
|
*/
|
|
|
|
|
private void shareImage(){
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
Intent shareIntent = new Intent();
|
|
|
|
|
shareIntent.setAction(Intent.ACTION_SEND);
|
|
|
|
|
shareIntent.setType("image/*"); //设置分享内容的类型
|
|
|
|
|
Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), getBitmap(ivCode.getDrawable()), null,null));
|
|
|
|
|
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
|
|
|
|
Message message = new Message();
|
|
|
|
|
message.arg1 = 200;
|
|
|
|
|
message.obj = shareIntent;
|
|
|
|
|
shareImageHandler.sendMessage(message);
|
|
|
|
|
}).start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从drawable获取BitMap
|
|
|
|
|
* @param drawable 从ImageView中获取的
|
|
|
|
|
* @return 返回BitMap
|
|
|
|
|
*/
|
|
|
|
|
private Bitmap getBitmap(Drawable drawable) {
|
|
|
|
|
Bitmap bitmap = Bitmap.createBitmap(
|
|
|
|
|
drawable.getIntrinsicWidth(),
|
|
|
|
|
drawable.getIntrinsicHeight(),
|
|
|
|
|
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
|
|
|
|
|
: Bitmap.Config.RGB_565);
|
|
|
|
|
Canvas canvas = new Canvas(bitmap);
|
|
|
|
|
//canvas.setBitmap(bitmap);
|
|
|
|
|
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
|
|
|
|
drawable.draw(canvas);
|
|
|
|
|
return bitmap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|