Commit e845f252e0101e1ee1ff7a73e350090d952f6bf8
1 parent
831fc93537
Exists in
master
框选迁移
Showing
18 changed files
with
401 additions
and
21 deletions
Show diff stats
.idea/inspectionProfiles/Project_Default.xml
| 1 | <component name="InspectionProjectProfileManager"> | 1 | <component name="InspectionProjectProfileManager"> |
| 2 | <profile version="1.0"> | 2 | <profile version="1.0"> |
| 3 | <option name="myName" value="Project Default" /> | 3 | <option name="myName" value="Project Default" /> |
| 4 | <inspection_tool class="Deprecation" enabled="false" level="WARNING" enabled_by_default="false" /> | 4 | <inspection_tool class="Deprecation" enabled="false" level="WARNING" enabled_by_default="false" /> |
| 5 | <inspection_tool class="IgnoreResultOfCall" enabled="false" level="WARNING" enabled_by_default="false"> | 5 | <inspection_tool class="IgnoreResultOfCall" enabled="false" level="WARNING" enabled_by_default="false"> |
| 6 | <option name="m_reportAllNonLibraryCalls" value="false" /> | 6 | <option name="m_reportAllNonLibraryCalls" value="false" /> |
| 7 | <option name="callCheckString" value="java.io.File,.*,java.io.InputStream,read|skip|available|markSupported,java.io.Reader,read|skip|ready|markSupported,java.lang.AbstractStringBuilder,capacity|codePointAt|codePointBefore|codePointCount|indexOf|lastIndexOf|offsetByCodePoints|substring|subSequence,java.lang.Boolean,.*,java.lang.Byte,.*,java.lang.Character,.*,java.lang.Double,.*,java.lang.Float,.*,java.lang.Integer,.*,java.lang.Long,.*,java.lang.Math,.*,java.lang.Object,equals|hashCode|toString,java.lang.Short,.*,java.lang.StrictMath,.*,java.lang.String,.*,java.lang.Thread,interrupted,java.math.BigDecimal,.*,java.math.BigInteger,.*,java.net.InetAddress,.*,java.net.URI,.*,java.nio.channels.AsynchronousChannelGroup,.*,java.nio.channels.Channel,isOpen,java.nio.channels.FileChannel,open|map|lock|tryLock|write,java.nio.channels.ScatteringByteChannel,read,java.nio.channels.SocketChannel,open|socket|isConnected|isConnectionPending,java.util.Arrays,.*,java.util.Collections,(?!addAll).*,java.util.List,of,java.util.Map,of|ofEntries|entry,java.util.Set,of,java.util.UUID,.*,java.util.concurrent.BlockingQueue,offer|remove,java.util.concurrent.CountDownLatch,await|getCount,java.util.concurrent.ExecutorService,awaitTermination|isShutdown|isTerminated,java.util.concurrent.ForkJoinPool,awaitQuiescence,java.util.concurrent.Semaphore,tryAcquire|availablePermits|isFair|hasQueuedThreads|getQueueLength|getQueuedThreads,java.util.concurrent.locks.Condition,await|awaitNanos|awaitUntil,java.util.concurrent.locks.Lock,tryLock|newCondition,java.util.regex.Matcher,pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparentBounds|hasAnchoringBounds|hitEnd|requireEnd,java.util.regex.Pattern,.*,java.util.stream.BaseStream,.*,java.util.stream.DoubleStream,.*,java.util.stream.IntStream,.*,java.util.stream.LongStream,.*,java.util.stream.Stream,.*" /> | 7 | <option name="callCheckString" value="java.io.File,.*,java.io.InputStream,read|skip|available|markSupported,java.io.Reader,read|skip|ready|markSupported,java.lang.AbstractStringBuilder,capacity|codePointAt|codePointBefore|codePointCount|indexOf|lastIndexOf|offsetByCodePoints|substring|subSequence,java.lang.Boolean,.*,java.lang.Byte,.*,java.lang.Character,.*,java.lang.Double,.*,java.lang.Float,.*,java.lang.Integer,.*,java.lang.Long,.*,java.lang.Math,.*,java.lang.Object,equals|hashCode|toString,java.lang.Short,.*,java.lang.StrictMath,.*,java.lang.String,.*,java.lang.Thread,interrupted,java.math.BigDecimal,.*,java.math.BigInteger,.*,java.net.InetAddress,.*,java.net.URI,.*,java.nio.channels.AsynchronousChannelGroup,.*,java.nio.channels.Channel,isOpen,java.nio.channels.FileChannel,open|map|lock|tryLock|write,java.nio.channels.ScatteringByteChannel,read,java.nio.channels.SocketChannel,open|socket|isConnected|isConnectionPending,java.util.Arrays,.*,java.util.Collections,(?!addAll).*,java.util.List,of,java.util.Map,of|ofEntries|entry,java.util.Set,of,java.util.UUID,.*,java.util.concurrent.BlockingQueue,offer|remove,java.util.concurrent.CountDownLatch,await|getCount,java.util.concurrent.ExecutorService,awaitTermination|isShutdown|isTerminated,java.util.concurrent.ForkJoinPool,awaitQuiescence,java.util.concurrent.Semaphore,tryAcquire|availablePermits|isFair|hasQueuedThreads|getQueueLength|getQueuedThreads,java.util.concurrent.locks.Condition,await|awaitNanos|awaitUntil,java.util.concurrent.locks.Lock,tryLock|newCondition,java.util.regex.Matcher,pattern|toMatchResult|start|end|group|groupCount|matches|find|lookingAt|quoteReplacement|replaceAll|replaceFirst|regionStart|regionEnd|hasTransparentBounds|hasAnchoringBounds|hitEnd|requireEnd,java.util.regex.Pattern,.*,java.util.stream.BaseStream,.*,java.util.stream.DoubleStream,.*,java.util.stream.IntStream,.*,java.util.stream.LongStream,.*,java.util.stream.Stream,.*" /> |
| 8 | </inspection_tool> | 8 | </inspection_tool> |
| 9 | <inspection_tool class="UnnecessaryLocalVariable" enabled="false" level="WARNING" enabled_by_default="false"> | ||
| 10 | <option name="m_ignoreImmediatelyReturnedVariables" value="false" /> | ||
| 11 | <option name="m_ignoreAnnotatedVariables" value="false" /> | ||
| 12 | </inspection_tool> | ||
| 9 | </profile> | 13 | </profile> |
| 10 | </component> | 14 | </component> |
app/build.gradle
| 1 | apply plugin: 'com.android.application' | 1 | apply plugin: 'com.android.application' |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | def androidId = rootProject.ext.androidId | 4 | def androidId = rootProject.ext.androidId |
| 5 | def support = rootProject.ext.dependencies | 5 | def support = rootProject.ext.dependencies |
| 6 | def url = rootProject.ext.url | 6 | def url = rootProject.ext.url |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | android { | 9 | android { |
| 10 | signingConfigs { | 10 | signingConfigs { |
| 11 | 11 | ||
| 12 | config { | 12 | config { |
| 13 | keyAlias 'alias' | 13 | keyAlias 'alias' |
| 14 | keyPassword '123456' | 14 | keyPassword '123456' |
| 15 | storeFile file('key.jks') | 15 | storeFile file('key.jks') |
| 16 | storePassword '123456' | 16 | storePassword '123456' |
| 17 | } | 17 | } |
| 18 | debug { | 18 | debug { |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| 21 | compileSdk 32 | 21 | compileSdk 32 |
| 22 | 22 | ||
| 23 | defaultConfig { | 23 | defaultConfig { |
| 24 | applicationId "com.hjx.parent" | 24 | applicationId "com.hjx.parent" |
| 25 | minSdk 26 | 25 | minSdk 26 |
| 26 | targetSdk 32 | 26 | targetSdk 32 |
| 27 | versionCode 1012 | 27 | versionCode 1012 |
| 28 | versionName "1.0.12" | 28 | versionName "1.0.12" |
| 29 | 29 | ||
| 30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | android.applicationVariants.all { | 33 | android.applicationVariants.all { |
| 34 | variant -> | 34 | variant -> |
| 35 | variant.outputs.all { | 35 | variant.outputs.all { |
| 36 | //在这里修改apk文件名 | 36 | //在这里修改apk文件名 |
| 37 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" | 37 | outputFileName = "parent-${variant.name}-v${variant.versionName}.apk" |
| 38 | } | 38 | } |
| 39 | } | 39 | } |
| 40 | buildTypes { | 40 | buildTypes { |
| 41 | debug { | 41 | debug { |
| 42 | debuggable true | 42 | debuggable true |
| 43 | minifyEnabled false | 43 | minifyEnabled false |
| 44 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 44 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 45 | signingConfig signingConfigs.config | 45 | signingConfig signingConfigs.config |
| 46 | } | 46 | } |
| 47 | release { | 47 | release { |
| 48 | debuggable true | 48 | debuggable true |
| 49 | minifyEnabled false | 49 | minifyEnabled false |
| 50 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 50 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 51 | signingConfig signingConfigs.config | 51 | signingConfig signingConfigs.config |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | lintOptions { | 54 | lintOptions { |
| 55 | checkReleaseBuilds false | 55 | checkReleaseBuilds false |
| 56 | abortOnError false | 56 | abortOnError false |
| 57 | } | 57 | } |
| 58 | buildFeatures { | 58 | buildFeatures { |
| 59 | viewBinding true | 59 | viewBinding true |
| 60 | dataBinding true | 60 | dataBinding 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 | ||
| 82 | // rx | 82 | // rx |
| 83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") | 83 | implementation("com.trello.rxlifecycle2:rxlifecycle:2.2.2") |
| 84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") | 84 | implementation("com.trello.rxlifecycle2:rxlifecycle-android:2.2.2") |
| 85 | 85 | ||
| 86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") | 86 | implementation("com.github.PhilJay:MPAndroidChart:v3.1.0") |
| 87 | implementation("com.contrarywind:Android-PickerView:4.1.9") | 87 | implementation("com.contrarywind:Android-PickerView:4.1.9") |
| 88 | 88 | ||
| 89 | implementation 'com.google.android:flexbox:1.0.0' | 89 | implementation 'com.google.android:flexbox:1.0.0' |
| 90 | 90 | ||
| 91 | // 沉浸式状态栏和他的Kotlin拓展 | 91 | // 沉浸式状态栏和他的Kotlin拓展 |
| 92 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' | 92 | implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' |
| 93 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' | 93 | implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' |
| 94 | 94 | ||
| 95 | // 图片查看 | 95 | // 图片查看 |
| 96 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' | 96 | implementation 'com.github.chrisbanes:PhotoView:2.0.0' |
| 97 | 97 | ||
| 98 | implementation 'com.jakewharton:butterknife:10.2.3' | 98 | implementation 'com.jakewharton:butterknife:10.2.3' |
| 99 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' | 99 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' |
| 100 | |||
| 101 | |||
| 102 | /** 鲁班压缩 */ | ||
| 103 | implementation 'top.zibin:Luban:1.1.8' | ||
| 104 | |||
| 100 | } | 105 | } |
app/src/main/AndroidManifest.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | xmlns:tools="http://schemas.android.com/tools" | 3 | xmlns:tools="http://schemas.android.com/tools" |
| 4 | package="com.hjx.parent" | 4 | package="com.hjx.parent" |
| 5 | tools:ignore="LockedOrientationActivity"> | 5 | tools:ignore="LockedOrientationActivity"> |
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | <uses-feature | 8 | <uses-feature |
| 9 | android:name="android.hardware.camera" | 9 | android:name="android.hardware.camera" |
| 10 | android:required="false" /> | 10 | android:required="false" /> |
| 11 | 11 | ||
| 12 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | 12 | <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> |
| 13 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> | 13 | <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 允许程序改变网络链接状态 --> |
| 14 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> | 14 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 允许程序访问访问WIFI网络状态信息 --> |
| 15 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> | 15 | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 允许程序改变WIFI链接状态 --> |
| 16 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> | 16 | <!-- 6.0系统需要添加权限才能获得wifi列表 --> |
| 17 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | 17 | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> |
| 18 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | 18 | <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
| 19 | <uses-permission android:name="android.permission.INTERNET" /> | 19 | <uses-permission android:name="android.permission.INTERNET" /> |
| 20 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> | 20 | <uses-permission android:name="android.permission.RECORD_AUDIO" /> |
| 21 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | 21 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| 22 | 22 | ||
| 23 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | 23 | <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> |
| 24 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | 24 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 25 | <uses-permission android:name="android.permission.WAKE_LOCK" /> | 25 | <uses-permission android:name="android.permission.WAKE_LOCK" /> |
| 26 | <uses-permission android:name="android.permission.CAMERA" /> | 26 | <uses-permission android:name="android.permission.CAMERA" /> |
| 27 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | 27 | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> |
| 28 | <uses-permission android:name="android.permission.VIBRATE" /> | 28 | <uses-permission android:name="android.permission.VIBRATE" /> |
| 29 | <uses-permission | 29 | <uses-permission |
| 30 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" | 30 | android:name="android.permission.WRITE_EXTERNAL_STORAGE" |
| 31 | tools:ignore="ScopedStorage" /> | 31 | tools:ignore="ScopedStorage" /> |
| 32 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> | 32 | <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> |
| 33 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> | 33 | <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" /> |
| 34 | 34 | ||
| 35 | <uses-permission | 35 | <uses-permission |
| 36 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" | 36 | android:name="android.permission.MANAGE_EXTERNAL_STORAGE" |
| 37 | tools:ignore="ScopedStorage" /> | 37 | tools:ignore="ScopedStorage" /> |
| 38 | 38 | ||
| 39 | <application | 39 | <application |
| 40 | android:name=".App" | 40 | android:name=".App" |
| 41 | android:allowBackup="true" | 41 | android:allowBackup="true" |
| 42 | android:icon="@mipmap/icon" | 42 | android:icon="@mipmap/icon" |
| 43 | android:label="@string/app_name" | 43 | android:label="@string/app_name" |
| 44 | android:networkSecurityConfig="@xml/network_security_config" | 44 | android:networkSecurityConfig="@xml/network_security_config" |
| 45 | android:supportsRtl="true" | 45 | android:supportsRtl="true" |
| 46 | android:theme="@style/AppTheme"> | 46 | android:theme="@style/AppTheme"> |
| 47 | <activity | 47 | <activity |
| 48 | android:name=".LoginActivity" | 48 | android:name=".LoginActivity" |
| 49 | android:exported="true" | 49 | android:exported="true" |
| 50 | android:screenOrientation="portrait" | 50 | android:screenOrientation="portrait" |
| 51 | android:theme="@style/ThemeSplash"> | 51 | android:theme="@style/ThemeSplash"> |
| 52 | </activity> | 52 | </activity> |
| 53 | <activity | 53 | <activity |
| 54 | android:name=".MainActivity" | 54 | android:name=".MainActivity" |
| 55 | android:launchMode="singleTask" | 55 | android:launchMode="singleTask" |
| 56 | android:screenOrientation="portrait" /> | 56 | android:screenOrientation="portrait" /> |
| 57 | <activity | 57 | <activity |
| 58 | android:name=".RegisterActivity" | 58 | android:name=".RegisterActivity" |
| 59 | android:screenOrientation="portrait" | 59 | android:screenOrientation="portrait" |
| 60 | android:theme="@style/ThemeSplash" /> | 60 | android:theme="@style/ThemeSplash" /> |
| 61 | <activity | 61 | <activity |
| 62 | android:name=".UserActivity" | 62 | android:name=".UserActivity" |
| 63 | android:screenOrientation="portrait" /> | 63 | android:screenOrientation="portrait" /> |
| 64 | <activity | 64 | <activity |
| 65 | android:name=".YinsiActivity" | 65 | android:name=".YinsiActivity" |
| 66 | android:screenOrientation="portrait" /> | 66 | android:screenOrientation="portrait" /> |
| 67 | <activity | 67 | <activity |
| 68 | android:name=".QRActivity" | 68 | android:name=".QRActivity" |
| 69 | android:screenOrientation="portrait" /> | 69 | android:screenOrientation="portrait" /> |
| 70 | <activity | 70 | <activity |
| 71 | android:name=".AddStudentActivity" | 71 | android:name=".AddStudentActivity" |
| 72 | android:screenOrientation="portrait" /> | 72 | android:screenOrientation="portrait" /> |
| 73 | <activity | 73 | <activity |
| 74 | android:name=".NickActivity" | 74 | android:name=".NickActivity" |
| 75 | android:screenOrientation="portrait" /> | 75 | android:screenOrientation="portrait" /> |
| 76 | <activity | 76 | <activity |
| 77 | android:name=".SexActivity" | 77 | android:name=".SexActivity" |
| 78 | android:screenOrientation="portrait" /> | 78 | android:screenOrientation="portrait" /> |
| 79 | <activity | 79 | <activity |
| 80 | android:name=".NianActivity" | 80 | android:name=".NianActivity" |
| 81 | android:screenOrientation="portrait" /> | 81 | android:screenOrientation="portrait" /> |
| 82 | <activity | 82 | <activity |
| 83 | android:name=".ShenActivity" | 83 | android:name=".ShenActivity" |
| 84 | android:screenOrientation="portrait" /> | 84 | android:screenOrientation="portrait" /> |
| 85 | <activity | 85 | <activity |
| 86 | android:name=".UserAgreementActivity" | 86 | android:name=".UserAgreementActivity" |
| 87 | android:screenOrientation="portrait" /> | 87 | android:screenOrientation="portrait" /> |
| 88 | <activity | 88 | <activity |
| 89 | android:name=".AccountActivity" | 89 | android:name=".AccountActivity" |
| 90 | android:screenOrientation="portrait" /> | 90 | android:screenOrientation="portrait" /> |
| 91 | 91 | ||
| 92 | <activity | 92 | <activity |
| 93 | android:name=".ChangePwdActivity" | 93 | android:name=".ChangePwdActivity" |
| 94 | android:screenOrientation="portrait" /> | 94 | android:screenOrientation="portrait" /> |
| 95 | <activity | 95 | <activity |
| 96 | android:name=".EditStudentActivity" | 96 | android:name=".EditStudentActivity" |
| 97 | android:screenOrientation="portrait" /> | 97 | android:screenOrientation="portrait" /> |
| 98 | <activity | 98 | <activity |
| 99 | android:name=".ChooseActivity" | 99 | android:name=".ChooseActivity" |
| 100 | android:screenOrientation="portrait" /> | 100 | android:screenOrientation="portrait" /> |
| 101 | <activity | 101 | <activity |
| 102 | android:name=".AddTeacherActivity" | 102 | android:name=".AddTeacherActivity" |
| 103 | android:screenOrientation="portrait" /> | 103 | android:screenOrientation="portrait" /> |
| 104 | <activity | 104 | <activity |
| 105 | android:name=".ErrorBookActivity" | 105 | android:name=".ErrorBookActivity" |
| 106 | android:screenOrientation="portrait" /> | 106 | android:screenOrientation="portrait" /> |
| 107 | <activity | 107 | <activity |
| 108 | android:name=".ImageActivity" | 108 | android:name=".ImageActivity" |
| 109 | android:screenOrientation="portrait" /> | 109 | android:screenOrientation="portrait" /> |
| 110 | <activity | 110 | <activity |
| 111 | android:name=".ImageEditActivity" | 111 | android:name=".ImageEditActivity" |
| 112 | android:screenOrientation="portrait" /> | 112 | android:screenOrientation="portrait" /> |
| 113 | <activity | 113 | <activity |
| 114 | android:name=".ImageSelectActivity" | 114 | android:name=".ImageSelectActivity" |
| 115 | android:screenOrientation="portrait" /> | 115 | android:screenOrientation="portrait" /> |
| 116 | <activity | 116 | <activity |
| 117 | android:name=".AddSuccessActivity" | 117 | android:name=".AddSuccessActivity" |
| 118 | android:screenOrientation="portrait" /> | 118 | android:screenOrientation="portrait" /> |
| 119 | <activity | 119 | <activity |
| 120 | android:name=".ErrorListActivity" | 120 | android:name=".ErrorListActivity" |
| 121 | android:screenOrientation="portrait" /> | 121 | android:screenOrientation="portrait" /> |
| 122 | <activity | 122 | <activity |
| 123 | android:name=".ErrorDetailActivity" | 123 | android:name=".ErrorDetailActivity" |
| 124 | android:screenOrientation="portrait" /> | 124 | android:screenOrientation="portrait" /> |
| 125 | <activity | 125 | <activity |
| 126 | android:name=".TeacherChooseActivity" | 126 | android:name=".TeacherChooseActivity" |
| 127 | android:screenOrientation="portrait" /> | 127 | android:screenOrientation="portrait" /> |
| 128 | <activity | 128 | <activity |
| 129 | android:name=".TeacherMainActivity" | 129 | android:name=".TeacherMainActivity" |
| 130 | android:screenOrientation="portrait" /> | 130 | android:screenOrientation="portrait" /> |
| 131 | <activity android:name=".StuHomeworkActivity" /> | 131 | <activity android:name=".StuHomeworkActivity" /> |
| 132 | <activity android:name=".HomeworkDetailActivity" /> | 132 | <activity android:name=".HomeworkDetailActivity" /> |
| 133 | <activity android:name=".HomeworkSelectActivity" /> | 133 | <activity android:name=".HomeworkSelectActivity" /> |
| 134 | <activity android:name=".HomeworkFeedbackActivity" /> | 134 | <activity android:name=".HomeworkFeedbackActivity" /> |
| 135 | <activity android:name=".HomeworkTopicActivity" /> | 135 | <activity android:name=".HomeworkTopicActivity" /> |
| 136 | <activity android:name=".HomeworkShareActivity" /> | 136 | <activity android:name=".HomeworkShareActivity" /> |
| 137 | <activity android:name=".HuyouDetailActivity" /> | 137 | <activity android:name=".HuyouDetailActivity" /> |
| 138 | <activity android:name=".SmsLoginActivity" | 138 | <activity android:name=".SmsLoginActivity" |
| 139 | android:exported="true" | 139 | android:exported="true" |
| 140 | android:screenOrientation="portrait" | 140 | android:screenOrientation="portrait" |
| 141 | android:theme="@style/ThemeSplash"> | 141 | android:theme="@style/ThemeSplash"> |
| 142 | <intent-filter> | 142 | <intent-filter> |
| 143 | <action android:name="android.intent.action.MAIN" /> | 143 | <action android:name="android.intent.action.MAIN" /> |
| 144 | <category android:name="android.intent.category.LAUNCHER" /> | 144 | <category android:name="android.intent.category.LAUNCHER" /> |
| 145 | </intent-filter> | 145 | </intent-filter> |
| 146 | </activity> | 146 | </activity> |
| 147 | <activity android:name=".JudgeActivity" /> | ||
| 147 | 148 | ||
| 148 | <provider | 149 | <provider |
| 149 | android:name="androidx.core.content.FileProvider" | 150 | android:name="androidx.core.content.FileProvider" |
| 150 | android:authorities="com.hjx.parent.fileprovider" | 151 | android:authorities="com.hjx.parent.fileprovider" |
| 151 | android:exported="false" | 152 | android:exported="false" |
| 152 | android:grantUriPermissions="true" | 153 | android:grantUriPermissions="true" |
| 153 | tools:replace="android:authorities"> | 154 | tools:replace="android:authorities"> |
| 154 | <meta-data | 155 | <meta-data |
| 155 | android:name="android.support.FILE_PROVIDER_PATHS" | 156 | android:name="android.support.FILE_PROVIDER_PATHS" |
| 156 | android:resource="@xml/file_provider_paths" | 157 | android:resource="@xml/file_provider_paths" |
| 157 | tools:replace="android:resource" /> | 158 | tools:replace="android:resource" /> |
| 158 | </provider> | 159 | </provider> |
| 159 | </application> | 160 | </application> |
| 160 | 161 | ||
| 161 | </manifest> | 162 | </manifest> |
app/src/main/java/com/hjx/parent/ImageActivity.java
| 1 | package com.hjx.parent; | 1 | package com.hjx.parent; |
| 2 | 2 | ||
| 3 | import android.annotation.SuppressLint; | 3 | import android.annotation.SuppressLint; |
| 4 | import android.app.Dialog; | 4 | import android.app.Dialog; |
| 5 | import android.content.Intent; | 5 | import android.content.Intent; |
| 6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
| 7 | import android.graphics.BitmapFactory; | 7 | import android.graphics.BitmapFactory; |
| 8 | import android.graphics.Rect; | 8 | import android.graphics.Rect; |
| 9 | import android.net.Uri; | 9 | import android.net.Uri; |
| 10 | import android.os.Bundle; | 10 | import android.os.Bundle; |
| 11 | import android.os.Handler; | 11 | import android.os.Handler; |
| 12 | import android.provider.MediaStore; | 12 | import android.provider.MediaStore; |
| 13 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
| 14 | import android.util.Log; | 14 | import android.util.Log; |
| 15 | import android.view.KeyEvent; | 15 | import android.view.KeyEvent; |
| 16 | import android.view.View; | 16 | import android.view.View; |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | import androidx.annotation.Nullable; | 19 | import androidx.annotation.Nullable; |
| 20 | import androidx.core.content.FileProvider; | 20 | import androidx.core.content.FileProvider; |
| 21 | import androidx.viewpager2.widget.ViewPager2; | 21 | import androidx.viewpager2.widget.ViewPager2; |
| 22 | 22 | ||
| 23 | import com.google.gson.Gson; | 23 | import com.google.gson.Gson; |
| 24 | import com.google.gson.JsonObject; | 24 | import com.google.gson.JsonObject; |
| 25 | import com.hjx.parent.adapter.ImageAdapter; | 25 | import com.hjx.parent.adapter.ImageAdapter; |
| 26 | import com.hjx.parent.databinding.ActivityImageBinding; | 26 | import com.hjx.parent.databinding.ActivityImageBinding; |
| 27 | import com.hjx.parent.databinding.ItemImageBinding; | ||
| 27 | import com.hjx.parent.dialog.AddHomeworkDialog; | 28 | import com.hjx.parent.dialog.AddHomeworkDialog; |
| 28 | import com.hjx.parent.dialog.ErrorInputDialog; | 29 | import com.hjx.parent.dialog.ErrorInputDialog; |
| 29 | import com.hjx.parent.dialog.PhotoViewDialog; | 30 | import com.hjx.parent.dialog.PhotoViewDialog; |
| 30 | import com.hjx.parent.dialog.TipDialog; | 31 | import com.hjx.parent.dialog.TipDialog; |
| 31 | import com.hjx.parent.rx.BaseRxActivity; | 32 | import com.hjx.parent.rx.BaseRxActivity; |
| 33 | import com.hjx.parent.utils.CutUtil; | ||
| 32 | import com.prws.common.bean.CutPicBean; | 34 | import com.prws.common.bean.CutPicBean; |
| 33 | import com.prws.common.bean.ImageBean; | 35 | import com.prws.common.bean.ImageBean; |
| 34 | import com.prws.common.bean.TopicBean; | 36 | import com.prws.common.bean.TopicBean; |
| 35 | import com.prws.common.net.NetWorks; | 37 | import com.prws.common.net.NetWorks; |
| 36 | import com.prws.common.utils.BitmapUtils; | 38 | import com.prws.common.utils.BitmapUtils; |
| 37 | import com.prws.common.utils.CommonUtil; | 39 | import com.prws.common.utils.CommonUtil; |
| 38 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; | 40 | import com.xiasuhuei321.loadingdialog.view.LoadingDialog; |
| 39 | 41 | ||
| 40 | import java.io.File; | 42 | import java.io.File; |
| 41 | import java.util.ArrayList; | 43 | import java.util.ArrayList; |
| 42 | import java.util.List; | 44 | import java.util.List; |
| 43 | 45 | ||
| 44 | import io.reactivex.Observer; | 46 | import io.reactivex.Observer; |
| 45 | import io.reactivex.disposables.Disposable; | 47 | import io.reactivex.disposables.Disposable; |
| 46 | import retrofit2.Call; | 48 | import retrofit2.Call; |
| 47 | import retrofit2.Callback; | 49 | import retrofit2.Callback; |
| 48 | import retrofit2.Response; | 50 | import retrofit2.Response; |
| 49 | 51 | ||
| 50 | public class ImageActivity extends BaseRxActivity<ActivityImageBinding> implements View.OnClickListener { | 52 | public class ImageActivity extends BaseRxActivity<ActivityImageBinding> implements View.OnClickListener { |
| 51 | 53 | ||
| 52 | private List<String> images = new ArrayList<>(); | 54 | private List<String> images = new ArrayList<>(); |
| 53 | private ImageAdapter imageAdapter; | 55 | private ImageAdapter imageAdapter; |
| 54 | private List<ImageBean> list = new ArrayList<>(); | 56 | private List<ImageBean> list = new ArrayList<>(); |
| 55 | private String filePath; | 57 | private String filePath; |
| 56 | 58 | ||
| 57 | private int type = 0; | 59 | private int type = 0; |
| 58 | private AddHomeworkDialog addHomeworkDialog; | 60 | private AddHomeworkDialog addHomeworkDialog; |
| 59 | 61 | ||
| 60 | @Override | 62 | @Override |
| 61 | public void initView(Bundle savedInstanceState) { | 63 | public void initView(Bundle savedInstanceState) { |
| 62 | type = getIntent().getIntExtra("type", 0); | 64 | type = getIntent().getIntExtra("type", 0); |
| 63 | binding.tvSave.setText(type == 0 ? "保存错题" : "录入题目"); | 65 | binding.tvSave.setText(type == 0 ? "保存错题" : "录入题目"); |
| 64 | 66 | ||
| 65 | images = getIntent().getStringArrayListExtra("images"); | 67 | images = getIntent().getStringArrayListExtra("images"); |
| 66 | if (images == null || images.size() <= 1) { | 68 | if (images == null || images.size() <= 1) { |
| 67 | binding.rlPrevious.setVisibility(View.GONE); | 69 | binding.rlPrevious.setVisibility(View.GONE); |
| 68 | binding.rlNext.setVisibility(View.GONE); | 70 | binding.rlNext.setVisibility(View.GONE); |
| 69 | } | 71 | } |
| 70 | for (String s : images) { | 72 | for (String s : images) { |
| 71 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; | 73 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + System.currentTimeMillis() + CommonUtil.getStr() + ".jpg"; |
| 72 | ImageBean imageBean = new ImageBean(); | 74 | ImageBean imageBean = new ImageBean(); |
| 73 | Bitmap bitmap = BitmapUtils.getimage(s); | 75 | Bitmap bitmap = BitmapUtils.getimage(s); |
| 74 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 76 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
| 75 | imageBean.setPath(filepath); | 77 | imageBean.setPath(filepath); |
| 76 | imageBean.source = filepath; | 78 | imageBean.source = filepath; |
| 77 | list.add(imageBean); | 79 | list.add(imageBean); |
| 78 | } | 80 | } |
| 79 | imageAdapter = new ImageAdapter(this, list); | 81 | imageAdapter = new ImageAdapter(this, list); |
| 80 | binding.viewPager.setAdapter(imageAdapter); | 82 | binding.viewPager.setAdapter(imageAdapter); |
| 81 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 83 | binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
| 82 | @Override | 84 | @Override |
| 83 | public void onPageSelected(int position) { | 85 | public void onPageSelected(int position) { |
| 84 | if (list.get(position).getCuts() == null) { | 86 | if (list.get(position).getCuts() == null) { |
| 85 | // binding.ivPrevious.setEnabled(false); | 87 | // binding.ivPrevious.setEnabled(false); |
| 86 | // binding.ivNext.setEnabled(false); | 88 | // binding.ivNext.setEnabled(false); |
| 87 | clearText(); | 89 | clearText(); |
| 88 | } | 90 | } |
| 89 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 91 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
| 90 | if (position == 0) { | 92 | if (position == 0) { |
| 91 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); | 93 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous_gray); |
| 92 | // binding.ivPrevious.setEnabled(true); | 94 | // binding.ivPrevious.setEnabled(true); |
| 93 | } else { | 95 | } else { |
| 94 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); | 96 | binding.ivPrevious.setImageResource(R.mipmap.ic_previous); |
| 95 | // binding.ivPrevious.setEnabled(false); | 97 | // binding.ivPrevious.setEnabled(false); |
| 96 | } | 98 | } |
| 97 | if (position == list.size() - 1) { | 99 | if (position == list.size() - 1) { |
| 98 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); | 100 | binding.ivNext.setImageResource(R.mipmap.ic_next_gray); |
| 99 | // binding.ivNext.setEnabled(true); | 101 | // binding.ivNext.setEnabled(true); |
| 100 | } else { | 102 | } else { |
| 101 | binding.ivNext.setImageResource(R.mipmap.ic_next); | 103 | binding.ivNext.setImageResource(R.mipmap.ic_next); |
| 102 | // binding.ivNext.setEnabled(false); | 104 | // binding.ivNext.setEnabled(false); |
| 103 | } | 105 | } |
| 104 | super.onPageSelected(position); | 106 | super.onPageSelected(position); |
| 105 | } | 107 | } |
| 106 | }); | 108 | }); |
| 107 | binding.rlNext.setOnClickListener(this); | 109 | binding.rlNext.setOnClickListener(this); |
| 108 | binding.rlPrevious.setOnClickListener(this); | 110 | binding.rlPrevious.setOnClickListener(this); |
| 109 | binding.ivBack.setOnClickListener(this); | 111 | binding.ivBack.setOnClickListener(this); |
| 110 | binding.tvPhoto.setOnClickListener(this); | 112 | binding.tvPhoto.setOnClickListener(this); |
| 111 | binding.tvAdd.setOnClickListener(this); | 113 | binding.tvAdd.setOnClickListener(this); |
| 112 | binding.llEdit.setOnClickListener(this); | 114 | binding.llEdit.setOnClickListener(this); |
| 113 | binding.tvSave.setOnClickListener(this); | 115 | binding.tvSave.setOnClickListener(this); |
| 114 | binding.btnShowSource.setOnClickListener(v -> { | 116 | binding.btnShowSource.setOnClickListener(v -> { |
| 115 | if (list.isEmpty()) return; | 117 | if (list.isEmpty()) return; |
| 116 | ImageBean data = list.get(binding.viewPager.getCurrentItem()); | 118 | ImageBean data = list.get(binding.viewPager.getCurrentItem()); |
| 117 | new PhotoViewDialog(this).show(data.source); | 119 | new PhotoViewDialog(this).show(data.source); |
| 118 | }); | 120 | }); |
| 121 | |||
| 122 | binding.btnJudge.setVisibility(type == 0 ? View.VISIBLE : View.GONE); | ||
| 123 | binding.btnJudge.setOnClickListener(v -> { | ||
| 124 | goJudge(); | ||
| 125 | }); | ||
| 126 | } | ||
| 127 | |||
| 128 | private void goJudge() { | ||
| 129 | if (list.isEmpty()) return; | ||
| 130 | int position = binding.viewPager.getCurrentItem(); | ||
| 131 | ImageBean imageBean = list.get(position); | ||
| 132 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); | ||
| 133 | if (bitmap == null || imageBean.getCuts() == null) { | ||
| 134 | showToast("请先框选题目"); | ||
| 135 | return; | ||
| 136 | } | ||
| 137 | ItemImageBinding ib = imageAdapter.viewArray.get(position); | ||
| 138 | if (ib == null) { | ||
| 139 | showToast("出错"); | ||
| 140 | return; | ||
| 141 | } | ||
| 142 | View view = ib.ivPic; | ||
| 143 | float[] size = CutUtil.measureBitmap(view, bitmap); | ||
| 144 | |||
| 145 | ArrayList<Rect> rects = new ArrayList<>(); | ||
| 146 | for (ImageBean.Cut cut: imageBean.getCuts()) { | ||
| 147 | if (cut.getRect1() == null) continue; | ||
| 148 | Rect rectV = cut.getRect1(); | ||
| 149 | rects.add(getRectB(rectV, bitmap, size)); | ||
| 150 | } | ||
| 151 | if (list.isEmpty()) { | ||
| 152 | showToast("请先框选题目"); | ||
| 153 | return; | ||
| 154 | } | ||
| 155 | |||
| 156 | Intent intent = new Intent(this, JudgeActivity.class); | ||
| 157 | intent.putExtra("path", imageBean.getPath()); | ||
| 158 | intent.putParcelableArrayListExtra("rects", rects); | ||
| 159 | |||
| 160 | startActivity(intent); | ||
| 161 | } | ||
| 162 | |||
| 163 | private Rect getRectB(Rect rectV, Bitmap bitmap, float[] measuredSize) { | ||
| 164 | float realW = measuredSize[0]; | ||
| 165 | float realH = measuredSize[1]; | ||
| 166 | float offsetX = measuredSize[2]; | ||
| 167 | float offsetY = measuredSize[3]; | ||
| 168 | float percentX = bitmap.getWidth() / realW; | ||
| 169 | float percentY = bitmap.getHeight() / realH; | ||
| 170 | |||
| 171 | float left = (rectV.left - offsetX) * percentX; | ||
| 172 | float right = (rectV.right - offsetX) * percentX; | ||
| 173 | float top = (rectV.top - offsetY) * percentY; | ||
| 174 | float bottom = (rectV.bottom - offsetY) * percentY; | ||
| 175 | Rect rectB = new Rect((int) left, (int) top, (int) right, (int) bottom); | ||
| 176 | return rectB; | ||
| 119 | } | 177 | } |
| 120 | 178 | ||
| 121 | public void clearText() { | 179 | public void clearText() { |
| 122 | int index = binding.viewPager.getCurrentItem(); | 180 | int index = binding.viewPager.getCurrentItem(); |
| 123 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { | 181 | showLoadingDialog(getString(R.string.loading_text), new LoadingDialog.DismissListener() { |
| 124 | @Override | 182 | @Override |
| 125 | public void dimiss() { | 183 | public void dimiss() { |
| 126 | // binding.ivPrevious.setEnabled(index != 0); | 184 | // binding.ivPrevious.setEnabled(index != 0); |
| 127 | // binding.ivNext.setEnabled(index != list.size() - 1); | 185 | // binding.ivNext.setEnabled(index != list.size() - 1); |
| 128 | } | 186 | } |
| 129 | }); | 187 | }); |
| 130 | Log.i("clearText", list.get(index).getPath()); | 188 | Log.i("clearText", list.get(index).getPath()); |
| 131 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); | 189 | String base64 = BitmapUtils.imageToBase64(list.get(index).getPath()); |
| 132 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { | 190 | NetWorks.removeWriting(base64, new Observer<JsonObject>() { |
| 133 | @Override | 191 | @Override |
| 134 | public void onSubscribe(Disposable d) { | 192 | public void onSubscribe(Disposable d) { |
| 135 | 193 | ||
| 136 | } | 194 | } |
| 137 | 195 | ||
| 138 | @Override | 196 | @Override |
| 139 | public void onNext(JsonObject jsonObject) { | 197 | public void onNext(JsonObject jsonObject) { |
| 140 | if (jsonObject != null && jsonObject.get("image_processed") != null) { | 198 | if (jsonObject != null && jsonObject.get("image_processed") != null) { |
| 141 | String image = jsonObject.get("image_processed").getAsString(); | 199 | String image = jsonObject.get("image_processed").getAsString(); |
| 142 | if (image != null) { | 200 | if (image != null) { |
| 143 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 201 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
| 144 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); | 202 | CommonUtil.saveBitmapToUri(BitmapUtils.stringToBitmap(image), filepath); |
| 145 | list.get(index).setPath(filepath); | 203 | list.get(index).setPath(filepath); |
| 146 | if (list.get(index).getCuts() == null) { | 204 | if (list.get(index).getCuts() == null) { |
| 147 | list.get(index).setCuts(new ArrayList<>()); | 205 | list.get(index).setCuts(new ArrayList<>()); |
| 148 | } | 206 | } |
| 149 | imageAdapter.notifyItemChanged(index); | 207 | imageAdapter.notifyItemChanged(index); |
| 150 | cut(filepath); | 208 | cut(filepath); |
| 151 | } else { | 209 | } else { |
| 152 | loadFail("去除字迹失败"); | 210 | loadFail("去除字迹失败"); |
| 153 | } | 211 | } |
| 154 | } else { | 212 | } else { |
| 155 | loadFail("去除字迹失败"); | 213 | loadFail("去除字迹失败"); |
| 156 | } | 214 | } |
| 157 | } | 215 | } |
| 158 | 216 | ||
| 159 | @Override | 217 | @Override |
| 160 | public void onError(Throwable e) { | 218 | public void onError(Throwable e) { |
| 161 | e.printStackTrace(); | 219 | e.printStackTrace(); |
| 162 | loadFail("去除字迹失败"); | 220 | loadFail("去除字迹失败"); |
| 163 | } | 221 | } |
| 164 | 222 | ||
| 165 | @Override | 223 | @Override |
| 166 | public void onComplete() { | 224 | public void onComplete() { |
| 167 | 225 | ||
| 168 | } | 226 | } |
| 169 | }); | 227 | }); |
| 170 | } | 228 | } |
| 171 | 229 | ||
| 172 | public void cut(String path) { | 230 | public void cut(String path) { |
| 173 | String base64 = BitmapUtils.imageToBase64(path); | 231 | String base64 = BitmapUtils.imageToBase64(path); |
| 174 | Log.i("figLoaction", path); | 232 | Log.i("figLoaction", path); |
| 175 | NetWorks.cut(base64, new Observer<CutPicBean>() { | 233 | NetWorks.cut(base64, new Observer<CutPicBean>() { |
| 176 | @Override | 234 | @Override |
| 177 | public void onSubscribe(Disposable d) { | 235 | public void onSubscribe(Disposable d) { |
| 178 | 236 | ||
| 179 | } | 237 | } |
| 180 | 238 | ||
| 181 | @Override | 239 | @Override |
| 182 | public void onNext(CutPicBean cutPicBean) { | 240 | public void onNext(CutPicBean cutPicBean) { |
| 183 | if (cutPicBean != null) { | 241 | if (cutPicBean != null) { |
| 184 | if (cutPicBean.getDirection() != 0) { | 242 | if (cutPicBean.getDirection() != 0) { |
| 185 | rotatingImage(cutPicBean); | 243 | rotatingImage(cutPicBean); |
| 186 | } else { | 244 | } else { |
| 187 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 245 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
| 188 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 246 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
| 189 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 247 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
| 190 | figLoactions.add(cutLocation.getFig_location()); | 248 | figLoactions.add(cutLocation.getFig_location()); |
| 191 | } | 249 | } |
| 192 | new Handler().postDelayed(new Runnable() { | 250 | new Handler().postDelayed(new Runnable() { |
| 193 | @Override | 251 | @Override |
| 194 | public void run() { | 252 | public void run() { |
| 195 | getRects(figLoactions); | 253 | getRects(figLoactions); |
| 196 | } | 254 | } |
| 197 | }, 1000); | 255 | }, 1000); |
| 198 | } else { | 256 | } else { |
| 199 | cancelLoadingDialog(); | 257 | cancelLoadingDialog(); |
| 200 | } | 258 | } |
| 201 | } | 259 | } |
| 202 | } else { | 260 | } else { |
| 203 | loadFail("自动切题失败"); | 261 | loadFail("自动切题失败"); |
| 204 | } | 262 | } |
| 205 | } | 263 | } |
| 206 | 264 | ||
| 207 | @Override | 265 | @Override |
| 208 | public void onError(Throwable e) { | 266 | public void onError(Throwable e) { |
| 209 | loadFail("自动切题失败"); | 267 | loadFail("自动切题失败"); |
| 210 | } | 268 | } |
| 211 | 269 | ||
| 212 | @Override | 270 | @Override |
| 213 | public void onComplete() { | 271 | public void onComplete() { |
| 214 | 272 | ||
| 215 | } | 273 | } |
| 216 | }); | 274 | }); |
| 217 | } | 275 | } |
| 218 | 276 | ||
| 219 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { | 277 | private void getRects(List<CutPicBean.FigLoaction> figLoactions) { |
| 220 | Log.i("figLoaction", new Gson().toJson(figLoactions)); | 278 | Log.i("figLoaction", new Gson().toJson(figLoactions)); |
| 221 | int index = binding.viewPager.getCurrentItem(); | 279 | int index = binding.viewPager.getCurrentItem(); |
| 222 | List<ImageBean.Cut> cuts = new ArrayList<>(); | 280 | List<ImageBean.Cut> cuts = new ArrayList<>(); |
| 223 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { | 281 | for (CutPicBean.FigLoaction figLoaction : figLoactions) { |
| 224 | ImageBean.Cut cut = new ImageBean.Cut(); | 282 | ImageBean.Cut cut = new ImageBean.Cut(); |
| 225 | cut.setRect(figLoaction); | 283 | cut.setRect(figLoaction); |
| 226 | cut.setSelect(false); | 284 | cut.setSelect(false); |
| 227 | cuts.add(cut); | 285 | cuts.add(cut); |
| 228 | } | 286 | } |
| 229 | list.get(index).setCuts(cuts); | 287 | list.get(index).setCuts(cuts); |
| 230 | imageAdapter.notifyItemChanged(index); | 288 | imageAdapter.notifyItemChanged(index); |
| 231 | cancelLoadingDialog(); | 289 | cancelLoadingDialog(); |
| 232 | } | 290 | } |
| 233 | 291 | ||
| 234 | private void rotatingImage(CutPicBean cutPicBean) { | 292 | private void rotatingImage(CutPicBean cutPicBean) { |
| 235 | int index = binding.viewPager.getCurrentItem(); | 293 | int index = binding.viewPager.getCurrentItem(); |
| 236 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); | 294 | Bitmap bitmap = BitmapFactory.decodeFile(list.get(index).getPath()); |
| 237 | int angle = 0; | 295 | int angle = 0; |
| 238 | switch (cutPicBean.getDirection()) { | 296 | switch (cutPicBean.getDirection()) { |
| 239 | case 1: | 297 | case 1: |
| 240 | angle = 90; | 298 | angle = 90; |
| 241 | break; | 299 | break; |
| 242 | case 2: | 300 | case 2: |
| 243 | angle = 180; | 301 | angle = 180; |
| 244 | break; | 302 | break; |
| 245 | case 3: | 303 | case 3: |
| 246 | angle = 270; | 304 | angle = 270; |
| 247 | break; | 305 | break; |
| 248 | } | 306 | } |
| 249 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { | 307 | if (cutPicBean.getQus_figure() != null && cutPicBean.getQus_figure().size() > 0) { |
| 250 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); | 308 | List<CutPicBean.FigLoaction> figLoactions = new ArrayList<>(); |
| 251 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { | 309 | for (CutPicBean.CutLocation cutLocation : cutPicBean.getQus_figure()) { |
| 252 | figLoactions.add(cutLocation.getFig_location()); | 310 | figLoactions.add(cutLocation.getFig_location()); |
| 253 | } | 311 | } |
| 254 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); | 312 | figLoactions = CommonUtil.rotaingLocation(angle, figLoactions, bitmap.getWidth(), bitmap.getHeight()); |
| 255 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); | 313 | bitmap = CommonUtil.rotaingImageView(angle, bitmap); |
| 256 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 314 | String filepath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
| 257 | CommonUtil.saveBitmapToUri(bitmap, filepath); | 315 | CommonUtil.saveBitmapToUri(bitmap, filepath); |
| 258 | list.get(index).setPath(filepath); | 316 | list.get(index).setPath(filepath); |
| 259 | imageAdapter.notifyItemChanged(index); | 317 | imageAdapter.notifyItemChanged(index); |
| 260 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; | 318 | List<CutPicBean.FigLoaction> finalFigLoactions = figLoactions; |
| 261 | new Handler().postDelayed(new Runnable() { | 319 | new Handler().postDelayed(new Runnable() { |
| 262 | @Override | 320 | @Override |
| 263 | public void run() { | 321 | public void run() { |
| 264 | getRects(finalFigLoactions); | 322 | getRects(finalFigLoactions); |
| 265 | } | 323 | } |
| 266 | }, 500); | 324 | }, 500); |
| 267 | } else { | 325 | } else { |
| 268 | cancelLoadingDialog(); | 326 | cancelLoadingDialog(); |
| 269 | } | 327 | } |
| 270 | } | 328 | } |
| 271 | 329 | ||
| 272 | @Override | 330 | @Override |
| 273 | protected ActivityImageBinding getViewBinding() { | 331 | protected ActivityImageBinding getViewBinding() { |
| 274 | return ActivityImageBinding.inflate(getLayoutInflater()); | 332 | return ActivityImageBinding.inflate(getLayoutInflater()); |
| 275 | } | 333 | } |
| 276 | 334 | ||
| 277 | @SuppressLint("SetTextI18n") | 335 | @SuppressLint("SetTextI18n") |
| 278 | public void refreshNum() { | 336 | public void refreshNum() { |
| 279 | int num = 0; | 337 | int num = 0; |
| 280 | for (ImageBean imageBean : list) { | 338 | for (ImageBean imageBean : list) { |
| 281 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 339 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
| 282 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 340 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
| 283 | if (cut.isSelect()) { | 341 | if (cut.isSelect()) { |
| 284 | num++; | 342 | num++; |
| 285 | } | 343 | } |
| 286 | } | 344 | } |
| 287 | } | 345 | } |
| 288 | } | 346 | } |
| 289 | String btnText = type == 0 ? "保存错题" : "录入题目"; | 347 | String btnText = type == 0 ? "保存错题" : "录入题目"; |
| 290 | if (num > 0) { | 348 | if (num > 0) { |
| 291 | binding.tvSave.setEnabled(true); | 349 | binding.tvSave.setEnabled(true); |
| 292 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); | 350 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_5); |
| 293 | binding.tvSave.setText(btnText + "(" + num + ")"); | 351 | binding.tvSave.setText(btnText + "(" + num + ")"); |
| 294 | } else { | 352 | } else { |
| 295 | binding.tvSave.setEnabled(false); | 353 | binding.tvSave.setEnabled(false); |
| 296 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); | 354 | binding.tvSave.setBackgroundResource(R.drawable.bg_soild_blue_light_5); |
| 297 | binding.tvSave.setText(btnText); | 355 | binding.tvSave.setText(btnText); |
| 298 | } | 356 | } |
| 299 | } | 357 | } |
| 300 | 358 | ||
| 301 | @Override | 359 | @Override |
| 302 | public void onClick(View v) { | 360 | public void onClick(View v) { |
| 303 | switch (v.getId()) { | 361 | switch (v.getId()) { |
| 304 | case R.id.iv_back: | 362 | case R.id.iv_back: |
| 305 | back(); | 363 | back(); |
| 306 | break; | 364 | break; |
| 307 | case R.id.rl_next: | 365 | case R.id.rl_next: |
| 308 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { | 366 | if (binding.viewPager.getCurrentItem() + 1 < list.size()) { |
| 309 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); | 367 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() + 1); |
| 310 | } | 368 | } |
| 311 | break; | 369 | break; |
| 312 | case R.id.rl_previous: | 370 | case R.id.rl_previous: |
| 313 | if (binding.viewPager.getCurrentItem() != 0) { | 371 | if (binding.viewPager.getCurrentItem() != 0) { |
| 314 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); | 372 | binding.viewPager.setCurrentItem(binding.viewPager.getCurrentItem() - 1); |
| 315 | } | 373 | } |
| 316 | break; | 374 | break; |
| 317 | case R.id.ll_edit: | 375 | case R.id.ll_edit: |
| 318 | Intent intent = new Intent(context, ImageEditActivity.class); | 376 | Intent intent = new Intent(context, ImageEditActivity.class); |
| 319 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 377 | intent.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
| 320 | startActivityForResult(intent, 1001); | 378 | startActivityForResult(intent, 1001); |
| 321 | break; | 379 | break; |
| 322 | case R.id.tv_photo: | 380 | case R.id.tv_photo: |
| 323 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | 381 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
| 324 | //确保有相机来处理Intent | 382 | //确保有相机来处理Intent |
| 325 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 383 | filePath = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
| 326 | File photoFile = new File(filePath); | 384 | File photoFile = new File(filePath); |
| 327 | if (photoFile != null) { | 385 | if (photoFile != null) { |
| 328 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri | 386 | //适配Android 7.0文件权限,通过FileProvider创建一个content类型的Uri |
| 329 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); | 387 | Uri photoUri = FileProvider.getUriForFile(activity, "com.hjx.parent.fileprovider", photoFile); |
| 330 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); | 388 | takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); |
| 331 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); | 389 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
| 332 | activity.startActivityForResult(takePictureIntent, 1002); | 390 | activity.startActivityForResult(takePictureIntent, 1002); |
| 333 | } | 391 | } |
| 334 | break; | 392 | break; |
| 335 | case R.id.tv_add: | 393 | case R.id.tv_add: |
| 336 | Intent intent1 = new Intent(context, ImageSelectActivity.class); | 394 | Intent intent1 = new Intent(context, ImageSelectActivity.class); |
| 337 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); | 395 | intent1.putExtra("path", list.get(binding.viewPager.getCurrentItem()).getPath()); |
| 338 | intent1.putExtra("source", list.get(binding.viewPager.getCurrentItem()).source); | 396 | intent1.putExtra("source", list.get(binding.viewPager.getCurrentItem()).source); |
| 339 | startActivityForResult(intent1, 1001); | 397 | startActivityForResult(intent1, 1001); |
| 340 | break; | 398 | break; |
| 341 | case R.id.tv_save: | 399 | case R.id.tv_save: |
| 342 | List<TopicBean> topicBeans = new ArrayList<>(); | 400 | List<TopicBean> topicBeans = new ArrayList<>(); |
| 343 | for (ImageBean imageBean : list) { | 401 | for (ImageBean imageBean : list) { |
| 344 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 402 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
| 345 | for (ImageBean.Cut cut : imageBean.getCuts()) { | 403 | for (ImageBean.Cut cut : imageBean.getCuts()) { |
| 346 | if (cut.isSelect()) { | 404 | if (cut.isSelect()) { |
| 347 | TopicBean bean = new TopicBean(); | 405 | TopicBean bean = new TopicBean(); |
| 348 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 406 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
| 349 | BitmapUtils.saveBitmap(cut.getBitmap(), path); | 407 | BitmapUtils.saveBitmap(cut.getBitmap(), path); |
| 350 | bean.setPath(path); | 408 | bean.setPath(path); |
| 351 | topicBeans.add(bean); | 409 | topicBeans.add(bean); |
| 352 | } | 410 | } |
| 353 | } | 411 | } |
| 354 | } | 412 | } |
| 355 | } | 413 | } |
| 356 | save(topicBeans); | 414 | save(topicBeans); |
| 357 | break; | 415 | break; |
| 358 | } | 416 | } |
| 359 | } | 417 | } |
| 360 | 418 | ||
| 361 | private void save(List<TopicBean> topicBeans) { | 419 | private void save(List<TopicBean> topicBeans) { |
| 362 | if (type == 0) { | 420 | if (type == 0) { |
| 363 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); | 421 | ErrorInputDialog dialog = new ErrorInputDialog(this, topicBeans); |
| 364 | dialog.show(); | 422 | dialog.show(); |
| 365 | } else { | 423 | } else { |
| 366 | List<String> paths = new ArrayList<>(); | 424 | List<String> paths = new ArrayList<>(); |
| 367 | for (TopicBean it: topicBeans) { | 425 | for (TopicBean it: topicBeans) { |
| 368 | paths.add(it.getPath()); | 426 | paths.add(it.getPath()); |
| 369 | } | 427 | } |
| 370 | if (addHomeworkDialog == null) { | 428 | if (addHomeworkDialog == null) { |
| 371 | addHomeworkDialog = new AddHomeworkDialog(this); | 429 | addHomeworkDialog = new AddHomeworkDialog(this); |
| 372 | } | 430 | } |
| 373 | addHomeworkDialog.show(paths, student -> { | 431 | addHomeworkDialog.show(paths, student -> { |
| 374 | Intent intent = new Intent(context, AddSuccessActivity.class); | 432 | Intent intent = new Intent(context, AddSuccessActivity.class); |
| 375 | intent.putExtra("type", type); | 433 | intent.putExtra("type", type); |
| 376 | intent.putExtra("studentJson", new Gson().toJson(student)); | 434 | intent.putExtra("studentJson", new Gson().toJson(student)); |
| 377 | startActivity(intent); | 435 | startActivity(intent); |
| 378 | finish(); | 436 | finish(); |
| 379 | }); | 437 | }); |
| 380 | } | 438 | } |
| 381 | } | 439 | } |
| 382 | 440 | ||
| 383 | @Override | 441 | @Override |
| 384 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | 442 | protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
| 385 | super.onActivityResult(requestCode, resultCode, data); | 443 | super.onActivityResult(requestCode, resultCode, data); |
| 386 | if (requestCode == 1001) { | 444 | if (requestCode == 1001) { |
| 387 | if (resultCode == 1002) { | 445 | if (resultCode == 1002) { |
| 388 | if (list.size() > 1) { | 446 | if (list.size() > 1) { |
| 389 | list.remove(binding.viewPager.getCurrentItem()); | 447 | list.remove(binding.viewPager.getCurrentItem()); |
| 390 | if (list.size() <= 1) { | 448 | if (list.size() <= 1) { |
| 391 | binding.rlPrevious.setVisibility(View.GONE); | 449 | binding.rlPrevious.setVisibility(View.GONE); |
| 392 | binding.rlNext.setVisibility(View.GONE); | 450 | binding.rlNext.setVisibility(View.GONE); |
| 393 | } | 451 | } |
| 394 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); | 452 | imageAdapter.notifyItemRemoved(binding.viewPager.getCurrentItem()); |
| 395 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); | 453 | binding.tvTitle.setText((binding.viewPager.getCurrentItem() + 1) + "/" + list.size()); |
| 396 | refreshNum(); | 454 | refreshNum(); |
| 397 | } else { | 455 | } else { |
| 398 | finish(); | 456 | finish(); |
| 399 | } | 457 | } |
| 400 | } else if (resultCode == 1003) { | 458 | } else if (resultCode == 1003) { |
| 401 | int position = binding.viewPager.getCurrentItem(); | 459 | int position = binding.viewPager.getCurrentItem(); |
| 402 | String src = list.get(position).source; | 460 | String src = list.get(position).source; |
| 403 | list.remove(position); | 461 | list.remove(position); |
| 404 | String path = data.getStringExtra("path"); | 462 | String path = data.getStringExtra("path"); |
| 405 | ImageBean imageBean = new ImageBean(); | 463 | ImageBean imageBean = new ImageBean(); |
| 406 | imageBean.setPath(path); | 464 | imageBean.setPath(path); |
| 407 | imageBean.source = src; | 465 | imageBean.source = src; |
| 408 | list.add(position, imageBean); | 466 | list.add(position, imageBean); |
| 409 | imageAdapter.notifyItemChanged(position); | 467 | imageAdapter.notifyItemChanged(position); |
| 410 | clearText(); | 468 | clearText(); |
| 411 | refreshNum(); | 469 | refreshNum(); |
| 412 | } else if (resultCode == 1004) { | 470 | } else if (resultCode == 1004) { |
| 413 | Rect rect = data.getParcelableExtra("cut"); | 471 | Rect rect = data.getParcelableExtra("cut"); |
| 414 | if (rect != null) { | 472 | if (rect != null) { |
| 415 | int position = binding.viewPager.getCurrentItem(); | 473 | int position = binding.viewPager.getCurrentItem(); |
| 416 | ImageBean.Cut cut = new ImageBean.Cut(); | 474 | ImageBean.Cut cut = new ImageBean.Cut(); |
| 417 | cut.setRect1(rect); | 475 | cut.setRect1(rect); |
| 418 | cut.setSelect(false); | 476 | cut.setSelect(false); |
| 419 | if (list.get(position).getCuts() != null) { | 477 | if (list.get(position).getCuts() != null) { |
| 420 | list.get(position).getCuts().add(cut); | 478 | list.get(position).getCuts().add(cut); |
| 421 | } else { | 479 | } else { |
| 422 | List<ImageBean.Cut> cuts =new ArrayList<>(); | 480 | List<ImageBean.Cut> cuts =new ArrayList<>(); |
| 423 | cuts.add(cut); | 481 | cuts.add(cut); |
| 424 | list.get(position).setCuts(cuts); | 482 | list.get(position).setCuts(cuts); |
| 425 | } | 483 | } |
| 426 | imageAdapter.notifyItemChanged(position); | 484 | imageAdapter.notifyItemChanged(position); |
| 427 | refreshNum(); | 485 | refreshNum(); |
| 428 | } | 486 | } |
| 429 | } else if (resultCode == 1005) { | 487 | } else if (resultCode == 1005) { |
| 430 | int i = data.getIntExtra("position", 0); | 488 | int i = data.getIntExtra("position", 0); |
| 431 | int position = binding.viewPager.getCurrentItem(); | 489 | int position = binding.viewPager.getCurrentItem(); |
| 432 | Rect rect = data.getParcelableExtra("cut"); | 490 | Rect rect = data.getParcelableExtra("cut"); |
| 433 | if (rect != null) { | 491 | if (rect != null) { |
| 434 | ImageBean.Cut cut = new ImageBean.Cut(); | 492 | ImageBean.Cut cut = new ImageBean.Cut(); |
| 435 | cut.setRect1(rect); | 493 | cut.setRect1(rect); |
| 436 | cut.setSelect(false); | 494 | cut.setSelect(false); |
| 437 | list.get(position).getCuts().remove(i); | 495 | list.get(position).getCuts().remove(i); |
| 438 | list.get(position).getCuts().add(i, cut); | 496 | list.get(position).getCuts().add(i, cut); |
| 439 | imageAdapter.notifyItemChanged(position); | 497 | imageAdapter.notifyItemChanged(position); |
| 440 | refreshNum(); | 498 | refreshNum(); |
| 441 | } else { | 499 | } else { |
| 442 | list.get(position).getCuts().remove(i); | 500 | list.get(position).getCuts().remove(i); |
| 443 | imageAdapter.notifyItemChanged(position); | 501 | imageAdapter.notifyItemChanged(position); |
| 444 | refreshNum(); | 502 | refreshNum(); |
| 445 | } | 503 | } |
| 446 | } | 504 | } |
| 447 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { | 505 | } else if (requestCode == 1002 && resultCode == RESULT_OK && !TextUtils.isEmpty(filePath)) { |
| 448 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); | 506 | Bitmap b = BitmapUtils.compress(BitmapFactory.decodeFile(filePath)); |
| 449 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; | 507 | String path = context.getExternalFilesDir("images").getPath() + "/" + String.valueOf(System.currentTimeMillis()) + CommonUtil.getStr() + ".jpg"; |
| 450 | CommonUtil.saveBitmapToUri(b, path); | 508 | CommonUtil.saveBitmapToUri(b, path); |
| 451 | int position = binding.viewPager.getCurrentItem(); | 509 | int position = binding.viewPager.getCurrentItem(); |
| 452 | list.remove(position); | 510 | list.remove(position); |
| 453 | ImageBean imageBean = new ImageBean(); | 511 | ImageBean imageBean = new ImageBean(); |
| 454 | imageBean.setPath(path); | 512 | imageBean.setPath(path); |
| 455 | imageBean.source = path; | 513 | imageBean.source = path; |
| 456 | list.add(position, imageBean); | 514 | list.add(position, imageBean); |
| 457 | imageAdapter.notifyItemChanged(position); | 515 | imageAdapter.notifyItemChanged(position); |
| 458 | clearText(); | 516 | clearText(); |
| 459 | refreshNum(); | 517 | refreshNum(); |
| 460 | } | 518 | } |
| 461 | } | 519 | } |
| 462 | 520 | ||
| 463 | private void back() { | 521 | private void back() { |
| 464 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { | 522 | showTipDialog("温馨提示", "是否确认退出?", "取消", "确定", new TipDialog.TipDialogInterface() { |
| 465 | @Override | 523 | @Override |
| 466 | public void onConfirm(Dialog dialog) { | 524 | public void onConfirm(Dialog dialog) { |
| 467 | dialog.dismiss(); | 525 | dialog.dismiss(); |
| 468 | finish(); | 526 | finish(); |
| 469 | } | 527 | } |
| 470 | 528 | ||
| 471 | @Override | 529 | @Override |
| 472 | public void onCancel(Dialog dialog) { | 530 | public void onCancel(Dialog dialog) { |
| 473 | dialog.dismiss(); | 531 | dialog.dismiss(); |
| 474 | } | 532 | } |
| 475 | }); | 533 | }); |
| 476 | } | 534 | } |
| 477 | 535 | ||
| 478 | @Override | 536 | @Override |
| 479 | public boolean onKeyDown(int keyCode, KeyEvent event) { | 537 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
| 480 | if (keyCode == KeyEvent.KEYCODE_BACK) { | 538 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
| 481 | back(); | 539 | back(); |
| 482 | return true; | 540 | return true; |
| 483 | } | 541 | } |
| 484 | return super.onKeyDown(keyCode, event); | 542 | return super.onKeyDown(keyCode, event); |
| 485 | } | 543 | } |
| 486 | } | 544 | } |
| 487 | 545 |
app/src/main/java/com/hjx/parent/JudgeActivity.java
| File was created | 1 | package com.hjx.parent; | |
| 2 | |||
| 3 | import android.annotation.SuppressLint; | ||
| 4 | import android.graphics.Bitmap; | ||
| 5 | import android.graphics.Rect; | ||
| 6 | import android.os.Bundle; | ||
| 7 | |||
| 8 | import com.bumptech.glide.Glide; | ||
| 9 | import com.hjx.parent.databinding.ActivityJudgeBinding; | ||
| 10 | import com.hjx.parent.databinding.LayoutJudgeRectBinding; | ||
| 11 | import com.hjx.parent.rx.BaseRxActivity; | ||
| 12 | import com.hjx.parent.utils.CutUtil; | ||
| 13 | |||
| 14 | import java.io.File; | ||
| 15 | import java.util.ArrayList; | ||
| 16 | import java.util.List; | ||
| 17 | |||
| 18 | import io.reactivex.Single; | ||
| 19 | import top.zibin.luban.Luban; | ||
| 20 | |||
| 21 | public class JudgeActivity extends BaseRxActivity<ActivityJudgeBinding> { | ||
| 22 | |||
| 23 | private Bitmap bitmap; | ||
| 24 | |||
| 25 | private final List<JudgeCut> mList = new ArrayList<>(); | ||
| 26 | |||
| 27 | @SuppressLint("CheckResult") | ||
| 28 | @Override | ||
| 29 | public void initView(Bundle savedInstanceState) { | ||
| 30 | binding.ivBack.setOnClickListener(v -> { | ||
| 31 | onBackPressed(); | ||
| 32 | }); | ||
| 33 | String path = getIntent().getStringExtra("path"); | ||
| 34 | if (path == null) return; | ||
| 35 | final ArrayList<Rect> rects = getIntent().getParcelableArrayListExtra("rects"); | ||
| 36 | if (rects == null) return; | ||
| 37 | |||
| 38 | Single.just(path) | ||
| 39 | .map(origin -> Luban.with(this).load(origin).ignoreBy(300).get().get(0)) | ||
| 40 | .map(file -> Glide.with(this).asBitmap().load(file).submit().get()) | ||
| 41 | .compose(transformSingle()) | ||
| 42 | .subscribe((bitmap, th) -> { | ||
| 43 | if (th != null) th.printStackTrace(); | ||
| 44 | if (bitmap == null) return; | ||
| 45 | this.bitmap = bitmap; | ||
| 46 | |||
| 47 | binding.ivPic.setImageBitmap(bitmap); | ||
| 48 | CutUtil.onLayoutReady(binding.ivPic, v -> { | ||
| 49 | prepareRects(rects); | ||
| 50 | }); | ||
| 51 | }); | ||
| 52 | } | ||
| 53 | |||
| 54 | private void prepareRects(List<Rect> rects) { | ||
| 55 | mList.clear(); | ||
| 56 | binding.flRects.removeAllViews(); | ||
| 57 | float[] measuredSize = CutUtil.measureBitmap(binding.ivPic, bitmap); | ||
| 58 | for (int i = 0; i < rects.size(); i++) { | ||
| 59 | Rect it = rects.get(i); | ||
| 60 | Bitmap bitmap = CutUtil.cut(this.bitmap, it.left, it.top, it.width(), it.height(), this); | ||
| 61 | Rect rect = measureRect(it, measuredSize); | ||
| 62 | LayoutJudgeRectBinding vb = showRect(rect); | ||
| 63 | mList.add(new JudgeCut(i, bitmap, rect, vb)); | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | private LayoutJudgeRectBinding showRect(Rect rect) { | ||
| 68 | LayoutJudgeRectBinding vb = LayoutJudgeRectBinding.inflate(getLayoutInflater(), binding.flRects, false); | ||
| 69 | |||
| 70 | vb.getRoot().setMinimumWidth(rect.width()); | ||
| 71 | vb.getRoot().setMinimumHeight(rect.height()); | ||
| 72 | vb.getRoot().setTranslationX((float) rect.left); | ||
| 73 | vb.getRoot().setTranslationY((float) rect.top); | ||
| 74 | vb.getRoot().setOnClickListener(v -> { | ||
| 75 | v.setSelected(!v.isSelected()); | ||
| 76 | checkCount(); | ||
| 77 | }); | ||
| 78 | binding.flRects.addView(vb.getRoot()); | ||
| 79 | |||
| 80 | return vb; | ||
| 81 | } | ||
| 82 | |||
| 83 | private void checkCount() { | ||
| 84 | // | ||
| 85 | } | ||
| 86 | |||
| 87 | /** bitmapRect 转换为 viewRect */ | ||
| 88 | private Rect measureRect(Rect rect, float[] measuredSize) { | ||
| 89 | float realW = measuredSize[0]; | ||
| 90 | float realH = measuredSize[1]; | ||
| 91 | float offsetX = measuredSize[2]; | ||
| 92 | float offsetY = measuredSize[3]; | ||
| 93 | float percentX = realW / bitmap.getWidth(); | ||
| 94 | float percentY = realH / bitmap.getHeight(); | ||
| 95 | |||
| 96 | float left = rect.left * percentX + offsetX; | ||
| 97 | float right = rect.right * percentX + offsetX; | ||
| 98 | float top = rect.top * percentY + offsetY; | ||
| 99 | float bottom = rect.bottom * percentY + offsetY; | ||
| 100 | return new Rect((int) left, (int) top, (int) right, (int) bottom); | ||
| 101 | } | ||
| 102 | |||
| 103 | @Override | ||
| 104 | protected ActivityJudgeBinding getViewBinding() { | ||
| 105 | return ActivityJudgeBinding.inflate(getLayoutInflater()); | ||
| 106 | } | ||
| 107 | |||
| 108 | static class JudgeCut { | ||
| 109 | final int index; | ||
| 110 | final Bitmap bitmap; | ||
| 111 | final Rect rect; | ||
| 112 | final LayoutJudgeRectBinding vb; | ||
| 113 | |||
| 114 | int correctResult = 0; | ||
| 115 | |||
| 116 | public JudgeCut(int index, Bitmap bitmap, Rect rect, LayoutJudgeRectBinding vb) { | ||
| 117 | this.index = index; | ||
| 118 | this.bitmap = bitmap; | ||
| 119 | this.rect = rect; | ||
| 120 | this.vb = vb; | ||
| 121 | } | ||
| 122 | } | ||
| 123 | } | ||
| 124 |
app/src/main/java/com/hjx/parent/adapter/ImageAdapter.java
| 1 | package com.hjx.parent.adapter; | 1 | package com.hjx.parent.adapter; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.graphics.Bitmap; | 5 | import android.graphics.Bitmap; |
| 6 | import android.graphics.BitmapFactory; | 6 | import android.graphics.BitmapFactory; |
| 7 | import android.graphics.Rect; | 7 | import android.graphics.Rect; |
| 8 | import android.graphics.RectF; | 8 | import android.graphics.RectF; |
| 9 | import android.util.Log; | 9 | import android.util.Log; |
| 10 | import android.util.SparseArray; | ||
| 10 | import android.view.LayoutInflater; | 11 | import android.view.LayoutInflater; |
| 11 | import android.view.View; | 12 | import android.view.View; |
| 12 | import android.view.ViewGroup; | 13 | import android.view.ViewGroup; |
| 13 | import android.widget.ImageView; | 14 | import android.widget.ImageView; |
| 14 | import android.widget.RelativeLayout; | 15 | import android.widget.RelativeLayout; |
| 15 | 16 | ||
| 16 | import androidx.annotation.NonNull; | 17 | import androidx.annotation.NonNull; |
| 17 | import androidx.recyclerview.widget.RecyclerView; | 18 | import androidx.recyclerview.widget.RecyclerView; |
| 18 | 19 | ||
| 19 | import com.google.gson.Gson; | 20 | import com.google.gson.Gson; |
| 20 | import com.hjx.parent.ImageActivity; | 21 | import com.hjx.parent.ImageActivity; |
| 21 | import com.hjx.parent.ImageSelectActivity; | 22 | import com.hjx.parent.ImageSelectActivity; |
| 22 | import com.hjx.parent.R; | 23 | import com.hjx.parent.R; |
| 23 | import com.hjx.parent.databinding.ItemImageBinding; | 24 | import com.hjx.parent.databinding.ItemImageBinding; |
| 24 | import com.prws.common.bean.ImageBean; | 25 | import com.prws.common.bean.ImageBean; |
| 25 | import com.prws.common.utils.CommonUtil; | 26 | import com.prws.common.utils.CommonUtil; |
| 26 | 27 | ||
| 27 | import java.util.List; | 28 | import java.util.List; |
| 28 | 29 | ||
| 29 | public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageHolder> { | 30 | public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageHolder> { |
| 31 | public SparseArray<ItemImageBinding> viewArray = new SparseArray<>(); | ||
| 32 | |||
| 30 | private List<ImageBean> list; | 33 | private List<ImageBean> list; |
| 31 | private ImageActivity context; | 34 | private ImageActivity context; |
| 32 | 35 | ||
| 36 | |||
| 33 | public ImageAdapter(ImageActivity context, List<ImageBean> list) { | 37 | public ImageAdapter(ImageActivity context, List<ImageBean> list) { |
| 34 | this.context = context; | 38 | this.context = context; |
| 35 | this.list = list; | 39 | this.list = list; |
| 36 | } | 40 | } |
| 37 | 41 | ||
| 38 | @NonNull | 42 | @NonNull |
| 39 | @Override | 43 | @Override |
| 40 | public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | 44 | public ImageHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { |
| 41 | ItemImageBinding itemImageBinding = ItemImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); | 45 | ItemImageBinding itemImageBinding = ItemImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); |
| 42 | return new ImageHolder(itemImageBinding); | 46 | return new ImageHolder(itemImageBinding); |
| 43 | } | 47 | } |
| 44 | 48 | ||
| 45 | @Override | 49 | @Override |
| 46 | public void onBindViewHolder(@NonNull ImageHolder holder, int position) { | 50 | public void onBindViewHolder(@NonNull ImageHolder holder, int position) { |
| 51 | viewArray.put(position, holder.binding); | ||
| 52 | |||
| 47 | ImageBean imageBean = list.get(position); | 53 | ImageBean imageBean = list.get(position); |
| 48 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); | 54 | Bitmap bitmap = BitmapFactory.decodeFile(imageBean.getPath()); |
| 49 | float imageHeight = bitmap.getHeight(); | 55 | float imageHeight = bitmap.getHeight(); |
| 50 | float imageWidth = bitmap.getWidth(); | 56 | float imageWidth = bitmap.getWidth(); |
| 51 | float viewHeight = CommonUtil.getScreenHeight(context) - CommonUtil.dpToPx(context, 250); | 57 | float viewHeight = CommonUtil.getScreenHeight(context) - CommonUtil.dpToPx(context, 250); |
| 52 | float viewWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); | 58 | float viewWidth = CommonUtil.getScreenWidth(context) - CommonUtil.dpToPx(context, 60); |
| 53 | 59 | ||
| 54 | RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(holder.binding.ivPic.getLayoutParams()); | 60 | RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(holder.binding.ivPic.getLayoutParams()); |
| 55 | if (imageHeight / imageWidth > viewHeight / viewWidth) { | 61 | if (imageHeight / imageWidth > viewHeight / viewWidth) { |
| 56 | if (viewHeight > imageHeight) { | 62 | if (viewHeight > imageHeight) { |
| 57 | layoutParams.height = (int) imageHeight; | 63 | layoutParams.height = (int) imageHeight; |
| 58 | layoutParams.width = (int) imageWidth; | 64 | layoutParams.width = (int) imageWidth; |
| 59 | } else { | 65 | } else { |
| 60 | layoutParams.height = (int) viewHeight; | 66 | layoutParams.height = (int) viewHeight; |
| 61 | layoutParams.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); | 67 | layoutParams.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); |
| 62 | } | 68 | } |
| 63 | } else { | 69 | } else { |
| 64 | if (viewWidth > imageWidth) { | 70 | if (viewWidth > imageWidth) { |
| 65 | layoutParams.height = (int) imageHeight; | 71 | layoutParams.height = (int) imageHeight; |
| 66 | layoutParams.width = (int) imageWidth; | 72 | layoutParams.width = (int) imageWidth; |
| 67 | } else { | 73 | } else { |
| 68 | layoutParams.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); | 74 | layoutParams.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); |
| 69 | layoutParams.width = (int) viewWidth; | 75 | layoutParams.width = (int) viewWidth; |
| 70 | } | 76 | } |
| 71 | } | 77 | } |
| 72 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); | 78 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); |
| 73 | holder.binding.ivPic.setLayoutParams(layoutParams); | 79 | holder.binding.ivPic.setLayoutParams(layoutParams); |
| 74 | holder.binding.ivPic.setImageBitmap(bitmap); | 80 | holder.binding.ivPic.setImageBitmap(bitmap); |
| 75 | 81 | ||
| 76 | 82 | ||
| 77 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(holder.binding.rlPic.getLayoutParams()); | 83 | RelativeLayout.LayoutParams layoutParams1 = new RelativeLayout.LayoutParams(holder.binding.rlPic.getLayoutParams()); |
| 78 | if (imageHeight / imageWidth > viewHeight / viewWidth) { | 84 | if (imageHeight / imageWidth > viewHeight / viewWidth) { |
| 79 | if (viewHeight > imageHeight) { | 85 | if (viewHeight > imageHeight) { |
| 80 | layoutParams1.height = (int) imageHeight; | 86 | layoutParams1.height = (int) imageHeight; |
| 81 | layoutParams1.width = (int) imageWidth; | 87 | layoutParams1.width = (int) imageWidth; |
| 82 | } else { | 88 | } else { |
| 83 | layoutParams1.height = (int) viewHeight; | 89 | layoutParams1.height = (int) viewHeight; |
| 84 | layoutParams1.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); | 90 | layoutParams1.width = (int) ((float) (imageWidth / imageHeight) * viewHeight); |
| 85 | } | 91 | } |
| 86 | } else { | 92 | } else { |
| 87 | if (viewWidth > imageWidth) { | 93 | if (viewWidth > imageWidth) { |
| 88 | layoutParams1.height = (int) imageHeight; | 94 | layoutParams1.height = (int) imageHeight; |
| 89 | layoutParams1.width = (int) imageWidth; | 95 | layoutParams1.width = (int) imageWidth; |
| 90 | } else { | 96 | } else { |
| 91 | layoutParams1.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); | 97 | layoutParams1.height = (int) ((float) (imageHeight / imageWidth) * viewWidth); |
| 92 | layoutParams1.width = (int) viewWidth; | 98 | layoutParams1.width = (int) viewWidth; |
| 93 | } | 99 | } |
| 94 | } | 100 | } |
| 95 | Log.i("figLoaction", "height=" + layoutParams1.height + " width=" + layoutParams1.width); | 101 | Log.i("figLoaction", "height=" + layoutParams1.height + " width=" + layoutParams1.width); |
| 96 | layoutParams1.addRule(RelativeLayout.CENTER_IN_PARENT); | 102 | layoutParams1.addRule(RelativeLayout.CENTER_IN_PARENT); |
| 97 | holder.binding.rlPic.setLayoutParams(layoutParams1); | 103 | holder.binding.rlPic.setLayoutParams(layoutParams1); |
| 98 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { | 104 | if (imageBean.getCuts() != null && imageBean.getCuts().size() > 0) { |
| 99 | holder.binding.rlPic.removeAllViews(); | 105 | holder.binding.rlPic.removeAllViews(); |
| 100 | for (int i = 0; i < imageBean.getCuts().size(); i++) { | 106 | for (int i = 0; i < imageBean.getCuts().size(); i++) { |
| 101 | View view = LayoutInflater.from(context).inflate(R.layout.layout_select, null); | 107 | View view = LayoutInflater.from(context).inflate(R.layout.layout_select, null); |
| 102 | Rect rect; | 108 | Rect rect; |
| 103 | if (imageBean.getCuts().get(i).getRect1() != null) { | 109 | if (imageBean.getCuts().get(i).getRect1() != null) { |
| 104 | rect = imageBean.getCuts().get(i).getRect1(); | 110 | rect = imageBean.getCuts().get(i).getRect1(); |
| 105 | } else { | 111 | } else { |
| 106 | rect = CommonUtil.getRect(imageBean.getCuts().get(i).getRect(), bitmap, layoutParams1.height, layoutParams1.width); | 112 | rect = CommonUtil.getRect(imageBean.getCuts().get(i).getRect(), bitmap, layoutParams1.height, layoutParams1.width); |
| 107 | imageBean.getCuts().get(i).setRect1(rect); | 113 | imageBean.getCuts().get(i).setRect1(rect); |
| 108 | } | 114 | } |
| 109 | Log.i("figLoaction", new Gson().toJson(rect)); | 115 | Log.i("figLoaction", new Gson().toJson(rect)); |
| 110 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(rect.right - rect.left, rect.bottom - rect.top); | 116 | RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(rect.right - rect.left, rect.bottom - rect.top); |
| 111 | params.setMargins(rect.left, rect.top, 0, 0); | 117 | params.setMargins(rect.left, rect.top, 0, 0); |
| 112 | holder.binding.rlPic.addView(view, params); | 118 | holder.binding.rlPic.addView(view, params); |
| 113 | RelativeLayout rl_add = view.findViewById(R.id.rl_add); | 119 | RelativeLayout rl_add = view.findViewById(R.id.rl_add); |
| 114 | ImageView iv_state = view.findViewById(R.id.iv_state); | 120 | ImageView iv_state = view.findViewById(R.id.iv_state); |
| 115 | ImageView iv_edit = view.findViewById(R.id.iv_edit); | 121 | ImageView iv_edit = view.findViewById(R.id.iv_edit); |
| 116 | int finalI = i; | 122 | int finalI = i; |
| 117 | if (imageBean.getCuts().get(i).isSelect()) { | 123 | if (imageBean.getCuts().get(i).isSelect()) { |
| 118 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); | 124 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); |
| 119 | iv_state.setImageResource(R.mipmap.ic_selected); | 125 | iv_state.setImageResource(R.mipmap.ic_selected); |
| 120 | } else { | 126 | } else { |
| 121 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); | 127 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); |
| 122 | iv_state.setImageResource(R.mipmap.ic_add); | 128 | iv_state.setImageResource(R.mipmap.ic_add); |
| 123 | } | 129 | } |
| 124 | rl_add.setOnClickListener(new View.OnClickListener() { | 130 | rl_add.setOnClickListener(new View.OnClickListener() { |
| 125 | @Override | 131 | @Override |
| 126 | public void onClick(View v) { | 132 | public void onClick(View v) { |
| 127 | Bitmap b = Bitmap.createBitmap(bitmap, v.getLeft() * bitmap.getWidth() / holder.binding.ivPic.getWidth(), v.getTop() * bitmap.getHeight() / holder.binding.ivPic.getHeight(), (v.getRight() - v.getLeft()) * bitmap.getWidth() / holder.binding.ivPic.getWidth(), (v.getBottom() - v.getTop()) * bitmap.getHeight() / holder.binding.ivPic.getHeight()); | 133 | Bitmap b = Bitmap.createBitmap(bitmap, v.getLeft() * bitmap.getWidth() / holder.binding.ivPic.getWidth(), v.getTop() * bitmap.getHeight() / holder.binding.ivPic.getHeight(), (v.getRight() - v.getLeft()) * bitmap.getWidth() / holder.binding.ivPic.getWidth(), (v.getBottom() - v.getTop()) * bitmap.getHeight() / holder.binding.ivPic.getHeight()); |
| 128 | if (imageBean.getCuts().get(finalI).isSelect()) { | 134 | if (imageBean.getCuts().get(finalI).isSelect()) { |
| 129 | imageBean.getCuts().get(finalI).setSelect(false); | 135 | imageBean.getCuts().get(finalI).setSelect(false); |
| 130 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); | 136 | rl_add.setBackgroundResource(R.drawable.bg_cut_unselect); |
| 131 | iv_state.setImageResource(R.mipmap.ic_add); | 137 | iv_state.setImageResource(R.mipmap.ic_add); |
| 132 | } else { | 138 | } else { |
| 133 | imageBean.getCuts().get(finalI).setSelect(true); | 139 | imageBean.getCuts().get(finalI).setSelect(true); |
| 134 | imageBean.getCuts().get(finalI).setBitmap(b); | 140 | imageBean.getCuts().get(finalI).setBitmap(b); |
| 135 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); | 141 | rl_add.setBackgroundResource(R.drawable.bg_cut_select); |
| 136 | iv_state.setImageResource(R.mipmap.ic_selected); | 142 | iv_state.setImageResource(R.mipmap.ic_selected); |
| 137 | } | 143 | } |
| 138 | context.refreshNum(); | 144 | context.refreshNum(); |
| 139 | } | 145 | } |
| 140 | }); | 146 | }); |
| 141 | iv_edit.setOnClickListener(new View.OnClickListener() { | 147 | iv_edit.setOnClickListener(new View.OnClickListener() { |
| 142 | @Override | 148 | @Override |
| 143 | public void onClick(View v) { | 149 | public void onClick(View v) { |
| 144 | Intent intent = new Intent(context, ImageSelectActivity.class); | 150 | Intent intent = new Intent(context, ImageSelectActivity.class); |
| 145 | intent.putExtra("rect", rect); | 151 | intent.putExtra("rect", rect); |
| 146 | intent.putExtra("path", imageBean.getPath()); | 152 | intent.putExtra("path", imageBean.getPath()); |
| 147 | intent.putExtra("position", finalI); | 153 | intent.putExtra("position", finalI); |
| 148 | context.startActivityForResult(intent, 1001); | 154 | context.startActivityForResult(intent, 1001); |
| 149 | } | 155 | } |
| 150 | }); | 156 | }); |
| 151 | } | 157 | } |
| 152 | } else { | 158 | } else { |
| 153 | holder.binding.rlPic.removeAllViews(); | 159 | holder.binding.rlPic.removeAllViews(); |
| 154 | } | 160 | } |
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | @Override | 163 | @Override |
| 158 | public int getItemCount() { | 164 | public int getItemCount() { |
| 159 | return list.size(); | 165 | return list.size(); |
| 160 | } | 166 | } |
| 161 | 167 | ||
| 162 | static class ImageHolder extends RecyclerView.ViewHolder { | 168 | static class ImageHolder extends RecyclerView.ViewHolder { |
| 163 | ItemImageBinding binding; | 169 | ItemImageBinding binding; |
| 164 | 170 | ||
| 165 | public ImageHolder(@NonNull ItemImageBinding itemView) { | 171 | public ImageHolder(@NonNull ItemImageBinding itemView) { |
| 166 | super(itemView.getRoot()); | 172 | super(itemView.getRoot()); |
| 167 | binding = itemView; | 173 | binding = itemView; |
| 168 | } | 174 | } |
| 169 | } | 175 | } |
| 170 | } | 176 | } |
| 171 | 177 |
app/src/main/java/com/hjx/parent/utils/CutUtil.java
| File was created | 1 | package com.hjx.parent.utils; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.graphics.Bitmap; | ||
| 5 | import android.graphics.Canvas; | ||
| 6 | import android.graphics.Color; | ||
| 7 | import android.graphics.Paint; | ||
| 8 | import android.view.View; | ||
| 9 | import android.view.ViewTreeObserver; | ||
| 10 | |||
| 11 | import com.bumptech.glide.Glide; | ||
| 12 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; | ||
| 13 | import com.hjx.parent.function.Function1; | ||
| 14 | |||
| 15 | public class CutUtil { | ||
| 16 | |||
| 17 | public static float[] measureBitmap(View view, Bitmap bitmap) { | ||
| 18 | float realW; | ||
| 19 | float realH; | ||
| 20 | float offsetX; | ||
| 21 | float offsetY; | ||
| 22 | |||
| 23 | float vp = 1f * view.getWidth() / view.getHeight(); | ||
| 24 | float bp = 1f * bitmap.getWidth() / bitmap.getHeight(); | ||
| 25 | |||
| 26 | if (vp > bp) { | ||
| 27 | realW = view.getHeight() * bp; | ||
| 28 | realH = (float) view.getHeight(); | ||
| 29 | offsetY = 0f; | ||
| 30 | offsetX = (view.getWidth() - realW) * 0.5f; | ||
| 31 | } else if (vp < bp) { | ||
| 32 | realW = (float) view.getWidth(); | ||
| 33 | realH = view.getWidth() * (1f / bp); | ||
| 34 | offsetX = 0f; | ||
| 35 | offsetY = (view.getHeight() - realH) * 0.5f; | ||
| 36 | } else { | ||
| 37 | realW = (float) view.getWidth(); | ||
| 38 | realH = (float) view.getHeight(); | ||
| 39 | offsetX = 0f; | ||
| 40 | offsetY = 0f; | ||
| 41 | } | ||
| 42 | |||
| 43 | return new float[]{realW, realH, offsetX, offsetY}; | ||
| 44 | } | ||
| 45 | |||
| 46 | public static Bitmap cut(Bitmap source, float x, float y, int w, int h, Context context) { | ||
| 47 | // 获取 Glide 的 BitmapPool | ||
| 48 | BitmapPool bitmapPool = Glide.get(context).getBitmapPool(); | ||
| 49 | |||
| 50 | // 从 BitmapPool 中获取可复用的 Bitmap | ||
| 51 | Bitmap result = bitmapPool.get(w, h, source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888); | ||
| 52 | |||
| 53 | // 填充白色背景 | ||
| 54 | result.eraseColor(Color.WHITE); | ||
| 55 | |||
| 56 | // 创建画布并绘制 | ||
| 57 | Canvas canvas = new Canvas(result); | ||
| 58 | Paint paint = new Paint(); | ||
| 59 | canvas.drawBitmap(source, -x, -y, paint); | ||
| 60 | |||
| 61 | return result; | ||
| 62 | } | ||
| 63 | |||
| 64 | public static void onLayoutReady(final View view, final Function1<View> action) { | ||
| 65 | view.getViewTreeObserver().addOnGlobalLayoutListener( | ||
| 66 | new ViewTreeObserver.OnGlobalLayoutListener() { | ||
| 67 | @Override | ||
| 68 | public void onGlobalLayout() { | ||
| 69 | view.getViewTreeObserver().removeOnGlobalLayoutListener(this); | ||
| 70 | action.invoke(view); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | ); | ||
| 74 | } | ||
| 75 | } | ||
| 76 |
app/src/main/res/drawable/bg_judge_cut.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | <item android:state_selected="true"> | ||
| 4 | <shape> | ||
| 5 | <solid android:color="#1A1C90F3"/> | ||
| 6 | <stroke android:color="#1C90F3" android:width="1px"/> | ||
| 7 | </shape> | ||
| 8 | </item> | ||
| 9 | <item> | ||
| 10 | <shape> | ||
| 11 | <solid android:color="#33000000"/> | ||
| 12 | <stroke android:color="#666666" android:width="1px"/> | ||
| 13 | </shape> | ||
| 14 | </item> | ||
| 15 | </selector> |
app/src/main/res/drawable/ic_add.png
1.12 KB
app/src/main/res/drawable/ic_judge_rect_select.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | <item android:drawable="@drawable/png_rect_selected" android:state_selected="true"/> | ||
| 4 | <item android:drawable="@drawable/png_rect_add"/> | ||
| 5 | </selector> |
app/src/main/res/drawable/ic_rect_20.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | <item android:drawable="@drawable/png_ic_rect" | ||
| 4 | android:width="20dp" android:height="20dp"/> | ||
| 5 | </layer-list> |
app/src/main/res/drawable/png_ic_judge_correct.png
1.09 KB
app/src/main/res/drawable/png_ic_rect.png
1.72 KB
app/src/main/res/drawable/png_rect_add.png
1.12 KB
app/src/main/res/drawable/png_rect_selected.png
902 Bytes
app/src/main/res/layout/activity_image.xml
| 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| 2 | xmlns:tools="http://schemas.android.com/tools" | ||
| 2 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
| 3 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
| 4 | android:orientation="vertical"> | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 6 | android:orientation="vertical" | ||
| 7 | tools:ignore="HardcodedText"> | ||
| 5 | 8 | ||
| 6 | <RelativeLayout | 9 | <RelativeLayout |
| 7 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
| 8 | android:layout_height="40dp" | 11 | android:layout_height="40dp" |
| 9 | android:background="@color/white"> | 12 | android:background="@color/white"> |
| 10 | 13 | ||
| 11 | <TextView | 14 | <TextView |
| 12 | android:id="@+id/tv_title" | 15 | android:id="@+id/tv_title" |
| 13 | android:layout_width="wrap_content" | 16 | android:layout_width="wrap_content" |
| 14 | android:layout_height="wrap_content" | 17 | android:layout_height="wrap_content" |
| 15 | android:layout_centerInParent="true" | 18 | android:layout_centerInParent="true" |
| 16 | android:textColor="#333333" | 19 | android:textColor="#333333" |
| 17 | android:textSize="18sp" /> | 20 | android:textSize="18sp" /> |
| 18 | 21 | ||
| 19 | <ImageView | 22 | <ImageView |
| 20 | android:id="@+id/iv_back" | 23 | android:id="@+id/iv_back" |
| 21 | android:layout_width="30dp" | 24 | android:layout_width="30dp" |
| 22 | android:layout_height="36dp" | 25 | android:layout_height="36dp" |
| 23 | android:layout_centerVertical="true" | 26 | android:layout_centerVertical="true" |
| 24 | android:layout_marginLeft="5dp" | 27 | android:layout_marginLeft="5dp" |
| 25 | android:padding="10dp" | 28 | android:padding="10dp" |
| 26 | android:src="@mipmap/icon_back" /> | 29 | android:src="@mipmap/icon_back" /> |
| 27 | 30 | ||
| 28 | <TextView | 31 | <TextView |
| 29 | android:id="@+id/tv_photo" | 32 | android:id="@+id/tv_photo" |
| 30 | android:layout_width="wrap_content" | 33 | android:layout_width="wrap_content" |
| 31 | android:layout_height="wrap_content" | 34 | android:layout_height="wrap_content" |
| 32 | android:layout_centerVertical="true" | 35 | android:layout_centerVertical="true" |
| 33 | android:layout_toRightOf="@+id/iv_back" | 36 | android:layout_toRightOf="@+id/iv_back" |
| 34 | android:text="重拍" | 37 | android:text="重拍" |
| 35 | android:textColor="#333333" | 38 | android:textColor="#333333" |
| 36 | android:textSize="14sp" /> | 39 | android:textSize="14sp" /> |
| 37 | 40 | ||
| 38 | <TextView | 41 | <TextView |
| 39 | android:id="@+id/btnShowSource" | 42 | android:id="@+id/btnShowSource" |
| 40 | android:layout_width="wrap_content" | 43 | android:layout_width="wrap_content" |
| 41 | android:layout_height="wrap_content" | 44 | android:layout_height="wrap_content" |
| 42 | android:layout_alignParentRight="true" | 45 | android:layout_alignParentRight="true" |
| 43 | android:layout_centerVertical="true" | 46 | android:layout_centerVertical="true" |
| 44 | android:layout_marginRight="15dp" | 47 | android:layout_marginRight="15dp" |
| 45 | android:text="查看原图" | 48 | android:text="查看原图" |
| 46 | android:textColor="#333333" | 49 | android:textColor="#333333" |
| 47 | android:textSize="14sp" /> | 50 | android:textSize="14sp" /> |
| 48 | </RelativeLayout> | 51 | </RelativeLayout> |
| 49 | 52 | ||
| 50 | <TextView | 53 | <TextView |
| 51 | android:layout_width="match_parent" | 54 | android:layout_width="match_parent" |
| 52 | android:layout_height="35dp" | 55 | android:layout_height="35dp" |
| 53 | android:background="#C7DFF5" | 56 | android:background="#C7DFF5" |
| 54 | android:gravity="center" | 57 | android:gravity="center" |
| 55 | android:text="已为您自动框选题目,点击“+”添加题目" | 58 | android:text="已为您自动框选题目,点击“+”添加题目" |
| 56 | android:textColor="#1C90F3" | 59 | android:textColor="#1C90F3" |
| 57 | android:textSize="13sp" /> | 60 | android:textSize="13sp" /> |
| 58 | 61 | ||
| 59 | <RelativeLayout | 62 | <RelativeLayout |
| 60 | android:layout_width="match_parent" | 63 | android:layout_width="match_parent" |
| 61 | android:layout_height="match_parent" | 64 | android:layout_height="match_parent" |
| 62 | android:background="#F8F8F8"> | 65 | android:background="#F8F8F8"> |
| 63 | 66 | ||
| 64 | <androidx.viewpager2.widget.ViewPager2 | 67 | <androidx.viewpager2.widget.ViewPager2 |
| 65 | android:id="@+id/viewPager" | 68 | android:id="@+id/viewPager" |
| 66 | android:layout_width="match_parent" | 69 | android:layout_width="match_parent" |
| 67 | android:layout_height="match_parent" | 70 | android:layout_height="match_parent" |
| 68 | android:layout_above="@+id/rl_previous" /> | 71 | android:layout_above="@+id/rl_previous" /> |
| 69 | 72 | ||
| 70 | <RelativeLayout | 73 | <RelativeLayout |
| 71 | android:id="@+id/rl_previous" | 74 | android:id="@+id/rl_previous" |
| 72 | android:layout_width="30dp" | 75 | android:layout_width="30dp" |
| 73 | android:layout_height="30dp" | 76 | android:layout_height="30dp" |
| 74 | android:layout_above="@+id/rl_bottom" | 77 | android:layout_above="@+id/rl_bottom" |
| 75 | android:layout_marginLeft="15dp" | 78 | android:layout_marginLeft="15dp" |
| 76 | android:layout_marginBottom="15dp" | 79 | android:layout_marginBottom="15dp" |
| 77 | android:background="@drawable/bg_solid_white"> | 80 | android:background="@drawable/bg_solid_white"> |
| 78 | 81 | ||
| 79 | <ImageView | 82 | <ImageView |
| 80 | android:id="@+id/iv_previous" | 83 | android:id="@+id/iv_previous" |
| 81 | android:layout_width="10dp" | 84 | android:layout_width="10dp" |
| 82 | android:layout_height="18dp" | 85 | android:layout_height="18dp" |
| 83 | android:layout_centerInParent="true" | 86 | android:layout_centerInParent="true" |
| 84 | android:src="@mipmap/ic_previous_gray" /> | 87 | android:src="@mipmap/ic_previous_gray" /> |
| 85 | </RelativeLayout> | 88 | </RelativeLayout> |
| 86 | 89 | ||
| 87 | <RelativeLayout | 90 | <RelativeLayout |
| 88 | android:id="@+id/rl_next" | 91 | android:id="@+id/rl_next" |
| 89 | android:layout_width="30dp" | 92 | android:layout_width="30dp" |
| 90 | android:layout_height="30dp" | 93 | android:layout_height="30dp" |
| 91 | android:layout_above="@+id/rl_bottom" | 94 | android:layout_above="@+id/rl_bottom" |
| 92 | android:layout_alignParentRight="true" | 95 | android:layout_alignParentRight="true" |
| 93 | android:layout_marginRight="15dp" | 96 | android:layout_marginRight="15dp" |
| 94 | android:layout_marginBottom="15dp" | 97 | android:layout_marginBottom="15dp" |
| 95 | android:background="@drawable/bg_solid_white"> | 98 | android:background="@drawable/bg_solid_white"> |
| 96 | 99 | ||
| 97 | <ImageView | 100 | <ImageView |
| 98 | android:id="@+id/iv_next" | 101 | android:id="@+id/iv_next" |
| 99 | android:layout_width="10dp" | 102 | android:layout_width="10dp" |
| 100 | android:layout_height="18dp" | 103 | android:layout_height="18dp" |
| 101 | android:layout_centerInParent="true" | 104 | android:layout_centerInParent="true" |
| 102 | android:src="@mipmap/ic_next_gray" /> | 105 | android:src="@mipmap/ic_next_gray" /> |
| 103 | </RelativeLayout> | 106 | </RelativeLayout> |
| 104 | 107 | ||
| 105 | <RelativeLayout | 108 | <LinearLayout |
| 106 | android:id="@+id/rl_bottom" | 109 | android:id="@+id/rl_bottom" |
| 110 | android:orientation="horizontal" | ||
| 111 | android:gravity="center_vertical" | ||
| 107 | android:layout_width="match_parent" | 112 | android:layout_width="match_parent" |
| 108 | android:layout_height="70dp" | 113 | android:layout_height="70dp" |
| 109 | android:layout_alignParentBottom="true" | 114 | android:layout_alignParentBottom="true" |
| 110 | android:background="@color/white"> | 115 | android:background="@color/white"> |
| 111 | 116 | ||
| 112 | <LinearLayout | 117 | <LinearLayout |
| 113 | android:id="@+id/ll_edit" | 118 | android:id="@+id/ll_edit" |
| 114 | android:layout_width="wrap_content" | 119 | android:layout_width="wrap_content" |
| 115 | android:layout_height="wrap_content" | 120 | android:layout_height="wrap_content" |
| 116 | android:layout_centerVertical="true" | 121 | android:layout_marginStart="15dp" |
| 117 | android:layout_marginLeft="15dp" | ||
| 118 | android:orientation="vertical"> | 122 | android:orientation="vertical"> |
| 119 | 123 | ||
| 120 | <ImageView | 124 | <ImageView |
| 121 | android:layout_width="25dp" | 125 | android:layout_width="20dp" |
| 122 | android:layout_height="25dp" | 126 | android:layout_height="20dp" |
| 123 | android:layout_gravity="center_horizontal" | 127 | android:layout_gravity="center_horizontal" |
| 124 | android:src="@mipmap/ic_pic_edit" /> | 128 | android:src="@mipmap/ic_pic_edit" /> |
| 125 | 129 | ||
| 126 | <TextView | 130 | <TextView |
| 127 | android:layout_width="wrap_content" | 131 | android:layout_width="wrap_content" |
| 128 | android:layout_height="wrap_content" | 132 | android:layout_height="wrap_content" |
| 129 | android:layout_marginTop="5dp" | 133 | android:layout_marginTop="5dp" |
| 130 | android:text="图片编辑" | 134 | android:text="图片编辑" |
| 135 | android:textColor="#333" | ||
| 131 | android:textSize="11sp" /> | 136 | android:textSize="11sp" /> |
| 132 | </LinearLayout> | 137 | </LinearLayout> |
| 133 | 138 | ||
| 134 | <TextView | 139 | <androidx.appcompat.widget.AppCompatTextView |
| 135 | android:id="@+id/tv_add" | 140 | android:id="@+id/tv_add" |
| 136 | android:layout_width="140dp" | 141 | android:text="手动框选" |
| 137 | android:layout_height="40dp" | 142 | android:textSize="11sp" |
| 138 | android:layout_centerVertical="true" | 143 | android:textColor="#333" |
| 139 | android:layout_marginRight="15dp" | 144 | android:gravity="center_horizontal" |
| 140 | android:layout_toLeftOf="@+id/tv_save" | 145 | android:drawableTop="@drawable/ic_rect_20" |
| 146 | android:drawablePadding="5dp" | ||
| 147 | android:layout_marginStart="12dp" | ||
| 148 | android:layout_width="wrap_content" | ||
| 149 | android:layout_height="wrap_content" /> | ||
| 150 | |||
| 151 | <Space style="@style/empty_space"/> | ||
| 152 | |||
| 153 | <TextView | ||
| 154 | android:id="@+id/btnJudge" | ||
| 155 | android:layout_width="112dp" | ||
| 156 | android:layout_height="36dp" | ||
| 141 | android:background="@drawable/bg_soild_orange_5" | 157 | android:background="@drawable/bg_soild_orange_5" |
| 142 | android:gravity="center" | 158 | android:gravity="center" |
| 143 | android:text="手动框选" | 159 | android:text="去批改" |
| 144 | android:textColor="@color/white" | 160 | android:textColor="@color/white" |
| 145 | android:textSize="18sp" /> | 161 | android:textSize="16sp" /> |
| 146 | 162 | ||
| 147 | <TextView | 163 | <TextView |
| 148 | android:id="@+id/tv_save" | 164 | android:id="@+id/tv_save" |
| 149 | android:layout_width="140dp" | 165 | android:layout_width="112dp" |
| 150 | android:layout_height="40dp" | 166 | android:layout_height="36dp" |
| 151 | android:layout_alignParentRight="true" | 167 | android:layout_marginHorizontal="15dp" |
| 152 | android:layout_centerVertical="true" | ||
| 153 | android:layout_marginRight="15dp" | ||
| 154 | android:background="@drawable/bg_soild_blue_light_5" | 168 | android:background="@drawable/bg_soild_blue_light_5" |
| 155 | android:enabled="false" | 169 | android:enabled="false" |
| 156 | android:gravity="center" | 170 | android:gravity="center" |
| 157 | android:text="保存错题" | 171 | android:text="保存错题" |
| 158 | android:textColor="@color/white" | 172 | android:textColor="@color/white" |
| 159 | android:textSize="18sp" /> | 173 | android:textSize="16sp" /> |
app/src/main/res/layout/activity_judge.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | android:orientation="vertical" | ||
| 6 | android:layout_width="match_parent" | ||
| 7 | android:layout_height="match_parent" | ||
| 8 | tools:ignore="UseCompoundDrawables,HardcodedText,SmallSp,ContentDescription"> | ||
| 9 | |||
| 10 | <androidx.appcompat.widget.Toolbar | ||
| 11 | android:background="@color/white" | ||
| 12 | app:contentInsetStart="0dp" | ||
| 13 | android:layout_width="match_parent" | ||
| 14 | android:layout_height="40dp"> | ||
| 15 | <ImageView | ||
| 16 | android:id="@+id/ivBack" | ||
| 17 | android:layout_width="30dp" | ||
| 18 | android:layout_height="36dp" | ||
| 19 | android:layout_centerVertical="true" | ||
| 20 | android:layout_marginStart="5dp" | ||
| 21 | android:padding="10dp" | ||
| 22 | android:src="@mipmap/icon_back" /> | ||
| 23 | </androidx.appcompat.widget.Toolbar> | ||
| 24 | |||
| 25 | <FrameLayout | ||
| 26 | android:background="@color/white" | ||
| 27 | android:padding="8dp" | ||
| 28 | android:layout_margin="16dp" | ||
| 29 | android:layout_width="match_parent" | ||
| 30 | android:layout_height="0px" | ||
| 31 | android:layout_weight="1"> | ||
| 32 | <ImageView | ||
| 33 | android:id="@+id/ivPic" | ||
| 34 | android:layout_width="match_parent" | ||
| 35 | android:layout_height="match_parent"/> | ||
| 36 | <FrameLayout | ||
| 37 | android:id="@+id/flRects" | ||
| 38 | android:layout_width="match_parent" | ||
| 39 | android:layout_height="match_parent" /> | ||
| 40 | </FrameLayout> | ||
| 41 | |||
| 42 | </LinearLayout> |
app/src/main/res/layout/layout_judge_rect.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | android:orientation="vertical" | ||
| 6 | android:background="@drawable/bg_judge_cut" | ||
| 7 | android:minWidth="160dp" | ||
| 8 | android:minHeight="48dp" | ||
| 9 | android:layout_width="wrap_content" | ||
| 10 | android:layout_height="wrap_content" | ||
| 11 | tools:ignore="UseCompoundDrawables,HardcodedText,SmallSp,ContentDescription"> | ||
| 12 | |||
| 13 | <ImageView | ||
| 14 | android:id="@+id/ivResult" | ||
| 15 | tools:src="@drawable/png_ic_judge_correct" | ||
| 16 | android:layout_gravity="end" | ||
| 17 | android:layout_margin="8dp" | ||
| 18 | android:layout_width="12dp" | ||
| 19 | android:layout_height="12dp"/> | ||
| 20 | |||
| 21 | <ImageView | ||
| 22 | android:src="@drawable/ic_judge_rect_select" | ||
| 23 | android:layout_gravity="center" | ||
| 24 | android:layout_width="12dp" | ||
| 25 | android:layout_height="12dp"/> | ||
| 26 | |||
| 27 | </FrameLayout> |