Skip to content

Commit

Permalink
fixed issue in restoring state of the feed activity
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjoserendon13 committed May 5, 2018
1 parent cdb8901 commit 4ca1a86
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), FeedActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void run() {
String readMessage = new String(buffer, 0, bytes);
data = readMessage;
if (data != bufferData) {
Log.i("-------------", "dato entrante en singleton: " + data);
// Log.i("-------------", "dato entrante en singleton: " + data);
setChanged();
notifyObservers();
clearChanged();
Expand Down
21 changes: 16 additions & 5 deletions app/src/main/java/com/proter/juanjose/protermico/FeedActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class FeedActivity extends AppCompatActivity implements Observer {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("--------------", "onCREATE");
setContentView(R.layout.activity_feed);
Intent intent = getIntent();
Bundle extras = intent.getExtras();
Expand Down Expand Up @@ -213,7 +214,7 @@ public void handleMessage(android.os.Message msg) {
if (msg.what == handlerState) { //if message is what we want
String readMessage = (String) msg.obj; // msg.arg1 = bytes from connect thread
recDataString.append(readMessage);
Log.i("----------", "llega al handler feed " + recDataString);//keep appending to string until ~
// Log.i("----------", "llega al handler feed " + recDataString);//keep appending to string until ~
int endOfLineIndex = recDataString.indexOf("~"); // determine the end-of-line
if (endOfLineIndex > 0) { // make sure there data before ~
String dataInPrint = recDataString.substring(0, endOfLineIndex); // extract string
Expand All @@ -226,7 +227,7 @@ public void handleMessage(android.os.Message msg) {
}
if (recDataString.charAt(0) == '/') {
String temp = recDataString.substring(1, endOfLineIndex);
Log.i("----------", "llega al / " + temp);
// Log.i("----------", "llega al / " + temp);
systemTemp(temp);
}

Expand Down Expand Up @@ -305,22 +306,32 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
@Override
protected void onStart() {
super.onStart();

Log.i("--------------", "onSTART");
}

protected void onResume() {
super.onResume();
Log.i("--------------", "onRESUME");
ConnectionBt.getInstance().addObserver(this);
homeBtn.setChecked(true);
statisticBtn.setChecked(false);
configBtn.setChecked(false);

super.onResume();
}

@Override
protected void onPause() {
ConnectionBt.getInstance().deleteObserver(this);
super.onPause();
Log.i("--------------", "onPAUSE");
ConnectionBt.getInstance().deleteObserver(this);

}

@Override
protected void onDestroy() {
super.onDestroy();
Log.i("--------------", "onDESTROY");

}

private void updateCountDownText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), FeedActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
});
Expand Down

0 comments on commit 4ca1a86

Please sign in to comment.