aboutsummaryrefslogtreecommitdiff
path: root/src/com/cyanogenmod/filemanager/commands/AsyncResultExecutable.java
blob: c53aa19205904f740449eb934b292a139e274558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * Copyright (C) 2012 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cyanogenmod.filemanager.commands;

/**
 * An interface that defines a class as executable in an asynchronous way.
 */
public interface AsyncResultExecutable extends Executable {

    /**
     * An interface that let to request the ending of the current
     * execution of an {@link Executable}.
     */
    public interface OnEndListener {
        /**
         * Invoked when a request of ending of the current execution
         *
         * @param signal The signal to send
         * @return boolean If the execution was ended
         */
        boolean onSendSignal(SIGNAL signal);

        /**
         * Invoked when a request of ending of the current execution
         *
         * @return boolean If the execution was ended
         */
        boolean onEnd();
    }

    /**
     * An interface that let to request the cancellation of the current
     * execution of an {@link Executable}.
     */
    public interface OnCancelListener {
        /**
         * Invoked when a request of cancellation of the current execution
         *
         * @return boolean If the execution was cancelled
         */
        boolean onCancel();
    }

    /**
     * Method that return if the command is cancelled.
     *
     * @return boolean Indicates if the command is cancelled
     */
    boolean isCancelled();

    /**
     * Method that cancels the execution of the program.
     *
     * @return boolean If the program was cancelled
     */
    boolean cancel();

    /**
     * Method that ends the execution of the program.
     *
     * @return boolean If the program was ended
     */
    boolean end();

    /**
     * Method that sets the end listener.
     *
     * @param onEndListener The end listener
     */
    void setOnEndListener(OnEndListener onEndListener);

    /**
     * Method that sets the cancel listener.
     *
     * @param onCancelListener The cancel listener
     */
    void setOnCancelListener(OnCancelListener onCancelListener);

    /**
     * Method that returns if program supports cancellation.
     *
     * @return boolean If the program supports cancellation
     */
    boolean isCancellable();


    /**
     * Method that returns the listener to communicate result in
     * an asynchronous way.
     *
     * @return AsyncResultListener The listener
     */
    AsyncResultListener getAsyncResultListener();
}