Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jkwiecien/Switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Kwiecień committed Jun 22, 2015
2 parents 82891ff + df47eda commit 5887ab7
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Library that allows you to eaisly switch between your content, progress, error a
You only show content, progress or error view. The switcher finds out what's currently visible and hides it.


<img src="http://g.recordit.co/mdqiMgA8iQ.gif" height="340" />
<img src="http://g.recordit.co/LAshoSUNxi.gif" height="340" />

#How to use it?
1) Build your layout like this. It's important to pack your content, progress and error view into the same ```FrameLayout```. It won't work otherwise.
Expand All @@ -16,6 +16,19 @@ Library that allows you to eaisly switch between your content, progress, error a
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="20dp"
android:visibility="invisible">

<-- your empty placeholder subviews goes here -->

</LinearLayout>

<LinearLayout
android:id="@+id/progress_view"
Expand Down Expand Up @@ -63,24 +76,29 @@ switcher = new Switcher.Builder()
.withBlurView(findViewById(R.id.blur_view)) //View overlaying another view, that you'd like to blur
.withErrorLabel((TextView) findViewById(R.id.error_label)) // TextView within your error ViewGroup that you want to change
.withProgressLabel((TextView) findViewById(R.id.progress_label)) // TextView within your progress ViewGroup that you want to change
.withEmptyView(findViewById(R.id.empty_view)) //SOme empty placeholder we display on lists for example if there are no results
.build();
```

3) Use the Switcher object to switch between your views
3) Use the Switcher object to switch between your views. This will use the crossfade animation.
```java
switcher.showContentView();
switcher.showProgressView();
switcher.showErrorView();
switcher.showEmptyView();
switcher.showBlurView(View viewToBlur);
```

If you rather switch views immediately without animation use ```showProgressViewImmediately()``` and corresponding for other states.

#Setup
```
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile ('com.github.jkwiecien:Switcher:1.1.0'){
compile ('com.github.jkwiecien:Switcher:1.1.1'){
exclude module: 'appcompat-v7'
}
}
Expand Down

0 comments on commit 5887ab7

Please sign in to comment.