mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
Merge pull request #58 from lacerta-doc/data/add_search_stub
LacertaSearchインタフェースにスタブを追加
This commit is contained in:
commit
1d3015a7e4
|
@ -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<ListItem> autoSearch(String query, int limit);
|
||||
|
||||
ListItem autoSearch(String query, int limit, int offset);
|
||||
ArrayList<ListItem> autoSearch(String query, int limit, int offset);
|
||||
|
||||
}
|
||||
|
|
|
@ -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<ListItem> autoSearch(String query, int limit) {
|
||||
logger.debug("SearchStub", "autoSearch");
|
||||
logger.debug("SearchStub", "query: " + query);
|
||||
return library.getLibraryPage(limit).getListItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ListItem> autoSearch(String query, int limit, int offset) {
|
||||
logger.debug("SearchStub", "autoSearch");
|
||||
logger.debug("SearchStub", "query: " + query);
|
||||
return library.getLibraryPage(limit, offset).getListItems();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user