Coder Social home page Coder Social logo

view404's Introduction

View404

License API Build Status

🍀 Easy way to implement 404 screens for android.

Including in your project

Version

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.

view404's People

Contributors

aftermoon-dev avatar dependabot-preview[bot] avatar jungh0 avatar palecosmos avatar rurimo avatar shinplest avatar tlaabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

view404's Issues

README

README should be written.

  • Introductions with some preview gif.
  • Download guide (using Jitpack)
  • How to use

Show animation

Show FadeIn, FadeOut animation to view404 view when the show method called.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.