1974a07824642fabd896930f20c7b176fd2333e31George Mount/* 2974a07824642fabd896930f20c7b176fd2333e31George Mount * Copyright (C) 2015 The Android Open Source Project 3974a07824642fabd896930f20c7b176fd2333e31George Mount * 4974a07824642fabd896930f20c7b176fd2333e31George Mount * Licensed under the Apache License, Version 2.0 (the "License"); 5974a07824642fabd896930f20c7b176fd2333e31George Mount * you may not use this file except in compliance with the License. 6974a07824642fabd896930f20c7b176fd2333e31George Mount * You may obtain a copy of the License at 7974a07824642fabd896930f20c7b176fd2333e31George Mount * 8974a07824642fabd896930f20c7b176fd2333e31George Mount * http://www.apache.org/licenses/LICENSE-2.0 9974a07824642fabd896930f20c7b176fd2333e31George Mount * 10974a07824642fabd896930f20c7b176fd2333e31George Mount * Unless required by applicable law or agreed to in writing, software 11974a07824642fabd896930f20c7b176fd2333e31George Mount * distributed under the License is distributed on an "AS IS" BASIS, 12974a07824642fabd896930f20c7b176fd2333e31George Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13974a07824642fabd896930f20c7b176fd2333e31George Mount * See the License for the specific language governing permissions and 14974a07824642fabd896930f20c7b176fd2333e31George Mount * limitations under the License. 15974a07824642fabd896930f20c7b176fd2333e31George Mount */ 16fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountpackage android.databinding.adapters; 17974a07824642fabd896930f20c7b176fd2333e31George Mount 18fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountimport android.databinding.BindingAdapter; 19fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountimport android.databinding.BindingMethod; 20fead9ca09b117136b35bc5bf137340a754f9edddGeorge Mountimport android.databinding.BindingMethods; 21974a07824642fabd896930f20c7b176fd2333e31George Mountimport android.support.v7.widget.CardView; 22974a07824642fabd896930f20c7b176fd2333e31George Mount 23974a07824642fabd896930f20c7b176fd2333e31George Mount@BindingMethods({ 24c619d8f69127c1200103d8119101c5f0675661d0George Mount @BindingMethod(type = android.support.v7.widget.CardView.class, attribute = "cardCornerRadius", method = "setRadius"), 25c619d8f69127c1200103d8119101c5f0675661d0George Mount @BindingMethod(type = android.support.v7.widget.CardView.class, attribute = "cardMaxElevation", method = "setMaxCardElevation"), 26c619d8f69127c1200103d8119101c5f0675661d0George Mount @BindingMethod(type = android.support.v7.widget.CardView.class, attribute = "cardPreventCornerOverlap", method = "setPreventCornerOverlap"), 27c619d8f69127c1200103d8119101c5f0675661d0George Mount @BindingMethod(type = android.support.v7.widget.CardView.class, attribute = "cardUseCompatPadding", method = "setUseCompatPadding"), 28974a07824642fabd896930f20c7b176fd2333e31George Mount}) 29974a07824642fabd896930f20c7b176fd2333e31George Mountpublic class CardViewBindingAdapter { 30974a07824642fabd896930f20c7b176fd2333e31George Mount 31974a07824642fabd896930f20c7b176fd2333e31George Mount @BindingAdapter("contentPadding") 32974a07824642fabd896930f20c7b176fd2333e31George Mount public static void setContentPadding(CardView view, int padding) { 33974a07824642fabd896930f20c7b176fd2333e31George Mount view.setContentPadding(padding, padding, padding, padding); 34974a07824642fabd896930f20c7b176fd2333e31George Mount } 35974a07824642fabd896930f20c7b176fd2333e31George Mount 36974a07824642fabd896930f20c7b176fd2333e31George Mount @BindingAdapter("contentPaddingLeft") 37974a07824642fabd896930f20c7b176fd2333e31George Mount public static void setContentPaddingLeft(CardView view, int left) { 38974a07824642fabd896930f20c7b176fd2333e31George Mount int top = view.getContentPaddingTop(); 39974a07824642fabd896930f20c7b176fd2333e31George Mount int right = view.getContentPaddingRight(); 40974a07824642fabd896930f20c7b176fd2333e31George Mount int bottom = view.getContentPaddingBottom(); 41974a07824642fabd896930f20c7b176fd2333e31George Mount view.setContentPadding(left, top, right, bottom); 42974a07824642fabd896930f20c7b176fd2333e31George Mount } 43974a07824642fabd896930f20c7b176fd2333e31George Mount 44974a07824642fabd896930f20c7b176fd2333e31George Mount @BindingAdapter("contentPaddingTop") 45974a07824642fabd896930f20c7b176fd2333e31George Mount public static void setContentPaddingTop(CardView view, int top) { 46974a07824642fabd896930f20c7b176fd2333e31George Mount int left = view.getContentPaddingLeft(); 47974a07824642fabd896930f20c7b176fd2333e31George Mount int right = view.getContentPaddingRight(); 48974a07824642fabd896930f20c7b176fd2333e31George Mount int bottom = view.getContentPaddingBottom(); 49974a07824642fabd896930f20c7b176fd2333e31George Mount view.setContentPadding(left, top, right, bottom); 50974a07824642fabd896930f20c7b176fd2333e31George Mount } 51974a07824642fabd896930f20c7b176fd2333e31George Mount 52974a07824642fabd896930f20c7b176fd2333e31George Mount @BindingAdapter("contentPaddingRight") 53974a07824642fabd896930f20c7b176fd2333e31George Mount public static void setContentPaddingRight(CardView view, int right) { 54974a07824642fabd896930f20c7b176fd2333e31George Mount int left = view.getContentPaddingLeft(); 55974a07824642fabd896930f20c7b176fd2333e31George Mount int top = view.getContentPaddingTop(); 56974a07824642fabd896930f20c7b176fd2333e31George Mount int bottom = view.getContentPaddingBottom(); 57974a07824642fabd896930f20c7b176fd2333e31George Mount view.setContentPadding(left, top, right, bottom); 58974a07824642fabd896930f20c7b176fd2333e31George Mount } 59974a07824642fabd896930f20c7b176fd2333e31George Mount 60974a07824642fabd896930f20c7b176fd2333e31George Mount @BindingAdapter("contentPaddingBottom") 61974a07824642fabd896930f20c7b176fd2333e31George Mount public static void setContentPaddingBottom(CardView view, int bottom) { 62974a07824642fabd896930f20c7b176fd2333e31George Mount int left = view.getContentPaddingLeft(); 63974a07824642fabd896930f20c7b176fd2333e31George Mount int top = view.getContentPaddingTop(); 64974a07824642fabd896930f20c7b176fd2333e31George Mount int right = view.getContentPaddingRight(); 65974a07824642fabd896930f20c7b176fd2333e31George Mount view.setContentPadding(left, top, right, bottom); 66974a07824642fabd896930f20c7b176fd2333e31George Mount } 67974a07824642fabd896930f20c7b176fd2333e31George Mount} 68