/* * * * Copyright 2015 Van Shu * * * * 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.mobimvp.cliques.ui; import android.os.Bundle; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.widget.ListView; import android.widget.Toast; import com.mobimvp.cliques.R; import com.mobimvp.cliques.ui.fragment.HomeFragment; import com.mobimvp.cliques.ui.widgets.DrawShadowFrameLayout; import com.mobimvp.cliques.util.UIUtils; import static com.mobimvp.cliques.util.LogUtils.makeLogTag; public class HomeActivity extends BaseActivity { private static final String TAG = makeLogTag(HomeActivity.class); private HomeFragment mSessionsFrag = null; private DrawShadowFrameLayout mDrawShadowFrameLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); overridePendingTransition(0, 0); Toolbar toolbar = getActionBarToolbar(); toolbar.setTitle(null); mDrawShadowFrameLayout = (DrawShadowFrameLayout) findViewById(R.id.main_content); } @Override public void onResume() { super.onResume(); checkShowStaleDataButterBar(); } @Override public boolean canSwipeRefreshChildScrollUp() { if (mSessionsFrag != null) { return mSessionsFrag.canCollectionViewScrollUp(); } return super.canSwipeRefreshChildScrollUp(); } private void checkShowStaleDataButterBar() { updateFragContentTopClearance(); } @Override protected int getSelfNavDrawerItem() { return NAVDRAWER_ITEM_HOME; } @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); ListView collectionView = (ListView) findViewById(R.id.listview); if (collectionView != null) { enableActionBarAutoHide(collectionView); } mSessionsFrag = (HomeFragment) getSupportFragmentManager().findFragmentById( R.id.home_fragment); registerHideableHeaderView(findViewById(R.id.headerbar)); } // Updates the Sessions fragment content top clearance to take our chrome into account private void updateFragContentTopClearance() { HomeFragment frag = (HomeFragment) getSupportFragmentManager().findFragmentById( R.id.home_fragment); if (frag == null) { return; } int actionBarClearance = UIUtils.calculateActionBarSize(this); int gridPadding = getResources().getDimensionPixelSize(R.dimen.explore_grid_padding); setProgressBarTopWhenActionBarShown(actionBarClearance); mDrawShadowFrameLayout.setShadowTopOffset(actionBarClearance); frag.setContentTopClearance(actionBarClearance + gridPadding); } @Override protected void onActionBarAutoShowOrHide(boolean shown) { super.onActionBarAutoShowOrHide(shown); mDrawShadowFrameLayout.setShadowVisible(shown, shown); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); } protected void requestDataRefresh() { mSessionsFrag.requestData(); Toast.makeText(getApplicationContext(),"toast ha",Toast.LENGTH_SHORT).show(); } }