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

shuffle dns records

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