1 /* 2 * Copyright (C) 2023 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.chassis.car.ui.plugin.toolbar; 18 19 import android.view.View; 20 import android.widget.ProgressBar; 21 22 import androidx.annotation.NonNull; 23 24 import com.android.car.ui.toolbar.ProgressBarController; 25 26 /** 27 * Implementation of {@link ProgressBarController}. 28 * 29 * <p>This class accepts a {@link ProgressBar} in its constructor and forwards the methods 30 * of {@link ProgressBarController} to it. 31 */ 32 class ProgressBarControllerImpl implements ProgressBarController { 33 34 @NonNull 35 private final ProgressBar mProgressBar; 36 ProgressBarControllerImpl(@onNull ProgressBar progressBar)37 ProgressBarControllerImpl(@NonNull ProgressBar progressBar) { 38 mProgressBar = progressBar; 39 } 40 41 @Override setVisible(boolean visible)42 public void setVisible(boolean visible) { 43 mProgressBar.setVisibility(visible ? View.VISIBLE : View.GONE); 44 } 45 46 @Override isVisible()47 public boolean isVisible() { 48 return mProgressBar.getVisibility() == View.VISIBLE; 49 } 50 51 @Override setIndeterminate(boolean indeterminate)52 public void setIndeterminate(boolean indeterminate) { 53 mProgressBar.setIndeterminate(indeterminate); 54 } 55 56 @Override isIndeterminate()57 public boolean isIndeterminate() { 58 return mProgressBar.isIndeterminate(); 59 } 60 61 @Override setMax(int max)62 public void setMax(int max) { 63 mProgressBar.setMax(max); 64 } 65 66 @Override getMax()67 public int getMax() { 68 return mProgressBar.getMax(); 69 } 70 71 @Override setMin(int min)72 public void setMin(int min) { 73 mProgressBar.setMin(min); 74 } 75 76 @Override getMin()77 public int getMin() { 78 return mProgressBar.getMin(); 79 } 80 81 @Override setProgress(int progress)82 public void setProgress(int progress) { 83 mProgressBar.setProgress(progress); 84 } 85 86 @Override getProgress()87 public int getProgress() { 88 return mProgressBar.getProgress(); 89 } 90 } 91