Implement feedbacks
parent
6a3940677d
commit
451fd5539a
|
@ -152,7 +152,12 @@ public class ContainerDetailActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
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 -> {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.utopiaindustries.selftrucking.Activities.dashboardScreens.apiservice
|
|||
|
||||
import com.utopiaindustries.selftrucking.models.Container;
|
||||
import com.utopiaindustries.selftrucking.models.DriverResponse;
|
||||
import com.utopiaindustries.selftrucking.models.LoginRequest;
|
||||
import com.utopiaindustries.selftrucking.models.PickResponse;
|
||||
import com.utopiaindustries.selftrucking.models.PickupRequest;
|
||||
|
||||
|
@ -22,8 +23,7 @@ public interface ApiService {
|
|||
|
||||
@GET("rest/application/authenticate-user")
|
||||
Call<DriverResponse> isUserAuthenticated(
|
||||
@Query("username") String username,
|
||||
@Query("password") String password
|
||||
@Body LoginRequest request
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.utopiaindustries.selftrucking.Activities.loginScreens.viewModels.Logi
|
|||
import com.utopiaindustries.selftrucking.R;
|
||||
import com.utopiaindustries.selftrucking.helper.Helper;
|
||||
import com.utopiaindustries.selftrucking.helper.Preference;
|
||||
import com.utopiaindustries.selftrucking.models.LoginRequest;
|
||||
import com.utopiaindustries.selftrucking.utils.ProgressDialogFragment;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
@ -40,15 +41,17 @@ public class LoginActivity extends AppCompatActivity {
|
|||
return insets;
|
||||
});
|
||||
|
||||
if( !Helper.isNetworkConnected(this) ){
|
||||
Toast.makeText( this, "No Internet Connection", Toast.LENGTH_LONG ).show();
|
||||
if (!Helper.isNetworkConnected(this)) {
|
||||
Toast.makeText(this, "No Internet Connection", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
initializeLayouts();
|
||||
|
||||
btnLogin.setOnClickListener(v -> {
|
||||
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 -> {
|
||||
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 -> {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.utopiaindustries.selftrucking.Activities.loginScreens.viewModels;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
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.ApiServiceFactory;
|
||||
import com.utopiaindustries.selftrucking.models.DriverResponse;
|
||||
import com.utopiaindustries.selftrucking.models.LoginRequest;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
|
@ -39,16 +42,18 @@ public class LoginViewModel extends ViewModel {
|
|||
return errorLiveData;
|
||||
}
|
||||
|
||||
public void authenticateUser(String user, String password) {
|
||||
public void authenticateUser(LoginRequest loginRequest) {
|
||||
isLoading.setValue(true);
|
||||
apiService.isUserAuthenticated(user, password).enqueue(new Callback<DriverResponse>() {
|
||||
apiService.isUserAuthenticated(loginRequest).enqueue(new Callback<DriverResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<DriverResponse> call, Response<DriverResponse> response) {
|
||||
isLoading.setValue(false);
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
userLiveData.setValue(response.body());
|
||||
Log.e("Success-1","");
|
||||
} else {
|
||||
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) {
|
||||
isLoading.setValue(false);
|
||||
errorLiveData.setValue(t.getMessage());
|
||||
Log.e("onFailure","****");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ public class ContainerWorkflow implements Serializable {
|
|||
@SerializedName("destination")
|
||||
@Expose
|
||||
private String destination;
|
||||
@SerializedName("currentStatus")
|
||||
@SerializedName("status")
|
||||
@Expose
|
||||
private String currentStatus = "Assigned";
|
||||
private String currentStatus;
|
||||
@SerializedName("truckLoadId")
|
||||
@Expose
|
||||
private Integer truckLoadId;
|
||||
|
|
|
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<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>
|
||||
</resources>
|
Loading…
Reference in New Issue