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 setClipChildren(false); 33 } 34 35 public DirectoryContainerView(Context context, AttributeSet attrs) { 36 super(context, attrs); 37 setClipChildren(false); 38 } 39 40 @Override 41 protected void dispatchDraw(Canvas canvas) { 42 final ArrayList<View> disappearing = mDisappearingChildren; 43 if (mDisappearingFirst && disappearing != null) { 44 for (int i = 0; i < disappearing.size(); i++) { 45 super.drawChild(canvas, disappearing.get(i), getDrawingTime()); 46 } 47 } 48 super.dispatchDraw(canvas); 49 } 50 51 @Override 52 protected boolean drawChild(Canvas canvas, View child, long drawingTime) { 53 if (mDisappearingFirst && mDisappearingChildren != null 54 && mDisappearingChildren.contains(child)) { 55 return false; 56 } 57 return super.drawChild(canvas, child, drawingTime); 58 } 59 60 public void setDrawDisappearingFirst(boolean disappearingFirst) { 61 mDisappearingFirst = disappearingFirst; 62 } 63 } 64