diff options
author | Allan Wang <me@allanwang.ca> | 2017-05-31 17:11:46 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-05-31 17:11:46 -0700 |
commit | 8618670b82641d5fbaec9c333f1290bab429ce27 (patch) | |
tree | 737c9a04f108ea68547eef2db1ae6e96caa64df6 /app/src/main/kotlin/com/pitchedapps/frost/fragments | |
parent | 9a41937a33539dbfaae4d072361caaec79865c29 (diff) | |
download | frost-8618670b82641d5fbaec9c333f1290bab429ce27.tar.gz frost-8618670b82641d5fbaec9c333f1290bab429ce27.tar.bz2 frost-8618670b82641d5fbaec9c333f1290bab429ce27.zip |
add more cookie handling
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/fragments')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt | 21 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt | 23 |
2 files changed, 9 insertions, 35 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt index 435b87a2..cb3bb713 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt @@ -12,12 +12,10 @@ import io.reactivex.functions.Consumer * Created by Allan Wang on 2017-05-29. */ interface BaseFragmentContract { - fun onActivityEvent(position: Int, key: Int) fun onBackPressed(): Boolean } -abstract class BaseFragment : Fragment(), Consumer<Pair<Int, Int>>, BaseFragmentContract { - var disposable: Disposable? = null +abstract class BaseFragment : Fragment(), BaseFragmentContract { val position: Int by lazy { arguments.getInt(ARG_POSITION) } companion object { @@ -29,21 +27,4 @@ abstract class BaseFragment : Fragment(), Consumer<Pair<Int, Int>>, BaseFragment } } - override fun onAttach(context: Context?) { - super.onAttach(context) - if (activity is KeyPairObservable && disposable == null) - disposable = (activity as KeyPairObservable).observable.subscribe(this, Consumer { - t: Throwable -> - L.e(t.message ?: "Observable error") - }) - } - - override fun onDestroyView() { - disposable?.dispose() - disposable = null - super.onDestroyView() - } - - override fun accept(t: Pair<Int, Int>) = onActivityEvent(t.first, t.second) - }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt index d7bf4061..ba9584eb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt @@ -8,13 +8,10 @@ import android.view.ViewGroup import butterknife.ButterKnife import butterknife.Unbinder import com.pitchedapps.frost.R -import com.pitchedapps.frost.facebook.FbUrl -import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.bindView import com.pitchedapps.frost.utils.putString -import com.pitchedapps.frost.views.FrostWebView -import com.pitchedapps.frost.views.SwipeRefreshBase -import com.pitchedapps.frost.views.WebStatus +import com.pitchedapps.frost.web.FrostWebView +import com.pitchedapps.frost.web.WebStatus /** * Created by Allan Wang on 2017-05-29. @@ -23,10 +20,6 @@ import com.pitchedapps.frost.views.WebStatus class WebFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener { - override fun onActivityEvent(position: Int, key: Int) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - override fun onRefresh() { web.reload() } @@ -34,10 +27,9 @@ class WebFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener { companion object { private val ARG_URL = "arg_url" fun newInstance(position: Int, url: String) = BaseFragment.newInstance(WebFragment(), position).putString(ARG_URL, url) - fun newInstance(position: Int, url: FbUrl = FbUrl.FEED) = newInstance(position, url.url) } - val refresh: SwipeRefreshBase by bindView(R.id.swipe_refresh) + val refresh: SwipeRefreshLayout by bindView(R.id.swipe_refresh) val web: FrostWebView by bindView(R.id.frost_webview) lateinit var url: String private lateinit var unbinder: Unbinder @@ -56,6 +48,7 @@ class WebFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener { override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + web.baseUrl = url web.observable.subscribe { t: WebStatus -> when (t) { @@ -64,10 +57,10 @@ class WebFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener { } } refresh.setOnRefreshListener(this) - refresh.shouldSwipe = { - L.e("Y ${web.scrollY}") - SwipeRefreshBase.shouldScroll(web) - } +// refresh.shouldSwipe = { +// L.e("Y ${web.scrollY}") +// SwipeRefreshBase.shouldScroll(web) +// } web.loadUrl(url) } |