Easy way to implement 404 not found screens for android

View404

Easy way to implement 404 screens for android.

Including in your project


Gradle

Add Below codes to your root build.gradle file! (Not your module's build.gradle file).

allprojects {
    repositories {
        maven {
            url 'https://jitpack.io'
        }
    }
}

And add a dependency code to your module's build.gradle file.

dependencies {
    implementation 'com.github.BlueCat-Community:View404:v1.0.0'
}

Usage

Make Layout XML File for Showing Error inside your project's res/layout.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white">

    <TextView
        android:id="@+id/text_404"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="There is no results!"
        android:textSize="16sp"
        android:textStyle="bold" />

</RelativeLayout>

..And Add Error Layout Space in Your Layout.

<RelativeLayout
    android:id="@+id/errorLayout"
    android:background="#000000"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="50dp" />

Import following Package inside your Class.

import com.bluecat.view404.View404
import com.bluecat.view404.show404

Make Variable for View404.

private var view404: View404? = null

If you want to overlay 'not found' View on your ViewGroup,

if(view404 == null) {
    view404 = View404(this, R.layout.layout_404)
    errorLayout.show404(view404!!, R.anim.view404_fade_in_default)
}

If you want to dismiss 'not found' View on your ViewGroup,

if(view404 != null) {
    view404?.dismiss(R.anim.view404_fade_out_default)
    view404 = null
}

GitHub