aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-30 12:55:56 -0400
committerGitHub <noreply@github.com>2017-08-30 12:55:56 -0400
commit270ff7705be5ec0c78f5eae4934779ff4b4c00ee (patch)
treefb0ba3e117e138391ac268bc8116e97140e6f436 /app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
parenta854dcc471078f4e21916730abb5d5d75dd7b03c (diff)
downloadfrost-270ff7705be5ec0c78f5eae4934779ff4b4c00ee.tar.gz
frost-270ff7705be5ec0c78f5eae4934779ff4b4c00ee.tar.bz2
frost-270ff7705be5ec0c78f5eae4934779ff4b4c00ee.zip
fix/searchview (#239)
* Keep searchview even if headless response fails * Keep searchview even if headless response fails * Update changelog and add search tests * Update kau and remove tests * Remove duplicate dispose calls
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.kt23
1 files changed, 8 insertions, 15 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 29bc350b..dd8ed558 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -143,8 +143,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels)
val delta: Float by lazy { positionOffset * (255 - 128).toFloat() }
- tabsForEachView {
- tabPosition, view ->
+ tabsForEachView { tabPosition, view ->
view.setAllAlpha(when (tabPosition) {
position -> 255.0f - delta
position + 1 -> 128.0f + delta
@@ -163,15 +162,13 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
setFrostColors(toolbar, themeWindow = false, headers = arrayOf(appBar), backgrounds = arrayOf(viewPager))
tabs.setBackgroundColor(Prefs.mainActivityLayout.backgroundColor())
onCreateBilling()
- setNetworkObserver {
- connectivity ->
+ setNetworkObserver { connectivity ->
shouldLoadImages = !connectivity.isRoaming
}
}
fun tabsForEachView(action: (position: Int, view: BadgedIcon) -> Unit) {
- (0 until tabs.tabCount).asSequence().forEach {
- i ->
+ (0 until tabs.tabCount).asSequence().forEach { i ->
action(i, tabs.getTabAt(i)!!.customView as BadgedIcon)
}
}
@@ -200,10 +197,8 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
return@map arrayOf(feed, requests, messages, notifications).map { it?.getOrNull(0)?.ownText() }
}
.observeOn(AndroidSchedulers.mainThread())
- .subscribe {
- (feed, requests, messages, notifications) ->
- tabsForEachView {
- _, view ->
+ .subscribe { (feed, requests, messages, notifications) ->
+ tabsForEachView { _, view ->
when (view.iicon) {
FbItem.FEED.icon -> view.badgeText = feed
FbItem.FRIENDS.icon -> view.badgeText = requests
@@ -340,11 +335,9 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
* Something happened where the normal search function won't work
* Fallback to overlay style
*/
- override fun searchOverlayDispose() {
- hiddenSearchView?.dispose()
+ override fun disposeHeadlessSearch() {
hiddenSearchView = null
- searchView?.unBind { launchWebOverlay(FbItem.SEARCH.url); true }
- searchView = null
+ searchView?.config { textCallback = { _, _ -> } }
}
override fun emitSearchResponse(items: List<SearchItem>) {
@@ -373,7 +366,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
onItemClick = { _, key, _, _ -> launchWebOverlay(key) }
}
} else {
- if (searchView != null) searchOverlayDispose()
+ if (searchView != null) disposeHeadlessSearch()
else menu.findItem(R.id.action_search).setOnMenuItemClickListener { _ -> launchWebOverlay(FbItem.SEARCH.url); true }
}
return true