beta bug fixes 2
This commit is contained in:
@@ -9,6 +9,7 @@ import com.badoualy.stepperindicator.StepperIndicator;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.fragment.createOrder.CreateOrderNoteFragment;
|
||||
import ch.pizzalink.android.fragment.createOrder.CreateOrderResultFragment;
|
||||
import ch.pizzalink.android.fragment.createOrder.CreateOrderSummaryFragment;
|
||||
import ch.pizzalink.android.fragment.createOrder.PaymentMethodFragment;
|
||||
@@ -30,6 +31,7 @@ public class CreateOrderActivity extends BaseActivity {
|
||||
private ShippingMethodModel selectedShippingMethod;
|
||||
private AddressModel selectedShippingAddress;
|
||||
private PaymentMethodModel selectedPaymentMethod;
|
||||
private String orderNote;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -57,9 +59,9 @@ public class CreateOrderActivity extends BaseActivity {
|
||||
|
||||
private void initStepIndicator(){
|
||||
/*
|
||||
5 fragment var, ama sonuncu step'te tik göstersin diye step sayısını, fragment sayısı - 1 yaptık
|
||||
6 fragment var, ama sonuncu step'te tik göstersin diye step sayısını, fragment sayısı - 1 yaptık
|
||||
*/
|
||||
stepperIndicator.setStepCount(4);
|
||||
stepperIndicator.setStepCount(5);
|
||||
/*
|
||||
stepperIndicator.addOnStepClickListener(new StepperIndicator.OnStepClickListener() {
|
||||
@Override
|
||||
@@ -86,9 +88,14 @@ public class CreateOrderActivity extends BaseActivity {
|
||||
break;
|
||||
case 3:
|
||||
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
|
||||
CreateOrderSummaryFragment.newInstance()).commit();
|
||||
CreateOrderNoteFragment.newInstance()).commit();
|
||||
break;
|
||||
case 4:
|
||||
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
|
||||
CreateOrderSummaryFragment.newInstance()).commit();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
fragmentManager.beginTransaction().replace(R.id.orderFragmentsContainer,
|
||||
CreateOrderResultFragment.newInstance()).commit();
|
||||
break;
|
||||
@@ -107,9 +114,12 @@ public class CreateOrderActivity extends BaseActivity {
|
||||
case PaymentMethodFragment.FRAGMENT_NAME:
|
||||
openFragment(3);
|
||||
break;
|
||||
case CreateOrderSummaryFragment.FRAGMENT_NAME:
|
||||
case CreateOrderNoteFragment.FRAGMENT_NAME:
|
||||
openFragment(4);
|
||||
break;
|
||||
case CreateOrderSummaryFragment.FRAGMENT_NAME:
|
||||
openFragment(5);
|
||||
break;
|
||||
case CreateOrderResultFragment.FRAGMENT_NAME:
|
||||
Intent mainActivityIntent = new Intent(this, MainActivity.class);
|
||||
mainActivityIntent.putExtra("isStartWithOrderHistory", true);
|
||||
@@ -128,9 +138,12 @@ public class CreateOrderActivity extends BaseActivity {
|
||||
case PaymentMethodFragment.FRAGMENT_NAME:
|
||||
openFragment(1);
|
||||
break;
|
||||
case CreateOrderSummaryFragment.FRAGMENT_NAME:
|
||||
case CreateOrderNoteFragment.FRAGMENT_NAME:
|
||||
openFragment(2);
|
||||
break;
|
||||
case CreateOrderSummaryFragment.FRAGMENT_NAME:
|
||||
openFragment(3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,4 +174,14 @@ public class CreateOrderActivity extends BaseActivity {
|
||||
public void setSelectedPaymentMethod(PaymentMethodModel selectedPaymentMethod){
|
||||
this.selectedPaymentMethod = selectedPaymentMethod;
|
||||
}
|
||||
|
||||
public String getOrderNote(){
|
||||
if(orderNote == null)
|
||||
orderNote = "";
|
||||
return orderNote;
|
||||
}
|
||||
|
||||
public void setOrderNote(String orderNote){
|
||||
this.orderNote = orderNote;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ public class MainActivity extends BaseActivity {
|
||||
itemHolder.rootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openProductsScreen(categoryList.get(pstn));
|
||||
openProductsScreen(list.get(position));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class SplashActivity extends BaseActivity {
|
||||
response.body().isSuccess()){
|
||||
CategoryModel.checkNull(response.body().getData());
|
||||
SharedPrefsHelper.saveCategoryList(response.body().getData());
|
||||
checkCustomerToken();
|
||||
getIgnoredCategoryIds();
|
||||
}
|
||||
else
|
||||
ApiErrorUtils.parseError(response);
|
||||
@@ -114,6 +114,29 @@ public class SplashActivity extends BaseActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void getIgnoredCategoryIds(){
|
||||
Call<ResponseArray<Integer>> call = ApiService.apiInterface.getIgnoredCategoryIds();
|
||||
call.enqueue(new Callback<ResponseArray<Integer>>() {
|
||||
@Override
|
||||
public void onResponse(Call<ResponseArray<Integer>> call, Response<ResponseArray<Integer>> response) {
|
||||
if(response.isSuccessful() &&
|
||||
response.body().getData() != null &&
|
||||
response.body().isSuccess()){
|
||||
SharedPrefsHelper.saveIgnoredCategoryIdList(response.body().getData());
|
||||
checkCustomerToken();
|
||||
}
|
||||
else {
|
||||
ApiErrorUtils.parseError(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<ResponseArray<Integer>> call, Throwable t) {
|
||||
DialogHelper.showFailedDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
private void checkCustomerToken(){
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ public class MenuProductRecyclerAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
private ArrayList<MenuProductModel> menuProductList = new ArrayList<>();
|
||||
private RecyclerItemClickListener recyclerItemClickListener;
|
||||
private boolean isDescriptionVisible;
|
||||
|
||||
public static class MenuProductViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@@ -66,9 +67,11 @@ public class MenuProductRecyclerAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
}
|
||||
|
||||
public MenuProductRecyclerAdapter(ArrayList<MenuProductModel> menuProductList,
|
||||
boolean isDescriptionVisible,
|
||||
RecyclerItemClickListener recyclerItemClickListener){
|
||||
this.menuProductList = menuProductList;
|
||||
this.recyclerItemClickListener = recyclerItemClickListener;
|
||||
this.isDescriptionVisible = isDescriptionVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,17 +113,15 @@ public class MenuProductRecyclerAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
menuProductViewHolder.productNameTextView.setText(menuProductList.get(position).getName());
|
||||
menuProductViewHolder.productPriceTextView.setText(
|
||||
PriceHelper.getPriceWithCurreny(menuProductList.get(position).getPrice()));
|
||||
|
||||
TextHelper.setTextFromHTML(menuProductViewHolder.productIngredientsTextView, menuProductList.get(position).getDescription());
|
||||
|
||||
/*
|
||||
if(menuProductList.get(position).isDescriptionAvailable()){
|
||||
if(isDescriptionVisible){
|
||||
menuProductViewHolder.productIngredientsLayout.setVisibility(View.VISIBLE);
|
||||
menuProductViewHolder.productIngredientsTextView.setText(menuProductList.get(position).getDescription());
|
||||
}
|
||||
else
|
||||
else {
|
||||
menuProductViewHolder.productIngredientsLayout.setVisibility(View.GONE);
|
||||
*/
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ public class ApiEndPoints {
|
||||
private static final String SUFFIX = "&is_mobile=1";
|
||||
|
||||
public static final String API_GET_ALL_CATEGORIES = PREFIX + "getAllCategories" + SUFFIX;
|
||||
public static final String API_GET_IGNORED_CATEGORI_IDS= PREFIX + "getIgnoredCategory" + SUFFIX;
|
||||
public static final String API_REGISTER = PREFIX + "signUp" + SUFFIX;
|
||||
public static final String API_LOGIN = PREFIX + "login" + SUFFIX;
|
||||
public static final String API_LOGOUT = PREFIX + "logout" + SUFFIX;
|
||||
|
||||
@@ -22,19 +22,23 @@ public class ApiErrorUtils {
|
||||
|
||||
BaseResponse baseResponse = (BaseResponse) response.body();
|
||||
|
||||
if(baseResponse != null &&baseResponse.getErrorCode() == ApiConstants.APP_ERROR_CODE_AUTHORIZATION){
|
||||
SharedPrefsHelper.clearCustomerInfo();
|
||||
SharedPrefsHelper.clearCustomerToken();
|
||||
SharedPrefsHelper.setCustomerLoggedIn(false);
|
||||
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, LoginActivity.class));
|
||||
BaseActivity.currentActivity.finishAffinity();
|
||||
return;
|
||||
if(baseResponse != null){
|
||||
|
||||
if(baseResponse.getErrorCode() == ApiConstants.APP_ERROR_CODE_AUTHORIZATION){
|
||||
SharedPrefsHelper.clearCustomerInfo();
|
||||
SharedPrefsHelper.clearCustomerToken();
|
||||
SharedPrefsHelper.setCustomerLoggedIn(false);
|
||||
BaseActivity.currentActivity.startActivity(new Intent(BaseActivity.currentActivity, LoginActivity.class));
|
||||
BaseActivity.currentActivity.finishAffinity();
|
||||
return;
|
||||
}
|
||||
|
||||
if(baseResponse.getMessage() != null && !baseResponse.getMessage().isEmpty()){
|
||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity, baseResponse.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(baseResponse.getMessage() != null && !baseResponse.getMessage().isEmpty()){
|
||||
DialogHelper.showAlertDialog(BaseActivity.currentActivity, baseResponse.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
error = converter.convert(response.errorBody());
|
||||
|
||||
@@ -37,29 +37,13 @@ public interface ApiInterface {
|
||||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||||
Call<ResponseArray<CategoryModel>> getAllCategories();
|
||||
|
||||
/*
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REGISTER)
|
||||
Call<ResponseObject<UserModel>> register(@Field("firstname") String firstname,
|
||||
@Field("lastname") String lastname,
|
||||
@Field("telephone") String telephone,
|
||||
@Field("email") String email,
|
||||
@Field("password") String passsword,
|
||||
@Field("password1") 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);
|
||||
*/
|
||||
@GET(ApiEndPoints.API_GET_IGNORED_CATEGORI_IDS)
|
||||
Call<ResponseArray<Integer>> getIgnoredCategoryIds();
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_REGISTER)
|
||||
Call<ResponseObject<UserModel>> register(@FieldMap HashMap<String, Object> body);
|
||||
|
||||
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST(ApiEndPoints.API_LOGIN)
|
||||
Call<ResponseObject<UserModel>> login(@Field("email") String email, @Field("password") String password);
|
||||
|
||||
@@ -80,12 +80,15 @@ public class MenuFragment extends BaseFragment {
|
||||
private void initRecyclerView(){
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
|
||||
menuProductRecyclerView.setLayoutManager(layoutManager);
|
||||
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(menuProductList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
showBottomsheetDialog(menuProductList.get(position));
|
||||
}
|
||||
});
|
||||
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(
|
||||
menuProductList,
|
||||
categoryModel.isDescriptionVisible(),
|
||||
new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
showBottomsheetDialog(menuProductList.get(position));
|
||||
}
|
||||
});
|
||||
menuProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
menuProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
|
||||
}
|
||||
|
||||
@@ -79,12 +79,15 @@ public class ProductFragment extends BaseFragment {
|
||||
private void initRecyclerView(){
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(BaseActivity.currentActivity, 2);
|
||||
customProductRecyclerView.setLayoutManager(layoutManager);
|
||||
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(productList, new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
showBottomsheetDialog(productList.get(position));
|
||||
}
|
||||
});
|
||||
menuProductRecyclerAdapter = new MenuProductRecyclerAdapter(
|
||||
productList,
|
||||
categoryModel.isDescriptionVisible(),
|
||||
new RecyclerItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
showBottomsheetDialog(productList.get(position));
|
||||
}
|
||||
});
|
||||
customProductRecyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayHelper.dpToPx(12)));
|
||||
customProductRecyclerView.setAdapter(menuProductRecyclerAdapter);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package ch.pizzalink.android.fragment.createOrder;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindString;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import ch.pizzalink.android.R;
|
||||
import ch.pizzalink.android.activity.BaseActivity;
|
||||
import ch.pizzalink.android.activity.CreateOrderActivity;
|
||||
import ch.pizzalink.android.adapter.recycler.PaymentMethodsRecyclerAdapter;
|
||||
import ch.pizzalink.android.api.ApiErrorUtils;
|
||||
import ch.pizzalink.android.api.ApiService;
|
||||
import ch.pizzalink.android.api.ResponseObject;
|
||||
import ch.pizzalink.android.helper.DialogHelper;
|
||||
import ch.pizzalink.android.helper.SessionHelper;
|
||||
import ch.pizzalink.android.interfaces.RecyclerItemClickListener;
|
||||
import ch.pizzalink.android.model.PaymentMethodModel;
|
||||
import ch.pizzalink.android.model.PaymentMethodsResponseModel;
|
||||
import ch.pizzalink.android.view.PizzalinkEditText;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 28.10.2017.
|
||||
*/
|
||||
|
||||
public class CreateOrderNoteFragment extends CreateOrderBaseFragment {
|
||||
|
||||
@BindView(R.id.orderNotePizzalinkEditText) PizzalinkEditText orderNotePizzalinkEditText;
|
||||
|
||||
public static final java.lang.String FRAGMENT_NAME = "createOrderNoteFragment";
|
||||
|
||||
public CreateOrderNoteFragment() {}
|
||||
|
||||
public static CreateOrderNoteFragment newInstance() {
|
||||
return new CreateOrderNoteFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_create_order_note, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@OnClick({R.id.previousTextView, R.id.nextTextView})
|
||||
protected void onClick(View view){
|
||||
CreateOrderActivity createOrderActivity = (CreateOrderActivity) getActivity();
|
||||
switch (view.getId()){
|
||||
case R.id.previousTextView:
|
||||
createOrderActivity.onPreviousClicked(FRAGMENT_NAME);
|
||||
break;
|
||||
case R.id.nextTextView:
|
||||
createOrderActivity.setOrderNote(orderNotePizzalinkEditText.getText());
|
||||
createOrderActivity.onNextClicked(FRAGMENT_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
@BindView(R.id.orderShippingAddressPizzalinkInfoLayout) PizzalinkInfoView orderShippingAddressPizzalinkInfoLayout;
|
||||
@BindView(R.id.orderPaymentMethodPizzalinkInfoLayout) PizzalinkInfoView orderPaymentMethodPizzalinkInfoLayout;
|
||||
@BindView(R.id.orderTotalPizzalinkInfoLayout) PizzalinkInfoView orderTotalPizzalinkInfoLayout;
|
||||
@BindView(R.id.orderNotePizzalinkInfoLayout) PizzalinkInfoView orderNotePizzalinkInfoLayout;
|
||||
|
||||
@BindString(R.string.confirm_order) String confirmOrderText;
|
||||
|
||||
@@ -84,6 +85,13 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
orderShippingAddressPizzalinkInfoLayout.setText(createOrderActivity.getSelectedShippingAddress().getAddress());
|
||||
orderPaymentMethodPizzalinkInfoLayout.setText(createOrderActivity.getSelectedPaymentMethod().getTitle());
|
||||
orderTotalPizzalinkInfoLayout.setText(createOrderActivity.getCartInfo().getTotals().get(0).getText());
|
||||
if(createOrderActivity.getOrderNote().isEmpty()){
|
||||
orderNotePizzalinkInfoLayout.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
orderNotePizzalinkInfoLayout.setVisibility(View.VISIBLE);
|
||||
orderNotePizzalinkInfoLayout.setText(createOrderActivity.getOrderNote());
|
||||
}
|
||||
}
|
||||
|
||||
private void createOrder(){
|
||||
@@ -118,6 +126,7 @@ public class CreateOrderSummaryFragment extends CreateOrderBaseFragment {
|
||||
params.put("address_id", createOrderActivity.getSelectedShippingAddress().getId());
|
||||
params.put("payment_method_title", createOrderActivity.getSelectedPaymentMethod().getTitle());
|
||||
params.put("payment_method_code", createOrderActivity.getSelectedPaymentMethod().getCode());
|
||||
params.put("comment", createOrderActivity.getOrderNote());
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class SharedPrefsHelper {
|
||||
private static final String SHARED_PREFS_NAME = "ch.pizzalink.android.preferences.";
|
||||
|
||||
private static final String PREF_KEY_CATEGORY_LIST = SHARED_PREFS_NAME + "categoryList";
|
||||
private static final String PREF_KEY_IGNORED_CATEGORY_ID_LIST = SHARED_PREFS_NAME + "ignoredCategoryIdList";
|
||||
private static final String PREF_KEY_USER = SHARED_PREFS_NAME + "user";
|
||||
private static final String PREF_KEY_CUSTOMER_TOKEN = SHARED_PREFS_NAME + "customerToken";
|
||||
private static final String PREF_KEY_USER_LOG_IN_STATUS = SHARED_PREFS_NAME + "userLoginStatus";
|
||||
@@ -50,6 +51,17 @@ public class SharedPrefsHelper {
|
||||
return gson.fromJson(sharedPreferences.getString(PREF_KEY_CATEGORY_LIST, ""), categoryListType);
|
||||
}
|
||||
|
||||
public static void saveIgnoredCategoryIdList(ArrayList<Integer> ignoredCategoryIdList){
|
||||
String ignoredCategoryIdsJsonString = gson.toJson(ignoredCategoryIdList, new TypeToken<ArrayList<Integer>>() {}.getType());
|
||||
editor.putString(PREF_KEY_IGNORED_CATEGORY_ID_LIST, ignoredCategoryIdsJsonString);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static ArrayList<Integer> readIgnoredCategoryIdList(){
|
||||
Type ignoredCategoryIdListType = new TypeToken<ArrayList<Integer>>(){}.getType();
|
||||
return gson.fromJson(sharedPreferences.getString(PREF_KEY_IGNORED_CATEGORY_ID_LIST, ""), ignoredCategoryIdListType);
|
||||
}
|
||||
|
||||
|
||||
public static void saveUser(UserModel user){
|
||||
editor.putString(PREF_KEY_USER, gson.toJson(user));
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ch.pizzalink.android.api.ApiConstants;
|
||||
import ch.pizzalink.android.helper.SharedPrefsHelper;
|
||||
|
||||
/**
|
||||
* Created by cimenmus on 26/09/2017.
|
||||
@@ -43,6 +44,10 @@ public class CategoryModel implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDescriptionVisible(){
|
||||
return !SharedPrefsHelper.readIgnoredCategoryIdList().contains(id);
|
||||
}
|
||||
|
||||
public String getCategoryIdString(){
|
||||
return String.valueOf(id);
|
||||
}
|
||||
|
||||
@@ -96,22 +96,12 @@ public class PizzalinkEditText extends LinearLayout implements View.OnClickListe
|
||||
case "address":
|
||||
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
|
||||
editText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
// if edittext has 10chars & this is not called yet, add new line
|
||||
if(editText.getText().length() == 40 * editText.getLineCount()) {
|
||||
editText.append("\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
goNextLineWhenEndOfLine();
|
||||
break;
|
||||
case "multiline":
|
||||
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
goNextLineWhenEndOfLine();
|
||||
break;
|
||||
default:
|
||||
editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_CLASS_TEXT |
|
||||
@@ -141,6 +131,24 @@ public class PizzalinkEditText extends LinearLayout implements View.OnClickListe
|
||||
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
|
||||
}
|
||||
|
||||
private void goNextLineWhenEndOfLine(){
|
||||
editText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
// if edittext has 10chars & this is not called yet, add new line
|
||||
if(editText.getText().length() == 40 * editText.getLineCount()) {
|
||||
editText.append("\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return editText.getText().toString().isEmpty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user