From c70164078baaa80fd63b3ef35cfc08a620102d6d Mon Sep 17 00:00:00 2001 From: Fernando Franco Giraldez Date: Mon, 9 Apr 2018 23:48:46 +0200 Subject: [PATCH] refactor: :recycle: remove ReplaceToVoid use Replacements.returnVoid() closes #2 --- .../ffgiraldez/comicsearch/ReplaceToVoid.java | 26 ------------------- .../comicsearch/rx/Replacements.java | 10 +++++++ .../search/presentation/SearchViewModel.java | 4 +-- .../presentation/SuggestionViewModel.java | 5 ++-- 4 files changed, 15 insertions(+), 30 deletions(-) delete mode 100644 app/src/main/java/es/ffgiraldez/comicsearch/ReplaceToVoid.java create mode 100644 app/src/main/java/es/ffgiraldez/comicsearch/rx/Replacements.java diff --git a/app/src/main/java/es/ffgiraldez/comicsearch/ReplaceToVoid.java b/app/src/main/java/es/ffgiraldez/comicsearch/ReplaceToVoid.java deleted file mode 100644 index 291f3e6..0000000 --- a/app/src/main/java/es/ffgiraldez/comicsearch/ReplaceToVoid.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2015 Fernando Franco Giráldez - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package es.ffgiraldez.comicsearch; - -import rx.functions.Func1; - -public class ReplaceToVoid implements Func1 { - @Override - public Void call(T t) { - return null; - } -} diff --git a/app/src/main/java/es/ffgiraldez/comicsearch/rx/Replacements.java b/app/src/main/java/es/ffgiraldez/comicsearch/rx/Replacements.java new file mode 100644 index 0000000..4fd9fa7 --- /dev/null +++ b/app/src/main/java/es/ffgiraldez/comicsearch/rx/Replacements.java @@ -0,0 +1,10 @@ +package es.ffgiraldez.comicsearch.rx; + +import es.ffgiraldez.comicsearch.ReplaceToVoid; +import rx.functions.Func1; + +public class Replacements { + public static Func1 returnVoid() { + return new ReplaceToVoid(); + } +} diff --git a/app/src/main/java/es/ffgiraldez/comicsearch/search/presentation/SearchViewModel.java b/app/src/main/java/es/ffgiraldez/comicsearch/search/presentation/SearchViewModel.java index 4b34bc1..e8627a9 100644 --- a/app/src/main/java/es/ffgiraldez/comicsearch/search/presentation/SearchViewModel.java +++ b/app/src/main/java/es/ffgiraldez/comicsearch/search/presentation/SearchViewModel.java @@ -18,9 +18,9 @@ import java.util.List; -import es.ffgiraldez.comicsearch.ReplaceToVoid; import es.ffgiraldez.comicsearch.data.ComicStorage; import es.ffgiraldez.comicsearch.model.SearchResult; +import es.ffgiraldez.comicsearch.rx.Replacements; import es.ffgiraldez.comicsearch.search.domain.FetchSearchResultTransformer; import rx.Observable; @@ -40,7 +40,7 @@ public void initialize() { subscribe(Property.RESULTS, fetchResultObservable); Observable> resultsObservable = observe(Property.RESULTS); - updatedResultsObservable = resultsObservable.map(new ReplaceToVoid>()); + updatedResultsObservable = resultsObservable.map(Replacements.returnVoid()); } public Observable didUpdateResults() { diff --git a/app/src/main/java/es/ffgiraldez/comicsearch/sugestion/presentation/SuggestionViewModel.java b/app/src/main/java/es/ffgiraldez/comicsearch/sugestion/presentation/SuggestionViewModel.java index b0c2ac5..6a32fd6 100644 --- a/app/src/main/java/es/ffgiraldez/comicsearch/sugestion/presentation/SuggestionViewModel.java +++ b/app/src/main/java/es/ffgiraldez/comicsearch/sugestion/presentation/SuggestionViewModel.java @@ -19,8 +19,8 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import es.ffgiraldez.comicsearch.ReplaceToVoid; import es.ffgiraldez.comicsearch.data.ComicStorage; +import es.ffgiraldez.comicsearch.rx.Replacements; import es.ffgiraldez.comicsearch.sugestion.domain.FetchQueryTransformer; import rx.Observable; @@ -32,6 +32,7 @@ public class SuggestionViewModel extends ObservableSuggestionViewModel { public SuggestionViewModel(ComicStorage comicStorage) { this.comicStorage = comicStorage; } + @Override public void initialize() { Observable input = this.observe(Property.QUERY) @@ -42,7 +43,7 @@ public void initialize() { subscribe(Property.SUGGESTIONS, suggestionObservable); Observable> suggestionPropObservable = observe(Property.SUGGESTIONS); - updatedSuggestionsObservable = suggestionPropObservable.map(new ReplaceToVoid>()); + updatedSuggestionsObservable = suggestionPropObservable.map(Replacements.returnVoid()); } public Observable didUpdateSuggestion() {