idea formatter (#84)
This commit is contained in:
parent
20a9597c35
commit
dc2b9ef3ff
|
|
@ -59,7 +59,7 @@ public final class CalendarUtils {
|
|||
* @param calendarItems List of {@link CalendarItem} where need to find specific element;
|
||||
* @param position Position of adapter;
|
||||
* @return Position of Header that respond to requested position.
|
||||
* Returns null if Header or related CalendarItem was not found for specified position.
|
||||
* Returns null if Header or related CalendarItem was not found for specified position.
|
||||
*/
|
||||
@Nullable
|
||||
public static Integer findPositionOfSelectedMonth(@NonNull final List<CalendarItem> calendarItems, final long position) {
|
||||
|
|
@ -76,7 +76,7 @@ public final class CalendarUtils {
|
|||
* @param calendarItems List of {@link CalendarItem} where need to find specific element;
|
||||
* @param date Requested date in milliseconds.
|
||||
* @return Position of Calendar cell that that has specific date.
|
||||
* Returns null if CalendarItem was not found for specified position.
|
||||
* Returns null if CalendarItem was not found for specified position.
|
||||
*/
|
||||
@Nullable
|
||||
public static Integer findPositionByDate(@NonNull final List<CalendarItem> calendarItems, final long date) {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public abstract class JsonResponseBodyConverter<T> implements Converter<Response
|
|||
validateCollection((Collection) result);
|
||||
}
|
||||
if (result instanceof Map) {
|
||||
validateCollection(((Map)result).values());
|
||||
validateCollection(((Map) result).values());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class ValidationState implements Serializable {
|
|||
|
||||
/**
|
||||
* Returns unique code of the {@link ValidationState}.
|
||||
*
|
||||
* @return code or the ValidationState.
|
||||
*/
|
||||
public int getCode() {
|
||||
|
|
@ -67,6 +68,7 @@ public class ValidationState implements Serializable {
|
|||
|
||||
/**
|
||||
* Don't forget to override this method!
|
||||
*
|
||||
* @param object that you want to compare.
|
||||
* @return true if objects equals and false otherwise.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public interface ViewWithError {
|
|||
* Shows error
|
||||
* Pass here error state.
|
||||
* It is not correct to pass here {@link ValidationState#VALID} or {@link ValidationState#INITIAL}
|
||||
*
|
||||
* @param validationState error state. Can be other than {@link ValidationState} if you have successor of base {@link ValidationState}.
|
||||
*/
|
||||
void showError(@NonNull final ValidationState validationState);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public class BooleanValidationController extends ValidationController<Boolean, B
|
|||
|
||||
/**
|
||||
* This method validates bounded view.
|
||||
*
|
||||
* @param activatedObservable emits true when we need to show error on empty fields. Eg when user clicks on Done button but he missed some
|
||||
* necessary fields to fill.
|
||||
* @return observable without any concrete type. Simply subscribe to this method to make it works.
|
||||
|
|
|
|||
|
|
@ -98,8 +98,7 @@ public class EditTextValidationController<TModel extends Serializable>
|
|||
/**
|
||||
* If we don't want to show error when focus is lost.
|
||||
*
|
||||
* @param showErrorOnFocusOut show an error or don't show an error.
|
||||
*
|
||||
* @param showErrorOnFocusOut show an error or don't show an error.
|
||||
*/
|
||||
public void setShowErrorOnFocusOut(final boolean showErrorOnFocusOut) {
|
||||
this.showErrorOnFocusOut = showErrorOnFocusOut;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ import rx.Observable;
|
|||
* Created by Ilia Kurtov on 24/01/2017.
|
||||
* {@link ValidationController} for models that have the same modal as wrapper model. You can use it when you simply need to be sure
|
||||
* that user have selected some item and it is not null.
|
||||
* @param <TModel> type of the model.
|
||||
*
|
||||
* @param <TModel> type of the model.
|
||||
* @param <TValidator> corresponding {@link Validator}
|
||||
*/
|
||||
public class SimpleValidationController<TModel extends Serializable, TValidator extends Validator<TModel, TModel>>
|
||||
|
|
@ -24,6 +25,7 @@ public class SimpleValidationController<TModel extends Serializable, TValidator
|
|||
|
||||
/**
|
||||
* This method validates bounded view.
|
||||
*
|
||||
* @param activatedObservable emits true when we need to show error on empty fields. Eg when user clicks on Done button but he missed some
|
||||
* necessary fields to fill.
|
||||
* @return observable without any concrete type. Simply subscribe to this method to make it works.
|
||||
|
|
|
|||
|
|
@ -53,10 +53,11 @@ public class ValidationController
|
|||
/**
|
||||
* Bind to this observable to connect view and model. If you provide first argument (viewStateObservable) - the connection would be two-way.
|
||||
* If not - one-way. This method changes updates view with current {@link ValidationState}.
|
||||
*
|
||||
* @param viewStateObservable input view state {@link Observable}.
|
||||
* Eg it can be observable with input text from the {@link android.widget.EditText}
|
||||
* @param updateViewAction action that updates current state of the bounded view.
|
||||
* @param viewWithError view that implements {@link ViewWithError} interface and could reacts to the validation errors.
|
||||
* @param updateViewAction action that updates current state of the bounded view.
|
||||
* @param viewWithError view that implements {@link ViewWithError} interface and could reacts to the validation errors.
|
||||
* @return observable without any concrete type. Simply subscribe to this method to make it works.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -68,7 +69,7 @@ public class ValidationController
|
|||
: Observable.empty();
|
||||
return Observable
|
||||
.merge(getValidator().getWrapperModel().observe()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext(updateViewAction),
|
||||
getValidator().getValidationState().observe()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
@ -84,6 +85,7 @@ public class ValidationController
|
|||
|
||||
/**
|
||||
* Helper function to check if validation state in error state ot not
|
||||
*
|
||||
* @param validationState the state you want to check for the errors.
|
||||
* @return true if validation state is in error and false otherwise.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
* This flag needed to force showing errors. You don't want to show final error when you start to enter data in some field at first time.
|
||||
* But if user leaves this view and final check not passed - you need to force to show an error till user not enters correct data and leaves
|
||||
* the view.
|
||||
*
|
||||
* @return {@link NonNullChangeable} with current state of the flag - do we need to show errors from final checks while user types.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -60,6 +61,7 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
|
||||
/**
|
||||
* Use this method to get or set final check.
|
||||
*
|
||||
* @return final check.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -69,6 +71,7 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
|
||||
/**
|
||||
* Use this method to get or set primary check.
|
||||
*
|
||||
* @return primary check.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -119,6 +122,7 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
|
||||
/**
|
||||
* Validates text with primary check.
|
||||
*
|
||||
* @param text - input text.
|
||||
* @return {@link Observable} with the result of the primary check.
|
||||
*/
|
||||
|
|
@ -129,6 +133,7 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
|
||||
/**
|
||||
* Validates text with final check.
|
||||
*
|
||||
* @param text - input text.
|
||||
* @return {@link Observable} with the result of the final check.
|
||||
*/
|
||||
|
|
@ -140,9 +145,10 @@ public abstract class EditTextValidator<TModel extends Serializable> extends Val
|
|||
/**
|
||||
* Validates text with primary and final check consequentially and returns {@link Observable} with {@link HalfNullablePair} of final state
|
||||
* and resulting model.
|
||||
*
|
||||
* @param text - input text.
|
||||
* @return pair with final {@link ValidationState} that is always not null and a model that we get after converting the text.
|
||||
* Model can be null if validation fails on primary or final checks.
|
||||
* Model can be null if validation fails on primary or final checks.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@ import rx.Observable;
|
|||
/**
|
||||
* Created by Ilia Kurtov on 24/01/2017.
|
||||
* Class that simplifies work with {@link Validator}'s that have the same wrapper model and model type.
|
||||
*
|
||||
* @param <TModel> model that should be bounded with a view.
|
||||
*/
|
||||
public class SameTypeValidator<TModel extends Serializable> extends Validator<TModel, TModel> {
|
||||
|
||||
/**
|
||||
* Simply returns the same model without any converting.
|
||||
*
|
||||
* @param wrapperModel input model.
|
||||
* @return the same model as input parameter.
|
||||
* @throws Throwable - in this case no throwable would be thrown.
|
||||
|
|
@ -31,9 +33,10 @@ public class SameTypeValidator<TModel extends Serializable> extends Validator<TM
|
|||
|
||||
/**
|
||||
* Validates {@link TModel} and returns {@link Observable} with {@link HalfNullablePair} of final state and resulting model.
|
||||
*
|
||||
* @param wrapperModel - not null value that should be validated.
|
||||
* @return pair with final {@link ValidationState} that is always not null and a model that we get after converting the {@link TModel}.
|
||||
* Model can be null if validation fails.
|
||||
* Model can be null if validation fails.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public abstract class Validator<TWrapperModel extends Serializable, TModel exten
|
|||
|
||||
/**
|
||||
* This method converts {@link TWrapperModel} into a {@link TModel}.
|
||||
*
|
||||
* @param wrapperModel - not null value that should be converted into a {@link TModel} object.
|
||||
* @return converted wrapperModel into a {@link TModel}.
|
||||
* @throws Throwable for the cases when converting cannot be processed.
|
||||
|
|
@ -63,6 +64,7 @@ public abstract class Validator<TWrapperModel extends Serializable, TModel exten
|
|||
|
||||
/**
|
||||
* Call this method to get {@link Changeable} with {@link TWrapperModel} inside it that should be connected to its bounded view.
|
||||
*
|
||||
* @return {@link Changeable} with {@link TWrapperModel}.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -72,6 +74,7 @@ public abstract class Validator<TWrapperModel extends Serializable, TModel exten
|
|||
|
||||
/**
|
||||
* Returns current {@link ValidationState} or its successor. Needed to connect with bounded view and react to this state changes.
|
||||
*
|
||||
* @return current validation state.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -82,6 +85,7 @@ public abstract class Validator<TWrapperModel extends Serializable, TModel exten
|
|||
/**
|
||||
* This method needed to get {@link ValidationState} that needed to be shown when bounded view is empty and you need to show to user reminder,
|
||||
* that he or she needs to fill this view.
|
||||
*
|
||||
* @return {@link ValidationState} that should be shown for an empty field.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -91,9 +95,10 @@ public abstract class Validator<TWrapperModel extends Serializable, TModel exten
|
|||
|
||||
/**
|
||||
* Validates {@link TWrapperModel} and returns {@link Observable} with {@link HalfNullablePair} of final state and resulting model.
|
||||
*
|
||||
* @param wrapperModel - not null value that should be validated.
|
||||
* @return pair with final {@link ValidationState} that is always not null and a model that we get after converting the {@link TWrapperModel}.
|
||||
* Model can be null if validation fails.
|
||||
* Model can be null if validation fails.
|
||||
*/
|
||||
@NonNull
|
||||
public abstract Observable<HalfNullablePair<ValidationState, TModel>> fullValidateAndGetModel(@NonNull final TWrapperModel wrapperModel);
|
||||
|
|
|
|||
Loading…
Reference in New Issue