Giter Site home page Giter Site logo

Comments (8)

xuyecan avatar xuyecan commented on May 18, 2024

没太听明白你的需求。

callback是在调用上传、下载接口的时候以参数形式传进去的,如果有不同的callback,延迟到调用时决定不可以吗?

from aliyun-oss-android-sdk.

start141 avatar start141 commented on May 18, 2024

意思是我需要在上传下载中途更换callback.

from aliyun-oss-android-sdk.

xuyecan avatar xuyecan commented on May 18, 2024

callback归属于任务,在调用的时候决定我觉得是合理的。归属给谁都不合适。

你说的需求,不可以把业务逻辑延迟到callback中决定吗?效果是一样的吧。比如,实现一个类implements callback接口,调用时候将它传入,然后持有它在不同场景中改变状态,等到回调它的时候,它根据自己的状态来决定做什么事情。

from aliyun-oss-android-sdk.

start141 avatar start141 commented on May 18, 2024

你可以看一下其他项目,像android View的Onclicklistener也是一个callback,同样有setter/getter方法,同一个View我可以根据时机设置不同的listener,这是完全合理的,你说的什么归属我不赞同。

from aliyun-oss-android-sdk.

start141 avatar start141 commented on May 18, 2024

你说的用延迟啊implements之类的就会把问题复杂化了。

from aliyun-oss-android-sdk.

start141 avatar start141 commented on May 18, 2024

callback确实是归属于任务,但是我的意思是要提供一个给任务set callback的方法,新set的callback还是归属于之前的任务,不知道你是不是理解错我的意思了。

from aliyun-oss-android-sdk.

xuyecan avatar xuyecan commented on May 18, 2024

你打的比方不对,OnClickListener是监听器,持续性地对动作序列做响应,可以随时更换响应逻辑是合理的。

但SDK这里,是任务回调,在任务发起时就应该决定,以参数形式传入。任务完成时需要做什么处理,这个应该在回调里处理,而不是在外面决定更换什么回调。

你看下okhttp,或者android-async-http。这些才是一样的场景,它们都是在任务发起时传入handler,发起后就换不了了。

from aliyun-oss-android-sdk.

start141 avatar start141 commented on May 18, 2024

好吧,这个问题我已经用别的办法解决了。

from aliyun-oss-android-sdk.

Related Issues (20)

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.