Skip to content

Instantly share code, notes, and snippets.

@illuzor
Created September 21, 2018 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illuzor/201eef875cf4d8608f158fb5066077df to your computer and use it in GitHub Desktop.
Save illuzor/201eef875cf4d8608f158fb5066077df to your computer and use it in GitHub Desktop.
package com.illuzor.lesson.wallpapers.screens
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_list.*
abstract class AbstractFragment : Fragment() {
protected lateinit var contentView: View
protected abstract val layoutId: Int
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =
inflater.inflate(layoutId, container, false)
protected fun showProgress() {
contentView.visibility = View.GONE
rotator.visibility = View.VISIBLE
error_group.visibility = View.GONE
}
protected fun showContent() {
contentView.visibility = View.VISIBLE
rotator.visibility = View.GONE
error_group.visibility = View.GONE
}
protected fun showError(@StringRes textId: Int, handler: () -> Unit) {
contentView.visibility = View.GONE
rotator.visibility = View.GONE
error_group.visibility = View.VISIBLE
tv_error.setText(textId)
btn_retry.setOnClickListener { handler() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment