Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0e9da290
authored
Sep 02, 2016
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix - In My Incidents screen, record shuold be sorted according to date.
parent
f3c9603d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
app/src/main/java/com/vsoft/uoflservicenow/adapters/MyIncidentsAdapter.java
app/src/main/java/com/vsoft/uoflservicenow/db/models/Incident.java
app/src/main/java/com/vsoft/uoflservicenow/ui/MyIncidentScreen.java
app/src/main/java/com/vsoft/uoflservicenow/utils/Util.java
app/src/main/java/com/vsoft/uoflservicenow/adapters/MyIncidentsAdapter.java
View file @
0e9da290
...
...
@@ -9,6 +9,7 @@ import android.widget.TextView;
import
com.vsoft.uoflservicenow.R
;
import
com.vsoft.uoflservicenow.db.models.Incident
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -68,7 +69,7 @@ public class MyIncidentsAdapter extends BaseAdapter {
Incident
incident
=
mIncidentList
.
get
(
position
);
holder
.
numberTextView
.
setText
(
incident
.
getNumber
());
holder
.
dateTextView
.
setText
(
incident
.
getOpenedAt
(
));
holder
.
dateTextView
.
setText
(
Util
.
getDateTimeFromLong
(
incident
.
getOpenedAt
()
));
holder
.
shortDesTextView
.
setText
(
incident
.
getShortDescription
());
return
convertView
;
...
...
app/src/main/java/com/vsoft/uoflservicenow/db/models/Incident.java
View file @
0e9da290
...
...
@@ -21,7 +21,7 @@ public class Incident {
private
String
shortDescription
;
@SerializedName
(
"opened_at"
)
// @Expose
private
Stri
ng
openedAt
;
private
lo
ng
openedAt
;
@SerializedName
(
"impact"
)
// @Expose
private
Impact
impact
;
...
...
@@ -34,11 +34,11 @@ public class Incident {
this
.
impact
=
impact
;
}
public
Stri
ng
getOpenedAt
()
{
public
lo
ng
getOpenedAt
()
{
return
openedAt
;
}
public
void
setOpenedAt
(
Stri
ng
openedAt
)
{
public
void
setOpenedAt
(
lo
ng
openedAt
)
{
this
.
openedAt
=
openedAt
;
}
...
...
@@ -68,7 +68,7 @@ public class Incident {
e
.
printStackTrace
();
}
this
.
setOpenedAt
(
Util
.
getDateTime
(
openedAt
));
this
.
setOpenedAt
(
Util
.
getDateTime
ForMyIncidentFromString
(
openedAt
));
this
.
setImpact
(
Impact
.
from
(
impact
));
}
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/MyIncidentScreen.java
View file @
0e9da290
...
...
@@ -22,6 +22,8 @@ import com.vsoft.uoflservicenow.enums.SyncStatus;
import
com.vsoft.uoflservicenow.utils.CatalogueLog
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
butterknife.BindView
;
...
...
@@ -134,10 +136,19 @@ public class MyIncidentScreen extends AppCompatActivity {
private
void
setData
(
final
List
<
Incident
>
catalogueList
)
{
MyIncidentsAdapter
adapter
=
new
MyIncidentsAdapter
(
MyIncidentScreen
.
this
);
Collections
.
sort
(
catalogueList
,
new
StringDateComparator
());
adapter
.
setIncidentList
(
catalogueList
);
mListView
.
setAdapter
(
adapter
);
}
class
StringDateComparator
implements
Comparator
<
Incident
>
{
public
int
compare
(
Incident
lhs
,
Incident
rhs
)
{
return
lhs
.
getOpenedAt
()>
rhs
.
getOpenedAt
()
?
-
1
:
1
;
}
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
menuItem
)
{
if
(
menuItem
.
getItemId
()
==
android
.
R
.
id
.
home
)
{
...
...
app/src/main/java/com/vsoft/uoflservicenow/utils/Util.java
View file @
0e9da290
...
...
@@ -271,7 +271,7 @@ public class Util {
return
dateFormat
.
format
(
timeStamp
);
}
public
static
String
getDateTime
(
String
strDate
)
{
public
static
long
getDateTimeForMyIncidentFromString
(
String
strDate
)
{
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
US
);
Date
date
=
null
;
try
{
...
...
@@ -279,10 +279,7 @@ public class Util {
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd MMM, yyyy HH:mm"
,
Locale
.
US
);
return
dateFormat
.
format
(
date
.
getTime
());
return
date
.
getTime
();
}
/*Record a screen view hit for the visible*/
...
...
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