Home | History | Annotate | Download | only in documentsui
      1 /*
      2  * Copyright (C) 2013 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.android.documentsui;
     18 
     19 import android.content.Context;
     20 import android.graphics.Canvas;
     21 import android.util.AttributeSet;
     22 import android.view.View;
     23 import android.widget.FrameLayout;
     24 
     25 import java.util.ArrayList;
     26 
     27 public class DirectoryContainerView extends FrameLayout {
     28     private boolean mDisappearingFirst = false;
     29 
     30     public DirectoryContainerView(Context context) {
     31         super(context);
     32     }
     33 
     34     public DirectoryContainerView(Context context, AttributeSet attrs) {
     35         super(context, attrs);
     36     }
     37 
     38     @Override
     39     protected void dispatchDraw(Canvas canvas) {
     40         final ArrayList<View> disappearing = mDisappearingChildren;
     41         if (mDisappearingFirst && disappearing != null) {
     42             for (int i = 0; i < disappearing.size(); i++) {
     43                 super.drawChild(canvas, disappearing.get(i), getDrawingTime());
     44             }
     45         }
     46         super.dispatchDraw(canvas);
     47     }
     48 
     49     @Override
     50     protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
     51         if (mDisappearingFirst && mDisappearingChildren != null
     52                 && mDisappearingChildren.contains(child)) {
     53             return false;
     54         }
     55         return super.drawChild(canvas, child, drawingTime);
     56     }
     57 
     58     public void setDrawDisappearingFirst(boolean disappearingFirst) {
     59         mDisappearingFirst = disappearingFirst;
     60     }
     61 }
     62