|
|
@ -4,14 +4,25 @@ import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
|
|
|
import android.content.Intent; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.ImageButton; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import retrofit2.Call; |
|
|
|
import retrofit2.Callback; |
|
|
|
import retrofit2.Response; |
|
|
|
import retrofit2.Retrofit; |
|
|
|
import retrofit2.converter.gson.GsonConverterFactory; |
|
|
|
import ru.visionlab.constant.Url; |
|
|
|
import ru.visionlab.femdemo.CheckInActivity; |
|
|
|
import ru.visionlab.femdemo.R; |
|
|
|
import ru.visionlab.femdemo.api.CallApiService; |
|
|
|
import ru.visionlab.femdemo.api.JsonPlaceHolderApi; |
|
|
|
import ru.visionlab.femdemo.models.RegistrationNew; |
|
|
|
import ru.visionlab.femdemo.models.Users; |
|
|
|
import ru.visionlab.femdemo.register.RegisterActivityNew; |
|
|
|
|
|
|
|
public class LoginActivityNew extends AppCompatActivity { |
|
|
@ -25,6 +36,10 @@ public class LoginActivityNew extends AppCompatActivity { |
|
|
|
|
|
|
|
boolean isAllFieldsChecked = false; |
|
|
|
|
|
|
|
JsonPlaceHolderApi jsonPlaceHolderApi; |
|
|
|
|
|
|
|
String tenancyName =""; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
@ -33,9 +48,11 @@ public class LoginActivityNew extends AppCompatActivity { |
|
|
|
|
|
|
|
edt_empId = findViewById(R.id.edt_empId); |
|
|
|
edt_pass = findViewById(R.id.edt_pass); |
|
|
|
createRetrofit(); |
|
|
|
|
|
|
|
empId = edt_empId.getText().toString().trim(); |
|
|
|
pass = edt_pass.getText().toString().trim(); |
|
|
|
tenancyName = "tenancyName"; |
|
|
|
|
|
|
|
System.out.println("value of emp and pass " + empId + " " + pass); |
|
|
|
|
|
|
@ -64,6 +81,15 @@ public class LoginActivityNew extends AppCompatActivity { |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void createRetrofit(){ |
|
|
|
Retrofit retrofit=new Retrofit.Builder() |
|
|
|
.baseUrl(Url.Base_url) |
|
|
|
.addConverterFactory(GsonConverterFactory.create()) |
|
|
|
.build(); |
|
|
|
|
|
|
|
jsonPlaceHolderApi=retrofit.create(JsonPlaceHolderApi.class); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -80,4 +106,34 @@ public class LoginActivityNew extends AppCompatActivity { |
|
|
|
// after all validation return true. |
|
|
|
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());*/ |
|
|
|
|
|
|
|
Users users = new Users(empId,pass,tenancyName); |
|
|
|
CallApiService.getClient().login(users); |
|
|
|
Call<Users> call=jsonPlaceHolderApi.login(users); |
|
|
|
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(); |
|
|
|
// |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailure(Call<Users> call, Throwable t) { |
|
|
|
Toast.makeText(LoginActivityNew.this, ""+t.getMessage(), Toast.LENGTH_SHORT).show(); |
|
|
|
Log.e("error=",t.getMessage().toString()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |