Home | History | Annotate | Download | only in leanback
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
      5  * in compliance with the License. You may obtain a copy of the License at
      6  *
      7  * http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the License
     10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
     11  * or implied. See the License for the specific language governing permissions and limitations under
     12  * the License.
     13  */
     14 package com.example.android.leanback;
     15 
     16 import android.os.Parcel;
     17 import android.os.Parcelable;
     18 
     19 public class PhotoItem implements Parcelable {
     20 
     21     private String mTitle;
     22     private int mImageResourceId;
     23 
     24     public PhotoItem(String title, int imageResourceId) {
     25         mTitle = title;
     26         mImageResourceId = imageResourceId;
     27     }
     28 
     29     public int getImageResourceId() {
     30         return mImageResourceId;
     31     }
     32 
     33     public String getTitle() {
     34         return mTitle;
     35     }
     36 
     37     @Override
     38     public String toString() {
     39         return mTitle;
     40     }
     41 
     42     @Override
     43     public int describeContents() {
     44         return 0;
     45     }
     46 
     47     @Override
     48     public void writeToParcel(Parcel dest, int flags) {
     49         dest.writeString(mTitle);
     50         dest.writeInt(mImageResourceId);
     51     }
     52 
     53     public static final Parcelable.Creator<PhotoItem> CREATOR
     54             = new Parcelable.Creator<PhotoItem>() {
     55         @Override
     56         public PhotoItem createFromParcel(Parcel in) {
     57             return new PhotoItem(in);
     58         }
     59 
     60         @Override
     61         public PhotoItem[] newArray(int size) {
     62             return new PhotoItem[size];
     63         }
     64     };
     65 
     66     private PhotoItem(Parcel in) {
     67         mTitle = in.readString();
     68         mImageResourceId = in.readInt();
     69     }
     70 }
     71