Skip to content

Commit

Permalink
Merge pull request #3 from balysv/dev
Browse files Browse the repository at this point in the history
Added new morphing icon - CHECK
  • Loading branch information
balysv committed Aug 26, 2014
2 parents 2d27e0f + ca2931e commit 66ded91
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.switch_item_arrow).setOnClickListener(this);
findViewById(R.id.switch_item_menu).setOnClickListener(this);
findViewById(R.id.switch_item_x).setOnClickListener(this);
findViewById(R.id.switch_item_check).setOnClickListener(this);
findViewById(R.id.animate_item_arrow).setOnClickListener(this);
findViewById(R.id.animate_item_menu).setOnClickListener(this);
findViewById(R.id.animate_item_x).setOnClickListener(this);
findViewById(R.id.animate_item_check).setOnClickListener(this);
}

@Override public void onClick(View v) {
Expand All @@ -50,6 +52,9 @@ protected void onCreate(Bundle savedInstanceState) {
case R.id.animate_item_x:
materialMenuView.animateState(IconState.X);
break;
case R.id.animate_item_check:
materialMenuView.animateState(IconState.CHECK);
break;
case R.id.switch_item_menu:
materialMenuView.setState(IconState.BURGER);
break;
Expand All @@ -59,6 +64,9 @@ protected void onCreate(Bundle savedInstanceState) {
case R.id.switch_item_x:
materialMenuView.setState(IconState.X);
break;
case R.id.switch_item_check:
materialMenuView.setState(IconState.CHECK);
break;
case R.id.material_menu_button:
setMainState();
break;
Expand Down Expand Up @@ -87,7 +95,7 @@ private void setMainState() {
}

protected int generateState(int previous) {
int generated = new Random().nextInt(3);
int generated = new Random().nextInt(4);
return generated != previous ? generated : generateState(previous);
}

Expand All @@ -99,6 +107,8 @@ protected IconState intToState(int state) {
return IconState.ARROW;
case 2:
return IconState.X;
case 3:
return IconState.CHECK;
}
throw new IllegalArgumentException("Must be a number [0,3)");
}
Expand Down
22 changes: 22 additions & 0 deletions demo/src/main/res/layout/demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
android:layout_marginLeft="12dp"
android:text="@string/animate_x"/>

<Button
style="?android:buttonBarStyle"
android:id="@+id/animate_item_check"
android:textColor="@android:color/white"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:text="@string/animate_check"/>

</LinearLayout>

<LinearLayout
Expand Down Expand Up @@ -132,6 +143,17 @@
android:layout_marginLeft="12dp"
android:text="@string/set_x"/>

<Button
style="?android:buttonBarStyle"
android:id="@+id/switch_item_check"
android:textColor="@android:color/white"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:layout_marginLeft="12dp"
android:text="@string/set_check"/>


</LinearLayout>

Expand Down
9 changes: 5 additions & 4 deletions demo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<string name="action_switch_custom">Use CustomView</string>
<string name="action_switch_home_icon">Use Home icon</string>
<string name="duration">DURATION</string>
<string name="animate_menu">ANIMATE MENU</string>
<string name="animate_arrow">ANIMATE ARROW</string>
<string name="animate_x">ANIMATE X</string>
<string name="animate_menu">ANIM MENU</string>
<string name="animate_arrow">ANIM ARROW</string>
<string name="animate_check">ANIM CHECK</string>
<string name="animate_x">ANIM X</string>
<string name="set_menu">SET MENU</string>
<string name="set_arrow">SET ARROW</string>
<string name="set_x">SET X</string>
<string name="set_check">SET CHECK</string>
<string name="title_activity_custom_view">Material menu</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ public interface MaterialMenu {
/**
* @return {@link MaterialMenuDrawable} to be used for the menu
*/
public abstract MaterialMenuDrawable getDrawable();
public MaterialMenuDrawable getDrawable();
}
Loading

0 comments on commit 66ded91

Please sign in to comment.