Login and registration implementation through api
This commit is contained in:
parent
7c8fa6e2c6
commit
97e70cceff
@ -14,10 +14,10 @@ public interface JsonPlaceHolderApi {
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("services/app/Employee/RegisterEmployee")
|
||||
Call<RegistrationNew> createpost(@Body RegistrationNew registrationNew);
|
||||
//Call<RegistrationNew> createpost(@FieldMap Map<String,String> fields);
|
||||
//Call<RegistrationNew> createpost(@Body RegistrationNew registrationNew);
|
||||
Call<RegistrationNew> createpost(@FieldMap Map<String,String> fields);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("posts")
|
||||
Call<Users> login(Users users);
|
||||
Call<Users> login(@FieldMap Map<String,String> fields);
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -64,8 +67,9 @@ public class LoginActivityNew extends AppCompatActivity {
|
||||
|
||||
isAllFieldsChecked = CheckAllFields();
|
||||
if(isAllFieldsChecked) {
|
||||
Intent intent = new Intent(LoginActivityNew.this, CheckInActivity.class);
|
||||
startActivity(intent);
|
||||
login();
|
||||
/*Intent intent = new Intent(LoginActivityNew.this, CheckInActivity.class);
|
||||
startActivity(intent);*/
|
||||
|
||||
}
|
||||
}
|
||||
@ -107,25 +111,30 @@ public class LoginActivityNew extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void saveInfo(){
|
||||
/*Map<String,String> fields=new HashMap<>();
|
||||
fields.put("companyId",edt_comp.getText().toString());
|
||||
fields.put("employeeId",edt_emp.getText().toString());
|
||||
fields.put("otp",edt_otp.getText().toString());*/
|
||||
public void login(){
|
||||
Map<String,String> fields=new HashMap<>();
|
||||
fields.put("employeeId",edt_empId.getText().toString());
|
||||
fields.put("password",edt_pass.getText().toString());
|
||||
fields.put("tenancyName","facebio");
|
||||
|
||||
Users users = new Users(empId,pass,tenancyName);
|
||||
CallApiService.getClient().login(users);
|
||||
Call<Users> call=jsonPlaceHolderApi.login(users);
|
||||
/*Users users = new Users(empId,pass,tenancyName);*/
|
||||
CallApiService.getClient().login(fields);
|
||||
Call<Users> call=jsonPlaceHolderApi.login(fields);
|
||||
call.enqueue(new Callback<Users>() {
|
||||
@Override
|
||||
public void onResponse(Call<Users> call, Response<Users> response) {
|
||||
if(response.isSuccessful())
|
||||
{
|
||||
Log.e("code=", String.valueOf(response.code()));
|
||||
Toast.makeText(LoginActivityNew.this, "Info Added successfully", Toast.LENGTH_SHORT).show();
|
||||
//
|
||||
response.code();
|
||||
Log.e("login response code=", String.valueOf(response.code()));
|
||||
Toast.makeText(LoginActivityNew.this, "Logging in ", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(LoginActivityNew.this, CheckInActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
else{
|
||||
Toast.makeText(LoginActivityNew.this, "Error "+String.valueOf(response.code()), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -103,34 +103,55 @@ public class RegisterActivityNew extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void saveInfo(){
|
||||
/*Map<String,String> fields=new HashMap<>();
|
||||
Map<String,String> fields=new HashMap<>();
|
||||
fields.put("companyId",edt_comp.getText().toString());
|
||||
fields.put("employeeId",edt_emp.getText().toString());
|
||||
fields.put("otp",edt_otp.getText().toString());*/
|
||||
fields.put("otp",edt_otp.getText().toString());
|
||||
|
||||
RegistrationNew registrationNew = new RegistrationNew(edt_comp.getText().toString(),edt_emp.getText().toString(),edt_otp.getText().toString());
|
||||
CallApiService.getClient().createpost(registrationNew);
|
||||
Call<RegistrationNew> call=jsonPlaceHolderApi.createpost(registrationNew);
|
||||
/* RegistrationNew registrationNew = new RegistrationNew(edt_comp.getText().toString(),edt_emp.getText().toString(),edt_otp.getText().toString());
|
||||
System.out.println("Value of registrationNew " );*/
|
||||
CallApiService.getClient().createpost(fields);
|
||||
Call<RegistrationNew> call=jsonPlaceHolderApi.createpost(fields);
|
||||
// call.enqueue(new Callback<RegistrationNew>() {
|
||||
// @Override
|
||||
// public void onResponse(Call<RegistrationNew> call, Response<RegistrationNew> response) {
|
||||
// if(response.isSuccessful())
|
||||
// {
|
||||
// Log.e("code=", String.valueOf(response.code()));
|
||||
// Toast.makeText(RegisterActivityNew.this, "Info Added successfully", Toast.LENGTH_SHORT).show();
|
||||
//// Intent intent=new Intent(AddBook.this,Home.class);
|
||||
//// startActivity(intent);
|
||||
//
|
||||
// RegistrationNew post=response.body();
|
||||
// String content="";
|
||||
// content +="COMPANYID: "+post.getCompanyId() +"\n";
|
||||
// content +="EMP ID: "+post.getEmployeeId() +"\n";
|
||||
// content +="OTP: "+post.getOtp() +"\n";
|
||||
//
|
||||
// // txt_value.append(content);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Call<RegistrationNew> call, Throwable t) {
|
||||
// Toast.makeText(RegisterActivityNew.this, ""+t.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
// Log.e("error=",t.getMessage().toString());
|
||||
// }
|
||||
// });
|
||||
call.enqueue(new Callback<RegistrationNew>() {
|
||||
@Override
|
||||
public void onResponse(Call<RegistrationNew> call, Response<RegistrationNew> response) {
|
||||
if(response.isSuccessful())
|
||||
{
|
||||
Log.e("code=", String.valueOf(response.code()));
|
||||
Toast.makeText(RegisterActivityNew.this, "Info Added successfully", Toast.LENGTH_SHORT).show();
|
||||
// Intent intent=new Intent(AddBook.this,Home.class);
|
||||
// startActivity(intent);
|
||||
|
||||
RegistrationNew post=response.body();
|
||||
String content="";
|
||||
content +="COMPANYID: "+post.getCompanyId() +"\n";
|
||||
content +="EMP ID: "+post.getEmployeeId() +"\n";
|
||||
content +="OTP: "+post.getOtp() +"\n";
|
||||
|
||||
// txt_value.append(content);
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
Log.e("register code=", String.valueOf(response.code()));
|
||||
Toast.makeText(RegisterActivityNew.this, "User Added succesfully", Toast.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(RegisterActivityNew.this, LoginActivityNew.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
else{
|
||||
Toast.makeText(RegisterActivityNew.this, response.message(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,7 +98,7 @@
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold"
|
||||
android:inputType="numberPassword"
|
||||
android:maxLength="3"/>
|
||||
android:maxLength="6"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/verifynproceed"
|
||||
|
Loading…
x
Reference in New Issue
Block a user