diff --git a/demo/build.gradle b/demo/build.gradle index efe319d..827a5df 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -29,4 +29,6 @@ dependencies { compile project(':library') absCompile project(':extras-abs') abcCompile project(':extras-abc') + + compile 'com.android.support:support-v4:20.0.0' } diff --git a/demo/src/abc/java/com/balysv/materialmenu/demo/abc/BaseActivity.java b/demo/src/abc/java/com/balysv/materialmenu/demo/abc/BaseActivity.java index b752800..5d89da1 100644 --- a/demo/src/abc/java/com/balysv/materialmenu/demo/abc/BaseActivity.java +++ b/demo/src/abc/java/com/balysv/materialmenu/demo/abc/BaseActivity.java @@ -15,6 +15,5 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.demo); helper = new BaseActivityHelper(); - helper.init(getWindow().getDecorView()); } } diff --git a/demo/src/abc/java/com/balysv/materialmenu/demo/abc/CustomViewActivity.java b/demo/src/abc/java/com/balysv/materialmenu/demo/abc/CustomViewActivity.java index a694942..abe2a1c 100644 --- a/demo/src/abc/java/com/balysv/materialmenu/demo/abc/CustomViewActivity.java +++ b/demo/src/abc/java/com/balysv/materialmenu/demo/abc/CustomViewActivity.java @@ -22,6 +22,7 @@ public class CustomViewActivity extends BaseActivity implements View.OnClickList protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initCustomActionBar(); + helper.init(getWindow().getDecorView(), materialMenu); } private void initCustomActionBar() { diff --git a/demo/src/abc/java/com/balysv/materialmenu/demo/abc/HomeIconActivity.java b/demo/src/abc/java/com/balysv/materialmenu/demo/abc/HomeIconActivity.java index ac71ed3..186712e 100644 --- a/demo/src/abc/java/com/balysv/materialmenu/demo/abc/HomeIconActivity.java +++ b/demo/src/abc/java/com/balysv/materialmenu/demo/abc/HomeIconActivity.java @@ -23,6 +23,7 @@ public class HomeIconActivity extends BaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); materialMenu = new MaterialMenuIconCompat(this, Color.WHITE, Stroke.THIN); + helper.init(getWindow().getDecorView(), materialMenu); } @Override diff --git a/demo/src/abs/java/com/balysv/materialmenu/demo/abs/BaseActivity.java b/demo/src/abs/java/com/balysv/materialmenu/demo/abs/BaseActivity.java index a8e42e1..0eda7b8 100644 --- a/demo/src/abs/java/com/balysv/materialmenu/demo/abs/BaseActivity.java +++ b/demo/src/abs/java/com/balysv/materialmenu/demo/abs/BaseActivity.java @@ -15,6 +15,5 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.demo); helper = new BaseActivityHelper(); - helper.init(getWindow().getDecorView()); } } diff --git a/demo/src/abs/java/com/balysv/materialmenu/demo/abs/CustomViewActivity.java b/demo/src/abs/java/com/balysv/materialmenu/demo/abs/CustomViewActivity.java index ca172da..1e84176 100644 --- a/demo/src/abs/java/com/balysv/materialmenu/demo/abs/CustomViewActivity.java +++ b/demo/src/abs/java/com/balysv/materialmenu/demo/abs/CustomViewActivity.java @@ -24,6 +24,7 @@ public class CustomViewActivity extends BaseActivity implements View.OnClickList protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initCustomActionBar(); + helper.init(getWindow().getDecorView(), materialMenu); } private void initCustomActionBar() { diff --git a/demo/src/abs/java/com/balysv/materialmenu/demo/abs/HomeIconActivity.java b/demo/src/abs/java/com/balysv/materialmenu/demo/abs/HomeIconActivity.java index 488a03a..692f925 100644 --- a/demo/src/abs/java/com/balysv/materialmenu/demo/abs/HomeIconActivity.java +++ b/demo/src/abs/java/com/balysv/materialmenu/demo/abs/HomeIconActivity.java @@ -23,6 +23,7 @@ public class HomeIconActivity extends BaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); materialMenu = new MaterialMenuIconSherlock(this, Color.WHITE, Stroke.THIN); + helper.init(getWindow().getDecorView(), materialMenu); } @Override diff --git a/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java b/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java index 6445e75..4addcea 100644 --- a/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java +++ b/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java @@ -1,20 +1,26 @@ package com.balysv.materialmenu.demo; +import android.support.v4.widget.DrawerLayout; +import android.view.Gravity; import android.view.View; import android.widget.SeekBar; +import com.balysv.materialmenu.MaterialMenu; import com.balysv.materialmenu.MaterialMenuView; import java.util.Random; +import static com.balysv.materialmenu.MaterialMenuDrawable.AnimationState; import static com.balysv.materialmenu.MaterialMenuDrawable.IconState; public class BaseActivityHelper implements View.OnClickListener, SeekBar.OnSeekBarChangeListener { private MaterialMenuView materialMenuView; private int materialButtonState; + private MaterialMenu materialIcon; + private DrawerLayout drawerLayout; - public void init(View parent) { + public void init(View parent, MaterialMenu actionBarIcon) { SeekBar duration = (SeekBar) parent.findViewById(R.id.item_animation_duration); duration.setMax(4600); duration.setProgress(2600); @@ -22,6 +28,7 @@ public void init(View parent) { materialMenuView = (MaterialMenuView) parent.findViewById(R.id.material_menu_button); materialMenuView.setOnClickListener(this); + materialIcon = actionBarIcon; parent.findViewById(R.id.switch_item_arrow).setOnClickListener(this); parent.findViewById(R.id.switch_item_menu).setOnClickListener(this); @@ -31,6 +38,35 @@ public void init(View parent) { parent.findViewById(R.id.animate_item_menu).setOnClickListener(this); parent.findViewById(R.id.animate_item_x).setOnClickListener(this); parent.findViewById(R.id.animate_item_check).setOnClickListener(this); + + drawerLayout = ((DrawerLayout) parent.findViewById(R.id.drawer_layout)); + drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() { + private boolean direction = false; + + @Override + public void onDrawerSlide(View drawerView, float slideOffset) { + materialIcon.setTransformationOffset( + AnimationState.BURGER_ARROW, + direction ? 2 - slideOffset : slideOffset + ); + } + + @Override + public void onDrawerOpened(android.view.View drawerView) { + direction = true; + } + + @Override + public void onDrawerClosed(android.view.View drawerView) { + direction = false; + } + }); + + drawerLayout.postDelayed(new Runnable() { + @Override public void run() { + drawerLayout.openDrawer(Gravity.LEFT); + } + }, 1500); } @Override public void onClick(View v) { diff --git a/demo/src/main/res/layout/demo.xml b/demo/src/main/res/layout/demo.xml index 279910a..d878b6b 100644 --- a/demo/src/main/res/layout/demo.xml +++ b/demo/src/main/res/layout/demo.xml @@ -1,151 +1,175 @@ - - - - - - - + android:layout_height="match_parent" + android:background="@android:color/darker_gray"> - - - + + + + + - - - - -