1 /* 2 * Copyright (C) 2014 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.example.android.activityscenetransitionbasic; 18 19 /** 20 * Represents an Item in our application. Each item has a name, id, full size image url and 21 * thumbnail url. 22 */ 23 public class Item { 24 25 private static final String LARGE_BASE_URL = "http://storage.googleapis.com/androiddevelopers/sample_data/activity_transition/large/"; 26 private static final String THUMB_BASE_URL = "http://storage.googleapis.com/androiddevelopers/sample_data/activity_transition/thumbs/"; 27 28 public static Item[] ITEMS = new Item[] { 29 new Item("Flying in the Light", "Romain Guy", "flying_in_the_light.jpg"), 30 new Item("Caterpillar", "Romain Guy", "caterpillar.jpg"), 31 new Item("Look Me in the Eye", "Romain Guy", "look_me_in_the_eye.jpg"), 32 new Item("Flamingo", "Romain Guy", "flamingo.jpg"), 33 new Item("Rainbow", "Romain Guy", "rainbow.jpg"), 34 new Item("Over there", "Romain Guy", "over_there.jpg"), 35 new Item("Jelly Fish 2", "Romain Guy", "jelly_fish_2.jpg"), 36 new Item("Lone Pine Sunset", "Romain Guy", "lone_pine_sunset.jpg"), 37 }; 38 getItem(int id)39 public static Item getItem(int id) { 40 for (Item item : ITEMS) { 41 if (item.getId() == id) { 42 return item; 43 } 44 } 45 return null; 46 } 47 48 private final String mName; 49 private final String mAuthor; 50 private final String mFileName; 51 Item(String name, String author, String fileName)52 Item (String name, String author, String fileName) { 53 mName = name; 54 mAuthor = author; 55 mFileName = fileName; 56 } 57 getId()58 public int getId() { 59 return mName.hashCode() + mFileName.hashCode(); 60 } 61 getAuthor()62 public String getAuthor() { 63 return mAuthor; 64 } 65 getName()66 public String getName() { 67 return mName; 68 } 69 getPhotoUrl()70 public String getPhotoUrl() { 71 return LARGE_BASE_URL + mFileName; 72 } 73 getThumbnailUrl()74 public String getThumbnailUrl() { 75 return THUMB_BASE_URL + mFileName; 76 } 77 78 } 79