Commit 6522898f authored by Max Lv's avatar Max Lv

fix for tablet

parent aa0d9442
...@@ -44,7 +44,7 @@ import android.graphics.Typeface ...@@ -44,7 +44,7 @@ import android.graphics.Typeface
import android.os._ import android.os._
import android.preference.{CheckBoxPreference, Preference, PreferenceManager} import android.preference.{CheckBoxPreference, Preference, PreferenceManager}
import android.util.Log import android.util.Log
import android.view.{ViewParent, KeyEvent} import android.view.{ViewGroup, ViewParent, KeyEvent}
import android.widget.{LinearLayout, CompoundButton, RelativeLayout, TextView} import android.widget.{LinearLayout, CompoundButton, RelativeLayout, TextView}
import com.actionbarsherlock.view.Menu import com.actionbarsherlock.view.Menu
import com.actionbarsherlock.view.MenuItem import com.actionbarsherlock.view.MenuItem
...@@ -384,17 +384,20 @@ class Shadowsocks ...@@ -384,17 +384,20 @@ class Shadowsocks
if (settings.getString(Key.proxy, "") == "198.199.101.152") { if (settings.getString(Key.proxy, "") == "198.199.101.152") {
val adView = new AdView(this, AdSize.SMART_BANNER, "a151becb8068b09") val adView = new AdView(this, AdSize.SMART_BANNER, "a151becb8068b09")
val rootView = findViewById(android.R.id.content).asInstanceOf[ViewParent]
val layoutView = { val layoutView = {
def getLayoutView(view: ViewParent): LinearLayout = { def getLayoutView(view: ViewParent): LinearLayout = {
view match { view match {
case layout: LinearLayout => layout case layout: LinearLayout => layout
case _ => getLayoutView(view.getParent) case _ => if (view != null) getLayoutView(view.getParent) else null
} }
} }
getLayoutView(getListView) getLayoutView(rootView)
}
if (layoutView != null) {
layoutView.addView(adView, 0)
adView.loadAd(new AdRequest)
} }
layoutView.addView(adView, 0)
adView.loadAd(new AdRequest)
} }
val init: Boolean = !Shadowsocks.isServiceStarted(this) val init: Boolean = !Shadowsocks.isServiceStarted(this)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment