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
5e659328
authored
Sep 19, 2016
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
UOFLMA-87 - Implemented Sort categories, items alphabetically.
parent
f5cea91c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
9 deletions
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueItemScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueItemScreen.java
View file @
5e659328
...
...
@@ -28,6 +28,8 @@ import com.vsoft.uoflservicenow.utils.Constants;
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
;
...
...
@@ -113,7 +115,14 @@ public class CatalogueItemScreen extends AppCompatActivity {
}
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
mCatalogueItemList
!=
null
)
{
setData
();
/*Sort catalogue items list alphabetically*/
Collections
.
sort
(
mCatalogueItemList
,
new
Comparator
<
CatalogueItem
>()
{
@Override
public
int
compare
(
CatalogueItem
lhs
,
CatalogueItem
rhs
)
{
return
lhs
.
getName
().
compareToIgnoreCase
(
rhs
.
getName
());
}
});
setData
(
mCatalogueItemList
);
}
}
else
{
showErrorDialog
(
R
.
string
.
failed_to_fetch_catalogue_category_items_string
);
...
...
@@ -121,12 +130,12 @@ public class CatalogueItemScreen extends AppCompatActivity {
}
}
private
void
setData
()
{
private
void
setData
(
final
List
<
CatalogueItem
>
catalogueItemList
)
{
if
(!
mCatalogueItemList
.
isEmpty
())
{
mListView
.
setVisibility
(
View
.
VISIBLE
);
mEmptyTextView
.
setVisibility
(
View
.
GONE
);
CatalogueCategoryItemAdapter
adapter
=
new
CatalogueCategoryItemAdapter
(
CatalogueItemScreen
.
this
);
adapter
.
setCatalogueItemList
(
mC
atalogueItemList
);
adapter
.
setCatalogueItemList
(
c
atalogueItemList
);
mListView
.
setAdapter
(
adapter
);
mListView
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
...
...
@@ -134,12 +143,12 @@ public class CatalogueItemScreen extends AppCompatActivity {
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
CatalogueLog
.
e
(
"OnItemClickListener: position: "
+
position
+
", Catalogue: "
+
mC
atalogueItemList
.
get
(
position
));
CatalogueLog
.
e
(
"OnItemClickListener: position: "
+
position
+
", Catalogue: "
+
c
atalogueItemList
.
get
(
position
));
Intent
intent
=
new
Intent
(
CatalogueItemScreen
.
this
,
CatalogueVariableScreen
.
class
);
intent
.
putExtra
(
Constants
.
DATA_KEY_SYS_ID
,
mC
atalogueItemList
.
get
(
position
).
getSysId
());
intent
.
putExtra
(
Constants
.
DATA_KEY_CATALOGUE_ITEM_DESCRIPTION
,
mC
atalogueItemList
.
get
(
position
).
getDescription
());
intent
.
putExtra
(
Constants
.
DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION
,
mC
atalogueItemList
.
get
(
position
).
getShortDescription
());
intent
.
putExtra
(
Constants
.
DATA_KEY_CATALOGUE_TITLE
,
mC
atalogueItemList
.
get
(
position
).
getName
());
intent
.
putExtra
(
Constants
.
DATA_KEY_SYS_ID
,
c
atalogueItemList
.
get
(
position
).
getSysId
());
intent
.
putExtra
(
Constants
.
DATA_KEY_CATALOGUE_ITEM_DESCRIPTION
,
c
atalogueItemList
.
get
(
position
).
getDescription
());
intent
.
putExtra
(
Constants
.
DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION
,
c
atalogueItemList
.
get
(
position
).
getShortDescription
());
intent
.
putExtra
(
Constants
.
DATA_KEY_CATALOGUE_TITLE
,
c
atalogueItemList
.
get
(
position
).
getName
());
startActivity
(
intent
);
}
});
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueScreen.java
View file @
5e659328
...
...
@@ -27,6 +27,8 @@ import com.vsoft.uoflservicenow.utils.Constants;
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
;
...
...
@@ -103,8 +105,16 @@ public class CatalogueScreen extends AppCompatActivity {
progressDialog
.
dismiss
();
}
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
mCatalogueList
!=
null
)
if
(
mCatalogueList
!=
null
)
{
/*Sort catalogue list alphabetically*/
Collections
.
sort
(
mCatalogueList
,
new
Comparator
<
Catalogue
>()
{
@Override
public
int
compare
(
Catalogue
lhs
,
Catalogue
rhs
)
{
return
lhs
.
getTitle
().
compareToIgnoreCase
(
rhs
.
getTitle
());
}
});
setData
(
mCatalogueList
);
}
}
else
{
showErrorDialog
(
R
.
string
.
failed_to_fetch_catalogue_category_string
);
}
...
...
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