Commit 09211cd4 authored by Max Lv's avatar Max Lv

Clean up

parent 0030d8aa
......@@ -53,10 +53,6 @@ class Subscription {
abstract fun compareNonNull(o1: T, o2: T): Int
}
private open class DefaultSorter<T : Comparable<T>> : BaseSorter<T>() {
override fun compareNonNull(o1: T, o2: T): Int = o1.compareTo(o2)
}
private object URLSorter : BaseSorter<URL>() {
private val ordering = compareBy<URL>({ it.host }, { it.port }, { it.file }, { it.protocol })
override fun compareNonNull(o1: URL, o2: URL): Int = ordering.compare(o1, o2)
......
......@@ -55,6 +55,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import me.zhanghai.android.materialprogressbar.MaterialProgressBar
import java.io.IOException
import java.net.HttpURLConnection
import java.net.MalformedURLException
import java.net.URL
......@@ -68,7 +69,6 @@ class SubscriptionFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener
private const val SELECTED_URLS = "com.github.shadowsocks.acl.subscription.SELECTED_URLS"
}
@Parcelize
data class SubItem(val item: String = "") : Parcelable {
fun toURL() = URL(item)
......@@ -155,7 +155,8 @@ class SubscriptionFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener
override fun onClick(v: View?) {
if (selectedItems.isNotEmpty()) onLongClick(v)
else SubDialogFragment().withArg(SubItem(item.toString())).show(this@SubscriptionFragment, REQUEST_CODE_EDIT)
else SubDialogFragment().withArg(SubItem(item.toString()))
.show(this@SubscriptionFragment, REQUEST_CODE_EDIT)
}
override fun onLongClick(v: View?): Boolean {
......@@ -246,7 +247,7 @@ class SubscriptionFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener
try {
for (url in subscription.urls.asIterable()) {
val connection = url.openConnection() as HttpURLConnection
ProfileManager.createProfilesFromJson(sequenceOf(connection.inputStream),replace = true)
ProfileManager.createProfilesFromJson(sequenceOf(connection.inputStream), replace = true)
}
} catch (e: Exception) {
e.printStackTrace()
......
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