1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.work; 18 19 /** 20 * The current status of a unit of work. 21 */ 22 public enum State { 23 24 /** 25 * The status for work that is enqueued (hasn't completed and isn't running) 26 */ 27 ENQUEUED, 28 29 /** 30 * The status for work that is currently being executed 31 */ 32 RUNNING, 33 34 /** 35 * The status for work that has completed successfully 36 */ 37 SUCCEEDED, 38 39 /** 40 * The status for work that has completed in a failure state 41 */ 42 FAILED, 43 44 /** 45 * The status for work that is currently blocked because its prerequisites haven't finished 46 * successfully 47 */ 48 BLOCKED, 49 50 /** 51 * The status for work that has been cancelled and will not execute 52 */ 53 CANCELLED; 54 55 /** 56 * Returns {@code true} if this State is considered finished. 57 * 58 * @return {@code true} for {@link #SUCCEEDED}, {@link #FAILED}, and {@link #CANCELLED} States 59 */ 60 public boolean isFinished() { 61 return (this == SUCCEEDED || this == FAILED || this == CANCELLED); 62 } 63 } 64