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
03b97a19
authored
Sep 08, 2016
by
Krishna Vemulavada
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Set the single asyncTask inLoginpage
parent
a7dfa538
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
109 deletions
app/src/main/java/com/vsoft/uoflservicenow/ui/HomeScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/LoginScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/HomeScreen.java
View file @
03b97a19
...
...
@@ -24,64 +24,66 @@ import butterknife.OnItemClick;
* Created by Kunj on 11/8/16.
*/
public
class
HomeScreen
extends
AppCompatActivity
{
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
@BindView
(
R
.
id
.
home_screen_grid_view
)
GridView
mGridView
;
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
@BindView
(
R
.
id
.
home_screen_grid_view
)
GridView
mGridView
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
// TODO Auto-generated method stub
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
home_screen
);
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
// TODO Auto-generated method stub
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
home_screen
);
ButterKnife
.
bind
(
this
);
ButterKnife
.
bind
(
this
);
CatalogueApplication
application
=
(
CatalogueApplication
)
getApplication
();
setSupportActionBar
(
mToolbar
);
ActionBar
actionBar
=
getSupportActionBar
();
if
(
actionBar
!=
null
)
{
actionBar
.
setElevation
(
0
);
actionBar
.
setTitle
(
""
);
actionBar
.
setDisplayShowHomeEnabled
(
false
);
actionBar
.
setDisplayShowTitleEnabled
(
true
);
}
CatalogueApplication
application
=
(
CatalogueApplication
)
getApplication
();
setSupportActionBar
(
mToolbar
);
ActionBar
actionBar
=
getSupportActionBar
();
if
(
actionBar
!=
null
)
{
actionBar
.
setElevation
(
0
);
actionBar
.
setTitle
(
""
);
actionBar
.
setDisplayShowHomeEnabled
(
false
);
actionBar
.
setDisplayShowTitleEnabled
(
true
);
}
Tracker
tracker
=
application
.
getDefaultTracker
();
// Send initial screen view hit.
Util
.
sendScreenName
(
tracker
,
getString
(
R
.
string
.
home_screen_string
));
Tracker
tracker
=
application
.
getDefaultTracker
();
// Send initial screen view hit.
Util
.
sendScreenName
(
tracker
,
getString
(
R
.
string
.
home_screen_string
));
String
[]
gridValuesArray
=
getResources
().
getStringArray
(
R
.
array
.
home_screen_array
);
TypedArray
gridViewIcons
=
getResources
().
obtainTypedArray
(
R
.
array
.
home_screen_icon_array
);
HomeScreenAdapter
adapter
=
new
HomeScreenAdapter
(
this
,
gridValuesArray
,
gridViewIcons
);
mGridView
.
setAdapter
(
adapter
);
}
String
[]
gridValuesArray
=
getResources
().
getStringArray
(
R
.
array
.
home_screen_array
);
TypedArray
gridViewIcons
=
getResources
().
obtainTypedArray
(
R
.
array
.
home_screen_icon_array
);
HomeScreenAdapter
adapter
=
new
HomeScreenAdapter
(
this
,
gridValuesArray
,
gridViewIcons
);
mGridView
.
setAdapter
(
adapter
);
}
@OnItemClick
(
R
.
id
.
home_screen_grid_view
)
void
gridViewItemClicked
(
int
position
)
{
boolean
networkStatus
=
NetworkUtil
.
getConnectivityStatus
(
getApplicationContext
());
if
(
position
==
0
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
ReportIncidentScreen
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
else
if
(
position
==
1
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
CatalogueScreen
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
else
if
(
position
==
2
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
MyIncidentScreen
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
else
if
(
position
==
3
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
MyRequestActivity
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
}
@OnItemClick
(
R
.
id
.
home_screen_grid_view
)
void
gridViewItemClicked
(
int
position
)
{
boolean
networkStatus
=
NetworkUtil
.
getConnectivityStatus
(
getApplicationContext
());
if
(
position
==
0
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
ReportIncidentScreen
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
else
if
(
position
==
1
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
CatalogueScreen
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
else
if
(
position
==
2
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
MyIncidentScreen
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
else
if
(
position
==
3
)
{
if
(
networkStatus
)
{
startActivity
(
new
Intent
(
HomeScreen
.
this
,
MyRequestActivity
.
class
));
}
else
{
DialogUtils
.
showNoConnectionDialog
(
HomeScreen
.
this
);
}
}
}
}
app/src/main/java/com/vsoft/uoflservicenow/ui/LoginScreen.java
View file @
03b97a19
...
...
@@ -8,12 +8,9 @@ import android.content.Intent;
import
android.content.SharedPreferences
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.support.v7.app.AlertDialog
;
import
android.text.TextUtils
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.EditText
;
import
android.widget.ScrollView
;
import
android.widget.TextView
;
...
...
@@ -49,7 +46,6 @@ import butterknife.internal.Utils;
*/
public
class
LoginScreen
extends
Activity
{
@BindView
(
R
.
id
.
login_screen_username_edit_text
)
EditText
userName
;
@BindView
(
R
.
id
.
errormessage
)
...
...
@@ -105,7 +101,6 @@ public class LoginScreen extends Activity {
CatalogueApplication
application
=
(
CatalogueApplication
)
getApplication
();
Tracker
tracker
=
application
.
getDefaultTracker
();
// Send initial screen view hit.
Util
.
sendScreenName
(
tracker
,
getString
(
R
.
string
.
login_screen_string
));
}
...
...
@@ -141,7 +136,6 @@ public class LoginScreen extends Activity {
@OnClick
(
R
.
id
.
login_screen_login_text_view
)
void
onLoginClicked
()
{
//startActivity(new Intent(LoginScreen.this, HomeScreen.class));
callLoginAPI
();
}
...
...
@@ -161,11 +155,21 @@ public class LoginScreen extends Activity {
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
SyncStatus
syncStatus
=
null
;
userName
=
params
[
0
];
//"a0kuma18";
String
password
=
params
[
1
];
//"v$0ftA$win";
return
LoginApiManger
.
submitLoginValues
(
Constants
.
GRANT_TYPE
,
Constants
.
CLIENT_ID
,
Constants
.
CLIENT_SECRET
,
userName
,
password
);
syncStatus
=
LoginApiManger
.
submitLoginValues
(
Constants
.
GRANT_TYPE
,
Constants
.
CLIENT_ID
,
Constants
.
CLIENT_SECRET
,
userName
,
password
);
if
(
syncStatus
!=
null
&&
syncStatus
==
SyncStatus
.
SUCCESS
)
{
return
UserApiManager
.
getUserDetailResponse
(
userName
,
new
GetUserApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
UserApiValues
>
userValues
)
{
mUserDetails
=
userValues
;
}
});
}
else
{
return
syncStatus
;
}
}
@Override
...
...
@@ -174,55 +178,18 @@ public class LoginScreen extends Activity {
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
())
{
progressDialog
.
dismiss
();
}
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
new
UserApiDetails
().
execute
(
userName
);
if
(
syncStatus
!=
null
&&
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
mUserDetails
!=
null
)
{
String
firstname
=
mUserDetails
.
get
(
0
).
getFirstName
();
String
lasrname
=
mUserDetails
.
get
(
0
).
getLastName
();
String
sysid
=
mUserDetails
.
get
(
0
).
getSysId
();
PrefManager
.
saveUserDetailsInPreferences
(
LoginScreen
.
this
,
firstname
,
lasrname
,
sysid
);
startActivity
(
new
Intent
(
LoginScreen
.
this
,
HomeScreen
.
class
));
finish
();
}
}
else
{
errorMessage
.
setVisibility
(
View
.
VISIBLE
);
errorMessage
.
setText
(
"Invalid username and password"
);
//Toast.makeText(LoginScreen.this, "Invalid username and password", Toast.LENGTH_SHORT).show();
}
}
private
class
UserApiDetails
extends
AsyncTask
<
String
,
Void
,
SyncStatus
>
{
private
ProgressDialog
progressDialog
;
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
progressDialog
=
new
ProgressDialog
(
LoginScreen
.
this
);
progressDialog
.
setMessage
(
getString
(
R
.
string
.
loading_string
));
progressDialog
.
show
();
progressDialog
.
setCancelable
(
false
);
}
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
String
userName
=
params
[
0
];
return
UserApiManager
.
getUserDetailResponse
(
userName
,
new
GetUserApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
UserApiValues
>
userValues
)
{
mUserDetails
=
userValues
;
}
});
}
@Override
protected
void
onPostExecute
(
SyncStatus
syncStatus
)
{
super
.
onPostExecute
(
syncStatus
);
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
())
{
progressDialog
.
dismiss
();
}
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
mUserDetails
!=
null
)
{
String
firstname
=
mUserDetails
.
get
(
0
).
getFirstName
();
String
lasrname
=
mUserDetails
.
get
(
0
).
getLastName
();
String
sysid
=
mUserDetails
.
get
(
0
).
getSysId
();
PrefManager
.
saveUserDetailsInPreferences
(
LoginScreen
.
this
,
firstname
,
lasrname
,
sysid
);
startActivity
(
new
Intent
(
LoginScreen
.
this
,
HomeScreen
.
class
));
finish
();
}
}
}
}
}
...
...
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