Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
ba636ec6
Commit
ba636ec6
authored
Nov 29, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set selected nav item explicitly from fragments (fix #202)
parent
65911895
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
36 additions
and
1 deletion
+36
-1
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+11
-0
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+0
-1
app/src/main/java/app/insti/fragment/AboutFragment.java
app/src/main/java/app/insti/fragment/AboutFragment.java
+2
-0
app/src/main/java/app/insti/fragment/CalendarFragment.java
app/src/main/java/app/insti/fragment/CalendarFragment.java
+1
-0
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
+3
-0
app/src/main/java/app/insti/fragment/ExploreFragment.java
app/src/main/java/app/insti/fragment/ExploreFragment.java
+1
-0
app/src/main/java/app/insti/fragment/FeedFragment.java
app/src/main/java/app/insti/fragment/FeedFragment.java
+2
-0
app/src/main/java/app/insti/fragment/MapFragment.java
app/src/main/java/app/insti/fragment/MapFragment.java
+3
-0
app/src/main/java/app/insti/fragment/MessMenuFragment.java
app/src/main/java/app/insti/fragment/MessMenuFragment.java
+1
-0
app/src/main/java/app/insti/fragment/NewsFragment.java
app/src/main/java/app/insti/fragment/NewsFragment.java
+3
-0
app/src/main/java/app/insti/fragment/PlacementBlogFragment.java
...c/main/java/app/insti/fragment/PlacementBlogFragment.java
+3
-0
app/src/main/java/app/insti/fragment/QuickLinksFragment.java
app/src/main/java/app/insti/fragment/QuickLinksFragment.java
+2
-0
app/src/main/java/app/insti/fragment/SettingsFragment.java
app/src/main/java/app/insti/fragment/SettingsFragment.java
+1
-0
app/src/main/java/app/insti/fragment/TrainingBlogFragment.java
...rc/main/java/app/insti/fragment/TrainingBlogFragment.java
+3
-0
No files found.
app/src/main/java/app/insti/Utils.java
View file @
ba636ec6
package
app.insti
;
package
app.insti
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.design.widget.NavigationView
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentActivity
;
import
android.support.v4.app.FragmentActivity
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.app.FragmentTransaction
;
...
@@ -135,4 +137,13 @@ public final class Utils {
...
@@ -135,4 +137,13 @@ public final class Utils {
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
context
.
finish
();
context
.
finish
();
}
}
public
static
void
setSelectedMenuItem
(
Activity
activity
,
int
id
)
{
if
(
activity
!=
null
)
{
NavigationView
navigationView
=
activity
.
findViewById
(
R
.
id
.
nav_view
);
if
(
navigationView
!=
null
)
{
navigationView
.
setCheckedItem
(
id
);
}
}
}
}
}
app/src/main/java/app/insti/activity/MainActivity.java
View file @
ba636ec6
...
@@ -467,7 +467,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -467,7 +467,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private
void
initNavigationView
()
{
private
void
initNavigationView
()
{
NavigationView
navigationView
=
(
NavigationView
)
findViewById
(
R
.
id
.
nav_view
);
NavigationView
navigationView
=
(
NavigationView
)
findViewById
(
R
.
id
.
nav_view
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
navigationView
.
setNavigationItemSelectedListener
(
this
);
navigationView
.
setCheckedItem
(
initMenuChecked
);
}
}
private
void
updateNavigationView
()
{
private
void
updateNavigationView
()
{
...
...
app/src/main/java/app/insti/fragment/AboutFragment.java
View file @
ba636ec6
...
@@ -16,6 +16,7 @@ import java.util.HashMap;
...
@@ -16,6 +16,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
de.hdodenhof.circleimageview.CircleImageView
;
import
de.hdodenhof.circleimageview.CircleImageView
;
/**
/**
...
@@ -43,6 +44,7 @@ public class AboutFragment extends BaseFragment {
...
@@ -43,6 +44,7 @@ public class AboutFragment extends BaseFragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"About"
);
toolbar
.
setTitle
(
"About"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_settings
);
/* Map CircleImageView ids to image URLs */
/* Map CircleImageView ids to image URLs */
final
Map
<
Integer
,
String
>
team
=
new
HashMap
<
Integer
,
String
>()
{{
final
Map
<
Integer
,
String
>
team
=
new
HashMap
<
Integer
,
String
>()
{{
...
...
app/src/main/java/app/insti/fragment/CalendarFragment.java
View file @
ba636ec6
...
@@ -61,6 +61,7 @@ public class CalendarFragment extends BaseFragment {
...
@@ -61,6 +61,7 @@ public class CalendarFragment extends BaseFragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Calendar"
);
toolbar
.
setTitle
(
"Calendar"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_calendar
);
final
CalendarView
simpleCalendarView
=
(
CalendarView
)
view
.
findViewById
(
R
.
id
.
simpleCalendarView
);
// get the reference of CalendarView
final
CalendarView
simpleCalendarView
=
(
CalendarView
)
view
.
findViewById
(
R
.
id
.
simpleCalendarView
);
// get the reference of CalendarView
simpleCalendarView
.
setFirstDayOfWeek
(
1
);
// set Sunday as the first day of the week
simpleCalendarView
.
setFirstDayOfWeek
(
1
);
// set Sunday as the first day of the week
...
...
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
View file @
ba636ec6
...
@@ -16,6 +16,7 @@ import android.widget.Button;
...
@@ -16,6 +16,7 @@ import android.widget.Button;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.adapter.ComplaintFragmentViewPagerAdapter
;
import
app.insti.adapter.ComplaintFragmentViewPagerAdapter
;
public
class
ComplaintsFragment
extends
BaseFragment
{
public
class
ComplaintsFragment
extends
BaseFragment
{
...
@@ -28,8 +29,10 @@ public class ComplaintsFragment extends BaseFragment {
...
@@ -28,8 +29,10 @@ public class ComplaintsFragment extends BaseFragment {
Bundle
savedInstanceState
)
{
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
// Inflate the layout for this fragment
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_complaints
,
container
,
false
);
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_complaints
,
container
,
false
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Complaints/Suggestions"
);
toolbar
.
setTitle
(
"Complaints/Suggestions"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_complaint
);
Bundle
bundle
=
getArguments
();
Bundle
bundle
=
getArguments
();
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
...
...
app/src/main/java/app/insti/fragment/ExploreFragment.java
View file @
ba636ec6
...
@@ -83,6 +83,7 @@ public class ExploreFragment extends Fragment {
...
@@ -83,6 +83,7 @@ public class ExploreFragment extends Fragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Explore"
);
toolbar
.
setTitle
(
"Explore"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_explore
);
final
EditText
searchEditText
=
getView
().
findViewById
(
R
.
id
.
explore_search
);
final
EditText
searchEditText
=
getView
().
findViewById
(
R
.
id
.
explore_search
);
...
...
app/src/main/java/app/insti/fragment/FeedFragment.java
View file @
ba636ec6
...
@@ -52,6 +52,8 @@ public class FeedFragment extends BaseFragment {
...
@@ -52,6 +52,8 @@ public class FeedFragment extends BaseFragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Feed"
);
toolbar
.
setTitle
(
"Feed"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_feed
);
feedRecyclerView
=
view
.
findViewById
(
R
.
id
.
feed_recycler_view
);
feedRecyclerView
=
view
.
findViewById
(
R
.
id
.
feed_recycler_view
);
mLayoutManager
=
new
LinearLayoutManager
(
getContext
());
mLayoutManager
=
new
LinearLayoutManager
(
getContext
());
feedRecyclerView
.
setLayoutManager
(
mLayoutManager
);
feedRecyclerView
.
setLayoutManager
(
mLayoutManager
);
...
...
app/src/main/java/app/insti/fragment/MapFragment.java
View file @
ba636ec6
...
@@ -220,6 +220,9 @@ public class MapFragment extends Fragment implements TextWatcher,
...
@@ -220,6 +220,9 @@ public class MapFragment extends Fragment implements TextWatcher,
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"InstiMap"
);
toolbar
.
setTitle
(
"InstiMap"
);
/* Set selected menu item */
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_map
);
/* Initialize */
/* Initialize */
editText
=
(
EditText
)
getView
().
findViewById
(
R
.
id
.
search
);
editText
=
(
EditText
)
getView
().
findViewById
(
R
.
id
.
search
);
setFonts
();
setFonts
();
...
...
app/src/main/java/app/insti/fragment/MessMenuFragment.java
View file @
ba636ec6
...
@@ -60,6 +60,7 @@ public class MessMenuFragment extends BaseFragment {
...
@@ -60,6 +60,7 @@ public class MessMenuFragment extends BaseFragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Mess Menu"
);
toolbar
.
setTitle
(
"Mess Menu"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_mess_menu
);
hostel
=
(
String
)
getArguments
().
get
(
Constants
.
USER_HOSTEL
);
hostel
=
(
String
)
getArguments
().
get
(
Constants
.
USER_HOSTEL
);
displayMenu
(
hostel
);
displayMenu
(
hostel
);
...
...
app/src/main/java/app/insti/fragment/NewsFragment.java
View file @
ba636ec6
...
@@ -11,6 +11,7 @@ import android.view.ViewGroup;
...
@@ -11,6 +11,7 @@ import android.view.ViewGroup;
import
java.util.List
;
import
java.util.List
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.adapter.NewsAdapter
;
import
app.insti.adapter.NewsAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.NewsArticle
;
import
app.insti.api.model.NewsArticle
;
...
@@ -39,6 +40,8 @@ public class NewsFragment extends RecyclerViewFragment<NewsArticle, NewsAdapter>
...
@@ -39,6 +40,8 @@ public class NewsFragment extends RecyclerViewFragment<NewsArticle, NewsAdapter>
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"News"
);
toolbar
.
setTitle
(
"News"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_news
);
setHasOptionsMenu
(
true
);
setHasOptionsMenu
(
true
);
updateData
();
updateData
();
...
...
app/src/main/java/app/insti/fragment/PlacementBlogFragment.java
View file @
ba636ec6
...
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
...
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import
java.util.List
;
import
java.util.List
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.adapter.PlacementBlogAdapter
;
import
app.insti.adapter.PlacementBlogAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.PlacementBlogPost
;
import
app.insti.api.model.PlacementBlogPost
;
...
@@ -40,6 +41,8 @@ public class PlacementBlogFragment extends RecyclerViewFragment<PlacementBlogPos
...
@@ -40,6 +41,8 @@ public class PlacementBlogFragment extends RecyclerViewFragment<PlacementBlogPos
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Placement Blog"
);
toolbar
.
setTitle
(
"Placement Blog"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_placement_blog
);
setHasOptionsMenu
(
true
);
setHasOptionsMenu
(
true
);
updateData
();
updateData
();
...
...
app/src/main/java/app/insti/fragment/QuickLinksFragment.java
View file @
ba636ec6
...
@@ -10,6 +10,7 @@ import android.view.ViewGroup;
...
@@ -10,6 +10,7 @@ import android.view.ViewGroup;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
public
class
QuickLinksFragment
extends
BaseFragment
{
public
class
QuickLinksFragment
extends
BaseFragment
{
...
@@ -22,6 +23,7 @@ public class QuickLinksFragment extends BaseFragment {
...
@@ -22,6 +23,7 @@ public class QuickLinksFragment extends BaseFragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Quick Links"
);
toolbar
.
setTitle
(
"Quick Links"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_qlinks
);
TextView
CMS
=
getActivity
().
findViewById
(
R
.
id
.
button_CMS
);
TextView
CMS
=
getActivity
().
findViewById
(
R
.
id
.
button_CMS
);
TextView
CMSMaint
=
getActivity
().
findViewById
(
R
.
id
.
button_CMSMaint
);
TextView
CMSMaint
=
getActivity
().
findViewById
(
R
.
id
.
button_CMSMaint
);
...
...
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
ba636ec6
...
@@ -49,6 +49,7 @@ public class SettingsFragment extends Fragment {
...
@@ -49,6 +49,7 @@ public class SettingsFragment extends Fragment {
super
.
onStart
();
super
.
onStart
();
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Settings"
);
toolbar
.
setTitle
(
"Settings"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_settings
);
Bundle
bundle
=
getArguments
();
Bundle
bundle
=
getArguments
();
...
...
app/src/main/java/app/insti/fragment/TrainingBlogFragment.java
View file @
ba636ec6
...
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
...
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import
java.util.List
;
import
java.util.List
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.adapter.TrainingBlogAdapter
;
import
app.insti.adapter.TrainingBlogAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.TrainingBlogPost
;
import
app.insti.api.model.TrainingBlogPost
;
...
@@ -40,6 +41,8 @@ public class TrainingBlogFragment extends RecyclerViewFragment<TrainingBlogPost,
...
@@ -40,6 +41,8 @@ public class TrainingBlogFragment extends RecyclerViewFragment<TrainingBlogPost,
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Internship Blog"
);
toolbar
.
setTitle
(
"Internship Blog"
);
Utils
.
setSelectedMenuItem
(
getActivity
(),
R
.
id
.
nav_training_blog
);
setHasOptionsMenu
(
true
);
setHasOptionsMenu
(
true
);
updateData
();
updateData
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment