URLs bei Ankündigunen werden jetzt angezeigt

This commit is contained in:
Joshua
2018-08-02 15:02:52 +02:00
parent 4f24e74e18
commit 0c5e6d5f57
3 changed files with 30 additions and 4 deletions

View File

@@ -5,6 +5,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import java.util.ArrayList;
import de.sebse.fuplanner.R;
import de.sebse.fuplanner.services.KVV.types.Announcement;
import de.sebse.fuplanner.services.KVV.types.Modules;
@@ -18,7 +20,12 @@ class ModDetailAnnounceAdapter extends BaseExpandableListAdapter {
@Override
public String getChild(int groupPosition, int childPosititon) {
return this.getGroup(groupPosition).getBody();
String s= this.getGroup(groupPosition).getBody();
ArrayList<String> urls = this.getGroup(groupPosition).getUrls();
for (int j =0; j<urls.size(); j++){
s += urls.get(j);
}
return s;
}
@Override

View File

@@ -225,8 +225,19 @@ class KVVModuleList extends HTTPService {
text = new Source(text).getRenderer().toString();
String createdBy = site.getString("createdByDisplayName");
long createdOn = site.getLong("createdOn");
announcements.add(new Announcement(id, title, text, createdBy, createdOn));
//PDFs links rausziehen
JSONArray attachments = site.getJSONArray("attachments");
ArrayList<String> urls = new ArrayList<>();
for (int j =0; j<attachments.length(); j++){
urls.add(attachments.getJSONObject(j).optString("url",null));
}
announcements.add(new Announcement(id, title, text, createdBy, createdOn, urls));
}
} catch (JSONException e) {
e.printStackTrace();
errorCallback.onError(new NetworkError(101202, 403, "Cannot parse announcements!"));

View File

@@ -1,6 +1,7 @@
package de.sebse.fuplanner.services.KVV.types;
import java.io.Serializable;
import java.util.ArrayList;
public class Announcement implements Serializable {
private final String id;
@@ -8,14 +9,20 @@ public class Announcement implements Serializable {
private final String body;
private final String createdBy;
private final long createdOn;
private final ArrayList<String> urls;
public Announcement(String id, String title, String body, String createdBy, long createdOn) {
public Announcement(String id, String title, String body, String createdBy, long createdOn, ArrayList<String> urls) {
this.id = id;
this.title = title;
this.body = body;
this.createdBy = createdBy;
this.createdOn = createdOn;
this.urls = urls;
}
public ArrayList<String> getUrls() {
return urls;
}
public String getId() {
@@ -44,6 +51,7 @@ public class Announcement implements Serializable {
"\nTitle: "+getTitle()+
"\nBody length: "+getBody().length()+
"\nCreated by: "+getCreatedBy()+
"\nCreated on: "+getCreatedOn();
"\nCreated on: "+getCreatedOn()+
"\nURLs: "+getUrls().toString();
}
}