Merge pull request #58 from lacerta-doc/data/add_search_stub

LacertaSearchインタフェースにスタブを追加
This commit is contained in:
ろむねこ 2024-01-13 14:39:12 +09:00 committed by GitHub
commit 1d3015a7e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 2 deletions

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}