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

end() not call when you cancel an UserTask (photostream sample) #16

Closed
GoogleCodeExporter opened this issue Sep 6, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hello

I extend photostream class called UserTask. If I call cancel(true) on my 
class he don't call my overrided end() (but my task is cancel).

private class Tick extends UserTask<Integer, Integer, Integer> {
        private int mTarget = 0;

        @Override
        public void begin() {

        }

        public Integer doInBackground(Integer... params) {
            //int target = Integer.parseInt(params[0].trim());
            mTarget = params[0];
            int end = params[1];
            int i = 0;
            while (i <= end && !isCancelled()) {
                    publishProgress(i);
                    try {
                    java.lang.Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                    e.printStackTrace();
            }
            i++;
            }
            return i;
        }

        public void processProgress(Integer... progress) {
            if(!isCancelled())
            {
                mSwitcher.setText(Integer.toString(progress[0]));
            }
        }

        @Override
        public void end(Integer result) {
            if(result == mTarget)
            {
                android.util.Log.d(NoName.LOG_TAG, "WIN");
            }
            else
            {
                android.util.Log.w(NoName.LOG_TAG, "LOSE");
            }
            mTick = null;
        }
    }

Original issue reported on code.google.com by barbapapaz@gmail.com on 9 Sep 2008 at 12:19

@GoogleCodeExporter
Copy link
Author

end() will not be called, instead onCancelled() will be called.

Original comment by romaingu...@gtempaccount.com on 11 Sep 2008 at 9:23

  • Changed state: Fixed

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

No branches or pull requests

1 participant