Remove package object
This commit is contained in:
@@ -232,7 +232,7 @@ class AppManager extends AppCompatActivity with OnMenuItemClickListener {
|
||||
def reloadApps() = if (!appsLoading.compareAndSet(true, false)) loadAppsAsync()
|
||||
def loadAppsAsync() {
|
||||
if (!appsLoading.compareAndSet(false, true)) return
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
var adapter: AppsAdapter = null
|
||||
do {
|
||||
appsLoading.set(true)
|
||||
|
||||
@@ -336,7 +336,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
|
||||
}
|
||||
|
||||
def prepareStartService() {
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
if (ShadowsocksApplication.isVpnEnabled) {
|
||||
val intent = VpnService.prepare(this)
|
||||
if (intent != null) {
|
||||
@@ -381,7 +381,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
|
||||
handler.post(() => connectionTestText.setText(R.string.connection_test_testing))
|
||||
testCount
|
||||
}
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
// Based on: https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/connectivity/NetworkMonitor.java#640
|
||||
autoDisconnect(new URL("https", "www.google.com", "/generate_204").openConnection()
|
||||
.asInstanceOf[HttpURLConnection]) { conn =>
|
||||
@@ -562,7 +562,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
|
||||
def recovery() {
|
||||
if (serviceStarted) serviceStop()
|
||||
val h = showProgress(R.string.recovering)
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
reset()
|
||||
h.sendEmptyMessage(0)
|
||||
}
|
||||
@@ -570,7 +570,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
|
||||
|
||||
def flushDnsCache() {
|
||||
val h = showProgress(R.string.flushing)
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
if (!Utils.toggleAirplaneMode(getBaseContext)) h.post(() => Snackbar.make(findViewById(android.R.id.content),
|
||||
R.string.flush_dnscache_no_root, Snackbar.LENGTH_LONG).show)
|
||||
h.sendEmptyMessage(0)
|
||||
|
||||
@@ -359,7 +359,7 @@ class ShadowsocksNatService extends BaseService {
|
||||
|
||||
changeState(State.CONNECTING)
|
||||
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val holder = ShadowsocksApplication.containerHolder
|
||||
try {
|
||||
|
||||
@@ -150,7 +150,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
changeState(State.CONNECTING)
|
||||
|
||||
ThrowableFuture {
|
||||
Utils.ThrowableFuture {
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val holder = ShadowsocksApplication.containerHolder
|
||||
try {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.github
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
import scala.util.{Failure, Try}
|
||||
|
||||
/**
|
||||
* @author Mygod
|
||||
*/
|
||||
package object shadowsocks {
|
||||
private val handleFailure: Try[_] => Unit = {
|
||||
case Failure(e) => e.printStackTrace()
|
||||
case _ =>
|
||||
}
|
||||
|
||||
def ThrowableFuture[T](f: => T) = Future(f) onComplete handleFailure
|
||||
}
|
||||
@@ -54,6 +54,9 @@ import android.widget.Toast
|
||||
import com.github.shadowsocks.{BuildConfig, ShadowsocksApplication, ShadowsocksRunnerService}
|
||||
import org.xbill.DNS._
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
import scala.util.{Failure, Try}
|
||||
|
||||
object Utils {
|
||||
|
||||
@@ -237,4 +240,11 @@ object Utils {
|
||||
val intent = new Intent(Action.CLOSE)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
|
||||
private val handleFailure: Try[_] => Unit = {
|
||||
case Failure(e) => e.printStackTrace()
|
||||
case _ =>
|
||||
}
|
||||
|
||||
def ThrowableFuture[T](f: => T) = Future(f) onComplete handleFailure
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user