Skip to content

Commit

Permalink
add custom variable (emtpy title)
Browse files Browse the repository at this point in the history
  • Loading branch information
amkalantari committed Aug 19, 2019
1 parent b9e2be2 commit 37e2972
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 25
versionName "1.2.5"
versionCode 26
versionName "1.2.6"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,16 @@ private void setColor(AttributeSet attrs) {
return;
}
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.MyCustomView);

titleColor = ta.getColor(R.styleable.MyCustomView_titleColor, Color.WHITE);
subtitleColor = ta.getColor(R.styleable.MyCustomView_subtitleColor, Color.GRAY);
retryButtonColor = ta.getColor(R.styleable.MyCustomView_retryButtonColor, Color.GRAY);
retryButtonTextColor = ta.getColor(R.styleable.MyCustomView_retryButtonTextColor, Color.GRAY);
iconTintColor = ta.getColor(R.styleable.MyCustomView_iconBackGroundColor, Color.GRAY);

CharSequence title = ta.getString(R.styleable.MyCustomView_emptyTitle);
if (title != null)
setEmptyTitle(title.toString());

emptyTextViewTitle.setTextColor(titleColor);
errorTextViewTitle.setTextColor(titleColor);
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<attr name="subtitleColor" format="color" />
<attr name="retryButtonColor" format="color" />
<attr name="retryButtonTextColor" format="color" />
<attr name="emptyTitle" format="string" />
</declare-styleable>

</resources>
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
android:id="@+id/myCustomView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:emptyTitle="helloooooooooo"
app:retryButtonColor="@color/purple"
app:retryButtonTextColor="@color/gray"
app:subtitleColor="@color/red"
Expand Down

0 comments on commit 37e2972

Please sign in to comment.