Skip to content

A non-navigation-blocking customizable spinner/loading view for Android

License

Notifications You must be signed in to change notification settings

ravindu1024/android-loadingdialog

Repository files navigation

Android Loading Views

  • A non blocking customisable progress view that can can block click events without blocking the back button
  • A better looking loading dialog for Android inspired by ios

alt tag

Installation:

Add this to the main gradle file:

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

Add this to your project gradle file:

	dependencies {
	        compile 'com.github.ravindu1024:android-loadingdialog:1.0.3'
	}

Usage

To create a new loading view

LoadingView loadingView = new LoadingView.Builder(act)
                .setProgressColorResource(R.color.ew_dark_pink)
                .setBackgroundColorRes(R.color.ew_white)
                .setProgressStyle(LoadingView.ProgressStyle.HORIZONTAL)
                .setCustomMargins(0, 100, 100, 0)
                .attachTo(act);

loadingView.show();

To set the failed state with a retry calback

loadingView.setLoadingFailed("Operation failed", "retry", new LoadingView.OnRefreshClickListener()
                {
                    @Override
                    public void onRefreshClicked()
                    {
		    	//do stuff here
                    }
                });

To set a custom layout to the operation failed view

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:orientation="vertical">

    <TextView
        android:id="@+id/label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-light"
        android:text="Operation Failed"
        android:textAlignment="center"
        android:textSize="14sp"/>

    <TextView
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:background="@color/colorPrimaryDark"
        android:padding="10dp"
        android:text="TextView"
        android:textColor="@android:color/white"
        android:textSize="16sp"/>
</LinearLayout>

The custom layout should contain two views that inherit from TextView (or support the setText method) named "label" and "button". The onRefreshClicked click event is added to the view named "button".

About

A non-navigation-blocking customizable spinner/loading view for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages