1 /*
2  * Copyright (C) 2022 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.launcher3.testing.shared;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * Request object for querying a hotseat cell region in Rect.
24  */
25 public class HotseatCellCenterRequest implements TestInformationRequest {
26     public final int cellInd;
27 
28     @Override
describeContents()29     public int describeContents() {
30         return 0;
31     }
32 
33     @Override
writeToParcel(Parcel dest, int flags)34     public void writeToParcel(Parcel dest, int flags) {
35         dest.writeInt(cellInd);
36     }
37 
38     @Override
getRequestName()39     public String getRequestName() {
40         return TestProtocol.REQUEST_HOTSEAT_CELL_CENTER;
41     }
42 
43     public static final Parcelable.Creator<HotseatCellCenterRequest> CREATOR =
44             new Parcelable.Creator<HotseatCellCenterRequest>() {
45 
46                 @Override
47                 public HotseatCellCenterRequest createFromParcel(Parcel source) {
48                     return new HotseatCellCenterRequest(source);
49                 }
50 
51                 @Override
52                 public HotseatCellCenterRequest[] newArray(int size) {
53                     return new HotseatCellCenterRequest[size];
54                 }
55             };
56 
HotseatCellCenterRequest(int cellInd)57     private HotseatCellCenterRequest(int cellInd) {
58         this.cellInd = cellInd;
59     }
60 
HotseatCellCenterRequest(Parcel in)61     private HotseatCellCenterRequest(Parcel in) {
62         this(in.readInt());
63     }
64 
65     /**
66      * Create a builder for HotseatCellCenterRequest.
67      *
68      * @return HotseatCellCenterRequest builder.
69      */
builder()70     public static HotseatCellCenterRequest.Builder builder() {
71         return new HotseatCellCenterRequest.Builder();
72     }
73 
74     /**
75      * HotseatCellCenterRequest Builder.
76      */
77     public static final class Builder {
78         private int mCellInd;
79 
Builder()80         private Builder() {
81             mCellInd = 0;
82         }
83 
84         /**
85          * Set the index of hotseat cells.
86          */
setCellInd(int i)87         public HotseatCellCenterRequest.Builder setCellInd(int i) {
88             this.mCellInd = i;
89             return this;
90         }
91 
92         /**
93          * build the HotseatCellCenterRequest.
94          */
build()95         public HotseatCellCenterRequest build() {
96             return new HotseatCellCenterRequest(mCellInd);
97         }
98     }
99 }
100