Skip to content

Commit

Permalink
Correções de bugs
Browse files Browse the repository at this point in the history
Correção da data das medições manuais.
  • Loading branch information
fabiioojr committed Jun 12, 2019
1 parent 826a1f1 commit eaa4a28
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;

Expand Down Expand Up @@ -223,6 +224,7 @@ private boolean checkConnectivity() {
return true;
}


/**
* Setup date picker.
*/
Expand All @@ -231,8 +233,9 @@ public void setupComponents() {
final Calendar c = Calendar.getInstance();
int mHour = c.get(Calendar.HOUR_OF_DAY);
int mMinute = c.get(Calendar.MINUTE);
myCalendar.getTime().setHours(mHour);
myCalendar.getTime().setMinutes(mMinute);
myCalendar.set(Calendar.HOUR_OF_DAY, mHour);
myCalendar.set(Calendar.MINUTE, mMinute);

updateLabel();

View.OnClickListener timeClick = v -> {
Expand All @@ -241,8 +244,8 @@ public void setupComponents() {
textTime.setText(new StringBuilder().append(hourOfDay)
.append(":")
.append(String.format("%02d", minute)).toString());
myCalendar.getTime().setHours(hourOfDay);
myCalendar.getTime().setMinutes(minute);
myCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
myCalendar.set(Calendar.MINUTE, minute);
}, mHour, mMinute, true);
timePickerDialog.show();
};
Expand Down Expand Up @@ -286,6 +289,7 @@ private void updateLabel() {
textDate.setText(sdf.format(myCalendar.getTime()));
}

