0
我正在使用Android Image Slider库来显示滑块上的图像。但是,某些图像未加载,因为后端需要验证。所以我需要一个监听器来加载图像。Android应用程序模块中未调用Android库模块的接口方法
这是库:在抽象BaseSliderView类里面,有ImageLoadListener接口。我使用setOnImageLoadListener方法设置监听器。
public abstract class BaseSliderView {
.....
private ImageLoadListener mLoadListener;
.....
protected void bindEventAndShow(final View v, ImageView targetImageView){
....
rq.into(targetImageView,new Callback() {
@Override
public void onSuccess() {
if(v.findViewById(R.id.loading_bar) != null){
v.findViewById(R.id.loading_bar).setVisibility(View.INVISIBLE);
}
}
@Override
public void onError() {
if(mLoadListener != null){
mLoadListener.onEnd(false,me);
}
if(v.findViewById(R.id.loading_bar) != null){
v.findViewById(R.id.loading_bar).setVisibility(View.INVISIBLE);
}
}
});
}
/**
* set a listener to get a message , if load error.
* @param l
*/
public void setOnImageLoadListener(ImageLoadListener l){
mLoadListener = l;
}
.....
public interface ImageLoadListener{
void onStart(BaseSliderView target);
void onEnd(boolean result,BaseSliderView target);
}
.....
}
我检查,当图像未加载时,在库模块中调用接口onEnd方法。
但是应用模块,onEnd方法甚至没有在库模块的叫法叫。
这究竟是为什么?不应该在应用程序模块中调用onEnd方法?如何解决这个问题呢?
你看看你的AndroidMonitor来检查错误吗? 尝试'Log.i(“开始”)'而不是'MyLog.log(“开始”)'; – 2017-04-01 18:43:15
它看起来像是被打了某种方式。 'mLoadListener'是你的匿名类的一个实例吗? – tynn
是的,我检查了AndroidMonitor检查错误 - 没有日志。 onEnd方法根本不被调用。 –