Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BIDL
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Christof Wolke
BIDL
Commits
31e384e4
Commit
31e384e4
authored
Sep 09, 2016
by
Christof Wolke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Andere Logik, wann das eventobject vom Server geholt wird
parent
9e9fd2b0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
186 additions
and
47 deletions
+186
-47
BIDL/BIDL/app/src/main/AndroidManifest.xml
BIDL/BIDL/app/src/main/AndroidManifest.xml
+1
-1
BIDL/BIDL/app/src/main/java/classes/Event.java
BIDL/BIDL/app/src/main/java/classes/Event.java
+40
-2
BIDL/BIDL/app/src/main/java/classes/apps/Feedback/Question.java
...IDL/app/src/main/java/classes/apps/Feedback/Question.java
+1
-0
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
...in/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
+62
-20
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/FeedbackActivity.java
...a/de/uni_oldenburg/bidl/member_view/FeedbackActivity.java
+23
-21
BIDL/BIDL/app/src/main/java/services/db/DBHelper.java
BIDL/BIDL/app/src/main/java/services/db/DBHelper.java
+19
-2
BIDL/BIDL/app/src/main/java/services/servercommunication/NetworkService.java
...ain/java/services/servercommunication/NetworkService.java
+38
-0
BIDL/BIDL/app/src/main/res/values/strings.xml
BIDL/BIDL/app/src/main/res/values/strings.xml
+2
-1
No files found.
BIDL/BIDL/app/src/main/AndroidManifest.xml
View file @
31e384e4
...
...
@@ -24,7 +24,7 @@
android:value=
"de.uni_oldenburg.bidl.classes"
/>
<meta-data
android:name=
"Rush_db_version"
android:value=
"
3
"
/>
android:value=
"
4
"
/>
<meta-data
android:name=
"Rush_db_name"
android:value=
"bidl.db"
/>
...
...
BIDL/BIDL/app/src/main/java/classes/Event.java
View file @
31e384e4
...
...
@@ -25,16 +25,27 @@ public class Event extends RushObject implements Serializable {
@JsonField
(
name
=
"apps"
)
private
HashMap
<
String
,
String
>
apps
;
@JsonField
(
name
=
"nextStart"
)
private
int
nextStart
;
@JsonField
(
name
=
"nextName"
)
private
String
nextEventName
;
@JsonField
(
name
=
"currentEnd"
)
private
int
currentEnd
;
public
Event
()
{
}
public
Event
(
int
eventId
,
String
name
,
HashMap
<
String
,
String
>
apps
)
{
public
Event
(
int
eventId
,
String
name
,
HashMap
<
String
,
String
>
apps
,
int
nextStart
,
String
nextEventName
,
int
currentEnd
)
{
this
.
eventId
=
eventId
;
this
.
name
=
name
;
this
.
apps
=
apps
;
this
.
nextStart
=
nextStart
;
this
.
nextEventName
=
nextEventName
;
this
.
currentEnd
=
currentEnd
;
}
public
int
getEventId
()
{
return
eventId
;
}
...
...
@@ -59,12 +70,39 @@ public class Event extends RushObject implements Serializable {
this
.
apps
=
apps
;
}
public
int
getNextStart
()
{
return
nextStart
;
}
public
void
setNextStart
(
int
nextStart
)
{
this
.
nextStart
=
nextStart
;
}
public
String
getNextEventName
()
{
return
nextEventName
;
}
public
void
setNextEventName
(
String
nextEventName
)
{
this
.
nextEventName
=
nextEventName
;
}
public
int
getCurrentEnd
()
{
return
currentEnd
;
}
public
void
setCurrentEnd
(
int
currentEnd
)
{
this
.
currentEnd
=
currentEnd
;
}
@Override
public
String
toString
()
{
return
"Event{"
+
"eventId="
+
eventId
+
", name='"
+
name
+
'\''
+
", apps="
+
apps
+
", nextStart="
+
nextStart
+
", nextEventName='"
+
nextEventName
+
'\''
+
", currentEnd="
+
currentEnd
+
'}'
;
}
}
BIDL/BIDL/app/src/main/java/classes/apps/Feedback/Question.java
View file @
31e384e4
...
...
@@ -4,6 +4,7 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
import
com.bluelinelabs.logansquare.annotation.JsonObject
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
co.uk.rushorm.core.RushObject
;
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
View file @
31e384e4
...
...
@@ -19,7 +19,9 @@ import com.estimote.sdk.Region;
import
com.estimote.sdk.SystemRequirementsChecker
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -59,6 +61,8 @@ public class MainActivity extends BaseActivity {
private
ArrayAdapter
<
String
>
adapter
;
private
Event
event
;
private
HashMap
<
String
,
String
>
map
;
private
int
currentEventEnd
;
private
int
nextEventStart
;
...
...
@@ -143,6 +147,9 @@ public class MainActivity extends BaseActivity {
progress
.
show
();
}
/**
* Searching for the nearest Beacon and get the Event from the Server
*/
private
void
startRanging
()
{
if
(
RANGING
&&
isBluetoothAvailable
()){
beaconManager
.
setRangingListener
(
new
BeaconManager
.
RangingListener
()
{
...
...
@@ -150,15 +157,36 @@ public class MainActivity extends BaseActivity {
public
void
onBeaconsDiscovered
(
Region
region
,
List
<
Beacon
>
list
)
{
noBeaconTV
.
setVisibility
(
View
.
INVISIBLE
);
grid
.
setVisibility
(
View
.
VISIBLE
);
if
(!
list
.
isEmpty
()
&&
!
list
.
get
(
0
).
equals
(
nearestBeacon
)){
nearestBeacon
=
list
.
get
(
0
);
getEventFromServer
(
nearestBeacon
);
int
currentTime
=
getCurrentTime
();
if
(
event
!=
null
){
currentEventEnd
=
event
.
getCurrentEnd
();
nextEventStart
=
event
.
getNextStart
();
}
else
{
currentEventEnd
=
0
;
nextEventStart
=
0
;
}
/**
* only do a Network call, if there is a new Beacon or if the current Event ends and
* a new Event starts
*/
if
(!
list
.
isEmpty
()
&&
!
list
.
get
(
0
).
equals
(
nearestBeacon
)
||
currentEventEnd
<
currentTime
){
if
(
currentEventEnd
<=
currentTime
&&
currentTime
<
nextEventStart
){
setInformationText
(
"In "
+(
nextEventStart
-
currentTime
)+
" Minuten findet die Veranstaltung "
+
event
.
getNextEventName
()+
" statt."
);
setTitle
(
R
.
string
.
app_name
);
}
else
if
(
nextEventStart
==
-
1
){
setInformationText
(
getString
(
R
.
string
.
noEventToday
));
setTitle
(
R
.
string
.
app_name
);
}
else
{
nearestBeacon
=
list
.
get
(
0
);
getEventFromServer
(
nearestBeacon
);
}
}
if
(
list
.
isEmpty
()){
progress
.
dismiss
();
grid
.
setVisibility
(
View
.
INVISIBLE
);
noBeaconTV
.
setText
(
R
.
string
.
noBeaconFound
);
noBeaconTV
.
setVisibility
(
View
.
VISIBLE
);
setInformationText
(
getString
(
R
.
string
.
noBeaconFound
));
}
}
...
...
@@ -166,6 +194,30 @@ public class MainActivity extends BaseActivity {
}
}
private
void
setInformationText
(
final
String
text
)
{
MainActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
progress
.
dismiss
();
grid
.
setVisibility
(
View
.
INVISIBLE
);
noBeaconTV
.
setText
(
text
);
noBeaconTV
.
setVisibility
(
View
.
VISIBLE
);
}
});
}
/**
* Get the current Time
* @return the current Time with the format from the Server
*/
private
int
getCurrentTime
()
{
Calendar
calendar
=
Calendar
.
getInstance
();
Date
date
=
calendar
.
getTime
();
int
hour
=
date
.
getHours
()*
60
;
int
minute
=
date
.
getMinutes
();
return
hour
+
minute
;
}
private
void
getEventFromServer
(
Beacon
nearestBeacon
)
{
String
uud
=
nearestBeacon
.
getProximityUUID
().
toString
().
toUpperCase
();
int
major
=
nearestBeacon
.
getMajor
();
...
...
@@ -179,7 +231,7 @@ public class MainActivity extends BaseActivity {
@Override
public
void
run
()
{
setTitle
(
event
.
getName
());
Log
.
d
(
TAG
,
event
.
getName
()
);
currentEventEnd
=
event
.
getCurrentEnd
(
);
map
=
event
.
getApps
();
Collection
<
String
>
appnames
=
map
.
values
();
updateData
(
appnames
);
...
...
@@ -188,8 +240,7 @@ public class MainActivity extends BaseActivity {
});
}
else
{
progress
.
dismiss
();
showMessage
(
getResources
().
getString
(
R
.
string
.
noCurrentEvent
));
setInformationText
(
getString
(
R
.
string
.
noCurrentEvent
));
}
}
...
...
@@ -237,22 +288,13 @@ public class MainActivity extends BaseActivity {
}
public
static
boolean
isBluetoothAvailable
(){
final
BluetoothAdapter
bluetoothAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
return
(
bluetoothAdapter
!=
null
&&
bluetoothAdapter
.
isEnabled
());
}
private
void
showMessage
(
final
String
message
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
getApplicationContext
(),
message
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
public
void
setEvent
(
Event
event
)
{
this
.
event
=
event
;
}
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/FeedbackActivity.java
View file @
31e384e4
...
...
@@ -2,6 +2,7 @@ package de.uni_oldenburg.bidl.member_view;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.widget.Button
;
...
...
@@ -62,31 +63,32 @@ public class FeedbackActivity extends AppCompatActivity {
protected
void
onStart
()
{
super
.
onStart
();
event
=
DBHelper
.
getEvent
();
NetworkService
.
getQuestions
(
event
.
getEventId
(),
new
NetworkService
.
RequestGetQuestionsHandler
()
{
@Override
public
void
done
(
final
List
<
Question
>
questions
)
{
if
(
questions
!=
null
){
setQuestions
(
questions
);
FeedbackActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
Question
question
:
questions
)
{
initGui
(
question
);
NetworkService
.
getQuestions
(
event
.
getEventId
(),
new
NetworkService
.
RequestGetQuestionsHandler
()
{
@Override
public
void
done
(
final
List
<
Question
>
questions
)
{
if
(
questions
!=
null
){
//setQuestions(questions);
FeedbackActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
for
(
Question
question
:
questions
)
{
initGui
(
question
);
}
}
}
});
}
else
{
TextView
tv
=
new
TextView
(
getApplicationContext
());
tv
.
setText
(
R
.
string
.
noQuestions
);
tv
.
setGravity
(
Gravity
.
CENTER
);
tv
.
setSingleLine
(
false
);
});
}
else
{
TextView
tv
=
new
TextView
(
getApplicationContext
());
tv
.
setText
(
R
.
string
.
noQuestions
);
tv
.
setGravity
(
Gravity
.
CENTER
);
tv
.
setSingleLine
(
false
);
}
}
}
});
}
});
}
...
...
BIDL/BIDL/app/src/main/java/services/db/DBHelper.java
View file @
31e384e4
...
...
@@ -3,8 +3,12 @@ package services.db;
import
android.app.Application
;
import
android.content.Context
;
import
java.util.ArrayList
;
import
java.util.List
;
import
classes.Event
;
import
classes.LocalStorage
;
import
classes.apps.feedback.Question
;
import
co.uk.rushorm.core.RushCore
;
import
co.uk.rushorm.core.RushSearch
;
...
...
@@ -46,17 +50,30 @@ public class DBHelper {
return
event
;
}
public
static
List
<
Question
>
getQuestions
(){
List
<
Question
>
questions
=
new
RushSearch
().
find
(
Question
.
class
);
return
questions
;
}
public
static
Question
getQuestionById
(
int
questionId
){
Question
question
=
new
RushSearch
().
whereEqual
(
"questionId"
,
questionId
).
findSingle
(
Question
.
class
);
return
question
;
}
/**
* Löscht
Recommendations, Locations, Favoriten und Check-I
ns von der Datenbank
* Löscht
Events und Questio
ns von der Datenbank
*/
public
static
void
clearAll
()
{
clearEvents
();
clearQuestions
();
}
private
static
void
clearEvents
()
{
RushCore
.
getInstance
().
deleteAll
(
Event
.
class
);
}
private
static
void
clearQuestions
(){
RushCore
.
getInstance
().
deleteAll
(
Question
.
class
);}
}
BIDL/BIDL/app/src/main/java/services/servercommunication/NetworkService.java
View file @
31e384e4
...
...
@@ -18,6 +18,7 @@ import classes.StatusResponse;
import
classes.User
;
import
classes.apps.feedback.Question
;
import
classes.apps.forum.Forum
;
import
services.db.DBHelper
;
/**
* Helfer Klasse, die häufig verwendete I/O Operationen im Netzwerk und der Datenbank erleichtert
...
...
@@ -132,8 +133,19 @@ public abstract class NetworkService {
void
done
(
String
statusResponse
);
}
/**
* Holt sich das aktuelle event mit den zugeordneten apps, dem eventende und wann das nächste
* event in diesem Raum startet.
* @param uud
* @param major
* @param minor
* @param handler
*/
public
static
void
getEvent
(
String
uud
,
int
major
,
int
minor
,
final
RequestGetEventHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
if
(
DBHelper
.
getEvent
()
!=
null
){
DBHelper
.
clearAll
();
}
/* OkHttpClient
Request body mit POST params
...
...
@@ -182,6 +194,11 @@ public abstract class NetworkService {
void
done
(
Event
event
);
}
/**
* Liefert alle Kommentare der User zu dem Event.
* @param eventId
* @param handler
*/
public
static
void
forum
(
int
eventId
,
final
RequestForumHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
...
...
@@ -222,6 +239,13 @@ public abstract class NetworkService {
void
done
(
Forum
forum
);
}
/**
* Speichert einen neuen Kommentar
* @param comment
* @param forumId
* @param userId
* @param handler
*/
public
static
void
setNewComment
(
String
comment
,
int
forumId
,
int
userId
,
final
RequestNewCommentHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
...
...
@@ -265,6 +289,11 @@ public abstract class NetworkService {
void
done
(
String
status
);
}
/**
* Holt sich alle Fragen mit den Antwortmöglichkeiten, die für das Event erstellt wurden.
* @param eventId
* @param handler
*/
public
static
void
getQuestions
(
int
eventId
,
final
RequestGetQuestionsHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
...
...
@@ -291,6 +320,9 @@ public abstract class NetworkService {
try
{
if
(
response
.
isSuccessful
()){
List
<
Question
>
questions
=
LoganSquare
.
parseList
(
response
.
body
().
byteStream
(),
Question
.
class
);
for
(
Question
question:
questions
)
{
question
.
save
();
}
handler
.
done
(
questions
);
}
}
catch
(
IOException
e
){
...
...
@@ -306,6 +338,12 @@ public abstract class NetworkService {
void
done
(
List
<
Question
>
questions
);
}
/**
* speichert die Antworten des Users zu jeder Frage.
* @param questionId
* @param finalAnswer
* @param handler
*/
public
static
void
saveAnswer
(
int
questionId
,
String
finalAnswer
,
final
RequestSaveAnswerHandler
handler
){
okHttpClient
.
setReadTimeout
(
15
,
TimeUnit
.
SECONDS
);
...
...
BIDL/BIDL/app/src/main/res/values/strings.xml
View file @
31e384e4
...
...
@@ -8,7 +8,8 @@
<!-- Main Activity !-->
<string
name=
"clickAgainToExit"
>
Erneut klicken zum Beenden!
</string>
<string
name=
"noCurrentEvent"
>
In diesem Raum findet aktuell keine Veranstaltung statt
</string>
<string
name=
"noCurrentEvent"
>
In diesem Raum findet aktuell keine Veranstaltung statt!
</string>
<string
name=
"noEventToday"
>
Heute findet in diesem Raum keine Veranstaltung mehr statt!
</string>
<string
name=
"ESTIMOTE_PROXIMITY_UUID"
>
B9407F30-F5F8-466E-AFF9-25556B57FE6D
</string>
<!-- Menu -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment