├── sample
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── drawable
│ │ │ ├── error.png
│ │ │ └── sample_image.png
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-hdpi
│ │ │ └── ic_message_white_24dp.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_message_white_24dp.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_message_white_24dp.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_message_white_24dp.png
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ ├── view_cell.xml
│ │ │ ├── view_progress.xml
│ │ │ ├── view_empty.xml
│ │ │ ├── view_error.xml
│ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── pl
│ │ └── aprilapps
│ │ └── switcher
│ │ └── sample
│ │ ├── ColorAdapter.java
│ │ └── MainActivity.java
└── build.gradle
├── library
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── pl
│ │ └── aprilapps
│ │ └── switcher
│ │ └── Switcher.kt
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── compiler.xml
└── gradle.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── proguard-rules.pro
├── gradle.properties
├── .gitignore
├── gradlew.bat
├── README.md
└── gradlew
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':library'
2 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Switcher2
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/drawable/error.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/sample_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/drawable/sample_image.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_message_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/drawable-hdpi/ic_message_white_24dp.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_message_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/drawable-mdpi/ic_message_white_24dp.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_message_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/drawable-xhdpi/ic_message_white_24dp.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_message_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkwiecien/Switcher/HEAD/sample/src/main/res/drawable-xxhdpi/ic_message_white_24dp.png
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Apr 06 19:31:26 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3E50B4
4 | #143593
5 | #EEEEEE
6 | #ffffffff
7 | #80ffffff
8 | #ff000000
9 | #4BAE4F
10 |
11 |
--------------------------------------------------------------------------------
/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Applications/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/view_cell.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.minSdkVersion
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 | versionCode rootProject.ext.versionCode
14 | versionName rootProject.ext.versionName
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation 'androidx.appcompat:appcompat:1.4.1'
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
22 |
23 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/view_progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/view_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
21 |
22 |
28 |
29 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/view_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
17 |
18 |
26 |
27 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.compileSdkVersion
8 | buildToolsVersion rootProject.ext.buildToolsVersion
9 |
10 | defaultConfig {
11 | applicationId "pl.aprilapps.switcher.sample"
12 | minSdkVersion rootProject.ext.minSdkVersion
13 | targetSdkVersion rootProject.ext.targetSdkVersion
14 | versionCode rootProject.ext.versionCode
15 | versionName rootProject.ext.versionName
16 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), '../proguard-rules.pro'
22 | }
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation(project(':library'))
28 | implementation 'androidx.appcompat:appcompat:1.4.1'
29 | implementation 'androidx.recyclerview:recyclerview:1.2.1'
30 | implementation 'androidx.cardview:cardview:1.0.0'
31 | implementation 'com.google.android.material:material:1.5.0'
32 | implementation "io.reactivex:rxandroid:$rxJavaVersion"
33 | implementation "io.reactivex:rxjava:$rxJavaVersion"
34 | }
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
16 |
17 |
22 |
23 |
29 |
30 |
31 |
32 |
37 |
38 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.gitignore.io
2 |
3 | *.DS_Store
4 |
5 | ### Java ###
6 | *.class
7 |
8 | # Mobile Tools for Java (J2ME)
9 | .mtj.tmp/
10 |
11 | # Package Files #
12 | *.jar
13 | *.war
14 | *.ear
15 |
16 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
17 | hs_err_pid*
18 |
19 |
20 | ### Android ###
21 | # Built application files
22 | *.apk
23 | *.ap_
24 |
25 | # Files for the Dalvik VM
26 | *.dex
27 |
28 | # Java class files
29 | *.class
30 |
31 | # Generated files
32 | bin/
33 | gen/
34 |
35 | # Gradle files
36 | .gradle/
37 | build/
38 | /*/build/
39 | /*/.idea/
40 | *.iml
41 |
42 | # Local configuration file (sdk path, etc)
43 | local.properties
44 |
45 | # Proguard folder generated by Eclipse
46 | proguard/
47 |
48 | # Log Files
49 | *.log
50 |
51 | ### Android Patch ###
52 | gen-external-apklibs
53 |
54 |
55 | ### Intellij ###
56 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
57 |
58 | *.iml
59 |
60 | ## Directory-based project format:
61 | .idea/
62 | # if you remove the above rule, at least ignore the following:
63 |
64 | # User-specific stuff:
65 | # .idea/workspace.xml
66 | # .idea/tasks.xml
67 | # .idea/dictionaries
68 |
69 | # Sensitive or high-churn files:
70 | # .idea/dataSources.ids
71 | # .idea/dataSources.xml
72 | # .idea/sqlDataSources.xml
73 | # .idea/dynamic.xml
74 | # .idea/uiDesigner.xml
75 |
76 | # Gradle:
77 | # .idea/gradle.xml
78 | # .idea/libraries
79 |
80 | # Mongo Explorer plugin:
81 | # .idea/mongoSettings.xml
82 |
83 | ## File-based project format:
84 | *.ipr
85 | *.iws
86 |
87 | ## Plugin-specific files:
88 |
89 | # IntelliJ
90 | /out/
91 |
92 | # mpeltonen/sbt-idea plugin
93 | .idea_modules/
94 |
95 | # JIRA plugin
96 | atlassian-ide-plugin.xml
97 |
98 | # Crashlytics plugin (for Android Studio and IntelliJ)
99 | com_crashlytics_export_strings.xml
100 | crashlytics.properties
101 | crashlytics-build.properties
102 |
103 |
104 | ### Gradle ###
105 | .gradle
106 | build/
107 |
108 | # Ignore Gradle GUI config
109 | gradle-app.setting
110 |
111 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
112 | !gradle-wrapper.jar
113 |
114 |
115 | ### Crashlytics ###
116 | #Crashlytics
117 | crashlytics-build.properties
118 | com_crashlytics_export_strings.xml
119 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/sample/src/main/java/pl/aprilapps/switcher/sample/ColorAdapter.java:
--------------------------------------------------------------------------------
1 | package pl.aprilapps.switcher.sample;
2 |
3 | import androidx.recyclerview.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | /**
10 | * Created by Jacek Kwiecień on 08.10.2015.
11 | */
12 | public class ColorAdapter extends RecyclerView.Adapter {
13 |
14 | private enum Case {
15 | PROGRESS, ERROR, EMPTY
16 | }
17 |
18 | private MainActivity activity;
19 |
20 | public ColorAdapter(MainActivity activity) {
21 | this.activity = activity;
22 | }
23 |
24 | @Override
25 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
26 | LayoutInflater inflater = LayoutInflater.from(activity);
27 | View view = inflater.inflate(R.layout.view_cell, parent, false);
28 | return new ViewHolder(view);
29 | }
30 |
31 | @Override
32 | public void onBindViewHolder(ViewHolder holder, int position) {
33 | switch (position) {
34 | case 0:
35 | holder.sampleCase = Case.PROGRESS;
36 | holder.itemView.setBackgroundColor(activity.getResources().getColor(android.R.color.holo_green_light));
37 | holder.label.setText("TEST PROGRESS");
38 | break;
39 | case 1:
40 | holder.sampleCase = Case.ERROR;
41 | holder.itemView.setBackgroundColor(activity.getResources().getColor(android.R.color.holo_red_light));
42 | holder.label.setText("TEST ERROR");
43 | break;
44 | default:
45 | holder.sampleCase = Case.EMPTY;
46 | holder.itemView.setBackgroundColor(activity.getResources().getColor(android.R.color.holo_orange_light));
47 | holder.label.setText("TEST EMPTY PLACEHOLDER");
48 | break;
49 | }
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return 3;
55 | }
56 |
57 | public class ViewHolder extends RecyclerView.ViewHolder {
58 |
59 | public Case sampleCase;
60 | protected TextView label;
61 |
62 | public ViewHolder(View itemView) {
63 | super(itemView);
64 |
65 | label = itemView.findViewById(R.id.label);
66 |
67 | itemView.findViewById(R.id.cell).setOnClickListener(view -> {
68 | switch (sampleCase) {
69 | case PROGRESS:
70 | activity.onProgress();
71 | break;
72 | case ERROR:
73 | activity.onError();
74 | break;
75 | default:
76 | activity.onEmpty();
77 | break;
78 | }
79 | });
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/sample/src/main/java/pl/aprilapps/switcher/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package pl.aprilapps.switcher.sample;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import androidx.recyclerview.widget.LinearLayoutManager;
6 | import androidx.recyclerview.widget.RecyclerView;
7 |
8 | import android.view.View;
9 | import android.widget.TextView;
10 |
11 | import java.util.concurrent.TimeUnit;
12 | import pl.aprilapps.switcher.Switcher;
13 | import rx.Observable;
14 | import rx.Subscriber;
15 | import rx.android.schedulers.AndroidSchedulers;
16 | import rx.schedulers.Schedulers;
17 |
18 |
19 | public class MainActivity extends AppCompatActivity {
20 |
21 | private Switcher switcher;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 |
28 | setSupportActionBar(findViewById(R.id.toolbar));
29 |
30 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
31 |
32 | switcher = new Switcher.Builder(this)
33 | .addContentView(findViewById(R.id.recyclerView)) //content member
34 | .addContentView(findViewById(R.id.fab)) //content member
35 | .addErrorView(findViewById(R.id.errorView)) //error view member
36 | .addProgressView(findViewById(R.id.progressView)) //progress view member
37 | .setErrorLabel((TextView) findViewById(R.id.errorLabel)) // TextView within your error member group that you want to change
38 | .setProgressLabel((TextView) findViewById(R.id.progressLabel)) // TextView within your progress member group that you want to change
39 | .addEmptyView(findViewById(R.id.emptyView)) //empty placeholder member
40 | .setAnimDuration(400)
41 | .setLogsEnabled(true)
42 | .build();
43 |
44 | ColorAdapter adapter = new ColorAdapter(this);
45 | recyclerView.setLayoutManager(new LinearLayoutManager(this));
46 | recyclerView.setAdapter(adapter);
47 |
48 | findViewById(R.id.dismissErrorButton).setOnClickListener(view -> {
49 | switcher.showContentView();
50 | });
51 |
52 | }
53 |
54 | public void onProgress() {
55 | switcher.showProgressViewImmediately();
56 | Observable.just(new Object())
57 | .subscribeOn(Schedulers.newThread())
58 | .observeOn(AndroidSchedulers.mainThread())
59 | .delaySubscription(800, TimeUnit.MILLISECONDS)
60 | .subscribe(new Subscriber