Zhomart Mukhamejanov | 8f4059d | 2018-05-18 10:15:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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 com.example.android.systemupdatersample.util; |
| 18 | |
| 19 | import android.util.SparseArray; |
| 20 | |
| 21 | /** |
| 22 | * SystemUpdaterSample app state. |
| 23 | */ |
| 24 | public class UpdaterStates { |
| 25 | |
| 26 | public static final int IDLE = 0; |
| 27 | public static final int ERROR = 1; |
| 28 | public static final int RUNNING = 2; |
| 29 | public static final int PAUSED = 3; |
| 30 | public static final int FINISHED = 4; |
| 31 | |
| 32 | private static final SparseArray<String> STATE_MAP = new SparseArray<>(); |
| 33 | |
| 34 | static { |
| 35 | STATE_MAP.put(0, "IDLE"); |
| 36 | STATE_MAP.put(1, "ERROR"); |
| 37 | STATE_MAP.put(2, "RUNNING"); |
| 38 | STATE_MAP.put(3, "PAUSED"); |
| 39 | STATE_MAP.put(4, "FINISHED"); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * converts status code to status name |
| 44 | */ |
| 45 | public static String getStateText(int state) { |
| 46 | return STATE_MAP.get(state); |
| 47 | } |
| 48 | |
| 49 | private UpdaterStates() {} |
| 50 | } |