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
b853b15c
Commit
b853b15c
authored
Oct 01, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MAJOR REFACOR: move getSessionIDHeader and getRetrofitInterface to Utils
parent
a3e5d0d6
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
67 additions
and
49 deletions
+67
-49
app/src/main/java/app/insti/Utils.java
app/src/main/java/app/insti/Utils.java
+19
-0
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+11
-18
app/src/main/java/app/insti/fragment/AddEventFragment.java
app/src/main/java/app/insti/fragment/AddEventFragment.java
+6
-5
app/src/main/java/app/insti/fragment/BodyFragment.java
app/src/main/java/app/insti/fragment/BodyFragment.java
+4
-4
app/src/main/java/app/insti/fragment/CalendarFragment.java
app/src/main/java/app/insti/fragment/CalendarFragment.java
+3
-2
app/src/main/java/app/insti/fragment/EventFragment.java
app/src/main/java/app/insti/fragment/EventFragment.java
+2
-2
app/src/main/java/app/insti/fragment/ExploreFragment.java
app/src/main/java/app/insti/fragment/ExploreFragment.java
+4
-3
app/src/main/java/app/insti/fragment/FeedFragment.java
app/src/main/java/app/insti/fragment/FeedFragment.java
+2
-2
app/src/main/java/app/insti/fragment/MapFragment.java
app/src/main/java/app/insti/fragment/MapFragment.java
+2
-1
app/src/main/java/app/insti/fragment/MessMenuFragment.java
app/src/main/java/app/insti/fragment/MessMenuFragment.java
+2
-1
app/src/main/java/app/insti/fragment/NotificationsFragment.java
...c/main/java/app/insti/fragment/NotificationsFragment.java
+4
-4
app/src/main/java/app/insti/fragment/RecyclerViewFragment.java
...rc/main/java/app/insti/fragment/RecyclerViewFragment.java
+5
-4
app/src/main/java/app/insti/fragment/SettingsFragment.java
app/src/main/java/app/insti/fragment/SettingsFragment.java
+2
-2
app/src/main/java/app/insti/fragment/UserFragment.java
app/src/main/java/app/insti/fragment/UserFragment.java
+1
-1
No files found.
app/src/main/java/app/insti/Utils.java
View file @
b853b15c
...
@@ -11,6 +11,7 @@ import com.google.gson.Gson;
...
@@ -11,6 +11,7 @@ import com.google.gson.Gson;
import
com.squareup.picasso.Callback
;
import
com.squareup.picasso.Callback
;
import
com.squareup.picasso.Picasso
;
import
com.squareup.picasso.Picasso
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.Body
;
import
app.insti.api.model.Body
;
import
app.insti.api.model.Event
;
import
app.insti.api.model.Event
;
import
app.insti.api.model.User
;
import
app.insti.api.model.User
;
...
@@ -19,6 +20,8 @@ import app.insti.fragment.EventFragment;
...
@@ -19,6 +20,8 @@ import app.insti.fragment.EventFragment;
import
app.insti.fragment.UserFragment
;
import
app.insti.fragment.UserFragment
;
public
final
class
Utils
{
public
final
class
Utils
{
private
static
String
sessionId
;
private
static
RetrofitInterface
retrofitInterface
;
public
static
UpdatableList
<
Event
>
eventCache
=
new
UpdatableList
<>();
public
static
UpdatableList
<
Event
>
eventCache
=
new
UpdatableList
<>();
public
static
final
void
loadImageWithPlaceholder
(
final
ImageView
imageView
,
final
String
url
)
{
public
static
final
void
loadImageWithPlaceholder
(
final
ImageView
imageView
,
final
String
url
)
{
...
@@ -79,4 +82,20 @@ public final class Utils {
...
@@ -79,4 +82,20 @@ public final class Utils {
userFragment
.
setArguments
(
bundle
);
userFragment
.
setArguments
(
bundle
);
updateFragment
(
userFragment
,
fragmentActivity
);
updateFragment
(
userFragment
,
fragmentActivity
);
}
}
public
static
void
setSessionId
(
String
sessionId1
)
{
sessionId
=
sessionId1
;
}
public
static
String
getSessionIDHeader
()
{
return
"sessionid="
+
sessionId
;
}
public
static
RetrofitInterface
getRetrofitInterface
()
{
return
retrofitInterface
;
}
public
static
void
setRetrofitInterface
(
RetrofitInterface
retrofitInterface
)
{
Utils
.
retrofitInterface
=
retrofitInterface
;
}
}
}
app/src/main/java/app/insti/activity/MainActivity.java
View file @
b853b15c
...
@@ -43,6 +43,7 @@ import java.util.List;
...
@@ -43,6 +43,7 @@ import java.util.List;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.SessionManager
;
import
app.insti.SessionManager
;
import
app.insti.Utils
;
import
app.insti.api.EmptyCallback
;
import
app.insti.api.EmptyCallback
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.api.ServiceGenerator
;
...
@@ -90,15 +91,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -90,15 +91,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private
boolean
showNotifications
=
false
;
private
boolean
showNotifications
=
false
;
private
BackHandledFragment
selectedFragment
;
private
BackHandledFragment
selectedFragment
;
private
Menu
menu
;
private
Menu
menu
;
private
RetrofitInterface
retrofitInterface
;
/** which menu item should be checked on activity start */
/** which menu item should be checked on activity start */
private
int
initMenuChecked
=
R
.
id
.
nav_feed
;
private
int
initMenuChecked
=
R
.
id
.
nav_feed
;
public
RetrofitInterface
getRetrofitInterface
()
{
return
retrofitInterface
;
}
public
static
void
hideKeyboard
(
Activity
activity
)
{
public
static
void
hideKeyboard
(
Activity
activity
)
{
InputMethodManager
imm
=
(
InputMethodManager
)
activity
.
getSystemService
(
Activity
.
INPUT_METHOD_SERVICE
);
InputMethodManager
imm
=
(
InputMethodManager
)
activity
.
getSystemService
(
Activity
.
INPUT_METHOD_SERVICE
);
//Find the currently focused view, so we can grab the correct window token from it.
//Find the currently focused view, so we can grab the correct window token from it.
...
@@ -115,7 +111,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -115,7 +111,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
this
.
retrofitInterface
=
serviceGenerator
.
getRetrofitInterface
(
);
Utils
.
setRetrofitInterface
(
serviceGenerator
.
getRetrofitInterface
()
);
/* Make notification channel on oreo */
/* Make notification channel on oreo */
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
O
)
{
if
(
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
O
)
{
...
@@ -151,8 +147,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -151,8 +147,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
private
void
fetchNotifications
()
{
private
void
fetchNotifications
()
{
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getNotifications
(
getSessionIDHeader
()).
enqueue
(
new
EmptyCallback
<
List
<
Notification
>>()
{
retrofitInterface
.
getNotifications
(
Utils
.
getSessionIDHeader
()).
enqueue
(
new
EmptyCallback
<
List
<
Notification
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Notification
>>
call
,
Response
<
List
<
Notification
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Notification
>>
call
,
Response
<
List
<
Notification
>>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
@@ -181,7 +177,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -181,7 +177,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private
void
checkLatestVersion
()
{
private
void
checkLatestVersion
()
{
final
int
versionCode
=
getCurrentVersion
();
final
int
versionCode
=
getCurrentVersion
();
if
(
versionCode
==
0
)
{
return
;
}
if
(
versionCode
==
0
)
{
return
;
}
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getLatestVersion
().
enqueue
(
new
EmptyCallback
<
JsonObject
>()
{
retrofitInterface
.
getLatestVersion
().
enqueue
(
new
EmptyCallback
<
JsonObject
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
...
@@ -247,7 +243,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -247,7 +243,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/* Mark the notification read */
/* Mark the notification read */
final
String
notificationId
=
bundle
.
getString
(
FCM_BUNDLE_NOTIFICATION_ID
);
final
String
notificationId
=
bundle
.
getString
(
FCM_BUNDLE_NOTIFICATION_ID
);
if
(
notificationId
!=
null
)
{
if
(
notificationId
!=
null
)
{
getRetrofitInterface
().
markNotificationRead
(
getSessionIDHeader
(),
notificationId
).
enqueue
(
new
EmptyCallback
<
Void
>());
Utils
.
getRetrofitInterface
().
markNotificationRead
(
Utils
.
getSessionIDHeader
(),
notificationId
).
enqueue
(
new
EmptyCallback
<
Void
>());
}
}
/* Follow the notification */
/* Follow the notification */
...
@@ -323,8 +319,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -323,8 +319,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/** Open the event fragment from the provided id */
/** Open the event fragment from the provided id */
private
void
openEventFragment
(
String
id
)
{
private
void
openEventFragment
(
String
id
)
{
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getEvent
(
getSessionIDHeader
(),
id
).
enqueue
(
new
EmptyCallback
<
Event
>()
{
retrofitInterface
.
getEvent
(
Utils
.
getSessionIDHeader
(),
id
).
enqueue
(
new
EmptyCallback
<
Event
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Event
>
call
,
Response
<
Event
>
response
)
{
public
void
onResponse
(
Call
<
Event
>
call
,
Response
<
Event
>
response
)
{
EventFragment
eventFragment
=
new
EventFragment
();
EventFragment
eventFragment
=
new
EventFragment
();
...
@@ -366,6 +362,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -366,6 +362,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
super
.
onStart
();
super
.
onStart
();
initNavigationView
();
initNavigationView
();
if
(
session
.
isLoggedIn
())
{
if
(
session
.
isLoggedIn
())
{
Utils
.
setSessionId
(
session
.
getSessionID
());
currentUser
=
User
.
fromString
(
session
.
pref
.
getString
(
Constants
.
CURRENT_USER
,
""
));
currentUser
=
User
.
fromString
(
session
.
pref
.
getString
(
Constants
.
CURRENT_USER
,
""
));
updateNavigationView
();
updateNavigationView
();
updateFCMId
();
updateFCMId
();
...
@@ -380,9 +377,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -380,9 +377,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override
@Override
public
void
onSuccess
(
InstanceIdResult
instanceIdResult
)
{
public
void
onSuccess
(
InstanceIdResult
instanceIdResult
)
{
final
String
fcmId
=
instanceIdResult
.
getToken
();
final
String
fcmId
=
instanceIdResult
.
getToken
();
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
patchUserMe
(
getSessionIDHeader
(),
new
UserFCMPatchRequest
(
fcmId
,
getCurrentVersion
())).
enqueue
(
new
EmptyCallback
<
User
>()
{
retrofitInterface
.
patchUserMe
(
Utils
.
getSessionIDHeader
(),
new
UserFCMPatchRequest
(
fcmId
,
getCurrentVersion
())).
enqueue
(
new
EmptyCallback
<
User
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
@@ -597,10 +594,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -597,10 +594,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
}
}
public
String
getSessionIDHeader
()
{
return
"sessionid="
+
session
.
getSessionID
();
}
@Override
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
...
...
app/src/main/java/app/insti/fragment/AddEventFragment.java
View file @
b853b15c
...
@@ -26,6 +26,7 @@ import com.google.gson.Gson;
...
@@ -26,6 +26,7 @@ import com.google.gson.Gson;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.Body
;
import
app.insti.api.model.Body
;
...
@@ -77,7 +78,7 @@ public class AddEventFragment extends BaseFragment {
...
@@ -77,7 +78,7 @@ public class AddEventFragment extends BaseFragment {
webView
.
setWebViewClient
(
new
MyWebViewClient
());
webView
.
setWebViewClient
(
new
MyWebViewClient
());
CookieManager
cookieManager
=
CookieManager
.
getInstance
();
CookieManager
cookieManager
=
CookieManager
.
getInstance
();
String
cookieString
=
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
();
String
cookieString
=
Utils
.
getSessionIDHeader
();
cookieManager
.
setCookie
(
host
,
cookieString
);
cookieManager
.
setCookie
(
host
,
cookieString
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP_MR1
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP_MR1
)
{
CookieManager
.
getInstance
().
flush
();
CookieManager
.
getInstance
().
flush
();
...
@@ -166,8 +167,8 @@ public class AddEventFragment extends BaseFragment {
...
@@ -166,8 +167,8 @@ public class AddEventFragment extends BaseFragment {
if
(
url
.
contains
(
"/event/"
))
{
if
(
url
.
contains
(
"/event/"
))
{
url
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
url
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getEvent
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Event
>()
{
retrofitInterface
.
getEvent
(
Utils
.
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Event
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Event
>
call
,
Response
<
Event
>
response
)
{
public
void
onResponse
(
Call
<
Event
>
call
,
Response
<
Event
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
@@ -184,8 +185,8 @@ public class AddEventFragment extends BaseFragment {
...
@@ -184,8 +185,8 @@ public class AddEventFragment extends BaseFragment {
}
else
if
(
url
.
contains
(
"/org/"
))
{
}
else
if
(
url
.
contains
(
"/org/"
))
{
url
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
url
=
url
.
substring
(
url
.
lastIndexOf
(
"/"
)
+
1
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getBody
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Body
>()
{
retrofitInterface
.
getBody
(
Utils
.
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Body
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
...
app/src/main/java/app/insti/fragment/BodyFragment.java
View file @
b853b15c
...
@@ -146,8 +146,8 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -146,8 +146,8 @@ public class BodyFragment extends BackHandledFragment {
}
}
private
void
updateBody
()
{
private
void
updateBody
()
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getBody
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
(),
min_body
.
getBodyID
()).
enqueue
(
new
Callback
<
Body
>()
{
retrofitInterface
.
getBody
(
Utils
.
getSessionIDHeader
(),
min_body
.
getBodyID
()).
enqueue
(
new
Callback
<
Body
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
public
void
onResponse
(
Call
<
Body
>
call
,
Response
<
Body
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
@@ -223,8 +223,8 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -223,8 +223,8 @@ public class BodyFragment extends BackHandledFragment {
followButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
followButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
updateBodyFollowing
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
(),
body
.
getBodyID
(),
body
.
getBodyUserFollows
()
?
0
:
1
).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
updateBodyFollowing
(
Utils
.
getSessionIDHeader
(),
body
.
getBodyID
(),
body
.
getBodyUserFollows
()
?
0
:
1
).
enqueue
(
new
Callback
<
Void
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
...
app/src/main/java/app/insti/fragment/CalendarFragment.java
View file @
b853b15c
...
@@ -29,6 +29,7 @@ import java.util.List;
...
@@ -29,6 +29,7 @@ import java.util.List;
import
java.util.TimeZone
;
import
java.util.TimeZone
;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.Utils
;
import
app.insti.interfaces.ItemClickListener
;
import
app.insti.interfaces.ItemClickListener
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
...
@@ -118,8 +119,8 @@ public class CalendarFragment extends BaseFragment {
...
@@ -118,8 +119,8 @@ public class CalendarFragment extends BaseFragment {
final
String
oneMonthBack
=
isoFormatter
.
format
(
oneMonthBackDate
).
toString
();
final
String
oneMonthBack
=
isoFormatter
.
format
(
oneMonthBackDate
).
toString
();
final
String
oneMonthOn
=
isoFormatter
.
format
(
oneMonthOnDate
).
toString
();
final
String
oneMonthOn
=
isoFormatter
.
format
(
oneMonthOnDate
).
toString
();
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getEventsBetweenDates
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
(),
oneMonthBack
,
oneMonthOn
).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
retrofitInterface
.
getEventsBetweenDates
(
Utils
.
getSessionIDHeader
(),
oneMonthBack
,
oneMonthOn
).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
...
app/src/main/java/app/insti/fragment/EventFragment.java
View file @
b853b15c
...
@@ -275,8 +275,8 @@ public class EventFragment extends BackHandledFragment {
...
@@ -275,8 +275,8 @@ public class EventFragment extends BackHandledFragment {
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
final
int
endStatus
=
event
.
getEventUserUes
()
==
status
?
0
:
status
;
final
int
endStatus
=
event
.
getEventUserUes
()
==
status
?
0
:
status
;
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
updateUserEventStatus
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
(),
event
.
getEventID
(),
endStatus
).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
updateUserEventStatus
(
Utils
.
getSessionIDHeader
(),
event
.
getEventID
(),
endStatus
).
enqueue
(
new
Callback
<
Void
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
...
app/src/main/java/app/insti/fragment/ExploreFragment.java
View file @
b853b15c
...
@@ -18,6 +18,7 @@ import java.util.ArrayList;
...
@@ -18,6 +18,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.BodyAdapter
;
import
app.insti.adapter.BodyAdapter
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.adapter.FeedAdapter
;
...
@@ -77,7 +78,7 @@ public class ExploreFragment extends Fragment {
...
@@ -77,7 +78,7 @@ public class ExploreFragment extends Fragment {
super
.
onStart
();
super
.
onStart
();
// Initialize
// Initialize
sessionId
=
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
();
sessionId
=
Utils
.
getSessionIDHeader
();
initRecyclerViews
();
initRecyclerViews
();
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
...
@@ -85,7 +86,7 @@ public class ExploreFragment extends Fragment {
...
@@ -85,7 +86,7 @@ public class ExploreFragment extends Fragment {
// Get all bodies
// Get all bodies
if
(
allBodies
.
size
()
==
0
)
{
if
(
allBodies
.
size
()
==
0
)
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getAllBodies
(
sessionId
).
enqueue
(
new
EmptyCallback
<
List
<
Body
>>()
{
retrofitInterface
.
getAllBodies
(
sessionId
).
enqueue
(
new
EmptyCallback
<
List
<
Body
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Body
>>
call
,
Response
<
List
<
Body
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Body
>>
call
,
Response
<
List
<
Body
>>
response
)
{
...
@@ -136,7 +137,7 @@ public class ExploreFragment extends Fragment {
...
@@ -136,7 +137,7 @@ public class ExploreFragment extends Fragment {
currentQuery
=
query
;
currentQuery
=
query
;
// Make request
// Make request
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
search
(
sessionId
,
query
).
enqueue
(
new
EmptyCallback
<
ExploreResponse
>()
{
retrofitInterface
.
search
(
sessionId
,
query
).
enqueue
(
new
EmptyCallback
<
ExploreResponse
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
ExploreResponse
>
call
,
Response
<
ExploreResponse
>
response
)
{
public
void
onResponse
(
Call
<
ExploreResponse
>
call
,
Response
<
ExploreResponse
>
response
)
{
...
...
app/src/main/java/app/insti/fragment/FeedFragment.java
View file @
b853b15c
...
@@ -100,8 +100,8 @@ public class FeedFragment extends BaseFragment {
...
@@ -100,8 +100,8 @@ public class FeedFragment extends BaseFragment {
private
void
updateFeed
()
{
private
void
updateFeed
()
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getNewsFeed
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
()).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
retrofitInterface
.
getNewsFeed
(
Utils
.
getSessionIDHeader
()).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
...
app/src/main/java/app/insti/fragment/MapFragment.java
View file @
b853b15c
...
@@ -87,6 +87,7 @@ import java.util.regex.Pattern;
...
@@ -87,6 +87,7 @@ import java.util.regex.Pattern;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.model.Venue
;
import
app.insti.api.model.Venue
;
...
@@ -226,7 +227,7 @@ public class MapFragment extends Fragment implements TextWatcher,
...
@@ -226,7 +227,7 @@ public class MapFragment extends Fragment implements TextWatcher,
}
}
private
void
getAPILocations
()
{
private
void
getAPILocations
()
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getAllVenues
().
enqueue
(
new
Callback
<
List
<
Venue
>>()
{
retrofitInterface
.
getAllVenues
().
enqueue
(
new
Callback
<
List
<
Venue
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Venue
>>
call
,
Response
<
List
<
Venue
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Venue
>>
call
,
Response
<
List
<
Venue
>>
response
)
{
...
...
app/src/main/java/app/insti/fragment/MessMenuFragment.java
View file @
b853b15c
...
@@ -23,6 +23,7 @@ import java.util.Locale;
...
@@ -23,6 +23,7 @@ import java.util.Locale;
import
app.insti.ActivityBuffer
;
import
app.insti.ActivityBuffer
;
import
app.insti.Constants
;
import
app.insti.Constants
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.MessMenuAdapter
;
import
app.insti.adapter.MessMenuAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
...
@@ -107,7 +108,7 @@ public class MessMenuFragment extends BaseFragment {
...
@@ -107,7 +108,7 @@ public class MessMenuFragment extends BaseFragment {
}
}
private
void
updateMessMenu
(
final
String
hostel
)
{
private
void
updateMessMenu
(
final
String
hostel
)
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getInstituteMessMenu
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
)).
enqueue
(
new
Callback
<
List
<
HostelMessMenu
>>()
{
retrofitInterface
.
getInstituteMessMenu
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
)).
enqueue
(
new
Callback
<
List
<
HostelMessMenu
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
HostelMessMenu
>>
call
,
Response
<
List
<
HostelMessMenu
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
HostelMessMenu
>>
call
,
Response
<
List
<
HostelMessMenu
>>
response
)
{
...
...
app/src/main/java/app/insti/fragment/NotificationsFragment.java
View file @
b853b15c
...
@@ -59,8 +59,8 @@ public class NotificationsFragment extends BaseFragment {
...
@@ -59,8 +59,8 @@ public class NotificationsFragment extends BaseFragment {
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
Toolbar
toolbar
=
getActivity
().
findViewById
(
R
.
id
.
toolbar
);
toolbar
.
setTitle
(
"Notifications"
);
toolbar
.
setTitle
(
"Notifications"
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getNotifications
(
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
()).
enqueue
(
new
Callback
<
List
<
Notification
>>()
{
retrofitInterface
.
getNotifications
(
Utils
.
getSessionIDHeader
()).
enqueue
(
new
Callback
<
List
<
Notification
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
Notification
>>
call
,
Response
<
List
<
Notification
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
Notification
>>
call
,
Response
<
List
<
Notification
>>
response
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
...
@@ -89,8 +89,8 @@ public class NotificationsFragment extends BaseFragment {
...
@@ -89,8 +89,8 @@ public class NotificationsFragment extends BaseFragment {
Notification
notification
=
notifications
.
get
(
position
);
Notification
notification
=
notifications
.
get
(
position
);
/* Mark notification read */
/* Mark notification read */
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
String
sessId
=
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
();
String
sessId
=
Utils
.
getSessionIDHeader
();
retrofitInterface
.
markNotificationRead
(
sessId
,
notification
.
getNotificationId
().
toString
()).
enqueue
(
new
EmptyCallback
<
Void
>());
retrofitInterface
.
markNotificationRead
(
sessId
,
notification
.
getNotificationId
().
toString
()).
enqueue
(
new
EmptyCallback
<
Void
>());
/* Open event */
/* Open event */
...
...
app/src/main/java/app/insti/fragment/RecyclerViewFragment.java
View file @
b853b15c
...
@@ -20,6 +20,7 @@ import java.util.Objects;
...
@@ -20,6 +20,7 @@ import java.util.Objects;
import
app.insti.ActivityBuffer
;
import
app.insti.ActivityBuffer
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.interfaces.Browsable
;
import
app.insti.interfaces.Browsable
;
...
@@ -55,8 +56,8 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
...
@@ -55,8 +56,8 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
final
String
requestSearchQuery
=
searchQuery
;
final
String
requestSearchQuery
=
searchQuery
;
// Make the request
// Make the request
String
sessionIDHeader
=
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
();
String
sessionIDHeader
=
Utils
.
getSessionIDHeader
();
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
Call
<
List
<
T
>>
call
=
getCall
(
retrofitInterface
,
sessionIDHeader
,
0
);
Call
<
List
<
T
>>
call
=
getCall
(
retrofitInterface
,
sessionIDHeader
,
0
);
call
.
enqueue
(
new
Callback
<
List
<
T
>>()
{
call
.
enqueue
(
new
Callback
<
List
<
T
>>()
{
@Override
@Override
...
@@ -129,8 +130,8 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
...
@@ -129,8 +130,8 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
LinearLayoutManager
layoutManager
=
(
LinearLayoutManager
)
recyclerView
.
getLayoutManager
();
LinearLayoutManager
layoutManager
=
(
LinearLayoutManager
)
recyclerView
.
getLayoutManager
();
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
)
&&
(!
allLoaded
))
{
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
)
&&
(!
allLoaded
))
{
loading
=
true
;
loading
=
true
;
String
sessionIDHeader
=
((
MainActivity
)
getActivity
())
.
getSessionIDHeader
();
String
sessionIDHeader
=
Utils
.
getSessionIDHeader
();
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
Call
<
List
<
T
>>
call
=
getCall
(
retrofitInterface
,
sessionIDHeader
,
getPostCount
());
Call
<
List
<
T
>>
call
=
getCall
(
retrofitInterface
,
sessionIDHeader
,
getPostCount
());
call
.
enqueue
(
new
Callback
<
List
<
T
>>()
{
call
.
enqueue
(
new
Callback
<
List
<
T
>>()
{
@Override
@Override
...
...
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
b853b15c
...
@@ -56,7 +56,7 @@ public class SettingsFragment extends Fragment {
...
@@ -56,7 +56,7 @@ public class SettingsFragment extends Fragment {
populateViews
();
populateViews
();
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getUser
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
userID
).
enqueue
(
new
Callback
<
User
>()
{
retrofitInterface
.
getUser
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
userID
).
enqueue
(
new
Callback
<
User
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
...
@@ -132,7 +132,7 @@ public class SettingsFragment extends Fragment {
...
@@ -132,7 +132,7 @@ public class SettingsFragment extends Fragment {
logoutButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
logoutButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
logout
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
)).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
logout
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
)).
enqueue
(
new
Callback
<
Void
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
...
...
app/src/main/java/app/insti/fragment/UserFragment.java
View file @
b853b15c
...
@@ -108,7 +108,7 @@ public class UserFragment extends BackHandledFragment {
...
@@ -108,7 +108,7 @@ public class UserFragment extends BackHandledFragment {
Bundle
bundle
=
getArguments
();
Bundle
bundle
=
getArguments
();
String
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
String
userID
=
bundle
.
getString
(
Constants
.
USER_ID
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
())
.
getRetrofitInterface
();
RetrofitInterface
retrofitInterface
=
Utils
.
getRetrofitInterface
();
retrofitInterface
.
getUser
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
userID
).
enqueue
(
new
Callback
<
User
>()
{
retrofitInterface
.
getUser
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
userID
).
enqueue
(
new
Callback
<
User
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
...
...
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