Commit 324693cab8d6622d3339da95b29582059bd545ba
1 parent
d3e82c2efd
Exists in
master
版本升级
Showing
2 changed files
with
77 additions
and
46 deletions
Show diff stats
app/build.gradle
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
| 2 | apply from: '../config.gradle' | 2 | apply from: '../config.gradle' |
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | def androidId = rootProject.ext.androidId | 5 | def androidId = rootProject.ext.androidId |
| 6 | def support = rootProject.ext.dependencies | 6 | def support = rootProject.ext.dependencies |
| 7 | def url = rootProject.ext.url | 7 | def url = rootProject.ext.url |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | android { | 10 | android { |
| 11 | signingConfigs { | 11 | signingConfigs { |
| 12 | 12 | ||
| 13 | config { | 13 | config { |
| 14 | keyAlias 'alias' | 14 | keyAlias 'alias' |
| 15 | keyPassword '123456' | 15 | keyPassword '123456' |
| 16 | storeFile file('key.jks') | 16 | storeFile file('key.jks') |
| 17 | storePassword '123456' | 17 | storePassword '123456' |
| 18 | } | 18 | } |
| 19 | debug { | 19 | debug { |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | compileSdk 32 | 22 | compileSdk 32 |
| 23 | 23 | ||
| 24 | defaultConfig { | 24 | defaultConfig { |
| 25 | applicationId "com.hjx.parent" | 25 | applicationId "com.hjx.parent" |
| 26 | minSdk 24 | 26 | minSdk 24 |
| 27 | targetSdk 32 | 27 | targetSdk 32 |
| 28 | versionCode 1001 | 28 | versionCode 1002 |
| 29 | versionName "1.0.0.1" | 29 | versionName "1.0.0.2" |
| 30 | 30 | ||
| 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | android.applicationVariants.all { | 34 | android.applicationVariants.all { |
| 35 | variant -> | 35 | variant -> |
| 36 | variant.outputs.all { | 36 | variant.outputs.all { |
| 37 | //在这里修改apk文件名 | 37 | //在这里修改apk文件名 |
| 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 38 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | buildTypes { | 41 | buildTypes { |
| 42 | debug { | 42 | debug { |
| 43 | debuggable true | 43 | debuggable true |
| 44 | minifyEnabled false | 44 | minifyEnabled false |
| 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 45 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 46 | signingConfig signingConfigs.config | 46 | signingConfig signingConfigs.config |
| 47 | } | 47 | } |
| 48 | release { | 48 | release { |
| 49 | debuggable true | 49 | debuggable true |
| 50 | minifyEnabled false | 50 | minifyEnabled false |
| 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 51 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 52 | signingConfig signingConfigs.config | 52 | signingConfig signingConfigs.config |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | lintOptions { | 55 | lintOptions { |
| 56 | checkReleaseBuilds false | 56 | checkReleaseBuilds false |
| 57 | abortOnError false | 57 | abortOnError false |
| 58 | } | 58 | } |
| 59 | buildFeatures { | 59 | buildFeatures { |
| 60 | viewBinding true | 60 | viewBinding true |
| 61 | } | 61 | } |
| 62 | compileOptions { | 62 | compileOptions { |
| 63 | sourceCompatibility JavaVersion.VERSION_1_8 | 63 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 64 | targetCompatibility JavaVersion.VERSION_1_8 | 64 | targetCompatibility JavaVersion.VERSION_1_8 |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | dependencies { | 68 | dependencies { |
| 69 | support.each { k, v -> implementation v } | 69 | support.each { k, v -> implementation v } |
| 70 | api project(path: ':libs:common') | 70 | api project(path: ':libs:common') |
| 71 | implementation 'androidx.appcompat:appcompat:1.5.1' | 71 | implementation 'androidx.appcompat:appcompat:1.5.1' |
| 72 | implementation 'com.google.android.material:material:1.6.1' | 72 | implementation 'com.google.android.material:material:1.6.1' |
| 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | 73 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' |
| 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' | 74 | implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' |
| 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' | 75 | implementation 'com.github.ForgetAll:LoadingDialog:1.1.2' |
| 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' | 76 | implementation 'com.github.DL-ZhangTeng:ImagePicker:1.5.0' |
| 77 | //使用的三方 | 77 | //使用的三方 |
| 78 | implementation 'com.yalantis:ucrop:2.2.0' | 78 | implementation 'com.yalantis:ucrop:2.2.0' |
| 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' | 79 | implementation 'com.github.DL-ZhangTeng:RequestPermission:1.3.0' |
| 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' | 80 | implementation 'com.github.DL-ZhangTeng:Utils:2.2.0' |
| 81 | } | 81 | } |
app/src/main/java/com/hjx/parent/ErrorBookActivity.java
| 1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
| 2 | 2 | ||
| 3 | import android.content.Intent; | 3 | import android.content.Intent; |
| 4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
| 5 | import android.graphics.BitmapFactory; | 5 | import android.graphics.BitmapFactory; |
| 6 | import android.net.Uri; | 6 | import android.net.Uri; |
| 7 | import android.os.Bundle; | 7 | import android.os.Bundle; |
| 8 | import android.provider.MediaStore; | 8 | import android.provider.MediaStore; |
| 9 | import android.text.TextUtils; | 9 | import android.text.TextUtils; |
| 10 | import android.util.Log; | 10 | import android.util.Log; |
| 11 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
| 12 | import android.view.View; | 12 | import android.view.View; |
| 13 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
| 14 | import android.widget.LinearLayout; | 14 | import android.widget.LinearLayout; |
| 15 | import android.widget.Toast; | ||
| 15 | 16 | ||
| 16 | import androidx.annotation.NonNull; | 17 | import androidx.annotation.NonNull; |
| 17 | import androidx.annotation.Nullable; | 18 | import androidx.annotation.Nullable; |
| 18 | import androidx.core.content.FileProvider; | 19 | import androidx.core.content.FileProvider; |
| 19 | import androidx.recyclerview.widget.LinearLayoutManager; | 20 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 20 | import androidx.recyclerview.widget.RecyclerView; | 21 | import androidx.recyclerview.widget.RecyclerView; |
| 21 | 22 | ||
| 22 | import com.chad.library.adapter.base.BaseQuickAdapter; | 23 | import com.chad.library.adapter.base.BaseQuickAdapter; |
| 23 | import com.chad.library.adapter.base.BaseViewHolder; | 24 | import com.chad.library.adapter.base.BaseViewHolder; |
| 24 | import com.google.gson.Gson; | 25 | import com.google.gson.Gson; |
| 26 | import com.hjq.permissions.OnPermissionCallback; | ||
| 27 | import com.hjq.permissions.Permission; | ||
| 28 | import com.hjq.permissions.XXPermissions; | ||
| 25 | import com.hjx.parent.adapter.ErrorAdapter; | 29 | import com.hjx.parent.adapter.ErrorAdapter; |
| 26 | import com.hjx.parent.bean.StudentBean; | 30 | import com.hjx.parent.bean.StudentBean; |
| 27 | import com.hjx.parent.databinding.ActivityErrorBookBinding; | 31 | import com.hjx.parent.databinding.ActivityErrorBookBinding; |
| 28 | import com.prws.common.base.BasePresenter; | 32 | import com.prws.common.base.BasePresenter; |
| 29 | import com.prws.common.bean.ImageBean; | 33 | import com.prws.common.bean.ImageBean; |
| 30 | import com.prws.common.bean.PageInfo; | 34 | import com.prws.common.bean.PageInfo; |
| 31 | import com.prws.common.bean.ResponseResult; | 35 | import com.prws.common.bean.ResponseResult; |
| 32 | import com.prws.common.bean.TopicBean; | 36 | import com.prws.common.bean.TopicBean; |
| 33 | import com.prws.common.net.NetWorks; | 37 | import com.prws.common.net.NetWorks; |
| 34 | import com.prws.common.utils.BitmapUtils; | 38 | import com.prws.common.utils.BitmapUtils; |
| 35 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
| 36 | import com.prws.common.utils.SharedPreferencesUtil; | 40 | import com.prws.common.utils.SharedPreferencesUtil; |
| 37 | import com.prws.common.utils.dialog.MyButtomDialog; | 41 | import com.prws.common.utils.dialog.MyButtomDialog; |
| 38 | import com.zhangteng.imagepicker.bean.ImageInfo; | 42 | import com.zhangteng.imagepicker.bean.ImageInfo; |
| 39 | import com.zhangteng.imagepicker.callback.HandlerCallBack; | 43 | import com.zhangteng.imagepicker.callback.HandlerCallBack; |
| 40 | import com.zhangteng.imagepicker.config.ImagePickerConfig; | 44 | import com.zhangteng.imagepicker.config.ImagePickerConfig; |
| 41 | import com.zhangteng.imagepicker.config.ImagePickerEnum; | 45 | import com.zhangteng.imagepicker.config.ImagePickerEnum; |
| 42 | import com.zhangteng.imagepicker.config.ImagePickerOpen; | 46 | import com.zhangteng.imagepicker.config.ImagePickerOpen; |
| 43 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; | 47 | import com.zhangteng.imagepicker.imageloader.GlideImageLoader; |
| 44 | import com.zhangteng.utils.IHandlerCallBack; | 48 | import com.zhangteng.utils.IHandlerCallBack; |
| 45 | 49 | ||
| 46 | import java.io.File; | 50 | import java.io.File; |
| 47 | import java.util.ArrayList; | 51 | import java.util.ArrayList; |
| 48 | import java.util.Arrays; | 52 | import java.util.Arrays; |
| 49 | import java.util.HashMap; | 53 | import java.util.HashMap; |
| 50 | import java.util.List; | 54 | import java.util.List; |
| 51 | import java.util.Map; | 55 | import java.util.Map; |
| 52 | 56 | ||
| 53 | import io.reactivex.Observer; | 57 | import io.reactivex.Observer; |
| 54 | import io.reactivex.disposables.Disposable; | 58 | import io.reactivex.disposables.Disposable; |
| 55 | 59 | ||
| 56 | public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { | 60 | public class ErrorBookActivity extends BaseActivity<ActivityErrorBookBinding> { |
| 57 | StudentBean studentBean; | 61 | StudentBean studentBean; |
| 58 | private int subject; | 62 | private int subject; |
| 59 | private ErrorAdapter adapter; | 63 | private ErrorAdapter adapter; |
| 60 | private int REQUEST_CODE_IMAGE = 123; | 64 | private int REQUEST_CODE_IMAGE = 123; |
| 61 | private String filePath; | 65 | private String filePath; |
| 62 | 66 | ||
| 63 | @Override | 67 | @Override |
| 64 | public void initView(Bundle savedInstanceState) { | 68 | public void initView(Bundle savedInstanceState) { |
| 65 | String student = (String) SharedPreferencesUtil.getData("student", ""); | 69 | String student = (String) SharedPreferencesUtil.getData("student", ""); |
| 66 | try { | 70 | try { |
| 67 | studentBean = new Gson().fromJson(student, StudentBean.class); | 71 | studentBean = new Gson().fromJson(student, StudentBean.class); |
| 68 | } catch (Exception e) { | 72 | } catch (Exception e) { |
| 69 | 73 | ||
| 70 | } | 74 | } |
| 71 | binding.ivBack.setOnClickListener(new View.OnClickListener() { | 75 | binding.ivBack.setOnClickListener(new View.OnClickListener() { |
| 72 | @Override | 76 | @Override |
| 73 | public void onClick(View v) { | 77 | public void onClick(View v) { |
| 74 | finish(); | 78 | finish(); |
| 75 | } | 79 | } |
| 76 | }); | 80 | }); |
| 77 | binding.rlTakePhoto.post(new Runnable() { | 81 | binding.rlTakePhoto.post(new Runnable() { |
| 78 | @Override | 82 | @Override |
| 79 | public void run() { | 83 | public void run() { |
| 80 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) binding.rlTakePhoto.getLayoutParams(); | 84 | LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) binding.rlTakePhoto.getLayoutParams(); |
| 81 | layoutParams.width = CommonUtil.getScreenWidth(context); | 85 | layoutParams.width = CommonUtil.getScreenWidth(context); |
| 82 | layoutParams.height = CommonUtil.getScreenWidth(context) * 20 / 37; | 86 | layoutParams.height = CommonUtil.getScreenWidth(context) * 20 / 37; |
| 83 | binding.rlTakePhoto.setLayoutParams(layoutParams); | 87 | binding.rlTakePhoto.setLayoutParams(layoutParams); |
| 84 | } | 88 | } |
| 85 | }); | 89 | }); |
| 86 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { | 90 | binding.rlTakePhoto.setOnClickListener(new View.OnClickListener() { |
| 87 | @Override | 91 | @Override |
| 88 | public void onClick(View v) { | 92 | public void onClick(View v) { |
| 89 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | 93 | if (!XXPermissions.isGranted(context, Permission.CAMERA, Permission.WRITE_EXTERNAL_STORAGE)) { |
| 90 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | 94 | XXPermissions.with(context) |
| 91 | dialog.setContentView(bottomView); | 95 | // 申请多个权限 |
| 92 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | 96 | .permission(Permission.CAMERA) |
| 93 | @Override | 97 | .request(new OnPermissionCallback() { |
| 94 | public void onClick(View view) { | 98 | @Override |
| 95 | dialog.dismiss(); | 99 | public void onGranted(List<String> permissions, boolean all) { |
| 96 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 100 | if (all) { |
| 97 | //确保有相机来处理Intent | 101 | //开启扫码界面 |
| 98 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 102 | showButtonDialog(); |
| 99 | File photoFile = new File(filePath); | 103 | } else { |
| 100 | if (photoFile != null) { | 104 | Toast.makeText(context, "需要权限", Toast.LENGTH_SHORT).show(); |
| 101 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 105 | } |
| 102 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 106 | } |
| 103 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 107 | |
| 104 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 108 | @Override |
| 105 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | 109 | public void onDenied(List<String> permissions, boolean never) { |
| 106 | } | 110 | XXPermissions.startPermissionActivity(context, permissions); |
| 107 | } | 111 | } |
| 108 | }); | 112 | }); |
| 109 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | 113 | } else { |
| 110 | @Override | 114 | showButtonDialog(); |
| 111 | public void onClick(View view) { | 115 | } |
| 112 | dialog.dismiss(); | ||
| 113 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | ||
| 114 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | ||
| 115 | .multiSelect(true) //是否多选 | ||
| 116 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | ||
| 117 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | ||
| 118 | .maxImageSelectable(9) //图片可选择数 | ||
| 119 | .maxHeight(1920) //图片最大高度 | ||
| 120 | .maxWidth(1920) //图片最大宽度 | ||
| 121 | .maxImageSize(10) //图片最大大小Mb | ||
| 122 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | ||
| 123 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); | ||
| 124 | 116 | ||
| 125 | } | ||
| 126 | }); | ||
| 127 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | ||
| 128 | @Override | ||
| 129 | public void onClick(View view) { | ||
| 130 | dialog.dismiss(); | ||
| 131 | } | ||
| 132 | }); | ||
| 133 | dialog.show(); | ||
| 134 | } | 117 | } |
| 135 | }); | 118 | }); |
| 136 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { | 119 | BaseQuickAdapter adapter = new BaseQuickAdapter(R.layout.item_subject, Arrays.asList(getResources().getStringArray(R.array.filter_subject))) { |
| 137 | @Override | 120 | @Override |
| 138 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { | 121 | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| 139 | 122 | ||
| 140 | } | 123 | } |
| 141 | 124 | ||
| 142 | @Override | 125 | @Override |
| 143 | protected void convert(@NonNull BaseViewHolder item, Object o) { | 126 | protected void convert(@NonNull BaseViewHolder item, Object o) { |
| 144 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); | 127 | item.setText(R.id.tv_subject, getResources().getStringArray(R.array.filter_subject)[item.getAdapterPosition()]); |
| 145 | switch (item.getAdapterPosition()) { | 128 | switch (item.getAdapterPosition()) { |
| 146 | case 0: | 129 | case 0: |
| 147 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); | 130 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chinese); |
| 148 | break; | 131 | break; |
| 149 | case 1: | 132 | case 1: |
| 150 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); | 133 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_math); |
| 151 | break; | 134 | break; |
| 152 | case 2: | 135 | case 2: |
| 153 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); | 136 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_english); |
| 154 | break; | 137 | break; |
| 155 | case 3: | 138 | case 3: |
| 156 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); | 139 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_physics); |
| 157 | break; | 140 | break; |
| 158 | case 4: | 141 | case 4: |
| 159 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); | 142 | item.setImageResource(R.id.iv_subject, R.mipmap.ic_chemistry); |
| 160 | break; | 143 | break; |
| 161 | } | 144 | } |
| 162 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); | 145 | ViewGroup.LayoutParams layoutParams = item.getView(R.id.rl_subject).getLayoutParams(); |
| 163 | layoutParams.width = (CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 30)) / 4; | 146 | layoutParams.width = (CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 30)) / 4; |
| 164 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); | 147 | item.getView(R.id.rl_subject).setLayoutParams(layoutParams); |
| 165 | item.getConvertView().setOnClickListener(new View.OnClickListener() { | 148 | item.getConvertView().setOnClickListener(new View.OnClickListener() { |
| 166 | @Override | 149 | @Override |
| 167 | public void onClick(View v) { | 150 | public void onClick(View v) { |
| 168 | if (subject != item.getAdapterPosition()) { | 151 | if (subject != item.getAdapterPosition()) { |
| 169 | subject = item.getAdapterPosition(); | 152 | subject = item.getAdapterPosition(); |
| 170 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 153 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
| 171 | } | 154 | } |
| 172 | } | 155 | } |
| 173 | }); | 156 | }); |
| 174 | } | 157 | } |
| 175 | }; | 158 | }; |
| 176 | binding.recycleSubject.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); | 159 | binding.recycleSubject.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)); |
| 177 | binding.recycleSubject.setAdapter(adapter); | 160 | binding.recycleSubject.setAdapter(adapter); |
| 178 | subject = 0; | 161 | subject = 0; |
| 179 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); | 162 | getError(getResources().getStringArray(R.array.filter_subject)[subject]); |
| 180 | binding.llAll.setOnClickListener(new View.OnClickListener() { | 163 | binding.llAll.setOnClickListener(new View.OnClickListener() { |
| 181 | @Override | 164 | @Override |
| 182 | public void onClick(View v) { | 165 | public void onClick(View v) { |
| 183 | Intent intent = new Intent(context, ErrorListActivity.class); | 166 | Intent intent = new Intent(context, ErrorListActivity.class); |
| 184 | startActivity(intent); | 167 | startActivity(intent); |
| 185 | } | 168 | } |
| 186 | }); | 169 | }); |
| 187 | } | 170 | } |
| 188 | 171 | ||
| 189 | @Override | 172 | @Override |
| 190 | protected ActivityErrorBookBinding getViewBinding() { | 173 | protected ActivityErrorBookBinding getViewBinding() { |
| 191 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); | 174 | return ActivityErrorBookBinding.inflate(getLayoutInflater()); |
| 192 | } | 175 | } |
| 193 | 176 | ||
| 177 | private void showButtonDialog() { | ||
| 178 | MyButtomDialog dialog = new MyButtomDialog(context, R.style.BottomSheetDialog); | ||
| 179 | View bottomView = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_layout, null); | ||
| 180 | dialog.setContentView(bottomView); | ||
| 181 | bottomView.findViewById(R.id.take_photo).setOnClickListener(new View.OnClickListener() { | ||
| 182 | @Override | ||
| 183 | public void onClick(View view) { | ||
| 184 | dialog.dismiss(); | ||
| 185 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | ||
| 186 | //确保有相机来处理Intent | ||
| 187 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | ||
| 188 | File photoFile = new File(filePath); | ||
| 189 | if (photoFile != null) { | ||
| 190 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | ||
| 191 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | ||
| 192 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | ||
| 193 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | ||
| 194 | activity.startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE); | ||
| 195 | } | ||
| 196 | } | ||
| 197 | }); | ||
| 198 | bottomView.findViewById(R.id.choose_photo).setOnClickListener(new View.OnClickListener() { | ||
| 199 | @Override | ||
| 200 | public void onClick(View view) { | ||
| 201 | dialog.dismiss(); | ||
| 202 | ImagePickerConfig imagePickerConfig = new ImagePickerConfig.Builder().provider(getPackageName() + ".fileprovider").imageLoader(new GlideImageLoader()) //图片加载器 | ||
| 203 | .iHandlerCallBack(new HandlerCallBack()) //图片选择器生命周期监听(直接打开摄像头时无效) | ||
| 204 | .multiSelect(true) //是否多选 | ||
| 205 | .isShowCamera(false).isVideoPicker(false) //是否选择视频 默认false | ||
| 206 | .isImagePicker(true).imagePickerType(ImagePickerEnum.PHOTO_PICKER) //选择器打开类型 | ||
| 207 | .maxImageSelectable(9) //图片可选择数 | ||
| 208 | .maxHeight(1920) //图片最大高度 | ||
| 209 | .maxWidth(1920) //图片最大宽度 | ||
| 210 | .maxImageSize(10) //图片最大大小Mb | ||
| 211 | .isCrop(false).pathList(new ArrayList<>()).pickerThemeColorRes(R.color.image_picker_white).pickerTitleColorRes(R.color.image_picker_text_black).cropThemeColorRes(R.color.image_picker_white).cropTitleColorRes(R.color.image_picker_text_black).pickerBackRes(R.mipmap.image_picker_back_black).pickerFolderRes(R.mipmap.image_picker_folder_black).build(); | ||
| 212 | ImagePickerOpen.getInstance().setImagePickerConfig(imagePickerConfig).pathList(new ArrayList<>()).open(ErrorBookActivity.this); | ||
| 213 | |||
| 214 | } | ||
| 215 | }); | ||
| 216 | bottomView.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { | ||
| 217 | @Override | ||
| 218 | public void onClick(View view) { | ||
| 219 | dialog.dismiss(); | ||
| 220 | } | ||
| 221 | }); | ||
| 222 | dialog.show(); | ||
| 223 | } | ||
| 224 | |||
| 194 | private void getError(String subject) { | 225 | private void getError(String subject) { |
| 195 | if (studentBean != null) { | 226 | if (studentBean != null) { |
| 196 | Map map = new HashMap(); | 227 | Map map = new HashMap(); |
| 197 | map.put("subject", subject); | 228 | map.put("subject", subject); |
| 198 | map.put("stuId", studentBean.getStuId()); | 229 | map.put("stuId", studentBean.getStuId()); |
| 199 | map.put("pageSize", 5); | 230 | map.put("pageSize", 5); |
| 200 | map.put("pageNum", 1); | 231 | map.put("pageNum", 1); |
| 201 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { | 232 | NetWorks.getError(map, new Observer<ResponseResult<PageInfo<TopicBean>>>() { |
| 202 | @Override | 233 | @Override |
| 203 | public void onSubscribe(Disposable d) { | 234 | public void onSubscribe(Disposable d) { |
| 204 | 235 | ||
| 205 | } | 236 | } |
| 206 | 237 | ||
| 207 | @Override | 238 | @Override |
| 208 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { | 239 | public void onNext(ResponseResult<PageInfo<TopicBean>> result) { |
| 209 | if (result.getData() != null && result.getCode() == 200) { | 240 | if (result.getData() != null && result.getCode() == 200) { |
| 210 | List<TopicBean> topicBeans = result.getData().getList(); | 241 | List<TopicBean> topicBeans = result.getData().getList(); |
| 211 | loadError(topicBeans); | 242 | loadError(topicBeans); |
| 212 | } | 243 | } |
| 213 | } | 244 | } |
| 214 | 245 | ||
| 215 | @Override | 246 | @Override |
| 216 | public void onError(Throwable e) { | 247 | public void onError(Throwable e) { |
| 217 | e.toString(); | 248 | e.toString(); |
| 218 | } | 249 | } |
| 219 | 250 | ||
| 220 | @Override | 251 | @Override |
| 221 | public void onComplete() { | 252 | public void onComplete() { |
| 222 | 253 | ||
| 223 | } | 254 | } |
| 224 | }); | 255 | }); |
| 225 | } | 256 | } |
| 226 | } | 257 | } |
| 227 | 258 | ||
| 228 | @Override | 259 | @Override |
| 229 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 260 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
| 230 | super.onActivityResult(requestCode, resultCode, data); | 261 | super.onActivityResult(requestCode, resultCode, data); |
| 231 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 262 | if (requestCode == REQUEST_CODE_IMAGE && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
| 232 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 263 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
| 233 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 264 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
| 234 | CommonUtil.saveBitmapToUri(b, path); | 265 | CommonUtil.saveBitmapToUri(b, path); |
| 235 | List<String> strings = new ArrayList<>(); | 266 | List<String> strings = new ArrayList<>(); |
| 236 | Intent intent = new Intent(context, ImageActivity.class); | 267 | Intent intent = new Intent(context, ImageActivity.class); |
| 237 | strings.add(path); | 268 | strings.add(path); |
| 238 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); | 269 | intent.putStringArrayListExtra("images", (ArrayList<String>) strings); |
| 239 | startActivity(intent); | 270 | startActivity(intent); |
| 240 | } | 271 | } |
| 241 | } | 272 | } |
| 242 | 273 | ||
| 243 | private void loadError(List<TopicBean> list) { | 274 | private void loadError(List<TopicBean> list) { |
| 244 | if (list.size() > 0) { | 275 | if (list.size() > 0) { |
| 245 | binding.recycleError.setVisibility(View.VISIBLE); | 276 | binding.recycleError.setVisibility(View.VISIBLE); |
| 246 | binding.llEmpty.setVisibility(View.GONE); | 277 | binding.llEmpty.setVisibility(View.GONE); |
| 247 | if (adapter != null) { | 278 | if (adapter != null) { |
| 248 | adapter.refresh(list); | 279 | adapter.refresh(list); |
| 249 | } else { | 280 | } else { |
| 250 | adapter = new ErrorAdapter(context, list, false); | 281 | adapter = new ErrorAdapter(context, list, false); |
| 251 | binding.recycleError.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); | 282 | binding.recycleError.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false)); |
| 252 | binding.recycleError.setAdapter(adapter); | 283 | binding.recycleError.setAdapter(adapter); |
| 253 | } | 284 | } |
| 254 | } else { | 285 | } else { |
| 255 | binding.recycleError.setVisibility(View.GONE); | 286 | binding.recycleError.setVisibility(View.GONE); |
| 256 | binding.llEmpty.setVisibility(View.VISIBLE); | 287 | binding.llEmpty.setVisibility(View.VISIBLE); |
| 257 | } | 288 | } |
| 258 | } | 289 | } |
| 259 | 290 | ||
| 260 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { | 291 | public class HandlerCallBack implements IHandlerCallBack<ImageInfo> { |
| 261 | private String TAG = "---ImagePicker---"; | 292 | private String TAG = "---ImagePicker---"; |
| 262 | List<ImageInfo> photoList = new ArrayList<>(); | 293 | List<ImageInfo> photoList = new ArrayList<>(); |
| 263 | 294 | ||
| 264 | @Override | 295 | @Override |
| 265 | public void onStart() { | 296 | public void onStart() { |
| 266 | Log.i(TAG, "onStart: 开启"); | 297 | Log.i(TAG, "onStart: 开启"); |
| 267 | } | 298 | } |
| 268 | 299 | ||
| 269 | @Override | 300 | @Override |
| 270 | public void onSuccess(List<ImageInfo> photoList) { | 301 | public void onSuccess(List<ImageInfo> photoList) { |
| 271 | this.photoList = photoList; | 302 | this.photoList = photoList; |
| 272 | Log.i(TAG, "onSuccess: 返回数据"); | 303 | Log.i(TAG, "onSuccess: 返回数据"); |
| 273 | } | 304 | } |
| 274 | 305 | ||
| 275 | @Override | 306 | @Override |
| 276 | public void onCancel() { | 307 | public void onCancel() { |
| 277 | Log.i(TAG, "onCancel: 取消"); | 308 | Log.i(TAG, "onCancel: 取消"); |
| 278 | } | 309 | } |