List of usage examples for android.view ViewGroup PERSISTENT_SCROLLING_CACHE
int PERSISTENT_SCROLLING_CACHE
To view the source code for android.view ViewGroup PERSISTENT_SCROLLING_CACHE.
Click Source Link
From source file:us.shandian.blacklight.ui.statuses.TimeLineFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { initTitle();//from ww w . j av a2 s . c om View v = inflater.inflate(R.layout.home_timeline, null); mList = (ListView) v.findViewById(R.id.home_timeline); mCache = bindApiCache(); mCache.loadFromCache(); mAdapter = new WeiboAdapter(getActivity(), mList, mCache.mMessages, mBindOrig, mShowCommentStatus); mList.setAdapter(mAdapter); mList.setDrawingCacheEnabled(true); mList.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); mList.setPersistentDrawingCache( ViewGroup.PERSISTENT_ANIMATION_CACHE | ViewGroup.PERSISTENT_SCROLLING_CACHE); // Swipe To Refresh bindSwipeToRefresh((ViewGroup) v); if (mCache.mMessages.getSize() == 0) { new Refresher().execute(new Boolean[] { true }); } // Floating "New" button bindNewButton(v); return v; }
From source file:info.papdt.blacklight.ui.statuses.TimeLineFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActionBar = ((ToolbarActivity) getActivity()).getSupportActionBar(); mToolbar = ((ToolbarActivity) getActivity()).getToolbar(); initTitle();/*www . j av a 2s . co m*/ mSettings = Settings.getInstance(getActivity().getApplicationContext()); final View v = inflater.inflate(R.layout.home_timeline, null); // Initialize views mList = Utility.findViewById(v, R.id.home_timeline); mShadow = Utility.findViewById(v, R.id.action_shadow); mCache = bindApiCache(); mCache.loadFromCache(); mList.setDrawingCacheEnabled(true); mList.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); mList.setPersistentDrawingCache( ViewGroup.PERSISTENT_ANIMATION_CACHE | ViewGroup.PERSISTENT_SCROLLING_CACHE); mManager = new LinearLayoutManager(getActivity()); mList.setLayoutManager(mManager); // Swipe To Refresh bindSwipeToRefresh((ViewGroup) v); if (mCache.mMessages.getSize() == 0) { new Refresher().execute(true); } // Adapter mAdapter = new WeiboAdapter(getActivity(), mList, mCache.mMessages, mBindOrig, mShowCommentStatus); // Content Margin if (getActivity() instanceof MainActivity && mAllowHidingActionBar) { View header = new View(getActivity()); RecyclerView.LayoutParams p = new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, Utility.getDecorPaddingTop(getActivity())); header.setLayoutParams(p); mAdapter.setHeaderView(header); mSwipeRefresh.setProgressViewOffset(false, 0, (int) ((p.height + Utility.dp2px(getActivity(), 20)) * 1.2)); } mList.setAdapter(mAdapter); // Listener if (getActivity() instanceof MainActivity) { mAdapter.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView view, int dx, int dy) { int deltaY = -dy; boolean shouldShow = deltaY > 0; if (shouldShow != mFABShowing) { if (shouldShow) { showFAB(); } else { hideFAB(); } } if (mAllowHidingActionBar) { if ((mTranslationY > -mActionBarHeight && deltaY < 0) || (mTranslationY < 0 && deltaY > 0)) { mTranslationY += deltaY; } if (mTranslationY < -mActionBarHeight) { mTranslationY = -mActionBarHeight; } else if (mTranslationY > 0) { mTranslationY = 0; } updateTranslation(); } mFABShowing = shouldShow; mLastY = dy; } }); } mAdapter.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView v, int dx, int dy) { if (!mRefreshing && mManager.findLastVisibleItemPosition() >= mAdapter.getItemCount() - 5) { new Refresher().execute(false); } } }); mShadow.bringToFront(); v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (getActivity() instanceof MainActivity && mAllowHidingActionBar) { mActionBarHeight = mToolbar.getHeight(); mShadow.setTranslationY(mActionBarHeight); RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) mAdapter.getHeaderView() .getLayoutParams(); lp.height = mActionBarHeight; mAdapter.getHeaderView().setLayoutParams(lp); mSwipeRefresh.setProgressViewOffset(false, 0, (int) (mActionBarHeight * 1.2)); mSwipeRefresh.invalidate(); v.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); return v; }
From source file:cm.aptoide.pt.RemoteInTab.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); File local_path = new File(LOCAL_PATH); if (!local_path.exists()) local_path.mkdir();//from w ww.j ava 2 s. c om File icon_path = new File(ICON_PATH); if (!icon_path.exists()) icon_path.mkdir(); db = new DbHandler(this); sPref = getSharedPreferences("aptoide_prefs", MODE_PRIVATE); prefEdit = sPref.edit(); prefEdit.putBoolean("update", true); prefEdit.commit(); myTabHost = getTabHost(); myTabHost.addTab(myTabHost.newTabSpec("avail") .setIndicator("Available", getResources().getDrawable(android.R.drawable.ic_menu_add)) .setContent(new Intent(this, TabAvailable.class))); myTabHost.addTab(myTabHost.newTabSpec("inst") .setIndicator("Installed", getResources().getDrawable(android.R.drawable.ic_menu_agenda)) .setContent(new Intent(this, TabInstalled.class))); myTabHost.addTab(myTabHost.newTabSpec("updt") .setIndicator("Updates", getResources().getDrawable(android.R.drawable.ic_menu_info_details)) .setContent(new Intent(this, TabUpdates.class))); myTabHost.setPersistentDrawingCache(ViewGroup.PERSISTENT_SCROLLING_CACHE); Vector<ServerNode> srv_lst = db.getServers(); if (srv_lst.isEmpty()) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("empty", true); call.putExtra("uri", "http://apps.aptoide.org"); startActivityForResult(call, NEWREPO_FLAG); } Intent i = getIntent(); if (i.hasExtra("uri")) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("uri", i.getStringExtra("uri")); startActivityForResult(call, NEWREPO_FLAG); } else if (i.hasExtra("newrepo")) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("newrepo", i.getStringExtra("newrepo")); startActivityForResult(call, NEWREPO_FLAG); } }