Skip to content

Commit aa9a17e

Browse files
author
shrikanth7698
committed
Final commit for v0.0.1
1 parent ff93b65 commit aa9a17e

File tree

19 files changed

+363
-187
lines changed

19 files changed

+363
-187
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dependencies {
2424
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
2525
implementation 'com.android.support:cardview-v7:27.1.0'
2626
implementation 'com.android.support:recyclerview-v7:27.1.0'
27+
implementation 'com.android.support:support-v4:27.1.0'
2728
testImplementation 'junit:junit:4.12'
2829
androidTestImplementation 'com.android.support.test:runner:1.0.1'
2930
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.shrikanthravi.customnavigationdrawer;
2+
3+
4+
import android.os.Bundle;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
11+
/**
12+
* A simple {@link Fragment} subclass.
13+
*/
14+
public class FeedFragment extends Fragment {
15+
16+
17+
public FeedFragment() {
18+
// Required empty public constructor
19+
}
20+
21+
22+
@Override
23+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
24+
Bundle savedInstanceState) {
25+
// Inflate the layout for this fragment
26+
return inflater.inflate(R.layout.fragment_feed, container, false);
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,119 @@
11
package com.shrikanthravi.customnavigationdrawer;
22

3+
import android.support.v4.app.Fragment;
4+
import android.support.v4.app.FragmentManager;
35
import android.support.v7.app.AppCompatActivity;
46
import android.os.Bundle;
57

8+
import com.shrikanthravi.customnavigationdrawer2.data.MenuItem;
9+
import com.shrikanthravi.customnavigationdrawer2.widget.SNavigationDrawer;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
614
public class Main2Activity extends AppCompatActivity {
715

16+
SNavigationDrawer sNavigationDrawer;
17+
int color1=0;
18+
Class fragmentClass;
19+
public static Fragment fragment;
20+
821
@Override
922
protected void onCreate(Bundle savedInstanceState) {
1023
super.onCreate(savedInstanceState);
1124
setContentView(R.layout.activity_main2);
12-
getSupportActionBar().hide();
25+
if(getSupportActionBar()!=null) {
26+
getSupportActionBar().hide();
27+
}
28+
29+
sNavigationDrawer = findViewById(R.id.navigationDrawer);
30+
List<MenuItem> menuItems = new ArrayList<>();
31+
menuItems.add(new MenuItem("News",R.drawable.news_bg));
32+
menuItems.add(new MenuItem("Feed",R.drawable.feed_bg));
33+
menuItems.add(new MenuItem("Messages",R.drawable.message_bg));
34+
menuItems.add(new MenuItem("Music",R.drawable.music_bg));
35+
sNavigationDrawer.setMenuItemList(menuItems);
36+
fragmentClass = NewsFragment.class;
37+
try {
38+
fragment = (Fragment) fragmentClass.newInstance();
39+
} catch (Exception e) {
40+
e.printStackTrace();
41+
}
42+
if (fragment != null) {
43+
FragmentManager fragmentManager = getSupportFragmentManager();
44+
fragmentManager.beginTransaction().setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out).replace(R.id.frameLayout, fragment).commit();
45+
}
46+
47+
48+
sNavigationDrawer.setOnMenuItemClickListener(new SNavigationDrawer.OnMenuItemClickListener() {
49+
@Override
50+
public void onMenuItemClicked(int position) {
51+
System.out.println("Position "+position);
52+
53+
switch (position){
54+
case 0:{
55+
color1 = R.color.red;
56+
fragmentClass = NewsFragment.class;
57+
break;
58+
}
59+
case 1:{
60+
color1 = R.color.orange;
61+
fragmentClass = FeedFragment.class;
62+
break;
63+
}
64+
case 2:{
65+
color1 = R.color.green;
66+
fragmentClass = MessagesFragment.class;
67+
break;
68+
}
69+
case 3:{
70+
color1 = R.color.blue;
71+
fragmentClass = MusicFragment.class;
72+
break;
73+
}
74+
75+
}
76+
sNavigationDrawer.setDrawerListener(new SNavigationDrawer.DrawerListener() {
77+
78+
@Override
79+
public void onDrawerOpened() {
80+
81+
}
82+
83+
@Override
84+
public void onDrawerOpening(){
85+
86+
}
87+
88+
@Override
89+
public void onDrawerClosing(){
90+
System.out.println("Drawer closed");
91+
92+
try {
93+
fragment = (Fragment) fragmentClass.newInstance();
94+
} catch (Exception e) {
95+
e.printStackTrace();
96+
}
97+
98+
if (fragment != null) {
99+
FragmentManager fragmentManager = getSupportFragmentManager();
100+
fragmentManager.beginTransaction().setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out).replace(R.id.frameLayout, fragment).commit();
101+
102+
}
103+
}
104+
105+
@Override
106+
public void onDrawerClosed() {
107+
108+
}
109+
110+
@Override
111+
public void onDrawerStateChanged(int newState) {
112+
System.out.println("State "+newState);
113+
}
114+
});
115+
}
116+
});
117+
13118
}
14119
}

