7 | In app you can see integrated navigation drawer with items containing different types of movie genres. Each item contains some (hard-coded) movie list related to the corresponding genre. When user clicks on one of the items the item will be expanded and the content of that item (actually it is list of the films of the given genre) will become visible. If user clicks on the expanded item the list of movies will be collapsed.
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | generateDebugSources
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.android.msahakyan.expandablenavigationdrawer"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:23.4.0'
25 | compile 'com.android.support:support-v4:23.4.0'
26 | }
27 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/msahakan/development/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer;
2 |
3 | import android.content.res.Configuration;
4 | import android.os.Bundle;
5 | import android.support.v4.view.GravityCompat;
6 | import android.support.v4.widget.DrawerLayout;
7 | import android.support.v7.app.ActionBarDrawerToggle;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.LayoutInflater;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.ExpandableListAdapter;
14 | import android.widget.ExpandableListView;
15 |
16 | import com.android.msahakyan.expandablenavigationdrawer.adapter.CustomExpandableListAdapter;
17 | import com.android.msahakyan.expandablenavigationdrawer.datasource.ExpandableListDataSource;
18 | import com.android.msahakyan.expandablenavigationdrawer.fragment.navigation.FragmentNavigationManager;
19 | import com.android.msahakyan.expandablenavigationdrawer.fragment.navigation.NavigationManager;
20 |
21 | import java.util.ArrayList;
22 | import java.util.List;
23 | import java.util.Map;
24 |
25 |
26 | public class MainActivity extends AppCompatActivity {
27 |
28 | private DrawerLayout mDrawerLayout;
29 | private ActionBarDrawerToggle mDrawerToggle;
30 | private String mActivityTitle;
31 | private String[] items;
32 |
33 | private ExpandableListView mExpandableListView;
34 | private ExpandableListAdapter mExpandableListAdapter;
35 | private List mExpandableListTitle;
36 | private NavigationManager mNavigationManager;
37 |
38 | private Map> mExpandableListData;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_main);
44 |
45 | mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
46 | mActivityTitle = getTitle().toString();
47 |
48 | mExpandableListView = (ExpandableListView) findViewById(R.id.navList);
49 | mNavigationManager = FragmentNavigationManager.obtain(this);
50 |
51 | initItems();
52 |
53 | LayoutInflater inflater = getLayoutInflater();
54 | View listHeaderView = inflater.inflate(R.layout.nav_header, null, false);
55 | mExpandableListView.addHeaderView(listHeaderView);
56 |
57 | mExpandableListData = ExpandableListDataSource.getData(this);
58 | mExpandableListTitle = new ArrayList(mExpandableListData.keySet());
59 |
60 | addDrawerItems();
61 | setupDrawer();
62 |
63 | if (savedInstanceState == null) {
64 | selectFirstItemAsDefault();
65 | }
66 |
67 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
68 | getSupportActionBar().setHomeButtonEnabled(true);
69 | }
70 |
71 | private void selectFirstItemAsDefault() {
72 | if (mNavigationManager != null) {
73 | String firstActionMovie = getResources().getStringArray(R.array.actionFilms)[0];
74 | mNavigationManager.showFragmentAction(firstActionMovie);
75 | getSupportActionBar().setTitle(firstActionMovie);
76 | }
77 | }
78 |
79 | private void initItems() {
80 | items = getResources().getStringArray(R.array.film_genre);
81 | }
82 |
83 | private void addDrawerItems() {
84 | mExpandableListAdapter = new CustomExpandableListAdapter(this, mExpandableListTitle, mExpandableListData);
85 | mExpandableListView.setAdapter(mExpandableListAdapter);
86 | mExpandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
87 | @Override
88 | public void onGroupExpand(int groupPosition) {
89 | getSupportActionBar().setTitle(mExpandableListTitle.get(groupPosition).toString());
90 | }
91 | });
92 |
93 | mExpandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
94 | @Override
95 | public void onGroupCollapse(int groupPosition) {
96 | getSupportActionBar().setTitle(R.string.film_genres);
97 | }
98 | });
99 |
100 | mExpandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
101 | @Override
102 | public boolean onChildClick(ExpandableListView parent, View v,
103 | int groupPosition, int childPosition, long id) {
104 | String selectedItem = ((List) (mExpandableListData.get(mExpandableListTitle.get(groupPosition))))
105 | .get(childPosition).toString();
106 | getSupportActionBar().setTitle(selectedItem);
107 |
108 | if (items[0].equals(mExpandableListTitle.get(groupPosition))) {
109 | mNavigationManager.showFragmentAction(selectedItem);
110 | } else if (items[1].equals(mExpandableListTitle.get(groupPosition))) {
111 | mNavigationManager.showFragmentComedy(selectedItem);
112 | } else if (items[2].equals(mExpandableListTitle.get(groupPosition))) {
113 | mNavigationManager.showFragmentDrama(selectedItem);
114 | } else if (items[3].equals(mExpandableListTitle.get(groupPosition))) {
115 | mNavigationManager.showFragmentMusical(selectedItem);
116 | } else if (items[4].equals(mExpandableListTitle.get(groupPosition))) {
117 | mNavigationManager.showFragmentThriller(selectedItem);
118 | } else {
119 | throw new IllegalArgumentException("Not supported fragment type");
120 | }
121 |
122 | mDrawerLayout.closeDrawer(GravityCompat.START);
123 | return false;
124 | }
125 | });
126 | }
127 |
128 | private void setupDrawer() {
129 | mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
130 |
131 | /** Called when a drawer has settled in a completely open state. */
132 | public void onDrawerOpened(View drawerView) {
133 | super.onDrawerOpened(drawerView);
134 | getSupportActionBar().setTitle(R.string.film_genres);
135 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
136 | }
137 |
138 | /** Called when a drawer has settled in a completely closed state. */
139 | public void onDrawerClosed(View view) {
140 | super.onDrawerClosed(view);
141 | getSupportActionBar().setTitle(mActivityTitle);
142 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
143 | }
144 | };
145 |
146 | mDrawerToggle.setDrawerIndicatorEnabled(true);
147 | mDrawerLayout.setDrawerListener(mDrawerToggle);
148 | }
149 |
150 | @Override
151 | protected void onPostCreate(Bundle savedInstanceState) {
152 | super.onPostCreate(savedInstanceState);
153 | // Sync the toggle state after onRestoreInstanceState has occurred.
154 | mDrawerToggle.syncState();
155 | }
156 |
157 | @Override
158 | public void onConfigurationChanged(Configuration newConfig) {
159 | super.onConfigurationChanged(newConfig);
160 | mDrawerToggle.onConfigurationChanged(newConfig);
161 | }
162 |
163 | @Override
164 | public boolean onCreateOptionsMenu(Menu menu) {
165 | // Inflate the menu; this adds items to the action bar if it is present.
166 | getMenuInflater().inflate(R.menu.menu_main, menu);
167 | return true;
168 | }
169 |
170 | @Override
171 | public boolean onOptionsItemSelected(MenuItem item) {
172 | // Handle action bar item clicks here. The action bar will
173 | // automatically handle clicks on the Home/Up button, so long
174 | // as you specify a parent activity in AndroidManifest.xml.
175 | int id = item.getItemId();
176 |
177 | // Activate the navigation drawer toggle
178 | if (mDrawerToggle.onOptionsItemSelected(item)) {
179 | return true;
180 | }
181 |
182 | return super.onOptionsItemSelected(item);
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/adapter/CustomExpandableListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseExpandableListAdapter;
9 | import android.widget.TextView;
10 |
11 | import com.android.msahakyan.expandablenavigationdrawer.R;
12 |
13 | import java.util.List;
14 | import java.util.Map;
15 |
16 | public class CustomExpandableListAdapter extends BaseExpandableListAdapter {
17 |
18 | private Context mContext;
19 | private List mExpandableListTitle;
20 | private Map> mExpandableListDetail;
21 | private LayoutInflater mLayoutInflater;
22 |
23 | public CustomExpandableListAdapter(Context context, List expandableListTitle,
24 | Map> expandableListDetail) {
25 | mContext = context;
26 | mExpandableListTitle = expandableListTitle;
27 | mExpandableListDetail = expandableListDetail;
28 | mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
29 | }
30 |
31 | @Override
32 | public Object getChild(int listPosition, int expandedListPosition) {
33 | return mExpandableListDetail.get(mExpandableListTitle.get(listPosition))
34 | .get(expandedListPosition);
35 | }
36 |
37 | @Override
38 | public long getChildId(int listPosition, int expandedListPosition) {
39 | return expandedListPosition;
40 | }
41 |
42 | @Override
43 | public View getChildView(int listPosition, final int expandedListPosition,
44 | boolean isLastChild, View convertView, ViewGroup parent) {
45 | final String expandedListText = (String) getChild(listPosition, expandedListPosition);
46 | if (convertView == null) {
47 | convertView = mLayoutInflater.inflate(R.layout.list_item, null);
48 | }
49 | TextView expandedListTextView = (TextView) convertView
50 | .findViewById(R.id.expandedListItem);
51 | expandedListTextView.setText(expandedListText);
52 | return convertView;
53 | }
54 |
55 | @Override
56 | public int getChildrenCount(int listPosition) {
57 | return mExpandableListDetail.get(mExpandableListTitle.get(listPosition))
58 | .size();
59 | }
60 |
61 | @Override
62 | public Object getGroup(int listPosition) {
63 | return mExpandableListTitle.get(listPosition);
64 | }
65 |
66 | @Override
67 | public int getGroupCount() {
68 | return mExpandableListTitle.size();
69 | }
70 |
71 | @Override
72 | public long getGroupId(int listPosition) {
73 | return listPosition;
74 | }
75 |
76 | @Override
77 | public View getGroupView(int listPosition, boolean isExpanded,
78 | View convertView, ViewGroup parent) {
79 | String listTitle = (String) getGroup(listPosition);
80 | if (convertView == null) {
81 | convertView = mLayoutInflater.inflate(R.layout.list_group, null);
82 | }
83 | TextView listTitleTextView = (TextView) convertView
84 | .findViewById(R.id.listTitle);
85 | listTitleTextView.setTypeface(null, Typeface.BOLD);
86 | listTitleTextView.setText(listTitle);
87 | return convertView;
88 | }
89 |
90 | @Override
91 | public boolean hasStableIds() {
92 | return false;
93 | }
94 |
95 | @Override
96 | public boolean isChildSelectable(int listPosition, int expandedListPosition) {
97 | return true;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/datasource/ExpandableListDataSource.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.datasource;
2 |
3 | import android.content.Context;
4 |
5 | import com.android.msahakyan.expandablenavigationdrawer.R;
6 |
7 | import java.util.Arrays;
8 | import java.util.List;
9 | import java.util.Map;
10 | import java.util.TreeMap;
11 |
12 | /**
13 | * Created by msahakyan on 22/10/15.
14 | */
15 | public class ExpandableListDataSource {
16 |
17 | /**
18 | * Returns fake data of films
19 | *
20 | * @param context
21 | * @return
22 | */
23 | public static Map> getData(Context context) {
24 | Map> expandableListData = new TreeMap<>();
25 |
26 | List filmGenres = Arrays.asList(context.getResources().getStringArray(R.array.film_genre));
27 |
28 | List actionFilms = Arrays.asList(context.getResources().getStringArray(R.array.actionFilms));
29 | List musicalFilms = Arrays.asList(context.getResources().getStringArray(R.array.musicals));
30 | List dramaFilms = Arrays.asList(context.getResources().getStringArray(R.array.dramas));
31 | List thrillerFilms = Arrays.asList(context.getResources().getStringArray(R.array.thrillers));
32 | List comedyFilms = Arrays.asList(context.getResources().getStringArray(R.array.comedies));
33 |
34 | expandableListData.put(filmGenres.get(0), actionFilms);
35 | expandableListData.put(filmGenres.get(1), musicalFilms);
36 | expandableListData.put(filmGenres.get(2), dramaFilms);
37 | expandableListData.put(filmGenres.get(3), thrillerFilms);
38 | expandableListData.put(filmGenres.get(4), comedyFilms);
39 |
40 | return expandableListData;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/FragmentACtion.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment;
2 |
3 | import android.graphics.PorterDuff;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v4.content.res.ResourcesCompat;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.android.msahakyan.expandablenavigationdrawer.R;
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | * Use the {@link FragmentAction#newInstance} factory method to
21 | * create an instance of this fragment.
22 | */
23 | public class FragmentAction extends Fragment {
24 |
25 | private static final String KEY_MOVIE_TITLE = "key_title";
26 |
27 | public FragmentAction() {
28 | // Required empty public constructor
29 | }
30 |
31 | /**
32 | * Use this factory method to create a new instance of
33 | * this fragment.
34 | *
35 | * @return A new instance of fragment FragmentAction.
36 | */
37 | public static FragmentAction newInstance(String movieTitle) {
38 | FragmentAction fragmentAction = new FragmentAction();
39 | Bundle args = new Bundle();
40 | args.putString(KEY_MOVIE_TITLE, movieTitle);
41 | fragmentAction.setArguments(args);
42 |
43 | return fragmentAction;
44 | }
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
53 | Bundle savedInstanceState) {
54 | // Inflate the layout for this fragment
55 | return inflater.inflate(R.layout.fragment_action, container, false);
56 | }
57 |
58 | @Override
59 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
60 | super.onViewCreated(view, savedInstanceState);
61 |
62 | Drawable movieIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.movie_icon, getContext().getTheme());
63 | if (movieIcon != null) {
64 | movieIcon.setColorFilter(ContextCompat.getColor(getContext(), R.color.pink), PorterDuff.Mode.SRC_ATOP);
65 | }
66 | ((ImageView) view.findViewById(R.id.movie_icon)).setImageDrawable(movieIcon);
67 |
68 | String movieTitle = getArguments().getString(KEY_MOVIE_TITLE);
69 | ((TextView) view.findViewById(R.id.movie_title)).setText(movieTitle);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/FragmentComedy.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment;
2 |
3 | import android.graphics.PorterDuff;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v4.content.res.ResourcesCompat;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.android.msahakyan.expandablenavigationdrawer.R;
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | * Use the {@link FragmentComedy#newInstance} factory method to
21 | * create an instance of this fragment.
22 | */
23 | public class FragmentComedy extends Fragment {
24 |
25 | private static final String KEY_MOVIE_TITLE = "key_title";
26 |
27 | public FragmentComedy() {
28 | // Required empty public constructor
29 | }
30 |
31 | /**
32 | * Use this factory method to create a new instance of
33 | * this fragment.
34 | *
35 | * @return A new instance of fragment FragmentComedy.
36 | */
37 | public static FragmentComedy newInstance(String movieTitle) {
38 | FragmentComedy fragmentComedy = new FragmentComedy();
39 | Bundle args = new Bundle();
40 | args.putString(KEY_MOVIE_TITLE, movieTitle);
41 | fragmentComedy.setArguments(args);
42 |
43 | return fragmentComedy;
44 | }
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
53 | Bundle savedInstanceState) {
54 | // Inflate the layout for this fragment
55 | return inflater.inflate(R.layout.fragment_comedy, container, false);
56 | }
57 |
58 | @Override
59 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
60 | super.onViewCreated(view, savedInstanceState);
61 |
62 | Drawable movieIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.movie_icon, getContext().getTheme());
63 | if (movieIcon != null) {
64 | movieIcon.setColorFilter(ContextCompat.getColor(getContext(), R.color.purple), PorterDuff.Mode.SRC_ATOP);
65 | }
66 | ((ImageView) view.findViewById(R.id.movie_icon)).setImageDrawable(movieIcon);
67 |
68 | String movieTitle = getArguments().getString(KEY_MOVIE_TITLE);
69 | ((TextView) view.findViewById(R.id.movie_title)).setText(movieTitle);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/FragmentDrama.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment;
2 |
3 | import android.graphics.PorterDuff;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v4.content.res.ResourcesCompat;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.android.msahakyan.expandablenavigationdrawer.R;
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | * Use the {@link FragmentDrama#newInstance} factory method to
21 | * create an instance of this fragment.
22 | */
23 | public class FragmentDrama extends Fragment {
24 |
25 | private static final String KEY_MOVIE_TITLE = "key_title";
26 |
27 | public FragmentDrama() {
28 | // Required empty public constructor
29 | }
30 |
31 | /**
32 | * Use this factory method to create a new instance of
33 | * this fragment.
34 | *
35 | * @return A new instance of fragment FragmentDrama.
36 | */
37 | public static FragmentDrama newInstance(String movieTitle) {
38 | FragmentDrama fragmentDrama = new FragmentDrama();
39 | Bundle args = new Bundle();
40 | args.putString(KEY_MOVIE_TITLE, movieTitle);
41 | fragmentDrama.setArguments(args);
42 |
43 | return fragmentDrama;
44 | }
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
53 | Bundle savedInstanceState) {
54 | // Inflate the layout for this fragment
55 | return inflater.inflate(R.layout.fragment_drama, container, false);
56 | }
57 |
58 | @Override
59 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
60 | super.onViewCreated(view, savedInstanceState);
61 |
62 | Drawable movieIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.movie_icon, getContext().getTheme());
63 | if (movieIcon != null) {
64 | movieIcon.setColorFilter(ContextCompat.getColor(getContext(), R.color.grey), PorterDuff.Mode.SRC_ATOP);
65 | }
66 | ((ImageView) view.findViewById(R.id.movie_icon)).setImageDrawable(movieIcon);
67 |
68 | String movieTitle = getArguments().getString(KEY_MOVIE_TITLE);
69 | ((TextView) view.findViewById(R.id.movie_title)).setText(movieTitle);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/FragmentMusical.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment;
2 |
3 | import android.graphics.PorterDuff;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v4.content.res.ResourcesCompat;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.android.msahakyan.expandablenavigationdrawer.R;
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | * Use the {@link FragmentMusical#newInstance} factory method to
21 | * create an instance of this fragment.
22 | */
23 | public class FragmentMusical extends Fragment {
24 |
25 | private static final String KEY_MOVIE_TITLE = "key_title";
26 |
27 | public FragmentMusical() {
28 | // Required empty public constructor
29 | }
30 |
31 | /**
32 | * Use this factory method to create a new instance of
33 | * this fragment.
34 | *
35 | * @return A new instance of fragment FragmentMusical.
36 | */
37 | public static FragmentMusical newInstance(String movieTitle) {
38 | FragmentMusical fragment = new FragmentMusical();
39 | Bundle args = new Bundle();
40 | args.putString(KEY_MOVIE_TITLE, movieTitle);
41 | fragment.setArguments(args);
42 |
43 | return fragment;
44 | }
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
53 | Bundle savedInstanceState) {
54 | // Inflate the layout for this fragment
55 | return inflater.inflate(R.layout.fragment_musical, container, false);
56 | }
57 |
58 | @Override
59 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
60 | super.onViewCreated(view, savedInstanceState);
61 |
62 | Drawable movieIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.movie_icon, getContext().getTheme());
63 | if (movieIcon != null) {
64 | movieIcon.setColorFilter(ContextCompat.getColor(getContext(), R.color.lime), PorterDuff.Mode.SRC_ATOP);
65 | }
66 | ((ImageView) view.findViewById(R.id.movie_icon)).setImageDrawable(movieIcon);
67 |
68 | String movieTitle = getArguments().getString(KEY_MOVIE_TITLE);
69 | ((TextView) view.findViewById(R.id.movie_title)).setText(movieTitle);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/FragmentThriller.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment;
2 |
3 | import android.graphics.PorterDuff;
4 | import android.graphics.drawable.Drawable;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v4.content.ContextCompat;
9 | import android.support.v4.content.res.ResourcesCompat;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import com.android.msahakyan.expandablenavigationdrawer.R;
17 |
18 | /**
19 | * A simple {@link Fragment} subclass.
20 | * Use the {@link FragmentThriller#newInstance} factory method to
21 | * create an instance of this fragment.
22 | */
23 | public class FragmentThriller extends Fragment {
24 |
25 | private static final String KEY_MOVIE_TITLE = "key_title";
26 |
27 | public FragmentThriller() {
28 | // Required empty public constructor
29 | }
30 |
31 | /**
32 | * Use this factory method to create a new instance of
33 | * this fragment.
34 | *
35 | * @return A new instance of fragment FragmentThriller.
36 | */
37 | public static FragmentThriller newInstance(String movieTitle) {
38 | FragmentThriller fragmentThriller = new FragmentThriller();
39 | Bundle args = new Bundle();
40 | args.putString(KEY_MOVIE_TITLE, movieTitle);
41 | fragmentThriller.setArguments(args);
42 |
43 | return fragmentThriller;
44 | }
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
53 | Bundle savedInstanceState) {
54 | // Inflate the layout for this fragment
55 | return inflater.inflate(R.layout.fragment_thriller, container, false);
56 | }
57 |
58 | @Override
59 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
60 | super.onViewCreated(view, savedInstanceState);
61 |
62 | Drawable movieIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.movie_icon, getContext().getTheme());
63 | if (movieIcon != null) {
64 | movieIcon.setColorFilter(ContextCompat.getColor(getContext(), R.color.orange), PorterDuff.Mode.SRC_ATOP);
65 | }
66 | ((ImageView) view.findViewById(R.id.movie_icon)).setImageDrawable(movieIcon);
67 |
68 | String movieTitle = getArguments().getString(KEY_MOVIE_TITLE);
69 | ((TextView) view.findViewById(R.id.movie_title)).setText(movieTitle);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/navigation/FragmentNavigationManager.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment.navigation;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentTransaction;
7 |
8 | import com.android.msahakyan.expandablenavigationdrawer.BuildConfig;
9 | import com.android.msahakyan.expandablenavigationdrawer.MainActivity;
10 | import com.android.msahakyan.expandablenavigationdrawer.R;
11 | import com.android.msahakyan.expandablenavigationdrawer.fragment.FragmentAction;
12 | import com.android.msahakyan.expandablenavigationdrawer.fragment.FragmentComedy;
13 | import com.android.msahakyan.expandablenavigationdrawer.fragment.FragmentDrama;
14 | import com.android.msahakyan.expandablenavigationdrawer.fragment.FragmentMusical;
15 | import com.android.msahakyan.expandablenavigationdrawer.fragment.FragmentThriller;
16 |
17 | /**
18 | * @author msahakyan
19 | */
20 |
21 | public class FragmentNavigationManager implements NavigationManager {
22 |
23 | private static FragmentNavigationManager sInstance;
24 |
25 | private FragmentManager mFragmentManager;
26 | private MainActivity mActivity;
27 |
28 | public static FragmentNavigationManager obtain(MainActivity activity) {
29 | if (sInstance == null) {
30 | sInstance = new FragmentNavigationManager();
31 | }
32 | sInstance.configure(activity);
33 | return sInstance;
34 | }
35 |
36 | private void configure(MainActivity activity) {
37 | mActivity = activity;
38 | mFragmentManager = mActivity.getSupportFragmentManager();
39 | }
40 |
41 | @Override
42 | public void showFragmentAction(String title) {
43 | showFragment(FragmentAction.newInstance(title), false);
44 | }
45 |
46 | @Override
47 | public void showFragmentComedy(String title) {
48 | showFragment(FragmentComedy.newInstance(title), false);
49 | }
50 |
51 | @Override
52 | public void showFragmentDrama(String title) {
53 | showFragment(FragmentDrama.newInstance(title), false);
54 | }
55 |
56 | @Override
57 | public void showFragmentMusical(String title) {
58 | showFragment(FragmentMusical.newInstance(title), false);
59 | }
60 |
61 | @Override
62 | public void showFragmentThriller(String title) {
63 | showFragment(FragmentThriller.newInstance(title), false);
64 | }
65 |
66 | private void showFragment(Fragment fragment, boolean allowStateLoss) {
67 | FragmentManager fm = mFragmentManager;
68 |
69 | @SuppressLint("CommitTransaction")
70 | FragmentTransaction ft = fm.beginTransaction()
71 | .replace(R.id.container, fragment);
72 |
73 | ft.addToBackStack(null);
74 |
75 | if (allowStateLoss || !BuildConfig.DEBUG) {
76 | ft.commitAllowingStateLoss();
77 | } else {
78 | ft.commit();
79 | }
80 |
81 | fm.executePendingTransactions();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/msahakyan/expandablenavigationdrawer/fragment/navigation/NavigationManager.java:
--------------------------------------------------------------------------------
1 | package com.android.msahakyan.expandablenavigationdrawer.fragment.navigation;
2 |
3 | /**
4 | * @author msahakyan
5 | */
6 |
7 | public interface NavigationManager {
8 |
9 | void showFragmentAction(String title);
10 |
11 | void showFragmentComedy(String title);
12 |
13 | void showFragmentDrama(String title);
14 |
15 | void showFragmentMusical(String title);
16 |
17 | void showFragmentThriller(String title);
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/header.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/drawable/header.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon_film.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/drawable/icon_film.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movie_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/drawable/movie_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_action.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
11 |
12 |
18 |
19 |
27 |
28 |
29 |
30 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_comedy.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
12 |
13 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_drama.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
11 |
12 |
18 |
19 |
27 |
28 |
29 |
30 |
31 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_musical.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
12 |
13 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_thriller.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
11 |
12 |
18 |
19 |
27 |
28 |
29 |
30 |
31 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_group.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
22 |
23 |
34 |
35 |
36 |
37 |
38 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #00695C
4 | #004D40
5 | #9C27B0
6 | #808080
7 | #AAAAAA
8 |
9 | #80CBC4
10 | #FFFFFF
11 |
12 | #E6EE9C
13 | #FFCC80
14 | #B0BEC5
15 | #B39DDB
16 | #F48FB1
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 10dp
7 | 10dp
8 | 70dp
9 | 0.5dp
10 |
11 | 235dp
12 |
13 | 14sp
14 | 300dp
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ExpandableNavigationDrawer
3 | Settings
4 | Open navigation drawer
5 | Close navigation drawer
6 | Film genres
7 | https://en.wikipedia.org/wiki/Film
8 | 22 Oct 2015
9 | Selected item
10 |
11 |
12 | Action
13 | Comedy
14 | Drama
15 | Musical
16 | Thriller
17 |
18 |
19 |
20 | Dr. No (1962)
21 | Goldfinger (1964)
22 | Thunderball (1965)
23 | Live and Let Die (1973)
24 | Moonraker (1979)
25 | For Your Eyes Only (1981)
26 | Octopussy (1983)
27 | A View to a Kill (1985)
28 | Licence to Kill (1989)
29 | GoldenEye (1995)
30 |
31 |
32 |
33 | Naughty Marietta (1935)
34 | Rose Marie (1936)
35 | Maytime (1937)
36 | Sweethearts (1938)
37 | Bitter Sweet (1940)
38 | New Moon (1940)
39 | I Married an Angel (1942)
40 | Lady Be Good (1941)
41 | Ship Ahoy (1942)
42 | Sensations of 1945 (1944)
43 |
44 |
45 |
46 | Home of the Brave (1949)
47 | The Accused (1949)
48 | 12 Angry Men (1957)
49 | Compulsion (1959)
50 | Inherit the Wind (1960)
51 | To Kill a Mockingbird (1962)
52 | Mrs. Miniver (1942)
53 | Since You Went Away (1944)
54 | The Champ (1931)
55 | Nashville (1975)
56 |
57 |
58 |
59 | Alien (1979)
60 | The French Connection (1971)
61 | High Noon (1952)
62 | Double Indemnity (1944)
63 | Safety Last (1923)
64 | The Lady From Shanghai (1948)
65 | The Third Man (1949)
66 | Rear Window (1954)
67 | The 39 Steps (1935)
68 | Shadow of a Doubt (1943)
69 |
70 |
71 |
72 | Safety Last (1923)
73 | Duck Soup (1933)
74 | Cat Ballou (1965)
75 | What\'s Up, Tiger Lily? (1966)
76 | Blazing Saddles (1974)
77 | Play It Again, Sam (1972)
78 | The Cheap Detective (1978)
79 | The Naked Gun (1988)
80 | The Freshman (1990)
81 | Waiting for Guffman (1996)
82 |
83 |
84 |
85 | Hello blank fragment
86 | movie title
87 | Action
88 | Musical
89 | Drama
90 | Comedy
91 | Thriller
92 | genre
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msahakyan/expandable-navigation-drawer/09c5f8ee778dc7322b06ea23ca64ab350a234251/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 23 09:53:41 CEST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------