Home | History | Annotate | Download | only in models
      1 /*
      2  * Copyright (C) 2015 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 
     16 package android.support.v17.leanback.supportleanbackshowcase.models;
     17 
     18 import android.content.Context;
     19 import android.graphics.drawable.Drawable;
     20 import android.support.v17.leanback.supportleanbackshowcase.R;
     21 import android.support.v17.leanback.widget.BaseOnItemViewSelectedListener;
     22 import android.support.v17.leanback.widget.MultiActionsProvider;
     23 import android.support.v17.leanback.widget.Row;
     24 import android.support.v17.leanback.widget.RowPresenter;
     25 import android.util.Log;
     26 import android.view.LayoutInflater;
     27 import android.view.View;
     28 import android.view.ViewGroup;
     29 import android.widget.TextView;
     30 
     31 import com.google.gson.Gson;
     32 import com.google.gson.annotations.SerializedName;
     33 
     34 public class Song implements MultiActionsProvider {
     35 
     36     @SerializedName("title") private String mTitle = "";
     37     @SerializedName("description") private String mDescription = "";
     38     @SerializedName("text") private String mText = "";
     39     @SerializedName("image") private String mImage = null;
     40     @SerializedName("file") private String mFile = null;
     41     @SerializedName("duration") private String mDuration = null;
     42     @SerializedName("number") private int mNumber = 0;
     43     @SerializedName("favorite") private boolean mFavorite = false;
     44 
     45     private MultiAction[] mMediaRowActions;
     46 
     47 
     48     public void setMediaRowActions(MultiAction[] mediaRowActions) {
     49         mMediaRowActions = mediaRowActions;
     50     }
     51 
     52     public MultiAction[] getMediaRowActions() {
     53         return mMediaRowActions;
     54     }
     55 
     56     public String getDuration() {
     57         return mDuration;
     58     }
     59 
     60     public void setDuration(String duration) {
     61         mDuration = duration;
     62     }
     63 
     64     public int getNumber() {
     65         return mNumber;
     66     }
     67 
     68     public String getText() {
     69         return mText;
     70     }
     71 
     72     public String getDescription() {
     73         return mDescription;
     74     }
     75 
     76     public void setDescription(String description) {
     77         mDescription = description;
     78     }
     79 
     80     public String getTitle() {
     81         return mTitle;
     82     }
     83 
     84     public void setTitle(String title) {
     85         mTitle = title;
     86     }
     87 
     88     public boolean isFavorite() {
     89         return mFavorite;
     90     }
     91 
     92     public void setFavorite(boolean favorite) {
     93         mFavorite = favorite;
     94     }
     95 
     96     public int getFileResource(Context context) {
     97         return context.getResources()
     98                       .getIdentifier(mFile, "raw", context.getPackageName());
     99     }
    100 
    101     public int getImageResource(Context context) {
    102         return context.getResources()
    103                       .getIdentifier(mImage, "drawable", context.getPackageName());
    104     }
    105 
    106     @Override
    107     public MultiAction[] getActions() {
    108         return mMediaRowActions;
    109     }
    110 
    111 }
    112