Commit c4e93cac authored by Christof Wolke's avatar Christof Wolke

CommentListadapter + View

parent e6b9f79e
......@@ -5,6 +5,7 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import co.uk.rushorm.core.RushObject;
......@@ -22,12 +23,12 @@ public class Event extends RushObject implements Serializable {
private String name;
@JsonField(name = "apps")
private ArrayList<String> apps;
private HashMap<String, String> apps;
public Event() {
}
public Event(int eventId, String name, ArrayList<String> apps) {
public Event(int eventId, String name, HashMap<String, String> apps) {
this.eventId = eventId;
this.name = name;
this.apps = apps;
......@@ -50,11 +51,11 @@ public class Event extends RushObject implements Serializable {
this.name = name;
}
public ArrayList<String> getApps() {
public HashMap<String, String> getApps() {
return apps;
}
public void setApps(ArrayList<String> apps) {
public void setApps(HashMap<String,String> apps) {
this.apps = apps;
}
......
package classes;
import java.io.Serializable;
/**
* Superklasse für alle Listen Objekte
* Created by Christof on 01.09.2016.
*/
public class MyList implements Serializable {
}
......@@ -5,6 +5,9 @@ import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.io.Serializable;
import classes.apps.feedback.Feedback;
import classes.apps.forum.Forum;
import classes.apps.materials.Materials;
import co.uk.rushorm.core.RushObject;
/**
......
package classes.apps;
package classes.apps.feedback;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
......
package classes.apps;
package classes.apps.forum;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.io.Serializable;
import java.util.Date;
import co.uk.rushorm.core.RushObject;
import co.uk.rushorm.core.annotations.RushList;
/**
* Created by Christof on 23.08.2016.
......
package classes.apps.forum;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import java.io.Serializable;
import java.util.ArrayList;
import classes.MyList;
/**
*
* Created by Christof on 01.09.2016.
*/
@JsonObject
public class CommentList extends MyList implements Serializable {
@JsonField
private ArrayList<Comment> commentList;
public CommentList(){
}
public CommentList(ArrayList<Comment> commentList) {
this.commentList = commentList;
}
public ArrayList<Comment> getCommentList() {
return commentList;
}
public void setCommentList(ArrayList<Comment> commentList) {
this.commentList = commentList;
}
@Override
public String toString() {
return "CommentList{" +
"commentList=" + commentList +
'}';
}
}
package classes.apps;
package classes.apps.forum;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
......@@ -18,14 +18,15 @@ public class Forum extends RushObject implements Serializable {
@JsonField(name = "id")
private int forumId;
@RushList(classType = Forum.Comment.class)
@JsonField(name = "comments")
private ArrayList<Comment>comments;
private ArrayList<Forum.Comment>comments;
public Forum(){
}
public Forum(int id, ArrayList<Comment> comments) {
public Forum(int id, ArrayList<Forum.Comment> comments) {
this.forumId = id;
this.comments = comments;
}
......@@ -38,11 +39,11 @@ public class Forum extends RushObject implements Serializable {
this.forumId = forumId;
}
public ArrayList<Comment> getComments() {
public ArrayList<Forum.Comment> getComments() {
return comments;
}
public void setComments(ArrayList<Comment> comments) {
public void setComments(ArrayList<Forum.Comment> comments) {
this.comments = comments;
}
......
package classes.apps;
package classes.apps.materials;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
......
......@@ -26,7 +26,7 @@ public class BaseActivity extends AppCompatActivity implements NavigationView.On
protected void setMenu() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
......
......@@ -18,7 +18,10 @@ import com.estimote.sdk.Region;
import com.estimote.sdk.SystemRequirementsChecker;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import classes.Event;
......@@ -54,6 +57,7 @@ public class MainActivity extends BaseActivity {
private ArrayList<String> apps = new ArrayList<>();
private ArrayAdapter<String> adapter;
private Event event;
private HashMap<String, String> map;
......@@ -103,10 +107,12 @@ public class MainActivity extends BaseActivity {
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
String appName = (String) adapterView.getItemAtPosition(position);
Class<?> c = null;
String app = getClassnameFromHashmap(appName);
Class<?> c = null;
try {
c = Class.forName(appPackage+appName+"Activity");
c = Class.forName(appPackage+app+"Activity");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
......@@ -115,6 +121,17 @@ public class MainActivity extends BaseActivity {
}
private String getClassnameFromHashmap(String appName) {
for(Map.Entry<String,String> entry : map.entrySet()){
String key = entry.getKey();
String value = entry.getValue();
if (value.equals(appName)){
return key;
}
}
return null;
}
});
}
......@@ -161,7 +178,9 @@ public class MainActivity extends BaseActivity {
@Override
public void run() {
setTitle(event.getName());
updateData(event.getApps());
map = event.getApps();
Collection<String> appnames = map.values();
updateData(appnames);
setEvent(event);
}
});
......@@ -176,7 +195,7 @@ public class MainActivity extends BaseActivity {
}
private void updateData(ArrayList<String> apps) {
private void updateData(Collection<String> apps) {
progress.dismiss();
adapter.clear();
if (apps != null){
......
package de.uni_oldenburg.bidl.listfragment;
/**
* Created by Christof on 01.09.2016.
*/
public class CommentListAdapter {
}
package de.uni_oldenburg.bidl.listfragment;
import android.widget.BaseAdapter;
import classes.MyList;
/**
* Created by Christof on 01.09.2016.
*/
public abstract class ListAdapter extends BaseAdapter {
abstract void setList(MyList list);
}
......@@ -2,18 +2,15 @@ package de.uni_oldenburg.bidl.member_view;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import classes.Event;
import classes.apps.Comment;
import classes.apps.Forum;
import classes.apps.forum.Forum;
import de.uni_oldenburg.bidl.R;
import de.uni_oldenburg.bidl.home_view.MainActivity;
import services.db.DBHelper;
import services.servercommunication.NetworkService;
public class ForumActivity extends AppCompatActivity {
public class ForumActivity extends AppCompatActivity {
/** Tag for Logging **/
private static final String TAG = ForumActivity.class.getSimpleName();
......@@ -27,22 +24,38 @@ public class ForumActivity extends AppCompatActivity {
setTitle(getIntent().getStringExtra("appName"));
Event event = DBHelper.getEvent();
getForumObjectFromServer(event.getEventId());
}
private void getForumObjectFromServer(int eventId) {
NetworkService.forum(eventId, new NetworkService.RequestForumHandler() {
@Override
public void done(final Forum forum) {
setForum(forum);
Comment comment = forum.getComments().get(0);
Log.d(TAG, "FORUMACTIVITY: "+comment.getText());
public void done(Forum forum) {
if (forum != null){
setForum(forum);
ForumActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
initGui();
}
});
}
}
});
}
public void initGui() {
try {
if (forum.getComments() != null){
}
}catch (NullPointerException e){
e.printStackTrace();
}
}
public void setForum(Forum forum) {
this.forum = forum;
}
......
package services.servercommunication;
import android.util.Log;
import com.bluelinelabs.logansquare.LoganSquare;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.Callback;
......@@ -12,15 +10,12 @@ import com.squareup.okhttp.RequestBody;
import com.squareup.okhttp.Response;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import classes.Event;
import classes.StatusResponse;
import classes.User;
import classes.apps.Comment;
import classes.apps.Forum;
import classes.apps.forum.Forum;
/**
* Helfer Klasse, die häufig verwendete I/O Operationen im Netzwerk und der Datenbank erleichtert
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/username"
android:layout_margin="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/message"
android:layout_margin="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/time"
android:layout_margin="10dp"/>
</ScrollView>
</LinearLayout>
\ No newline at end of file
......@@ -33,7 +33,7 @@
android:stretchMode="columnWidth"
android:id="@+id/mainActivityGrid"
android:numColumns="2"
android:focusable="true"/>
android:focusable="true" />
......
......@@ -14,6 +14,7 @@
android:layout_margin="10dp"
android:padding="20dp"
android:elevation="2dp"
android:singleLine="false"/>
android:singleLine="false"
android:minLines="3"/>
</LinearLayout>
\ No newline at end of file
......@@ -8,23 +8,6 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">@color/black_overlay</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment