Search in sources :

Example 1 with Validator

use of br.com.ilhasoft.support.validation.Validator in project open-event-orga-app by fossasia.

the class ChangePasswordFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.change_password_fragment, container, false);
    validator = new Validator(binding);
    AppCompatActivity activity = ((AppCompatActivity) getActivity());
    activity.setSupportActionBar(binding.toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    return binding.getRoot();
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) Validator(br.com.ilhasoft.support.validation.Validator) ActionBar(android.support.v7.app.ActionBar)

Example 2 with Validator

use of br.com.ilhasoft.support.validation.Validator in project open-event-orga-app by fossasia.

the class CreateTicketFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.AppTheme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    binding = DataBindingUtil.inflate(localInflater, R.layout.ticket_create_layout, container, false);
    validator = new Validator(binding.form);
    binding.submit.setOnClickListener(view -> {
        if (validator.validate())
            getPresenter().createTicket();
    });
    return binding.getRoot();
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) Validator(br.com.ilhasoft.support.validation.Validator)

Example 3 with Validator

use of br.com.ilhasoft.support.validation.Validator in project open-event-orga-app by fossasia.

the class CreateEventFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.event_create_layout, container, false);
    validator = new Validator(binding.form);
    AppCompatActivity activity = ((AppCompatActivity) getActivity());
    activity.setSupportActionBar(binding.toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    setHasOptionsMenu(true);
    binding.submit.setOnClickListener(view -> {
        if (validator.validate())
            getPresenter().createEvent();
    });
    // check if there's an google places API key
    try {
        ApplicationInfo ai = getContext().getPackageManager().getApplicationInfo(getContext().getPackageName(), PackageManager.GET_META_DATA);
        Bundle bundle = ai.metaData;
        String placesApiKey = bundle.getString("com.google.android.geo.API_KEY");
        if ("YOUR_API_KEY".equals(placesApiKey)) {
            Timber.d("Add Google Places API key in AndroidManifest.xml file to use Place Picker.");
            binding.form.buttonPlacePicker.setVisibility(View.GONE);
            binding.form.layoutLatitude.setVisibility(View.VISIBLE);
            binding.form.layoutLongitude.setVisibility(View.VISIBLE);
            showLocationLayouts();
        }
    } catch (PackageManager.NameNotFoundException e) {
        Timber.e(e, "Package name not found");
    }
    binding.form.buttonPlacePicker.setOnClickListener(view -> {
        int errorCode = googleApiAvailabilityInstance.isGooglePlayServicesAvailable(getContext());
        if (errorCode == ConnectionResult.SUCCESS) {
            // SUCCESS
            PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
            try {
                startActivityForResult(builder.build(getActivity()), PLACE_PICKER_REQUEST);
            } catch (GooglePlayServicesRepairableException e) {
                Timber.d(e, "GooglePlayServicesRepairable");
            } catch (GooglePlayServicesNotAvailableException e) {
                Timber.d("GooglePlayServices NotAvailable => Updating or Unauthentic");
            }
        } else if (googleApiAvailabilityInstance.isUserResolvableError(errorCode)) {
            // SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED
            googleApiAvailabilityInstance.getErrorDialog(getActivity(), errorCode, PLACE_PICKER_REQUEST, (dialog) -> {
                showLocationLayouts();
            });
        } else {
            // SERVICE_UPDATING, SERVICE_INVALID - can't use place picker - must enter manually
            showLocationLayouts();
        }
    });
    adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    return binding.getRoot();
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) ConnectionResult(com.google.android.gms.common.ConnectionResult) PackageManager(android.content.pm.PackageManager) RESULT_OK(android.app.Activity.RESULT_OK) Intent(android.content.Intent) Editable(android.text.Editable) TextInputLayout(android.support.design.widget.TextInputLayout) GooglePlayServicesRepairableException(com.google.android.gms.common.GooglePlayServicesRepairableException) Inject(javax.inject.Inject) EventCreateLayoutBinding(org.fossasia.openevent.app.databinding.EventCreateLayoutBinding) Validator(br.com.ilhasoft.support.validation.Validator) PlacePicker(com.google.android.gms.location.places.ui.PlacePicker) Toast(android.widget.Toast) View(android.view.View) Event(org.fossasia.openevent.app.data.models.Event) R(org.fossasia.openevent.app.R) BaseBottomSheetFragment(org.fossasia.openevent.app.common.mvp.view.BaseBottomSheetFragment) ActionBar(android.support.v7.app.ActionBar) ViewUtils.showView(org.fossasia.openevent.app.ui.ViewUtils.showView) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) ViewUtils(org.fossasia.openevent.app.ui.ViewUtils) Lazy(dagger.Lazy) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) ArrayAdapter(android.widget.ArrayAdapter) ValidateUtils(org.fossasia.openevent.app.utils.ValidateUtils) List(java.util.List) GooglePlayServicesNotAvailableException(com.google.android.gms.common.GooglePlayServicesNotAvailableException) DataBindingUtil(android.databinding.DataBindingUtil) Function(org.fossasia.openevent.app.common.Function) Nullable(android.support.annotation.Nullable) ApplicationInfo(android.content.pm.ApplicationInfo) Place(com.google.android.gms.location.places.Place) GoogleApiAvailability(com.google.android.gms.common.GoogleApiAvailability) TextWatcher(android.text.TextWatcher) Bundle(android.os.Bundle) AppCompatActivity(android.support.v7.app.AppCompatActivity) ApplicationInfo(android.content.pm.ApplicationInfo) PlacePicker(com.google.android.gms.location.places.ui.PlacePicker) PackageManager(android.content.pm.PackageManager) GooglePlayServicesRepairableException(com.google.android.gms.common.GooglePlayServicesRepairableException) Validator(br.com.ilhasoft.support.validation.Validator) ActionBar(android.support.v7.app.ActionBar) GooglePlayServicesNotAvailableException(com.google.android.gms.common.GooglePlayServicesNotAvailableException)

Example 4 with Validator

use of br.com.ilhasoft.support.validation.Validator in project open-event-orga-app by fossasia.

the class CreateCopyrightFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.AppTheme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    binding = DataBindingUtil.inflate(localInflater, R.layout.copyright_create_layout, container, false);
    validator = new Validator(binding.form);
    AppCompatActivity activity = ((AppCompatActivity) getActivity());
    activity.setSupportActionBar(binding.toolbar);
    ActionBar actionBar = activity.getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    setHasOptionsMenu(true);
    binding.submit.setOnClickListener(view -> {
        if (validator.validate())
            getPresenter().createCopyright();
    });
    return binding.getRoot();
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) AppCompatActivity(android.support.v7.app.AppCompatActivity) Validator(br.com.ilhasoft.support.validation.Validator) ActionBar(android.support.v7.app.ActionBar) Nullable(android.support.annotation.Nullable)

Example 5 with Validator

use of br.com.ilhasoft.support.validation.Validator in project open-event-orga-app by fossasia.

the class ResetPasswordByTokenFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.reset_password_by_token_fragment, container, false);
    validator = new Validator(binding);
    return binding.getRoot();
}
Also used : Validator(br.com.ilhasoft.support.validation.Validator)

Aggregations

Validator (br.com.ilhasoft.support.validation.Validator)10 Nullable (android.support.annotation.Nullable)4 ActionBar (android.support.v7.app.ActionBar)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)4 LayoutInflater (android.view.LayoutInflater)4 Context (android.content.Context)3 ContextThemeWrapper (android.view.ContextThemeWrapper)3 Bundle (android.os.Bundle)2 RESULT_OK (android.app.Activity.RESULT_OK)1 Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 DataBindingUtil (android.databinding.DataBindingUtil)1 TextInputLayout (android.support.design.widget.TextInputLayout)1 Editable (android.text.Editable)1 TextUtils (android.text.TextUtils)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ArrayAdapter (android.widget.ArrayAdapter)1