LayoutChangeHelper.java revision dac1bb32531f7f4d49622bd38c82dde9333c38ac
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 17package com.android.camera.ui; 18 19import android.view.View; 20 21public class LayoutChangeHelper implements LayoutChangeNotifier { 22 private LayoutChangeNotifier.Listener mListener; 23 private boolean mFirstTimeLayout; 24 private View mView; 25 26 public LayoutChangeHelper(View v) { 27 mView = v; 28 mFirstTimeLayout = true; 29 } 30 31 @Override 32 public void setOnLayoutChangeListener(LayoutChangeNotifier.Listener listener) { 33 mListener = listener; 34 } 35 36 public void onLayout(boolean changed, int l, int t, int r, int b) { 37 if (mListener == null) return; 38 if (mFirstTimeLayout || changed) { 39 mFirstTimeLayout = false; 40 mListener.onLayoutChange(mView, l, t, r, b); 41 } 42 } 43} 44