Comments (9)
Unfortunately, I'm not too familiar with kotlin. Are you sure that TaskCompletionSource
being an internal class is the problem?
Are you able to initialize TaskCompletionSource
on it's own like the following?
Task<String>.TaskCompletionSource tcs = Task.create();
tcs.setResult("ggg");
(This is in Java as I'm unfamiliar with Kotlin syntax)
Additionally, TaskCompletionSource
needs to modify the internals of Task
, so it'd require a huge amount of refactoring to make it a non-internal class.
from bolts-android.
I made TaskCompletionSource static and its works fine now.
Check out here: https://github.com/romansl/Bolts-Android/blob/989541b7492452189da34a3277284778fbba6616/Bolts/src/bolts/Task.java#L502
from bolts-android.
Would be a breaking change
from bolts-android.
Could this be a bug in Kotlin that has been fixed since?
from bolts-android.
This is actually not a bug with Kotlin, it is by design. You can read here http://blog.jetbrains.com/kotlin/2015/04/upcoming-changes-and-more/.
When a generic class Outer has an inner class Inner, Java allows us to use generic parameters of Outer inside Inner:
Although very logical, this feature also has rather few use cases, and current implementation we have in Kotlin requires a lot of work before it is production quality. So, we are going to forbid this, and maybe implement it in later releases of Kotlin.
from bolts-android.
A good workaround I have found is to write an extension in Kotlin for TaskCompletionSource like so:
fun Task.TaskCompletionSource.setResult(result: Any) {
Util.setResult(this, result)
}
where Util is a Java class with static method that takes the TaskCompletionSource and the result:
public static void setResult(Task.TaskCompletionSource tcs, Object result)
tcs.setResult(result);
}
from bolts-android.
Can someone check if #84 fixes the Kotlin problems?
from bolts-android.
I can confirm #84 fixes the problem with Kotlin.
from bolts-android.
Awesome, thanks!
from bolts-android.
Related Issues (20)
- API 19 DUPLICATE ENTRY HOT 1
- Task.continueWithTask(task) is not supported?
- Task.BACKGROUND_EXECUTOR is badly defined and prone to lockups HOT 4
- Progress in whenAll() and whenAllResult()
- onSuccessInUi() shortcut for onSuccess(..., Task.UI_THREAD_EXECUTOR)? HOT 1
- Getting OOM
- com.parse.ParseException: bolts.ExecutorException: An exception was thrown by an Executor
- Easier way to unit test background Tasks HOT 1
- continueWhile HOT 3
- What happens when task is running and activity is closed ?
- Are you still updating?
- Update to MIT license HOT 3
- Publish latest version HOT 2
- ssl
- 1.5.0 HOT 3
- Bundle proguard rules
- Hello world
- Cancel a Task.call() with CancellationToken HOT 2
- Get task from TaskCompletionSource without executing it. HOT 3
- How not to start a task when creating it? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bolts-android.