aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-09-27 19:56:25 -0400
committerAllan Wang <me@allanwang.ca>2018-09-27 19:56:25 -0400
commit3aa44ba16e52ceaf37dd28a8075b302c42785526 (patch)
treef072ae062c404c0d87cb7cbc4aeb4d23e604a3e6
parentd3e11bbaaf497682f2e62a20b2866e2b05b8ba16 (diff)
downloadfrost-3aa44ba16e52ceaf37dd28a8075b302c42785526.tar.gz
frost-3aa44ba16e52ceaf37dd28a8075b302c42785526.tar.bz2
frost-3aa44ba16e52ceaf37dd28a8075b302c42785526.zip
Fix more lints
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbRegex.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt2
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/MiscTest.kt10
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbFullImageTest.kt3
11 files changed, 21 insertions, 20 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
index 08728ae4..3ac8c6ce 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
@@ -8,7 +8,6 @@ import com.pitchedapps.frost.contracts.VideoViewHolder
import com.pitchedapps.frost.utils.setFrostTheme
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
-import io.reactivex.rxkotlin.addTo
/**
* Created by Allan Wang on 2017-06-12.
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 1ed71622..4d92cbcb 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -52,11 +52,11 @@ import com.pitchedapps.frost.dbflow.loadFbTabs
import com.pitchedapps.frost.enums.MainActivityLayout
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.facebook.FbItem
+import com.pitchedapps.frost.facebook.parsers.FrostSearch
+import com.pitchedapps.frost.facebook.parsers.SearchParser
import com.pitchedapps.frost.facebook.profilePictureUrl
import com.pitchedapps.frost.fragments.BaseFragment
import com.pitchedapps.frost.fragments.WebFragment
-import com.pitchedapps.frost.facebook.parsers.FrostSearch
-import com.pitchedapps.frost.facebook.parsers.SearchParser
import com.pitchedapps.frost.utils.*
import com.pitchedapps.frost.views.BadgedIcon
import com.pitchedapps.frost.views.FrostVideoViewer
@@ -378,7 +378,8 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
super.onRestoreInstanceState(savedInstanceState)
adapter.forcedFallbacks.clear()
- adapter.forcedFallbacks.addAll(savedInstanceState.getStringArrayList(STATE_FORCE_FALLBACK) ?: emptyList())
+ adapter.forcedFallbacks.addAll(savedInstanceState.getStringArrayList(STATE_FORCE_FALLBACK)
+ ?: emptyList())
}
override fun onResume() {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt
index 8be9c847..4b00c242 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt
@@ -106,11 +106,14 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On
ripple.ripple(blue, x, y, 600) {
postDelayed(1000) { finish() }
}
- arrayOf(skip, indicator, next, fragments.last().view?.find<View>(R.id.intro_title), fragments.last().view?.find<View>(R.id.intro_desc)).forEach {
+ val lastView: View? = fragments.last().view
+ arrayOf<View?>(skip, indicator, next,
+ lastView?.find(R.id.intro_title),
+ lastView?.find(R.id.intro_desc)).forEach {
it?.animate()?.alpha(0f)?.setDuration(600)?.start()
}
if (Prefs.textColor != Color.WHITE) {
- val f = fragments.last().view?.find<ImageView>(R.id.intro_image)?.drawable
+ val f = lastView?.find<ImageView>(R.id.intro_image)?.drawable
if (f != null)
ValueAnimator.ofFloat(0f, 1f).apply {
addUpdateListener {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 6b5b2021..11ed4525 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -6,8 +6,6 @@ import android.support.v4.view.ViewPager
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.views.BadgedIcon
import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.disposables.CompositeDisposable
-import io.reactivex.rxkotlin.addTo
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import org.jsoup.Jsoup
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt
index ca6df366..1182e609 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/ActivityContract.kt
@@ -1,6 +1,7 @@
package com.pitchedapps.frost.contracts
import com.mikepenz.iconics.typeface.IIcon
+import com.pitchedapps.frost.activities.MainActivity
import com.pitchedapps.frost.fragments.BaseFragment
import io.reactivex.subjects.PublishSubject
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbRegex.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbRegex.kt
index cfa2796c..05467dfa 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbRegex.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbRegex.kt
@@ -1,5 +1,7 @@
package com.pitchedapps.frost.facebook
+import org.apache.commons.text.StringEscapeUtils
+
/**
* Created by Allan Wang on 21/12/17.
*
@@ -22,7 +24,7 @@ val FB_USER_MATCHER: Regex by lazy { Regex("c_user=([0-9]*);") }
val FB_EPOCH_MATCHER: Regex by lazy { Regex(":([0-9]+)") }
val FB_NOTIF_ID_MATCHER: Regex by lazy { Regex("notif_([0-9]+)") }
-val FB_MESSAGE_NOTIF_ID_MATCHER: Regex by lazy { Regex("[thread|user]_fbid_([0-9]+)") }
+val FB_MESSAGE_NOTIF_ID_MATCHER: Regex by lazy { Regex("(?:thread|user)_fbid_([0-9]+)") }
val FB_CSS_URL_MATCHER: Regex by lazy { Regex("url\\([\"|']?(.*?)[\"|']?\\)") }
val FB_JSON_URL_MATCHER: Regex by lazy { Regex("\"(http.*?)\"") }
val FB_IMAGE_ID_MATCHER: Regex by lazy { Regex("fbcdn.*?/[0-9]+_([0-9]+)_") }
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt
index 5d023023..90d2a214 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/FrostParser.kt
@@ -116,7 +116,7 @@ internal abstract class FrostParserBase<out T : Any>(private val redirectToText:
protected fun Elements.getStyleUrl() =
FB_CSS_URL_MATCHER.find(attr("style"))[1]?.formattedFbUrl
- protected open fun textToDoc(text: String) = if (!redirectToText)
+ protected open fun textToDoc(text: String): Document = if (!redirectToText)
Jsoup.parse(text)
else
throw RuntimeException("${this::class.java.simpleName} requires text redirect but did not implement textToDoc")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt
index e3b8f3d3..4f9133a6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt
@@ -47,7 +47,7 @@ abstract class GenericRecyclerFragment<T, Item : IItem<*, *>> : RecyclerFragment
abstract fun mapper(data: T): Item
- val adapter: ModelAdapter<T, Item> = ModelAdapter(this::mapper)
+ val adapter: ModelAdapter<T, Item> = ModelAdapter { this.mapper(it) }
final override fun bind(recyclerView: FrostRecyclerView) {
recyclerView.adapter = getAdapter()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt
index 72e448b9..4e4df027 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt
@@ -23,7 +23,7 @@ fun WebView.shouldFrostInterceptRequest(request: WebResourceRequest): WebResourc
val host = httpUrl.host()
val url = httpUrl.toString()
if (host.contains("facebook") || host.contains("fbcdn")) return null
- if (FrostPglAdBlock.isAdHost(host)) return blankResource
+ if (FrostPglAdBlock.isAd(host)) return blankResource
// if (!shouldLoadImages && !Prefs.loadMediaOnMeteredNetwork && request.isMedia) return blankResource
L.v { "Intercept Request: $host $url" }
return null
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/MiscTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/MiscTest.kt
index 2be743a3..d730b933 100644
--- a/app/src/test/kotlin/com/pitchedapps/frost/MiscTest.kt
+++ b/app/src/test/kotlin/com/pitchedapps/frost/MiscTest.kt
@@ -1,7 +1,6 @@
package com.pitchedapps.frost
import com.pitchedapps.frost.facebook.requests.zip
-import com.pitchedapps.frost.injectors.CssHider
import org.junit.Test
import kotlin.test.assertTrue
@@ -19,10 +18,11 @@ class MiscTest {
fun zip() {
val now = System.currentTimeMillis()
val base = 1
- val data = (0..15).map { Math.random() + base }.toTypedArray().zip(
- List<Long>::toLongArray,
- { Thread.sleep((it * 1000).toLong()); System.currentTimeMillis() - now }
- ).blockingGet()
+ val data: LongArray = (0..15).map { Math.random() + base }
+ .toTypedArray().zip(List<Long>::toLongArray) {
+ Thread.sleep((it * 1000).toLong())
+ System.currentTimeMillis() - now
+ }.blockingGet()
println(data.contentToString())
assertTrue(data.all { it >= base * 1000 && it < base * 1000 * 5 },
"zip did not seem to work on different threads")
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbFullImageTest.kt b/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbFullImageTest.kt
index 291637c6..c4e51d41 100644
--- a/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbFullImageTest.kt
+++ b/app/src/test/kotlin/com/pitchedapps/frost/facebook/requests/FbFullImageTest.kt
@@ -1,13 +1,10 @@
package com.pitchedapps.frost.facebook.requests
-import com.pitchedapps.frost.facebook.requests.getFullSizedImage
-import com.pitchedapps.frost.facebook.requests.getFullSizedImageUrl
import com.pitchedapps.frost.internal.COOKIE
import com.pitchedapps.frost.internal.authDependent
import org.junit.BeforeClass
import org.junit.Test
import kotlin.test.assertNotNull
-import kotlin.test.assertTrue
/**
* Created by Allan Wang on 12/04/18.