Home | History | Annotate | Download | only in certinstaller
      1 /*
      2  * Copyright (C) 2009 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.certinstaller;
     18 
     19 import android.view.View;
     20 import android.widget.TextView;
     21 
     22 /**
     23  * A helper class for handling text views in the dialogs.
     24  */
     25 class ViewHelper {
     26     private View mView;
     27     private boolean mHasEmptyError;
     28 
     29     void setView(View view) {
     30         mView = view;
     31     }
     32 
     33     void showError(int msgId) {
     34         TextView v = (TextView) mView.findViewById(R.id.error);
     35         v.setText(msgId);
     36         if (v != null) v.setVisibility(View.VISIBLE);
     37     }
     38 
     39     String getText(int viewId) {
     40         return ((TextView) mView.findViewById(viewId)).getText().toString();
     41     }
     42 
     43     void setText(int viewId, String text) {
     44         if (text == null) return;
     45         TextView v = (TextView) mView.findViewById(viewId);
     46         if (v != null) v.setText(text);
     47     }
     48 
     49     void setText(int viewId, int textId) {
     50         TextView v = (TextView) mView.findViewById(viewId);
     51         if (v != null) v.setText(textId);
     52     }
     53 
     54     void setHasEmptyError(boolean hasEmptyError) {
     55         mHasEmptyError = hasEmptyError;
     56     }
     57 
     58     boolean getHasEmptyError() {
     59         return mHasEmptyError;
     60     }
     61 }
     62