@Override public void onThemeSelected(String themeId) { FragmentManager fm = getSupportFragmentManager(); if (!Utils.isXLarge(ThemeBrowserActivity.this)) { // show details as a fragment on top FragmentTransaction ft = fm.beginTransaction(); if (mSearchFragment != null && mSearchFragment.isVisible()) { fm.popBackStack(); } setupBaseLayout(); mDetailsFragment = ThemeDetailsFragment.newInstance(themeId); ft.add(R.id.theme_browser_container, mDetailsFragment, ThemeDetailsFragment.TAG); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.addToBackStack(null); ft.commit(); } else { // show details as a dialog mDetailsFragment = ThemeDetailsFragment.newInstance(themeId); mDetailsFragment.show(getSupportFragmentManager(), ThemeDetailsFragment.TAG); getSupportFragmentManager().executePendingTransactions(); int minWidth = getResources().getDimensionPixelSize(R.dimen.theme_details_dialog_min_width); int height = getResources().getDimensionPixelSize(R.dimen.theme_details_dialog_height); int width = Math.max((int) (DisplayUtils.getDisplayPixelWidth(this) * 0.6), minWidth); mDetailsFragment.getDialog().getWindow().setLayout(width, height); } }
@Override protected void onSaveInstanceState(Bundle outState) { if (Utils.isXLarge(ThemeBrowserActivity.this) && mDetailsFragment != null) { mDetailsFragment.dismiss(); } super.onSaveInstanceState(outState); outState.putBoolean(KEY_IS_ACTIVATING_THEME, mIsActivatingTheme); }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.stats_visitors_and_views_fragment, container, false); TextView titleTextView = (TextView) view.findViewById(R.id.stats_pager_title); titleTextView.setText(getTitle()); mVisitorsToday = (TextView) view.findViewById(R.id.stats_visitors_and_views_today_visitors_count); mViewsToday = (TextView) view.findViewById(R.id.stats_visitors_and_views_today_views_count); mViewsBestEver = (TextView) view.findViewById(R.id.stats_visitors_and_views_best_ever_views_count); mViewsAllTime = (TextView) view.findViewById(R.id.stats_visitors_and_views_all_time_view_count); mCommentsAllTime = (TextView) view.findViewById(R.id.stats_visitors_and_views_all_time_comment_count); RadioGroup mRadioGroup = (RadioGroup) view.findViewById(R.id.stats_pager_tabs); mRadioGroup.setVisibility(View.VISIBLE); mRadioGroup.setOnCheckedChangeListener(this); for (int i = 0; i < TITLES.length; i++) { RadioButton rb = (RadioButton) LayoutInflater.from(getActivity()).inflate(R.layout.stats_radio_button, null, false); RadioGroup.LayoutParams params = new RadioGroup.LayoutParams( RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT); int dp8 = (int) Utils.dpToPx(8); params.setMargins(0, 0, dp8, 0); rb.setMinimumWidth((int) Utils.dpToPx(80)); rb.setGravity(Gravity.CENTER); rb.setLayoutParams(params); rb.setText(TITLES[i]); mRadioGroup.addView(rb); if (i == mSelectedButtonIndex) rb.setChecked(true); } return view; }
@Override public void onLivePreviewClicked(String themeId, String previewURL) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); if (mPreviewFragment == null) { mPreviewFragment = ThemePreviewFragment.newInstance(themeId, previewURL); } else { mPreviewFragment.load(themeId, previewURL); } if (mDetailsFragment != null) { if (Utils.isXLarge(ThemeBrowserActivity.this)) { mDetailsFragment.dismiss(); } else { ft.hide(mDetailsFragment); } } ft.add(R.id.theme_browser_container, mPreviewFragment, ThemePreviewFragment.TAG); ft.addToBackStack(null); ft.commit(); setupBaseLayout(); }