vimeo / vimeo-networking-java

The Vimeo Java (Android) SDK
MIT License
121 stars 49 forks source link

'void com.vimeo.networking.GsonDeserializer.deserialize #398

Open DhirajG opened 5 years ago

DhirajG commented 5 years ago
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.vimeo.networking.GsonDeserializer.deserialize(com.google.gson.Gson, java.lang.Object, com.vimeo.networking.callbacks.ModelCallback)' on a null object reference
        at com.vimeo.networking.VimeoClient$5.success(VimeoClient.java:1169)
        at com.vimeo.networking.callbacks.VimeoCallback.onResponse(VimeoCallback.java:55)
        at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
var configBuilder = Configuration.Builder(VimeoHelper.clientId, VimeoHelper.clientSecret, VimeoHelper.SCOPE)
    .setCacheDirectory(activity?.getCacheDir())

VimeoClient.initialize(configBuilder.build());
VimeoClient.getInstance().authorizeWithClientCredentialsGrant(object : AuthCallback {
    override fun success() {
        vimeoClient = VimeoClient.getInstance();
        playVideo();
    }

    override fun failure(error: VimeoError?) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
})

vimeoClient ?.fetchNetworkContent("/videos/354539932", object : ModelCallback<VideoList>(com.vimeo.networking.model.VideoList::class.java) {
    override fun success(video: com.vimeo.networking.model.VideoList?) {
        Helper.setLog(TAG,"success")
    }

    override fun failure(error: VimeoError) {
        Helper.setLog(TAG,"failure"+error.developerMessage)
    }
})
Vishal12796 commented 4 years ago

intialize the Configuration.Builder with this parameter in "getClientIdAndClientSecretBuilder()"

    GsonDeserializer gsonDeserializer = new GsonDeserializer();
    ModelCallback<Object> videoModelCallback = new ModelCallback<Object>(Object.class) {
        @Override
        public void success(Object video) {  }

        @Override
        public void failure(VimeoError error) { }
    };
    gsonDeserializer.deserialize(new Gson(), new Object(), videoModelCallback);

    Configuration.Builder configBuilder =
            new Configuration.Builder(clientId, clientSecret, SCOPE, null, gsonDeserializer);