public boolean onBackPressed() { if (mLayout != null && (mLayout.isPanelExpanded() || mLayout.isPanelDragging())) { mLayout.setAnchorPoint(1.0f); mLayout.collapsePanel(); return true; } else { if (mUnfoldableView != null && (mUnfoldableView.isUnfolded() || mUnfoldableView.isUnfolding())) { mUnfoldableView.foldBack(); return true; } } return false; }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.weather_list_layout, container, false); // mListView = Views.find(this, R.id.list_view); // mListView.setAdapter(new PaintingsAdapter(this)); mListTouchInterceptor = Views.find(rootView, R.id.touch_interceptor_view); mListTouchInterceptor.setClickable(false); mDetailsLayout = Views.find(rootView, R.id.details_layout); mDetailsLayout.setVisibility(View.INVISIBLE); mUnfoldableView = Views.find(rootView, R.id.unfoldable_view); mLayout = (SlidingUpPanelLayout) Views.find(rootView, R.id.sliding_layout); Bitmap glance = ((BitmapDrawable) getResources().getDrawable(R.drawable.unfold_glance)).getBitmap(); mUnfoldableView.setFoldShading(new GlanceFoldShading(inflater.getContext(), glance)); mUnfoldableView.setOnFoldingListener( new UnfoldableView.SimpleFoldingListener() { @Override public void onUnfolding(UnfoldableView unfoldableView) { mListTouchInterceptor.setClickable(true); mDetailsLayout.setVisibility(View.VISIBLE); } @Override public void onUnfolded(UnfoldableView unfoldableView) { getActivity().getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL); mListTouchInterceptor.setClickable(false); ((HomeActivity) getActivity()).mDrawerToggle.setDrawerIndicatorEnabled(false); getActivity().invalidateOptionsMenu(); } @Override public void onFoldProgress(UnfoldableView unfoldableView, float progress) { // if(currentAlpha!=255){ // // getFadingActionBarHelper().setActionBarAlpha((int)((255-currentAlpha)*progress)); // } } @Override public void onFoldingBack(UnfoldableView unfoldableView) { mListTouchInterceptor.setClickable(true); } @Override public void onFoldedBack(UnfoldableView unfoldableView) { getActivity().getActionBar().setTitle(getResources().getString(R.string.drawer_home)); mListTouchInterceptor.setClickable(false); mDetailsLayout.setVisibility(View.INVISIBLE); getActivity().getWindow().invalidatePanelMenu(Window.FEATURE_OPTIONS_PANEL); ((HomeActivity) getActivity()).mDrawerToggle.setDrawerIndicatorEnabled(true); getActivity().invalidateOptionsMenu(); } }); mLayout.setPanelSlideListener( new SlidingUpPanelLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { // Log.i(TAG, "onPanelSlide, offset " + slideOffset); // setActionBarTranslation(mLayout.getCurrentParalaxOffset()); mUnfoldableView.setTouchable(false); } @Override public void onPanelExpanded(View panel) { // Log.i(TAG, "onPanelExpanded"); mUnfoldableView.setTouchable(false); } @Override public void onPanelCollapsed(View panel) { // Log.i(TAG, "onPanelCollapsed"); mUnfoldableView.setTouchable(true); } @Override public void onPanelAnchored(View panel) { Log.i(TAG, "onPanelAnchored"); } @Override public void onPanelHidden(View panel) { Log.i(TAG, "onPanelHidden"); } }); if (savedInstanceState == null) { FragmentExchangeManager.exchangeFragment( getChildFragmentManager(), R.id.list_container, List_TAG, WeatherListFragment.class, null, WeatherListContainerFragment.this); // int commit = getChildFragmentManager().beginTransaction().(R.id.list_container, // new FocusCityWeatherListFragment()).commit(); } return rootView; }