Commit 642f4ded authored by Max Lv's avatar Max Lv

shuffle dns records

parent bb9c0dab
...@@ -42,9 +42,9 @@ import android.content._ ...@@ -42,9 +42,9 @@ import android.content._
import android.content.res.AssetManager import android.content.res.AssetManager
import android.graphics.Typeface import android.graphics.Typeface
import android.os._ import android.os._
import android.preference.{CheckBoxPreference, Preference, PreferenceManager} import android.preference.{Preference, PreferenceManager}
import android.util.Log import android.util.Log
import android.view.{ViewGroup, ViewParent, KeyEvent} import android.view.{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
......
...@@ -41,7 +41,6 @@ import android.content.{Intent, SharedPreferences, Context} ...@@ -41,7 +41,6 @@ import android.content.{Intent, SharedPreferences, Context}
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.graphics.drawable.{BitmapDrawable, Drawable} import android.graphics.drawable.{BitmapDrawable, Drawable}
import android.os.Environment
import android.util.Log import android.util.Log
import java.io._ import java.io._
import java.net.{UnknownHostException, InetAddress, NetworkInterface} import java.net.{UnknownHostException, InetAddress, NetworkInterface}
...@@ -264,8 +263,9 @@ object Utils { ...@@ -264,8 +263,9 @@ object Utils {
val resolver = new SimpleResolver("8.8.8.8") val resolver = new SimpleResolver("8.8.8.8")
resolver.setTimeout(5) resolver.setTimeout(5)
lookup.setResolver(resolver) lookup.setResolver(resolver)
val records = lookup.run() val result = lookup.run()
if (records == null) return None if (result == null) return None
val records = scala.util.Random.shuffle(result.toList)
for (r <- records) { for (r <- records) {
addrType match { addrType match {
case Type.A => case Type.A =>
...@@ -426,8 +426,10 @@ object Utils { ...@@ -426,8 +426,10 @@ object Utils {
} }
def drawableToBitmap(drawable: Drawable): Bitmap = { def drawableToBitmap(drawable: Drawable): Bitmap = {
if (drawable.isInstanceOf[BitmapDrawable]) { drawable match {
return drawable.asInstanceOf[BitmapDrawable].getBitmap case d: BitmapDrawable =>
return d.getBitmap
case _ =>
} }
val width = if (drawable.getIntrinsicWidth > 0) drawable.getIntrinsicWidth else 1 val width = if (drawable.getIntrinsicWidth > 0) drawable.getIntrinsicWidth else 1
......
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