SimpleDraweeView上的setImageURI:加载图像时的回调 - Android

时间:2016-12-30 09:40:05

标签: android

我正在使用此代码显示图片:

$trending_url = {
    "response": {
        "status": 200
    },
    "symbols": [{
        "id": 11631,
        "symbol": "JNUG",
        "title": "Direxion Daily Jr Gld Mnrs Bull 3X Shrs",
        "is_following": false
    }, {
        "id": 9553,
        "symbol": "NUGT",
        "title": "Direxion Daily Gold Miners Bull 3X Shrs",
        "is_following": false
    }, {
        "id": 12100,
        "symbol": "BABA",
        "title": "Alibaba",
        "is_following": false
    }]
}

foreach($trending_url->symbols as $obj){
  echo $obj->symbol."<br>";
}

我需要知道图像何时加载,因此我可以隐藏进度条。

有什么想法吗?

3 个答案:

答案 0 :(得分:5)

您可以将controller listener添加到付款人视图中。像这样:

def createStream(streamName: String): RunnableGraph[UniqueKillSwitch] =
  Source.fromGraph(new NumbersSource)
    .map(el => s"$streamName: $el")
    .viaMat(KillSwitches.single)(Keep.right)
    .to(Sink.foreach(println))

val switch1 = createStream("a").run()
// ...
switch1.shutdown()

val switch2 = createStream("b").run()
// ...
switch2.shutdown()

答案 1 :(得分:0)

@Surabhi Singh有一种更简单的方式(希望Kotlin不是问题):

val controllerBuilder = Fresco.newDraweeControllerBuilder()
controllerBuilder.setUri(url)
controllerBuilder.oldController = drawee.controller
controllerBuilder.controllerListener = object : BaseControllerListener<ImageInfo>() {
     override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
         super.onFinalImageSet(id, imageInfo, animatable)
                //image is loaded
     }
}
drawee.controller = controllerBuilder.build()

答案 2 :(得分:0)

SimpleDraweeView提供了在XML文件本身中添加进度栏的功能。因此,无需手动隐藏和显示。它将自行处理进度栏。

浏览以下代码以供参考。

colors, counts = np.unique(image.reshape(-1, 3), 
                           return_counts = True, 
                           axis = 0)