diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-06-07 15:22:51 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-06-07 15:22:51 +0200 |
commit | f7d2e1560377b36d3730922a2fadaee05a570b49 (patch) | |
tree | 1c99bd75d863d82a82495fabe434892ee76b9842 /src/main/java/de/thedevstack/conversationsplus/ui/listeners/AvatarLogoPositioningListener.java | |
parent | c5c5b417ddd66b4611b0493c0e0a8349adbd34a4 (diff) |
Related to FS#140, Logo implementation moved to FloatingActionButton
- Appcompat v7 dependency added
- References adjusted to work correctly with appcompat v7
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/ui/listeners/AvatarLogoPositioningListener.java | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/AvatarLogoPositioningListener.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/AvatarLogoPositioningListener.java deleted file mode 100644 index e6846d9b..00000000 --- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/AvatarLogoPositioningListener.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.thedevstack.conversationsplus.ui.listeners; - -import android.os.Build; -import android.view.View; -import android.view.ViewTreeObserver; - -import de.thedevstack.conversationsplus.R; - -/** - * This listener aims to position the avatar logo. - */ -public class AvatarLogoPositioningListener implements ViewTreeObserver.OnGlobalLayoutListener { - private View actionBarView; - private View avatarLogoView; - - public AvatarLogoPositioningListener(View actionBarView, View avatarLogoView) { - this.actionBarView = actionBarView; - this.avatarLogoView = avatarLogoView; - } - - @Override - public void onGlobalLayout() { - // Measure views - int[] location = new int[2]; - this.actionBarView.getLocationOnScreen(location); - - int[] logoLocation = new int[2]; - this.avatarLogoView.getLocationOnScreen(logoLocation); - - int[] titleViewLocation = new int[2]; - View titleView = this.actionBarView.findViewById(R.id.conversationsTitle); - int oldTitleViewLeftPadding = 0; - if (null != titleView) { - // Remove the listener only if all necessary view elements are there - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - this.actionBarView.getViewTreeObserver().removeOnGlobalLayoutListener(this); - } else { - this.actionBarView.getViewTreeObserver().removeGlobalOnLayoutListener(this); - } - - titleView.getLocationOnScreen(titleViewLocation); - int avatarWidth = (int) (58 * titleView.getResources().getDisplayMetrics().density); - int newTitleViewLeftPadding = titleViewLocation[0] + avatarWidth; - titleView.setPadding(newTitleViewLeftPadding, titleView.getPaddingTop(), 0, 0); - oldTitleViewLeftPadding = titleViewLocation[0]; - } - - // Add top padding if necessary - if (location[1] > logoLocation[1]) { - int actionBarViewHeight = this.actionBarView.getMeasuredHeight(); - int newAvatarLogoTopPadding = location[1]; // Move to the top padding of the action bar (below the notification bar) - newAvatarLogoTopPadding += actionBarViewHeight; - newAvatarLogoTopPadding -= 58 * avatarLogoView.getResources().getDisplayMetrics().density * 0.6; - this.avatarLogoView.setPadding(oldTitleViewLeftPadding, newAvatarLogoTopPadding, 0, 0); - } - } -} |