aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-26 14:54:07 -0700
committerAllan Wang <me@allanwang.ca>2017-06-26 14:54:07 -0700
commit6270c060e4d33db12903e476146456569d260261 (patch)
tree828eb1d6da7ea1dae7b4e08c40cbb7fc08c88846 /app/src/main/kotlin/com
parenta95107d0d10583bfd95495bdc84cc23022b56000 (diff)
downloadfrost-6270c060e4d33db12903e476146456569d260261.tar.gz
frost-6270c060e4d33db12903e476146456569d260261.tar.bz2
frost-6270c060e4d33db12903e476146456569d260261.zip
Test dependencies
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt31
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbSearch.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt10
3 files changed, 29 insertions, 21 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index cccb3e0c..2103a8ee 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -4,10 +4,7 @@ import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.annotation.StringRes
-import android.support.design.widget.AppBarLayout
-import android.support.design.widget.FloatingActionButton
-import android.support.design.widget.Snackbar
-import android.support.design.widget.TabLayout
+import android.support.design.widget.*
import android.support.v4.app.ActivityOptionsCompat
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
@@ -17,6 +14,9 @@ import android.support.v7.widget.Toolbar
import android.view.Menu
import android.view.MenuItem
import ca.allanwang.kau.changelog.showChangelog
+import ca.allanwang.kau.searchview.SearchItem
+import ca.allanwang.kau.searchview.SearchView
+import ca.allanwang.kau.searchview.bindSearchView
import ca.allanwang.kau.utils.*
import co.zsmb.materialdrawerkt.builders.Builder
import co.zsmb.materialdrawerkt.builders.accountHeader
@@ -56,6 +56,7 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract {
val fab: FloatingActionButton by bindView(R.id.fab)
val tabs: TabLayout by bindView(R.id.tabs)
val appBar: AppBarLayout by bindView(R.id.appbar)
+ val coordinator: CoordinatorLayout by bindView(R.id.main_content)
lateinit var drawer: Drawer
lateinit var drawerHeader: AccountHeader
var webFragmentObservable = PublishSubject.create<Int>()!!
@@ -71,6 +72,7 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract {
currentFragment.frostWebView.addView(hiddenSearchView)
}
}
+ var searchView: SearchView? = null
companion object {
const val FRAGMENT_REFRESH = 99
@@ -306,9 +308,8 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract {
//todo remove true searchview and add contract
}
- //todo add args
- override fun emitSearchResponse() {
-
+ override fun emitSearchResponse(items: List<SearchItem>) {
+ searchView?.results = items
}
fun refreshAll() {
@@ -320,6 +321,22 @@ class MainActivity : BaseActivity(), FrostWebViewSearch.SearchContract {
toolbar.tint(Prefs.iconColor)
setMenuIcons(menu, Prefs.iconColor,
R.id.action_settings to GoogleMaterial.Icon.gmd_settings)
+ searchView = coordinator.bindSearchView(menu, R.id.action_search) {
+ textObserver = {
+ observable, _ ->
+ observable.subscribe {
+ hiddenSearchView?.query(it)
+ }
+ }
+ foregroundColor = Prefs.textColor
+ backgroundColor = Prefs.bgColor
+ openListener = {
+ hiddenSearchView?.pauseLoad = false
+ }
+ closeListener = {
+ hiddenSearchView?.pauseLoad = true
+ }
+ }
return true
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbSearch.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbSearch.kt
deleted file mode 100644
index 151957d3..00000000
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbSearch.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.pitchedapps.frost.facebook
-
-/**
- * Created by Allan Wang on 2017-06-26.
- *
- * Handles asynchronous user graph searches
- */
-class FbSearch {
-} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
index 6c9ee9d5..d42ea33e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewSearch.kt
@@ -6,6 +6,7 @@ import android.view.View
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.webkit.WebViewClient
+import ca.allanwang.kau.searchview.SearchItem
import ca.allanwang.kau.utils.gone
import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
@@ -68,11 +69,11 @@ class FrostWebViewSearch(context: Context, val contract: SearchContract) : WebVi
.subscribe {
content: List<Pair<List<String>, String>> ->
saveResultFrame(content)
- content.forEach {
+ contract.emitSearchResponse(content.map {
(texts, href) ->
L.d("Search element $texts $href")
- }
- contract.emitSearchResponse()
+ SearchItem(href, texts[0], texts.getOrNull(1))
+ })
}
reload()
}
@@ -138,8 +139,7 @@ class FrostWebViewSearch(context: Context, val contract: SearchContract) : WebVi
interface SearchContract {
fun searchOverlayError()
- //todo add args
- fun emitSearchResponse()
+ fun emitSearchResponse(items: List<SearchItem>)
}
}