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 28 void setView(View view) { 29 mView = view; 30 } 31 32 void showError(int msgId) { 33 TextView v = (TextView) mView.findViewById(R.id.error); 34 v.setText(msgId); 35 if (v != null) v.setVisibility(View.VISIBLE); 36 } 37 38 String getText(int viewId) { 39 return ((TextView) mView.findViewById(viewId)).getText().toString(); 40 } 41 42 void setText(int viewId, String text) { 43 if (text == null) return; 44 TextView v = (TextView) mView.findViewById(viewId); 45 if (v != null) v.setText(text); 46 } 47 48 void setText(int viewId, int textId) { 49 TextView v = (TextView) mView.findViewById(viewId); 50 if (v != null) v.setText(textId); 51 } 52 } 53