Java Code Examples for android.widget.ListView#setDrawingCacheEnabled()

The following examples show how to use android.widget.ListView#setDrawingCacheEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimeLineFragment.java    From BlackLight with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	
	initTitle();

	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;
}
 
Example 2
Source File: PhotoAlbumPickerActivity.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    // actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
 
Example 3
Source File: FMActivity.java    From Kernel-Tuner with GNU General Public License v3.0 4 votes vote down vote up
@Override
   public void onCreate(Bundle savedInstanceState)
{
	//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
       super.onCreate(savedInstanceState);

	setContentView(R.layout.fm);
	fListView = (ListView) findViewById(R.id.list);

	path = savedInstanceState != null ? savedInstanceState.getString(CURR_DIR) : FILE_SEPARATOR;//Environment.getExternalStorageDirectory().toString();

       fListView.setDrawingCacheEnabled(true);
	fAdapter = new FMAdapter(this, R.layout.fm_row);

	fListView.setAdapter(fAdapter);

	ls(path, false);

	getSupportActionBar().setSubtitle(path);
	fListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
	{
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
									long arg3)
			{
                   FMEntry entry = fAdapter.getItem(pos);
                   if(entry.getType() == TYPE_DIRECTORY || entry.getType() == TYPE_DIRECTORY_LINK)
                   {
                       Parcelable state = fListView.onSaveInstanceState();
                       listScrollStates.put(path, state);
                       backstack.add(path);
                       path = entry.getType() == TYPE_DIRECTORY_LINK ? entry.getLink() : entry.getPath();
                       validatePath();
                       ls(path, false);
                   }
                   else if(entry.getType() == TYPE_FILE || entry.getType() == TYPE_LINK)
                   {
                       //TODO
                   }
			}
		});
	if(savedInstanceState != null)
	{
           backstack = (LinkedList<String>) savedInstanceState.getSerializable(BACKSTACK);
		Parcelable listState = savedInstanceState.getParcelable("list_position");
		if(listState != null)fListView.post(new RestoreListStateRunnable(listState));
	}
   }