• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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.dialer.voicemail.listui;
18 
19 import android.support.v7.widget.RecyclerView.ViewHolder;
20 import android.view.View;
21 import android.widget.Button;
22 import android.widget.TextView;
23 import com.android.dialer.voicemail.listui.error.VoicemailErrorMessage.Action;
24 
25 /** ViewHolder for {@link NewVoicemailAdapter} to display voicemail error states. */
26 final class NewVoicemailAlertViewHolder extends ViewHolder {
27 
28   private final TextView voicemailErrorTitleTextView;
29   private final TextView voicemailErrorDetailsTextView;
30   private final Button primaryButton;
31   private final Button secondaryButton;
32 
NewVoicemailAlertViewHolder(View view)33   NewVoicemailAlertViewHolder(View view) {
34     super(view);
35     voicemailErrorTitleTextView = view.findViewById(R.id.voicemail_alert_header);
36     voicemailErrorDetailsTextView = view.findViewById(R.id.voicemail_alert_details);
37     primaryButton = view.findViewById(R.id.voicemail_alert_primary_button);
38     secondaryButton = view.findViewById(R.id.voicemail_alert_primary_button);
39   }
40 
setTitle(CharSequence error)41   void setTitle(CharSequence error) {
42     voicemailErrorTitleTextView.setText(error);
43   }
44 
setDescription(CharSequence error)45   void setDescription(CharSequence error) {
46     voicemailErrorDetailsTextView.setText(error);
47   }
48 
setPrimaryButton(Action action)49   void setPrimaryButton(Action action) {
50     primaryButton.setVisibility(View.VISIBLE);
51     primaryButton.setText(action.getText());
52     primaryButton.setOnClickListener(action.getListener());
53   }
54 
setSecondaryButton(Action action)55   void setSecondaryButton(Action action) {
56     secondaryButton.setVisibility(View.VISIBLE);
57     secondaryButton.setText(action.getText());
58     secondaryButton.setOnClickListener(action.getListener());
59   }
60 }
61