Skip to content

Commit

Permalink
minor fix update sample
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelbussa committed Jan 24, 2017
1 parent 91a5f30 commit e6e3408
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
26 changes: 16 additions & 10 deletions app/src/main/java/rebus/header/view/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,31 @@ public void run() {
.setId(2)
.setUsername("Raphaël Bussa")
.setEmail("[email protected]")
.setAvatar("https://avatars1.githubusercontent.com/u/3964819?v=3&s=460")
.setAvatar("https://github.com/rebus007.png?size=512")
.setBackground("https://images.unsplash.com/photo-1473220464492-452fb02e6221?dpr=2&auto=format&fit=crop&w=767&h=512&q=80&cs=tinysrgb&crop=")
.build();

Profile profile2 = new Profile.Builder()
.setId(4)
.setUsername("Federico Gentile")
.setEmail("[email protected]")
.setAvatar("https://avatars2.githubusercontent.com/u/22976202?v=3&s=460")
.setAvatar("https://github.com/FedeGens.png?size=512")
.setBackground("https://images.unsplash.com/photo-1469173479606-ada03df615ac?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
.build();

Profile profile3 = new Profile.Builder()
.setId(6)
.setUsername("Luca Rurio")
.setEmail("[email protected]")
.setAvatar("https://avatars3.githubusercontent.com/u/16242044?v=3&s=460")
.setAvatar("https://github.com/RurioLuca.png?size=512")
.setBackground("https://images.unsplash.com/photo-1473789810014-375ed569d0ed?dpr=2&auto=format&fit=crop&w=767&h=511&q=80&cs=tinysrgb&crop=")
.build();

Profile profile4 = new Profile.Builder()
.setId(8)
.setUsername("Claudio Pastorini")
.setEmail("[email protected]")
.setAvatar("https://avatars0.githubusercontent.com/u/4195199?v=3&s=460")
.setAvatar("https://github.com/claudiopastorini.png?size=512")
.setBackground("https://images.unsplash.com/photo-1452509133926-2b180c6d6245?dpr=2&auto=format&fit=crop&w=767&h=431&q=80&cs=tinysrgb&crop=")
.build();

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


headerView.setStyle(HeaderView.STYLE_NORMAL);
headerView.setShowGradient(true);
headerView.setTheme(HeaderView.THEME_LIGHT);
headerView.setShowGradient(true);
headerView.setHighlightColor(ContextCompat.getColor(this, R.color.colorAccent));
headerView.addProfile(profile, profile2, profile3, profile4);
headerView.addDialogItem(item, item2);
headerView.setShowAddButton(true);
//headerView.setAddIconDrawable(R.drawable.ic_action_settings);
headerView.setAddIconDrawable(R.drawable.ic_action_settings);
headerView.setDialogTitle("Choose account");
//headerView.setShowArrow(false);
headerView.setShowArrow(true);
headerView.setOnHeaderClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
drawerLayout.closeDrawer(GravityCompat.START, true);
}
});
headerView.setFragmentManager(getFragmentManager());
headerView.setCallback(new HeaderCallback() {

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

});
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
app:headerLayout="@layout/header_drawer"
app:menu="@menu/drawer" />

</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
22 changes: 15 additions & 7 deletions app/src/main/res/layout/header_drawer.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ The MIT License (MIT)
~
~ Copyright (c) 2017 Raphaël Bussa
Expand All @@ -26,10 +25,19 @@
<rebus.header.view.HeaderView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/header_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hv_add_icon="@drawable/ic_action_settings"
app:hv_add_status_bar_height="true"
app:hv_style="compact"
app:hv_theme="light"
app:hv_highlight_color="@color/colorAccent"
app:hv_background_color="@color/colorPrimaryDark"
app:hv_dialog_title="@string/account"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
app:hv_highlight_color="@color/colorAccent"
app:hv_profile_avatar="@drawable/ic_placeholder"
app:hv_profile_background="@drawable/ic_placeholder_bg"
app:hv_profile_email="[email protected]"
app:hv_profile_username="Bruce Wayne"
app:hv_show_add_button="true"
app:hv_show_arrow="true"
app:hv_show_gradient="true"
app:hv_style="normal"
app:hv_theme="light" />
6 changes: 3 additions & 3 deletions library/src/main/java/rebus/header/view/HeaderCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public class HeaderCallback implements ProfileChooserCallback {

@Override
public boolean onSelect(int id, boolean isActive) {
return false;
return true;
}

@Override
public boolean onItem(int id) {
return false;
return true;
}

@Override
public boolean onAdd() {
return false;
return true;
}

}
1 change: 1 addition & 0 deletions library/src/main/java/rebus/header/view/HeaderView.java
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ private void addArrow() {
arrow = new ImageView(getContext());
arrow.setImageResource(R.drawable.hv_arrow);
arrow.setBackgroundResource(Utils.selectableItemBackground(getContext()));
arrow.setColorFilter(hvTextColor);
arrow.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Expand Down

0 comments on commit e6e3408

Please sign in to comment.