Hello everyone I want to know how I can improve th...
# android
b
Hello everyone I want to know how I can improve this code snippet. I am tasked with converting the java code to kotlin
Copy code
public class E2EEService {
    Context context;
    public EThree eThree = null;
    ApiService apiService;

    public E2EEService(@NotNull ApiService apiService, Context context) {
        this.apiService = apiService;
        this.context = context;
    }

    public void initE2EE(Callback<Void> initCallback) {
        Callback<User> requestCallback = new Callback<User>() {
            @Override
            public void onSuccess(User user) {
                Function0<String> getToken = () -> user.virgilJwt;
                EThreeParams eThreeParams = new EThreeParams(
                        user.uuid,
                        getToken,
                        context
                );
                E2EEService.this.eThree = new EThree(eThreeParams);
                initCallback.onSuccess(null);
            }

            @Override
            public void onError(Throwable throwable) {
                initCallback.onError(throwable);
            }
        };

        apiService.getUser(requestCallback);
    }
So this is the callback
Copy code
public interface Callback<T> {
    void onSuccess(T t);
    void onError(Throwable throwable);
}
Possibly wrap it in a try catch block but then the apiService getUser function comes in