Implement feedbacks

master
saad.siddiq 2024-11-29 17:45:55 +05:00
parent 6a3940677d
commit 451fd5539a
8 changed files with 54 additions and 13 deletions

View File

@ -152,7 +152,12 @@ public class ContainerDetailActivity extends AppCompatActivity {
}); });
homeViewModel.getErrorMessage().observe(this, errorResponse -> { homeViewModel.getErrorMessage().observe(this, errorResponse -> {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show(); if (errorResponse.isEmpty()) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
}
}); });
homeViewModel.getPickLiveData().observe(this, pickResponse -> { homeViewModel.getPickLiveData().observe(this, pickResponse -> {

View File

@ -2,6 +2,7 @@ package com.utopiaindustries.selftrucking.Activities.dashboardScreens.apiservice
import com.utopiaindustries.selftrucking.models.Container; import com.utopiaindustries.selftrucking.models.Container;
import com.utopiaindustries.selftrucking.models.DriverResponse; import com.utopiaindustries.selftrucking.models.DriverResponse;
import com.utopiaindustries.selftrucking.models.LoginRequest;
import com.utopiaindustries.selftrucking.models.PickResponse; import com.utopiaindustries.selftrucking.models.PickResponse;
import com.utopiaindustries.selftrucking.models.PickupRequest; import com.utopiaindustries.selftrucking.models.PickupRequest;
@ -22,8 +23,7 @@ public interface ApiService {
@GET("rest/application/authenticate-user") @GET("rest/application/authenticate-user")
Call<DriverResponse> isUserAuthenticated( Call<DriverResponse> isUserAuthenticated(
@Query("username") String username, @Body LoginRequest request
@Query("password") String password
); );

View File

@ -11,7 +11,9 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClient { public class RetrofitClient {
private final static String BASE_URL = "http://192.168.90.228:8080/cosmos/";//"http://192.168.90.27:8080/uind/"; //"https://cosmos.utopiadeals.com/cosmos/";
//http://192.168.90.228:8080/cosmos/
private final static String BASE_URL = "https://cosmos.utopiadeals.com/cosmos/";
private static Retrofit retrofit; private static Retrofit retrofit;

View File

@ -20,6 +20,7 @@ import com.utopiaindustries.selftrucking.Activities.loginScreens.viewModels.Logi
import com.utopiaindustries.selftrucking.R; import com.utopiaindustries.selftrucking.R;
import com.utopiaindustries.selftrucking.helper.Helper; import com.utopiaindustries.selftrucking.helper.Helper;
import com.utopiaindustries.selftrucking.helper.Preference; import com.utopiaindustries.selftrucking.helper.Preference;
import com.utopiaindustries.selftrucking.models.LoginRequest;
import com.utopiaindustries.selftrucking.utils.ProgressDialogFragment; import com.utopiaindustries.selftrucking.utils.ProgressDialogFragment;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
@ -40,15 +41,17 @@ public class LoginActivity extends AppCompatActivity {
return insets; return insets;
}); });
if( !Helper.isNetworkConnected(this) ){ if (!Helper.isNetworkConnected(this)) {
Toast.makeText( this, "No Internet Connection", Toast.LENGTH_LONG ).show(); Toast.makeText(this, "No Internet Connection", Toast.LENGTH_LONG).show();
} }
initializeLayouts(); initializeLayouts();
btnLogin.setOnClickListener(v -> { btnLogin.setOnClickListener(v -> {
if (isValidate()) { if (isValidate()) {
loginViewModel.authenticateUser(tfEmail.getText().toString(), tfPassword.getText().toString()); LoginRequest loginRequest = new LoginRequest(tfEmail.getText().toString(),
tfPassword.getText().toString());
loginViewModel.authenticateUser(loginRequest);
} }
}); });
@ -74,7 +77,12 @@ public class LoginActivity extends AppCompatActivity {
}); });
loginViewModel.getErrorMessage().observe(this, errorResponse -> { loginViewModel.getErrorMessage().observe(this, errorResponse -> {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show(); if (errorResponse.isEmpty()) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, errorResponse, Toast.LENGTH_SHORT).show();
}
}); });
loginViewModel.getUserLiveData().observe(this, user -> { loginViewModel.getUserLiveData().observe(this, user -> {

View File

@ -1,5 +1,7 @@
package com.utopiaindustries.selftrucking.Activities.loginScreens.viewModels; package com.utopiaindustries.selftrucking.Activities.loginScreens.viewModels;
import android.util.Log;
import androidx.lifecycle.LiveData; import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
@ -7,6 +9,7 @@ import androidx.lifecycle.ViewModel;
import com.utopiaindustries.selftrucking.Activities.dashboardScreens.apiservice.ApiService; import com.utopiaindustries.selftrucking.Activities.dashboardScreens.apiservice.ApiService;
import com.utopiaindustries.selftrucking.Activities.dashboardScreens.apiservice.ApiServiceFactory; import com.utopiaindustries.selftrucking.Activities.dashboardScreens.apiservice.ApiServiceFactory;
import com.utopiaindustries.selftrucking.models.DriverResponse; import com.utopiaindustries.selftrucking.models.DriverResponse;
import com.utopiaindustries.selftrucking.models.LoginRequest;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -39,16 +42,18 @@ public class LoginViewModel extends ViewModel {
return errorLiveData; return errorLiveData;
} }
public void authenticateUser(String user, String password) { public void authenticateUser(LoginRequest loginRequest) {
isLoading.setValue(true); isLoading.setValue(true);
apiService.isUserAuthenticated(user, password).enqueue(new Callback<DriverResponse>() { apiService.isUserAuthenticated(loginRequest).enqueue(new Callback<DriverResponse>() {
@Override @Override
public void onResponse(Call<DriverResponse> call, Response<DriverResponse> response) { public void onResponse(Call<DriverResponse> call, Response<DriverResponse> response) {
isLoading.setValue(false); isLoading.setValue(false);
if (response.isSuccessful() && response.body() != null) { if (response.isSuccessful() && response.body() != null) {
userLiveData.setValue(response.body()); userLiveData.setValue(response.body());
Log.e("Success-1","");
} else { } else {
errorLiveData.setValue(response.message()); errorLiveData.setValue(response.message());
Log.e("Else-2","****");
} }
} }
@ -56,6 +61,7 @@ public class LoginViewModel extends ViewModel {
public void onFailure(Call<DriverResponse> call, Throwable t) { public void onFailure(Call<DriverResponse> call, Throwable t) {
isLoading.setValue(false); isLoading.setValue(false);
errorLiveData.setValue(t.getMessage()); errorLiveData.setValue(t.getMessage());
Log.e("onFailure","****");
} }
}); });
} }

View File

@ -23,9 +23,9 @@ public class ContainerWorkflow implements Serializable {
@SerializedName("destination") @SerializedName("destination")
@Expose @Expose
private String destination; private String destination;
@SerializedName("currentStatus") @SerializedName("status")
@Expose @Expose
private String currentStatus = "Assigned"; private String currentStatus;
@SerializedName("truckLoadId") @SerializedName("truckLoadId")
@Expose @Expose
private Integer truckLoadId; private Integer truckLoadId;

View File

@ -0,0 +1,20 @@
package com.utopiaindustries.selftrucking.models;
public class LoginRequest {
private String username;
private String password;
public LoginRequest(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public String toString() {
return "LoginRequest{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
'}';
}
}

View File

@ -3,7 +3,7 @@
<string name="select">Select Type</string> <string name="select">Select Type</string>
<string name="map_key">AIzaSyCFRiiIaGtNnpr2OZNfOF95mHVnTSm3Csw</string> <string name="map_key">abc</string>
<string name="app_version">Version 1.0</string> <string name="app_version">Version 1.0</string>
</resources> </resources>