app/src/main/java/com/shrikanthravi/customnavigationdrawer/MenuItem.java

-39
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.shrikanthravi.customnavigationdrawer;
2+
3+
4+
import android.os.Bundle;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
11+
/**
12+
* A simple {@link Fragment} subclass.
13+
*/
14+
public class MessagesFragment extends Fragment {
15+
16+
17+
public MessagesFragment() {
18+
// Required empty public constructor
19+
}
20+
21+
22+
@Override
23+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
24+
Bundle savedInstanceState) {
25+
// Inflate the layout for this fragment
26+
return inflater.inflate(R.layout.fragment_messages, container, false);
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.shrikanthravi.customnavigationdrawer;
2+
3+
import android.content.Context;
4+
import android.net.Uri;
5+
import android.os.Bundle;
6+
import android.support.v4.app.Fragment;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
11+
12+
/**
13+
* A simple {@link Fragment} subclass.
14+
* Activities that contain this fragment must implement the
15+
* {@link MusicFragment.OnFragmentInteractionListener} interface
16+
* to handle interaction events.
17+
* Use the {@link MusicFragment#newInstance} factory method to
18+
* create an instance of this fragment.
19+
*/
20+
public class MusicFragment extends Fragment {
21+
22+
23+
public MusicFragment() {
24+
// Required empty public constructor
25+
}
26+
27+
28+
29+
30+
@Override
31+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
32+
Bundle savedInstanceState) {
33+
// Inflate the layout for this fragment
34+
return inflater.inflate(R.layout.fragment_music, container, false);
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.shrikanthravi.customnavigationdrawer;
2+
3+
4+
import android.os.Bundle;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
11+
/**
12+
* A simple {@link Fragment} subclass.
13+
*/
14+
public class NewsFragment extends Fragment {
15+
16+
17+
public NewsFragment() {
18+
// Required empty public constructor
19+
}
20+
21+
22+
@Override
23+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
24+
Bundle savedInstanceState) {
25+
// Inflate the layout for this fragment
26+
return inflater.inflate(R.layout.fragment_news, container, false);
27+
}
28+
29+
}

app/src/main/res/layout/activity_main2.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
tools:context=".Main2Activity">
88
<com.shrikanthravi.customnavigationdrawer2.widget.SNavigationDrawer
99
android:layout_width="match_parent"
10-
android:layout_height="match_parent">
10+
android:layout_height="match_parent"
11+
android:id="@+id/navigationDrawer">
1112
<FrameLayout
1213
android:id="@+id/frameLayout"
1314
android:layout_width="match_parent"
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#ffb067"
7+
tools:context=".FeedFragment">
8+
9+
<!-- TODO: Update blank fragment layout -->
10+
<TextView
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:layout_gravity="center"
14+
android:gravity="center"
15+
android:textColor="@android:color/white"
16+
android:textSize="20sp"
17+
android:textStyle="bold"
18+
android:text="Feed Fragment" />
19+
20+
</FrameLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#67ffae"
7+
tools:context=".MessagesFragment">
8+
9+
<!-- TODO: Update blank fragment layout -->
10+
<TextView
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:layout_gravity="center"
14+
android:gravity="center"
15+
android:textColor="@android:color/white"
16+
android:textSize="20sp"
17+
android:textStyle="bold"
18+
android:text="Messages Fragment" />
19+
20+
</FrameLayout>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#6785ff"
7+
tools:context=".MusicFragment">
8+
9+
<!-- TODO: Update blank fragment layout -->
10+
<TextView
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:layout_gravity="center"
14+
android:gravity="center"
15+
android:textColor="@android:color/white"
16+
android:textSize="20sp"
17+
android:textStyle="bold"
18+
android:text="Music Fragment" />
19+
20+
</FrameLayout>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#ff6767"
7+
tools:context=".NewsFragment">
8+
9+
<!-- TODO: Update blank fragment layout -->
10+
<TextView
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:layout_gravity="center"
14+
android:gravity="center"
15+
android:textSize="20sp"
16+
android:textColor="@android:color/white"
17+
android:textStyle="bold"
18+
android:text="News Fragment" />
19+
w
20+
</FrameLayout>

0 commit comments

Comments
 (0)