Fixes issue #134 - Prepares entity for lists
This commit is contained in:
parent
37e83f8c64
commit
503a643179
|
@ -1398,6 +1398,44 @@ public class API {
|
|||
return emojis;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse Lists
|
||||
* @param jsonArray JSONArray
|
||||
* @return List<List> of lists
|
||||
*/
|
||||
private List<fr.gouv.etalab.mastodon.client.Entities.List> parseLists(JSONArray jsonArray){
|
||||
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
|
||||
try {
|
||||
int i = 0;
|
||||
while (i < jsonArray.length() ) {
|
||||
JSONObject resobj = jsonArray.getJSONObject(i);
|
||||
fr.gouv.etalab.mastodon.client.Entities.List list = parseList(resobj);
|
||||
lists.add(list);
|
||||
i++;
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
setDefaultError();
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response for emoji
|
||||
* @param resobj JSONObject
|
||||
* @return Emojis
|
||||
*/
|
||||
private static fr.gouv.etalab.mastodon.client.Entities.List parseList(JSONObject resobj){
|
||||
fr.gouv.etalab.mastodon.client.Entities.List list = new fr.gouv.etalab.mastodon.client.Entities.List();
|
||||
try {
|
||||
list.setId(resobj.get("id").toString());
|
||||
list.setTitle(resobj.get("title").toString());
|
||||
}catch (Exception ignored){}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse json response an unique account
|
||||
* @param resobj JSONObject
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* Copyright 2017 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.client.Entities;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 13/12/2017.
|
||||
* Manage List
|
||||
*/
|
||||
|
||||
public class List implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String title;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue