Giter VIP home page Giter VIP logo

Comments (7)

huangxumin avatar huangxumin commented on August 21, 2024

额,我现在oncreate调用 RxLife.with(this),初始化之后就不会出现这个问题了。。

from rxlife.

huangxumin avatar huangxumin commented on August 21, 2024

Attempt to invoke virtual method 'void io.reactivex.subjects.Subject.onNext(java.lang.Object)' on a null object reference,其他地方还是会报错。

from rxlife.

dhhAndroid avatar dhhAndroid commented on August 21, 2024

你调用代码我看一下,是否添加依赖 RxJava2,我看了代码,此处调用的是 lifecycleSubject.onNext()方法,lifecycleSubject已经在类实例化的时候初始化了 lifecycleSubject,点击查看LifecycleBridge代码,另外在Activity里使用有问题吗 ?是不是Fragment 的问题,Fragment只能是v4包下的 Fragment

from rxlife.

dhhAndroid avatar dhhAndroid commented on August 21, 2024

@huangxumin Fragment应该是动态添加的吧 ?

from rxlife.

huangxumin avatar huangxumin commented on August 21, 2024

有添加rxjava2依赖,activity也会出现这个问题,我觉得不是fragment的问题。我跳转activity也会出现这个问题。fargment是动态添加的

 //判断此Fragment是否已经添加到FragmentTransaction事物中
    if (!fragment.isAdded()) {
        ft.add(R.id.fragment, fragment, fragment.getClass().getName());
    } else {
        ft.show(fragment);
    }

是v4的fragment,activity继承fragmentAvtivity.

这是activity和fragmrnt的调用代码:
注释的rxlife,我现在用RxLifecycle测试。

baseActivity里面:

public <T> LifecycleTransformer<T> bindToLifecycle() {

// return RxLife.with(this).bindOnDestroy();
return RxLifecycle.with(this).bindOnDestroy();
}
调用:

RxView.clicks(back).throttleFirst(1, TimeUnit.SECONDS).compose(bindToLifecycle())

.subscribe(new Consumer() {
@OverRide
public void accept(Unit o) throws Exception {
onBackPressed();
}
});

from rxlife.

dhhAndroid avatar dhhAndroid commented on August 21, 2024

原因我已经查到,类加载构造方法执行顺序的问题,可能会导致这个问题,我正在解决,随后发布代码

from rxlife.

dhhAndroid avatar dhhAndroid commented on August 21, 2024

你试一下使用最新的1.1.3版本,能否解决问题

from rxlife.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.