/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.support.v4.view; import android.view.View; import android.view.WindowInsets; class ViewCompatApi21 { public static void setTransitionName(View view, String transitionName) { view.setTransitionName(transitionName); } public static String getTransitionName(View view) { return view.getTransitionName(); } public static void requestApplyInsets(View view) { view.requestApplyInsets(); } public static void setElevation(View view, float elevation) { view.setElevation(elevation); } public static float getElevation(View view) { return view.getElevation(); } public static void setTranslationZ(View view, float translationZ) { view.setTranslationZ(translationZ); } public static float getTranslationZ(View view) { return view.getTranslationZ(); } public static void setOnApplyWindowInsetsListener(View view, final OnApplyWindowInsetsListener listener) { view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) { // Wrap the framework insets in our wrapper WindowInsetsCompatApi21 insets = new WindowInsetsCompatApi21(windowInsets); // Give the listener a chance to use the wrapped insets insets = (WindowInsetsCompatApi21) listener.onApplyWindowInsets(view, insets); // Return the unwrapped insets return insets.unwrap(); } }); } }