Skip to content

Commit ead8ada

Browse files
committed
added menu-arrow animation
1 parent 44c45c0 commit ead8ada

18 files changed

+492
-6
lines changed

app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ android {
1919
}
2020
}
2121

22+
2223
dependencies {
2324
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.android.support:appcompat-v7:21.0.+'
2525

26+
compile 'com.android.support:appcompat-v7:21.0.0'
27+
compile 'com.android.support:support-v4:21.0.0'
2628
}

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
<activity
1111
android:name=".FirstActivity"
1212
android:label="" >
13-
<intent-filter>
14-
<action android:name="android.intent.action.MAIN" />
1513

16-
<category android:name="android.intent.category.LAUNCHER" />
17-
</intent-filter>
1814
</activity>
1915
<activity
2016
android:name=".SecondActivity"
2117
android:label="@string/title_activity_my_activity2" >
2218
</activity>
19+
<activity
20+
android:name=".NavDrawerActivity"
21+
android:label="@string/title_activity_nav_drawer" >
22+
23+
<intent-filter>
24+
<action android:name="android.intent.action.MAIN" />
25+
<category android:name="android.intent.category.LAUNCHER" />
26+
</intent-filter>
27+
</activity>
2328
</application>
2429

2530
</manifest>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package com.saulmm.material;
2+
3+
import android.app.Activity;
4+
5+
import android.app.ActionBar;
6+
import android.app.Fragment;
7+
import android.app.FragmentManager;
8+
import android.content.Context;
9+
import android.os.Build;
10+
import android.os.Bundle;
11+
import android.view.Gravity;
12+
import android.view.LayoutInflater;
13+
import android.view.Menu;
14+
import android.view.MenuItem;
15+
import android.view.View;
16+
import android.view.ViewGroup;
17+
import android.support.v4.widget.DrawerLayout;
18+
import android.widget.ArrayAdapter;
19+
import android.widget.TextView;
20+
import com.saulmm.material.R;
21+
22+
public class NavDrawerActivity extends Activity
23+
implements NavigationDrawerFragment.NavigationDrawerCallbacks {
24+
25+
/**
26+
* Fragment managing the behaviors, interactions and presentation of the navigation drawer.
27+
*/
28+
private NavigationDrawerFragment mNavigationDrawerFragment;
29+
30+
/**
31+
* Used to store the last screen title. For use in {@link #restoreActionBar()}.
32+
*/
33+
private CharSequence mTitle;
34+
35+
@Override
36+
protected void onCreate(Bundle savedInstanceState) {
37+
super.onCreate(savedInstanceState);
38+
setContentView(R.layout.activity_nav_drawer);
39+
40+
mNavigationDrawerFragment = (NavigationDrawerFragment)
41+
getFragmentManager().findFragmentById(R.id.navigation_drawer);
42+
mTitle = getTitle();
43+
44+
// Set up the drawer.
45+
mNavigationDrawerFragment.setUp(
46+
R.id.navigation_drawer,
47+
(DrawerLayout) findViewById(R.id.drawer_layout));
48+
}
49+
50+
@Override
51+
public void onNavigationDrawerItemSelected(int position) {
52+
// update the main content by replacing fragments
53+
FragmentManager fragmentManager = getFragmentManager();
54+
fragmentManager.beginTransaction()
55+
.replace(R.id.container, PlaceholderFragment.newInstance(position + 1))
56+
.commit();
57+
}
58+
59+
60+
61+
public void restoreActionBar() {
62+
ActionBar actionBar = getActionBar();
63+
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
64+
actionBar.setDisplayShowTitleEnabled(true);
65+
actionBar.setTitle(mTitle);
66+
}
67+
68+
69+
70+
71+
@Override
72+
public boolean onOptionsItemSelected(MenuItem item) {
73+
// Handle action bar item clicks here. The action bar will
74+
// automatically handle clicks on the Home/Up button, so long
75+
// as you specify a parent activity in AndroidManifest.xml.
76+
int id = item.getItemId();
77+
if (id == R.id.action_settings) {
78+
return true;
79+
}
80+
return super.onOptionsItemSelected(item);
81+
}
82+
83+
/**
84+
* A placeholder fragment containing a simple view.
85+
*/
86+
public static class PlaceholderFragment extends Fragment {
87+
/**
88+
* The fragment argument representing the section number for this
89+
* fragment.
90+
*/
91+
private static final String ARG_SECTION_NUMBER = "section_number";
92+
93+
/**
94+
* Returns a new instance of this fragment for the given section
95+
* number.
96+
*/
97+
public static PlaceholderFragment newInstance(int sectionNumber) {
98+
PlaceholderFragment fragment = new PlaceholderFragment();
99+
Bundle args = new Bundle();
100+
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
101+
fragment.setArguments(args);
102+
return fragment;
103+
}
104+
105+
public PlaceholderFragment() {
106+
}
107+
108+
@Override
109+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
110+
Bundle savedInstanceState) {
111+
View rootView = inflater.inflate(R.layout.fragment_nav_drawer, container, false);
112+
return rootView;
113+
}
114+
115+
116+
}
117+
118+
}

0 commit comments

Comments
 (0)