diff --git a/data/src/main/java/one/nem/lacerta/data/LacertaSearch.java b/data/src/main/java/one/nem/lacerta/data/LacertaSearch.java index d8c337f0..04e27783 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaSearch.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaSearch.java @@ -1,11 +1,13 @@ package one.nem.lacerta.data; +import java.util.ArrayList; + import one.nem.lacerta.model.ListItem; public interface LacertaSearch { - ListItem autoSearch(String query, int limit); + ArrayList autoSearch(String query, int limit); - ListItem autoSearch(String query, int limit, int offset); + ArrayList autoSearch(String query, int limit, int offset); } diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaSearchStubImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaSearchStubImpl.java new file mode 100644 index 00000000..ff56abe4 --- /dev/null +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaSearchStubImpl.java @@ -0,0 +1,38 @@ +package one.nem.lacerta.data.impl; + +import java.util.ArrayList; + +import javax.inject.Inject; + +import one.nem.lacerta.data.LacertaSearch; +import one.nem.lacerta.model.ListItem; + +import one.nem.lacerta.data.LacertaLibrary; +import one.nem.lacerta.utils.LacertaLogger; + +public class LacertaSearchStubImpl implements LacertaSearch { + + private LacertaLibrary library; + private LacertaLogger logger; + + + @Inject + public LacertaSearchStubImpl(LacertaLibrary library, LacertaLogger logger) { + this.library = library; + this.logger = logger; + } + + @Override + public ArrayList autoSearch(String query, int limit) { + logger.debug("SearchStub", "autoSearch"); + logger.debug("SearchStub", "query: " + query); + return library.getLibraryPage(limit).getListItems(); + } + + @Override + public ArrayList autoSearch(String query, int limit, int offset) { + logger.debug("SearchStub", "autoSearch"); + logger.debug("SearchStub", "query: " + query); + return library.getLibraryPage(limit, offset).getListItems(); + } +} diff --git a/data/src/main/java/one/nem/lacerta/data/module/LacertaSearchModule.java b/data/src/main/java/one/nem/lacerta/data/module/LacertaSearchModule.java new file mode 100644 index 00000000..3357fb42 --- /dev/null +++ b/data/src/main/java/one/nem/lacerta/data/module/LacertaSearchModule.java @@ -0,0 +1,16 @@ +package one.nem.lacerta.data.module; + +import dagger.Binds; +import dagger.Module; +import dagger.hilt.InstallIn; +import dagger.hilt.android.components.FragmentComponent; +import one.nem.lacerta.data.LacertaSearch; +import one.nem.lacerta.data.impl.LacertaSearchStubImpl; + +@Module +@InstallIn(FragmentComponent.class) +abstract public class LacertaSearchModule { + + @Binds + public abstract LacertaSearch bindLacertaSearch(LacertaSearchStubImpl impl); +}