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

Progress on download file #7

Open
crysan opened this issue Dec 12, 2016 · 3 comments
Open

Progress on download file #7

crysan opened this issue Dec 12, 2016 · 3 comments

Comments

@crysan
Copy link

crysan commented Dec 12, 2016

Hi!
I'm trying to do in RecyclerView progress display when copying files. But it displays only the last one (100%) results.

                try {
                    InputStream input = null;
                    OutputStream output = null;
                    long lenghtOfFile = source.length();
                    int count;
                    try {
                        input = new FileInputStream(source);
                        output = new FileOutputStream(destination);
                        byte[] data = new byte[1024];
                        long total  = 0;
                        while ((count = input.read(data)) != -1) {
                            total += count;
                            int xc = (int) ((total * 100) / lenghtOfFile);
                            holder.progress_bar.setProgress(xc);
                        }
                    } finally {
                        output.flush();
                        output.close();
                        input.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }

Why are not the intermediate values?

@HotBitmapGG
Copy link
Owner

This item should be caused by reuse progress bar is not normal! @crysan

@crysan
Copy link
Author

crysan commented Feb 28, 2017

I've already figured out. Thank you!
It is a pity that the answer for so long ((

@HotBitmapGG
Copy link
Owner

@crysan I'm sorry, because too busy working on my side, there has been no time to maintain the project

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

2 participants