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