shuffle dns records

This commit is contained in:
Max Lv
2013-06-28 19:09:42 +08:00
parent bb9c0dab0a
commit 642f4dedfc
2 changed files with 9 additions and 7 deletions
@@ -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