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
987407ef
Commit
987407ef
authored
Jul 16, 2017
by
Sajal Narang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Launch NotificationsFragment through main menu
parent
e02df0a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
+14
-18
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
...c/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
+14
-12
app/src/main/res/menu/main.xml
app/src/main/res/menu/main.xml
+0
-6
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/MainActivity.java
View file @
987407ef
...
...
@@ -51,6 +51,7 @@ public class MainActivity extends AppCompatActivity
private
static
final
String
TAG
=
"MainActivity"
;
SessionManager
session
;
NotificationsResponse
notificationsResponse
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -81,14 +82,7 @@ public class MainActivity extends AppCompatActivity
@Override
public
void
onResponse
(
Call
<
NotificationsResponse
>
call
,
Response
<
NotificationsResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
NotificationsResponse
notificationsResponse
=
response
.
body
();
String
notificationsResponseJson
=
new
Gson
().
toJson
(
notificationsResponse
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
NOTIFICATIONS_RESPONSE_JSON
,
notificationsResponseJson
);
NotificationsFragment
notificationsFragment
=
new
NotificationsFragment
();
notificationsFragment
.
setArguments
(
bundle
);
updateFragment
(
notificationsFragment
);
notificationsResponse
=
response
.
body
();
}
//Server Error
}
...
...
@@ -100,6 +94,15 @@ public class MainActivity extends AppCompatActivity
});
}
public
void
showNotifications
()
{
String
notificationsResponseJson
=
new
Gson
().
toJson
(
notificationsResponse
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
Constants
.
NOTIFICATIONS_RESPONSE_JSON
,
notificationsResponseJson
);
NotificationsFragment
notificationsFragment
=
new
NotificationsFragment
();
notificationsFragment
.
setArguments
(
bundle
);
updateFragment
(
notificationsFragment
);
}
@Override
public
void
onBackPressed
()
{
DrawerLayout
drawer
=
(
DrawerLayout
)
findViewById
(
R
.
id
.
drawer_layout
);
...
...
@@ -126,7 +129,9 @@ public class MainActivity extends AppCompatActivity
int
id
=
item
.
getItemId
();
//noinspection SimplifiableIfStatement
if
(
id
==
R
.
id
.
action_settings
)
{
if
(
id
==
R
.
id
.
action_notifications
)
{
fetchNotifications
();
showNotifications
();
return
true
;
}
...
...
@@ -176,11 +181,8 @@ public class MainActivity extends AppCompatActivity
if
(
ContextCompat
.
checkSelfPermission
(
MainActivity
.
this
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
}
else
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
0
);
break
;
case
R
.
id
.
nav_contacts
:
...
...
app/src/main/res/menu/main.xml
View file @
987407ef
...
...
@@ -7,10 +7,4 @@
android:icon=
"@drawable/ic_notifications_black_24dp"
android:title=
"Notifications"
app:showAsAction=
"always"
/>
<item
android:id=
"@+id/action_settings"
android:orderInCategory=
"100"
android:title=
"@string/action_settings"
app:showAsAction=
"never"
/>
</menu>
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