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
f7dddf57
authored
Sep 12, 2016
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
UOFLMA-33: Fix - List items should be sorted according to date.
parent
0a0f9fb7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
31 deletions
app/src/main/java/com/vsoft/uoflservicenow/adapters/MyRequestAdapter.java
app/src/main/java/com/vsoft/uoflservicenow/api/managers/MyRequestApiManager.java
app/src/main/java/com/vsoft/uoflservicenow/db/models/MyRequest.java
app/src/main/java/com/vsoft/uoflservicenow/ui/MyRequestActivity.java
app/src/main/java/com/vsoft/uoflservicenow/utils/Util.java
app/src/main/res/layout/request_list_item.xml
app/src/main/java/com/vsoft/uoflservicenow/adapters/MyRequestAdapter.java
View file @
f7dddf57
...
...
@@ -64,8 +64,7 @@ public class MyRequestAdapter extends BaseAdapter {
convertView
=
mInflater
.
inflate
(
R
.
layout
.
request_list_item
,
parent
,
false
);
holder
=
new
ViewHolder
();
holder
.
number
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
number
);
holder
.
dueDate
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
dueDate
);
holder
.
shotrDescription
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
shotrDescription
);
holder
.
shortDescription
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
shotrDescription
);
holder
.
approval
=
(
TextView
)
convertView
.
findViewById
(
R
.
id
.
approval
);
holder
.
statusIndicator
=
(
ImageView
)
convertView
.
findViewById
(
R
.
id
.
approval_image
);
convertView
.
setTag
(
holder
);
...
...
@@ -75,9 +74,7 @@ public class MyRequestAdapter extends BaseAdapter {
MyRequest
req
=
mReqList
.
get
(
position
);
holder
.
number
.
setText
(
req
.
getNumber
());
String
dueDate
=
"Due : "
+
req
.
getDueDate
();
holder
.
dueDate
.
setText
(
dueDate
);
holder
.
shotrDescription
.
setText
(
req
.
getShotrDescription
());
holder
.
shortDescription
.
setText
(
req
.
getShotrDescription
());
if
(!
req
.
getApproval
().
isEmpty
())
{
if
(
req
.
getApproval
().
equalsIgnoreCase
(
"requested"
))
{
...
...
@@ -99,8 +96,7 @@ public class MyRequestAdapter extends BaseAdapter {
static
class
ViewHolder
{
private
TextView
number
;
private
TextView
dueDate
;
private
TextView
shotrDescription
;
private
TextView
shortDescription
;
private
TextView
approval
;
private
ImageView
statusIndicator
;
}
...
...
app/src/main/java/com/vsoft/uoflservicenow/api/managers/MyRequestApiManager.java
View file @
f7dddf57
...
...
@@ -89,9 +89,10 @@ public class MyRequestApiManager {
List
<
MyRequest
>
catalogueList
=
new
ArrayList
<>(
catalogueJsonArray
.
length
());
for
(
int
i
=
0
;
i
<
catalogueJsonArray
.
length
();
i
++)
{
JSONObject
expenseJsonObject
=
catalogueJsonArray
.
getJSONObject
(
i
);
MyRequest
catalogue
=
gson
.
fromJson
(
expenseJsonObject
.
toString
(),
MyRequest
.
class
);
catalogueList
.
add
(
catalogue
);
JSONObject
myRequestJsonObject
=
catalogueJsonArray
.
getJSONObject
(
i
);
MyRequest
myRequest
=
gson
.
fromJson
(
myRequestJsonObject
.
toString
(),
MyRequest
.
class
);
myRequest
.
parseJson
(
myRequestJsonObject
);
catalogueList
.
add
(
myRequest
);
}
listener
.
onDoneApiCall
(
catalogueList
);
}
else
{
...
...
app/src/main/java/com/vsoft/uoflservicenow/db/models/MyRequest.java
View file @
f7dddf57
...
...
@@ -2,6 +2,10 @@ package com.vsoft.uoflservicenow.db.models;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Created by kvemulavada on 8/30/2016.
...
...
@@ -13,8 +17,8 @@ public class MyRequest {
private
String
number
;
@SerializedName
(
"due_date"
)
@Expose
private
Stri
ng
dueDate
;
//
@Expose
private
lo
ng
dueDate
;
@SerializedName
(
"short_description"
)
@Expose
...
...
@@ -32,11 +36,11 @@ public class MyRequest {
this
.
number
=
number
;
}
public
Stri
ng
getDueDate
()
{
public
lo
ng
getDueDate
()
{
return
dueDate
;
}
public
void
setDueDate
(
Stri
ng
dueDate
)
{
public
void
setDueDate
(
lo
ng
dueDate
)
{
this
.
dueDate
=
dueDate
;
}
...
...
@@ -56,8 +60,20 @@ public class MyRequest {
this
.
approval
=
approval
;
}
public
void
parseJson
(
JSONObject
jsonObject
)
{
String
dueDate
=
null
;
try
{
dueDate
=
jsonObject
.
getString
(
Json
.
DUE_DATE
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
this
.
setDueDate
(
Util
.
getDateTimeForMyRequestFromString
(
dueDate
));
}
public
static
class
Json
{
public
static
final
String
URL_PARAM_CATALOGUE_SYSPRM_QUERY_VALUE
=
"request.requested_for=javascript:gs.getUserID()"
;
public
static
final
String
DUE_DATE
=
"due_date"
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/ui/MyRequestActivity.java
View file @
f7dddf57
...
...
@@ -22,6 +22,8 @@ import com.vsoft.uoflservicenow.enums.SyncStatus;
import
com.vsoft.uoflservicenow.utils.DialogUtils
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
butterknife.BindView
;
...
...
@@ -104,11 +106,20 @@ public class MyRequestActivity extends AppCompatActivity {
private
void
setData
(
final
List
<
MyRequest
>
reqList
)
{
MyRequestAdapter
adapter
=
new
MyRequestAdapter
(
MyRequestActivity
.
this
);
Collections
.
sort
(
reqList
,
new
StringDateComparator
());
adapter
.
setRequestList
(
reqList
);
mListView
.
setAdapter
(
adapter
);
}
class
StringDateComparator
implements
Comparator
<
MyRequest
>
{
public
int
compare
(
MyRequest
lhs
,
MyRequest
rhs
)
{
return
lhs
.
getDueDate
()>
rhs
.
getDueDate
()
?
-
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 @
f7dddf57
...
...
@@ -300,6 +300,17 @@ public class Util {
return
date
.
getTime
();
}
public
static
long
getDateTimeForMyRequestFromString
(
String
strDate
)
{
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
US
);
Date
date
=
null
;
try
{
date
=
df
.
parse
(
strDate
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
date
.
getTime
();
}
/*Record a screen view hit for the visible*/
public
static
void
sendScreenName
(
Tracker
tracker
,
String
name
)
{
tracker
.
setScreenName
(
name
);
...
...
app/src/main/res/layout/request_list_item.xml
View file @
f7dddf57
...
...
@@ -19,21 +19,6 @@
android:textSize=
"@dimen/ruquest_descps_text_size"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/dueDate"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignBaseline=
"@+id/number"
android:layout_alignParentRight=
"true"
android:layout_below=
"@+id/number"
android:layout_marginRight=
"@dimen/my_request_top"
android:layout_marginTop=
"@dimen/my_request_top"
android:text=
"Large Text"
android:textColor=
"#8e8e8e"
android:textSize=
"@dimen/ruquest_descps_text_size"
android:visibility=
"gone"
/>
<TextView
android:id=
"@+id/shotrDescription"
android:layout_width=
"wrap_content"
...
...
@@ -69,5 +54,4 @@
android:text=
"Large Text"
android:textColor=
"#8e8e8e"
android:textSize=
"@dimen/ruquest_status_text_size"
/>
</RelativeLayout>
\ No newline at end of file
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