Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
1b4fadb0
Commit
1b4fadb0
authored
Jun 28, 2018
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse timestamps natively fornews and PT blogs
Fixes crash on Marshmallow
parent
bd38c2aa
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
55 deletions
+50
-55
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/NewsAdapter.java
...java/in/ac/iitb/gymkhana/iitbapp/adapter/NewsAdapter.java
+11
-14
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/PlacementBlogAdapter.java
...c/iitb/gymkhana/iitbapp/adapter/PlacementBlogAdapter.java
+11
-14
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/TrainingBlogAdapter.java
...ac/iitb/gymkhana/iitbapp/adapter/TrainingBlogAdapter.java
+11
-14
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/NewsArticle.java
...in/java/in/ac/iitb/gymkhana/iitbapp/data/NewsArticle.java
+5
-5
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/PlacementBlogPost.java
...a/in/ac/iitb/gymkhana/iitbapp/data/PlacementBlogPost.java
+6
-4
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/TrainingBlogPost.java
...va/in/ac/iitb/gymkhana/iitbapp/data/TrainingBlogPost.java
+6
-4
No files found.
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/NewsAdapter.java
View file @
1b4fadb0
...
@@ -54,9 +54,8 @@ public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
...
@@ -54,9 +54,8 @@ public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
NewsArticle
article
=
newsArticles
.
get
(
position
);
NewsArticle
article
=
newsArticles
.
get
(
position
);
Markwon
.
setMarkdown
(
holder
.
articleTitle
,
article
.
getTitle
());
Markwon
.
setMarkdown
(
holder
.
articleTitle
,
article
.
getTitle
());
holder
.
articleBody
.
setText
(
article
.
getBody
().
getBodyName
());
holder
.
articleBody
.
setText
(
article
.
getBody
().
getBodyName
());
try
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssXXX"
,
Locale
.
US
);
Date
publishedDate
=
article
.
getPublished
();
Date
publishedDate
=
dateFormat
.
parse
(
article
.
getPublished
());
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
publishedDate
);
calendar
.
setTime
(
publishedDate
);
DateFormat
displayFormat
;
DateFormat
displayFormat
;
...
@@ -66,9 +65,7 @@ public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
...
@@ -66,9 +65,7 @@ public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> {
displayFormat
=
new
SimpleDateFormat
(
"EEE, MMM d, ''yy, HH:mm"
,
Locale
.
US
);
displayFormat
=
new
SimpleDateFormat
(
"EEE, MMM d, ''yy, HH:mm"
,
Locale
.
US
);
}
}
holder
.
articlePublished
.
setText
(
displayFormat
.
format
(
publishedDate
));
holder
.
articlePublished
.
setText
(
displayFormat
.
format
(
publishedDate
));
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
Markwon
.
setMarkdown
(
holder
.
articleContent
,
article
.
getContent
());
Markwon
.
setMarkdown
(
holder
.
articleContent
,
article
.
getContent
());
}
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/PlacementBlogAdapter.java
View file @
1b4fadb0
...
@@ -51,9 +51,8 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<PlacementBlogAdap
...
@@ -51,9 +51,8 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<PlacementBlogAdap
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
PlacementBlogPost
post
=
posts
.
get
(
position
);
PlacementBlogPost
post
=
posts
.
get
(
position
);
Markwon
.
setMarkdown
(
holder
.
postTitle
,
post
.
getTitle
());
Markwon
.
setMarkdown
(
holder
.
postTitle
,
post
.
getTitle
());
try
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssXXX"
,
Locale
.
US
);
Date
publishedDate
=
post
.
getPublished
();
Date
publishedDate
=
dateFormat
.
parse
(
post
.
getPublished
());
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
publishedDate
);
calendar
.
setTime
(
publishedDate
);
DateFormat
displayFormat
;
DateFormat
displayFormat
;
...
@@ -63,9 +62,7 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<PlacementBlogAdap
...
@@ -63,9 +62,7 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<PlacementBlogAdap
displayFormat
=
new
SimpleDateFormat
(
"EEE, MMM d, ''yy, HH:mm"
,
Locale
.
US
);
displayFormat
=
new
SimpleDateFormat
(
"EEE, MMM d, ''yy, HH:mm"
,
Locale
.
US
);
}
}
holder
.
postPublished
.
setText
(
displayFormat
.
format
(
publishedDate
));
holder
.
postPublished
.
setText
(
displayFormat
.
format
(
publishedDate
));
}
catch
(
ParseException
e
)
{
holder
.
postPublished
.
setText
(
post
.
getPublished
());
}
Markwon
.
setMarkdown
(
holder
.
postContent
,
post
.
getContent
());
Markwon
.
setMarkdown
(
holder
.
postContent
,
post
.
getContent
());
}
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/adapter/TrainingBlogAdapter.java
View file @
1b4fadb0
...
@@ -51,9 +51,8 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<TrainingBlogAdapte
...
@@ -51,9 +51,8 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<TrainingBlogAdapte
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
ViewHolder
holder
,
int
position
)
{
TrainingBlogPost
post
=
posts
.
get
(
position
);
TrainingBlogPost
post
=
posts
.
get
(
position
);
Markwon
.
setMarkdown
(
holder
.
postTitle
,
post
.
getTitle
());
Markwon
.
setMarkdown
(
holder
.
postTitle
,
post
.
getTitle
());
try
{
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ssXXX"
,
Locale
.
US
);
Date
publishedDate
=
post
.
getPublished
();
Date
publishedDate
=
dateFormat
.
parse
(
post
.
getPublished
());
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
publishedDate
);
calendar
.
setTime
(
publishedDate
);
DateFormat
displayFormat
;
DateFormat
displayFormat
;
...
@@ -63,9 +62,7 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<TrainingBlogAdapte
...
@@ -63,9 +62,7 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<TrainingBlogAdapte
displayFormat
=
new
SimpleDateFormat
(
"EEE, MMM d, ''yy, HH:mm"
,
Locale
.
US
);
displayFormat
=
new
SimpleDateFormat
(
"EEE, MMM d, ''yy, HH:mm"
,
Locale
.
US
);
}
}
holder
.
postPublished
.
setText
(
displayFormat
.
format
(
publishedDate
));
holder
.
postPublished
.
setText
(
displayFormat
.
format
(
publishedDate
));
}
catch
(
ParseException
e
)
{
holder
.
postPublished
.
setText
(
post
.
getPublished
());
}
Markwon
.
setMarkdown
(
holder
.
postContent
,
post
.
getContent
());
Markwon
.
setMarkdown
(
holder
.
postContent
,
post
.
getContent
());
}
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/NewsArticle.java
View file @
1b4fadb0
...
@@ -6,7 +6,7 @@ import android.arch.persistence.room.PrimaryKey;
...
@@ -6,7 +6,7 @@ import android.arch.persistence.room.PrimaryKey;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.
util.Ma
p
;
import
java.
sql.Timestam
p
;
@Entity
(
tableName
=
"news"
)
@Entity
(
tableName
=
"news"
)
...
@@ -33,13 +33,13 @@ public class NewsArticle {
...
@@ -33,13 +33,13 @@ public class NewsArticle {
@ColumnInfo
(
name
=
"published"
)
@ColumnInfo
(
name
=
"published"
)
@SerializedName
(
"published"
)
@SerializedName
(
"published"
)
private
String
published
;
private
Timestamp
published
;
@ColumnInfo
(
name
=
"body"
)
@ColumnInfo
(
name
=
"body"
)
@SerializedName
(
"body"
)
@SerializedName
(
"body"
)
private
Body
body
;
private
Body
body
;
public
NewsArticle
(
String
articleID
,
String
link
,
String
title
,
String
content
,
String
published
,
Body
body
)
{
public
NewsArticle
(
String
articleID
,
String
link
,
String
title
,
String
content
,
Timestamp
published
,
Body
body
)
{
this
.
articleID
=
articleID
;
this
.
articleID
=
articleID
;
this
.
link
=
link
;
this
.
link
=
link
;
this
.
title
=
title
;
this
.
title
=
title
;
...
@@ -80,11 +80,11 @@ public class NewsArticle {
...
@@ -80,11 +80,11 @@ public class NewsArticle {
this
.
content
=
content
;
this
.
content
=
content
;
}
}
public
String
getPublished
()
{
public
Timestamp
getPublished
()
{
return
published
;
return
published
;
}
}
public
void
setPublished
(
String
published
)
{
public
void
setPublished
(
Timestamp
published
)
{
this
.
published
=
published
;
this
.
published
=
published
;
}
}
...
...
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/PlacementBlogPost.java
View file @
1b4fadb0
...
@@ -6,6 +6,8 @@ import android.arch.persistence.room.PrimaryKey;
...
@@ -6,6 +6,8 @@ import android.arch.persistence.room.PrimaryKey;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.sql.Timestamp
;
@Entity
(
tableName
=
"placementBlogPosts"
)
@Entity
(
tableName
=
"placementBlogPosts"
)
public
class
PlacementBlogPost
{
public
class
PlacementBlogPost
{
...
@@ -31,9 +33,9 @@ public class PlacementBlogPost {
...
@@ -31,9 +33,9 @@ public class PlacementBlogPost {
@ColumnInfo
(
name
=
"published"
)
@ColumnInfo
(
name
=
"published"
)
@SerializedName
(
"published"
)
@SerializedName
(
"published"
)
private
String
published
;
private
Timestamp
published
;
public
PlacementBlogPost
(
String
postID
,
String
link
,
String
title
,
String
content
,
String
published
)
{
public
PlacementBlogPost
(
String
postID
,
String
link
,
String
title
,
String
content
,
Timestamp
published
)
{
this
.
postID
=
postID
;
this
.
postID
=
postID
;
this
.
link
=
link
;
this
.
link
=
link
;
this
.
title
=
title
;
this
.
title
=
title
;
...
@@ -73,11 +75,11 @@ public class PlacementBlogPost {
...
@@ -73,11 +75,11 @@ public class PlacementBlogPost {
this
.
content
=
content
;
this
.
content
=
content
;
}
}
public
String
getPublished
()
{
public
Timestamp
getPublished
()
{
return
published
;
return
published
;
}
}
public
void
setPublished
(
String
published
)
{
public
void
setPublished
(
Timestamp
published
)
{
this
.
published
=
published
;
this
.
published
=
published
;
}
}
}
}
app/src/main/java/in/ac/iitb/gymkhana/iitbapp/data/TrainingBlogPost.java
View file @
1b4fadb0
...
@@ -6,6 +6,8 @@ import android.arch.persistence.room.PrimaryKey;
...
@@ -6,6 +6,8 @@ import android.arch.persistence.room.PrimaryKey;
import
com.google.gson.annotations.SerializedName
;
import
com.google.gson.annotations.SerializedName
;
import
java.sql.Timestamp
;
@Entity
(
tableName
=
"trainingBlogPosts"
)
@Entity
(
tableName
=
"trainingBlogPosts"
)
public
class
TrainingBlogPost
{
public
class
TrainingBlogPost
{
...
@@ -31,9 +33,9 @@ public class TrainingBlogPost {
...
@@ -31,9 +33,9 @@ public class TrainingBlogPost {
@ColumnInfo
(
name
=
"published"
)
@ColumnInfo
(
name
=
"published"
)
@SerializedName
(
"published"
)
@SerializedName
(
"published"
)
private
String
published
;
private
Timestamp
published
;
public
TrainingBlogPost
(
String
postID
,
String
link
,
String
title
,
String
content
,
String
published
)
{
public
TrainingBlogPost
(
String
postID
,
String
link
,
String
title
,
String
content
,
Timestamp
published
)
{
this
.
postID
=
postID
;
this
.
postID
=
postID
;
this
.
link
=
link
;
this
.
link
=
link
;
this
.
title
=
title
;
this
.
title
=
title
;
...
@@ -73,11 +75,11 @@ public class TrainingBlogPost {
...
@@ -73,11 +75,11 @@ public class TrainingBlogPost {
this
.
content
=
content
;
this
.
content
=
content
;
}
}
public
String
getPublished
()
{
public
Timestamp
getPublished
()
{
return
published
;
return
published
;
}
}
public
void
setPublished
(
String
published
)
{
public
void
setPublished
(
Timestamp
published
)
{
this
.
published
=
published
;
this
.
published
=
published
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment