Git Product home page Git Product logo

empty-view's Introduction

EmptyView

Android Arsenal Build Status

A view that displays states of screen like loadingType, error, empty etc.

Samples

Usage

Gradle

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.santalu:emptyview:1.3.6'
}

XML

<com.santalu.emptyview.EmptyView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/empty_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:ev_gravity="center"
    app:ev_empty_button="@string/try_again"
    app:ev_empty_buttonTextColor="@color/colorPrimaryDark"
    app:ev_empty_drawable="@drawable/ic_sentiment_dissatisfied"
    app:ev_empty_drawableTint="@color/colorPrimary"
    app:ev_empty_text="@string/empty"
    app:ev_empty_title="@string/error_endpoint_title"
    app:ev_error_backgroundColor="@color/red"
    app:ev_error_button="@string/try_again"
    app:ev_error_buttonTextColor="@color/white"
    app:ev_error_drawable="@drawable/ic_sentiment_very_dissatisfied"
    app:ev_error_drawableTint="@color/white"
    app:ev_error_text="@string/error_unknown"
    app:ev_error_textColor="@color/white"
    app:ev_error_title="@string/error_unknown_title"
    app:ev_error_titleTextColor="@color/white"
    app:ev_font="@font/allerta"
    app:ev_loading="circular"
    app:ev_loading_drawable="@drawable/ic_sentiment_satisfied"
    app:ev_loading_drawableTint="@color/colorPrimary"
    app:ev_loading_title="@string/loadingType"
    app:ev_loading_type="circular"                             
    app:ev_transition="auto">

    *** your content here ***

</com.santalu.emptyview.EmptyView>

Attributes

Name Value
ev_gravity top,center,bottom default center
ev_transition slide, explode, fade default none
ev_font reference
ev_titleTextSize dimension
ev_textSize dimension
ev_letterSpacing dimension
ev_lineSpacingExtra dimension
ev_lineSpacingExtraMultiplier dimension
ev_buttonTextSize dimension
ev_loading_type circular default none
ev_loading_title string
ev_loading_titleTextColor color
ev_loading_text string
ev_loading_textColor color
ev_loading_drawable reference
ev_loading_drawableTint color
ev_loading_backgroundColor color
ev_empty_title string
ev_empty_titleTextColor color
ev_empty_text string
ev_empty_textColor color
ev_empty_button string
ev_empty_buttonTextColor color
ev_empty_buttonBackgroundColor color
ev_empty_drawable reference
ev_empty_drawableTint color
ev_empty_backgroundColor color
ev_error_title string
ev_error_titleTextColor color
ev_error_text string
ev_error_textColor color
ev_error_button string
ev_error_buttonTextColor color
ev_error_buttonBackgroundColor color
ev_error_drawable reference
ev_error_drawableTint color
ev_error_backgroundColor color

Notes

  • Use exclude(int... ids) or exclude(View... views) methods to exclude views from visibility changes
  • Use include(int... ids) or include(View... views) methods to include views for visibility changes

License

Copyright 2017 Fatih Santalu

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.

empty-view's People

Contributors

gounlaf avatar santalu 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

empty-view's Issues

set button text programmatically

Please add method to set button text programmatically.

For instance, if empty button text depends on some condition.

Thanks a lot!

EmptyView not working with SwipeRefreshLayout

I receive this error when trying to use the swipe refresh after I added the emptyview.
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

Vector drawable's issue on Android < Lollipop

There is an vector drawables issue on old Android devices. You should use AppCompatResources.getDrawable to support old Android versions.

...
mLoadingDrawableRes = a.getResourceId(R.styleable.EmptyView_loadingDrawable, -1);
...
mEmptyDrawableRes = a.getResourceId(R.styleable.EmptyView_emptyDrawable, -1);
...
mErrorDrawableRes = a.getResourceId(R.styleable.EmptyView_errorDrawable, -1);`
    private void setIcon(@DrawableRes int emptyDrawableRes, @ColorInt int tint) {
        if (emptyDrawableRes == -1) {
            mImageView.setVisibility(GONE);
        } else {
            mImageView.setVisibility(VISIBLE);
            mImageView.setImageDrawable(AppCompatResources.getDrawable(getContext(), emptyDrawableRes));
            ...
        }
    }

Thanks!

Lots of visual glitches in latest version

In recyclerviews with EmptyView I get a lot of visual glitches like List DivisorItem don't appear well and text from a list item disappears and only appears when I make a scroll gesture.
If I rollback to previous version all works normally.

Version that works well- 1.0.5

I love the new animations btw! Congrats!

像这样使用,第一个EmptyView使用showLoading()方法不显示

<?xml version="1.0" encoding="utf-8"?>
<com.santalu.emptyview.EmptyView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/empty_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:emptyButtonText="@string/try_again"
    app:emptyButtonTextColor="@color/colorPrimaryDark"
    app:emptyDrawable="@drawable/ic_sentiment_dissatisfied"
    app:emptyDrawableTint="@color/colorPrimary"
    app:emptyGravity="center"
    app:emptyText="@string/empty"
    app:errorBackgroundColor="@color/red"
    app:errorButtonBackgroundColor="@color/white"
    app:errorButtonText="@string/try_again"
    app:errorButtonTextColor="@color/black"
    app:errorDrawable="@drawable/ic_sentiment_very_dissatisfied"
    app:errorDrawableTint="@color/white"
    app:errorText="@string/emptyview_error_unknown"
    app:errorTextColor="@color/white"
    app:loadingDrawable="@drawable/ic_sentiment_satisfied"
    app:loadingStyle="circular"
    app:loadingText="@string/emptyview_loading"
    app:loadingTint="@color/colorPrimary">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="15dp"
        android:background="#98FB98"
        android:visibility="visible">

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:background="#9ACD32"
            android:orientation="vertical">

            <TextView
                android:id="@+id/text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="15dp"
                android:background="#9A32CD"
                android:lineSpacingExtra="1dp"
                android:lineSpacingMultiplier="1.2"
                android:padding="16dp"
                android:text="@string/lorem" />

            <com.santalu.emptyview.EmptyView
                android:id="@+id/empty_view1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:emptyDrawable="@drawable/ic_sentiment_dissatisfied"
                app:emptyDrawableTint="@color/colorPrimary"
                app:emptyGravity="center"
                app:emptyText="@string/empty"
                app:errorBackgroundColor="@color/red"
                app:errorButtonBackgroundColor="@color/white"
                app:errorButtonText="@string/try_again"
                app:errorButtonTextColor="@color/black"
                app:errorDrawable="@drawable/ic_sentiment_very_dissatisfied"
                app:errorDrawableTint="@color/white"
                app:errorText="@string/emptyview_error_unknown"
                app:errorTextColor="@color/white"
                app:loadingDrawable="@drawable/ic_sentiment_satisfied"
                app:loadingStyle="circular"
                app:loadingText="@string/emptyview_loading"
                app:loadingTint="@color/colorPrimary">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="15dp"
                    android:background="#A4D3EE">

                    <TextView
                        android:id="@+id/text1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="15dp"
                        android:background="#A0522D"
                        android:lineSpacingExtra="1dp"
                        android:lineSpacingMultiplier="1.2"
                        android:padding="16dp"
                        android:text="@string/lorem" />

                </LinearLayout>

            </com.santalu.emptyview.EmptyView>

        </LinearLayout>

    </ScrollView>

</com.santalu.emptyview.EmptyView>

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.