Search in sources :

Example 6 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project fdroidclient by f-droid.

the class AppListActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    ((FDroidApp) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_list);
    searchInput = (EditText) findViewById(R.id.search);
    searchInput.addTextChangedListener(new CategoryTextWatcher(this, searchInput, this));
    searchInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // Hide the keyboard (http://stackoverflow.com/a/1109108 (when pressing search)
                InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                inputManager.hideSoftInputFromWindow(searchInput.getWindowToken(), 0);
                // Change focus from the search input to the app list.
                appView.requestFocus();
                return true;
            }
            return false;
        }
    });
    sortImage = (ImageView) findViewById(R.id.sort);
    if (FDroidApp.isAppThemeLight()) {
        sortImage.setImageResource(R.drawable.ic_last_updated_black);
    } else {
        sortImage.setImageResource(R.drawable.ic_last_updated_white);
    }
    sortImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (sortClauseSelected.equalsIgnoreCase(SortClause.LAST_UPDATED)) {
                sortClauseSelected = SortClause.NAME;
                if (FDroidApp.isAppThemeLight()) {
                    sortImage.setImageResource(R.drawable.ic_az_black);
                } else {
                    sortImage.setImageResource(R.drawable.ic_az_white);
                }
            } else {
                sortClauseSelected = SortClause.LAST_UPDATED;
                if (FDroidApp.isAppThemeLight()) {
                    sortImage.setImageResource(R.drawable.ic_last_updated_black);
                } else {
                    sortImage.setImageResource(R.drawable.ic_last_updated_white);
                }
            }
            getSupportLoaderManager().restartLoader(0, null, AppListActivity.this);
            appView.scrollToPosition(0);
        }
    });
    emptyState = (TextView) findViewById(R.id.empty_state);
    View backButton = findViewById(R.id.back);
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    View clearButton = findViewById(R.id.clear);
    clearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            searchInput.setText("");
        }
    });
    appAdapter = new AppListAdapter(this);
    appView = (RecyclerView) findViewById(R.id.app_list);
    appView.setHasFixedSize(true);
    appView.setLayoutManager(new LinearLayoutManager(this));
    appView.setAdapter(appAdapter);
    appView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        private final ImageLoader imageLoader = ImageLoader.getInstance();

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            switch(newState) {
                case RecyclerView.SCROLL_STATE_DRAGGING:
                    imageLoader.pause();
                    break;
                case RecyclerView.SCROLL_STATE_IDLE:
                    imageLoader.resume();
                    break;
            }
            super.onScrollStateChanged(recyclerView, newState);
        }
    });
    parseIntentForSearchQuery();
}
Also used : FDroidApp(org.fdroid.fdroid.FDroidApp) InputMethodManager(android.view.inputmethod.InputMethodManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) KeyEvent(android.view.KeyEvent) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader)

Example 7 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project AndroidStudy by tinggengyan.

the class UILApplication method initImageLoader.

// init the image loader params
public static void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you may tune some of them,
    // or you can create default configuration by
    // ImageLoaderConfiguration.createDefault(this);
    // method.
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    // 50 MiB
    config.diskCacheSize(50 * 1024 * 1024);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    // Remove for release app
    config.writeDebugLogs();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config.build());
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 8 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project NewPipe by TeamNewPipe.

the class ContentSettingsFragment method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (preference.getKey().equals(thumbnailLoadToggleKey)) {
        final ImageLoader imageLoader = ImageLoader.getInstance();
        imageLoader.stop();
        imageLoader.clearDiskCache();
        imageLoader.clearMemoryCache();
        imageLoader.resume();
        Toast.makeText(preference.getContext(), R.string.thumbnail_cache_wipe_complete_notice, Toast.LENGTH_SHORT).show();
    }
    return super.onPreferenceTreeClick(preference);
}
Also used : ImageLoader(com.nostra13.universalimageloader.core.ImageLoader)

Example 9 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project MGit by maks.

the class BasicFunctions method setAvatarImage.

public static void setAvatarImage(ImageView imageView, String email) {
    String avatarUri = "";
    if (!email.isEmpty())
        avatarUri = "avatar://" + md5(email);
    ImageLoader im = BasicFunctions.getImageLoader();
    im.displayImage(avatarUri, imageView);
}
Also used : ImageLoader(com.nostra13.universalimageloader.core.ImageLoader)

Example 10 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project summer-android by cn-cerc.

the class MyApp method initImageLoader.

/**
 * ImageLoader 初始化
 */
private void initImageLoader() {
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(this);
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    // 缓存的文件数量
    config.discCacheFileCount(100);
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    // 100 MiB
    config.diskCacheSize(200 * 1024 * 1024);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    // webConfig.writeDebugLogs(); // Remove for release app
    ImageLoader.getInstance().init(config.build());
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)20 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)10 ImageLoader (com.nostra13.universalimageloader.core.ImageLoader)8 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)6 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)5 File (java.io.File)5 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)4 View (android.view.View)3 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)3 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)2 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)2 IOException (java.io.IOException)2 DataSetObserver (android.database.DataSetObserver)1 Bitmap (android.graphics.Bitmap)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1