• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 package com.example.android.leanback;
16 
17 import android.util.Log;
18 
19 import java.io.Serializable;
20 import java.net.URI;
21 import java.net.URISyntaxException;
22 
23 /*
24  * Movie class represents video entity with title, description, image thumbs and video url.
25  *
26  */
27 public class Movie implements Serializable {
28     static final long serialVersionUID = 727566175075960653L;
29     private static long count = 0;
30     private long id;
31     private String title;
32     private String description;
33     private String bgImageUrl;
34     private String cardImageUrl;
35     private String videoUrl;
36     private String studio;
37     private String category;
38 
Movie()39     public Movie() {
40     }
41 
getCount()42     public static long getCount() {
43         return count;
44     }
45 
incCount()46     public static void incCount() {
47         count++;
48     }
49 
getId()50     public long getId() {
51         return id;
52     }
53 
setId(long id)54     public void setId(long id) {
55         this.id = id;
56     }
57 
getTitle()58     public String getTitle() {
59         return title;
60     }
61 
setTitle(String title)62     public void setTitle(String title) {
63         this.title = title;
64     }
65 
getDescription()66     public String getDescription() {
67         return description;
68     }
69 
setDescription(String description)70     public void setDescription(String description) {
71         this.description = description;
72     }
73 
getStudio()74     public String getStudio() {
75         return studio;
76     }
77 
setStudio(String studio)78     public void setStudio(String studio) {
79         this.studio = studio;
80     }
81 
getVideoUrl()82     public String getVideoUrl() {
83         return videoUrl;
84     }
85 
setVideoUrl(String videoUrl)86     public void setVideoUrl(String videoUrl) {
87         this.videoUrl = videoUrl;
88     }
89 
getBackgroundImageUrl()90     public String getBackgroundImageUrl() {
91         return bgImageUrl;
92     }
93 
setBackgroundImageUrl(String bgImageUrl)94     public void setBackgroundImageUrl(String bgImageUrl) {
95         this.bgImageUrl = bgImageUrl;
96     }
97 
getCardImageUrl()98     public String getCardImageUrl() {
99         return cardImageUrl;
100     }
101 
setCardImageUrl(String cardImageUrl)102     public void setCardImageUrl(String cardImageUrl) {
103         this.cardImageUrl = cardImageUrl;
104     }
105 
getCategory()106     public String getCategory() {
107         return category;
108     }
109 
setCategory(String category)110     public void setCategory(String category) {
111         this.category = category;
112     }
113 
getBackgroundImageURI()114     public URI getBackgroundImageURI() {
115         try {
116             Log.d("BACK MOVIE: ", bgImageUrl);
117             return new URI(getBackgroundImageUrl());
118         } catch (URISyntaxException e) {
119             Log.d("URI exception: ", bgImageUrl);
120             return null;
121         }
122     }
123 
getCardImageURI()124     public URI getCardImageURI() {
125         try {
126             return new URI(getCardImageUrl());
127         } catch (URISyntaxException e) {
128             return null;
129         }
130     }
131 
132     @Override
toString()133     public String toString() {
134         return "Movie{" +
135                 "id=" + id +
136                 ", title='" + title + '\'' +
137                 ", videoUrl='" + videoUrl + '\'' +
138                 ", backgroundImageUrl='" + bgImageUrl + '\'' +
139                 ", backgroundImageURI='" + getBackgroundImageURI().toString() + '\'' +
140                 ", cardImageUrl='" + cardImageUrl + '\'' +
141                 '}';
142     }
143 }
144