Updated api calls to have separated responsabilities based on db entity
This commit is contained in:
parent
fafd98c0f2
commit
e22d62bf7e
|
|
@ -20,13 +20,13 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
import com.example.acloc.activity.ManageRolesActivity;
|
import com.example.acloc.activity.ManageRolesActivity;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.dialog.AlertChangePasswordDialog;
|
import com.example.acloc.dialog.AlertChangePasswordDialog;
|
||||||
import com.example.acloc.dialog.AlertViewOrUpdateProfileDialog;
|
import com.example.acloc.dialog.AlertViewOrUpdateProfileDialog;
|
||||||
import com.example.acloc.fragments.FavoriteFragment;
|
import com.example.acloc.fragments.FavoriteFragment;
|
||||||
import com.example.acloc.fragments.MapFragment;
|
import com.example.acloc.fragments.MapFragment;
|
||||||
import com.example.acloc.fragments.MyReportsFragment;
|
import com.example.acloc.fragments.MyReportsFragment;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
import com.example.acloc.service.RoleService;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -359,9 +359,10 @@ public class MainActivity extends AppCompatActivity {
|
||||||
DialogUtils.showLoadingDialog(context, "");
|
DialogUtils.showLoadingDialog(context, "");
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.getRoles(token);
|
RoleService roleService = LocationApiClient.getInstance().getRoleService();
|
||||||
|
|
||||||
|
Call<JsonObject> call = roleService.getRoles(token);
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ import androidx.appcompat.widget.AppCompatButton;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Place;
|
import com.example.acloc.model.Place;
|
||||||
|
import com.example.acloc.service.PlaceService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -188,9 +188,10 @@ public class AddNewPlaceActivity extends AppCompatActivity implements View.OnCli
|
||||||
placeBody.addProperty("createdBy", createdBy);
|
placeBody.addProperty("createdBy", createdBy);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.insertPlace(token, placeBody);
|
PlaceService placeService = LocationApiClient.getInstance().getPlaceService();
|
||||||
|
Call<JsonObject> call = placeService.insertPlace(token, placeBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -238,9 +239,10 @@ public class AddNewPlaceActivity extends AppCompatActivity implements View.OnCli
|
||||||
placeBody.addProperty("createdBy", createdBy);
|
placeBody.addProperty("createdBy", createdBy);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.updatePlace(token, uuid, placeBody);
|
PlaceService placeService = LocationApiClient.getInstance().getPlaceService();
|
||||||
|
Call<JsonObject> call = placeService.updatePlace(token, uuid, placeBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ import androidx.appcompat.widget.AppCompatButton;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Place;
|
import com.example.acloc.model.Place;
|
||||||
import com.example.acloc.model.Report;
|
import com.example.acloc.model.Report;
|
||||||
|
import com.example.acloc.service.ReportService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -30,7 +30,6 @@ import com.ieslamar.acloc.R;
|
||||||
import com.google.android.material.textfield.TextInputEditText;
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
@ -95,16 +94,6 @@ public class AddReportActivity extends AppCompatActivity implements View.OnClick
|
||||||
if (placeEntity != null) {
|
if (placeEntity != null) {
|
||||||
place_uuid = placeEntity.getUuid();
|
place_uuid = placeEntity.getUuid();
|
||||||
etPlaceName.setText(placeEntity.getName()); //Just to display place name in report
|
etPlaceName.setText(placeEntity.getName()); //Just to display place name in report
|
||||||
// Log.d(TAG,
|
|
||||||
// "PLACE ENTITY DATA \n " +
|
|
||||||
// "Place uuid: " + placeEntity.getUuid() + "\n " +
|
|
||||||
// "Place name: " + placeEntity.getName() + "\n " +
|
|
||||||
// "Place address: " + placeEntity.getAddress() + "\n " +
|
|
||||||
// "Place created by: " + placeEntity.getCreatedBy() + "\n " +
|
|
||||||
// "Place latitude: " + placeEntity.getLatitude() + "\n " +
|
|
||||||
// "Place longitude: " + placeEntity.getLongitude() + "\n " +
|
|
||||||
// "Place description: " + placeEntity.getDescription() + "\n "
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reportEntity = (Report) getIntent().getSerializableExtra(Constants.REPORT);
|
reportEntity = (Report) getIntent().getSerializableExtra(Constants.REPORT);
|
||||||
|
|
@ -265,9 +254,10 @@ public class AddReportActivity extends AppCompatActivity implements View.OnClick
|
||||||
reportBody.addProperty("createdBy", createdBy);
|
reportBody.addProperty("createdBy", createdBy);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.insertReport(token, reportBody);
|
ReportService reportService = LocationApiClient.getInstance().getReportService();
|
||||||
|
Call<JsonObject> call = reportService.insertReport(token, reportBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -283,10 +273,6 @@ public class AddReportActivity extends AppCompatActivity implements View.OnClick
|
||||||
rlAddReport.postDelayed(() -> {
|
rlAddReport.postDelayed(() -> {
|
||||||
finish();
|
finish();
|
||||||
}, 500);
|
}, 500);
|
||||||
// Delay .5 sec
|
|
||||||
// rlAddReport.postDelayed(() -> {
|
|
||||||
// Helper.goToAndFinish(AddReportActivity.this, MainActivity.class);
|
|
||||||
// }, 500);
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Failed to extract report UUID.");
|
Log.d(TAG, "Failed to extract report UUID.");
|
||||||
Helper.makeSnackBar(rlAddReport, getString(R.string.Something_went_wrong_Try_again));
|
Helper.makeSnackBar(rlAddReport, getString(R.string.Something_went_wrong_Try_again));
|
||||||
|
|
@ -319,9 +305,11 @@ public class AddReportActivity extends AppCompatActivity implements View.OnClick
|
||||||
reportBody.addProperty("createdBy", createdBy);
|
reportBody.addProperty("createdBy", createdBy);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.updateReport(token, uuid, reportBody);
|
// Using the new ReportService through LocationApiClient
|
||||||
|
ReportService reportService = LocationApiClient.getInstance().getReportService();
|
||||||
|
Call<JsonObject> call = reportService.updateReport(token, uuid, reportBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -344,5 +332,4 @@ public class AddReportActivity extends AppCompatActivity implements View.OnClick
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -12,9 +12,9 @@ import androidx.appcompat.widget.AppCompatButton;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import com.example.acloc.MainActivity;
|
import com.example.acloc.MainActivity;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.User;
|
import com.example.acloc.model.User;
|
||||||
|
import com.example.acloc.service.AuthService;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -130,8 +130,8 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||||
jsonParam.addProperty("username", entity.getUsername());
|
jsonParam.addProperty("username", entity.getUsername());
|
||||||
jsonParam.addProperty("password", entity.getPassword());
|
jsonParam.addProperty("password", entity.getPassword());
|
||||||
|
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
AuthService authService = LocationApiClient.getInstance().getAuthService();
|
||||||
Call<JsonObject> call = apiService.loginUser(jsonParam);
|
Call<JsonObject> call = authService.loginUser(jsonParam);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -182,7 +182,6 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Login error reading response", e);
|
Log.e(TAG, "Login error reading response", e);
|
||||||
// Helper.makeSnackBar(rlLogin, getString(R.string.Something_went_wrong));
|
|
||||||
Helper.makeSnackBar(rlLogin, e.toString() + " Try again");
|
Helper.makeSnackBar(rlLogin, e.toString() + " Try again");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -192,10 +191,8 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
||||||
public void onFailure(Call<JsonObject> call, Throwable t) {
|
public void onFailure(Call<JsonObject> call, Throwable t) {
|
||||||
DialogUtils.dismissDialog();
|
DialogUtils.dismissDialog();
|
||||||
Log.e(TAG, "Login API call failed", t);
|
Log.e(TAG, "Login API call failed", t);
|
||||||
// Helper.makeSnackBar(rlLogin, getString(R.string.Something_went_wrong));
|
|
||||||
Helper.makeSnackBar(rlLogin, "Server error: " + t.toString() + " Try again");
|
Helper.makeSnackBar(rlLogin, "Server error: " + t.toString() + " Try again");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,9 +15,9 @@ import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.example.acloc.adapter.UserAdapter;
|
import com.example.acloc.adapter.UserAdapter;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.User;
|
import com.example.acloc.model.User;
|
||||||
|
import com.example.acloc.service.UserService;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -72,7 +72,7 @@ public class ManageRolesActivity extends AppCompatActivity {
|
||||||
if (isDataAvailable) {
|
if (isDataAvailable) {
|
||||||
rvUsers.setVisibility(View.VISIBLE);
|
rvUsers.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
// rvReports.setVisibility(View.GONE);
|
// rvUsers.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,9 +185,10 @@ public class ManageRolesActivity extends AppCompatActivity {
|
||||||
DialogUtils.showLoadingDialog(context, getString(R.string.Loading_users));
|
DialogUtils.showLoadingDialog(context, getString(R.string.Loading_users));
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.getAllUsers(token);
|
UserService userService = LocationApiClient.getInstance().getUserService();
|
||||||
|
Call<JsonObject> call = userService.getAllUsers(token);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,12 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.adapter.PlaceReportsAdapter;
|
import com.example.acloc.adapter.PlaceReportsAdapter;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Place;
|
import com.example.acloc.model.Place;
|
||||||
import com.example.acloc.model.Report;
|
import com.example.acloc.model.Report;
|
||||||
|
import com.example.acloc.service.FavoriteService;
|
||||||
|
import com.example.acloc.service.PlaceService;
|
||||||
|
import com.example.acloc.service.ReportService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -215,9 +217,10 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
||||||
Log.d(TAG, "Request Body: " + body.toString());
|
Log.d(TAG, "Request Body: " + body.toString());
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.addPlaceToFavorites(token, userUuid, body);
|
FavoriteService favoriteService = LocationApiClient.getInstance().getFavoriteService();
|
||||||
|
Call<JsonObject> call = favoriteService.restorePlaceToFavorites(token, userUuid, body);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -264,9 +267,10 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
||||||
body.addProperty("place_uuid", placeUuid);
|
body.addProperty("place_uuid", placeUuid);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.restorePlaceToFavorites(token, userUuid, body);
|
FavoriteService favoriteService = LocationApiClient.getInstance().getFavoriteService();
|
||||||
|
Call<JsonObject> call = favoriteService.restorePlaceToFavorites(token, userUuid, body);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -292,9 +296,10 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
||||||
private void removePlaceFromFavorites(String userUuid, String placeUuid) {
|
private void removePlaceFromFavorites(String userUuid, String placeUuid) {
|
||||||
DialogUtils.showLoadingDialog(context, getString(R.string.Removing_from_favorites));
|
DialogUtils.showLoadingDialog(context, getString(R.string.Removing_from_favorites));
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<Void> call = apiService.removePlaceFromFavorites(token, userUuid, placeUuid);
|
FavoriteService favoriteService = LocationApiClient.getInstance().getFavoriteService();
|
||||||
|
Call<Void> call = favoriteService.removePlaceFromFavorites(token, userUuid, placeUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<Void>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||||
|
|
@ -323,9 +328,10 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
||||||
DialogUtils.showLoadingDialog(context, getString(R.string.Checking_favorite_status));
|
DialogUtils.showLoadingDialog(context, getString(R.string.Checking_favorite_status));
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.getFavoritePlaces(token, userUuid);
|
FavoriteService favoriteService = LocationApiClient.getInstance().getFavoriteService();
|
||||||
|
Call<JsonObject> call = favoriteService.getFavoritePlaces(token, userUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -374,10 +380,10 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
||||||
DialogUtils.showLoadingDialog(context, getString(R.string.Loading_reports));
|
DialogUtils.showLoadingDialog(context, getString(R.string.Loading_reports));
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
// Make the API call to fetch reports by place UUID
|
ReportService reportService = LocationApiClient.getInstance().getReportService();
|
||||||
Call<JsonObject> call = apiService.getPlaceReports(token, placeUuid);
|
Call<JsonObject> call = reportService.getPlaceReports(token, placeUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -426,5 +432,4 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -12,9 +12,9 @@ import androidx.appcompat.widget.AppCompatButton;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.User;
|
import com.example.acloc.model.User;
|
||||||
|
import com.example.acloc.service.AuthService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -116,8 +116,8 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL
|
||||||
jsonParam.addProperty("password", entity.getPassword());
|
jsonParam.addProperty("password", entity.getPassword());
|
||||||
jsonParam.addProperty("fk_role", Constants.ADMIN); //Default Admin for now (BUT acc to api it will be Viewer)
|
jsonParam.addProperty("fk_role", Constants.ADMIN); //Default Admin for now (BUT acc to api it will be Viewer)
|
||||||
|
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
AuthService authService = LocationApiClient.getInstance().getAuthService();
|
||||||
Call<JsonObject> call = apiService.registerUser(jsonParam);
|
Call<JsonObject> call = authService.registerUser(jsonParam);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -145,12 +145,10 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL
|
||||||
Log.e(TAG, "Error Response: " + errorBody);
|
Log.e(TAG, "Error Response: " + errorBody);
|
||||||
Helper.makeSnackBar(rlRegister, "Server Error " + errorBody + " Try again");
|
Helper.makeSnackBar(rlRegister, "Server Error " + errorBody + " Try again");
|
||||||
} else {
|
} else {
|
||||||
// Helper.makeSnackBar(rlRegister, getString(R.string.Something_went_wrong));
|
|
||||||
Helper.makeSnackBar(rlRegister, "Server Error " + " Try again");
|
Helper.makeSnackBar(rlRegister, "Server Error " + " Try again");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Error reading errorBody", e);
|
Log.e(TAG, "Error reading errorBody", e);
|
||||||
// Helper.makeSnackBar(rlRegister, getString(R.string.Something_went_wrong));
|
|
||||||
Helper.makeSnackBar(rlRegister, "API Failure: " + e.toString() + " Try again");
|
Helper.makeSnackBar(rlRegister, "API Failure: " + e.toString() + " Try again");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,10 +158,8 @@ public class RegisterActivity extends AppCompatActivity implements View.OnClickL
|
||||||
public void onFailure(Call<JsonObject> call, Throwable t) {
|
public void onFailure(Call<JsonObject> call, Throwable t) {
|
||||||
DialogUtils.dismissDialog();
|
DialogUtils.dismissDialog();
|
||||||
Log.e(TAG, "API Failure", t);
|
Log.e(TAG, "API Failure", t);
|
||||||
// Helper.makeSnackBar(rlRegister, getString(R.string.Something_went_wrong));
|
|
||||||
Helper.makeSnackBar(rlRegister, "API Failure: " + t.toString() + " Try again");
|
Helper.makeSnackBar(rlRegister, "API Failure: " + t.toString() + " Try again");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,10 +16,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.activity.PlaceDetailActivity;
|
import com.example.acloc.activity.PlaceDetailActivity;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Favorite;
|
import com.example.acloc.model.Favorite;
|
||||||
import com.example.acloc.model.Place;
|
import com.example.acloc.model.Place;
|
||||||
|
import com.example.acloc.service.FavoriteService;
|
||||||
|
import com.example.acloc.service.PlaceService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -102,9 +103,10 @@ public class FavoriteAdapter extends RecyclerView.Adapter<FavoriteAdapter.ViewHo
|
||||||
private void removePlaceFromFavorites(String userUuid, String placeUuid, String favoriteUuid) {
|
private void removePlaceFromFavorites(String userUuid, String placeUuid, String favoriteUuid) {
|
||||||
DialogUtils.showLoadingDialog(context, context.getString(R.string.Removing_from_favorites));
|
DialogUtils.showLoadingDialog(context, context.getString(R.string.Removing_from_favorites));
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<Void> call = apiService.removePlaceFromFavorites(token, userUuid, placeUuid);
|
FavoriteService favoriteService = LocationApiClient.getInstance().getFavoriteService();
|
||||||
|
Call<Void> call = favoriteService.removePlaceFromFavorites(token, userUuid, placeUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<Void>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||||
|
|
@ -149,9 +151,10 @@ public class FavoriteAdapter extends RecyclerView.Adapter<FavoriteAdapter.ViewHo
|
||||||
DialogUtils.showLoadingDialog(context, context.getString(R.string.Please_wait));
|
DialogUtils.showLoadingDialog(context, context.getString(R.string.Please_wait));
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.getPlaceFromUuid(token, placeUuid);
|
PlaceService placeService = LocationApiClient.getInstance().getPlaceService();
|
||||||
|
Call<JsonObject> call = placeService.getPlaceFromUuid(token, placeUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -175,12 +178,9 @@ public class FavoriteAdapter extends RecyclerView.Adapter<FavoriteAdapter.ViewHo
|
||||||
}
|
}
|
||||||
Helper.goTo(context, PlaceDetailActivity.class, Constants.PLACE, place);
|
Helper.goTo(context, PlaceDetailActivity.class, Constants.PLACE, place);
|
||||||
} else {
|
} else {
|
||||||
// Helper.makeSnackBar(rlPlaceDetails, getString(R.string.No_reports_found));
|
|
||||||
Log.e(TAG, "No place found");
|
Log.e(TAG, "No place found");
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Helper.makeSnackBar(rlPlaceDetails, getString(R.string.Failed_to_load_reports_Try_again_));
|
|
||||||
Log.e(TAG, "Get Reports Error: " + response.code());
|
Log.e(TAG, "Get Reports Error: " + response.code());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -189,9 +189,7 @@ public class FavoriteAdapter extends RecyclerView.Adapter<FavoriteAdapter.ViewHo
|
||||||
public void onFailure(Call<JsonObject> call, Throwable t) {
|
public void onFailure(Call<JsonObject> call, Throwable t) {
|
||||||
DialogUtils.dismissDialog();
|
DialogUtils.dismissDialog();
|
||||||
Log.e(TAG, "Get Reports Failure: ", t);
|
Log.e(TAG, "Get Reports Failure: ", t);
|
||||||
// Helper.makeSnackBar(rlPlaceDetails, context.getString(R.string.Network_error_Try_again));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.activity.AddReportActivity;
|
import com.example.acloc.activity.AddReportActivity;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Report;
|
import com.example.acloc.model.Report;
|
||||||
|
import com.example.acloc.service.ReportService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -124,9 +124,10 @@ public class MyReportsAdapter extends RecyclerView.Adapter<MyReportsAdapter.View
|
||||||
private void removeReport(String reportUuid) {
|
private void removeReport(String reportUuid) {
|
||||||
DialogUtils.showLoadingDialog(context, context.getString(R.string.Removing_Report));
|
DialogUtils.showLoadingDialog(context, context.getString(R.string.Removing_Report));
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<Void> call = apiService.removeReport(token, reportUuid);
|
ReportService reportService = LocationApiClient.getInstance().getReportService();
|
||||||
|
Call<Void> call = reportService.removeReport(token, reportUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<Void>() {
|
call.enqueue(new Callback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<Void> call, Response<Void> response) {
|
public void onResponse(Call<Void> call, Response<Void> response) {
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.activity.ManageRolesActivity;
|
import com.example.acloc.activity.ManageRolesActivity;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.User;
|
import com.example.acloc.model.User;
|
||||||
|
import com.example.acloc.service.UserService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -126,9 +126,11 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
|
||||||
userBody.addProperty("role", fkRole);
|
userBody.addProperty("role", fkRole);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.updateRole(token, uuid, userBody);
|
// Using the new UserService through LocationApiClient
|
||||||
|
UserService userService = LocationApiClient.getInstance().getUserService();
|
||||||
|
Call<JsonObject> call = userService.updateRole(token, uuid, userBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
package com.example.acloc.api;
|
|
||||||
|
|
||||||
import static com.example.acloc.utility.Constants.BASE_URL;
|
|
||||||
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
|
||||||
|
|
||||||
public class ApiClient {
|
|
||||||
private static Retrofit retrofit;
|
|
||||||
|
|
||||||
public static Retrofit getClient() {
|
|
||||||
if (retrofit == null) {
|
|
||||||
retrofit = new Retrofit.Builder()
|
|
||||||
.baseUrl(BASE_URL)
|
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
return retrofit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
package com.example.acloc.api;
|
||||||
|
|
||||||
|
import static com.example.acloc.utility.Constants.BASE_URL;
|
||||||
|
|
||||||
|
import com.example.acloc.service.AuthService;
|
||||||
|
import com.example.acloc.service.FavoriteService;
|
||||||
|
import com.example.acloc.service.PlaceService;
|
||||||
|
import com.example.acloc.service.ReportService;
|
||||||
|
import com.example.acloc.service.RoleService;
|
||||||
|
import com.example.acloc.service.UserService;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Centralized API client that manages Retrofit instance and provides access to all service interfaces
|
||||||
|
*/
|
||||||
|
public class LocationApiClient {
|
||||||
|
private static LocationApiClient instance;
|
||||||
|
private final Retrofit retrofit;
|
||||||
|
|
||||||
|
// Service interface instances
|
||||||
|
private AuthService authService;
|
||||||
|
private FavoriteService favoriteService;
|
||||||
|
private PlaceService placeService;
|
||||||
|
private ReportService reportService;
|
||||||
|
private RoleService roleService;
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
// Private constructor for singleton pattern
|
||||||
|
private LocationApiClient() {
|
||||||
|
this.retrofit = RetrofitProvider.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the singleton instance of RetrofitClient
|
||||||
|
* @return RetrofitClient instance
|
||||||
|
*/
|
||||||
|
public static synchronized LocationApiClient getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new LocationApiClient();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the AuthService interface
|
||||||
|
* @return AuthService implementation
|
||||||
|
*/
|
||||||
|
public AuthService getAuthService() {
|
||||||
|
if (authService == null) {
|
||||||
|
authService = retrofit.create(AuthService.class);
|
||||||
|
}
|
||||||
|
return authService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the FavoriteService interface
|
||||||
|
* @return FavoriteService implementation
|
||||||
|
*/
|
||||||
|
public FavoriteService getFavoriteService() {
|
||||||
|
if (favoriteService == null) {
|
||||||
|
favoriteService = retrofit.create(FavoriteService.class);
|
||||||
|
}
|
||||||
|
return favoriteService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the PlaceService interface
|
||||||
|
* @return PlaceService implementation
|
||||||
|
*/
|
||||||
|
public PlaceService getPlaceService() {
|
||||||
|
if (placeService == null) {
|
||||||
|
placeService = retrofit.create(PlaceService.class);
|
||||||
|
}
|
||||||
|
return placeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ReportService interface
|
||||||
|
* @return ReportService implementation
|
||||||
|
*/
|
||||||
|
public ReportService getReportService() {
|
||||||
|
if (reportService == null) {
|
||||||
|
reportService = retrofit.create(ReportService.class);
|
||||||
|
}
|
||||||
|
return reportService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the RoleService interface
|
||||||
|
* @return RoleService implementation
|
||||||
|
*/
|
||||||
|
public RoleService getRoleService() {
|
||||||
|
if (roleService == null) {
|
||||||
|
roleService = retrofit.create(RoleService.class);
|
||||||
|
}
|
||||||
|
return roleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the UserService interface
|
||||||
|
* @return UserService implementation
|
||||||
|
*/
|
||||||
|
public UserService getUserService() {
|
||||||
|
if (userService == null) {
|
||||||
|
userService = retrofit.create(UserService.class);
|
||||||
|
}
|
||||||
|
return userService;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.example.acloc.api;
|
||||||
|
|
||||||
|
import static com.example.acloc.utility.Constants.BASE_URL;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.logging.HttpLoggingInterceptor;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
|
public class RetrofitProvider {
|
||||||
|
private static final int TIMEOUT_SECONDS = 30;
|
||||||
|
private static Retrofit retrofit;
|
||||||
|
|
||||||
|
public static Retrofit getInstance() {
|
||||||
|
if (retrofit == null) {
|
||||||
|
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
|
||||||
|
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
|
||||||
|
|
||||||
|
OkHttpClient client = new OkHttpClient.Builder()
|
||||||
|
.addInterceptor(logging)
|
||||||
|
.connectTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
retrofit = new Retrofit.Builder()
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
|
.client(client)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
return retrofit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,8 +13,9 @@ import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.AppCompatButton;
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
import com.example.acloc.service.AuthService;
|
||||||
|
import com.example.acloc.service.UserService;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -107,8 +108,8 @@ public class AlertChangePasswordDialog implements View.OnClickListener {
|
||||||
loginBody.addProperty("username", username);
|
loginBody.addProperty("username", username);
|
||||||
loginBody.addProperty("password", oldPassword);
|
loginBody.addProperty("password", oldPassword);
|
||||||
|
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
AuthService authService = LocationApiClient.getInstance().getAuthService();
|
||||||
Call<JsonObject> call = apiService.verifyOldPassword(loginBody);
|
Call<JsonObject> call = authService.verifyOldPassword(loginBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -140,8 +141,8 @@ public class AlertChangePasswordDialog implements View.OnClickListener {
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
|
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
UserService userService = LocationApiClient.getInstance().getUserService();
|
||||||
Call<JsonObject> call = apiService.changePassword(token, uuid, body);
|
Call<JsonObject> call = userService.changePassword(token, uuid, body);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
|
||||||
import com.example.acloc.MainActivity;
|
import com.example.acloc.MainActivity;
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
import com.example.acloc.service.PlaceService;
|
||||||
import com.example.acloc.model.Place;
|
import com.example.acloc.model.Place;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -127,7 +127,6 @@ public class AlertViewAddNewPlaceDialog implements View.OnClickListener {
|
||||||
insertPlaceRetrofit(entity.getName(), entity.getDescription(),
|
insertPlaceRetrofit(entity.getName(), entity.getDescription(),
|
||||||
entity.getAddress(), entity.getLatitude(), entity.getLongitude(), entity.getCreatedBy());
|
entity.getAddress(), entity.getLatitude(), entity.getLongitude(), entity.getCreatedBy());
|
||||||
}
|
}
|
||||||
// Helper.goTo(context, AddReportActivity.class, Constants.PLACE, entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,9 +153,10 @@ public class AlertViewAddNewPlaceDialog implements View.OnClickListener {
|
||||||
placeBody.addProperty("createdBy", createdBy);
|
placeBody.addProperty("createdBy", createdBy);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.insertPlace(token, placeBody);
|
PlaceService placeService = LocationApiClient.getInstance().getPlaceService();
|
||||||
|
Call<JsonObject> call = placeService.insertPlace(token, placeBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -204,9 +204,10 @@ public class AlertViewAddNewPlaceDialog implements View.OnClickListener {
|
||||||
placeBody.addProperty("createdBy", createdBy);
|
placeBody.addProperty("createdBy", createdBy);
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.updatePlace(token, uuid, placeBody);
|
PlaceService placeService = LocationApiClient.getInstance().getPlaceService();
|
||||||
|
Call<JsonObject> call = placeService.updatePlace(token, uuid, placeBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -229,6 +230,4 @@ public class AlertViewAddNewPlaceDialog implements View.OnClickListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.AppCompatButton;
|
import androidx.appcompat.widget.AppCompatButton;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
import com.example.acloc.service.UserService;
|
||||||
import com.example.acloc.model.User;
|
import com.example.acloc.model.User;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
|
|
@ -137,8 +137,8 @@ public class AlertViewOrUpdateProfileDialog implements View.OnClickListener {
|
||||||
String accessToken = SharedPref.getAccessToken(context);
|
String accessToken = SharedPref.getAccessToken(context);
|
||||||
String bearerToken = "Bearer " + accessToken;
|
String bearerToken = "Bearer " + accessToken;
|
||||||
|
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
UserService userService = LocationApiClient.getInstance().getUserService();
|
||||||
Call<JsonObject> call = apiService.updateUser(bearerToken, uuid, jsonBody);
|
Call<JsonObject> call = userService.updateUser(bearerToken, uuid, jsonBody);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -175,5 +175,4 @@ public class AlertViewOrUpdateProfileDialog implements View.OnClickListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -17,9 +17,9 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.adapter.FavoriteAdapter;
|
import com.example.acloc.adapter.FavoriteAdapter;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Favorite;
|
import com.example.acloc.model.Favorite;
|
||||||
|
import com.example.acloc.service.FavoriteService;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -135,9 +135,10 @@ public class FavoriteFragment extends Fragment {
|
||||||
DialogUtils.showLoadingDialog(context, context.getString(R.string.Loading_Favorites));
|
DialogUtils.showLoadingDialog(context, context.getString(R.string.Loading_Favorites));
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.getUserFavorites(token, userUuid);
|
FavoriteService favoriteService = LocationApiClient.getInstance().getFavoriteService();
|
||||||
|
Call<JsonObject> call = favoriteService.getFavoritePlaces(token, userUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -191,6 +192,4 @@ public class FavoriteFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -28,8 +28,9 @@ import android.widget.RelativeLayout;
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.activity.AddNewPlaceActivity;
|
import com.example.acloc.activity.AddNewPlaceActivity;
|
||||||
import com.example.acloc.activity.PlaceDetailActivity;
|
import com.example.acloc.activity.PlaceDetailActivity;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.model.Place;
|
import com.example.acloc.model.Place;
|
||||||
|
import com.example.acloc.service.PlaceService;
|
||||||
import com.example.acloc.utility.Constants;
|
import com.example.acloc.utility.Constants;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -54,9 +55,6 @@ import okhttp3.ResponseBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public class MapFragment extends Fragment {
|
public class MapFragment extends Fragment {
|
||||||
public static final String TAG = MapFragment.class.getSimpleName();
|
public static final String TAG = MapFragment.class.getSimpleName();
|
||||||
|
|
@ -170,15 +168,6 @@ public class MapFragment extends Fragment {
|
||||||
if (existingPlace != null) {
|
if (existingPlace != null) {
|
||||||
Helper.goTo(getContext(), PlaceDetailActivity.class, Constants.PLACE, existingPlace); //Navigate to PlaceDetailActivity if the place already exists
|
Helper.goTo(getContext(), PlaceDetailActivity.class, Constants.PLACE, existingPlace); //Navigate to PlaceDetailActivity if the place already exists
|
||||||
return;
|
return;
|
||||||
//
|
|
||||||
// dialog = new AlertViewAddNewPlaceDialog(requireContext(),
|
|
||||||
// Double.parseDouble(existingPlace.getLatitude()),
|
|
||||||
// Double.parseDouble(existingPlace.getLongitude()),
|
|
||||||
// existingPlace.getName(),
|
|
||||||
// existingPlace.getAddress(),
|
|
||||||
// existingPlace.getDescription(),
|
|
||||||
// existingPlace.getUuid())
|
|
||||||
// .openPlaceDialog();
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
List<Address> addressList = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1);
|
List<Address> addressList = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1);
|
||||||
|
|
@ -187,15 +176,6 @@ public class MapFragment extends Fragment {
|
||||||
String addressLine = address.getAddressLine(0);
|
String addressLine = address.getAddressLine(0);
|
||||||
String placeName = address.getFeatureName();
|
String placeName = address.getFeatureName();
|
||||||
|
|
||||||
// dialog = new AlertViewAddNewPlaceDialog(requireContext(),
|
|
||||||
// latLng.latitude,
|
|
||||||
// latLng.longitude,
|
|
||||||
// placeName,
|
|
||||||
// addressLine,
|
|
||||||
// "", // Empty description
|
|
||||||
// null // UUID
|
|
||||||
// ).openPlaceDialog();
|
|
||||||
|
|
||||||
Place placeEntity = new Place();
|
Place placeEntity = new Place();
|
||||||
placeEntity.setLatitude(String.valueOf(latLng.latitude));
|
placeEntity.setLatitude(String.valueOf(latLng.latitude));
|
||||||
placeEntity.setLongitude(String.valueOf(latLng.longitude));
|
placeEntity.setLongitude(String.valueOf(latLng.longitude));
|
||||||
|
|
@ -261,9 +241,6 @@ public class MapFragment extends Fragment {
|
||||||
|
|
||||||
private void showNearbyPlaces(LatLng latLng) {
|
private void showNearbyPlaces(LatLng latLng) {
|
||||||
googleMap.clear();
|
googleMap.clear();
|
||||||
// googleMap.addMarker(new MarkerOptions()
|
|
||||||
// .position(latLng)
|
|
||||||
// .title("You are here"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchLocationByAddress(String address) {
|
private void searchLocationByAddress(String address) {
|
||||||
|
|
@ -317,13 +294,8 @@ public class MapFragment extends Fragment {
|
||||||
private void fetchAndShowAllPlaces() {
|
private void fetchAndShowAllPlaces() {
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context); // get saved token
|
String token = "Bearer " + SharedPref.getAccessToken(context); // get saved token
|
||||||
|
|
||||||
Retrofit retrofit = new Retrofit.Builder()
|
PlaceService placeService = LocationApiClient.getInstance().getPlaceService();
|
||||||
.baseUrl("https://locationapi-m13l.onrender.com/")
|
Call<ResponseBody> call = placeService.getAllPlaces(token);
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
ApiService apiService = retrofit.create(ApiService.class);
|
|
||||||
Call<ResponseBody> call = apiService.getAllPlaces(token);
|
|
||||||
|
|
||||||
call.enqueue(new Callback<ResponseBody>() {
|
call.enqueue(new Callback<ResponseBody>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ import android.widget.TextView;
|
||||||
import com.example.acloc.MainActivity;
|
import com.example.acloc.MainActivity;
|
||||||
import com.ieslamar.acloc.R;
|
import com.ieslamar.acloc.R;
|
||||||
import com.example.acloc.adapter.MyReportsAdapter;
|
import com.example.acloc.adapter.MyReportsAdapter;
|
||||||
import com.example.acloc.api.ApiClient;
|
import com.example.acloc.api.LocationApiClient;
|
||||||
import com.example.acloc.interfaces.ApiService;
|
|
||||||
import com.example.acloc.model.Report;
|
import com.example.acloc.model.Report;
|
||||||
|
import com.example.acloc.service.ReportService;
|
||||||
import com.example.acloc.utility.DialogUtils;
|
import com.example.acloc.utility.DialogUtils;
|
||||||
import com.example.acloc.utility.Helper;
|
import com.example.acloc.utility.Helper;
|
||||||
import com.example.acloc.utility.SharedPref;
|
import com.example.acloc.utility.SharedPref;
|
||||||
|
|
@ -152,9 +152,10 @@ public class MyReportsFragment extends Fragment implements View.OnClickListener
|
||||||
DialogUtils.showLoadingDialog(context, getString(R.string.Loading_reports));
|
DialogUtils.showLoadingDialog(context, getString(R.string.Loading_reports));
|
||||||
|
|
||||||
String token = "Bearer " + SharedPref.getAccessToken(context);
|
String token = "Bearer " + SharedPref.getAccessToken(context);
|
||||||
ApiService apiService = ApiClient.getClient().create(ApiService.class);
|
|
||||||
|
|
||||||
Call<JsonObject> call = apiService.getUserReports(token, userUuid);
|
ReportService reportService = LocationApiClient.getInstance().getReportService();
|
||||||
|
Call<JsonObject> call = reportService.getUserReports(token, userUuid);
|
||||||
|
|
||||||
call.enqueue(new Callback<JsonObject>() {
|
call.enqueue(new Callback<JsonObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
|
||||||
|
|
@ -205,5 +206,4 @@ public class MyReportsFragment extends Fragment implements View.OnClickListener
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,139 +0,0 @@
|
||||||
package com.example.acloc.interfaces;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.http.Body;
|
|
||||||
import retrofit2.http.DELETE;
|
|
||||||
import retrofit2.http.GET;
|
|
||||||
import retrofit2.http.Header;
|
|
||||||
import retrofit2.http.POST;
|
|
||||||
import retrofit2.http.PUT;
|
|
||||||
import retrofit2.http.Path;
|
|
||||||
|
|
||||||
public interface ApiService {
|
|
||||||
@POST("signin")
|
|
||||||
Call<JsonObject> registerUser(@Body JsonObject userData);
|
|
||||||
|
|
||||||
@POST("login")
|
|
||||||
Call<JsonObject> loginUser(@Body JsonObject body);
|
|
||||||
|
|
||||||
@PUT("users/{uuid}")
|
|
||||||
Call<JsonObject> updateUser(
|
|
||||||
@Header("Authorization") String bearerToken,
|
|
||||||
@Path("uuid") String uuid,
|
|
||||||
@Body JsonObject body
|
|
||||||
);
|
|
||||||
|
|
||||||
@POST("login")
|
|
||||||
Call<JsonObject> verifyOldPassword(@Body JsonObject loginBody);
|
|
||||||
|
|
||||||
@PUT("users/{uuid}")
|
|
||||||
Call<JsonObject> changePassword(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("uuid") String uuid,
|
|
||||||
@Body JsonObject body
|
|
||||||
);
|
|
||||||
|
|
||||||
@POST("places")
|
|
||||||
Call<JsonObject> insertPlace(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Body JsonObject body
|
|
||||||
);
|
|
||||||
|
|
||||||
@POST("report_types")
|
|
||||||
Call<JsonObject> insertReportType(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Body JsonObject body
|
|
||||||
);
|
|
||||||
|
|
||||||
@PUT("places/{uuid}")
|
|
||||||
Call<JsonObject> updatePlace(@Header("Authorization") String token,
|
|
||||||
@Path("uuid") String uuid,
|
|
||||||
@Body JsonObject placeData);
|
|
||||||
|
|
||||||
|
|
||||||
@GET("places")
|
|
||||||
Call<ResponseBody> getAllPlaces(@Header("Authorization") String token);
|
|
||||||
|
|
||||||
@POST("users/{user_uuid}/places")
|
|
||||||
Call<JsonObject> addPlaceToFavorites(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("user_uuid") String userUuid,
|
|
||||||
@Body JsonObject placeBody
|
|
||||||
);
|
|
||||||
|
|
||||||
@DELETE("users/{user_uuid}/places/{place_uuid}")
|
|
||||||
Call<Void> removePlaceFromFavorites(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("user_uuid") String userUuid,
|
|
||||||
@Path("place_uuid") String placeUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
@GET("users/{user_uuid}/places")
|
|
||||||
Call<JsonObject> getFavoritePlaces(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("user_uuid") String userUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
@PUT("users/{user_uuid}/places")
|
|
||||||
Call<JsonObject> restorePlaceToFavorites(
|
|
||||||
@Header("Authorization") String authToken,
|
|
||||||
@Path("user_uuid") String userUuid,
|
|
||||||
@Body JsonObject body
|
|
||||||
);
|
|
||||||
|
|
||||||
@POST("reports")
|
|
||||||
Call<JsonObject> insertReport(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Body JsonObject reportBody
|
|
||||||
);
|
|
||||||
|
|
||||||
@GET("users/{user_uuid}/reports")
|
|
||||||
Call<JsonObject> getUserReports(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("user_uuid") String userUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
@DELETE("reports/{report_uuid}")
|
|
||||||
Call<Void> removeReport(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("report_uuid") String reportUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
@PUT("/reports/{uuid}")
|
|
||||||
Call<JsonObject> updateReport(@Header("Authorization") String token,
|
|
||||||
@Path("uuid") String uuid,
|
|
||||||
@Body JsonObject placeData);
|
|
||||||
|
|
||||||
@GET("places/{place_uuid}/reports")
|
|
||||||
Call<JsonObject> getPlaceReports(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("place_uuid") String placeUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
@GET("users/{user_uuid}/places")
|
|
||||||
Call<JsonObject> getUserFavorites(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("user_uuid") String userUuid
|
|
||||||
);
|
|
||||||
|
|
||||||
@GET("roles")
|
|
||||||
Call<JsonObject> getRoles(@Header("Authorization") String token);
|
|
||||||
|
|
||||||
@GET("users")
|
|
||||||
Call<JsonObject> getAllUsers(@Header("Authorization") String token);
|
|
||||||
|
|
||||||
|
|
||||||
@PUT("users/{uuid}")
|
|
||||||
Call<JsonObject> updateRole(@Header("Authorization") String token,
|
|
||||||
@Path("uuid") String uuid,
|
|
||||||
@Body JsonObject userData);
|
|
||||||
|
|
||||||
@GET("places/{uuid}")
|
|
||||||
Call<JsonObject> getPlaceFromUuid(
|
|
||||||
@Header("Authorization") String token,
|
|
||||||
@Path("uuid") String uuid
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.example.acloc.service;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
|
||||||
|
public interface AuthService {
|
||||||
|
/**
|
||||||
|
* User registration endpoint
|
||||||
|
* @param userData User data
|
||||||
|
* @return JsonObject containing user information from signup
|
||||||
|
*/
|
||||||
|
@POST("signin")
|
||||||
|
Call<JsonObject> registerUser(@Body JsonObject userData);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User login endpoint
|
||||||
|
* @param body Login data (username and password)
|
||||||
|
* @return JsonObject containing user information from login
|
||||||
|
*/
|
||||||
|
@POST("login")
|
||||||
|
Call<JsonObject> loginUser(@Body JsonObject body);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify old password endpoint (specifically made for password reset)
|
||||||
|
* @param loginBody Login data (username and password)
|
||||||
|
* @return JsonObject containing user information from login
|
||||||
|
*/
|
||||||
|
@POST("login")
|
||||||
|
Call<JsonObject> verifyOldPassword(@Body JsonObject loginBody);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.example.acloc.service;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.DELETE;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.PUT;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
|
||||||
|
public interface FavoriteService {
|
||||||
|
/**
|
||||||
|
* Deletes a place from user's favorite places
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param userUuid User UUID
|
||||||
|
* @param placeUuid Place UUID
|
||||||
|
* @return Void (No response)
|
||||||
|
*/
|
||||||
|
@DELETE("users/{user_uuid}/places/{place_uuid}")
|
||||||
|
Call<Void> removePlaceFromFavorites(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("user_uuid") String userUuid,
|
||||||
|
@Path("place_uuid") String placeUuid
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains all favorite places from user
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param userUuid User UUID
|
||||||
|
* @return JsonObject containing all favorite places
|
||||||
|
*/
|
||||||
|
@GET("users/{user_uuid}/places")
|
||||||
|
Call<JsonObject> getFavoritePlaces(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("user_uuid") String userUuid
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restores a place to favorite places for user
|
||||||
|
* @param authToken Bearer token
|
||||||
|
* @param userUuid User UUID
|
||||||
|
* @param body Data to modify (favorite)
|
||||||
|
* @return JsonObject containing place information
|
||||||
|
*/
|
||||||
|
@PUT("users/{user_uuid}/places")
|
||||||
|
Call<JsonObject> restorePlaceToFavorites(
|
||||||
|
@Header("Authorization") String authToken,
|
||||||
|
@Path("user_uuid") String userUuid,
|
||||||
|
@Body JsonObject body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.example.acloc.service;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
import retrofit2.http.PUT;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
|
public interface PlaceService {
|
||||||
|
/**
|
||||||
|
* Inserts a new place into database
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param body Place data
|
||||||
|
* @return JsonObject containing place information
|
||||||
|
*/
|
||||||
|
@POST("places")
|
||||||
|
Call<JsonObject> insertPlace(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Body JsonObject body
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing place in the database
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param uuid Place UUID
|
||||||
|
* @param placeData Place data
|
||||||
|
* @return JsonObject containing place information
|
||||||
|
*/
|
||||||
|
@PUT("places/{uuid}")
|
||||||
|
Call<JsonObject> updatePlace(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("uuid") String uuid,
|
||||||
|
@Body JsonObject placeData
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains all places from database
|
||||||
|
* @param token Bearer token
|
||||||
|
* @return JsonObject containing all places
|
||||||
|
*/
|
||||||
|
@GET("places")
|
||||||
|
Call<ResponseBody> getAllPlaces(@Header("Authorization") String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains all places that match the query
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param query Search term to be matched
|
||||||
|
* @return JsonObject containing all places that match the query
|
||||||
|
*/
|
||||||
|
@GET("places")
|
||||||
|
Call<ResponseBody> getSearchPlaces(@Header("Authorization") String token,
|
||||||
|
@Query("query") String query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains a place from its UUID
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param uuid Place UUID
|
||||||
|
* @return JsonObject containing place information
|
||||||
|
*/
|
||||||
|
@GET("places/{uuid}")
|
||||||
|
Call<JsonObject> getPlaceFromUuid(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("uuid") String uuid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
package com.example.acloc.service;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.DELETE;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
import retrofit2.http.PUT;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
|
||||||
|
public interface ReportService {
|
||||||
|
/**
|
||||||
|
* Obtains all reports from a place
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param placeUuid Place UUID
|
||||||
|
* @return JsonObject containing all reports
|
||||||
|
*/
|
||||||
|
@GET("places/{place_uuid}/reports")
|
||||||
|
Call<JsonObject> getPlaceReports(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("place_uuid") String placeUuid
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains a user's reports
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param userUuid User UUID
|
||||||
|
* @return JSON Object containing report information
|
||||||
|
*/
|
||||||
|
@GET("users/{user_uuid}/reports")
|
||||||
|
Call<JsonObject> getUserReports(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("user_uuid") String userUuid
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts a new report
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param reportBody report data
|
||||||
|
* @return JsonObject containing report information
|
||||||
|
*/
|
||||||
|
@POST("reports")
|
||||||
|
Call<JsonObject> insertReport(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Body JsonObject reportBody
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a report from database (soft delete)
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param reportUuid Report UUID
|
||||||
|
* @return Void (No response)
|
||||||
|
*/
|
||||||
|
@DELETE("reports/{report_uuid}")
|
||||||
|
Call<Void> removeReport(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("report_uuid") String reportUuid
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing report in database
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param uuid Report UUID
|
||||||
|
* @param reportData Report data containing parameters to modify
|
||||||
|
* @return JsonObject containing updated report information
|
||||||
|
*/
|
||||||
|
@PUT("/reports/{uuid}")
|
||||||
|
Call<JsonObject> updateReport(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("uuid") String uuid,
|
||||||
|
@Body JsonObject reportData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.example.acloc.service;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
|
||||||
|
public interface RoleService {
|
||||||
|
/**
|
||||||
|
* Obtains all roles from database
|
||||||
|
* @param token Bearer token
|
||||||
|
* @return JsonObject containing all roles
|
||||||
|
*/
|
||||||
|
@GET("roles")
|
||||||
|
Call<JsonObject> getRoles(@Header("Authorization") String token);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.example.acloc.service;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.Body;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.PUT;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
/**
|
||||||
|
* Updates user data
|
||||||
|
* @param bearerToken Bearer token
|
||||||
|
* @param uuid User UUID
|
||||||
|
* @param body Parameters to modify
|
||||||
|
* @return JsonObject containing user information
|
||||||
|
*/
|
||||||
|
@PUT("users/{uuid}")
|
||||||
|
Call<JsonObject> updateUser(
|
||||||
|
@Header("Authorization") String bearerToken,
|
||||||
|
@Path("uuid") String uuid,
|
||||||
|
@Body JsonObject body
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes user password
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param uuid User UUID
|
||||||
|
* @param body Parameters to modify
|
||||||
|
* @return JsonObject containing user information
|
||||||
|
*/
|
||||||
|
@PUT("users/{uuid}")
|
||||||
|
Call<JsonObject> changePassword(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("uuid") String uuid,
|
||||||
|
@Body JsonObject body
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtains all users from database
|
||||||
|
* @param token Bearer token
|
||||||
|
* @return JsonObject containing all users
|
||||||
|
*/
|
||||||
|
@GET("users")
|
||||||
|
Call<JsonObject> getAllUsers(@Header("Authorization") String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates user role (only admins)
|
||||||
|
* @param token Bearer token
|
||||||
|
* @param uuid User UUID
|
||||||
|
* @param userData User data to modify (role)
|
||||||
|
* @return JsonObject containing user information
|
||||||
|
*/
|
||||||
|
@PUT("users/{uuid}")
|
||||||
|
Call<JsonObject> updateRole(
|
||||||
|
@Header("Authorization") String token,
|
||||||
|
@Path("uuid") String uuid,
|
||||||
|
@Body JsonObject userData
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue