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
Show 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;
...
@@ -9,6 +9,7 @@ import android.widget.TextView;
import
com.vsoft.uoflservicenow.R
;
import
com.vsoft.uoflservicenow.R
;
import
com.vsoft.uoflservicenow.db.models.Incident
;
import
com.vsoft.uoflservicenow.db.models.Incident
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -68,7 +69,7 @@ public class MyIncidentsAdapter extends BaseAdapter {
...
@@ -68,7 +69,7 @@ public class MyIncidentsAdapter extends BaseAdapter {
Incident
incident
=
mIncidentList
.
get
(
position
);
Incident
incident
=
mIncidentList
.
get
(
position
);
holder
.
numberTextView
.
setText
(
incident
.
getNumber
());
holder
.
numberTextView
.
setText
(
incident
.
getNumber
());
holder
.
dateTextView
.
setText
(
incident
.
getOpenedAt
(
));
holder
.
dateTextView
.
setText
(
Util
.
getDateTimeFromLong
(
incident
.
getOpenedAt
()
));
holder
.
shortDesTextView
.
setText
(
incident
.
getShortDescription
());
holder
.
shortDesTextView
.
setText
(
incident
.
getShortDescription
());
return
convertView
;
return
convertView
;
...
...
app/src/main/java/com/vsoft/uoflservicenow/db/models/Incident.java
View file @
0e9da290
...
@@ -21,7 +21,7 @@ public class Incident {
...
@@ -21,7 +21,7 @@ public class Incident {
private
String
shortDescription
;
private
String
shortDescription
;
@SerializedName
(
"opened_at"
)
@SerializedName
(
"opened_at"
)
// @Expose
// @Expose
private
Stri
ng
openedAt
;
private
lo
ng
openedAt
;
@SerializedName
(
"impact"
)
@SerializedName
(
"impact"
)
// @Expose
// @Expose
private
Impact
impact
;
private
Impact
impact
;
...
@@ -34,11 +34,11 @@ public class Incident {
...
@@ -34,11 +34,11 @@ public class Incident {
this
.
impact
=
impact
;
this
.
impact
=
impact
;
}
}
public
Stri
ng
getOpenedAt
()
{
public
lo
ng
getOpenedAt
()
{
return
openedAt
;
return
openedAt
;
}
}
public
void
setOpenedAt
(
Stri
ng
openedAt
)
{
public
void
setOpenedAt
(
lo
ng
openedAt
)
{
this
.
openedAt
=
openedAt
;
this
.
openedAt
=
openedAt
;
}
}
...
@@ -68,7 +68,7 @@ public class Incident {
...
@@ -68,7 +68,7 @@ public class Incident {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
this
.
setOpenedAt
(
Util
.
getDateTime
(
openedAt
));
this
.
setOpenedAt
(
Util
.
getDateTime
ForMyIncidentFromString
(
openedAt
));
this
.
setImpact
(
Impact
.
from
(
impact
));
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;
...
@@ -22,6 +22,8 @@ import com.vsoft.uoflservicenow.enums.SyncStatus;
import
com.vsoft.uoflservicenow.utils.CatalogueLog
;
import
com.vsoft.uoflservicenow.utils.CatalogueLog
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.BindView
;
...
@@ -134,10 +136,19 @@ public class MyIncidentScreen extends AppCompatActivity {
...
@@ -134,10 +136,19 @@ public class MyIncidentScreen extends AppCompatActivity {
private
void
setData
(
final
List
<
Incident
>
catalogueList
)
{
private
void
setData
(
final
List
<
Incident
>
catalogueList
)
{
MyIncidentsAdapter
adapter
=
new
MyIncidentsAdapter
(
MyIncidentScreen
.
this
);
MyIncidentsAdapter
adapter
=
new
MyIncidentsAdapter
(
MyIncidentScreen
.
this
);
Collections
.
sort
(
catalogueList
,
new
StringDateComparator
());
adapter
.
setIncidentList
(
catalogueList
);
adapter
.
setIncidentList
(
catalogueList
);
mListView
.
setAdapter
(
adapter
);
mListView
.
setAdapter
(
adapter
);
}
}
class
StringDateComparator
implements
Comparator
<
Incident
>
{
public
int
compare
(
Incident
lhs
,
Incident
rhs
)
{
return
lhs
.
getOpenedAt
()>
rhs
.
getOpenedAt
()
?
-
1
:
1
;
}
}
@Override
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
menuItem
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
menuItem
)
{
if
(
menuItem
.
getItemId
()
==
android
.
R
.
id
.
home
)
{
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 {
...
@@ -271,7 +271,7 @@ public class Util {
return
dateFormat
.
format
(
timeStamp
);
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
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
US
);
Date
date
=
null
;
Date
date
=
null
;
try
{
try
{
...
@@ -279,10 +279,7 @@ public class Util {
...
@@ -279,10 +279,7 @@ public class Util {
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
date
.
getTime
();
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"dd MMM, yyyy HH:mm"
,
Locale
.
US
);
return
dateFormat
.
format
(
date
.
getTime
());
}
}
/*Record a screen view hit for the visible*/
/*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