-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'support_design_library'
- Loading branch information
Showing
27 changed files
with
540 additions
and
942 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
app/src/main/java/io/github/froger/instamaterial/ui/activity/BaseDrawerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.github.froger.instamaterial.ui.activity; | ||
|
||
import android.os.Handler; | ||
import android.support.v4.widget.DrawerLayout; | ||
import android.view.Gravity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
|
||
import com.squareup.picasso.Picasso; | ||
|
||
import butterknife.InjectView; | ||
import butterknife.OnClick; | ||
import io.github.froger.instamaterial.R; | ||
import io.github.froger.instamaterial.ui.utils.CircleTransformation; | ||
|
||
/** | ||
* Created by Miroslaw Stanek on 15.07.15. | ||
*/ | ||
public class BaseDrawerActivity extends BaseActivity { | ||
|
||
@InjectView(R.id.drawerLayout) | ||
DrawerLayout drawerLayout; | ||
@InjectView(R.id.ivMenuUserProfilePhoto) | ||
ImageView ivMenuUserProfilePhoto; | ||
|
||
private int avatarSize; | ||
private String profilePhoto; | ||
|
||
@Override | ||
public void setContentView(int layoutResID) { | ||
super.setContentViewWithoutInject(R.layout.activity_drawer); | ||
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.flContentRoot); | ||
LayoutInflater.from(this).inflate(layoutResID, viewGroup, true); | ||
injectViews(); | ||
|
||
setupHeader(); | ||
} | ||
|
||
@Override | ||
protected void setupToolbar() { | ||
super.setupToolbar(); | ||
if (getToolbar() != null) { | ||
getToolbar().setNavigationOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
drawerLayout.openDrawer(Gravity.LEFT); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@OnClick(R.id.vGlobalMenuHeader) | ||
public void onGlobalMenuHeaderClick(final View v) { | ||
drawerLayout.closeDrawer(Gravity.LEFT); | ||
new Handler().postDelayed(new Runnable() { | ||
@Override | ||
public void run() { | ||
int[] startingLocation = new int[2]; | ||
v.getLocationOnScreen(startingLocation); | ||
startingLocation[0] += v.getWidth() / 2; | ||
UserProfileActivity.startUserProfileFromLocation(startingLocation, BaseDrawerActivity.this); | ||
overridePendingTransition(0, 0); | ||
} | ||
}, 200); | ||
} | ||
|
||
private void setupHeader() { | ||
this.avatarSize = getResources().getDimensionPixelSize(R.dimen.global_menu_avatar_size); | ||
this.profilePhoto = getResources().getString(R.string.user_profile_photo); | ||
Picasso.with(this) | ||
.load(profilePhoto) | ||
.placeholder(R.drawable.img_circle_placeholder) | ||
.resize(avatarSize, avatarSize) | ||
.centerCrop() | ||
.transform(new CircleTransformation()) | ||
.into(ivMenuUserProfilePhoto); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.