Commit 458beb8c by Kunj Gupta

Added user sysid null handle code in chat screen.

parent b6f32a03
...@@ -100,6 +100,15 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList ...@@ -100,6 +100,15 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
mLoggedInUserSysId = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_SYS_ID); mLoggedInUserSysId = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_SYS_ID);
mLoggedInUsername = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_FIRST_NAME); mLoggedInUsername = PrefManager.getSharedPref(this, PrefManager.PREFERENCE_USER_FIRST_NAME);
if(TextUtils.isEmpty(mLoggedInUserSysId) || TextUtils.isEmpty(mLoggedInUsername)) {
CatalogueLog.e("User Sys id or Name is Null");
Intent intent = new Intent(this, LoginScreen.class);
intent.putExtra(Constants.DATA_KEY_LOGIN_REQUEST_CODE, Constants.LOGIN_SCREEN_REQUEST_CODE);
startActivity(intent);
finish();
}
Toolbar mToolbar = findViewById(R.id.tool_bar_view); Toolbar mToolbar = findViewById(R.id.tool_bar_view);
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
...@@ -463,6 +472,8 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList ...@@ -463,6 +472,8 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
install.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); install.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(install); startActivity(install);
} }
} else if(requestCode == Constants.LOGIN_SCREEN_REQUEST_CODE) {
} }
} }
...@@ -553,17 +564,21 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList ...@@ -553,17 +564,21 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
mSocket.disconnect(); if(mSocket != null) {
mSocket.disconnect();
mSocket.off(Socket.EVENT_CONNECT, onConnect); mSocket.off(Socket.EVENT_CONNECT, onConnect);
mSocket.off(Socket.EVENT_DISCONNECT, onDisconnect); mSocket.off(Socket.EVENT_DISCONNECT, onDisconnect);
mSocket.off(Socket.EVENT_CONNECT_ERROR, onConnectError); mSocket.off(Socket.EVENT_CONNECT_ERROR, onConnectError);
mSocket.off(Socket.EVENT_CONNECT_TIMEOUT, onConnectError); mSocket.off(Socket.EVENT_CONNECT_TIMEOUT, onConnectError);
mSocket.off(NEW_MESSAGE, onNewMessage); mSocket.off(NEW_MESSAGE, onNewMessage);
mSocket.off(AUTHENTICATED, authenticated); mSocket.off(AUTHENTICATED, authenticated);
mSocket.off(UNAUTHORIZED, unAuthorized); mSocket.off(UNAUTHORIZED, unAuthorized);
}
speaker.destroy(); if(speaker != null) {
speaker.destroy();
}
} }
private String firstLetterCaps ( String data ) { private String firstLetterCaps ( String data ) {
......
...@@ -93,7 +93,17 @@ public class LoginScreen extends Activity { ...@@ -93,7 +93,17 @@ public class LoginScreen extends Activity {
intent.putExtra(Constants.APPLICATION_BROADCAST_DATA_ACTION, Constants.ACTION_SYNC); intent.putExtra(Constants.APPLICATION_BROADCAST_DATA_ACTION, Constants.ACTION_SYNC);
LocalBroadcastManager.getInstance(LoginScreen.this).sendBroadcast(intent); LocalBroadcastManager.getInstance(LoginScreen.this).sendBroadcast(intent);
startActivity(new Intent(LoginScreen.this, HomeScreen.class)); Bundle bundle = getIntent().getExtras();
if(bundle != null) {
int requestCode = bundle.getInt(Constants.DATA_KEY_LOGIN_REQUEST_CODE);
if (requestCode == Constants.LOGIN_SCREEN_REQUEST_CODE) {
setResult(Constants.LOGIN_SCREEN_REQUEST_CODE, new Intent());
} else {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
}
} else {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
}
finish(); finish();
} }
} }
...@@ -244,7 +254,17 @@ public class LoginScreen extends Activity { ...@@ -244,7 +254,17 @@ public class LoginScreen extends Activity {
intent.putExtra(Constants.APPLICATION_BROADCAST_DATA_ACTION, Constants.ACTION_SYNC); intent.putExtra(Constants.APPLICATION_BROADCAST_DATA_ACTION, Constants.ACTION_SYNC);
LocalBroadcastManager.getInstance(LoginScreen.this).sendBroadcast(intent); LocalBroadcastManager.getInstance(LoginScreen.this).sendBroadcast(intent);
startActivity(new Intent(LoginScreen.this, HomeScreen.class)); Bundle bundle = getIntent().getExtras();
if(bundle != null) {
int requestCode = bundle.getInt(Constants.DATA_KEY_LOGIN_REQUEST_CODE);
if (requestCode == Constants.LOGIN_SCREEN_REQUEST_CODE) {
startActivity(new Intent(LoginScreen.this, ChatActivity.class));
} else {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
}
} else {
startActivity(new Intent(LoginScreen.this, HomeScreen.class));
}
finish(); finish();
} else { } else {
Toast.makeText(LoginScreen.this, R.string.user_detail_not_available, Toast.LENGTH_LONG).show(); Toast.makeText(LoginScreen.this, R.string.user_detail_not_available, Toast.LENGTH_LONG).show();
......
...@@ -29,9 +29,9 @@ public class Constants { ...@@ -29,9 +29,9 @@ public class Constants {
public static final String DATA_KEY_CATALOGUE_TITLE = "catalogue_title"; public static final String DATA_KEY_CATALOGUE_TITLE = "catalogue_title";
public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des"; public static final String DATA_KEY_CATALOGUE_ITEM_DESCRIPTION = "catalogue_item_des";
public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des"; public static final String DATA_KEY_CATALOGUE_ITEM_SHORT_DESCRIPTION = "catalogue_item_short_des";
public static final String DATA_KEY_CHAT_USER_NAME = "username";
public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title"; public static final String DATA_KEY_NOTIFICATION_TITLE = "notification_title";
public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message"; public static final String DATA_KEY_NOTIFICATION_MESSAGE = "notification_message";
public static final String DATA_KEY_LOGIN_REQUEST_CODE = "login_request_code";
/** /**
* Broadcast custom intent * Broadcast custom intent
...@@ -45,6 +45,7 @@ public class Constants { ...@@ -45,6 +45,7 @@ public class Constants {
public static final String APPLICATION_BROADCAST_INTENT = "application_broadcast"; public static final String APPLICATION_BROADCAST_INTENT = "application_broadcast";
public static final String APPLICATION_BROADCAST_DATA_ACTION = "action"; public static final String APPLICATION_BROADCAST_DATA_ACTION = "action";
public static final String ACTION_PROMPT_LOGIN = "action_prompt_login"; public static final String ACTION_PROMPT_LOGIN = "action_prompt_login";
/** /**
* Catalogue services post parameters * Catalogue services post parameters
*/ */
...@@ -59,6 +60,11 @@ public class Constants { ...@@ -59,6 +60,11 @@ public class Constants {
public static final String URL_PARAM_SYS_ID = "sys_id"; public static final String URL_PARAM_SYS_ID = "sys_id";
/** /**
* Request Code
* */
public static final int LOGIN_SCREEN_REQUEST_CODE = 105;
/**
* Preference Notification token. * Preference Notification token.
*/ */
public static final String PREFS_NOTIFICATION_TOKEN = "notification_token"; public static final String PREFS_NOTIFICATION_TOKEN = "notification_token";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment