Skip to content

Commit e6e3408

Browse files
committed
minor fix update sample
1 parent 91a5f30 commit e6e3408

5 files changed

Lines changed: 36 additions & 21 deletions

File tree

app/src/main/java/rebus/header/view/sample/MainActivity.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,31 @@ public void run() {
7373
.setId(2)
7474
.setUsername("Raphaël Bussa")
7575
.setEmail("raphaelbussa@gmail.com")
76-
.setAvatar("https://avatars1.githubusercontent.com/u/3964819?v=3&s=460")
76+
.setAvatar("https://github.com/rebus007.png?size=512")
7777
.setBackground("https://images.unsplash.com/photo-1473220464492-452fb02e6221?dpr=2&auto=format&fit=crop&w=767&h=512&q=80&cs=tinysrgb&crop=")
7878
.build();
7979

8080
Profile profile2 = new Profile.Builder()
8181
.setId(4)
8282
.setUsername("Federico Gentile")
8383
.setEmail("fgentile95dev@icloud.com")
84-
.setAvatar("https://avatars2.githubusercontent.com/u/22976202?v=3&s=460")
84+
.setAvatar("https://github.com/FedeGens.png?size=512")
8585
.setBackground("https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
8686
.build();
8787

8888
Profile profile3 = new Profile.Builder()
8989
.setId(6)
9090
.setUsername("Luca Rurio")
9191
.setEmail("rurio.luca@gmail.com")
92-
.setAvatar("https://avatars3.githubusercontent.com/u/16242044?v=3&s=460")
92+
.setAvatar("https://github.com/RurioLuca.png?size=512")
9393
.setBackground("https://images.unsplash.com/photo-1473789810014-375ed569d0ed?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
9494
.build();
9595

9696
Profile profile4 = new Profile.Builder()
9797
.setId(8)
9898
.setUsername("Claudio Pastorini")
9999
.setEmail("pastorini.claudio@gmail.com")
100-
.setAvatar("https://avatars0.githubusercontent.com/u/4195199?v=3&s=460")
100+
.setAvatar("https://github.com/claudiopastorini.png?size=512")
101101
.setBackground("https://images.unsplash.com/photo-1452509133926-2b180c6d6245?dpr=2&auto=format&fit=crop&w=767&h=431&q=80&cs=tinysrgb&crop=")
102102
.build();
103103

@@ -113,15 +113,21 @@ public void run() {
113113

114114

115115
headerView.setStyle(HeaderView.STYLE_NORMAL);
116-
headerView.setShowGradient(true);
117116
headerView.setTheme(HeaderView.THEME_LIGHT);
117+
headerView.setShowGradient(true);
118118
headerView.setHighlightColor(ContextCompat.getColor(this, R.color.colorAccent));
119119
headerView.addProfile(profile, profile2, profile3, profile4);
120120
headerView.addDialogItem(item, item2);
121121
headerView.setShowAddButton(true);
122-
//headerView.setAddIconDrawable(R.drawable.ic_action_settings);
122+
headerView.setAddIconDrawable(R.drawable.ic_action_settings);
123123
headerView.setDialogTitle("Choose account");
124-
//headerView.setShowArrow(false);
124+
headerView.setShowArrow(true);
125+
headerView.setOnHeaderClickListener(new View.OnClickListener() {
126+
@Override
127+
public void onClick(View v) {
128+
drawerLayout.closeDrawer(GravityCompat.START, true);
129+
}
130+
});
125131
headerView.setFragmentManager(getFragmentManager());
126132
headerView.setCallback(new HeaderCallback() {
127133

@@ -152,13 +158,13 @@ public boolean onAdd() {
152158
Profile newProfile = new Profile.Builder()
153159
.setId(100)
154160
.setUsername("Mattia Novelli")
155-
.setEmail("@mattinove")
156-
.setAvatar("https://avatars1.githubusercontent.com/u/12815527?v=3&s=460")
161+
.setEmail("mattinove@me.com")
162+
.setAvatar("https://github.com/mattinove.png?size=512")
157163
.setBackground("https://images.unsplash.com/photo-1478194409487-fa5c1eb18622?dpr=2&auto=format&fit=crop&w=767&h=496&q=80&cs=tinysrgb&crop=")
158164
.build();
159165
headerView.addProfile(newProfile);
160166
headerView.setProfileActive(100);
161-
return false;
167+
return true;
162168
}
163169

164170
});

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@
5959
app:headerLayout="@layout/header_drawer"
6060
app:menu="@menu/drawer" />
6161

62-
</android.support.v4.widget.DrawerLayout>
62+
</android.support.v4.widget.DrawerLayout>

app/src/main/res/layout/header_drawer.xml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ The MIT License (MIT)
43
~
54
~ Copyright (c) 2017 Raphaël Bussa
@@ -26,10 +25,19 @@
2625
<rebus.header.view.HeaderView xmlns:android="http://schemas.android.com/apk/res/android"
2726
xmlns:app="http://schemas.android.com/apk/res-auto"
2827
android:id="@+id/header_view"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"
30+
app:hv_add_icon="@drawable/ic_action_settings"
2931
app:hv_add_status_bar_height="true"
30-
app:hv_style="compact"
31-
app:hv_theme="light"
32-
app:hv_highlight_color="@color/colorAccent"
32+
app:hv_background_color="@color/colorPrimaryDark"
3333
app:hv_dialog_title="@string/account"
34-
android:layout_width="match_parent"
35-
android:layout_height="wrap_content" />
34+
app:hv_highlight_color="@color/colorAccent"
35+
app:hv_profile_avatar="@drawable/ic_placeholder"
36+
app:hv_profile_background="@drawable/ic_placeholder_bg"
37+
app:hv_profile_email="batman@gotham.city"
38+
app:hv_profile_username="Bruce Wayne"
39+
app:hv_show_add_button="true"
40+
app:hv_show_arrow="true"
41+
app:hv_show_gradient="true"
42+
app:hv_style="normal"
43+
app:hv_theme="light" />

library/src/main/java/rebus/header/view/HeaderCallback.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ public class HeaderCallback implements ProfileChooserCallback {
3232

3333
@Override
3434
public boolean onSelect(int id, boolean isActive) {
35-
return false;
35+
return true;
3636
}
3737

3838
@Override
3939
public boolean onItem(int id) {
40-
return false;
40+
return true;
4141
}
4242

4343
@Override
4444
public boolean onAdd() {
45-
return false;
45+
return true;
4646
}
4747

4848
}

library/src/main/java/rebus/header/view/HeaderView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ private void addArrow() {
604604
arrow = new ImageView(getContext());
605605
arrow.setImageResource(R.drawable.hv_arrow);
606606
arrow.setBackgroundResource(Utils.selectableItemBackground(getContext()));
607+
arrow.setColorFilter(hvTextColor);
607608
arrow.setOnClickListener(new OnClickListener() {
608609
@Override
609610
public void onClick(View v) {

0 commit comments

Comments
 (0)