diff options
Diffstat (limited to 'src/com/android/tv/ui/sidepanel/BaseOptionFragment.java')
-rw-r--r-- | src/com/android/tv/ui/sidepanel/BaseOptionFragment.java | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/src/com/android/tv/ui/sidepanel/BaseOptionFragment.java b/src/com/android/tv/ui/sidepanel/BaseOptionFragment.java deleted file mode 100644 index b8d45acc..00000000 --- a/src/com/android/tv/ui/sidepanel/BaseOptionFragment.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.tv.ui.sidepanel; - -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RadioButton; - -import com.android.tv.R; -import com.android.tv.TvActivity; - -public class BaseOptionFragment extends BaseSideFragment { - private static final String TAG = "ClosedCaptionOptionFragment"; - private static final boolean DEBUG = true; - - private View mMainView; - private boolean mClosingByItemSelected; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - mMainView = super.onCreateView(inflater, container, savedInstanceState); - return mMainView; - } - - @Override - public void onDetach() { - super.onDetach(); - if (!mClosingByItemSelected) { - ((TvActivity) getActivity()).onSideFragmentCanceled(getInitiator()); - } - ((TvActivity) getActivity()).hideOverlays(false, false, true); - } - - @Override - public final void initialize(String title, Object[] itemTags, int fragmentLayoutId, - int itemLayoutId, int itemBgColor, int itemFocusedBgColor, int itemHeightResId) { - throw new UnsupportedOperationException("Call initialize(String title, Object[] itemTags)"); - } - - public void initialize(String title, Object[] itemTags) { - super.initialize(title, itemTags, R.layout.option_fragment, R.layout.option_item, - R.color.option_item_background, R.color.option_item_focused_background, - R.dimen.option_item_height); - } - - public void initialize(String title, int itemLayoutResId, Object[] itemTags) { - super.initialize(title, itemTags, R.layout.option_fragment, itemLayoutResId, - R.color.option_item_background, R.color.option_item_focused_background, - R.dimen.option_item_height); - } - - @Override - public void onItemSelected(View v, int position, Object tag) { - RadioButton radioButton = (RadioButton) v.findViewById(R.id.option_item); - uncheckAllRadioButtons((ViewGroup) mMainView); - radioButton.setChecked(true); - mClosingByItemSelected = true; - ((TvActivity) getActivity()).popFragmentBackStack(); - } - - @Override - public void onBindView(View v, int position, Object tag, boolean prevSelected) { - RadioButton radioButton = (RadioButton) v.findViewById(R.id.option_item); - if (prevSelected) { - radioButton.setChecked(true); - } else { - radioButton.setChecked(false); - } - if (tag instanceof String) { - radioButton.setText((String) tag); - } else { - radioButton.setText(""); - } - } - - private static void uncheckAllRadioButtons(ViewGroup parent) { - int count = parent.getChildCount(); - for (int i = 0; i < count; ++i) { - View v = parent.getChildAt(i); - if (v instanceof ViewGroup) { - uncheckAllRadioButtons((ViewGroup) v); - } else if (v instanceof RadioButton) { - ((RadioButton) v).setChecked(false); - } - } - } -} |