| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.app.smartspace.uitemplatedata; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.SystemApi; |
| 22 |
import android.app.smartspace.SmartspaceTarget; |
| 23 |
import android.app.smartspace.SmartspaceUtils; |
| 24 |
import android.os.Parcel; |
| 25 |
|
| 26 |
import java.util.Objects; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
@SystemApi |
| 41 |
public final class HeadToHeadTemplateData extends BaseTemplateData { |
| 42 |
|
| 43 |
@Nullable |
| 44 |
private final Text mHeadToHeadTitle; |
| 45 |
@Nullable |
| 46 |
private final Icon mHeadToHeadFirstCompetitorIcon; |
| 47 |
@Nullable |
| 48 |
private final Icon mHeadToHeadSecondCompetitorIcon; |
| 49 |
@Nullable |
| 50 |
private final Text mHeadToHeadFirstCompetitorText; |
| 51 |
@Nullable |
| 52 |
private final Text mHeadToHeadSecondCompetitorText; |
| 53 |
|
| 54 |
|
| 55 |
@Nullable |
| 56 |
private final TapAction mHeadToHeadAction; |
| 57 |
|
| 58 |
HeadToHeadTemplateData(@NonNull Parcel in) { |
| 59 |
super(in); |
| 60 |
mHeadToHeadTitle = in.readTypedObject(Text.CREATOR); |
| 61 |
mHeadToHeadFirstCompetitorIcon = in.readTypedObject(Icon.CREATOR); |
| 62 |
mHeadToHeadSecondCompetitorIcon = in.readTypedObject(Icon.CREATOR); |
| 63 |
mHeadToHeadFirstCompetitorText = in.readTypedObject(Text.CREATOR); |
| 64 |
mHeadToHeadSecondCompetitorText = in.readTypedObject(Text.CREATOR); |
| 65 |
mHeadToHeadAction = in.readTypedObject(TapAction.CREATOR); |
| 66 |
} |
| 67 |
|
| 68 |
private HeadToHeadTemplateData(@SmartspaceTarget.UiTemplateType int templateType, |
| 69 |
@Nullable SubItemInfo primaryItem, |
| 70 |
@Nullable SubItemInfo subtitleItem, |
| 71 |
@Nullable SubItemInfo subtitleSupplementalItem, |
| 72 |
@Nullable SubItemInfo supplementalLineItem, |
| 73 |
@Nullable SubItemInfo supplementalAlarmItem, |
| 74 |
int layoutWeight, |
| 75 |
@Nullable Text headToHeadTitle, |
| 76 |
@Nullable Icon headToHeadFirstCompetitorIcon, |
| 77 |
@Nullable Icon headToHeadSecondCompetitorIcon, |
| 78 |
@Nullable Text headToHeadFirstCompetitorText, |
| 79 |
@Nullable Text headToHeadSecondCompetitorText, |
| 80 |
@Nullable TapAction headToHeadAction) { |
| 81 |
super(templateType, primaryItem, subtitleItem, subtitleSupplementalItem, |
| 82 |
supplementalLineItem, supplementalAlarmItem, layoutWeight); |
| 83 |
|
| 84 |
mHeadToHeadTitle = headToHeadTitle; |
| 85 |
mHeadToHeadFirstCompetitorIcon = headToHeadFirstCompetitorIcon; |
| 86 |
mHeadToHeadSecondCompetitorIcon = headToHeadSecondCompetitorIcon; |
| 87 |
mHeadToHeadFirstCompetitorText = headToHeadFirstCompetitorText; |
| 88 |
mHeadToHeadSecondCompetitorText = headToHeadSecondCompetitorText; |
| 89 |
mHeadToHeadAction = headToHeadAction; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
@Nullable |
| 94 |
public Text getHeadToHeadTitle() { |
| 95 |
return mHeadToHeadTitle; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
@Nullable |
| 100 |
public Icon getHeadToHeadFirstCompetitorIcon() { |
| 101 |
return mHeadToHeadFirstCompetitorIcon; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
@Nullable |
| 106 |
public Icon getHeadToHeadSecondCompetitorIcon() { |
| 107 |
return mHeadToHeadSecondCompetitorIcon; |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
@Nullable |
| 112 |
public Text getHeadToHeadFirstCompetitorText() { |
| 113 |
return mHeadToHeadFirstCompetitorText; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
@Nullable |
| 118 |
public Text getHeadToHeadSecondCompetitorText() { |
| 119 |
return mHeadToHeadSecondCompetitorText; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
@Nullable |
| 124 |
public TapAction getHeadToHeadAction() { |
| 125 |
return mHeadToHeadAction; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
@NonNull |
| 132 |
public static final Creator<HeadToHeadTemplateData> CREATOR = |
| 133 |
new Creator<HeadToHeadTemplateData>() { |
| 134 |
@Override |
| 135 |
public HeadToHeadTemplateData createFromParcel(Parcel in) { |
| 136 |
return new HeadToHeadTemplateData(in); |
| 137 |
} |
| 138 |
|
| 139 |
@Override |
| 140 |
public HeadToHeadTemplateData[] newArray(int size) { |
| 141 |
return new HeadToHeadTemplateData[size]; |
| 142 |
} |
| 143 |
}; |
| 144 |
|
| 145 |
@Override |
| 146 |
public int describeContents() { |
| 147 |
return 0; |
| 148 |
} |
| 149 |
|
| 150 |
@Override |
| 151 |
public void writeToParcel(@NonNull Parcel out, int flags) { |
| 152 |
super.writeToParcel(out, flags); |
| 153 |
out.writeTypedObject(mHeadToHeadTitle, flags); |
| 154 |
out.writeTypedObject(mHeadToHeadFirstCompetitorIcon, flags); |
| 155 |
out.writeTypedObject(mHeadToHeadSecondCompetitorIcon, flags); |
| 156 |
out.writeTypedObject(mHeadToHeadFirstCompetitorText, flags); |
| 157 |
out.writeTypedObject(mHeadToHeadSecondCompetitorText, flags); |
| 158 |
out.writeTypedObject(mHeadToHeadAction, flags); |
| 159 |
} |
| 160 |
|
| 161 |
@Override |
| 162 |
public boolean equals(Object o) { |
| 163 |
if (this == o) return true; |
| 164 |
if (!(o instanceof HeadToHeadTemplateData)) return false; |
| 165 |
if (!super.equals(o)) return false; |
| 166 |
HeadToHeadTemplateData that = (HeadToHeadTemplateData) o; |
| 167 |
return SmartspaceUtils.isEqual(mHeadToHeadTitle, that.mHeadToHeadTitle) && Objects.equals( |
| 168 |
mHeadToHeadFirstCompetitorIcon, that.mHeadToHeadFirstCompetitorIcon) |
| 169 |
&& Objects.equals( |
| 170 |
mHeadToHeadSecondCompetitorIcon, that.mHeadToHeadSecondCompetitorIcon) |
| 171 |
&& SmartspaceUtils.isEqual(mHeadToHeadFirstCompetitorText, |
| 172 |
that.mHeadToHeadFirstCompetitorText) |
| 173 |
&& SmartspaceUtils.isEqual(mHeadToHeadSecondCompetitorText, |
| 174 |
that.mHeadToHeadSecondCompetitorText) |
| 175 |
&& Objects.equals( |
| 176 |
mHeadToHeadAction, that.mHeadToHeadAction); |
| 177 |
} |
| 178 |
|
| 179 |
@Override |
| 180 |
public int hashCode() { |
| 181 |
return Objects.hash(super.hashCode(), mHeadToHeadTitle, mHeadToHeadFirstCompetitorIcon, |
| 182 |
mHeadToHeadSecondCompetitorIcon, mHeadToHeadFirstCompetitorText, |
| 183 |
mHeadToHeadSecondCompetitorText, |
| 184 |
mHeadToHeadAction); |
| 185 |
} |
| 186 |
|
| 187 |
@Override |
| 188 |
public String toString() { |
| 189 |
return super.toString() + " + SmartspaceHeadToHeadUiTemplateData{" |
| 190 |
+ "mH2HTitle=" + mHeadToHeadTitle |
| 191 |
+ ", mH2HFirstCompetitorIcon=" + mHeadToHeadFirstCompetitorIcon |
| 192 |
+ ", mH2HSecondCompetitorIcon=" + mHeadToHeadSecondCompetitorIcon |
| 193 |
+ ", mH2HFirstCompetitorText=" + mHeadToHeadFirstCompetitorText |
| 194 |
+ ", mH2HSecondCompetitorText=" + mHeadToHeadSecondCompetitorText |
| 195 |
+ ", mH2HAction=" + mHeadToHeadAction |
| 196 |
+ '}'; |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
@SystemApi |
| 205 |
public static final class Builder extends BaseTemplateData.Builder { |
| 206 |
|
| 207 |
private Text mHeadToHeadTitle; |
| 208 |
private Icon mHeadToHeadFirstCompetitorIcon; |
| 209 |
private Icon mHeadToHeadSecondCompetitorIcon; |
| 210 |
private Text mHeadToHeadFirstCompetitorText; |
| 211 |
private Text mHeadToHeadSecondCompetitorText; |
| 212 |
private TapAction mHeadToHeadAction; |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
public Builder() { |
| 218 |
super(SmartspaceTarget.UI_TEMPLATE_HEAD_TO_HEAD); |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
@NonNull |
| 225 |
public Builder setHeadToHeadTitle(@Nullable Text headToHeadTitle) { |
| 226 |
mHeadToHeadTitle = headToHeadTitle; |
| 227 |
return this; |
| 228 |
} |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
@NonNull |
| 234 |
public Builder setHeadToHeadFirstCompetitorIcon( |
| 235 |
@Nullable Icon headToHeadFirstCompetitorIcon) { |
| 236 |
mHeadToHeadFirstCompetitorIcon = headToHeadFirstCompetitorIcon; |
| 237 |
return this; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
@NonNull |
| 244 |
public Builder setHeadToHeadSecondCompetitorIcon( |
| 245 |
@Nullable Icon headToHeadSecondCompetitorIcon) { |
| 246 |
mHeadToHeadSecondCompetitorIcon = headToHeadSecondCompetitorIcon; |
| 247 |
return this; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
@NonNull |
| 254 |
public Builder setHeadToHeadFirstCompetitorText( |
| 255 |
@Nullable Text headToHeadFirstCompetitorText) { |
| 256 |
mHeadToHeadFirstCompetitorText = headToHeadFirstCompetitorText; |
| 257 |
return this; |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
@NonNull |
| 264 |
public Builder setHeadToHeadSecondCompetitorText( |
| 265 |
@Nullable Text headToHeadSecondCompetitorText) { |
| 266 |
mHeadToHeadSecondCompetitorText = headToHeadSecondCompetitorText; |
| 267 |
return this; |
| 268 |
} |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
@NonNull |
| 274 |
public Builder setHeadToHeadAction(@Nullable TapAction headToHeadAction) { |
| 275 |
mHeadToHeadAction = headToHeadAction; |
| 276 |
return this; |
| 277 |
} |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
@NonNull |
| 283 |
public HeadToHeadTemplateData build() { |
| 284 |
return new HeadToHeadTemplateData(getTemplateType(), getPrimaryItem(), |
| 285 |
getSubtitleItem(), getSubtitleSupplemtnalItem(), |
| 286 |
getSupplementalLineItem(), getSupplementalAlarmItem(), getLayoutWeight(), |
| 287 |
mHeadToHeadTitle, |
| 288 |
mHeadToHeadFirstCompetitorIcon, |
| 289 |
mHeadToHeadSecondCompetitorIcon, mHeadToHeadFirstCompetitorText, |
| 290 |
mHeadToHeadSecondCompetitorText, |
| 291 |
mHeadToHeadAction); |
| 292 |
} |
| 293 |
} |
| 294 |
} |