Merge pull request #1992 from akkywadhwa/jni-mod-kotlin

Fixed #1991 Convert JNIModule to Kotlin
This commit is contained in:
Seán Mac Gillicuddy 2020-04-01 09:37:23 +01:00 committed by GitHub
commit 0f17813039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,36 +15,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package org.kiwix.kiwixmobile.core.di.modules; package org.kiwix.kiwixmobile.core.di.modules
import android.content.Context; import android.content.Context
import androidx.annotation.NonNull; import dagger.Module
import androidx.annotation.Nullable; import dagger.Provides
import dagger.Module; import org.kiwix.kiwixlib.JNIKiwix
import dagger.Provides; import org.kiwix.kiwixlib.JNIKiwixSearcher
import javax.inject.Singleton; import javax.inject.Singleton
import org.kiwix.kiwixlib.JNIKiwix;
import org.kiwix.kiwixlib.JNIKiwixSearcher;
/** @Module
* Created by mhutti1 on 14/04/17. class JNIModule {
*/ @Provides @Singleton
fun providesJNIKiwix(context: Context): JNIKiwix = JNIKiwix(context)
@Module public class JNIModule { @Provides @Singleton fun providesJNIKiwixSearcher(): JNIKiwixSearcher? {
@Provides return try {
@Singleton JNIKiwixSearcher()
public JNIKiwix providesJNIKiwix(@NonNull Context context) { } catch (ignore: UnsatisfiedLinkError) {
return new JNIKiwix(context); null
}
@Provides
@Singleton
@Nullable
public JNIKiwixSearcher providesJNIKiwixSearcher() {
try {
return new JNIKiwixSearcher();
} catch (UnsatisfiedLinkError ignore) {
return null;
} }
} }
} }