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
319a52f9
Commit
319a52f9
authored
Sep 01, 2016
by
Christof Wolke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get Comments and react on swipeRefresh
parent
c4e93cac
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
365 additions
and
15 deletions
+365
-15
BIDL/BIDL/app/src/main/java/classes/MyList.java
BIDL/BIDL/app/src/main/java/classes/MyList.java
+1
-1
BIDL/BIDL/app/src/main/java/classes/apps/Forum/Forum.java
BIDL/BIDL/app/src/main/java/classes/apps/Forum/Forum.java
+5
-5
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
...in/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
+2
-0
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/listfragment/CommentListAdapter.java
...e/uni_oldenburg/bidl/listfragment/CommentListAdapter.java
+65
-1
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/listfragment/ListCommunicator.java
.../de/uni_oldenburg/bidl/listfragment/ListCommunicator.java
+21
-0
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/listfragment/SuperListFragment.java
...de/uni_oldenburg/bidl/listfragment/SuperListFragment.java
+171
-0
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/ForumActivity.java
...java/de/uni_oldenburg/bidl/member_view/ForumActivity.java
+72
-4
BIDL/BIDL/app/src/main/res/layout/activity_forum.xml
BIDL/BIDL/app/src/main/res/layout/activity_forum.xml
+5
-0
BIDL/BIDL/app/src/main/res/layout/comment_item.xml
BIDL/BIDL/app/src/main/res/layout/comment_item.xml
+8
-4
BIDL/BIDL/app/src/main/res/layout/fragment_bidl_list.xml
BIDL/BIDL/app/src/main/res/layout/fragment_bidl_list.xml
+15
-0
No files found.
BIDL/BIDL/app/src/main/java/classes/MyList.java
View file @
319a52f9
...
...
@@ -6,5 +6,5 @@ import java.io.Serializable;
* Superklasse für alle Listen Objekte
* Created by Christof on 01.09.2016.
*/
public
class
MyList
implements
Serializable
{
public
abstract
class
MyList
implements
Serializable
{
}
BIDL/BIDL/app/src/main/java/classes/apps/Forum/Forum.java
View file @
319a52f9
...
...
@@ -18,15 +18,15 @@ public class Forum extends RushObject implements Serializable {
@JsonField
(
name
=
"id"
)
private
int
forumId
;
@RushList
(
classType
=
Forum
.
Comment
.
class
)
@RushList
(
classType
=
Comment
.
class
)
@JsonField
(
name
=
"comments"
)
private
ArrayList
<
Forum
.
Comment
>
comments
;
private
ArrayList
<
Comment
>
comments
;
public
Forum
(){
}
public
Forum
(
int
id
,
ArrayList
<
Forum
.
Comment
>
comments
)
{
public
Forum
(
int
id
,
ArrayList
<
Comment
>
comments
)
{
this
.
forumId
=
id
;
this
.
comments
=
comments
;
}
...
...
@@ -39,11 +39,11 @@ public class Forum extends RushObject implements Serializable {
this
.
forumId
=
forumId
;
}
public
ArrayList
<
Forum
.
Comment
>
getComments
()
{
public
ArrayList
<
Comment
>
getComments
()
{
return
comments
;
}
public
void
setComments
(
ArrayList
<
Forum
.
Comment
>
comments
)
{
public
void
setComments
(
ArrayList
<
Comment
>
comments
)
{
this
.
comments
=
comments
;
}
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/home_view/MainActivity.java
View file @
319a52f9
...
...
@@ -4,6 +4,7 @@ import android.app.ProgressDialog;
import
android.bluetooth.BluetoothAdapter
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.AdapterView
;
...
...
@@ -178,6 +179,7 @@ public class MainActivity extends BaseActivity {
@Override
public
void
run
()
{
setTitle
(
event
.
getName
());
Log
.
d
(
TAG
,
event
.
getName
());
map
=
event
.
getApps
();
Collection
<
String
>
appnames
=
map
.
values
();
updateData
(
appnames
);
...
...
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/listfragment/CommentListAdapter.java
View file @
319a52f9
package
de.uni_oldenburg.bidl.listfragment
;
import
android.content.Context
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.TextView
;
import
classes.MyList
;
import
classes.apps.forum.Comment
;
import
classes.apps.forum.CommentList
;
import
de.uni_oldenburg.bidl.R
;
/**
* Created by Christof on 01.09.2016.
*/
public
class
CommentListAdapter
{
public
class
CommentListAdapter
extends
ListAdapter
{
private
Context
context
;
private
TextView
username
;
private
TextView
commentText
;
private
TextView
time
;
private
CommentList
commentList
;
/**
* @param context Context der Activity
* @param commentList Liste die Dargestellt werden soll
*
* */
public
CommentListAdapter
(
Context
context
,
CommentList
commentList
)
{
this
.
context
=
context
;
this
.
commentList
=
commentList
;
}
@Override
void
setList
(
MyList
list
)
{
this
.
commentList
=
(
CommentList
)
list
;
}
@Override
public
int
getCount
()
{
return
this
.
commentList
.
getCommentList
().
size
();
}
@Override
public
Object
getItem
(
int
position
)
{
return
this
.
commentList
.
getCommentList
().
get
(
position
);
}
@Override
public
long
getItemId
(
int
position
)
{
return
0
;
}
@Override
public
View
getView
(
int
position
,
View
view
,
ViewGroup
parent
)
{
//current comment
Comment
comment
=
this
.
commentList
.
getCommentList
().
get
(
position
);
LayoutInflater
inflater
=
(
LayoutInflater
)
context
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
View
item
=
inflater
.
inflate
(
R
.
layout
.
comment_item
,
parent
,
false
);
this
.
username
=
(
TextView
)
item
.
findViewById
(
R
.
id
.
commentUsername
);
this
.
username
.
setText
(
comment
.
getUsername
());
this
.
commentText
=
(
TextView
)
item
.
findViewById
(
R
.
id
.
commentText
);
this
.
commentText
.
setText
(
comment
.
getText
());
this
.
time
=
(
TextView
)
item
.
findViewById
(
R
.
id
.
commentTime
);
this
.
time
.
setText
(
comment
.
getTimestamp
());
return
item
;
}
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/listfragment/ListCommunicator.java
0 → 100644
View file @
319a52f9
package
de.uni_oldenburg.bidl.listfragment
;
import
android.widget.ListView
;
/**
* Kommunikator Interface, damit Listen-Events gefeuert werden können
* Created by Christof on 01.09.2016.
*/
public
interface
ListCommunicator
{
/**
* Wird gerufen, wenn Fragment aktualisiert wird
*/
void
updateFragList
();
/**
* Wird gerufen, wenn aus einer Liste ein Item "herausgeswipet" wird
* @param listView ListView, in denen die Items sind
* @param reverseSortedPositions Positionen der Items, die herausgeswipt worden sind
*/
void
onSwipeDismiss
(
ListView
listView
,
int
[]
reverseSortedPositions
);
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/listfragment/SuperListFragment.java
0 → 100644
View file @
319a52f9
package
de.uni_oldenburg.bidl.listfragment
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.support.v4.app.ListFragment
;
import
android.os.Bundle
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
classes.MyList
;
import
classes.apps.forum.CommentList
;
import
de.uni_oldenburg.bidl.R
;
/**
* Created by Christof on 01.09.2016.
*/
public
class
SuperListFragment
extends
ListFragment
implements
SwipeRefreshLayout
.
OnRefreshListener
{
/* TAG Kostante für das Logging */
private
static
final
String
TAG
=
SuperListFragment
.
class
.
getSimpleName
();
//Verchiedene Typen von ListFragmenten
public
static
final
String
TYPE_COMMENTLIST
=
"commentlist"
;
//Optionen
private
String
type
;
private
boolean
withSwipe
;
private
boolean
isRefreshable
;
private
SwipeRefreshLayout
swipeRefreshLayout
;
private
MyList
list
;
private
ListCommunicator
communicator
;
public
SuperListFragment
()
{
}
public
static
SuperListFragment
newInstance
(
String
type
,
MyList
list
,
boolean
withSwipe
,
boolean
isRefreshable
)
{
SuperListFragment
fragment
=
new
SuperListFragment
();
Bundle
args
=
new
Bundle
();
args
.
putString
(
"listType"
,
type
);
args
.
putSerializable
(
"list"
,
list
);
args
.
putBoolean
(
"withSwipe"
,
withSwipe
);
args
.
putBoolean
(
"isRefreshable"
,
isRefreshable
);
fragment
.
setArguments
(
args
);
return
fragment
;
}
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
if
(
getArguments
()
!=
null
){
this
.
type
=
getArguments
().
getString
(
"listType"
);
this
.
list
=
(
MyList
)
getArguments
().
getSerializable
(
"list"
);
this
.
withSwipe
=
getArguments
().
getBoolean
(
"withSwipe"
,
false
);
this
.
isRefreshable
=
getArguments
().
getBoolean
(
"isRefreshable"
,
false
);
}
super
.
onCreate
(
savedInstanceState
);
}
@Override
public
void
onViewCreated
(
View
view
,
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
if
(
withSwipe
){
//ToDo: das Löschen von Daten durch swipen realisieren.
}
swipeRefreshLayout
=
(
SwipeRefreshLayout
)
view
.
findViewById
(
R
.
id
.
swipelayout
);
if
(
isRefreshable
){
swipeRefreshLayout
.
setOnRefreshListener
(
this
);
}
else
{
swipeRefreshLayout
.
setEnabled
(
false
);
}
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_bidl_list
,
container
,
false
);
return
view
;
}
@Override
public
void
onActivityCreated
(
Bundle
savedInstanceState
)
{
if
(
savedInstanceState
!=
null
){
this
.
type
=
savedInstanceState
.
getString
(
"listType"
);
this
.
list
=
(
MyList
)
savedInstanceState
.
getSerializable
(
"list"
);
if
(
getActivity
()
instanceof
ListCommunicator
)
this
.
communicator
=
(
ListCommunicator
)
getActivity
();
}
setList
();
super
.
onActivityCreated
(
savedInstanceState
);
}
@Override
public
void
onAttach
(
Activity
activity
)
{
super
.
onAttach
(
activity
);
if
(
activity
instanceof
ListCommunicator
)
this
.
communicator
=
(
ListCommunicator
)
activity
;
}
@Override
public
void
onDetach
()
{
super
.
onDetach
();
this
.
communicator
=
null
;
}
@Override
public
void
onRefresh
()
{
communicator
.
updateFragList
();
}
/**
* Zeigt Refresh Animation an oder beendet sie
* @param show true: wird angezeigt; false: wird nicht angezeigt
*/
public
void
showRefreshAnimation
(
final
boolean
show
){
swipeRefreshLayout
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
swipeRefreshLayout
.
setRefreshing
(
show
);
}
});
//swipeRefreshLayout.setRefreshing(show);
}
/**
* setzt den richtigen Adapter
*/
private
void
setList
()
{
if
(
this
.
list
!=
null
){
switch
(
this
.
type
){
case
TYPE_COMMENTLIST:
setListAdapter
(
new
CommentListAdapter
(
getActivity
(),
(
CommentList
)
list
));
break
;
}
}
}
public
void
update
(
final
MyList
newList
){
this
.
list
=
newList
;
if
(
this
.
getListAdapter
()
!=
null
){
final
ListAdapter
adapter
=
(
ListAdapter
)
this
.
getListAdapter
();
if
(
getActivity
()
!=
null
){
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Log
.
i
(
TAG
,
"Update request received, setting new list and notifying the adapter"
);
adapter
.
setList
(
newList
);
adapter
.
notifyDataSetChanged
();
}
});
}
else
{
if
(
getActivity
()
!=
null
){
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
setList
();
}
});
}
}
}
}
}
BIDL/BIDL/app/src/main/java/de/uni_oldenburg/bidl/member_view/ForumActivity.java
View file @
319a52f9
...
...
@@ -2,31 +2,54 @@ package de.uni_oldenburg.bidl.member_view;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.widget.FrameLayout
;
import
android.widget.ListView
;
import
android.widget.Toast
;
import
java.util.ArrayList
;
import
java.util.List
;
import
classes.Event
;
import
classes.apps.forum.Comment
;
import
classes.apps.forum.CommentList
;
import
classes.apps.forum.Forum
;
import
de.uni_oldenburg.bidl.R
;
import
de.uni_oldenburg.bidl.listfragment.CommentListAdapter
;
import
de.uni_oldenburg.bidl.listfragment.ListCommunicator
;
import
de.uni_oldenburg.bidl.listfragment.SuperListFragment
;
import
services.db.DBHelper
;
import
services.servercommunication.NetworkService
;
public
class
ForumActivity
extends
AppCompatActivity
{
public
class
ForumActivity
extends
AppCompatActivity
implements
ListCommunicator
,
View
.
OnTouchListener
{
/** Tag for Logging **/
private
static
final
String
TAG
=
ForumActivity
.
class
.
getSimpleName
();
private
Forum
forum
;
private
Event
event
;
private
CommentList
comments
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_forum
);
setTitle
(
getIntent
().
getStringExtra
(
"appName"
));
Event
event
=
DBHelper
.
getEvent
();
event
=
DBHelper
.
getEvent
();
getForumObjectFromServer
(
event
.
getEventId
());
}
private
void
getForumObjectFromServer
(
int
eventId
)
{
NetworkService
.
forum
(
eventId
,
new
NetworkService
.
RequestForumHandler
()
{
@Override
...
...
@@ -36,7 +59,7 @@ public class ForumActivity extends AppCompatActivity {
ForumActivity
.
this
.
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
initGui
();
addCommentFragment
();
}
});
}
...
...
@@ -45,10 +68,14 @@ public class ForumActivity extends AppCompatActivity {
});
}
public
void
initGui
()
{
public
void
addCommentFragment
()
{
try
{
if
(
forum
.
getComments
()
!=
null
){
FrameLayout
commentContainer
=
(
FrameLayout
)
findViewById
(
R
.
id
.
commentContainer
);
commentContainer
.
removeAllViews
();
SuperListFragment
commentFragment
=
SuperListFragment
.
newInstance
(
SuperListFragment
.
TYPE_COMMENTLIST
,
new
CommentList
(
forum
.
getComments
()),
false
,
true
);
getSupportFragmentManager
().
beginTransaction
().
add
(
R
.
id
.
commentContainer
,
commentFragment
).
commit
();
}
}
catch
(
NullPointerException
e
){
e
.
printStackTrace
();
...
...
@@ -59,4 +86,45 @@ public class ForumActivity extends AppCompatActivity {
public
void
setForum
(
Forum
forum
)
{
this
.
forum
=
forum
;
}
@Override
public
void
updateFragList
()
{
final
SuperListFragment
superListFragment
=
(
SuperListFragment
)
getSupportFragmentManager
().
findFragmentById
(
R
.
id
.
commentContainer
);
NetworkService
.
forum
(
event
.
getEventId
(),
new
NetworkService
.
RequestForumHandler
()
{
@Override
public
void
done
(
Forum
forum
)
{
if
(
forum
.
getComments
()
!=
null
){
comments
=
new
CommentList
(
forum
.
getComments
());
setCommentList
(
comments
);
Log
.
d
(
TAG
,
"REFRESHING: "
+
comments
.
toString
());
superListFragment
.
update
(
comments
);
superListFragment
.
showRefreshAnimation
(
false
);
}
}
});
}
private
void
setCommentList
(
CommentList
comments
)
{
this
.
comments
=
comments
;
}
@Override
public
void
onSwipeDismiss
(
ListView
listView
,
int
[]
reverseSortedPositions
)
{
}
@Override
public
boolean
onTouch
(
View
view
,
MotionEvent
motionEvent
)
{
float
x
=
motionEvent
.
getX
();
float
y
=
motionEvent
.
getY
();
int
eventaction
=
motionEvent
.
getAction
();
switch
(
eventaction
){
case
MotionEvent
.
ACTION_DOWN
:
// updateFragList();
}
return
true
;
}
}
BIDL/BIDL/app/src/main/res/layout/activity_forum.xml
View file @
319a52f9
...
...
@@ -9,4 +9,9 @@
android:paddingTop=
"@dimen/activity_vertical_margin"
tools:context=
"de.uni_oldenburg.bidl.member_view.ForumActivity"
>
<FrameLayout
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:id=
"@+id/commentContainer"
></FrameLayout>
</RelativeLayout>
BIDL/BIDL/app/src/main/res/layout/comment_item.xml
View file @
319a52f9
...
...
@@ -7,24 +7,28 @@
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/
u
sername"
android:id=
"@+id/
commentU
sername"
android:layout_margin=
"10dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/
message
"
android:id=
"@+id/
commentText
"
android:layout_margin=
"10dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/
t
ime"
android:id=
"@+id/
commentT
ime"
android:layout_margin=
"10dp"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
BIDL/BIDL/app/src/main/res/layout/fragment_bidl_list.xml
0 → 100644
View file @
319a52f9
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/swipelayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<ListView
android:id=
"@android:id/list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</ListView>
</android.support.v4.widget.SwipeRefreshLayout>
\ No newline at end of file
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