Giter VIP home page Giter VIP logo

malevich's Introduction

malevich

Android displaying bitmaps library

This library is just wrapper for Google tutorial Loading Large Bitmaps Efficiently:

http://developer.android.com/intl/ru/training/displaying-bitmaps/load-bitmap.html

Example of usage:

https://github.com/recoilme/android-DisplayingBitmaps

How to use:

// init
Malevich malevich = new Malevich.Builder(this).build();


// use
malevich.load(mImageUrl).into(mImageView);

Whats all!

Advansed usage:

Memory and disk caching params

ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, "dir");
        cacheParams.memoryCacheEnabled = true; //Enable memory cache
        cacheParams.setMemCacheSizePercent(0.4f);  //Percent of available memory for cache
        cacheParams.compressQuality = 90; // Compress quality
        cacheParams.compressFormat = Bitmap.CompressFormat.PNG; // Compress format
        cacheParams.diskCacheEnabled = true; // Use disk cache
        cacheParams.diskCacheSize = 10485760; // Disk cache size

Malevich Builder

malevich = new Malevich.Builder(this)
        .debug(true) // write log
        .maxSize(1024) // max size of image in px
        .LoadingImage(R.drawable.some) // preloader image or recource
        .CacheParams(casheParams) // custom cache
        .build();

Loading image

malevich.load(some).into(ImageView);

you may load:

  1. Bitmap
  2. BitmapDrawable
  3. Resource id
  4. HttpUrl

Transform image after loading with prebuild utils or custom method

malevich.load(url).width(mItemHeight).height(mItemHeight).imageDecodedListener(new Malevich.ImageDecodedListener() {
                    @Override
                    public Bitmap onImageDecoded(String data, int reqWidth, int reqHeight, Bitmap bitmap) {

                        // Get squared bitmap and transform it to circle
                        return Malevich.Utils.getSquaredCircleBitmap(bitmap,reqWidth);
                    }
                }).into(imageView);

Pause loading on scroll

mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int scrollState) {
                // Pause fetcher to ensure smoother scrolling when flinging
                if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                    // Pause image loading on scroll to help with performance
                    malevich.setPauseWork(true);
                } else {
                    malevich.setPauseWork(false);
                }
            }

            @Override
            public void onScroll(AbsListView absListView, int firstVisibleItem,
                    int visibleItemCount, int totalItemCount) {
            }
        });

Cansel and pausing tasks

    @Override
    public void onResume() {
        super.onResume();
        malevich.setExitTasksEarly(false);
        mAdapter.notifyDataSetChanged();
    }

    @Override
    public void onPause() {
        super.onPause();
        malevich.setPauseWork(false);
        malevich.setExitTasksEarly(true);
        malevich.flushCache();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        malevich.closeCache();
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.