View404

Additional

Language
Kotlin
Version
v1.1.0 (Oct 25, 2019)
Created
Oct 11, 2019
Updated
Jul 28, 2021 (Retired)
Owner
BlueCat Community (BlueCat-Community)
Contributors
Couzy (rurimo)
dependabot-preview[bot]
Sanghyeon Park (PaleCosmos)
Minjae Seon (Aftermoon-dev)
Leo (tlaabs)
JungHo (jungh0)
JAIHYOUNG SHIN (shinplest)
7
Activity
Badge
Generate
Download
Source code

Advertisement

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.1.0'
}

Usage

Use Layout XML File

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
}

Use Simple Custom Layout

View404 supports Custom Layout Class for More Simple!

First, 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" />

Write Import following Package inside your Class.

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

Make Variable for View404 & View404CustomLayout.

private var view404: View404? = null
private var view404CustomLayout: View404CustomLayout? = null

Write getInstance in View404CustomLayout.

view404CustomLayout = View404CustomLayout.getInstance(
            context = applicationContext, // Context
            bgColor = Color.parseColor("#ffffff"), // Background Color
            errMsg = "Error!" // Error Message
        )

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

if(view404 == null) {
    view404 = View404(this, view404CustomLayout?.inflate()!!)
    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
}

License

 Copyright 2019 Team Mulro in BlueCat-Community

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.