Home | History | Annotate | Download | only in dirlist
      1 /*
      2  * Copyright (C) 2016 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.documentsui.dirlist;
     18 
     19 import android.content.Context;
     20 import android.database.Cursor;
     21 import android.view.ViewGroup;
     22 import android.widget.ImageView;
     23 import android.widget.TextView;
     24 
     25 import com.android.documentsui.R;
     26 
     27 /**
     28  * RecyclerView.ViewHolder class that displays a message when there are no contents
     29  * in the directory, whether due to no items, no search results or an error.
     30  * Used by {@link DirectoryAddonsAdapter}.
     31  */
     32 final class InflateMessageDocumentHolder extends MessageHolder {
     33     private Message mMessage;
     34     private TextView mMsgView;
     35     private ImageView mImageView;
     36 
     37     public InflateMessageDocumentHolder(Context context, ViewGroup parent) {
     38         super(context, parent, R.layout.item_doc_inflated_message);
     39         mMsgView = (TextView) itemView.findViewById(R.id.message);
     40         mImageView = (ImageView) itemView.findViewById(R.id.artwork);
     41     }
     42 
     43     public void bind(Message message) {
     44         mMessage = message;
     45         bind(null, null);
     46     }
     47 
     48     @Override
     49     public void bind(Cursor cursor, String modelId) {
     50         mMsgView.setText(mMessage.getMessageString());
     51         mImageView.setImageDrawable(mMessage.getIcon());
     52     }
     53 }
     54