Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify loop
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Dec 10, 2018
commit f97ed9654ff7b432d897545b64753fc14a6ee4d7
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;
Expand All @@ -40,7 +39,7 @@ public class PreviewListAdapter extends TypeAdapter<PreviewObject> {

@Override
public void write(JsonWriter out, PreviewObject value) {

// not needed
}

@Override
Expand All @@ -49,26 +48,24 @@ public PreviewObject read(JsonReader in) throws IOException {
in.beginObject();

while (in.hasNext()) {
String name = in.nextName();
if (name != null && !name.isEmpty()) {
preview = readObject(name, in);
String name = in.peek().toString();
if (!name.isEmpty()) {
preview = readObject(in);
}
}


in.endObject();

return preview;
}

private PreviewObject readObject(String tag, JsonReader in) throws IOException {
private PreviewObject readObject(JsonReader in) throws IOException {
String tag;
PreviewObject preview = new PreviewObject();

do {
if (in.peek() == JsonToken.NAME) {
tag = in.nextName();
}

tag = in.nextName();

switch (tag) {
case "source":
preview.setSource(in.nextString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public class PreviewObject {
private String mimeType;
private String view;

public PreviewObject() {
}

public String getLink() {
return link;
}
Expand Down