login and register
This commit is contained in:
@@ -1,17 +1,111 @@
|
||||
package ch.pizzalink.android.activity;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
|
||||
import ch.pizzalink.android.view.PizzalinkButton;
|
||||
import ch.pizzalink.android.view.PizzalinkEditText;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class LoginActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.emailPizzalinkEditText) PizzalinkEditText emailPizzalinkEditText;
|
||||
@BindView(R.id.passwordPizzalinkEditText) PizzalinkEditText passwordPizzalinkEditText;
|
||||
@BindView(R.id.loginButton) Button loginButton;
|
||||
@BindView(R.id.registerTextView) TextView registerTextView;
|
||||
|
||||
@BindString(R.string.not_have_an_accaount) String notHaveAnAccountText;
|
||||
@BindString(R.string.register_text) String registerText;
|
||||
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
|
||||
@BindString(R.string.alert_valid_email) String validEmailText;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
ButterKnife.bind(this);
|
||||
initViews();
|
||||
}
|
||||
|
||||
@OnClick({R.id.loginButton, R.id.registerTextView})
|
||||
protected void onClick(View view){
|
||||
switch (view.getId()){
|
||||
case R.id.loginButton:
|
||||
if(checkFields())
|
||||
login();
|
||||
break;
|
||||
case R.id.registerTextView:
|
||||
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
initRegisterTextView();
|
||||
emailPizzalinkEditText.getEditText().setText("aytaccici@gmail.com");
|
||||
passwordPizzalinkEditText.getEditText().setText("3522625");
|
||||
}
|
||||
|
||||
private void initRegisterTextView(){
|
||||
Spannable wordtoSpan = new SpannableString(notHaveAnAccountText + " " + registerText);
|
||||
wordtoSpan.setSpan(new ForegroundColorSpan(Color.RED), 16, wordtoSpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
registerTextView.setText(wordtoSpan);
|
||||
}
|
||||
|
||||
private boolean checkFields(){
|
||||
|
||||
if(emailPizzalinkEditText.isEmpty() || passwordPizzalinkEditText.isEmpty()){
|
||||
DialogHelper.showAlertDialog(this, fillAllFieldsText);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!emailPizzalinkEditText.isEmail()){
|
||||
DialogHelper.showAlertDialog(this, validEmailText);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void login(){
|
||||
Call<LoginCustomerResponseModel> call = ApiService.apiInterface.login(
|
||||
emailPizzalinkEditText.getText(), passwordPizzalinkEditText.getText());
|
||||
call.enqueue(new Callback<LoginCustomerResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<LoginCustomerResponseModel> call, Response<LoginCustomerResponseModel> response) {
|
||||
if(response.isSuccessful()){
|
||||
SharedPrefsHelper.saveUser(response.body().getData());
|
||||
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
|
||||
SharedPrefsHelper.setCustomerLoggedIn(true);
|
||||
startActivity(new Intent(LoginActivity.this, MainActivity.class));
|
||||
}
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<LoginCustomerResponseModel> call, Throwable t) {
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,122 @@
|
||||
package ch.pizzalink.android.activity;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.BindViews;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SharedPrefsHelper;
|
||||
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
|
||||
import ch.pizzalink.android.view.PizzalinkButton;
|
||||
import ch.pizzalink.android.view.PizzalinkEditText;
|
||||
import ch.pizzalink.android.view.PizzalinkToolbar;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class RegisterActivity extends BaseActivity {
|
||||
|
||||
@BindView(R.id.registerToolbar) PizzalinkToolbar registerToolbar;
|
||||
@BindView(R.id.registerButton) Button registerButton;
|
||||
@BindViews({ R.id.firstnamePizzalinkEditText, R.id.lasstnamePizzalinkEditText,
|
||||
R.id.telephonePizzalinkEditText, R.id.emailPizzalinkEditText,
|
||||
R.id.passwordPizzalinkEditText, R.id.passwordAgainPizzalinkEditText,
|
||||
R.id.address1PizzalinkEditText, R.id.address2PizzalinkEditText,
|
||||
R.id.cityPizzalinkEditText, R.id.postcodePizzalinkEditText,
|
||||
R.id.zonePizzalinkEditText, R.id.countryPizzalinkEditText})
|
||||
List<PizzalinkEditText> pizzalinkEditTextList;
|
||||
|
||||
@BindString(R.string.alert_fill_all_fields) String fillAllFieldsText;
|
||||
@BindString(R.string.alert_valid_email) String validEmailText;
|
||||
@BindString(R.string.alert_passwords_not_matched) String passwordsNotMatchedText;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register);
|
||||
ButterKnife.bind(this);
|
||||
initViews();
|
||||
}
|
||||
|
||||
@OnClick(R.id.registerButton)
|
||||
protected void onClick(){
|
||||
if(checkFields())
|
||||
registerUser();
|
||||
}
|
||||
|
||||
private void initViews(){
|
||||
registerToolbar.setBackIconClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkFields(){
|
||||
|
||||
for(PizzalinkEditText pizzalinkEditText : pizzalinkEditTextList){
|
||||
if(pizzalinkEditText.isEmpty()){
|
||||
DialogHelper.showAlertDialog(this, fillAllFieldsText);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!pizzalinkEditTextList.get(3).isEmail()){
|
||||
DialogHelper.showAlertDialog(this, validEmailText);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(pizzalinkEditTextList
|
||||
.get(4)
|
||||
.getText()
|
||||
.toLowerCase()
|
||||
.equals(
|
||||
pizzalinkEditTextList
|
||||
.get(5)
|
||||
.getText()
|
||||
.toLowerCase())){
|
||||
DialogHelper.showAlertDialog(this, passwordsNotMatchedText);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void registerUser(){
|
||||
Call<LoginCustomerResponseModel> call = ApiService.apiInterface.register(
|
||||
pizzalinkEditTextList.get(0).getText(), pizzalinkEditTextList.get(1).getText(),pizzalinkEditTextList.get(2).getText(),
|
||||
pizzalinkEditTextList.get(3).getText(),pizzalinkEditTextList.get(4).getText(),pizzalinkEditTextList.get(5).getText(),
|
||||
pizzalinkEditTextList.get(6).getText(),pizzalinkEditTextList.get(7).getText(),pizzalinkEditTextList.get(8).getText(),
|
||||
pizzalinkEditTextList.get(9).getText(),pizzalinkEditTextList.get(10).getText(),pizzalinkEditTextList.get(11).getText());
|
||||
call.enqueue(new Callback<LoginCustomerResponseModel>() {
|
||||
@Override
|
||||
public void onResponse(Call<LoginCustomerResponseModel> call, Response<LoginCustomerResponseModel> response) {
|
||||
if(response.isSuccessful()){
|
||||
SharedPrefsHelper.saveUser(response.body().getData());
|
||||
SharedPrefsHelper.saveCustomerToken(response.body().getData().getToken());
|
||||
SharedPrefsHelper.setCustomerLoggedIn(true);
|
||||
startActivity(new Intent(RegisterActivity.this, MainActivity.class));
|
||||
}
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<LoginCustomerResponseModel> call, Throwable t) {
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SplashActivity extends BaseActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_splash);
|
||||
ButterKnife.bind(this);
|
||||
DisplayHelper.changeStatusColor();
|
||||
//DisplayHelper.changeStatusColor();
|
||||
if(NetworkHelper.isNetworkAvailable())
|
||||
getCategoryList();
|
||||
else
|
||||
@@ -80,8 +80,7 @@ public class SplashActivity extends BaseActivity {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//startActivity(new Intent(SplashActivity.this, cls));
|
||||
startActivity(new Intent(SplashActivity.this, RegisterActivity.class));
|
||||
startActivity(new Intent(SplashActivity.this, cls));
|
||||
finish();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
@@ -42,90 +42,24 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
private ArrayList<PizzaModel> pizzaList = new ArrayList<>();
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
private CheckBoxChangedListener checkBoxChangedListener;
|
||||
|
||||
public static class PizzaViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.pizzaNameTextView) TextView pizzaNameTextView;
|
||||
@BindView(R.id.pizzaImageView) ImageView pizzaImageView;
|
||||
@BindView(R.id.pizzaIngredientsTextView) TextView pizzaIngredientsTextView;
|
||||
@BindView(R.id.pizzaBottomLayout) LinearLayout pizzaBottomLayout;
|
||||
@BindView(R.id.expandBottomLayoutImageView) ImageView expandBottomLayoutImageView;
|
||||
@BindView(R.id.collapseBottomLayoutImageView) ImageView collapseBottomLayoutImageView;
|
||||
|
||||
@BindViews({ R.id.pizzaSize1CheckBox, R.id.pizzaSize2CheckBox, R.id.pizzaSize3CheckBox })
|
||||
List<AppCompatCheckBox> pizzaSizeCheckBoxList;
|
||||
|
||||
@BindView(R.id.pizzaSize1Layout) LinearLayout pizzaSize1Layout;
|
||||
@BindView(R.id.pizzaSize1NameTextView) TextView pizzaSize1NameTextView;
|
||||
@BindView(R.id.pizzaSize1CheckBox) AppCompatCheckBox pizzaSize1CheckBox;
|
||||
@BindView(R.id.pizzaSize1LengthTextView) TextView pizzaSize1LengthTextView;
|
||||
|
||||
@BindView(R.id.pizzaSize2Layout) LinearLayout pizzaSize2Layout;
|
||||
@BindView(R.id.pizzaSize2NameTextView) TextView pizzaSize2NameTextView;
|
||||
@BindView(R.id.pizzaSize2CheckBox) AppCompatCheckBox pizzaSize2CheckBox;
|
||||
@BindView(R.id.pizzaSize2LengthTextView) TextView pizzaSize2LengthTextView;
|
||||
|
||||
@BindView(R.id.pizzaSize3Layout) LinearLayout pizzaSize3Layout;
|
||||
@BindView(R.id.pizzaSize3NameTextView) TextView pizzaSize3NameTextView;
|
||||
@BindView(R.id.pizzaSize3CheckBox) AppCompatCheckBox pizzaSize3CheckBox;
|
||||
@BindView(R.id.pizzaSize3LengthTextView) TextView pizzaSize3LengthTextView;
|
||||
|
||||
@BindView(R.id.increasePizzaCountTextView) ImageView increasePizzaCountTextView;
|
||||
@BindView(R.id.pizzaCountTextView) TextView pizzaCountTextView;
|
||||
@BindView(R.id.deccreasePizzaCountTextView) ImageView deccreasePizzaCountTextView;
|
||||
|
||||
@BindView(R.id.pizzaPriceTextView) TextView pizzaPriceTextView;
|
||||
@BindView(R.id.addPizzaToCartButton) Button addPizzaToCartButton;
|
||||
|
||||
|
||||
public PizzaViewHolder(final View view,
|
||||
final RecyclerItemClickListener recyclerItemClickListener,
|
||||
final CheckBoxChangedListener checkBoxChangedListener) {
|
||||
public PizzaViewHolder(final View view, final RecyclerItemClickListener recyclerItemClickListener) {
|
||||
super(view);
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(pizzaBottomLayout, getAdapterPosition());
|
||||
recyclerItemClickListener.onItemClick(view, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
increasePizzaCountTextView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(increasePizzaCountTextView, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
deccreasePizzaCountTextView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(deccreasePizzaCountTextView, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
addPizzaToCartButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(recyclerItemClickListener != null)
|
||||
recyclerItemClickListener.onItemClick(addPizzaToCartButton, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
|
||||
for(final AppCompatCheckBox appCompatCheckBox : pizzaSizeCheckBoxList){
|
||||
appCompatCheckBox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(checkBoxChangedListener != null)
|
||||
checkBoxChangedListener.onCheckedChanged(appCompatCheckBox, getAdapterPosition());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,11 +79,9 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
public PizzaRecyclerAdapter(ArrayList<PizzaModel> pizzaList,
|
||||
RecyclerItemClickListener recyclerItemClickListener,
|
||||
CheckBoxChangedListener checkBoxChangedListener){
|
||||
RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.pizzaList = pizzaList;
|
||||
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||
this.checkBoxChangedListener = checkBoxChangedListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,8 +94,8 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
switch (viewType){
|
||||
|
||||
case HOLDER_PIZZA:
|
||||
view = inflater.inflate(R.layout.row_pizza_2, viewGroup, false);
|
||||
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener, checkBoxChangedListener);
|
||||
view = inflater.inflate(R.layout.row_pizza, viewGroup, false);
|
||||
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
|
||||
case HOLDER_SPACE:
|
||||
@@ -172,8 +104,8 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
break;
|
||||
|
||||
default:
|
||||
view = inflater.inflate(R.layout.row_pizza_2, viewGroup, false);
|
||||
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener, checkBoxChangedListener);
|
||||
view = inflater.inflate(R.layout.row_pizza, viewGroup, false);
|
||||
viewHolder = new PizzaViewHolder(view, recyclerItemClickListener);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -185,65 +117,18 @@ public class PizzaRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
|
||||
switch (holder.getItemViewType()){
|
||||
|
||||
case HOLDER_PIZZA :
|
||||
PizzaViewHolder pizzaViewHolder = (PizzaViewHolder) holder;
|
||||
pizzaViewHolder.pizzaNameTextView.setText(pizzaList.get(position).getName());
|
||||
pizzaViewHolder.pizzaIngredientsTextView.setText(pizzaList.get(position).getIngredients());
|
||||
pizzaViewHolder.pizzaCountTextView.setText(String.valueOf(pizzaList.get(position).getCount()));
|
||||
ImageLoadHelper.loadImage(pizzaViewHolder.pizzaImageView, pizzaList.get(position).getImageURL());
|
||||
|
||||
if(pizzaList.get(position).isExpanded()){
|
||||
pizzaViewHolder.expandBottomLayoutImageView.setVisibility(View.GONE);
|
||||
pizzaViewHolder.collapseBottomLayoutImageView.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaBottomLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
else{
|
||||
pizzaViewHolder.expandBottomLayoutImageView.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.collapseBottomLayoutImageView.setVisibility(View.GONE);
|
||||
pizzaViewHolder.pizzaBottomLayout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(pizzaList.get(position).getPizzaSizeList().size() == 0){
|
||||
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.GONE);
|
||||
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.GONE);
|
||||
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
else if(pizzaList.get(position).getPizzaSizeList().size() == 1){
|
||||
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaSize1NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(0).getName());
|
||||
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.GONE);
|
||||
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.GONE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(pizzaList.get(position).getPizzaSizeList().size() == 2){
|
||||
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaSize1NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(0).getName());
|
||||
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaSize2NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(1).getName());
|
||||
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
else if(pizzaList.get(position).getPizzaSizeList().size() <= 3){
|
||||
pizzaViewHolder.pizzaSize1Layout.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaSize1NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(0).getName());
|
||||
pizzaViewHolder.pizzaSize2Layout.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaSize2NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(1).getName());
|
||||
pizzaViewHolder.pizzaSize3Layout.setVisibility(View.VISIBLE);
|
||||
pizzaViewHolder.pizzaSize3NameTextView.setText(pizzaList.get(position).getPizzaSizeList().get(2).getName());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case HOLDER_SPACE :
|
||||
SpaceViewHolder spaceViewHolder = (SpaceViewHolder) holder;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,10 @@ package ch.pizzalink.android.api;
|
||||
public class ApiEndPoints {
|
||||
|
||||
private static final String PREFIX = "pizza2/index.php?route=mobile/service/";
|
||||
private static final String SUFFIX = "&is_mobile=1";
|
||||
|
||||
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories&is_mobile=1";
|
||||
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories" + SUFFIX;
|
||||
public static final String API_REGISTER = PREFIX + "signUp" + SUFFIX;
|
||||
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.pizzalink.android.api;
|
||||
|
||||
import ch.pizzalink.android.model.responseModel.CategoryResponseModel;
|
||||
import ch.pizzalink.android.model.responseModel.LoginCustomerResponseModel;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
@@ -17,6 +18,26 @@ public interface ApiInterface {
|
||||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||||
Call<CategoryResponseModel> getAllCategories();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REGISTER)
|
||||
Call<LoginCustomerResponseModel> register(@Field("firstname") String firstname,
|
||||
@Field("lastname") String lastname,
|
||||
@Field("telephone") String telephone,
|
||||
@Field("email") String email,
|
||||
@Field("passsword") String passsword,
|
||||
@Field("passsword1") String passswordRetype,
|
||||
@Field("address_1") String addressLine1,
|
||||
@Field("address_2") String addressLine2,
|
||||
@Field("city") String passswocityrd,
|
||||
@Field("postcode") String postcode,
|
||||
@Field("country_id") String country_id,
|
||||
@Field("zone_id") String zone_id);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_LOGIN)
|
||||
Call<LoginCustomerResponseModel> login(@Field("email") String email, @Field("password") String password);
|
||||
|
||||
|
||||
/*
|
||||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||||
Call<CategoryListResponseModel> getAllCategories();
|
||||
|
||||
@@ -66,14 +66,11 @@ public class PizzaFragment extends OrderBaseFragment {
|
||||
|
||||
private void initRecyclerView(){
|
||||
|
||||
/*
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
|
||||
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
*/
|
||||
|
||||
RecyclerItemClickListener recyclerItemClickListener = new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
/*
|
||||
switch (view.getId()){
|
||||
case R.id.increasePizzaCountTextView:
|
||||
pizzaList.get(position).setCount(pizzaList.get(position).getCount() + 1);
|
||||
@@ -96,6 +93,7 @@ public class PizzaFragment extends OrderBaseFragment {
|
||||
pizzaRecyclerView.scrollToPosition(position);
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,8 +104,9 @@ public class PizzaFragment extends OrderBaseFragment {
|
||||
}
|
||||
};
|
||||
|
||||
pizzaRecyclerAdapter = new PizzaRecyclerAdapter(pizzaList, recyclerItemClickListener, checkBoxChangedListener);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(BaseActivity.currentActivity);
|
||||
pizzaRecyclerAdapter = new PizzaRecyclerAdapter(pizzaList, recyclerItemClickListener);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
|
||||
pizzaRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
pizzaRecyclerView.setLayoutManager(layoutManager);
|
||||
pizzaRecyclerView.setAdapter(pizzaRecyclerAdapter);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.support.v4.content.ContextCompat;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import ch.pizzalink.android.R;
|
||||
@@ -14,7 +15,7 @@ import ch.pizzalink.android.R;
|
||||
* Created by cimenmus on 28/09/2017.
|
||||
*/
|
||||
|
||||
public class PizzalinkButton extends RelativeLayout {
|
||||
public class PizzalinkButton extends LinearLayout {
|
||||
|
||||
private View rootView;
|
||||
private boolean isEnabled;
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.widget.TextView;
|
||||
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.helper.PasswordHelper;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 28/09/2017.
|
||||
@@ -98,23 +99,33 @@ public class PizzalinkEditText extends LinearLayout implements View.OnClickListe
|
||||
}
|
||||
|
||||
private void hideShowPassword(){
|
||||
|
||||
if(isPasswordHidden)
|
||||
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
else
|
||||
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
|
||||
isPasswordHidden = !isPasswordHidden;
|
||||
editText.setTypeface(typeFace);
|
||||
}
|
||||
|
||||
private void focusEditText(){
|
||||
|
||||
editText.requestFocus();
|
||||
InputMethodManager inputMethodManager=(InputMethodManager)BaseActivity.currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return editText.getText().toString().isEmpty();
|
||||
}
|
||||
|
||||
public boolean isEmail(){
|
||||
return PasswordHelper.EMAIL_ADDRESS_PATTERN.matcher(editText.getText()).matches();
|
||||
}
|
||||
|
||||
public String getText(){
|
||||
return editText.getText().toString();
|
||||
}
|
||||
|
||||
|
||||
public TextView getHintTextView() {
|
||||
return hintTextView;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ public class PizzalinkToolbar extends Toolbar {
|
||||
|
||||
private View rootView;
|
||||
private TextView toolbarTitleTextView;
|
||||
private ImageView hamburgerIcon;
|
||||
private boolean showHamburgerIcon;
|
||||
private ImageView hamburgerIcon, backIcon;
|
||||
private boolean showHamburgerIcon, showBackIcon;
|
||||
private String title;
|
||||
private int toolbarBackgroundColor, titleTextColor;
|
||||
|
||||
@@ -44,6 +44,7 @@ public class PizzalinkToolbar extends Toolbar {
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PizzalinkToolbar, 0, 0);
|
||||
try {
|
||||
showHamburgerIcon = a.getBoolean(R.styleable.PizzalinkToolbar_showHamburgerMenuIcon, false);
|
||||
showBackIcon = a.getBoolean(R.styleable.PizzalinkToolbar_showBackIcon, false);
|
||||
title = a.getString(R.styleable.PizzalinkToolbar_title);
|
||||
/*
|
||||
toolbarBackgroundColor = a.getColor(R.styleable.PizzalinkToolbar_toolbarBackgroundColor,
|
||||
@@ -66,8 +67,11 @@ public class PizzalinkToolbar extends Toolbar {
|
||||
//this.setBackgroundResource(toolbarBackgroundColor);
|
||||
//toolbarTitleTextView.setTextColor(titleTextColor);
|
||||
hamburgerIcon = (ImageView) rootView.findViewById(R.id.hamburgerIcon);
|
||||
backIcon = (ImageView) rootView.findViewById(R.id.backIcon);
|
||||
if(showHamburgerIcon)
|
||||
hamburgerIcon.setVisibility(VISIBLE);
|
||||
if(showBackIcon)
|
||||
backIcon.setVisibility(VISIBLE);
|
||||
if(title != null) {
|
||||
toolbarTitleTextView.setText(title);
|
||||
toolbarTitleTextView.setVisibility(VISIBLE);
|
||||
@@ -91,6 +95,10 @@ public class PizzalinkToolbar extends Toolbar {
|
||||
hamburgerIcon.setVisibility(GONE);
|
||||
}
|
||||
|
||||
public void setBackIconClickListener(OnClickListener onClickListener){
|
||||
backIcon.setOnClickListener(onClickListener);
|
||||
}
|
||||
|
||||
public ImageView getHamburgerIcon() {
|
||||
return hamburgerIcon;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user