mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Injected proper classes in WebServerHelper
This commit is contained in:
parent
7faf13ee3a
commit
1669a87d3c
@ -39,9 +39,9 @@ class ServiceModule {
|
||||
@Provides
|
||||
@ServiceScope
|
||||
fun providesWebServerHelper(
|
||||
kiwixServer: KiwixServer,
|
||||
kiwixServerFactory: KiwixServer.Factory,
|
||||
ipAddressCallbacks: IpAddressCallbacks
|
||||
): WebServerHelper = WebServerHelper(kiwixServer, ipAddressCallbacks)
|
||||
): WebServerHelper = WebServerHelper(kiwixServerFactory, ipAddressCallbacks)
|
||||
|
||||
@Provides
|
||||
@ServiceScope
|
||||
|
@ -28,7 +28,7 @@ private const val TAG = "KiwixServer"
|
||||
|
||||
class KiwixServer @Inject constructor(private val jniKiwixServer: JNIKiwixServer) {
|
||||
|
||||
class Factory {
|
||||
class Factory @Inject constructor() {
|
||||
fun createKiwixServer(selectedBooksPath: ArrayList<String>): KiwixServer {
|
||||
val kiwixLibrary = Library()
|
||||
selectedBooksPath.forEach { path ->
|
||||
|
@ -40,13 +40,14 @@ import static org.kiwix.kiwixmobile.core.utils.ServerUtils.INVALID_IP;
|
||||
public class WebServerHelper {
|
||||
private static final String TAG = "WebServerHelper";
|
||||
private KiwixServer kiwixServer;
|
||||
private KiwixServer.Factory kiwixServerFactory;
|
||||
private IpAddressCallbacks ipAddressCallbacks;
|
||||
private boolean isServerStarted;
|
||||
private JNIKiwixServer server;
|
||||
|
||||
@Inject public WebServerHelper(@NonNull KiwixServer kiwixServer,
|
||||
@Inject public WebServerHelper(@NonNull KiwixServer.Factory kiwixServerFactory,
|
||||
@NonNull IpAddressCallbacks ipAddressCallbacks) {
|
||||
this.kiwixServer = kiwixServer;
|
||||
this.kiwixServerFactory = kiwixServerFactory;
|
||||
this.ipAddressCallbacks = ipAddressCallbacks;
|
||||
}
|
||||
|
||||
@ -71,8 +72,7 @@ public class WebServerHelper {
|
||||
if (!isServerStarted) {
|
||||
int DEFAULT_PORT = 8080;
|
||||
ServerUtils.port = DEFAULT_PORT;
|
||||
KiwixServer.Factory factory = new KiwixServer.Factory();
|
||||
kiwixServer = factory.createKiwixServer(selectedBooksPath);
|
||||
kiwixServer = kiwixServerFactory.createKiwixServer(selectedBooksPath);
|
||||
updateServerState(kiwixServer.startServer(ServerUtils.port));
|
||||
Log.d(TAG, "Server status" + isServerStarted);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user