修复 任务管理崩溃的Bug

修复 id有关选择器报错的Bug
修复 engines.myEngine()报错的Bug
This commit is contained in:
hyb1996
2018-12-01 10:20:33 +08:00
parent a38bc53b61
commit 25ca819fa7
11 changed files with 158 additions and 21 deletions

View File

@@ -0,0 +1,133 @@
package androidx.recyclerview.widget
import android.content.Context
import android.os.Build.VERSION
import android.util.AttributeSet
import android.widget.EdgeEffect
import androidx.annotation.Nullable
import androidx.core.widget.EdgeEffectCompat
import com.stardust.theme.ThemeColor
import com.stardust.theme.ThemeColorManager
import com.stardust.theme.ThemeColorMutable
import java.lang.reflect.Field
open class ThemeColorRecyclerView : RecyclerView, ThemeColorMutable {
private var mLeftGlowField: Field? = null
private var mTopGlowField: Field? = null
private var mRightGlowField: Field? = null
private var mBottomGlowField: Field? = null
private var mEdgeEffectField: Field? = null
private var mColorPrimary: Int = 0
private var hasAppliedThemeColorLeft: Boolean = false
private var hasAppliedThemeColorTop: Boolean = false
private var hasAppliedThemeColorRight: Boolean = false
private var hasAppliedThemeColorBottom: Boolean = false
constructor(context: Context) : super(context) {
this.init()
}
constructor(context: Context, @Nullable attrs: AttributeSet) : super(context, attrs) {
this.init()
}
constructor(context: Context, @Nullable attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
this.init()
}
private fun applyThemeColor(edgeEffectCompatField: Field?): Boolean {
try {
val edgeEffectCompat = edgeEffectCompatField?.get(this) as EdgeEffectCompat?
if (edgeEffectCompat != null) {
return this.setEdgeEffectColor(edgeEffectCompat, this.mColorPrimary)
}
} catch (var3: Exception) {
}
return false
}
private fun init() {
try {
this.mEdgeEffectField = EdgeEffectCompat::class.java.getDeclaredField("mEdgeEffect")
this.mEdgeEffectField!!.isAccessible = true
this.mLeftGlowField = RecyclerView::class.java.getDeclaredField("mLeftGlow")
this.mLeftGlowField!!.isAccessible = true
this.mRightGlowField = RecyclerView::class.java.getDeclaredField("mRightGlow")
this.mRightGlowField!!.isAccessible = true
this.mTopGlowField = RecyclerView::class.java.getDeclaredField("mTopGlow")
this.mTopGlowField!!.isAccessible = true
this.mBottomGlowField = RecyclerView::class.java.getDeclaredField("mBottomGlow")
this.mBottomGlowField!!.isAccessible = true
} catch (var2: Exception) {
var2.printStackTrace()
}
ThemeColorManager.add(this)
}
private fun setEdgeEffectColor(compat: EdgeEffectCompat?, color: Int): Boolean {
return if (compat == null) {
false
} else {
try {
if (VERSION.SDK_INT >= 21) {
val edgeEffect = this.mEdgeEffectField!!.get(compat) as EdgeEffect
edgeEffect.color = color
}
true
} catch (var4: Exception) {
true
}
}
}
override fun setThemeColor(color: ThemeColor) {
if (color.colorPrimary != this.mColorPrimary) {
this.mColorPrimary = color.colorPrimary
this.invalidateGlows()
}
}
internal override fun invalidateGlows() {
super.invalidateGlows()
this.hasAppliedThemeColorTop = false
this.hasAppliedThemeColorRight = this.hasAppliedThemeColorTop
this.hasAppliedThemeColorLeft = this.hasAppliedThemeColorRight
this.hasAppliedThemeColorBottom = this.hasAppliedThemeColorLeft
}
internal override fun ensureLeftGlow() {
super.ensureLeftGlow()
if (!this.hasAppliedThemeColorLeft) {
this.hasAppliedThemeColorLeft = this.applyThemeColor(this.mLeftGlowField)
}
}
internal override fun ensureRightGlow() {
super.ensureLeftGlow()
if (!this.hasAppliedThemeColorRight) {
this.hasAppliedThemeColorRight = this.applyThemeColor(this.mRightGlowField)
}
}
internal override fun ensureTopGlow() {
super.ensureTopGlow()
if (!this.hasAppliedThemeColorTop) {
this.hasAppliedThemeColorTop = this.applyThemeColor(this.mTopGlowField)
}
}
internal override fun ensureBottomGlow() {
super.ensureBottomGlow()
if (!this.hasAppliedThemeColorBottom) {
this.hasAppliedThemeColorBottom = this.applyThemeColor(this.mBottomGlowField)
}
}
}

View File

@@ -5,7 +5,6 @@ import android.graphics.drawable.GradientDrawable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.appcompat.widget.ThemeColorRecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
@@ -34,6 +33,7 @@ import org.autojs.autojs.ui.timing.TimedTaskSettingActivity_;
import java.util.ArrayList;
import java.util.List;
import androidx.recyclerview.widget.ThemeColorRecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

View File

@@ -3,7 +3,8 @@ package org.autojs.autojs.ui.widget;
import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import androidx.appcompat.widget.ThemeColorRecyclerView;
import androidx.recyclerview.widget.ThemeColorRecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;