Commit 8c86be74 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Clear BaseFragment.

parent 23f0900b
......@@ -2,8 +2,10 @@ package ru.terrakok.gitlabclient.extension
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.support.annotation.LayoutRes
import android.support.design.widget.Snackbar
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.view.LayoutInflater
......@@ -148,4 +150,13 @@ fun TargetHeader.openInfo(router: FlowRouter) {
}
}
}
}
fun Fragment.showSnackMessage(message: String) {
view?.let {
val snackbar = Snackbar.make(it, message, Snackbar.LENGTH_LONG)
val messageTextView = snackbar.view.findViewById<TextView>(android.support.design.R.id.snackbar_text)
messageTextView.setTextColor(Color.WHITE)
snackbar.show()
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import kotlinx.android.synthetic.main.fragment_auth.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.BuildConfig
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.auth.AuthPresenter
import ru.terrakok.gitlabclient.presentation.auth.AuthView
......
package ru.terrakok.gitlabclient.ui.global
import android.graphics.Color
import android.os.Bundle
import android.support.design.widget.Snackbar
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.arellomobile.mvp.MvpAppCompatFragment
private const val PROGRESS_TAG = "bf_progress"
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 26.03.17.
*/
abstract class BaseFragment : MvpAppCompatFragment() {
companion object {
private val PROGRESS_TAG = "bf_progress"
}
abstract val layoutRes: Int
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
savedInstanceState?.let { restoreState(it) }
}
open protected fun restoreState(state: Bundle) {}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) =
inflater.inflate(layoutRes, container, false)
......@@ -42,14 +29,5 @@ abstract class BaseFragment : MvpAppCompatFragment() {
}
}
protected fun showSnackMessage(message: String) {
view?.let {
val snackbar = Snackbar.make(it, message, Snackbar.LENGTH_LONG)
val messageTextView = snackbar.view.findViewById<TextView>(android.support.design.R.id.snackbar_text)
messageTextView.setTextColor(Color.WHITE)
snackbar.show()
}
}
open fun onBackPressed() {}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.extension.color
import ru.terrakok.gitlabclient.extension.humanTime
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.presentation.issue.info.IssueInfoPresenter
import ru.terrakok.gitlabclient.presentation.issue.info.IssueInfoView
import ru.terrakok.gitlabclient.toothpick.DI
......
......@@ -7,6 +7,7 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import kotlinx.android.synthetic.main.layout_base_list.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesPresenter
import ru.terrakok.gitlabclient.presentation.issue.notes.IssueNotesView
......
......@@ -6,10 +6,7 @@ import kotlinx.android.synthetic.main.fragment_mr_info.*
import ru.noties.markwon.Markwon
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
import ru.terrakok.gitlabclient.extension.humanTime
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.extension.tint
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.extension.*
import ru.terrakok.gitlabclient.presentation.mergerequest.info.MergeRequestInfoPresenter
import ru.terrakok.gitlabclient.presentation.mergerequest.info.MergeRequestInfoView
import ru.terrakok.gitlabclient.toothpick.DI
......
......@@ -7,6 +7,7 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.hannesdorfmann.adapterdelegates3.ListDelegationAdapter
import kotlinx.android.synthetic.main.layout_base_list.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.presentation.global.NoteWithFormattedBody
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesPresenter
import ru.terrakok.gitlabclient.presentation.mergerequest.notes.MergeRequestNotesView
......
......@@ -9,6 +9,7 @@ import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.my.events.MyEventsPresenter
import ru.terrakok.gitlabclient.presentation.my.events.MyEventsView
......
......@@ -29,6 +29,9 @@ class MyIssuesContainerFragment : BaseFragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
savedInstanceState?.let { state ->
showOnlyOpened = state.getBoolean(STATE_ONLY_OPENED)
}
with(toolbar) {
setNavigationOnClickListener { menuController.open() }
......@@ -51,11 +54,6 @@ class MyIssuesContainerFragment : BaseFragment() {
viewPager.adapter = adapter
}
override fun restoreState(state: Bundle) {
super.restoreState(state)
showOnlyOpened = state.getBoolean(STATE_ONLY_OPENED)
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putBoolean(STATE_ONLY_OPENED, showOnlyOpened)
......
......@@ -8,6 +8,7 @@ import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.my.issues.MyIssuesPresenter
import ru.terrakok.gitlabclient.presentation.my.issues.MyIssuesView
......
......@@ -26,6 +26,9 @@ class MyMergeRequestsContainerFragment : BaseFragment() {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
savedInstanceState?.let { state ->
showOnlyOpened = state.getBoolean(STATE_ONLY_OPENED)
}
with(toolbar) {
setNavigationOnClickListener { menuController.open() }
......@@ -49,11 +52,6 @@ class MyMergeRequestsContainerFragment : BaseFragment() {
viewPager.adapter = adapter
}
override fun restoreState(state: Bundle) {
super.restoreState(state)
showOnlyOpened = state.getBoolean(STATE_ONLY_OPENED)
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putBoolean(STATE_ONLY_OPENED, showOnlyOpened)
......
......@@ -8,6 +8,7 @@ import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.my.mergerequests.MyMergeRequestListView
import ru.terrakok.gitlabclient.presentation.my.mergerequests.MyMergeRequestsPresenter
......
......@@ -8,6 +8,7 @@ import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.my.todos.MyTodoListView
import ru.terrakok.gitlabclient.presentation.my.todos.MyTodosPresenter
......
......@@ -10,6 +10,7 @@ import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Visibility
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.extension.shareText
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.project.info.ProjectInfoPresenter
import ru.terrakok.gitlabclient.presentation.project.info.ProjectInfoView
......
......@@ -10,6 +10,7 @@ import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.projects.ProjectsListPresenter
import ru.terrakok.gitlabclient.presentation.projects.ProjectsListView
......
......@@ -6,10 +6,7 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import kotlinx.android.synthetic.main.fragment_user_info.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.User
import ru.terrakok.gitlabclient.extension.loadRoundedImage
import ru.terrakok.gitlabclient.extension.shareText
import ru.terrakok.gitlabclient.extension.showTextOrHide
import ru.terrakok.gitlabclient.extension.tryOpenLink
import ru.terrakok.gitlabclient.extension.*
import ru.terrakok.gitlabclient.presentation.user.info.UserInfoPresenter
import ru.terrakok.gitlabclient.presentation.user.info.UserInfoView
import ru.terrakok.gitlabclient.toothpick.DI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment