某些手机​​的翻新返回null

时间:2019-02-06 07:50:52

标签: android android-studio androidhttpclient

这很奇怪,我的代码在8以下的android上可以正常工作,在某些装有android 8的手机上也可以正常工作,但在有android 8的某些三星上可以正常工作,返回null /

这是我的代码:

getHomePage = ApiConnection.client.create(GetHomePage::class.java)
    getHomePage.getHomePage(Func.getUid(this))
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe({ result ->

            val Gallery = result.gallery;
            val Category = result.category
            val Product = result.products

            if (Gallery != null)
                GalleryMaker(this@MainActivity, Gallery)

            if(Category!=null){
                val catAdapter = CategoryAdapter(this@MainActivity, Category);
                rcCats?.adapter = catAdapter
                catAdapter.setOnItemClickListener(object : CategoryAdapter.ClickListener {
                    override fun onClick(pos: Int, aView: View) {
                        val item = Category.get(pos)
                        val intent: Intent = Intent(this@MainActivity, Products::class.java)
                        intent.putExtra("title", item.name)
                        intent.putExtra("id", item.id)
                        startActivity(intent)
                    }
                })
            }

            if(Product!=null){
                val productsAdapter = ProductAdapter(this@MainActivity, Product);
                rcProducts?.adapter = productsAdapter
            }


            customProgressDialog?.dismiss("")
        }, { error ->
            Log.v("this", error.printStackTrace().toString())
        })

category,product和category的结果为null。再一次,同一个应用程序在android pre 8上可以正常工作,在另一部手机上的android 8上也可以正常工作,但是在三星android版本8上,它不能正常工作并返回null

这是我的api连接:

    object ApiConnection {
    val BaseUrl = Const.BaseUrl
    val client: Retrofit
        get() {
            val gson = GsonBuilder()
                .setLenient()
                .create()

            ///for Logging
            val interceptor = HttpLoggingInterceptor()
            interceptor.level = HttpLoggingInterceptor.Level.BODY
            val client = OkHttpClient.Builder().addInterceptor(interceptor).build()


            var retrofit = Retrofit.Builder()
                .baseUrl(BaseUrl)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create(gson))
                .client(client)
                .build()
            return retrofit
        }
}

在我放下== null之前,这是只猫咪

Fatal Exception: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method b.a.a.a.b, parameter list
   at ir.s.cardiomeds.Adapters.CategoryAdapter.(Unknown Source:7)
   at ir.s.cardiomeds.MainActivity$getData$1.accept(Unknown Source:29)
   at ir.s.cardiomeds.MainActivity$getData$1.accept(Unknown Source:2)
   at io.reactivex.internal.observers.ConsumerSingleObserver.onError(Unknown Source:7)
   at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(Unknown Source:14)
   at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(Unknown Source:2)
   at android.os.Handler.handleCallback(Handler.java:789)
   at android.os.Handler.dispatchMessage(Handler.java:98)
   at android.os.Looper.loop(Looper.java:164)
   at android.app.ActivityThread.main(ActivityThread.java:6944)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

0 个答案:

没有答案