1 /* 2 * Copyright 2018 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.pump.db; 18 19 import android.net.Uri; 20 21 import androidx.annotation.AnyThread; 22 import androidx.annotation.NonNull; 23 import androidx.annotation.Nullable; 24 25 @AnyThread 26 public class Episode extends Video { 27 private final Series mSeries; 28 private final int mSeason; 29 private final int mEpisode; 30 31 // TODO(b/123706949) Lock mutable fields to ensure consistent updates 32 private Uri mThumbnailUri; 33 private Uri mPosterUri; 34 private String mDescription; 35 private boolean mLoaded; 36 Episode(long id, @NonNull String mimeType, @NonNull Series series, int season, int episode)37 Episode(long id, @NonNull String mimeType, @NonNull Series series, 38 int season, int episode) { 39 super(id, mimeType); 40 41 mSeries = series; 42 if (season <= 0 || episode <= 0) { 43 throw new IllegalArgumentException(); 44 } 45 mSeason = season; 46 mEpisode = episode; 47 } 48 getSeries()49 public @NonNull Series getSeries() { 50 return mSeries; 51 } 52 getSeason()53 public int getSeason() { 54 return mSeason; 55 } 56 getEpisode()57 public int getEpisode() { 58 return mEpisode; 59 } 60 getThumbnailUri()61 public @Nullable Uri getThumbnailUri() { 62 return mThumbnailUri; 63 } 64 setThumbnailUri(@onNull Uri thumbnailUri)65 public boolean setThumbnailUri(@NonNull Uri thumbnailUri) { 66 if (thumbnailUri.equals(mThumbnailUri)) { 67 return false; 68 } 69 mThumbnailUri = thumbnailUri; 70 return true; 71 } 72 getPosterUri()73 public @Nullable Uri getPosterUri() { 74 return mPosterUri; 75 } 76 setPosterUri(@onNull Uri posterUri)77 public boolean setPosterUri(@NonNull Uri posterUri) { 78 if (posterUri.equals(mPosterUri)) { 79 return false; 80 } 81 mPosterUri = posterUri; 82 return true; 83 } 84 getDescription()85 public @Nullable String getDescription() { 86 return mDescription; 87 } 88 setDescription(@onNull String description)89 public boolean setDescription(@NonNull String description) { 90 if (description.equals(mDescription)) { 91 return false; 92 } 93 mDescription = description; 94 return true; 95 } 96 isLoaded()97 boolean isLoaded() { 98 return mLoaded; 99 } 100 setLoaded()101 void setLoaded() { 102 mLoaded = true; 103 } 104 } 105