You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package com.community.pocket.util;
|
|
|
|
|
|
|
|
import androidx.lifecycle.MutableLiveData;
|
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
import okhttp3.Call;
|
|
|
|
import okhttp3.Response;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HTTP响应实体
|
|
|
|
*
|
|
|
|
* @param <T>
|
|
|
|
*/
|
|
|
|
public class SimpleHttpParse<T extends com.community.pocket.ui.main.ui.share.Response> implements HttpParse<T> {
|
|
|
|
|
|
|
|
private MutableLiveData liveData;
|
|
|
|
|
|
|
|
public SimpleHttpParse(MutableLiveData liveData) {
|
|
|
|
this.liveData = liveData;
|
|
|
|
}
|
|
|
|
|
|
|
|
public HttpResponse<T> getInterface(Class<T> tClass) {
|
|
|
|
return new HttpResponse<>(tClass, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public void onParseOk(@NotNull Call call, @NotNull Response response, T t) {
|
|
|
|
liveData.postValue(t);
|
|
|
|
}
|
|
|
|
}
|