From 5aac1cda7b1ad561131de109d1f29e8e7b730e82 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 4 Jun 2017 10:49:22 -0700 Subject: Remove positions in WebFragment --- .../kotlin/com/pitchedapps/frost/MainActivity.kt | 2 +- .../pitchedapps/frost/fragments/BaseFragment.kt | 31 ---------------------- .../com/pitchedapps/frost/fragments/WebFragment.kt | 8 +++--- .../com/pitchedapps/frost/web/FrostWebView.kt | 5 ---- .../com/pitchedapps/frost/web/FrostWebViewCore.kt | 1 - 5 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt (limited to 'app/src/main/kotlin/com') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt index 24497d1c..fa666aa4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt @@ -167,7 +167,7 @@ class MainActivity : BaseLeakActivity() { inner class SectionsPagerAdapter(fm: FragmentManager, val pages: List) : FragmentPagerAdapter(fm) { - override fun getItem(position: Int) = WebFragment.newInstance(position, pages[position].url) + override fun getItem(position: Int) = WebFragment.newInstance(pages[position].url) override fun getCount() = pages.size diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt deleted file mode 100644 index 4ca45d86..00000000 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/BaseFragment.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.pitchedapps.frost.fragments - -import android.support.annotation.CallSuper -import android.support.v4.app.Fragment -import com.pitchedapps.frost.utils.putInt -import com.pitchedapps.frost.utils.refWatch - -/** - * Created by Allan Wang on 2017-05-29. - */ -interface BaseFragmentContract { - fun onBackPressed(): Boolean -} - -abstract class BaseFragment : Fragment(), BaseFragmentContract { - val position: Int by lazy { arguments.getInt(ARG_POSITION) } - - companion object { - val ARG_POSITION = "arg_position" - - fun newInstance(fragment: T, position: Int): T { - fragment.putInt(ARG_POSITION, position) - return fragment - } - } - -// override fun onDestroyView() { -// super.onDestroyView() -// refWatch() -// } -} \ 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 3c8094aa..3882260e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragment.kt @@ -2,6 +2,7 @@ package com.pitchedapps.frost.fragments import android.content.Context import android.os.Bundle +import android.support.v4.app.Fragment import android.support.v4.widget.SwipeRefreshLayout import android.view.LayoutInflater import android.view.View @@ -18,11 +19,11 @@ import io.reactivex.disposables.Disposable */ -class WebFragment : BaseFragment() { +class WebFragment:Fragment() { companion object { private const val ARG_URL = "arg_url" - fun newInstance(position: Int, url: String) = BaseFragment.newInstance(WebFragment(), position).putString(ARG_URL, url) + fun newInstance(url: String) = WebFragment().putString(ARG_URL, url) } // val refresh: SwipeRefreshLayout by lazy { frostWebView.refresh } @@ -40,7 +41,6 @@ class WebFragment : BaseFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { super.onCreateView(inflater, container, savedInstanceState) frostWebView = FrostWebView(context) - frostWebView.position = position frostWebView.baseUrl = url return frostWebView } @@ -78,5 +78,5 @@ class WebFragment : BaseFragment() { super.onDetach() } - override fun onBackPressed() = frostWebView.onBackPressed() + fun onBackPressed() = frostWebView.onBackPressed() } \ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt index c5ac03ae..f9deb3b8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt @@ -27,11 +27,6 @@ class FrostWebView @JvmOverloads constructor(context: Context, attrs: AttributeS val refresh: SwipeRefreshLayout by bindView(R.id.swipe_refresh) val web: FrostWebViewCore by bindView(R.id.frost_webview_core) val progress: ProgressBar by bindView(R.id.progressBar) - var position: Int - get() = web.position - set(value) { - web.position = value - } init { inflate(getContext(), R.layout.swipe_webview, this) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt index ab9a6209..e0fcb9b5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt @@ -43,7 +43,6 @@ class FrostWebViewCore @JvmOverloads constructor( val titleObservable: BehaviorSubject // Only emits on different non http titles var baseUrl: String? = null - var position: Int = -1 init { isNestedScrollingEnabled = true -- cgit v1.2.3