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