Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setCallback return void #954

Open
kaleido8675 opened this issue Jul 22, 2021 · 3 comments
Open

setCallback return void #954

kaleido8675 opened this issue Jul 22, 2021 · 3 comments

Comments

@kaleido8675
Copy link

On the latest version, setCallback method return void and I don't use any sample code on Java Android

void setCallback(FutureCallback callback);

eg.) on ProgressBarDownload.java

Incompatible types error found return void, required com.koushikdutta.async.future.Future<File>
Please help this.

downloading = Ion.with(ProgressBarDownload.this)
.load("http://developer.clockworkmod.com/downloads/51/4883/cm-10.1-20130512-CPUFREQ-m7.zip")
.progressBar(progressBar)
.progressHandler(new ProgressCallback() {
@OverRide
public void onProgress(long downloaded, long total) {
downloadCount.setText("" + downloaded + " / " + total);
}
})
.write(getFileStreamPath("zip-" + System.currentTimeMillis() + ".zip"))
.setCallback(new FutureCallback() {
@OverRide
public void onCompleted(Exception e, File result) {
resetDownload();
if (e != null) {
Toast.makeText(ProgressBarDownload.this, "Error downloading file", Toast.LENGTH_LONG).show();
return;
}
Toast.makeText(ProgressBarDownload.this, "File upload complete", Toast.LENGTH_LONG).show();
}
});

@ajaymeena
Copy link

Any update?

@arnnalddo
Copy link

arnnalddo commented Oct 15, 2021

@kaleido8675 @ajaymeena

Try this way:

`downloading = Ion.with(ProgressBarDownload.this)
.load("http://developer.clockworkmod.com/downloads/51/4883/cm-10.1-20130512-CPUFREQ-m7.zip")
.progressBar(progressBar)
.progressHandler(new ProgressCallback() {
@OverRide
public void onProgress(long downloaded, long total) {
downloadCount.setText("" + downloaded + " / " + total);
}
})
.write(getFileStreamPath("zip-" + System.currentTimeMillis() + ".zip"));

downloading.setCallback(new FutureCallback() {
@OverRide
public void onCompleted(Exception e, File result) {
resetDownload();
if (e != null) {
Toast.makeText(ProgressBarDownload.this, "Error downloading file", Toast.LENGTH_LONG).show();
return;
}
Toast.makeText(ProgressBarDownload.this, "File upload complete", Toast.LENGTH_LONG).show();
}
});`

@BrettJackson1987
Copy link

I had to add .withResponse() to the constructor, but before setting the callback separately, as in the example above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants