-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use okhttp to retrive JSON data - Use gson to parse JSON into usable objects - Modify ListActivity to use feed data rather than static list of string
- Loading branch information
Showing
7 changed files
with
200 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/src/main/java/org/novinger/jason/demoreader/datamodels/Article.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.novinger.jason.demoreader.datamodels; | ||
|
||
/** | ||
* Created by jason on 4/27/16. | ||
*/ | ||
public class Article { | ||
private String id; | ||
private int realId; | ||
private String headline; | ||
private String slug; | ||
private Author[] authors; | ||
private String summary; | ||
private String url; | ||
|
||
public Article() {} | ||
|
||
public Article(String id, String headline, String slug, Author[] authors, String url, String summary) { | ||
this.id = id; | ||
this.realId = mungeId(id); | ||
this.headline = headline; | ||
this.slug = slug; | ||
this.authors = authors; | ||
this.url = url; | ||
this.summary = summary; | ||
} | ||
|
||
private int mungeId(String id) { | ||
String[] parts = id.split("."); | ||
return Integer.parseInt(parts[2]); | ||
} | ||
|
||
public String toString() { | ||
return getHeadline() + " — " + getPrimaryAuthor().getName(); | ||
} | ||
|
||
public int getId() { | ||
return realId; | ||
} | ||
|
||
public String getHeadline() { | ||
return headline; | ||
} | ||
|
||
public String getSlug() { | ||
return slug; | ||
} | ||
|
||
public Author[] getAuthors() { | ||
return authors; | ||
} | ||
|
||
public Author getPrimaryAuthor() { | ||
if (authors.length > 0) { | ||
return authors[0]; | ||
} | ||
|
||
return new Author(); | ||
} | ||
|
||
public String getSummary() { | ||
return summary; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/org/novinger/jason/demoreader/datamodels/ArticleFeed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.novinger.jason.demoreader.datamodels; | ||
|
||
/** | ||
* Created by jason on 4/27/16. | ||
*/ | ||
public class ArticleFeed { | ||
private int count; | ||
private String next; | ||
private String previous; | ||
private Article[] results; | ||
|
||
public ArticleFeed() {} | ||
|
||
public ArticleFeed(int count, String next, String previous, Article[] results) { | ||
this.count = count; | ||
this.next = next; | ||
this.previous = previous; | ||
this.results = results; | ||
} | ||
|
||
public Article[] getResults() { | ||
return results; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/org/novinger/jason/demoreader/datamodels/Author.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.novinger.jason.demoreader.datamodels; | ||
|
||
/** | ||
* Created by jason on 4/27/16. | ||
*/ | ||
public class Author { | ||
private String name; | ||
private String url; | ||
private String slug; | ||
|
||
public Author() {} | ||
|
||
public Author(String name, String url, String slug) { | ||
this.name = name; | ||
this.url = url; | ||
this.slug = slug; | ||
} | ||
|
||
public String toString() { | ||
return name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getSlug() { | ||
return slug; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/novinger/jason/demoreader/datamodels/Headline.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.novinger.jason.demoreader.datamodels; | ||
|
||
/** | ||
* Created by jason on 4/27/16. | ||
*/ | ||
public class Headline { | ||
private Boolean headline; | ||
private Boolean title; | ||
private Boolean social; | ||
private String text; | ||
|
||
public Headline() {} | ||
} |