Improve card API

This commit is contained in:
stom79 2018-11-07 18:00:00 +01:00
parent b814c6a9cf
commit 3a2f1e0d36
3 changed files with 118 additions and 23 deletions

View File

@ -303,27 +303,27 @@ public class API {
parameters.append("id[]=").append(account.getId()).append("&");
parameters = new StringBuilder(parameters.substring(0, parameters.length() - 1).substring(5));
params.put("id[]", parameters.toString());
List<Relationship> relationships = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
apiResponse.setRelationships(relationships);
}
}
List<Relationship> relationships = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
apiResponse.setRelationships(relationships);
return apiResponse;
}
@ -2448,6 +2448,41 @@ public class API {
card.setImage(resobj.get("image").toString());
card.setHtml(resobj.get("html").toString());
card.setType(resobj.get("type").toString());
try {
card.setAuthor_name(resobj.get("author_name").toString());
}catch (Exception e){
card.setAuthor_name(null);
}
try {
card.setAuthor_url(resobj.get("author_url").toString());
}catch (Exception e){
card.setAuthor_url(null);
}
try {
card.setEmbed_url(resobj.get("embed_url").toString());
}catch (Exception e){
card.setEmbed_url(null);
}
try {
card.setProvider_name(resobj.get("provider_name").toString());
}catch (Exception e){
card.setProvider_name(null);
}
try {
card.setProvider_url(resobj.get("provider_url").toString());
}catch (Exception e){
card.setProvider_url(null);
}
try {
card.setHeight(Integer.parseInt(resobj.get("height").toString()));
}catch (Exception e){
card.setHeight(0);
}
try {
card.setWidth(Integer.parseInt(resobj.get("width").toString()));
}catch (Exception e){
card.setWidth(0);
}
} catch (JSONException e) {
card = null;
}

View File

@ -30,6 +30,13 @@ public class Card{
private String image;
private String type;
private String html;
private String author_name;
private String author_url;
private String embed_url;
private String provider_name;
private String provider_url;
private int height;
private int width;
public Card(){}
@ -82,4 +89,60 @@ public class Card{
public void setHtml(String html) {
this.html = html;
}
public String getAuthor_name() {
return author_name;
}
public void setAuthor_name(String author_name) {
this.author_name = author_name;
}
public String getAuthor_url() {
return author_url;
}
public void setAuthor_url(String author_url) {
this.author_url = author_url;
}
public String getEmbed_url() {
return embed_url;
}
public void setEmbed_url(String embed_url) {
this.embed_url = embed_url;
}
public String getProvider_name() {
return provider_name;
}
public void setProvider_name(String provider_name) {
this.provider_name = provider_name;
}
public String getProvider_url() {
return provider_url;
}
public void setProvider_url(String provider_url) {
this.provider_url = provider_url;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
}

View File

@ -1273,7 +1273,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
holder.status_show_more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadAttachments(status, holder);
status.setAttachmentShown(true);
notifyStatusChanged(status);
/*
@ -1967,9 +1966,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
position++;
}
}else{
if(fullAttachement)
holder.status_horizontal_document_container.setVisibility(View.GONE);
else
holder.status_document_container.setVisibility(View.GONE);
}
holder.status_show_more.setVisibility(View.GONE);