Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Fix mysterious button
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-TSNG committed Feb 9, 2022
1 parent eeba6d1 commit b299ffd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "icu.nullptr.twifucker"
minSdk = 24
targetSdk = 32
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "1.0.1"
}

signingConfigs.create("config") {
Expand Down Expand Up @@ -47,7 +47,7 @@ android {
}

dependencies {
implementation("com.github.kyuubiran:EzXHelper:0.6.1")
implementation("com.github.kyuubiran:EzXHelper:0.6.2")

compileOnly("de.robv.android.xposed:api:82")
compileOnly("de.robv.android.xposed:api:82:sources")
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/icu/nullptr/twifucker/AdHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ private val OnLayoutChangeListener = View.OnLayoutChangeListener { v, _, _, _, _
handleView(v as ViewGroup, false)
}

private fun ViewGroup.isAd() = findViewById<View>(AdTextId)?.visibility == View.VISIBLE

private fun handleView(viewGroup: ViewGroup, delayed: Boolean) {
val isAd = viewGroup.findViewById<View>(AdTextId)?.visibility == View.VISIBLE
val isAd = viewGroup.isAd()
if (isAd) Log.i("Handle Ad")
if (delayed) viewGroup.visibility = if (isAd) View.GONE else View.VISIBLE
else {
Expand All @@ -39,8 +41,10 @@ fun adHook() {
vg.removeOnLayoutChangeListener(OnLayoutChangeListener)
vg.addOnLayoutChangeListener(OnLayoutChangeListener)

Handler(Looper.getMainLooper()).post {
handleView(vg, true)
if (vg.isAd()) {
Handler(Looper.getMainLooper()).post {
handleView(vg, true)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
maven("https://jitpack.io")
}
dependencies {
classpath("com.android.tools.build:gradle:7.1.0")
classpath("com.android.tools.build:gradle:7.1.1")
}
}

Expand Down

0 comments on commit b299ffd

Please sign in to comment.