1 /* 2 * Copyright (C) 2020 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.car.ui.baselayout; 18 19 import java.util.Objects; 20 21 /** 22 * A representation of the insets into the content view that the user-accessible 23 * content should have. 24 * 25 * See {@link InsetsChangedListener} for more information. 26 */ 27 public final class Insets { 28 private final int mLeft; 29 private final int mRight; 30 private final int mTop; 31 private final int mBottom; 32 Insets()33 public Insets() { 34 mLeft = mRight = mTop = mBottom = 0; 35 } 36 Insets(int left, int top, int right, int bottom)37 public Insets(int left, int top, int right, int bottom) { 38 mLeft = left; 39 mRight = right; 40 mTop = top; 41 mBottom = bottom; 42 } 43 getLeft()44 public int getLeft() { 45 return mLeft; 46 } 47 getRight()48 public int getRight() { 49 return mRight; 50 } 51 getTop()52 public int getTop() { 53 return mTop; 54 } 55 getBottom()56 public int getBottom() { 57 return mBottom; 58 } 59 60 @Override toString()61 public String toString() { 62 return "{ left: " + mLeft + ", right: " + mRight 63 + ", top: " + mTop + ", bottom: " + mBottom + " }"; 64 } 65 66 @Override equals(Object o)67 public boolean equals(Object o) { 68 if (this == o) return true; 69 if (o == null || getClass() != o.getClass()) return false; 70 Insets insets = (Insets) o; 71 return mLeft == insets.mLeft 72 && mRight == insets.mRight 73 && mTop == insets.mTop 74 && mBottom == insets.mBottom; 75 } 76 77 @Override hashCode()78 public int hashCode() { 79 return Objects.hash(mLeft, mRight, mTop, mBottom); 80 } 81 } 82