Example usage for android.view View DRAWING_CACHE_QUALITY_HIGH

List of usage examples for android.view View DRAWING_CACHE_QUALITY_HIGH

Introduction

In this page you can find the example usage for android.view View DRAWING_CACHE_QUALITY_HIGH.

Prototype

int DRAWING_CACHE_QUALITY_HIGH

To view the source code for android.view View DRAWING_CACHE_QUALITY_HIGH.

Click Source Link

Document

Enables high quality mode for the drawing cache.

Usage

From source file:us.shandian.blacklight.ui.statuses.TimeLineFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    initTitle();/* w w  w. j a v  a  2  s  .co  m*/

    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();/* w w w. j ava2 s .  c  om*/
    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:com.vuze.android.remote.activity.LoginActivity.java

@SuppressWarnings("deprecation")
private void setBackgroundGradient() {

    ViewGroup mainLayout = (ViewGroup) findViewById(R.id.main_loginlayout);
    assert mainLayout != null;
    int h = mainLayout.getHeight();
    int w = mainLayout.getWidth();
    View viewCenterOn = findViewById(R.id.login_frog_logo);
    assert viewCenterOn != null;

    RectShape shape = new RectShape();
    ShapeDrawable mDrawable = new ShapeDrawable(shape);
    int color1 = AndroidUtilsUI.getStyleColor(this, R.attr.login_grad_color_1);
    int color2 = AndroidUtilsUI.getStyleColor(this, R.attr.login_grad_color_2);

    RadialGradient shader;/*from  w  w w  . j  a v a 2s  .  co  m*/
    if (w > h) {
        int left = viewCenterOn.getLeft() + (viewCenterOn.getWidth() / 2);
        int top = viewCenterOn.getTop() + (viewCenterOn.getHeight() / 2);
        int remaining = w - left;
        shader = new RadialGradient(left, top, remaining, new int[] { color1, color2 }, new float[] { 0, 1.0f },
                Shader.TileMode.CLAMP);
    } else {
        int top = viewCenterOn.getTop() + (viewCenterOn.getHeight() / 2);
        shader = new RadialGradient(w / 2, top, w * 2 / 3, color1, color2, Shader.TileMode.CLAMP);
    }
    mDrawable.setBounds(0, 0, w, h);
    mDrawable.getPaint().setShader(shader);
    mDrawable.getPaint().setDither(true);
    mDrawable.getPaint().setAntiAlias(true);
    mDrawable.setDither(true);

    mainLayout.setDrawingCacheEnabled(true);
    mainLayout.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    mainLayout.setAnimationCacheEnabled(false);

    mainLayout.setBackgroundDrawable(mDrawable);
}

From source file:com.zoffcc.applications.zanavi.Navit.java

static void take_map_screenshot(String dir_name, String name_base) {
    try {//from ww  w . ja va2 s .  c  om
        View v1 = Navit.N_NavitGraphics.view;
        v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
        v1.setDrawingCacheEnabled(true);
        Bitmap bm = v1.getDrawingCache();

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(dir_name + "/" + name_base + ".png");
            bm.compress(Bitmap.CompressFormat.PNG, 100, out);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("TSCR:004 " + e.getMessage());
        } finally {
            v1.setDrawingCacheEnabled(false);

            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e4) {
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

static void take_phone_screenshot(Activity a, String dir_name, String name_base) {
    try {//  www .j  a v  a2  s .  co m
        View v1 = a.getWindow().getDecorView().getRootView();
        v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
        v1.setDrawingCacheEnabled(true);
        Bitmap bm = v1.getDrawingCache();

        FileOutputStream out = null;
        try {
            out = new FileOutputStream(dir_name + "/" + name_base + ".png");
            bm.compress(Bitmap.CompressFormat.PNG, 100, out);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("TSCR:004 " + e.getMessage());
        } finally {
            v1.setDrawingCacheEnabled(false);

            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e4) {
    }
}