18911006322 / apps-for-android

Automatically exported from code.google.com/p/apps-for-android
Apache License 2.0
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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 commented 8 years ago
end() will not be called, instead onCancelled() will be called.

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