Log.w(TAG, "Tempo selecionado do myCalendar (Update label): " + myCalendar.getTime());
textTime.setText(new StringBuilder().append(myCalendar.getTime().getHours())
.append(":")
.append(String.format("%02d", myCalendar.getTime().getMinutes())));
Expand Down Expand Up @@ -324,6 +328,7 @@ private void saveMeasurements(List<Measurement> measurements) {
}
for (Measurement measurement : measurements) {
measurement.setUserId(patient.get_id());
Log.w(TAG, "Tempo selecionado do myCalendar: " + myCalendar.getTime());
measurement.setTimestamp(DateUtils.convertDateTimeToUTC(myCalendar.getTime()));
Log.i("AAA", "saving " + measurement.toJson());

Expand Down Expand Up @@ -351,6 +356,7 @@ private void saveMeasurement(Measurement measurement) {
Log.w(TAG, measurement.getType() + ": salvando");
measurement.setUserId(patient.get_id());
measurement.setTimestamp(DateUtils.convertDateTimeToUTC(myCalendar.getTime()));
Log.w(TAG, "Tempo selecionado do myCalendar: " + myCalendar.getTime());
Log.w(TAG, "JSON: " + measurement.toJson());

new AlertDialog.Builder(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ public static String getStringPTBR(String type) {

public static class FoodAllergyStringolerance {
public static final String GLUTEN = "gluten";
//TODO aplv
public static final String APLV = "aplv";
public static final String LACTOSE = "lactose";
public static final String DYE = "dye";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ public Single<UserAccess> auth(String username, String password) {
userAccess.setSubject(jwt.getSubject());
userAccess.setExpirationDate(jwt.getExpiresAt().getTime());
userAccess.setScopes(jwt.getClaim(UserAccess.KEY_SCOPES).asString());
//TODO TEMP
Log.i("AAA", userAccess.toString());
}
return userAccess;
})
Expand Down Expand Up @@ -185,6 +183,13 @@ public Single<List<Measurement>> getAllMeasurementsByType(String userId, String
.observeOn(AndroidSchedulers.mainThread());
}

public Single<List<Measurement>> getAllMeasurementsByType(String userId, String type,
String sort, int page, int limit) {
return haniotService.getAllMeasurements(userId, type, sort, page, limit)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}

public Single<List<Measurement>> getAllMeasurements(String userId, String sort,
String dateStart, String dateEnd,
int page, int limit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Copyright (c) 2018, NUTES/UEPB
*/
public interface HaniotService {
// String BASE_URL_HANIOT = "http://192.168.0.119:8080/"; // API GATEWAY LOCAL
// String BASE_URL_HANIOT = "http://192.168.0.119:8080/"; // API GATEWAY LOCAL
String BASE_URL_HANIOT = "https://200.129.82.8:8081";

// auth
Expand Down Expand Up @@ -75,7 +75,7 @@ Single<Measurement> addMeasurement(@Path("user_id") String userId,

@POST("users/{user_id}/measurements")
Single<Object> addMeasurement(@Path("user_id") String userId,
@Body List<Measurement> measurement);
@Body List<Measurement> measurement);

@GET("users/{user_id}/measurements")
Single<List<Measurement>> getAllMeasurements(@Path("user_id") String userId,
Expand All @@ -94,6 +94,13 @@ Single<List<Measurement>> getAllMeasurements(@Path("user_id") String userId,
@Query("page") int page,
@Query("limit") int limit);

@GET("users/{user_id}/measurements")
Single<List<Measurement>> getAllMeasurements(@Path("user_id") String userId,
@Query("type") String type,
@Query("sort") String sort,
@Query("page") int page,
@Query("limit") int limit);

@GET("users/{user_id}/measurements")
Single<List<Measurement>> getAllMeasurements(@Path("user_id") String userId,
@Query("page") int page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,16 +440,6 @@ public void run() {
@Override
protected void onStart() {
super.onStart();

// TODO REMOVER!!! Pois o cadastro do device deverá ser no processo de emparelhamento
// mDevice = deviceDAO.get(mDeviceAddress, session.getUserLogged().get_id());
//
// if (mDevice == null) {
// mDevice = new Device(mDeviceAddress, "MI BAND 2", "XIAOMI", "", DeviceType.SMARTBAND, session.getUserLogged());
// mDevice.set_id("5a713bce7c210900147a4eda");
// if (!deviceDAO.save(mDevice)) finish();
// mDevice = deviceDAO.get(mDeviceAddress, session.getIdLogged());
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ protected void onCreate(Bundle savedInstanceState) {
haniotNetRepository = HaniotNetRepository.getInstance(this);
patient = appPreferencesHelper.getLastPatient();


//TODO TEMP - Há problemas no cadastro dos dispositivos
mDevice = deviceDAO.getByType(appPreferencesHelper.getUserLogged().get_id(), DeviceType.THERMOMETER);
animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
mChartButton.setOnClickListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,11 @@ public void init() {

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
//TODO Auto-generated method stub

}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
//TODO Auto-generated method stub

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,25 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
initComponents();
initRecyclerView();
refreshManagerBLE();

return view;
}

//TODO Próxima sprint
private void downloadLastMeasurements() {
DisposableManager.add(haniotRepository
.getAllMeasurementsByType(patient.get_id(), "blood_glucose", "-timestamp", null, null, 1, 1)
.subscribe(measurements -> {
if (!measurements.isEmpty()) {
Log.w(LOG_TAG, Arrays.toString(measurements.toArray()));
Measurement measurement = measurements.get(0);
updateMeasurement(String.valueOf(measurement.getValue()), measurement.getUnit(), measurement.getTimestamp(), ItemGridType.BLOOD_GLUCOSE);
}
}, throwable -> {
Log.w(LOG_TAG, throwable.getMessage());
}));

}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Expand All @@ -176,6 +191,7 @@ public void onResume() {
super.onResume();
refreshRegisteredDevices();
refreshManagerBLE();
//downloadLastMeasurements();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public void onDeviceNotSupported(@NonNull BluetoothDevice device) {
* @return double
*/
private double calcBMI(double bodyMass) {
//TODO pegar altura do paciente selecionado
//double height = (session.getUserLogged().getHeight()) / 100D;
double height = 1.0;
return bodyMass / (Math.pow(height, 2));
Expand Down

0 comments on commit eaa4a28

Please sign in to comment.