Commit f039445e authored by Loris's avatar Loris
Browse files

fix bug user null and position sometimes

parent a1d6d50d
......@@ -7,6 +7,7 @@ import android.support.annotation.RequiresApi;
import android.support.design.widget.TextInputEditText;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
......@@ -89,7 +90,9 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onClick(View v) {
appUser = inputUser.getText().toString();
Toast.makeText(MainActivity.this, "User set to " + appUser, Toast.LENGTH_SHORT).show();
Toast.makeText(MainActivity.this, "User set to " + appUser,
Toast.LENGTH_SHORT).show();
dataLogger.setAndroidUser(appUser);
}
});
......@@ -97,7 +100,9 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onClick(View v) {
appPosition = inputPosition.getText().toString();
Toast.makeText(MainActivity.this, "Position set to " + appPosition, Toast.LENGTH_LONG).show();
Toast.makeText(MainActivity.this, "Position set to " + appPosition,
Toast.LENGTH_LONG).show();
dataLogger.setAndroidPosition(appPosition);
}
});
......@@ -124,18 +129,10 @@ public class MainActivity extends AppCompatActivity {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void startRecording() {
phoneSensors.onResume(this);
if (appUser == "") {
dataLogger.setAndroidUser("dummy");
} else {
dataLogger.setAndroidUser(appUser);
}
if (appPosition == "") {
dataLogger.setAndroidPosition("dummy");
} else {
dataLogger.setAndroidPosition(appPosition);
}
Log.d("TAG", "startRecording: User " + dataLogger.getAndroidUser());
Log.d("TAG", "startRecording: Position " + dataLogger.getAndroidPosition());
dataLogger.start(phoneSensors.getAll());
String path = dataLogger.getFile().getAbsolutePath();
String path = dataLogger.getFile().getAbsolutePath();
txtViewFilename.setText(path.substring(path.length()-17));
}
......
......@@ -186,6 +186,14 @@ public final class Logger {
this.androidUser = u;
}
public String getAndroidUser() {
return androidUser;
}
public String getAndroidPosition() {
return androidPosition;
}
public void setAndroidPosition(String u) {
this.androidPosition = u;
}
......
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 to comment