drakeet / retrofit-agera-call-adapter

Retrofit Agera Call Adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.RuntimeException: Only one Looper may be created per thread

XunMengWinter opened this issue · comments

commented

// retrofit-agera-call-adapter-master/agera-call-adapter/src/main/java/me/drakeet/retrofit2/adapter/agera/CallResponseReservoir.java

line 45

As per the discussion here this library should never call Looper.prepare(). I believe this is needed since the library uses Reservoir<T> incorrectly and not Supplier<Result<T> as I have suggested. Using Reservoir<T> turns the values into not only a Receiver (incorrectly so, since it's not using the fact) but also into an Observable (also, incorrectly, since it's not using this either).
This problem, and the problem with turning every thread that's ever used with this library into a looper thread, will go away if my suggestions are followed.

@ernstsson Pretty cool!

@ernstsson Ha ha, very happy to see your help.

@XunMengWinter
I am busy with my work recently, only write open source at night. But I am going to use Supplier to instead of Reservoir, wait for some time please, and I want to know: If write Supplier<Result<T>>, can you accept it?

    public static void prepare() {
        prepare(true);
    }
    private static void prepare(boolean quitAllowed) {
        if (sThreadLocal.get() != null) {
            throw new RuntimeException("Only one Looper may be created per thread");
        }
        sThreadLocal.set(new Looper(quitAllowed));
    }

A thread can be executed once Looper.prepare()

It has fixed in #2

commented

hi, @drakeet can you accept this?😂
Supplier<Result<Response<BoloHttpResult<IdentityList>>>> getIdentityList();

@70kg
Chinese has a word called: "牵强附会(far-fetched)". 😂🌚