Skip to content

Instantly share code, notes, and snippets.


illuzor/AbstractFragment.kt Secret

Created Sep 21, 2018
What would you like to do?
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
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
btn_retry.setOnClickListener { handler() }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment