aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-11-12 04:03:41 -0500
committerGitHub <noreply@github.com>2017-11-12 04:03:41 -0500
commit4aed05a8923a7f76799bbaa254f407f7e11fef0b (patch)
treebadd20ad111989ce7bbeed3f7e9ed8df47b94331 /app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
parent2b51bc4bfa86863ed14b550fe3281840587ab038 (diff)
downloadfrost-4aed05a8923a7f76799bbaa254f407f7e11fef0b.tar.gz
frost-4aed05a8923a7f76799bbaa254f407f7e11fef0b.tar.bz2
frost-4aed05a8923a7f76799bbaa254f407f7e11fef0b.zip
Translations (#482)
* Update translators * Remove translation for some other texts * Update kau * Fix build and optimize * Add translations * Update readme and changelog * Clean unnecessary strings * Fix translations * Add korean translations for kau
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt49
1 files changed, 26 insertions, 23 deletions
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 d4c30547..442d98d8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -27,6 +27,7 @@ import android.webkit.WebChromeClient
import android.widget.FrameLayout
import ca.allanwang.kau.searchview.SearchItem
import ca.allanwang.kau.searchview.SearchView
+import ca.allanwang.kau.searchview.SearchViewHolder
import ca.allanwang.kau.searchview.bindSearchView
import ca.allanwang.kau.utils.*
import co.zsmb.materialdrawerkt.builders.Builder
@@ -47,7 +48,7 @@ import com.pitchedapps.frost.R
import com.pitchedapps.frost.contracts.ActivityWebContract
import com.pitchedapps.frost.contracts.FileChooserContract
import com.pitchedapps.frost.contracts.FileChooserDelegate
-import com.pitchedapps.frost.contracts.VideoViewerContract
+import com.pitchedapps.frost.contracts.VideoViewHolder
import com.pitchedapps.frost.dbflow.loadFbCookie
import com.pitchedapps.frost.dbflow.loadFbTabs
import com.pitchedapps.frost.enums.MainActivityLayout
@@ -76,7 +77,7 @@ import java.util.concurrent.TimeUnit
class MainActivity : BaseActivity(),
ActivityWebContract, FileChooserContract by FileChooserDelegate(),
- VideoViewerContract,
+ VideoViewHolder, SearchViewHolder,
FrostBilling by IabMain() {
lateinit var adapter: SectionsPagerAdapter
@@ -99,7 +100,7 @@ class MainActivity : BaseActivity(),
L.i("First fragment load has finished")
field = value
}
- var searchView: SearchView? = null
+ override var searchView: SearchView? = null
private val searchViewCache = mutableMapOf<String, List<SearchItem>>()
companion object {
@@ -340,27 +341,29 @@ class MainActivity : BaseActivity(),
setMenuIcons(menu, Prefs.iconColor,
R.id.action_settings to GoogleMaterial.Icon.gmd_settings,
R.id.action_search to GoogleMaterial.Icon.gmd_search)
- if (searchView == null) searchView = bindSearchView(menu, R.id.action_search, Prefs.iconColor) {
- textCallback = { query, _ ->
- val results = searchViewCache[query]
- if (results != null)
- runOnUiThread { searchView?.results = results }
- else
- doAsync {
- val data = SearchParser.query(query) ?: return@doAsync
- val items = data.map { SearchItem(it.href, it.title, it.description) }.toMutableList()
- if (items.isNotEmpty())
- items.add(SearchItem("${FbItem._SEARCH.url}?q=$query", string(R.string.show_all_results), iicon = null))
- searchViewCache.put(query, items)
- uiThread { searchView?.results = items }
- }
+ searchViewBindIfNull {
+ bindSearchView(menu, R.id.action_search, Prefs.iconColor) {
+ textCallback = { query, _ ->
+ val results = searchViewCache[query]
+ if (results != null)
+ runOnUiThread { searchView?.results = results }
+ else
+ doAsync {
+ val data = SearchParser.query(query) ?: return@doAsync
+ val items = data.map { SearchItem(it.href, it.title, it.description) }.toMutableList()
+ if (items.isNotEmpty())
+ items.add(SearchItem("${FbItem._SEARCH.url}?q=$query", string(R.string.show_all_results), iicon = null))
+ searchViewCache.put(query, items)
+ uiThread { searchView?.results = items }
+ }
+ }
+ textDebounceInterval = 300
+ searchCallback = { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query"); true }
+ closeListener = { _ -> searchViewCache.clear() }
+ foregroundColor = Prefs.textColor
+ backgroundColor = Prefs.bgColor.withMinAlpha(200)
+ onItemClick = { _, key, _, _ -> launchWebOverlay(key) }
}
- textDebounceInterval = 300
- searchCallback = { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query"); true }
- closeListener = { _ -> searchViewCache.clear() }
- foregroundColor = Prefs.textColor
- backgroundColor = Prefs.bgColor.withMinAlpha(200)
- onItemClick = { _, key, _, _ -> launchWebOverlay(key) }
}
return true
}