Skip to content

Commit 9097d55

Browse files
committed
Some features changed
[feat] Set spesific icon color
1 parent ecd0f40 commit 9097d55

16 files changed

Lines changed: 151 additions & 29 deletions

File tree

.idea/markdown-navigator.xml

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/markdown-navigator/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ Create & Show progress, data or error views, the easy way!
77
StateViews is based on ViewSwitcher mechanism and allows to handle the different app states, from loading... to displaying
88
data and error views, the library is tiny and fully customizable.
99

10+
This repo has been developed from https://github.com/medyo/StateViews.
11+
12+
Different features of original repo:
13+
- Codes converted to Kotlin
14+
- Fixed some memory leaks
15+
- Icons colors can be customized separately
16+
- Added showing state status
17+
1018
```xml
1119
<com.umutbey.stateviews.StateView
1220
android:id="@+id/status_page"
@@ -38,20 +46,29 @@ mStatusPage.hideStates();
3846

3947

4048
## Setup
41-
[![Snapshot](https://jitpack.io/v/medyo/stateviews.svg?style=flat-square)](https://jitpack.io/private#medyo/stateviews/-SNAPSHOT)
49+
[![](https://jitpack.io/v/kobeumut/StateViews.svg)](https://jitpack.io/#kobeumut/StateViews)
50+
51+
```
52+
allprojects {
53+
repositories {
54+
...
55+
maven { url 'https://jitpack.io' }
56+
}
57+
}
58+
```
59+
4260
```
43-
implementation 'com.github.medyo:state-views:0.2'
61+
implementation 'com.github.kobeumut:StateViews:0.4'
4462
```
4563

4664
## Usage
47-
[medyo/StateViews/app/](https://github.com/medyo/StateViews/tree/master/app)
4865

4966
### 1. Available attributes for PageStatus Builder
5067

5168
| Function | Description |
5269
| ------------- |:-------------:|
53-
| addState(params) | Create a new state|
54-
| setIconColor(Int) | Set Icon color |
70+
| addState(params) | Create a new state. Params are tag, title, description, icon, spesific icon color, button text, clicklistener|
71+
| setIconColor(Int) | Set Icon color for all icons(Same color) |
5572
| setIconSize(Int) | Set Icon Size |
5673
| setTextColor(Int) | set Title and description colors|
5774
| setFontFace(String) | Set Custom font |
@@ -63,7 +80,7 @@ implementation 'com.github.medyo:state-views:0.2'
6380

6481
| Function | Description |
6582
| ------------- |:-------------:|
66-
| displayState(String) | Display a state by his tag name|
83+
| displayState(String) | Display a state by his tag name. If you want to send displayState("hide") parameter, state will hide |
6784
| hideStates() | Hide all states and display data|
6885
| displayLoadingState() | Display the loading state|
6986
| addCustomState(Intent) | Create a new state only available for the current activity, fragment...|
@@ -81,6 +98,7 @@ addState(
8198
"No Connection",
8299
"Error retrieving information from server.",
83100
AppCompatResources.getDrawable(this, R.drawable.ic_server_error),
101+
Color.Black,
84102
"Retry"
85103
);
86104

@@ -96,7 +114,7 @@ addState(
96114
"TAG_NO_RESULTS",
97115
"No Results Found",
98116
"Unfortunately I could not find any results matching your search",
99-
AppCompatResources.getDrawable(this, R.drawable.search), null
117+
AppCompatResources.getDrawable(this, R.drawable.search), ,null, null
100118
)
101119

102120
mStatusPage.displayState("TAG_NO_RESULTS");

app/src/main/java/com/umutbey/stateviews/Samples/App.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import android.app.Application;
44
import android.graphics.Color;
5-
import androidx.appcompat.content.res.AppCompatResources;
5+
66
import com.umutbey.stateviews.StateViewsBuilder;
77

8+
import androidx.appcompat.content.res.AppCompatResources;
9+
810
/**
911
* Created by medyo on 11/20/17.
1012
* Developed by kobeumut on 11/04/18
@@ -16,14 +18,13 @@ public class App extends Application {
1618
public void onCreate() {
1719
super.onCreate();
1820

19-
StateViewsBuilder state = StateViewsBuilder.Companion
20-
.init();
21-
22-
state.setIconColor(Color.parseColor("#D2D5DA"))
21+
StateViewsBuilder.Companion
22+
.init()
2323
.addState("error",
2424
"No Connection",
2525
"Error retrieving information from server.",
2626
AppCompatResources.getDrawable(this, R.drawable.ic_server_error),
27+
Color.RED,
2728
"Retry"
2829
)
2930

@@ -33,18 +34,19 @@ public void onCreate() {
3334
"Archived items will be kept here. They'll still show in albums " +
3435
"& search results.",
3536
AppCompatResources.getDrawable(this, R.drawable.photos_archive),
37+
Color.BLUE,
3638
"LEARN MORE"
3739
)
3840

3941
.addState("search",
4042
"No Results Found",
4143
"Unfortunately I could not find any results matching your search",
42-
AppCompatResources.getDrawable(this, R.drawable.search),null)
43-
44+
AppCompatResources.getDrawable(this, R.drawable.search), null, null)
4445
.addState("custom",
4546
"Custom State",
4647
"This is a custom state, made in 5 seconds \nClick to hide status ",
47-
AppCompatResources.getDrawable(this, R.drawable.fingerprint),
48+
AppCompatResources.getDrawable(this, R.drawable.caution),
49+
null,
4850
"HIDE STATE")
4951
.setButtonBackgroundColor(Color.parseColor("#317DED"))
5052
.setButtonTextColor(Color.parseColor("#FFFFFF"))

app/src/main/java/com/umutbey/stateviews/Samples/MainActivity.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
1313

1414
StateView mStatusPage;
15-
Button mLoading, mError, mCustom, mSearch;
15+
Button mLoading, mError, mCustom, mSearch, mHide;
1616

1717
@Override
1818
protected void onCreate(Bundle savedInstanceState) {
@@ -23,11 +23,13 @@ protected void onCreate(Bundle savedInstanceState) {
2323
mError = findViewById(R.id.button_error);
2424
mCustom = findViewById(R.id.button_custom);
2525
mSearch = findViewById(R.id.button_search);
26+
mHide = findViewById(R.id.button_hide);
2627

2728
mLoading.setOnClickListener(this);
2829
mError.setOnClickListener(this);
2930
mCustom.setOnClickListener(this);
3031
mSearch.setOnClickListener(this);
32+
mHide.setOnClickListener(this);
3133

3234
mStatusPage = findViewById(R.id.status_page);
3335
mStatusPage.setOnStateButtonClicked(new View.OnClickListener() {
@@ -59,6 +61,11 @@ public void onClick(View view) {
5961
break;
6062
case R.id.button_search: {
6163
mStatusPage.displayState("search");
64+
break;
65+
}
66+
case R.id.button_hide: {
67+
mStatusPage.displayState("hide");
68+
break;
6269
}
6370
}
6471
}
7.81 KB
Loading
3.54 KB
Loading
6.77 KB
Loading
16.5 KB
Loading

0 commit comments

Comments
 (0)