fix AdView
This commit is contained in:
@@ -413,28 +413,8 @@ class Shadowsocks
|
||||
}
|
||||
}
|
||||
|
||||
def initAdView() {
|
||||
if (settings.getString(Key.proxy, "") == "198.199.101.152") {
|
||||
val layoutView = {
|
||||
if (Build.VERSION.SDK_INT > 10) {
|
||||
drawer.getContentContainer.getChildAt(0)
|
||||
} else {
|
||||
getLayoutView(drawer.getContentContainer.getParent)
|
||||
}
|
||||
}
|
||||
if (layoutView != null) {
|
||||
val adView = new AdView(this)
|
||||
adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322")
|
||||
adView.setAdSize(AdSize.SMART_BANNER)
|
||||
layoutView.asInstanceOf[ViewGroup].addView(adView, 0)
|
||||
adView.loadAd(new AdRequest.Builder().build())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def setContentView(layoutResId: Int) {
|
||||
drawer.setContentView(layoutResId)
|
||||
initAdView()
|
||||
onContentChanged()
|
||||
}
|
||||
|
||||
@@ -442,7 +422,13 @@ class Shadowsocks
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.layout_main)
|
||||
if (settings.getString(Key.proxy, "") == "198.199.101.152") {
|
||||
setContentView(R.layout.layout_main_ad)
|
||||
val adView = findViewById(R.id.adView).asInstanceOf[AdView]
|
||||
adView.loadAd(new AdRequest.Builder().build())
|
||||
} else {
|
||||
setContentView(R.layout.layout_main)
|
||||
}
|
||||
|
||||
// Update the profile
|
||||
if (!status.getBoolean(getVersionName, false)) {
|
||||
|
||||
Reference in New Issue
Block a user