/** * Method that returns a drawable reference of a FileSystemObject. * * @param iconView View to load the drawable into * @param fso The FileSystemObject reference * @param defaultIcon Drawable to be used in case no specific one could be found * @return Drawable The drawable reference */ public void loadDrawable(ImageView iconView, final String fso, Drawable defaultIcon) { if (!mUseThumbs) { return; } // Is cached? final String filePath = fso; if (this.mAppIcons.containsKey(filePath)) { iconView.setImageBitmap(this.mAppIcons.get(filePath)); return; } mRequests.put(iconView, fso); new Thread( new Runnable() { @Override public void run() { mHandler.removeMessages(MSG_DESTROY); if (mWorkerThread == null || mWorkerHandler == null) { mWorkerThread = new HandlerThread("IconHolderLoader"); mWorkerThread.start(); mWorkerHandler = new WorkerHandler(mWorkerThread.getLooper()); } Message msg = mWorkerHandler.obtainMessage(MSG_LOAD, fso); msg.sendToTarget(); } }) .start(); }
private void processResult(LoadResult result) { // Cache the new drawable final String filePath = (result.fso); mAppIcons.put(filePath, result.result); // find the request for it for (Map.Entry<ImageView, String> entry : mRequests.entrySet()) { final ImageView imageView = entry.getKey(); final String fso = entry.getValue(); if (fso == result.fso) { imageView.setImageBitmap(result.result); mRequests.remove(imageView); break; } } }
private void startUpload(int index) { if (NavigineApp.Navigation == null) return; String userHash = NavigineApp.Settings.getString("user_hash", ""); if (userHash.length() == 0) return; LocationInfo info = mInfoList.get(index); String location = new String(info.title); Log.d(TAG, String.format(Locale.ENGLISH, "Start upload: %s", location)); synchronized (mLoaderMap) { if (!mLoaderMap.containsKey(location)) { LoaderState loader = new LoaderState(); loader.location = location; loader.type = UPLOAD; loader.id = LocationLoader.startLocationUploader(location, info.archiveFile, true); mLoaderMap.put(location, loader); } } mAdapter.updateList(); }
// # Transformation Contract @Override public final Bitmap transform(Bitmap source) { final Palette palette = Palette.generate(source); CACHE.put(source, palette); return source; }