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
b89fe347
Commit
b89fe347
authored
Sep 29, 2018
by
Sajal Narang
Committed by
GitHub
Sep 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #199 from pulsejet/noroom
Swap database for caching
parents
4b48beff
c3e18a05
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
263 additions
and
836 deletions
+263
-836
app/build.gradle
app/build.gradle
+1
-14
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
app/src/main/java/app/insti/Constants.java
app/src/main/java/app/insti/Constants.java
+5
-0
app/src/main/java/app/insti/activity/LoginActivity.java
app/src/main/java/app/insti/activity/LoginActivity.java
+10
-2
app/src/main/java/app/insti/activity/MainActivity.java
app/src/main/java/app/insti/activity/MainActivity.java
+26
-8
app/src/main/java/app/insti/adapter/BodyAdapter.java
app/src/main/java/app/insti/adapter/BodyAdapter.java
+4
-1
app/src/main/java/app/insti/adapter/FeedAdapter.java
app/src/main/java/app/insti/adapter/FeedAdapter.java
+4
-6
app/src/main/java/app/insti/adapter/NotificationsAdapter.java
...src/main/java/app/insti/adapter/NotificationsAdapter.java
+7
-2
app/src/main/java/app/insti/api/ServiceGenerator.java
app/src/main/java/app/insti/api/ServiceGenerator.java
+109
-5
app/src/main/java/app/insti/data/AppDatabase.java
app/src/main/java/app/insti/data/AppDatabase.java
+0
-33
app/src/main/java/app/insti/data/Body.java
app/src/main/java/app/insti/data/Body.java
+0
-22
app/src/main/java/app/insti/data/Converters.java
app/src/main/java/app/insti/data/Converters.java
+0
-158
app/src/main/java/app/insti/data/DbDao.java
app/src/main/java/app/insti/data/DbDao.java
+0
-165
app/src/main/java/app/insti/data/Event.java
app/src/main/java/app/insti/data/Event.java
+19
-24
app/src/main/java/app/insti/data/HostelMessMenu.java
app/src/main/java/app/insti/data/HostelMessMenu.java
+0
-10
app/src/main/java/app/insti/data/MessMenu.java
app/src/main/java/app/insti/data/MessMenu.java
+0
-2
app/src/main/java/app/insti/data/NewsArticle.java
app/src/main/java/app/insti/data/NewsArticle.java
+0
-12
app/src/main/java/app/insti/data/Notification.java
app/src/main/java/app/insti/data/Notification.java
+1
-11
app/src/main/java/app/insti/data/PlacementBlogPost.java
app/src/main/java/app/insti/data/PlacementBlogPost.java
+0
-11
app/src/main/java/app/insti/data/Role.java
app/src/main/java/app/insti/data/Role.java
+0
-17
app/src/main/java/app/insti/data/TrainingBlogPost.java
app/src/main/java/app/insti/data/TrainingBlogPost.java
+0
-11
app/src/main/java/app/insti/data/User.java
app/src/main/java/app/insti/data/User.java
+16
-27
app/src/main/java/app/insti/data/Venue.java
app/src/main/java/app/insti/data/Venue.java
+11
-17
app/src/main/java/app/insti/fragment/AddEventFragment.java
app/src/main/java/app/insti/fragment/AddEventFragment.java
+2
-2
app/src/main/java/app/insti/fragment/BodyFragment.java
app/src/main/java/app/insti/fragment/BodyFragment.java
+2
-37
app/src/main/java/app/insti/fragment/CalendarFragment.java
app/src/main/java/app/insti/fragment/CalendarFragment.java
+1
-1
app/src/main/java/app/insti/fragment/EventFragment.java
app/src/main/java/app/insti/fragment/EventFragment.java
+1
-21
app/src/main/java/app/insti/fragment/ExploreFragment.java
app/src/main/java/app/insti/fragment/ExploreFragment.java
+2
-2
app/src/main/java/app/insti/fragment/FeedFragment.java
app/src/main/java/app/insti/fragment/FeedFragment.java
+2
-32
app/src/main/java/app/insti/fragment/MapFragment.java
app/src/main/java/app/insti/fragment/MapFragment.java
+1
-30
app/src/main/java/app/insti/fragment/MessMenuFragment.java
app/src/main/java/app/insti/fragment/MessMenuFragment.java
+2
-32
app/src/main/java/app/insti/fragment/MyEventsFragment.java
app/src/main/java/app/insti/fragment/MyEventsFragment.java
+20
-18
app/src/main/java/app/insti/fragment/NewsFragment.java
app/src/main/java/app/insti/fragment/NewsFragment.java
+2
-32
app/src/main/java/app/insti/fragment/NotificationsFragment.java
...c/main/java/app/insti/fragment/NotificationsFragment.java
+2
-2
app/src/main/java/app/insti/fragment/PlacementBlogFragment.java
...c/main/java/app/insti/fragment/PlacementBlogFragment.java
+2
-32
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/TrainingBlogFragment.java
...rc/main/java/app/insti/fragment/TrainingBlogFragment.java
+2
-32
app/src/main/java/app/insti/fragment/UserFragment.java
app/src/main/java/app/insti/fragment/UserFragment.java
+2
-1
app/src/main/java/app/insti/notifications/NotificationIntentService.java
...va/app/insti/notifications/NotificationIntentService.java
+4
-2
No files found.
app/build.gradle
View file @
b89fe347
...
@@ -23,13 +23,11 @@ android {
...
@@ -23,13 +23,11 @@ android {
}
}
ext
{
ext
{
supportLibVersion
=
'27.1.
1
'
supportLibVersion
=
'27.1.
0
'
playServicesVersion
=
'15.0.1'
playServicesVersion
=
'15.0.1'
butterKnifeVersion
=
'8.8.1'
retrofitVersion
=
'2.3.0'
retrofitVersion
=
'2.3.0'
okhttpVersion
=
'3.11.0'
okhttpVersion
=
'3.11.0'
picassoVersion
=
'2.71828'
picassoVersion
=
'2.71828'
archRoomVersion
=
'1.1.1'
circleImageViewVersion
=
'2.2.0'
circleImageViewVersion
=
'2.2.0'
markwonVersion
=
'1.0.6'
markwonVersion
=
'1.0.6'
}
}
...
@@ -37,25 +35,14 @@ ext {
...
@@ -37,25 +35,14 @@ ext {
dependencies
{
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
'com.google.firebase:firebase-messaging:17.1.0'
implementation
'com.google.firebase:firebase-messaging:17.1.0'
androidTestImplementation
(
'com.android.support.test.espresso:espresso-core:2.2.2'
,
{
exclude
group:
'com.android.support'
,
module:
'support-annotations'
})
testImplementation
"junit:junit:4.12"
implementation
"com.android.support:design:${supportLibVersion}"
implementation
"com.android.support:design:${supportLibVersion}"
implementation
"com.android.support:support-v4:${supportLibVersion}"
implementation
"com.android.support:support-v4:${supportLibVersion}"
implementation
"com.jakewharton:butterknife:${butterKnifeVersion}"
implementation
"com.google.android.gms:play-services-gcm:${playServicesVersion}"
implementation
"com.google.android.gms:play-services-maps:${playServicesVersion}"
implementation
"com.google.android.gms:play-services-location:${playServicesVersion}"
implementation
"com.google.android.gms:play-services-location:${playServicesVersion}"
annotationProcessor
"com.jakewharton:butterknife-compiler:${butterKnifeVersion}"
implementation
"com.squareup.retrofit2:retrofit:${retrofitVersion}"
implementation
"com.squareup.retrofit2:retrofit:${retrofitVersion}"
implementation
"com.squareup.retrofit2:converter-gson:${retrofitVersion}"
implementation
"com.squareup.retrofit2:converter-gson:${retrofitVersion}"
implementation
"com.squareup.okhttp3:okhttp:${okhttpVersion}"
implementation
"com.squareup.okhttp3:okhttp:${okhttpVersion}"
implementation
"com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
implementation
"com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
implementation
"com.squareup.picasso:picasso:${picassoVersion}"
implementation
"com.squareup.picasso:picasso:${picassoVersion}"
implementation
"com.android.support:customtabs:${supportLibVersion}"
implementation
"android.arch.persistence.room:runtime:${archRoomVersion}"
annotationProcessor
"android.arch.persistence.room:compiler:${archRoomVersion}"
implementation
"com.android.support:cardview-v7:${supportLibVersion}"
implementation
"com.android.support:cardview-v7:${supportLibVersion}"
implementation
"de.hdodenhof:circleimageview:${circleImageViewVersion}"
implementation
"de.hdodenhof:circleimageview:${circleImageViewVersion}"
implementation
"ru.noties:markwon:${markwonVersion}"
implementation
"ru.noties:markwon:${markwonVersion}"
...
...
app/src/main/AndroidManifest.xml
View file @
b89fe347
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
package=
"app.insti"
>
package=
"app.insti"
>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
...
...
app/src/main/java/app/insti/Constants.java
View file @
b89fe347
...
@@ -32,4 +32,9 @@ public class Constants {
...
@@ -32,4 +32,9 @@ public class Constants {
public
static
final
double
MAP_Xn
=
19.134417
,
MAP_Yn
=
72.901229
,
MAP_Zn
=
1757
,
MAP_Zyn
=
501
;
public
static
final
double
MAP_Xn
=
19.134417
,
MAP_Yn
=
72.901229
,
MAP_Zn
=
1757
,
MAP_Zyn
=
501
;
public
static
final
double
[]
MAP_WEIGHTS_X
=
{-
11.392001766454612
,
-
36.31634553309953
,
73.91269388324432
,
-
24.14021153064087
,
3.4508817531539115
,
-
0.1462262375477863
,
5.532505074667804
,
-
1.542391995870977
,
36.14211738142935
};
public
static
final
double
[]
MAP_WEIGHTS_X
=
{-
11.392001766454612
,
-
36.31634553309953
,
73.91269388324432
,
-
24.14021153064087
,
3.4508817531539115
,
-
0.1462262375477863
,
5.532505074667804
,
-
1.542391995870977
,
36.14211738142935
};
public
static
final
double
[]
MAP_WEIGHTS_Y
=
{
0.09738953520399705
,
-
4.519868444089616
,
62.38493718381985
,
16.664561869057696
,
-
2.168377988768651
,
0.0919143297622087
,
0.32304266159540823
,
0.21688067854428716
,
-
12.81393255320748
};
public
static
final
double
[]
MAP_WEIGHTS_Y
=
{
0.09738953520399705
,
-
4.519868444089616
,
62.38493718381985
,
16.664561869057696
,
-
2.168377988768651
,
0.0919143297622087
,
0.32304266159540823
,
0.21688067854428716
,
-
12.81393255320748
};
public
static
final
String
resizeImageUrl
(
String
url
,
Integer
dim
)
{
if
(
url
==
null
)
{
return
url
;
}
return
url
.
replace
(
"api.insti.app/static/"
,
"img.insti.app/static/"
+
dim
.
toString
()
+
"/"
);
}
}
}
app/src/main/java/app/insti/activity/LoginActivity.java
View file @
b89fe347
...
@@ -40,6 +40,11 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -40,6 +40,11 @@ public class LoginActivity extends AppCompatActivity {
private
boolean
loggingIn
=
false
;
private
boolean
loggingIn
=
false
;
private
ProgressDialog
progressDialog
;
private
ProgressDialog
progressDialog
;
private
RetrofitInterface
retrofitInterface
;
public
RetrofitInterface
getRetrofitInterface
()
{
return
retrofitInterface
;
}
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -63,6 +68,9 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -63,6 +68,9 @@ public class LoginActivity extends AppCompatActivity {
protected
void
onStart
()
{
protected
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
this
.
retrofitInterface
=
serviceGenerator
.
getRetrofitInterface
();
WebView
webview
=
(
WebView
)
findViewById
(
R
.
id
.
login_webview
);
WebView
webview
=
(
WebView
)
findViewById
(
R
.
id
.
login_webview
);
webview
.
getSettings
().
setJavaScriptEnabled
(
true
);
webview
.
getSettings
().
setJavaScriptEnabled
(
true
);
webview
.
getSettings
().
setDomStorageEnabled
(
true
);
webview
.
getSettings
().
setDomStorageEnabled
(
true
);
...
@@ -80,7 +88,7 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -80,7 +88,7 @@ public class LoginActivity extends AppCompatActivity {
private
void
login
(
final
String
authorizationCode
,
final
String
redirectURL
)
{
private
void
login
(
final
String
authorizationCode
,
final
String
redirectURL
)
{
/* This can be null if play services is hung */
/* This can be null if play services is hung */
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
(
);
Call
<
LoginResponse
>
call
;
Call
<
LoginResponse
>
call
;
if
(
fcmId
==
null
)
{
if
(
fcmId
==
null
)
{
call
=
retrofitInterface
.
login
(
authorizationCode
,
redirectURL
);
call
=
retrofitInterface
.
login
(
authorizationCode
,
redirectURL
);
...
@@ -118,7 +126,7 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -118,7 +126,7 @@ public class LoginActivity extends AppCompatActivity {
progressDialog
.
show
();
progressDialog
.
show
();
}
}
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
(
);
Call
<
LoginResponse
>
call
;
Call
<
LoginResponse
>
call
;
/* This can be null if play services is hung */
/* This can be null if play services is hung */
...
...
app/src/main/java/app/insti/activity/MainActivity.java
View file @
b89fe347
...
@@ -37,6 +37,7 @@ import com.google.firebase.iid.InstanceIdResult;
...
@@ -37,6 +37,7 @@ import com.google.firebase.iid.InstanceIdResult;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
com.squareup.picasso.Picasso
;
import
com.squareup.picasso.Picasso
;
import
java.io.File
;
import
java.util.List
;
import
java.util.List
;
import
app.insti.Constants
;
import
app.insti.Constants
;
...
@@ -66,6 +67,7 @@ import app.insti.fragment.QuickLinksFragment;
...
@@ -66,6 +67,7 @@ import app.insti.fragment.QuickLinksFragment;
import
app.insti.fragment.SettingsFragment
;
import
app.insti.fragment.SettingsFragment
;
import
app.insti.fragment.TrainingBlogFragment
;
import
app.insti.fragment.TrainingBlogFragment
;
import
app.insti.notifications.NotificationEventReceiver
;
import
app.insti.notifications.NotificationEventReceiver
;
import
okhttp3.Cache
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
...
@@ -87,6 +89,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -87,6 +89,11 @@ 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
;
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
);
...
@@ -107,6 +114,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -107,6 +114,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
catch
(
IllegalStateException
ignored
)
{
}
catch
(
IllegalStateException
ignored
)
{
}
}
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
this
.
retrofitInterface
=
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
)
{
createNotificationChannel
();
createNotificationChannel
();
...
@@ -140,15 +150,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -140,15 +150,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
}
}
fetchNotifications
();
checkLatestVersion
();
checkLatestVersion
();
NotificationEventReceiver
.
setupAlarm
(
getApplicationContext
());
NotificationEventReceiver
.
setupAlarm
(
getApplicationContext
());
}
}
private
void
fetchNotifications
()
{
private
void
fetchNotifications
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
(
);
retrofitInterface
.
getNotifications
(
getSessionIDHeader
()).
enqueue
(
new
Callback
<
List
<
Notification
>>()
{
retrofitInterface
.
getNotifications
(
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
)
{
...
@@ -172,7 +180,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -172,7 +180,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
try
{
try
{
PackageInfo
pInfo
=
this
.
getPackageManager
().
getPackageInfo
(
getPackageName
(),
0
);
PackageInfo
pInfo
=
this
.
getPackageManager
().
getPackageInfo
(
getPackageName
(),
0
);
final
int
versionCode
=
pInfo
.
versionCode
;
final
int
versionCode
=
pInfo
.
versionCode
;
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
(
);
retrofitInterface
.
getLatestVersion
().
enqueue
(
new
Callback
<
JsonObject
>()
{
retrofitInterface
.
getLatestVersion
().
enqueue
(
new
Callback
<
JsonObject
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
public
void
onResponse
(
Call
<
JsonObject
>
call
,
Response
<
JsonObject
>
response
)
{
...
@@ -255,7 +263,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -255,7 +263,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
updateFragment
(
userFragment
);
updateFragment
(
userFragment
);
break
;
break
;
case
"event"
:
case
"event"
:
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
(
);
retrofitInterface
.
getEvent
(
getSessionIDHeader
(),
getID
(
appLinkData
)).
enqueue
(
new
Callback
<
Event
>()
{
retrofitInterface
.
getEvent
(
getSessionIDHeader
(),
getID
(
appLinkData
)).
enqueue
(
new
Callback
<
Event
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Event
>
call
,
Response
<
Event
>
response
)
{
public
void
onResponse
(
Call
<
Event
>
call
,
Response
<
Event
>
response
)
{
...
@@ -319,7 +327,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -319,7 +327,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override
@Override
public
void
onSuccess
(
InstanceIdResult
instanceIdResult
)
{
public
void
onSuccess
(
InstanceIdResult
instanceIdResult
)
{
String
fcmId
=
instanceIdResult
.
getToken
();
String
fcmId
=
instanceIdResult
.
getToken
();
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
getRetrofitInterface
(
);
retrofitInterface
.
getUserMe
(
getSessionIDHeader
(),
fcmId
).
enqueue
(
new
Callback
<
User
>()
{
retrofitInterface
.
getUserMe
(
getSessionIDHeader
(),
fcmId
).
enqueue
(
new
Callback
<
User
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
...
@@ -394,8 +402,15 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -394,8 +402,15 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
// Inflate the menu; this adds items to the action bar if it is present.
// Inflate the menu; this adds items to the action bar if it is present.
this
.
menu
=
menu
;
this
.
menu
=
menu
;
fetchNotifications
();
getMenuInflater
().
inflate
(
R
.
menu
.
main
,
this
.
menu
);
getMenuInflater
().
inflate
(
R
.
menu
.
main
,
this
.
menu
);
// Fetch notifictions if logged in or hide icon
if
(
session
.
isLoggedIn
())
{
fetchNotifications
();
}
else
{
this
.
menu
.
findItem
(
R
.
id
.
action_notifications
).
setVisible
(
false
);
}
return
true
;
return
true
;
}
}
...
@@ -540,8 +555,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
...
@@ -540,8 +555,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
public
void
initPicasso
()
{
public
void
initPicasso
()
{
Picasso
.
Builder
builder
=
new
Picasso
.
Builder
(
getApplicationContext
());
Picasso
.
Builder
builder
=
new
Picasso
.
Builder
(
getApplicationContext
());
OkHttpClient
.
Builder
client
=
new
OkHttpClient
.
Builder
();
Cache
cache
=
new
Cache
(
new
File
(
getApplicationContext
().
getCacheDir
(),
"http-cache"
),
100
*
1024
*
1024
);
client
.
cache
(
cache
);
builder
.
downloader
(
new
com
.
squareup
.
picasso
.
OkHttp3Downloader
((
builder
.
downloader
(
new
com
.
squareup
.
picasso
.
OkHttp3Downloader
((
new
OkHttpClient
.
Builder
()
.
build
()
client
.
build
()
)));
)));
Picasso
built
=
builder
.
build
();
Picasso
built
=
builder
.
build
();
built
.
setIndicatorsEnabled
(
false
);
built
.
setIndicatorsEnabled
(
false
);
...
...
app/src/main/java/app/insti/adapter/BodyAdapter.java
View file @
b89fe347
...
@@ -12,6 +12,7 @@ import com.squareup.picasso.Picasso;
...
@@ -12,6 +12,7 @@ import com.squareup.picasso.Picasso;
import
java.util.List
;
import
java.util.List
;
import
app.insti.Constants
;
import
app.insti.ItemClickListener
;
import
app.insti.ItemClickListener
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.data.Body
;
import
app.insti.data.Body
;
...
@@ -51,7 +52,9 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
...
@@ -51,7 +52,9 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
Body
body
=
bodyList
.
get
(
position
);
Body
body
=
bodyList
.
get
(
position
);
holder
.
name
.
setText
(
body
.
getBodyName
());
holder
.
name
.
setText
(
body
.
getBodyName
());
holder
.
description
.
setText
(
body
.
getBodyShortDescription
());
holder
.
description
.
setText
(
body
.
getBodyShortDescription
());
Picasso
.
get
().
load
(
body
.
getBodyImageURL
()).
resize
(
0
,
200
).
into
(
holder
.
image
);
Picasso
.
get
().
load
(
Constants
.
resizeImageUrl
(
body
.
getBodyImageURL
(),
200
)
).
into
(
holder
.
image
);
}
}
...
...
app/src/main/java/app/insti/adapter/FeedAdapter.java
View file @
b89fe347
...
@@ -17,6 +17,7 @@ import java.util.List;
...
@@ -17,6 +17,7 @@ import java.util.List;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
app.insti.Constants
;
import
app.insti.ItemClickListener
;
import
app.insti.ItemClickListener
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.data.Event
;
import
app.insti.data.Event
;
...
@@ -112,17 +113,14 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
...
@@ -112,17 +113,14 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
getSubtitle
(
viewHolder
,
currentEvent
);
getSubtitle
(
viewHolder
,
currentEvent
);
// Fallback to image of first body if event has no image
if
(
currentEvent
.
getEventImageURL
()
==
null
)
{
currentEvent
.
setEventImageURL
(
currentEvent
.
getEventBodies
().
get
(
0
).
getBodyImageURL
());
}
if
(
currentEvent
.
isEventBigImage
())
{
if
(
currentEvent
.
isEventBigImage
())
{
viewHolder
.
eventBigPicture
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
eventBigPicture
.
setVisibility
(
View
.
VISIBLE
);
viewHolder
.
eventPicture
.
setVisibility
(
View
.
GONE
);
viewHolder
.
eventPicture
.
setVisibility
(
View
.
GONE
);
Picasso
.
get
().
load
(
currentEvent
.
getEventImageURL
()).
into
(
viewHolder
.
eventBigPicture
);
Picasso
.
get
().
load
(
currentEvent
.
getEventImageURL
()).
into
(
viewHolder
.
eventBigPicture
);
}
else
{
}
else
{
Picasso
.
get
().
load
(
currentEvent
.
getEventImageURL
()).
into
(
viewHolder
.
eventPicture
);
Picasso
.
get
().
load
(
Constants
.
resizeImageUrl
(
currentEvent
.
getEventImageURL
(),
200
)
).
into
(
viewHolder
.
eventPicture
);
}
}
}
}
...
...
app/src/main/java/app/insti/adapter/NotificationsAdapter.java
View file @
b89fe347
...
@@ -13,6 +13,7 @@ import com.squareup.picasso.Picasso;
...
@@ -13,6 +13,7 @@ import com.squareup.picasso.Picasso;
import
java.util.List
;
import
java.util.List
;
import
app.insti.Constants
;
import
app.insti.ItemClickListener
;
import
app.insti.ItemClickListener
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.data.Event
;
import
app.insti.data.Event
;
...
@@ -53,11 +54,15 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
...
@@ -53,11 +54,15 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
viewholder
.
notificationVerb
.
setText
(
appNotification
.
getNotificationVerb
());
viewholder
.
notificationVerb
.
setText
(
appNotification
.
getNotificationVerb
());
if
(
appNotification
.
getNotificationActorType
().
contains
(
"event"
))
{
if
(
appNotification
.
getNotificationActorType
().
contains
(
"event"
))
{
Event
event
=
gson
.
fromJson
(
gson
.
toJson
(
appNotification
.
getNotificationActor
()),
Event
.
class
);
Event
event
=
gson
.
fromJson
(
gson
.
toJson
(
appNotification
.
getNotificationActor
()),
Event
.
class
);
Picasso
.
get
().
load
(
event
.
getEventImageURL
()).
into
(
viewholder
.
notificationPicture
);
Picasso
.
get
().
load
(
Constants
.
resizeImageUrl
(
event
.
getEventImageURL
(),
200
)
).
into
(
viewholder
.
notificationPicture
);
viewholder
.
notificationTitle
.
setText
(
event
.
getEventName
());
viewholder
.
notificationTitle
.
setText
(
event
.
getEventName
());
}
else
if
(
appNotification
.
getNotificationActorType
().
contains
(
"newsentry"
))
{
}
else
if
(
appNotification
.
getNotificationActorType
().
contains
(
"newsentry"
))
{
NewsArticle
article
=
gson
.
fromJson
(
gson
.
toJson
(
appNotification
.
getNotificationActor
()),
NewsArticle
.
class
);
NewsArticle
article
=
gson
.
fromJson
(
gson
.
toJson
(
appNotification
.
getNotificationActor
()),
NewsArticle
.
class
);
Picasso
.
get
().
load
(
article
.
getBody
().
getBodyImageURL
()).
into
(
viewholder
.
notificationPicture
);
Picasso
.
get
().
load
(
Constants
.
resizeImageUrl
(
article
.
getBody
().
getBodyImageURL
(),
200
)
).
into
(
viewholder
.
notificationPicture
);
viewholder
.
notificationTitle
.
setText
(
article
.
getTitle
());
viewholder
.
notificationTitle
.
setText
(
article
.
getTitle
());
}
else
if
(
appNotification
.
getNotificationActorType
().
contains
(
"blogentry"
))
{
}
else
if
(
appNotification
.
getNotificationActorType
().
contains
(
"blogentry"
))
{
PlacementBlogPost
post
=
gson
.
fromJson
(
gson
.
toJson
(
appNotification
.
getNotificationActor
()),
PlacementBlogPost
.
class
);
PlacementBlogPost
post
=
gson
.
fromJson
(
gson
.
toJson
(
appNotification
.
getNotificationActor
()),
PlacementBlogPost
.
class
);
...
...
app/src/main/java/app/insti/api/ServiceGenerator.java
View file @
b89fe347
package
app.insti.api
;
package
app.insti.api
;
import
android.content.Context
;
import
android.net.NetworkInfo
;
import
android.util.Log
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.concurrent.TimeUnit
;
import
okhttp3.Cache
;
import
okhttp3.CacheControl
;
import
okhttp3.Interceptor
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
retrofit2.Retrofit
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
import
retrofit2.converter.gson.GsonConverterFactory
;
public
class
ServiceGenerator
{
public
class
ServiceGenerator
{
public
static
final
String
HEADER_CACHE_CONTROL
=
"Cache-Control"
;
public
static
final
String
HEADER_PRAGMA
=
"Pragma"
;
private
static
final
String
BASE_URL
=
"https://api.insti.app/api/"
;
private
static
final
String
BASE_URL
=
"https://api.insti.app/api/"
;
private
Context
context
;
private
Interceptor
provideCacheInterceptor
=
new
Interceptor
()
{
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
Response
response
=
chain
.
proceed
(
chain
.
request
());
CacheControl
cacheControl
;
if
(
isConnected
())
{
cacheControl
=
new
CacheControl
.
Builder
()
.
maxAge
(
0
,
TimeUnit
.
SECONDS
)
.
build
();
}
else
{
cacheControl
=
new
CacheControl
.
Builder
()
.
maxStale
(
7
,
TimeUnit
.
DAYS
)
.
build
();
}
return
response
.
newBuilder
()
.
removeHeader
(
HEADER_PRAGMA
)
.
removeHeader
(
HEADER_CACHE_CONTROL
)
.
header
(
HEADER_CACHE_CONTROL
,
cacheControl
.
toString
())
.
build
();
}
};
private
Interceptor
provideOfflineCacheInterceptor
=
new
Interceptor
()
{
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
Request
request
=
chain
.
request
();
if
(!
isConnected
())
{
CacheControl
cacheControl
=
new
CacheControl
.
Builder
()
.
maxStale
(
7
,
TimeUnit
.
DAYS
)
.
build
();
request
=
request
.
newBuilder
()
.
removeHeader
(
HEADER_PRAGMA
)
.
removeHeader
(
HEADER_CACHE_CONTROL
)
.
cacheControl
(
cacheControl
)
.
build
();
}
return
chain
.
proceed
(
request
);
}
};
private
Cache
provideCache
()
{
Cache
cache
=
null
;
try
{
cache
=
new
Cache
(
new
File
(
context
.
getCacheDir
(),
"api-cache"
),
50
*
1024
*
1024
);
// 50 MB
}
catch
(
Exception
e
)
{
Log
.
e
(
"cache"
,
"Could not create Cache!"
);
}
return
cache
;
}
public
boolean
isConnected
()
{
Log
.
wtf
(
"cache"
,
"MEOW"
);
try
{
android
.
net
.
ConnectivityManager
e
=
(
android
.
net
.
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
NetworkInfo
activeNetwork
=
e
.
getActiveNetworkInfo
();
Log
.
wtf
(
"cache"
,
Boolean
.
toString
(
activeNetwork
!=
null
&&
activeNetwork
.
isConnectedOrConnecting
()));
return
activeNetwork
!=
null
&&
activeNetwork
.
isConnectedOrConnecting
();
}
catch
(
Exception
e
)
{
Log
.
w
(
"cache"
,
e
.
toString
());
}
return
false
;
}
private
static
OkHttpClient
.
Builder
clientBuilder
=
new
OkHttpClient
.
Builder
();
private
static
OkHttpClient
.
Builder
clientBuilder
=
new
OkHttpClient
.
Builder
();
private
static
Retrofit
.
Builder
retrofitBuilder
=
new
Retrofit
.
Builder
()
private
static
Retrofit
.
Builder
retrofitBuilder
=
new
Retrofit
.
Builder
()
.
baseUrl
(
BASE_URL
)
.
baseUrl
(
BASE_URL
)
.
addConverterFactory
(
GsonConverterFactory
.
create
());
.
addConverterFactory
(
GsonConverterFactory
.
create
());
private
static
Retrofit
retrofit
;
public
static
<
S
>
S
createService
(
Class
<
S
>
serviceClass
)
{
private
Retrofit
retrofit
;
retrofit
=
retrofitBuilder
.
client
(
clientBuilder
.
build
()).
build
();
public
RetrofitInterface
retrofitInterface
;
return
retrofit
.
create
(
serviceClass
);
public
ServiceGenerator
(
Context
mContext
)
{
context
=
mContext
;
retrofit
=
retrofitBuilder
.
client
(
clientBuilder
.
addInterceptor
(
provideOfflineCacheInterceptor
)
.
addNetworkInterceptor
(
provideCacheInterceptor
)
.
cache
(
provideCache
())
.
build
()
).
build
();
retrofitInterface
=
retrofit
.
create
(
RetrofitInterface
.
class
);
}
public
RetrofitInterface
getRetrofitInterface
()
{
return
retrofitInterface
;
}
}
}
}
app/src/main/java/app/insti/data/AppDatabase.java
deleted
100644 → 0
View file @
4b48beff
package
app.insti.data
;
import
android.arch.persistence.room.Database
;
import
android.arch.persistence.room.Room
;
import
android.arch.persistence.room.RoomDatabase
;
import
android.arch.persistence.room.TypeConverters
;
import
android.content.Context
;
@Database
(
entities
=
{
Event
.
class
,
Body
.
class
,
Venue
.
class
,
User
.
class
,
Role
.
class
,
PlacementBlogPost
.
class
,
TrainingBlogPost
.
class
,
HostelMessMenu
.
class
,
NewsArticle
.
class
},
version
=
2
,
exportSchema
=
false
)
@TypeConverters
({
Converters
.
class
})
public
abstract
class
AppDatabase
extends
RoomDatabase
{
private
static
AppDatabase
INSTANCE
;
public
static
AppDatabase
getAppDatabase
(
Context
context
)
{
if
(
INSTANCE
==
null
)
{
INSTANCE
=
Room
.
databaseBuilder
(
context
.
getApplicationContext
(),
AppDatabase
.
class
,
"database"
)
// allow queries on the main thread.
// Don't do this on a real app! See PersistenceBasicSample for an example.
// .allowMainThreadQueries()
.
fallbackToDestructiveMigration
()
.
build
();
}
return
INSTANCE
;
}
public
static
void
destroyInstance
()
{
INSTANCE
=
null
;
}
public
abstract
DbDao
dbDao
();
}
app/src/main/java/app/insti/data/Body.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.Ignore
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
import
java.util.List
;
@Entity
(
tableName
=
"bodies"
)
public
class
Body
{
public
class
Body
{
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
String
bodyID
;
String
bodyID
;
@ColumnInfo
(
name
=
"str_id"
)
@SerializedName
(
"str_id"
)
@SerializedName
(
"str_id"
)
String
bodyStrID
;
String
bodyStrID
;
@ColumnInfo
(
name
=
"name"
)
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
String
bodyName
;
String
bodyName
;
@ColumnInfo
(
name
=
"short_description"
)
@SerializedName
(
"short_description"
)
@SerializedName
(
"short_description"
)
String
bodyShortDescription
;
String
bodyShortDescription
;
@ColumnInfo
(
name
=
"description"
)
@SerializedName
(
"description"
)
@SerializedName
(
"description"
)
String
bodyDescription
;
String
bodyDescription
;
@ColumnInfo
(
name
=
"image_url"
)
@SerializedName
(
"image_url"
)
@SerializedName
(
"image_url"
)
String
bodyImageURL
;
String
bodyImageURL
;
@ColumnInfo
(
name
=
"children"
)
@SerializedName
(
"children"
)
@SerializedName
(
"children"
)
List
<
Body
>
bodyChildren
;
List
<
Body
>
bodyChildren
;
@ColumnInfo
(
name
=
"parents"
)
@SerializedName
(
"parents"
)
@SerializedName
(
"parents"
)
List
<
Body
>
bodyParents
;
List
<
Body
>
bodyParents
;
@ColumnInfo
(
name
=
"events"
)
@SerializedName
(
"events"
)
@SerializedName
(
"events"
)
List
<
Event
>
bodyEvents
;
List
<
Event
>
bodyEvents
;
@ColumnInfo
(
name
=
"followers_count"
)
@SerializedName
(
"followers_count"
)
@SerializedName
(
"followers_count"
)
int
bodyFollowersCount
;
int
bodyFollowersCount
;
@ColumnInfo
(
name
=
"website_url"
)
@SerializedName
(
"website_url"
)
@SerializedName
(
"website_url"
)
String
bodyWebsiteURL
;
String
bodyWebsiteURL
;
@ColumnInfo
(
name
=
"blog_url"
)
@SerializedName
(
"blog_url"
)
@SerializedName
(
"blog_url"
)
String
bodyBlogURL
;
String
bodyBlogURL
;
@ColumnInfo
(
name
=
"user_follows"
)
@SerializedName
(
"user_follows"
)
@SerializedName
(
"user_follows"
)
boolean
bodyUserFollows
;
boolean
bodyUserFollows
;
@ColumnInfo
(
name
=
"roles"
)
@SerializedName
(
"roles"
)
@SerializedName
(
"roles"
)
List
<
Role
>
bodyRoles
;
List
<
Role
>
bodyRoles
;
@Ignore
public
Body
(
@NonNull
String
bodyID
)
{
public
Body
(
@NonNull
String
bodyID
)
{
this
.
bodyID
=
bodyID
;
this
.
bodyID
=
bodyID
;
}
}
...
...
app/src/main/java/app/insti/data/Converters.java
deleted
100644 → 0
View file @
4b48beff
package
app.insti.data
;
import
android.arch.persistence.room.TypeConverter
;
import
android.util.Log
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonSyntaxException
;
import
com.google.gson.reflect.TypeToken
;
import
java.lang.reflect.Type
;
import
java.sql.Timestamp
;
import
java.util.List
;
public
class
Converters
{
@TypeConverter
public
static
List
<
Event
>
eventsfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
Event
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromEvents
(
List
<
Event
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
@TypeConverter
public
static
List
<
User
>
usersfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
User
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromUsers
(
List
<
User
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
@TypeConverter
public
static
List
<
Venue
>
venuesfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
Venue
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromVenues
(
List
<
Venue
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
@TypeConverter
public
static
List
<
Body
>
bodiesfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
Body
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromBodies
(
List
<
Body
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
@TypeConverter
public
static
List
<
Role
>
rolesfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
Role
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromRoles
(
List
<
Role
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
@TypeConverter
public
static
Timestamp
timestampfromString
(
String
value
)
{
try
{
return
new
Gson
().
fromJson
(
value
,
Timestamp
.
class
);
}
catch
(
JsonSyntaxException
e
)
{
Log
.
d
(
"Converters"
,
"timestampfromString: "
+
value
);
e
.
printStackTrace
();
return
null
;
}
}
@TypeConverter
public
static
String
stringfromTimestamp
(
Timestamp
timestamp
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
timestamp
);
return
json
;
}
@TypeConverter
public
static
Body
bodyfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
Body
>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromBody
(
Body
body
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
body
);
return
json
;
}
@TypeConverter
public
static
Object
objectFromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
Object
>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringFromObject
(
Object
object
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
object
);
return
json
;
}
@TypeConverter
public
static
List
<
String
>
stringsfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
String
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromStrings
(
List
<
String
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
@TypeConverter
public
static
List
<
MessMenu
>
messMenusfromString
(
String
value
)
{
Type
listType
=
new
TypeToken
<
List
<
MessMenu
>>()
{
}.
getType
();
return
new
Gson
().
fromJson
(
value
,
listType
);
}
@TypeConverter
public
static
String
stringfromMessMenus
(
List
<
MessMenu
>
list
)
{
Gson
gson
=
new
Gson
();
String
json
=
gson
.
toJson
(
list
);
return
json
;
}
}
\ No newline at end of file
app/src/main/java/app/insti/data/DbDao.java
deleted
100644 → 0
View file @
4b48beff
package
app.insti.data
;
import
android.arch.persistence.room.Dao
;
import
android.arch.persistence.room.Delete
;
import
android.arch.persistence.room.Insert
;
import
android.arch.persistence.room.Query
;
import
android.arch.persistence.room.Update
;
import
java.util.List
;
@Dao
public
interface
DbDao
{
@Query
(
"SELECT * FROM events"
)
List
<
Event
>
getAllEvents
();
@Query
(
"SELECT * FROM events WHERE user_ues <> 0"
)
List
<
Event
>
getFollowingEvents
();
@Query
(
"SELECT * FROM bodies"
)
List
<
Body
>
getAllBodies
();
@Query
(
"SELECT * FROM venues"
)
List
<
Venue
>
getAllVenues
();
@Query
(
"SELECT * FROM users"
)
List
<
User
>
getAllUsers
();
@Query
(
"SELECT * FROM roles"
)
List
<
Role
>
getAllRoles
();
@Query
(
"SELECT * FROM placementBlogPosts"
)
List
<
PlacementBlogPost
>
getAllPlacementBlogPosts
();
@Query
(
"SELECT * FROM trainingBlogPosts"
)
List
<
TrainingBlogPost
>
getAllTrainingBlogPosts
();
@Query
(
"SELECT * FROM hostelMessMenus"
)
List
<
HostelMessMenu
>
getAllHostelMessMenus
();
@Query
(
"SELECT * FROM news"
)
List
<
NewsArticle
>
getAllNewsArticles
();
@Query
(
"SELECT COUNT(*) from events"
)
int
countEvents
();
@Query
(
"SELECT * FROM bodies WHERE id == :id"
)
public
Body
[]
getBody
(
String
id
);
@Query
(
"SELECT COUNT(*) from venues"
)
int
countVenues
();
@Query
(
"SELECT COUNT(*) from bodies"
)
int
countBodies
();
@Query
(
"SELECT COUNT(*) from users"
)
int
countUsers
();
@Query
(
"SELECT COUNT(*) from roles"
)
int
countRoles
();
@Query
(
"SELECT COUNT(*) from hostelMessMenus"
)
int
countHostelMessMenus
();
@Insert
void
insertEvents
(
List
<
Event
>
events
);
@Insert
void
insertEvent
(
Event
event
);
@Update
void
updateEvent
(
Event
event
);
@Insert
void
insertBodies
(
List
<
Body
>
bodies
);
@Insert
void
insertBody
(
Body
body
);
@Update
void
updateBody
(
Body
body
);
@Insert
void
insertVenues
(
List
<
Venue
>
venues
);
@Insert
void
insertVenue
(
Venue
venue
);
@Insert
void
insertUsers
(
List
<
User
>
users
);
@Insert
void
insertUser
(
User
user
);
@Insert
void
insertRoles
(
List
<
Role
>
roles
);
@Insert
void
insertRole
(
Role
role
);
@Insert
void
insertPlacementBlogPost
(
PlacementBlogPost
post
);
@Insert
void
insertPlacementBlogPosts
(
List
<
PlacementBlogPost
>
posts
);
@Insert
void
insertTrainingBlogPost
(
TrainingBlogPost
post
);
@Insert
void
insertTrainingBlogPosts
(
List
<
TrainingBlogPost
>
posts
);
@Insert
void
insertHostelMessMenu
(
HostelMessMenu
hostelMessMenu
);
@Insert
void
insertHostelMessMenus
(
List
<
HostelMessMenu
>
hostelMessMenus
);
@Insert
void
insertNewsArticle
(
NewsArticle
newsArticle
);
@Insert
void
insertNewsArticles
(
List
<
NewsArticle
>
newsArticles
);
@Delete
void
deleteEvent
(
Event
event
);
@Delete
void
deleteVenue
(
Venue
venue
);
@Delete
void
deleteBody
(
Body
body
);
@Delete
void
deleteUser
(
User
user
);
@Delete
void
deleteRole
(
Role
role
);
@Query
(
"DELETE from events"
)
void
deleteEvents
();
@Query
(
"DELETE from venues"
)
void
deleteVenues
();
@Query
(
"DELETE from bodies"
)
void
deleteBodies
();
@Query
(
"DELETE from users"
)
void
deleteUsers
();
@Query
(
"DELETE from roles"
)
void
deleteRoles
();
@Query
(
"DELETE from placementBlogPosts"
)
void
deletePlacementBlogPosts
();
@Query
(
"DELETE from trainingBlogPosts"
)
void
deleteTrainingBlogPosts
();
@Query
(
"DELETE from hostelMessMenus"
)
void
deleteHostelMessMenus
();
@Query
(
"DELETE from news"
)
void
deleteNewsArticles
();
}
app/src/main/java/app/insti/data/Event.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.Ignore
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -12,61 +8,56 @@ import com.google.gson.annotations.SerializedName;
...
@@ -12,61 +8,56 @@ import com.google.gson.annotations.SerializedName;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.List
;
@Entity
(
tableName
=
"events"
)
public
class
Event
{
public
class
Event
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
String
eventID
;
String
eventID
;
@ColumnInfo
(
name
=
"str_id"
)
@SerializedName
(
"str_id"
)
@SerializedName
(
"str_id"
)
String
eventStrID
;
String
eventStrID
;
@ColumnInfo
(
name
=
"name"
)
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
String
eventName
;
String
eventName
;
@ColumnInfo
(
name
=
"description"
)
@SerializedName
(
"description"
)
@SerializedName
(
"description"
)
String
eventDescription
;
String
eventDescription
;
@ColumnInfo
(
name
=
"image_url"
)
@SerializedName
(
"image_url"
)
@SerializedName
(
"image_url"
)
String
eventImageURL
;
String
eventImageURL
;
@ColumnInfo
(
name
=
"start_time"
)
@SerializedName
(
"start_time"
)
@SerializedName
(
"start_time"
)
Timestamp
eventStartTime
;
Timestamp
eventStartTime
;
@ColumnInfo
(
name
=
"end_time"
)
@SerializedName
(
"end_time"
)
@SerializedName
(
"end_time"
)
Timestamp
eventEndTime
;
Timestamp
eventEndTime
;
@ColumnInfo
(
name
=
"all_day"
)
@SerializedName
(
"all_day"
)
@SerializedName
(
"all_day"
)
boolean
allDayEvent
;
boolean
allDayEvent
;
@ColumnInfo
(
name
=
"venues"
)
@SerializedName
(
"venues"
)
@SerializedName
(
"venues"
)
List
<
Venue
>
eventVenues
;
List
<
Venue
>
eventVenues
;
@ColumnInfo
(
name
=
"bodies"
)
@SerializedName
(
"bodies"
)
@SerializedName
(
"bodies"
)
List
<
Body
>
eventBodies
;
List
<
Body
>
eventBodies
;
@ColumnInfo
(
name
=
"interested_count"
)
@SerializedName
(
"interested_count"
)
@SerializedName
(
"interested_count"
)
int
eventInterestedCount
;
int
eventInterestedCount
;
@ColumnInfo
(
name
=
"going_count"
)
@SerializedName
(
"going_count"
)
@SerializedName
(
"going_count"
)
int
eventGoingCount
;
int
eventGoingCount
;
@ColumnInfo
(
name
=
"interested"
)
@SerializedName
(
"interested"
)
@SerializedName
(
"interested"
)
List
<
User
>
eventInterested
;
List
<
User
>
eventInterested
;
@ColumnInfo
(
name
=
"going"
)
@SerializedName
(
"going"
)
@SerializedName
(
"going"
)
List
<
User
>
eventGoing
;
List
<
User
>
eventGoing
;
@ColumnInfo
(
name
=
"website_url"
)
@SerializedName
(
"website_url"
)
@SerializedName
(
"website_url"
)
String
eventWebsiteURL
;
String
eventWebsiteURL
;
@ColumnInfo
(
name
=
"user_ues"
)
@SerializedName
(
"user_ues"
)
@SerializedName
(
"user_ues"
)
int
eventUserUes
;
int
eventUserUes
;
@Ignore
boolean
eventBigImage
=
false
;
boolean
eventBigImage
=
false
;
public
Event
(
String
eventID
,
String
eventStrID
,
String
eventName
,
String
eventDescription
,
String
eventImageURL
,
Timestamp
eventStartTime
,
Timestamp
eventEndTime
,
boolean
allDayEvent
,
List
<
Venue
>
eventVenues
,
List
<
Body
>
eventBodies
,
int
eventInterestedCount
,
int
eventGoingCount
,
List
<
User
>
eventInterested
,
List
<
User
>
eventGoing
,
String
eventWebsiteURL
,
int
eventUserUes
)
{
public
Event
(
String
eventID
,
String
eventStrID
,
String
eventName
,
String
eventDescription
,
String
eventImageURL
,
Timestamp
eventStartTime
,
Timestamp
eventEndTime
,
boolean
allDayEvent
,
List
<
Venue
>
eventVenues
,
List
<
Body
>
eventBodies
,
int
eventInterestedCount
,
int
eventGoingCount
,
List
<
User
>
eventInterested
,
List
<
User
>
eventGoing
,
String
eventWebsiteURL
,
int
eventUserUes
)
{
...
@@ -121,6 +112,10 @@ public class Event {
...
@@ -121,6 +112,10 @@ public class Event {
}
}
public
String
getEventImageURL
()
{
public
String
getEventImageURL
()
{
// Fallback to body image if event has no image
if
(
eventImageURL
==
null
)
{
return
getEventBodies
().
get
(
0
).
getBodyImageURL
();
}
return
eventImageURL
;
return
eventImageURL
;
}
}
...
...
app/src/main/java/app/insti/data/HostelMessMenu.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
import
java.util.List
;
@Entity
(
tableName
=
"hostelMessMenus"
)
public
class
HostelMessMenu
{
public
class
HostelMessMenu
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
private
String
menuID
;
private
String
menuID
;
@ColumnInfo
(
name
=
"name"
)
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
private
String
name
;
private
String
name
;
@ColumnInfo
(
name
=
"short_name"
)
@SerializedName
(
"short_name"
)
@SerializedName
(
"short_name"
)
private
String
shortName
;
private
String
shortName
;
@ColumnInfo
(
name
=
"long_name"
)
@SerializedName
(
"long_name"
)
@SerializedName
(
"long_name"
)
private
String
longName
;
private
String
longName
;
@ColumnInfo
(
name
=
"mess"
)
@SerializedName
(
"mess"
)
@SerializedName
(
"mess"
)
private
List
<
MessMenu
>
messMenus
;
private
List
<
MessMenu
>
messMenus
;
...
...
app/src/main/java/app/insti/data/MessMenu.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
public
class
MessMenu
{
public
class
MessMenu
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
private
String
mealID
;
private
String
mealID
;
...
...
app/src/main/java/app/insti/data/NewsArticle.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
@Entity
(
tableName
=
"news"
)
public
class
NewsArticle
{
public
class
NewsArticle
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
private
String
articleID
;
private
String
articleID
;
@ColumnInfo
(
name
=
"link"
)
@SerializedName
(
"link"
)
@SerializedName
(
"link"
)
private
String
link
;
private
String
link
;
@ColumnInfo
(
name
=
"title"
)
@SerializedName
(
"title"
)
@SerializedName
(
"title"
)
private
String
title
;
private
String
title
;
@ColumnInfo
(
name
=
"content"
)
@SerializedName
(
"content"
)
@SerializedName
(
"content"
)
private
String
content
;
private
String
content
;
@ColumnInfo
(
name
=
"published"
)
@SerializedName
(
"published"
)
@SerializedName
(
"published"
)
private
Timestamp
published
;
private
Timestamp
published
;
@ColumnInfo
(
name
=
"body"
)
@SerializedName
(
"body"
)
@SerializedName
(
"body"
)
private
Body
body
;
private
Body
body
;
...
...
app/src/main/java/app/insti/data/Notification.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
@Entity
(
tableName
=
"news"
)
public
class
Notification
{
public
class
Notification
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
private
Integer
notificationId
;
private
Integer
notificationId
;
@ColumnInfo
(
name
=
"verb"
)
@SerializedName
(
"verb"
)
@SerializedName
(
"verb"
)
private
String
notificationVerb
;
private
String
notificationVerb
;
@ColumnInfo
(
name
=
"unread"
)
@SerializedName
(
"unread"
)
@SerializedName
(
"unread"
)
private
boolean
notificationUnread
;
private
boolean
notificationUnread
;
@ColumnInfo
(
name
=
"actor_type"
)
@SerializedName
(
"actor_type"
)
@SerializedName
(
"actor_type"
)
private
String
notificationActorType
;
private
String
notificationActorType
;
@ColumnInfo
(
name
=
"actor"
)
@SerializedName
(
"actor"
)
@SerializedName
(
"actor"
)
private
Object
notificationActor
;
private
Object
notificationActor
;
...
...
app/src/main/java/app/insti/data/PlacementBlogPost.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
@Entity
(
tableName
=
"placementBlogPosts"
)
public
class
PlacementBlogPost
{
public
class
PlacementBlogPost
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
private
String
postID
;
private
String
postID
;
@ColumnInfo
(
name
=
"link"
)
@SerializedName
(
"link"
)
@SerializedName
(
"link"
)
private
String
link
;
private
String
link
;
@ColumnInfo
(
name
=
"title"
)
@SerializedName
(
"title"
)
@SerializedName
(
"title"
)
private
String
title
;
private
String
title
;
@ColumnInfo
(
name
=
"content"
)
@SerializedName
(
"content"
)
@SerializedName
(
"content"
)
private
String
content
;
private
String
content
;
@ColumnInfo
(
name
=
"published"
)
@SerializedName
(
"published"
)
@SerializedName
(
"published"
)
private
Timestamp
published
;
private
Timestamp
published
;
...
...
app/src/main/java/app/insti/data/Role.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.List
;
import
java.util.List
;
@Entity
(
tableName
=
"roles"
)
public
class
Role
{
public
class
Role
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
String
roleID
;
String
roleID
;
@ColumnInfo
(
name
=
"name"
)
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
String
roleName
;
String
roleName
;
@ColumnInfo
(
name
=
"inheritable"
)
@SerializedName
(
"inheritable"
)
@SerializedName
(
"inheritable"
)
boolean
roleInheritable
;
boolean
roleInheritable
;
@ColumnInfo
(
name
=
"body"
)
@SerializedName
(
"body"
)
@SerializedName
(
"body"
)
String
roleBody
;
String
roleBody
;
@ColumnInfo
(
name
=
"body_detail"
)
@SerializedName
(
"body_detail"
)
@SerializedName
(
"body_detail"
)
Body
roleBodyDetails
;
Body
roleBodyDetails
;
@ColumnInfo
(
name
=
"bodies"
)
@SerializedName
(
"bodies"
)
@SerializedName
(
"bodies"
)
List
<
Body
>
roleBodies
;
List
<
Body
>
roleBodies
;
@ColumnInfo
(
name
=
"permissions"
)
@SerializedName
(
"permissions"
)
@SerializedName
(
"permissions"
)
List
<
String
>
rolePermissions
;
List
<
String
>
rolePermissions
;
@ColumnInfo
(
name
=
"users"
)
@SerializedName
(
"users"
)
@SerializedName
(
"users"
)
List
<
String
>
roleUsers
;
List
<
String
>
roleUsers
;
@ColumnInfo
(
name
=
"users_detail"
)
@SerializedName
(
"users_detail"
)
@SerializedName
(
"users_detail"
)
List
<
User
>
roleUsersDetail
;
List
<
User
>
roleUsersDetail
;
...
...
app/src/main/java/app/insti/data/TrainingBlogPost.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
@Entity
(
tableName
=
"trainingBlogPosts"
)
public
class
TrainingBlogPost
{
public
class
TrainingBlogPost
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
private
String
postID
;
private
String
postID
;
@ColumnInfo
(
name
=
"link"
)
@SerializedName
(
"link"
)
@SerializedName
(
"link"
)
private
String
link
;
private
String
link
;
@ColumnInfo
(
name
=
"title"
)
@SerializedName
(
"title"
)
@SerializedName
(
"title"
)
private
String
title
;
private
String
title
;
@ColumnInfo
(
name
=
"content"
)
@SerializedName
(
"content"
)
@SerializedName
(
"content"
)
private
String
content
;
private
String
content
;
@ColumnInfo
(
name
=
"published"
)
@SerializedName
(
"published"
)
@SerializedName
(
"published"
)
private
Timestamp
published
;
private
Timestamp
published
;
...
...
app/src/main/java/app/insti/data/User.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.Ignore
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -11,66 +7,59 @@ import com.google.gson.annotations.SerializedName;
...
@@ -11,66 +7,59 @@ import com.google.gson.annotations.SerializedName;
import
java.util.List
;
import
java.util.List
;
@Entity
(
tableName
=
"users"
)
public
class
User
{
public
class
User
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
String
userID
;
String
userID
;
@ColumnInfo
(
name
=
"name"
)
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
String
userName
;
String
userName
;
@ColumnInfo
(
name
=
"profile_pic"
)
@SerializedName
(
"profile_pic"
)
@SerializedName
(
"profile_pic"
)
String
userProfilePictureUrl
;
String
userProfilePictureUrl
;
@ColumnInfo
(
name
=
"events_interested"
)
@SerializedName
(
"events_interested"
)
@SerializedName
(
"events_interested"
)
List
<
Event
>
userInterestedEvents
;
List
<
Event
>
userInterestedEvents
;
@ColumnInfo
(
name
=
"events_going"
)
@SerializedName
(
"events_going"
)
@SerializedName
(
"events_going"
)
List
<
Event
>
userGoingEvents
;
List
<
Event
>
userGoingEvents
;
@ColumnInfo
(
name
=
"email"
)
@SerializedName
(
"email"
)
@SerializedName
(
"email"
)
String
userEmail
;
String
userEmail
;
@ColumnInfo
(
name
=
"roll_no"
)
@SerializedName
(
"roll_no"
)
@SerializedName
(
"roll_no"
)
String
userRollNumber
;
String
userRollNumber
;
@ColumnInfo
(
name
=
"contact_no"
)
@SerializedName
(
"contact_no"
)
@SerializedName
(
"contact_no"
)
String
userContactNumber
;
String
userContactNumber
;
@ColumnInfo
(
name
=
"about"
)
@SerializedName
(
"about"
)
@SerializedName
(
"about"
)
String
userAbout
;
String
userAbout
;
@ColumnInfo
(
name
=
"followed_bodies"
)
@SerializedName
(
"followed_bodies"
)
@SerializedName
(
"followed_bodies"
)
List
<
Body
>
userFollowedBodies
;
List
<
Body
>
userFollowedBodies
;
@ColumnInfo
(
name
=
"followed_bodies_id"
)
@SerializedName
(
"followed_bodies_id"
)
@SerializedName
(
"followed_bodies_id"
)
List
<
String
>
userFollowedBodiesID
;
List
<
String
>
userFollowedBodiesID
;
@ColumnInfo
(
name
=
"roles"
)
@SerializedName
(
"roles"
)
@SerializedName
(
"roles"
)
List
<
Role
>
userRoles
;
List
<
Role
>
userRoles
;
@ColumnInfo
(
name
=
"institute_roles"
)
@SerializedName
(
"institute_roles"
)
@SerializedName
(
"institute_roles"
)
List
<
Role
>
userInstituteRoles
;
List
<
Role
>
userInstituteRoles
;
@ColumnInfo
(
name
=
"former_roles"
)
@SerializedName
(
"former_roles"
)
@SerializedName
(
"former_roles"
)
List
<
Role
>
userFormerRoles
;
List
<
Role
>
userFormerRoles
;
@ColumnInfo
(
name
=
"website_url"
)
@SerializedName
(
"website_url"
)
@SerializedName
(
"website_url"
)
String
userWebsiteURL
;
String
userWebsiteURL
;
@ColumnInfo
(
name
=
"ldap_id"
)
@SerializedName
(
"ldap_id"
)
@SerializedName
(
"ldap_id"
)
String
userLDAPId
;
String
userLDAPId
;
@ColumnInfo
(
name
=
"hostel"
)
@SerializedName
(
"hostel"
)
@SerializedName
(
"hostel"
)
String
hostel
;
String
hostel
;
/**
* Not in database
*/
@Ignore
String
currentRole
;
String
currentRole
;
public
User
(
@NonNull
String
userID
,
String
userName
,
String
userProfilePictureUrl
,
List
<
Event
>
userInterestedEvents
,
List
<
Event
>
userGoingEvents
,
String
userEmail
,
String
userRollNumber
,
String
userContactNumber
,
String
userAbout
,
List
<
Body
>
userFollowedBodies
,
List
<
String
>
userFollowedBodiesID
,
List
<
Role
>
userRoles
,
List
<
Role
>
userInstituteRoles
,
List
<
Role
>
userFormerRoles
,
String
userWebsiteURL
,
String
userLDAPId
,
String
hostel
)
{
public
User
(
@NonNull
String
userID
,
String
userName
,
String
userProfilePictureUrl
,
List
<
Event
>
userInterestedEvents
,
List
<
Event
>
userGoingEvents
,
String
userEmail
,
String
userRollNumber
,
String
userContactNumber
,
String
userAbout
,
List
<
Body
>
userFollowedBodies
,
List
<
String
>
userFollowedBodiesID
,
List
<
Role
>
userRoles
,
List
<
Role
>
userInstituteRoles
,
List
<
Role
>
userFormerRoles
,
String
userWebsiteURL
,
String
userLDAPId
,
String
hostel
)
{
...
...
app/src/main/java/app/insti/data/Venue.java
View file @
b89fe347
package
app.insti.data
;
package
app.insti.data
;
import
android.arch.persistence.room.ColumnInfo
;
import
android.arch.persistence.room.Entity
;
import
android.arch.persistence.room.PrimaryKey
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.NonNull
;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
@Entity
(
tableName
=
"venues"
)
public
class
Venue
{
public
class
Venue
{
@NonNull
()
@NonNull
()
@PrimaryKey
()
@ColumnInfo
(
name
=
"id"
)
@SerializedName
(
"id"
)
@SerializedName
(
"id"
)
String
venueID
;
String
venueID
;
@ColumnInfo
(
name
=
"name"
)
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
String
venueName
;
String
venueName
;
@ColumnInfo
(
name
=
"short_name"
)
@SerializedName
(
"short_name"
)
@SerializedName
(
"short_name"
)
String
venueShortName
;
String
venueShortName
;
@ColumnInfo
(
name
=
"description"
)
@SerializedName
(
"description"
)
@SerializedName
(
"description"
)
String
venueDescripion
;
String
venueDescripion
;
@ColumnInfo
(
name
=
"parent"
)
@SerializedName
(
"parent"
)
@SerializedName
(
"parent"
)
String
venueParentId
;
String
venueParentId
;
@ColumnInfo
(
name
=
"parent_relation"
)
@SerializedName
(
"parent_relation"
)
@SerializedName
(
"parent_relation"
)
String
venueParentRelation
;
String
venueParentRelation
;
@ColumnInfo
(
name
=
"group_id"
)
@SerializedName
(
"group_id"
)
@SerializedName
(
"group_id"
)
Integer
venueGroupId
;
Integer
venueGroupId
;
@ColumnInfo
(
name
=
"pixel_x"
)
@SerializedName
(
"pixel_x"
)
@SerializedName
(
"pixel_x"
)
Integer
venuePixelX
;
Integer
venuePixelX
;
@ColumnInfo
(
name
=
"pixel_y"
)
@SerializedName
(
"pixel_y"
)
@SerializedName
(
"pixel_y"
)
Integer
venuePixelY
;
Integer
venuePixelY
;
@ColumnInfo
(
name
=
"reusable"
)
@SerializedName
(
"reusable"
)
@SerializedName
(
"reusable"
)
Boolean
venueReusable
;
Boolean
venueReusable
;
@ColumnInfo
(
name
=
"lat"
)
@SerializedName
(
"lat"
)
@SerializedName
(
"lat"
)
double
venueLatitude
;
double
venueLatitude
;
@ColumnInfo
(
name
=
"lng"
)
@SerializedName
(
"lng"
)
@SerializedName
(
"lng"
)
double
venueLongitude
;
double
venueLongitude
;
...
...
app/src/main/java/app/insti/fragment/AddEventFragment.java
View file @
b89fe347
...
@@ -167,7 +167,7 @@ public class AddEventFragment extends BaseFragment {
...
@@ -167,7 +167,7 @@ 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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getEvent
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Event
>()
{
retrofitInterface
.
getEvent
(((
MainActivity
)
getActivity
()).
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
)
{
...
@@ -185,7 +185,7 @@ public class AddEventFragment extends BaseFragment {
...
@@ -185,7 +185,7 @@ 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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getBody
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
url
).
enqueue
(
new
Callback
<
Body
>()
{
retrofitInterface
.
getBody
(((
MainActivity
)
getActivity
()).
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
)
{
...
...
app/src/main/java/app/insti/fragment/BodyFragment.java
View file @
b89fe347
...
@@ -45,8 +45,6 @@ import app.insti.adapter.BodyAdapter;
...
@@ -45,8 +45,6 @@ import app.insti.adapter.BodyAdapter;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.adapter.UserAdapter
;
import
app.insti.adapter.UserAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.Body
;
import
app.insti.data.Body
;
import
app.insti.data.Event
;
import
app.insti.data.Event
;
import
app.insti.data.Role
;
import
app.insti.data.Role
;
...
@@ -67,7 +65,6 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -67,7 +65,6 @@ public class BodyFragment extends BackHandledFragment {
String
TAG
=
"BodyFragment"
;
String
TAG
=
"BodyFragment"
;
private
AppDatabase
appDatabase
;
// TODO: Rename and change types of parameters
// TODO: Rename and change types of parameters
private
Body
min_body
;
private
Body
min_body
;
private
SwipeRefreshLayout
bodySwipeRefreshLayout
;
private
SwipeRefreshLayout
bodySwipeRefreshLayout
;
...
@@ -133,13 +130,11 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -133,13 +130,11 @@ public class BodyFragment extends BackHandledFragment {
/* Initialize */
/* Initialize */
bodyDisplayed
=
false
;
bodyDisplayed
=
false
;
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
body
=
min_body
;
body
=
min_body
;
displayBody
();
displayBody
();
/* Check if full body was passed */
/* Check if full body was passed */
if
(
min_body
.
getBodyDescription
()
==
null
)
{
if
(
min_body
.
getBodyDescription
()
==
null
)
{
new
getDbBody
().
execute
(
min_body
.
getBodyID
());
updateBody
();
updateBody
();
}
}
...
@@ -157,15 +152,13 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -157,15 +152,13 @@ public class BodyFragment extends BackHandledFragment {
}
}
private
void
updateBody
()
{
private
void
updateBody
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getBody
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
min_body
.
getBodyID
()).
enqueue
(
new
Callback
<
Body
>()
{
retrofitInterface
.
getBody
(((
MainActivity
)
getActivity
()).
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
())
{
Body
bodyResponse
=
response
.
body
();
Body
bodyResponse
=
response
.
body
();
new
updateDbBody
().
execute
(
bodyResponse
);
if
(!
bodyDisplayed
)
{
if
(!
bodyDisplayed
)
{
body
=
bodyResponse
;
body
=
bodyResponse
;
displayBody
();
displayBody
();
...
@@ -236,13 +229,12 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -236,13 +229,12 @@ 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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
updateBodyFollowing
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
body
.
getBodyID
(),
body
.
getBodyUserFollows
()
?
0
:
1
).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
updateBodyFollowing
(((
MainActivity
)
getActivity
()).
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
())
{
body
.
setBodyUserFollows
(!
body
.
getBodyUserFollows
());
body
.
setBodyUserFollows
(!
body
.
getBodyUserFollows
());
new
updateDbBody
().
execute
(
body
);
followButton
.
setBackgroundColor
(
getResources
().
getColor
(
body
.
getBodyUserFollows
()
?
R
.
color
.
colorAccent
:
R
.
color
.
colorWhite
));
followButton
.
setBackgroundColor
(
getResources
().
getColor
(
body
.
getBodyUserFollows
()
?
R
.
color
.
colorAccent
:
R
.
color
.
colorWhite
));
}
}
}
}
...
@@ -544,31 +536,4 @@ public class BodyFragment extends BackHandledFragment {
...
@@ -544,31 +536,4 @@ public class BodyFragment extends BackHandledFragment {
startScaleFinal
=
startScale
;
startScaleFinal
=
startScale
;
zoomMode
=
true
;
zoomMode
=
true
;
}
}
private
class
updateDbBody
extends
AsyncTask
<
Body
,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
Body
...
body
)
{
if
(
appDatabase
.
dbDao
().
getBody
(
body
[
0
].
getBodyID
()).
length
>
0
)
{
appDatabase
.
dbDao
().
updateBody
(
body
[
0
]);
}
else
{
appDatabase
.
dbDao
().
insertBody
(
body
[
0
]);
}
return
1
;
}
}
private
class
getDbBody
extends
AsyncTask
<
String
,
Void
,
Body
[]>
{
@Override
protected
Body
[]
doInBackground
(
String
...
id
)
{
return
appDatabase
.
dbDao
().
getBody
(
min_body
.
getBodyID
());
}
@Override
protected
void
onPostExecute
(
Body
[]
result
)
{
if
(
result
.
length
>
0
&&
!
bodyDisplayed
)
{
body
=
result
[
0
];
displayBody
();
}
}
}
}
}
app/src/main/java/app/insti/fragment/CalendarFragment.java
View file @
b89fe347
...
@@ -117,7 +117,7 @@ public class CalendarFragment extends BaseFragment {
...
@@ -117,7 +117,7 @@ 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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getEventsBetweenDates
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
oneMonthBack
,
oneMonthOn
).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
retrofitInterface
.
getEventsBetweenDates
(((
MainActivity
)
getActivity
()).
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
)
{
...
...
app/src/main/java/app/insti/fragment/EventFragment.java
View file @
b89fe347
...
@@ -49,8 +49,6 @@ import app.insti.ShareURLMaker;
...
@@ -49,8 +49,6 @@ import app.insti.ShareURLMaker;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.BodyAdapter
;
import
app.insti.adapter.BodyAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.Body
;
import
app.insti.data.Body
;
import
app.insti.data.Event
;
import
app.insti.data.Event
;
import
app.insti.data.Venue
;
import
app.insti.data.Venue
;
...
@@ -71,7 +69,6 @@ public class EventFragment extends BackHandledFragment {
...
@@ -71,7 +69,6 @@ public class EventFragment extends BackHandledFragment {
ImageButton
shareEventButton
;
ImageButton
shareEventButton
;
RecyclerView
bodyRecyclerView
;
RecyclerView
bodyRecyclerView
;
String
TAG
=
"EventFragment"
;
String
TAG
=
"EventFragment"
;
private
AppDatabase
appDatabase
;
// Hold a reference to the current animator,
// Hold a reference to the current animator,
// so that it can be canceled mid-way.
// so that it can be canceled mid-way.
...
@@ -135,9 +132,6 @@ public class EventFragment extends BackHandledFragment {
...
@@ -135,9 +132,6 @@ public class EventFragment extends BackHandledFragment {
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
/* Initialize */
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
Bundle
bundle
=
getArguments
();
Bundle
bundle
=
getArguments
();
String
eventJson
=
bundle
.
getString
(
Constants
.
EVENT_JSON
);
String
eventJson
=
bundle
.
getString
(
Constants
.
EVENT_JSON
);
Log
.
d
(
TAG
,
"onStart: "
+
eventJson
);
Log
.
d
(
TAG
,
"onStart: "
+
eventJson
);
...
@@ -161,11 +155,6 @@ public class EventFragment extends BackHandledFragment {
...
@@ -161,11 +155,6 @@ public class EventFragment extends BackHandledFragment {
webEventButton
=
getActivity
().
findViewById
(
R
.
id
.
web_event_button
);
webEventButton
=
getActivity
().
findViewById
(
R
.
id
.
web_event_button
);
shareEventButton
=
getActivity
().
findViewById
(
R
.
id
.
share_event_button
);
shareEventButton
=
getActivity
().
findViewById
(
R
.
id
.
share_event_button
);
// Fallback to image of first body if event has no image
if
(
event
.
getEventImageURL
()
==
null
)
{
event
.
setEventImageURL
(
event
.
getEventBodies
().
get
(
0
).
getBodyImageURL
());
}
Picasso
.
get
().
load
(
event
.
getEventImageURL
()).
into
(
eventPicture
);
Picasso
.
get
().
load
(
event
.
getEventImageURL
()).
into
(
eventPicture
);
eventTitle
.
setText
(
event
.
getEventName
());
eventTitle
.
setText
(
event
.
getEventName
());
Markwon
.
setMarkdown
(
eventDescription
,
event
.
getEventDescription
());
Markwon
.
setMarkdown
(
eventDescription
,
event
.
getEventDescription
());
...
@@ -299,7 +288,7 @@ public class EventFragment extends BackHandledFragment {
...
@@ -299,7 +288,7 @@ 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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
updateUserEventStatus
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
(),
event
.
getEventID
(),
endStatus
).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
updateUserEventStatus
(((
MainActivity
)
getActivity
()).
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
)
{
...
@@ -329,7 +318,6 @@ public class EventFragment extends BackHandledFragment {
...
@@ -329,7 +318,6 @@ public class EventFragment extends BackHandledFragment {
}
}
event
.
setEventUserUes
(
endStatus
);
event
.
setEventUserUes
(
endStatus
);
new
updateDbEvent
().
execute
(
event
);
setFollowButtonColors
(
endStatus
);
setFollowButtonColors
(
endStatus
);
}
}
}
}
...
@@ -479,12 +467,4 @@ public class EventFragment extends BackHandledFragment {
...
@@ -479,12 +467,4 @@ public class EventFragment extends BackHandledFragment {
set
.
start
();
set
.
start
();
mCurrentAnimator
=
set
;
mCurrentAnimator
=
set
;
}
}
private
class
updateDbEvent
extends
AsyncTask
<
Event
,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
Event
...
event
)
{
appDatabase
.
dbDao
().
updateEvent
(
event
[
0
]);
return
1
;
}
}
}
}
app/src/main/java/app/insti/fragment/ExploreFragment.java
View file @
b89fe347
...
@@ -87,7 +87,7 @@ public class ExploreFragment extends Fragment {
...
@@ -87,7 +87,7 @@ public class ExploreFragment extends Fragment {
// Get all bodies
// Get all bodies
if
(
allBodies
.
size
()
==
0
)
{
if
(
allBodies
.
size
()
==
0
)
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getAllBodies
(
sessionId
).
enqueue
(
new
Callback
<
List
<
Body
>>()
{
retrofitInterface
.
getAllBodies
(
sessionId
).
enqueue
(
new
Callback
<
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
)
{
...
@@ -141,7 +141,7 @@ public class ExploreFragment extends Fragment {
...
@@ -141,7 +141,7 @@ public class ExploreFragment extends Fragment {
getView
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
VISIBLE
);
getView
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
VISIBLE
);
// Make request
// Make request
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
search
(
sessionId
,
query
).
enqueue
(
new
Callback
<
ExploreResponse
>()
{
retrofitInterface
.
search
(
sessionId
,
query
).
enqueue
(
new
Callback
<
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 @
b89fe347
...
@@ -2,7 +2,6 @@ package app.insti.fragment;
...
@@ -2,7 +2,6 @@ package app.insti.fragment;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.Fragment
;
...
@@ -27,9 +26,7 @@ import app.insti.R;
...
@@ -27,9 +26,7 @@ import app.insti.R;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.api.model.NewsFeedResponse
;
import
app.insti.api.model.NewsFeedResponse
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.Event
;
import
app.insti.data.Event
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
...
@@ -42,7 +39,6 @@ public class FeedFragment extends BaseFragment {
...
@@ -42,7 +39,6 @@ public class FeedFragment extends BaseFragment {
private
RecyclerView
feedRecyclerView
;
private
RecyclerView
feedRecyclerView
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
AppDatabase
appDatabase
;
private
FloatingActionButton
fab
;
private
FloatingActionButton
fab
;
private
boolean
freshEventsDisplayed
=
false
;
private
boolean
freshEventsDisplayed
=
false
;
LinearLayoutManager
mLayoutManager
;
LinearLayoutManager
mLayoutManager
;
...
@@ -78,8 +74,6 @@ public class FeedFragment extends BaseFragment {
...
@@ -78,8 +74,6 @@ public class FeedFragment extends BaseFragment {
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
new
showEventsFromDB
().
execute
();
fab
=
(
FloatingActionButton
)
getView
().
findViewById
(
R
.
id
.
fab
);
fab
=
(
FloatingActionButton
)
getView
().
findViewById
(
R
.
id
.
fab
);
updateFeed
();
updateFeed
();
}
}
...
@@ -104,9 +98,9 @@ public class FeedFragment extends BaseFragment {
...
@@ -104,9 +98,9 @@ public class FeedFragment extends BaseFragment {
}
}
}
}
private
void
updateFeed
()
{
private
void
updateFeed
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
();
retrofitInterface
.
getNewsFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
)).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
retrofitInterface
.
getNewsFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
)).
enqueue
(
new
Callback
<
NewsFeedResponse
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
public
void
onResponse
(
Call
<
NewsFeedResponse
>
call
,
Response
<
NewsFeedResponse
>
response
)
{
...
@@ -115,8 +109,6 @@ public class FeedFragment extends BaseFragment {
...
@@ -115,8 +109,6 @@ public class FeedFragment extends BaseFragment {
List
<
Event
>
events
=
newsFeedResponse
.
getEvents
();
List
<
Event
>
events
=
newsFeedResponse
.
getEvents
();
freshEventsDisplayed
=
true
;
freshEventsDisplayed
=
true
;
displayEvents
(
events
);
displayEvents
(
events
);
new
updateDatabase
().
execute
(
events
);
}
}
//Server Error
//Server Error
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
...
@@ -192,26 +184,4 @@ public class FeedFragment extends BaseFragment {
...
@@ -192,26 +184,4 @@ public class FeedFragment extends BaseFragment {
if
(
view
!=
null
)
if
(
view
!=
null
)
view
.
setVisibility
(
View
.
GONE
);
view
.
setVisibility
(
View
.
GONE
);
}
}
private
class
updateDatabase
extends
AsyncTask
<
List
<
Event
>,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
List
<
Event
>...
events
)
{
appDatabase
.
dbDao
().
deleteEvents
();
appDatabase
.
dbDao
().
insertEvents
(
events
[
0
]);
return
1
;
}
}
private
class
showEventsFromDB
extends
AsyncTask
<
String
,
Void
,
List
<
Event
>>
{
@Override
protected
List
<
Event
>
doInBackground
(
String
...
events
)
{
return
appDatabase
.
dbDao
().
getAllEvents
();
}
protected
void
onPostExecute
(
List
<
Event
>
result
)
{
if
(!
freshEventsDisplayed
)
{
displayEvents
(
result
);
}
}
}
}
}
app/src/main/java/app/insti/fragment/MapFragment.java
View file @
b89fe347
...
@@ -90,8 +90,6 @@ import app.insti.Constants;
...
@@ -90,8 +90,6 @@ import app.insti.Constants;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.Venue
;
import
app.insti.data.Venue
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
...
@@ -129,7 +127,6 @@ public class MapFragment extends Fragment implements TextWatcher,
...
@@ -129,7 +127,6 @@ public class MapFragment extends Fragment implements TextWatcher,
public
ImageButton
addMarkerIcon
;
public
ImageButton
addMarkerIcon
;
public
SoundPool
soundPool
;
public
SoundPool
soundPool
;
public
int
[]
soundPoolIds
;
public
int
[]
soundPoolIds
;
private
AppDatabase
appDatabase
;
private
SettingsManager
settingsManager
;
private
SettingsManager
settingsManager
;
private
FuzzySearchAdapter
adapter
;
private
FuzzySearchAdapter
adapter
;
private
ExpandableListAdapter
expAdapter
;
private
ExpandableListAdapter
expAdapter
;
...
@@ -223,21 +220,18 @@ public class MapFragment extends Fragment implements TextWatcher,
...
@@ -223,21 +220,18 @@ public class MapFragment extends Fragment implements TextWatcher,
toolbar
.
setTitle
(
"InstiMap"
);
toolbar
.
setTitle
(
"InstiMap"
);
/* Initialize */
/* Initialize */
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
editText
=
(
EditText
)
getView
().
findViewById
(
R
.
id
.
search
);
editText
=
(
EditText
)
getView
().
findViewById
(
R
.
id
.
search
);
setFonts
();
setFonts
();
getAPILocations
();
getAPILocations
();
new
showLocationsFromDB
().
execute
();
}
}
private
void
getAPILocations
()
{
private
void
getAPILocations
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
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
)
{
if
(
response
.
isSuccessful
())
{
if
(
response
.
isSuccessful
())
{
new
updateDatabase
().
execute
(
response
.
body
());
if
(!
locationsShown
)
{
if
(!
locationsShown
)
{
setupWithData
(
response
.
body
());
setupWithData
(
response
.
body
());
locationsShown
=
true
;
locationsShown
=
true
;
...
@@ -1026,29 +1020,6 @@ public class MapFragment extends Fragment implements TextWatcher,
...
@@ -1026,29 +1020,6 @@ public class MapFragment extends Fragment implements TextWatcher,
});
});
}
}
private
class
updateDatabase
extends
AsyncTask
<
List
<
Venue
>,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
List
<
Venue
>...
venues
)
{
appDatabase
.
dbDao
().
deleteVenues
();
appDatabase
.
dbDao
().
insertVenues
(
venues
[
0
]);
return
1
;
}
}
private
class
showLocationsFromDB
extends
AsyncTask
<
String
,
Void
,
List
<
Venue
>>
{
@Override
protected
List
<
Venue
>
doInBackground
(
String
...
events
)
{
return
appDatabase
.
dbDao
().
getAllVenues
();
}
protected
void
onPostExecute
(
List
<
Venue
>
result
)
{
if
(!
locationsShown
&&
result
.
size
()
>
0
)
{
setupWithData
(
result
);
locationsShown
=
true
;
}
}
}
private
class
CustomListAdapter
extends
ArrayAdapter
<
String
>
{
private
class
CustomListAdapter
extends
ArrayAdapter
<
String
>
{
private
Context
mContext
;
private
Context
mContext
;
...
...
app/src/main/java/app/insti/fragment/MessMenuFragment.java
View file @
b89fe347
...
@@ -24,10 +24,9 @@ import java.util.Locale;
...
@@ -24,10 +24,9 @@ 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.activity.MainActivity
;
import
app.insti.adapter.MessMenuAdapter
;
import
app.insti.adapter.MessMenuAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.HostelMessMenu
;
import
app.insti.data.HostelMessMenu
;
import
app.insti.data.MessMenu
;
import
app.insti.data.MessMenu
;
import
retrofit2.Call
;
import
retrofit2.Call
;
...
@@ -41,7 +40,6 @@ public class MessMenuFragment extends BaseFragment {
...
@@ -41,7 +40,6 @@ public class MessMenuFragment extends BaseFragment {
private
RecyclerView
messMenuRecyclerView
;
private
RecyclerView
messMenuRecyclerView
;
private
SwipeRefreshLayout
messMenuSwipeRefreshLayout
;
private
SwipeRefreshLayout
messMenuSwipeRefreshLayout
;
private
AppDatabase
appDatabase
;
private
Spinner
hostelSpinner
;
private
Spinner
hostelSpinner
;
private
String
hostel
;
private
String
hostel
;
...
@@ -106,14 +104,11 @@ public class MessMenuFragment extends BaseFragment {
...
@@ -106,14 +104,11 @@ public class MessMenuFragment extends BaseFragment {
}
}
private
void
displayMenu
(
final
String
hostel
)
{
private
void
displayMenu
(
final
String
hostel
)
{
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
new
showMessMenuFromDB
().
execute
(
hostel
);
updateMessMenu
(
hostel
);
updateMessMenu
(
hostel
);
}
}
private
void
updateMessMenu
(
final
String
hostel
)
{
private
void
updateMessMenu
(
final
String
hostel
)
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
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
)
{
...
@@ -122,8 +117,6 @@ public class MessMenuFragment extends BaseFragment {
...
@@ -122,8 +117,6 @@ public class MessMenuFragment extends BaseFragment {
HostelMessMenu
hostelMessMenu
=
findMessMenu
(
instituteMessMenu
,
hostel
);
HostelMessMenu
hostelMessMenu
=
findMessMenu
(
instituteMessMenu
,
hostel
);
if
(
hostelMessMenu
!=
null
)
if
(
hostelMessMenu
!=
null
)
displayMessMenu
(
hostelMessMenu
);
displayMessMenu
(
hostelMessMenu
);
new
updateDatabase
().
execute
(
instituteMessMenu
);
}
}
//Server Error
//Server Error
messMenuSwipeRefreshLayout
.
setRefreshing
(
false
);
messMenuSwipeRefreshLayout
.
setRefreshing
(
false
);
...
@@ -186,27 +179,4 @@ public class MessMenuFragment extends BaseFragment {
...
@@ -186,27 +179,4 @@ public class MessMenuFragment extends BaseFragment {
});
});
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
}
}
private
class
updateDatabase
extends
AsyncTask
<
List
<
HostelMessMenu
>,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
List
<
HostelMessMenu
>...
menus
)
{
appDatabase
.
dbDao
().
deleteHostelMessMenus
();
appDatabase
.
dbDao
().
insertHostelMessMenus
(
menus
[
0
]);
return
1
;
}
}
public
class
showMessMenuFromDB
extends
AsyncTask
<
String
,
Void
,
HostelMessMenu
>
{
@Override
protected
HostelMessMenu
doInBackground
(
String
...
strings
)
{
return
findMessMenu
(
appDatabase
.
dbDao
().
getAllHostelMessMenus
(),
strings
[
0
]);
}
@Override
protected
void
onPostExecute
(
HostelMessMenu
hostelMessMenu
)
{
if
(
hostelMessMenu
!=
null
)
displayMessMenu
(
hostelMessMenu
);
}
}
}
}
app/src/main/java/app/insti/fragment/MyEventsFragment.java
View file @
b89fe347
...
@@ -26,8 +26,12 @@ import app.insti.ItemClickListener;
...
@@ -26,8 +26,12 @@ import app.insti.ItemClickListener;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.adapter.FeedAdapter
;
import
app.insti.
data.AppDatabas
e
;
import
app.insti.
api.RetrofitInterfac
e
;
import
app.insti.data.Event
;
import
app.insti.data.Event
;
import
app.insti.data.User
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
/**
/**
* A simple {@link Fragment} subclass.
* A simple {@link Fragment} subclass.
...
@@ -36,7 +40,6 @@ public class MyEventsFragment extends BaseFragment {
...
@@ -36,7 +40,6 @@ public class MyEventsFragment extends BaseFragment {
private
RecyclerView
myEventsFeedRecyclerView
;
private
RecyclerView
myEventsFeedRecyclerView
;
private
SwipeRefreshLayout
myEventsFeedSwipeRefreshLayout
;
private
SwipeRefreshLayout
myEventsFeedSwipeRefreshLayout
;
private
AppDatabase
appDatabase
;
private
FloatingActionButton
fab
;
private
FloatingActionButton
fab
;
public
MyEventsFragment
()
{
public
MyEventsFragment
()
{
...
@@ -71,8 +74,7 @@ public class MyEventsFragment extends BaseFragment {
...
@@ -71,8 +74,7 @@ public class MyEventsFragment extends BaseFragment {
fab
.
setVisibility
(
View
.
VISIBLE
);
fab
.
setVisibility
(
View
.
VISIBLE
);
}
}
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
updateOnRefresh
();
new
showEvents
().
execute
();
myEventsFeedSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
my_events_feed_swipe_refresh_layout
);
myEventsFeedSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
my_events_feed_swipe_refresh_layout
);
myEventsFeedSwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
myEventsFeedSwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
...
@@ -85,9 +87,21 @@ public class MyEventsFragment extends BaseFragment {
...
@@ -85,9 +87,21 @@ public class MyEventsFragment extends BaseFragment {
}
}
private
void
updateOnRefresh
()
{
private
void
updateOnRefresh
()
{
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
();
retrofitInterface
.
getUserMe
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
()).
enqueue
(
new
Callback
<
User
>()
{
@Override
public
void
onResponse
(
Call
<
User
>
call
,
Response
<
User
>
response
)
{
if
(
response
.
isSuccessful
())
{
User
user
=
response
.
body
();
List
<
Event
>
events
=
user
.
getUserGoingEvents
();
events
.
addAll
(
user
.
getUserInterestedEvents
());
displayEvents
(
events
);
}
}
new
showEvents
().
execute
();
@Override
public
void
onFailure
(
Call
<
User
>
call
,
Throwable
t
)
{}
});
}
}
private
void
displayEvents
(
final
List
<
Event
>
events
)
{
private
void
displayEvents
(
final
List
<
Event
>
events
)
{
...
@@ -126,16 +140,4 @@ public class MyEventsFragment extends BaseFragment {
...
@@ -126,16 +140,4 @@ public class MyEventsFragment extends BaseFragment {
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
getActivity
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
}
}
private
class
showEvents
extends
AsyncTask
<
String
,
Void
,
List
<
Event
>>
{
@Override
protected
List
<
Event
>
doInBackground
(
String
...
events
)
{
return
appDatabase
.
dbDao
().
getFollowingEvents
();
}
protected
void
onPostExecute
(
List
<
Event
>
result
)
{
displayEvents
(
result
);
}
}
}
}
\ No newline at end of file
app/src/main/java/app/insti/fragment/NewsFragment.java
View file @
b89fe347
...
@@ -30,8 +30,6 @@ import app.insti.R;
...
@@ -30,8 +30,6 @@ import app.insti.R;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.NewsAdapter
;
import
app.insti.adapter.NewsAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.NewsArticle
;
import
app.insti.data.NewsArticle
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
...
@@ -45,7 +43,6 @@ public class NewsFragment extends BaseFragment {
...
@@ -45,7 +43,6 @@ public class NewsFragment extends BaseFragment {
public
static
boolean
showLoader
=
true
;
public
static
boolean
showLoader
=
true
;
private
RecyclerView
newsRecyclerView
;
private
RecyclerView
newsRecyclerView
;
private
SwipeRefreshLayout
newsSwipeRefreshLayout
;
private
SwipeRefreshLayout
newsSwipeRefreshLayout
;
private
AppDatabase
appDatabase
;
private
boolean
freshNewsDisplayed
=
false
;
private
boolean
freshNewsDisplayed
=
false
;
private
String
searchQuery
;
private
String
searchQuery
;
...
@@ -70,9 +67,6 @@ public class NewsFragment extends BaseFragment {
...
@@ -70,9 +67,6 @@ public class NewsFragment extends BaseFragment {
setHasOptionsMenu
(
true
);
setHasOptionsMenu
(
true
);
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
new
NewsFragment
.
showNewsFromDB
().
execute
();
updateNews
();
updateNews
();
newsSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
news_swipe_refresh_layout
);
newsSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
news_swipe_refresh_layout
);
...
@@ -85,7 +79,7 @@ public class NewsFragment extends BaseFragment {
...
@@ -85,7 +79,7 @@ public class NewsFragment extends BaseFragment {
}
}
private
void
updateNews
()
{
private
void
updateNews
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getNews
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
0
,
20
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
NewsArticle
>>()
{
retrofitInterface
.
getNews
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
0
,
20
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
NewsArticle
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
NewsArticle
>>
call
,
Response
<
List
<
NewsArticle
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
NewsArticle
>>
call
,
Response
<
List
<
NewsArticle
>>
response
)
{
...
@@ -93,8 +87,6 @@ public class NewsFragment extends BaseFragment {
...
@@ -93,8 +87,6 @@ public class NewsFragment extends BaseFragment {
List
<
NewsArticle
>
articles
=
response
.
body
();
List
<
NewsArticle
>
articles
=
response
.
body
();
freshNewsDisplayed
=
true
;
freshNewsDisplayed
=
true
;
displayNews
(
articles
);
displayNews
(
articles
);
new
updateDatabase
().
execute
(
articles
);
}
}
//Server Error
//Server Error
newsSwipeRefreshLayout
.
setRefreshing
(
false
);
newsSwipeRefreshLayout
.
setRefreshing
(
false
);
...
@@ -138,7 +130,7 @@ public class NewsFragment extends BaseFragment {
...
@@ -138,7 +130,7 @@ public class NewsFragment extends BaseFragment {
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
))
{
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
))
{
loading
=
true
;
loading
=
true
;
View
v
=
getActivity
().
findViewById
(
R
.
id
.
training_feed_swipe_refresh_layout
);
View
v
=
getActivity
().
findViewById
(
R
.
id
.
training_feed_swipe_refresh_layout
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getNews
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
layoutManager
.
getItemCount
(),
10
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
NewsArticle
>>()
{
retrofitInterface
.
getNews
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
layoutManager
.
getItemCount
(),
10
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
NewsArticle
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
NewsArticle
>>
call
,
Response
<
List
<
NewsArticle
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
NewsArticle
>>
call
,
Response
<
List
<
NewsArticle
>>
response
)
{
...
@@ -213,26 +205,4 @@ public class NewsFragment extends BaseFragment {
...
@@ -213,26 +205,4 @@ public class NewsFragment extends BaseFragment {
updateNews
();
updateNews
();
showLoader
=
false
;
showLoader
=
false
;
}
}
private
class
updateDatabase
extends
AsyncTask
<
List
<
NewsArticle
>,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
List
<
NewsArticle
>...
posts
)
{
appDatabase
.
dbDao
().
deleteNewsArticles
();
appDatabase
.
dbDao
().
insertNewsArticles
(
posts
[
0
]);
return
1
;
}
}
private
class
showNewsFromDB
extends
AsyncTask
<
String
,
Void
,
List
<
NewsArticle
>>
{
@Override
protected
List
<
NewsArticle
>
doInBackground
(
String
...
posts
)
{
return
appDatabase
.
dbDao
().
getAllNewsArticles
();
}
protected
void
onPostExecute
(
List
<
NewsArticle
>
result
)
{
if
(!
freshNewsDisplayed
)
{
displayNews
(
result
);
}
}
}
}
}
app/src/main/java/app/insti/fragment/NotificationsFragment.java
View file @
b89fe347
...
@@ -57,7 +57,7 @@ public class NotificationsFragment extends BaseFragment {
...
@@ -57,7 +57,7 @@ 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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getNotifications
(((
MainActivity
)
getActivity
()).
getSessionIDHeader
()).
enqueue
(
new
Callback
<
List
<
Notification
>>()
{
retrofitInterface
.
getNotifications
(((
MainActivity
)
getActivity
()).
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
)
{
...
@@ -87,7 +87,7 @@ public class NotificationsFragment extends BaseFragment {
...
@@ -87,7 +87,7 @@ public class NotificationsFragment extends BaseFragment {
Notification
notification
=
notifications
.
get
(
position
);
Notification
notification
=
notifications
.
get
(
position
);
/* Mark notification read */
/* Mark notification read */
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
String
sessId
=
((
MainActivity
)
getActivity
()).
getSessionIDHeader
();
String
sessId
=
((
MainActivity
)
getActivity
()).
getSessionIDHeader
();
retrofitInterface
.
markNotificationRead
(
sessId
,
notification
.
getNotificationId
()).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
markNotificationRead
(
sessId
,
notification
.
getNotificationId
()).
enqueue
(
new
Callback
<
Void
>()
{
@Override
@Override
...
...
app/src/main/java/app/insti/fragment/PlacementBlogFragment.java
View file @
b89fe347
...
@@ -30,8 +30,6 @@ import app.insti.R;
...
@@ -30,8 +30,6 @@ import app.insti.R;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.PlacementBlogAdapter
;
import
app.insti.adapter.PlacementBlogAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.PlacementBlogPost
;
import
app.insti.data.PlacementBlogPost
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
...
@@ -46,7 +44,6 @@ public class PlacementBlogFragment extends BaseFragment {
...
@@ -46,7 +44,6 @@ public class PlacementBlogFragment extends BaseFragment {
private
RecyclerView
placementFeedRecyclerView
;
private
RecyclerView
placementFeedRecyclerView
;
private
PlacementBlogAdapter
placementBlogAdapter
;
private
PlacementBlogAdapter
placementBlogAdapter
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
AppDatabase
appDatabase
;
private
boolean
freshBlogDisplayed
=
false
;
private
boolean
freshBlogDisplayed
=
false
;
private
String
searchQuery
;
private
String
searchQuery
;
...
@@ -72,9 +69,6 @@ public class PlacementBlogFragment extends BaseFragment {
...
@@ -72,9 +69,6 @@ public class PlacementBlogFragment extends BaseFragment {
setHasOptionsMenu
(
true
);
setHasOptionsMenu
(
true
);
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
new
PlacementBlogFragment
.
showPlacementBlogFromDB
().
execute
();
updatePlacementFeed
();
updatePlacementFeed
();
feedSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
placement_feed_swipe_refresh_layout
);
feedSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
placement_feed_swipe_refresh_layout
);
...
@@ -87,7 +81,7 @@ public class PlacementBlogFragment extends BaseFragment {
...
@@ -87,7 +81,7 @@ public class PlacementBlogFragment extends BaseFragment {
}
}
private
void
updatePlacementFeed
()
{
private
void
updatePlacementFeed
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getPlacementBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
0
,
20
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
PlacementBlogPost
>>()
{
retrofitInterface
.
getPlacementBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
0
,
20
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
PlacementBlogPost
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
PlacementBlogPost
>>
call
,
Response
<
List
<
PlacementBlogPost
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
PlacementBlogPost
>>
call
,
Response
<
List
<
PlacementBlogPost
>>
response
)
{
...
@@ -95,8 +89,6 @@ public class PlacementBlogFragment extends BaseFragment {
...
@@ -95,8 +89,6 @@ public class PlacementBlogFragment extends BaseFragment {
List
<
PlacementBlogPost
>
posts
=
response
.
body
();
List
<
PlacementBlogPost
>
posts
=
response
.
body
();
freshBlogDisplayed
=
true
;
freshBlogDisplayed
=
true
;
displayPlacementFeed
(
posts
);
displayPlacementFeed
(
posts
);
new
updateDatabase
().
execute
(
posts
);
}
}
//Server Error
//Server Error
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
...
@@ -138,7 +130,7 @@ public class PlacementBlogFragment extends BaseFragment {
...
@@ -138,7 +130,7 @@ public class PlacementBlogFragment extends BaseFragment {
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
))
{
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
))
{
loading
=
true
;
loading
=
true
;
View
v
=
getActivity
().
findViewById
(
R
.
id
.
placement_feed_swipe_refresh_layout
);
View
v
=
getActivity
().
findViewById
(
R
.
id
.
placement_feed_swipe_refresh_layout
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getPlacementBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
layoutManager
.
getItemCount
(),
10
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
PlacementBlogPost
>>()
{
retrofitInterface
.
getPlacementBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
layoutManager
.
getItemCount
(),
10
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
PlacementBlogPost
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
PlacementBlogPost
>>
call
,
Response
<
List
<
PlacementBlogPost
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
PlacementBlogPost
>>
call
,
Response
<
List
<
PlacementBlogPost
>>
response
)
{
...
@@ -213,26 +205,4 @@ public class PlacementBlogFragment extends BaseFragment {
...
@@ -213,26 +205,4 @@ public class PlacementBlogFragment extends BaseFragment {
updatePlacementFeed
();
updatePlacementFeed
();
showLoader
=
false
;
showLoader
=
false
;
}
}
private
class
updateDatabase
extends
AsyncTask
<
List
<
PlacementBlogPost
>,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
List
<
PlacementBlogPost
>...
posts
)
{
appDatabase
.
dbDao
().
deletePlacementBlogPosts
();
appDatabase
.
dbDao
().
insertPlacementBlogPosts
(
posts
[
0
]);
return
1
;
}
}
private
class
showPlacementBlogFromDB
extends
AsyncTask
<
String
,
Void
,
List
<
PlacementBlogPost
>>
{
@Override
protected
List
<
PlacementBlogPost
>
doInBackground
(
String
...
posts
)
{
return
appDatabase
.
dbDao
().
getAllPlacementBlogPosts
();
}
protected
void
onPostExecute
(
List
<
PlacementBlogPost
>
result
)
{
if
(!
freshBlogDisplayed
)
{
displayPlacementFeed
(
result
);
}
}
}
}
}
app/src/main/java/app/insti/fragment/SettingsFragment.java
View file @
b89fe347
...
@@ -58,7 +58,7 @@ public class SettingsFragment extends Fragment {
...
@@ -58,7 +58,7 @@ public class SettingsFragment extends Fragment {
populateViews
();
populateViews
();
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
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
)
{
...
@@ -139,7 +139,7 @@ public class SettingsFragment extends Fragment {
...
@@ -139,7 +139,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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
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/TrainingBlogFragment.java
View file @
b89fe347
...
@@ -30,8 +30,6 @@ import app.insti.R;
...
@@ -30,8 +30,6 @@ import app.insti.R;
import
app.insti.activity.MainActivity
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.TrainingBlogAdapter
;
import
app.insti.adapter.TrainingBlogAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.ServiceGenerator
;
import
app.insti.data.AppDatabase
;
import
app.insti.data.TrainingBlogPost
;
import
app.insti.data.TrainingBlogPost
;
import
retrofit2.Call
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Callback
;
...
@@ -45,7 +43,6 @@ public class TrainingBlogFragment extends BaseFragment {
...
@@ -45,7 +43,6 @@ public class TrainingBlogFragment extends BaseFragment {
public
static
boolean
showLoader
=
true
;
public
static
boolean
showLoader
=
true
;
private
RecyclerView
trainingFeedRecyclerView
;
private
RecyclerView
trainingFeedRecyclerView
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
SwipeRefreshLayout
feedSwipeRefreshLayout
;
private
AppDatabase
appDatabase
;
private
boolean
freshBlogDisplayed
=
false
;
private
boolean
freshBlogDisplayed
=
false
;
private
String
searchQuery
;
private
String
searchQuery
;
...
@@ -71,9 +68,6 @@ public class TrainingBlogFragment extends BaseFragment {
...
@@ -71,9 +68,6 @@ public class TrainingBlogFragment extends BaseFragment {
setHasOptionsMenu
(
true
);
setHasOptionsMenu
(
true
);
appDatabase
=
AppDatabase
.
getAppDatabase
(
getContext
());
new
TrainingBlogFragment
.
showTrainingBlogFromDB
().
execute
();
updateTrainingFeed
();
updateTrainingFeed
();
feedSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
training_feed_swipe_refresh_layout
);
feedSwipeRefreshLayout
=
getActivity
().
findViewById
(
R
.
id
.
training_feed_swipe_refresh_layout
);
...
@@ -86,7 +80,7 @@ public class TrainingBlogFragment extends BaseFragment {
...
@@ -86,7 +80,7 @@ public class TrainingBlogFragment extends BaseFragment {
}
}
private
void
updateTrainingFeed
()
{
private
void
updateTrainingFeed
()
{
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getTrainingBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
0
,
20
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
TrainingBlogPost
>>()
{
retrofitInterface
.
getTrainingBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
0
,
20
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
TrainingBlogPost
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
TrainingBlogPost
>>
call
,
Response
<
List
<
TrainingBlogPost
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
TrainingBlogPost
>>
call
,
Response
<
List
<
TrainingBlogPost
>>
response
)
{
...
@@ -94,8 +88,6 @@ public class TrainingBlogFragment extends BaseFragment {
...
@@ -94,8 +88,6 @@ public class TrainingBlogFragment extends BaseFragment {
List
<
TrainingBlogPost
>
posts
=
response
.
body
();
List
<
TrainingBlogPost
>
posts
=
response
.
body
();
freshBlogDisplayed
=
true
;
freshBlogDisplayed
=
true
;
displayTrainingFeed
(
posts
);
displayTrainingFeed
(
posts
);
new
updateDatabase
().
execute
(
posts
);
}
}
//Server Error
//Server Error
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
feedSwipeRefreshLayout
.
setRefreshing
(
false
);
...
@@ -137,7 +129,7 @@ public class TrainingBlogFragment extends BaseFragment {
...
@@ -137,7 +129,7 @@ public class TrainingBlogFragment extends BaseFragment {
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
))
{
if
(((
layoutManager
.
getChildCount
()
+
layoutManager
.
findFirstVisibleItemPosition
())
>
(
layoutManager
.
getItemCount
()
-
5
))
&&
(!
loading
))
{
loading
=
true
;
loading
=
true
;
View
v
=
getActivity
().
findViewById
(
R
.
id
.
training_feed_swipe_refresh_layout
);
View
v
=
getActivity
().
findViewById
(
R
.
id
.
training_feed_swipe_refresh_layout
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
getRetrofitInterface
(
);
retrofitInterface
.
getTrainingBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
layoutManager
.
getItemCount
(),
10
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
TrainingBlogPost
>>()
{
retrofitInterface
.
getTrainingBlogFeed
(
"sessionid="
+
getArguments
().
getString
(
Constants
.
SESSION_ID
),
layoutManager
.
getItemCount
(),
10
,
searchQuery
).
enqueue
(
new
Callback
<
List
<
TrainingBlogPost
>>()
{
@Override
@Override
public
void
onResponse
(
Call
<
List
<
TrainingBlogPost
>>
call
,
Response
<
List
<
TrainingBlogPost
>>
response
)
{
public
void
onResponse
(
Call
<
List
<
TrainingBlogPost
>>
call
,
Response
<
List
<
TrainingBlogPost
>>
response
)
{
...
@@ -212,26 +204,4 @@ public class TrainingBlogFragment extends BaseFragment {
...
@@ -212,26 +204,4 @@ public class TrainingBlogFragment extends BaseFragment {
updateTrainingFeed
();
updateTrainingFeed
();
showLoader
=
false
;
showLoader
=
false
;
}
}
private
class
updateDatabase
extends
AsyncTask
<
List
<
TrainingBlogPost
>,
Void
,
Integer
>
{
@Override
protected
Integer
doInBackground
(
List
<
TrainingBlogPost
>...
posts
)
{
appDatabase
.
dbDao
().
deleteTrainingBlogPosts
();
appDatabase
.
dbDao
().
insertTrainingBlogPosts
(
posts
[
0
]);
return
1
;
}
}
private
class
showTrainingBlogFromDB
extends
AsyncTask
<
String
,
Void
,
List
<
TrainingBlogPost
>>
{
@Override
protected
List
<
TrainingBlogPost
>
doInBackground
(
String
...
posts
)
{
return
appDatabase
.
dbDao
().
getAllTrainingBlogPosts
();
}
protected
void
onPostExecute
(
List
<
TrainingBlogPost
>
result
)
{
if
(!
freshBlogDisplayed
)
{
displayTrainingFeed
(
result
);
}
}
}
}
}
app/src/main/java/app/insti/fragment/UserFragment.java
View file @
b89fe347
...
@@ -34,6 +34,7 @@ import app.insti.Constants;
...
@@ -34,6 +34,7 @@ import app.insti.Constants;
import
app.insti.ItemClickListener
;
import
app.insti.ItemClickListener
;
import
app.insti.R
;
import
app.insti.R
;
import
app.insti.ShareURLMaker
;
import
app.insti.ShareURLMaker
;
import
app.insti.activity.MainActivity
;
import
app.insti.adapter.RoleAdapter
;
import
app.insti.adapter.RoleAdapter
;
import
app.insti.adapter.TabAdapter
;
import
app.insti.adapter.TabAdapter
;
import
app.insti.api.RetrofitInterface
;
import
app.insti.api.RetrofitInterface
;
...
@@ -107,7 +108,7 @@ public class UserFragment extends BackHandledFragment {
...
@@ -107,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
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
RetrofitInterface
retrofitInterface
=
((
MainActivity
)
getActivity
()).
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
)
{
...
...
app/src/main/java/app/insti/notifications/NotificationIntentService.java
View file @
b89fe347
...
@@ -112,7 +112,8 @@ public class NotificationIntentService extends JobIntentService {
...
@@ -112,7 +112,8 @@ public class NotificationIntentService extends JobIntentService {
String
eventID
=
intent
.
getStringExtra
(
Constants
.
EVENT_ID
);
String
eventID
=
intent
.
getStringExtra
(
Constants
.
EVENT_ID
);
String
sessionID
=
intent
.
getStringExtra
(
Constants
.
SESSION_ID
);
String
sessionID
=
intent
.
getStringExtra
(
Constants
.
SESSION_ID
);
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
RetrofitInterface
retrofitInterface
=
serviceGenerator
.
getRetrofitInterface
();
retrofitInterface
.
updateUserEventStatus
(
"sessionid="
+
sessionID
,
eventID
,
Constants
.
STATUS_NOT_GOING
).
enqueue
(
new
Callback
<
Void
>()
{
retrofitInterface
.
updateUserEventStatus
(
"sessionid="
+
sessionID
,
eventID
,
Constants
.
STATUS_NOT_GOING
).
enqueue
(
new
Callback
<
Void
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
public
void
onResponse
(
Call
<
Void
>
call
,
Response
<
Void
>
response
)
{
...
@@ -149,7 +150,8 @@ public class NotificationIntentService extends JobIntentService {
...
@@ -149,7 +150,8 @@ public class NotificationIntentService extends JobIntentService {
String
userID
=
sessionManager
.
getUserID
();
String
userID
=
sessionManager
.
getUserID
();
final
String
sessionID
=
sessionManager
.
getSessionID
();
final
String
sessionID
=
sessionManager
.
getSessionID
();
RetrofitInterface
retrofitInterface
=
ServiceGenerator
.
createService
(
RetrofitInterface
.
class
);
ServiceGenerator
serviceGenerator
=
new
ServiceGenerator
(
getApplicationContext
());
RetrofitInterface
retrofitInterface
=
serviceGenerator
.
getRetrofitInterface
();
retrofitInterface
.
getUser
(
"sessionid="
+
sessionID
,
userID
).
enqueue
(
new
Callback
<
User
>()
{
retrofitInterface
.
getUser
(
"sessionid="
+
sessionID
,
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