Home | History | Annotate | Download | only in app
      1 /*
      2  * Copyright (C) 2012 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 package com.android.gallery3d.app;
     17 
     18 import android.content.Context;
     19 import android.view.LayoutInflater;
     20 import android.view.View;
     21 import android.view.ViewGroup;
     22 import android.view.ViewGroup.LayoutParams;
     23 import android.widget.RelativeLayout;
     24 
     25 import com.android.gallery3d.R;
     26 
     27 public class PhotoPageProgressBar {
     28     private ViewGroup mContainer;
     29     private View mProgress;
     30 
     31     public PhotoPageProgressBar(Context context, RelativeLayout parentLayout) {
     32         LayoutInflater inflater = (LayoutInflater) context
     33                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     34         mContainer = (ViewGroup) inflater.inflate(R.layout.photopage_progress_bar, parentLayout,
     35                 false);
     36         parentLayout.addView(mContainer);
     37         mProgress = mContainer.findViewById(R.id.photopage_progress_foreground);
     38     }
     39 
     40     public void setProgress(int progressPercent) {
     41         mContainer.setVisibility(View.VISIBLE);
     42         LayoutParams layoutParams = mProgress.getLayoutParams();
     43         layoutParams.width = mContainer.getWidth() * progressPercent / 100;
     44         mProgress.setLayoutParams(layoutParams);
     45     }
     46 
     47     public void hideProgress() {
     48         mContainer.setVisibility(View.INVISIBLE);
     49     }
     50 }
     51