Bug Fixes for crash, login page issue

parent 493df8e0
......@@ -23,6 +23,7 @@ import android.os.PowerManager;
import android.provider.MediaStore;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.support.design.widget.Snackbar;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
......@@ -148,6 +149,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
String takePictureFilePath = "";
private Speaker speaker;
private Boolean isConnected = false;
private Boolean isConnectError = false;
private static final int NONE = -1;
private static final int VOICE_STATE = 1;
private static final int TYPING_STATE = 2;
......@@ -249,7 +251,7 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
mSocket.connect();
checkTTS();
speaker = new Speaker(this);
//speaker = new Speaker(this);
textDotLoader = findViewById(R.id.avi);
mMessagesView = (RecyclerView) findViewById(R.id.messages);
sendImageToserv = (ImageButton) findViewById(R.id.image_button);
......@@ -261,7 +263,6 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public void imageViewOnClick(String imagePath) {
shoawUserImagePopupImageAlert(imagePath);
}
@Override
......@@ -667,8 +668,12 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
String message = mInputMessageView.getText().toString().trim();
if (!TextUtils.isEmpty(message)){
if (null == mLoggedInUsername) return;
if (!mSocket.connected())
return;
if (mSocket == null) return;
if (!mSocket.connected()) {
mSocket.connect();
//return;
}
//Whenever we'll click on send button, running TTS speak should stop
if(speaker != null && speaker.isSpeaking()) {
......@@ -777,8 +782,21 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
@Override
public void run() {
isConnected = false;
Toast.makeText(getApplicationContext(),
R.string.disconnect, Toast.LENGTH_LONG).show();
isConnectError = false;
Snackbar snackbar = Snackbar
.make(mMessagesView, R.string.disconnect, Snackbar.LENGTH_LONG);
snackbar.show();
// Changing action button text color
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.YELLOW);
snackbar.show();
/*Toast.makeText(getApplicationContext(),
R.string.disconnect, Toast.LENGTH_LONG).show();*/
}
});
}
......@@ -802,8 +820,8 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
private Emitter.Listener onReconnect = new Emitter.Listener() {
@Override
public void call(Object... args) {
Toast.makeText(getApplicationContext(),
"Reconnection Called", Toast.LENGTH_LONG).show();
/*Toast.makeText(getApplicationContext(),
"Reconnection Called", Toast.LENGTH_LONG).show();*/
//reconnect();
}
......@@ -818,18 +836,42 @@ public class ChatActivity extends AppCompatActivity implements OnDSListener, OnD
runOnUiThread(new Runnable() {
@Override
public void run() {
if(!isConnectError) {
Snackbar snackbar = Snackbar
.make(mMessagesView, R.string.error_connect, Snackbar.LENGTH_LONG)
.setAction("Dismiss", new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
snackbar.show();
// Changing message text color
snackbar.setActionTextColor(Color.RED);
Toast toast = Toast.makeText(getApplicationContext(), R.string.error_connect, Toast.LENGTH_LONG);
// Changing action button text color
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.YELLOW);
snackbar.show();
isConnectError = true;
}
/*Toast toast = Toast.makeText(getApplicationContext(), R.string.error_connect, Toast.LENGTH_LONG);
View toastView = toast.getView(); // This'll return the default View of the Toast.
/* And now you can get the TextView of the default View of the Toast. */
*//* And now you can get the TextView of the default View of the Toast. *//*
TextView toastMessage = (TextView) toastView.findViewById(android.R.id.message);
toastMessage.setTextSize(15);
toastMessage.setTextColor(Color.WHITE);
toastMessage.setGravity(Gravity.CENTER);
toastMessage.setPadding(30,0,30,0);
toastView.setBackgroundColor(Color.BLACK);
toast.show();
toast.show();*/
}
});
}
......
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