List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable
private BitmapDrawable(BitmapState state, Resources res)
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
public void refreshTheme() { layoutBackgroundApp.setBackgroundColor( Color.parseColor("#" + themeManager.getStringColor("color_background_new_status"))); themeManager.setColors();//from w w w. j a v a 2 s . c o m layoutBackgroundBar.setBackgroundDrawable( ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_top_bar"), false, 0)); layoutBackgroundColumnsBarContainer.setBackgroundDrawable( ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_top_bar"), false, 0)); StateListDrawable statesButtonBg = new StateListDrawable(); statesButtonBg.addState(new int[] { android.R.attr.state_pressed }, ImageUtils .createBackgroundDrawable(this, themeManager.getColor("color_button_press_default"), false, 0)); statesButtonBg.addState(new int[] { -android.R.attr.state_pressed }, ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_top_bar"), false, 0)); imgBarAvatarBg.setBackgroundDrawable(statesButtonBg); StateListDrawable statesButton = new StateListDrawable(); statesButton.addState(new int[] { android.R.attr.state_pressed }, ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_button_press_default"), false, 0)); statesButton.addState(new int[] { -android.R.attr.state_pressed }, ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_top_bar"), false, 0)); imgNewStatus.setBackgroundDrawable(statesButton); float size = getResources().getDimension(R.dimen.actionbar_height) - Utils.dip2px(this, 12); imgBarCounter.setBackgroundDrawable(new BitmapDrawable(getResources(), ImageUtils.getBackgroundBitmapInBubble(this, Color.RED, Utils.TYPE_RECTANGLE, size, size))); //(findViewById(R.id.tweettopics_bar_divider1)).setBackgroundDrawable(ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_top_bar"), false, 0)); //(findViewById(R.id.tweettopics_bar_divider2)).setBackgroundDrawable(ImageUtils.createBackgroundDrawable(this, themeManager.getColor("color_top_bar"), false, 0)); Drawable d = new ColorDrawable(android.R.color.transparent); StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_pressed }, d); states.addState(new int[] { android.R.attr.state_window_focused }, d); states.addState(new int[] { android.R.attr.state_pressed }, d); states.addState(new int[] { android.R.attr.state_selected }, d); states.addState(new int[] { android.R.attr.color }, new ColorDrawable(themeManager.getColor("color_indicator_text"))); indicator.setBackgroundDrawable(states); indicator.setTextSize(getResources().getDimension(R.dimen.text_size_title_page_indicator)); }
From source file:com.android.contacts.common.ContactPhotoManager.java
/** * Given a bitmap, returns a drawable that is configured to display the bitmap based on the * specified request./*from ww w. j a v a2 s.c o m*/ */ private Drawable getDrawableForBitmap(Resources resources, Bitmap bitmap, Request request) { if (request.mIsCircular) { final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(resources, bitmap); drawable.setAntiAlias(true); drawable.setCornerRadius(bitmap.getHeight() / 2); return drawable; } else { return new BitmapDrawable(resources, bitmap); } }
From source file:illab.nabal.NabalSimpleDemoActivity.java
/** * Fetch a photo attached to the current profile status from a remote URL * //from w w w . jav a 2s . c o m * @param remotePhotoUrl */ private final void fetchStatusThumbnailPhoto(final String remotePhotoUrl) { showSpinner(); Operation<Delegate, Bitmap> bitmapOp = new Operation<Delegate, Bitmap>() { public void onResult(final Bitmap result) { if (result != null) { //Log.d(TAG, "############## remotePhotoUrl : " + remotePhotoUrl); //Log.d(TAG, "############## result.getWidth() : " + result.getWidth()); //Log.d(TAG, "############## result.getheight() : " + result.getHeight()); // determine screen width and height DisplayMetrics displaymetrics = new DisplayMetrics(); getWindow().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int screenWidth = displaymetrics.widthPixels; int screenHeight = displaymetrics.heightPixels; int screenBiggerLength = (screenWidth > screenHeight) ? screenWidth : screenHeight; //Log.d(TAG, ">>>>>>>>>>>> screenWidth : " + screenWidth); //Log.d(TAG, ">>>>>>>>>>>> screenHeight : " + screenHeight); //Log.d(TAG, ">>>>>>>>>>>> screenBiggerLength : " + screenBiggerLength); // try to resize if the image is too big mTmpImgBitmap = result; if (mTmpImgBitmap.getWidth() > screenBiggerLength) { int dstWidth = screenBiggerLength; float ratio = (float) dstWidth / (float) mTmpImgBitmap.getWidth(); //Log.i(TAG, ">>>>>>>>>>>> ratio : " + ratio); int dstHeight = (int) (mTmpImgBitmap.getHeight() * ratio); //Log.i(TAG, ">>>>>>>>>>>> dstHeight : " + dstHeight); mTmpImgBitmap = Bitmap.createScaledBitmap(mTmpImgBitmap, dstWidth, dstHeight, true); } //Log.d(TAG, "############## mTmpImgBitmap.getWidth() : " + mTmpImgBitmap.getWidth()); //Log.d(TAG, "############## mTmpImgBitmap.getheight() : " + mTmpImgBitmap.getHeight()); if (mCurrentSnsId == SocialNetwork.FACEBOOK) { mFbBgBitmap = mTmpImgBitmap; } else if (mCurrentSnsId == SocialNetwork.TWITTER) { mTwBgBitmap = mTmpImgBitmap; } else if (mCurrentSnsId == SocialNetwork.WEIBO) { mWeBgBitmap = mTmpImgBitmap; } // set the image to background runOnUiThread(new Runnable() { public void run() { mBackground.setBackgroundDrawable(new BitmapDrawable(getResources(), mTmpImgBitmap)); mBackground.getBackground().setAlpha(STATUS_THUMBNAIL_BG_ALPHA); // finally finishing up the status fetch job mIsFetchingStatus = false; toastProfileFetchResult(); } }); } } public void onFail(Exception e) { mIsFetchingStatus = false; handleProfileFetchingError(e); } public void execute(Delegate networkDelegate) { if (StringHelper.isEmpty(remotePhotoUrl) == false) { networkDelegate.getBitmapFromUrl(this, remotePhotoUrl); } } }; mOpAgent.carryOut(bitmapOp); }
From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java
/** * This is a rather unintuitive helper method to load images. The reason why this method exists * is because due to some service limitations, one may not be able to add images to native * resource bundle. So this method offers a way to load image from www contents instead. * However loading from native resource bundle is already preferred over loading from www. So * if name is given, then it simply loads from resource bundle and the other two parameters are * ignored. If name is not given, then altPath is assumed to be a file path _under_ www and * altDensity is the desired density of the given image file, because without native resource * bundle, we can't tell what density the image is supposed to be so it needs to be given * explicitly./*from w w w .j av a 2 s .c o m*/ */ private Drawable getImage(String name, String altPath, double altDensity) throws IOException { Drawable result = null; Resources activityRes = cordova.getActivity().getResources(); if (name != null) { int id = activityRes.getIdentifier(name, "drawable", cordova.getActivity().getPackageName()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { result = activityRes.getDrawable(id); } else { result = activityRes.getDrawable(id, cordova.getActivity().getTheme()); } } else if (altPath != null) { File file = new File("www", altPath); InputStream is = null; try { is = cordova.getActivity().getAssets().open(file.getPath()); Bitmap bitmap = BitmapFactory.decodeStream(is); bitmap.setDensity((int) (DisplayMetrics.DENSITY_MEDIUM * altDensity)); result = new BitmapDrawable(activityRes, bitmap); } finally { // Make sure we close this input stream to prevent resource leak. try { is.close(); } catch (Exception e) { } } } return result; }
From source file:com.paramonod.kikos.MainActivity.java
public static Drawable createScaledIcon(Drawable id, int width, int height, Resources res) { Bitmap bitmap = ((BitmapDrawable) id).getBitmap(); // Scale it to 50 x 50 shop = new BitmapDrawable(res, Bitmap.createScaledBitmap(bitmap, width, height, true)); return shop;//from w ww . jav a 2 s . c o m }
From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java
private void setButtonImages(View view, BrowserButton buttonProps, int disabledAlpha) { Drawable normalDrawable = null;/* ww w . j a v a 2 s . c o m*/ Drawable disabledDrawable = null; Drawable pressedDrawable = null; CharSequence description = view.getContentDescription(); if (buttonProps.image != null || buttonProps.wwwImage != null) { try { normalDrawable = getImage(buttonProps.image, buttonProps.wwwImage, buttonProps.wwwImageDensity); ViewGroup.LayoutParams params = view.getLayoutParams(); params.width = normalDrawable.getIntrinsicWidth(); params.height = normalDrawable.getIntrinsicHeight(); } catch (Resources.NotFoundException e) { emitError(ERR_LOADFAIL, String.format("Image for %s, %s, failed to load", description, buttonProps.image)); } catch (IOException ioe) { emitError(ERR_LOADFAIL, String.format("Image for %s, %s, failed to load", description, buttonProps.wwwImage)); } } else { emitWarning(WRN_UNDEFINED, String.format("Image for %s is not defined. Button will not be shown", description)); } if (buttonProps.imagePressed != null || buttonProps.wwwImagePressed != null) { try { pressedDrawable = getImage(buttonProps.imagePressed, buttonProps.wwwImagePressed, buttonProps.wwwImageDensity); } catch (Resources.NotFoundException e) { emitError(ERR_LOADFAIL, String.format("Pressed image for %s, %s, failed to load", description, buttonProps.imagePressed)); } catch (IOException e) { emitError(ERR_LOADFAIL, String.format("Pressed image for %s, %s, failed to load", description, buttonProps.wwwImagePressed)); } } else { emitWarning(WRN_UNDEFINED, String.format("Pressed image for %s is not defined.", description)); } if (normalDrawable != null) { // Create the disabled state drawable by fading the normal state // drawable. Drawable.setAlpha() stopped working above Android 4.4 // so we gotta bring out some bitmap magic. Credit goes to: // http://stackoverflow.com/a/7477572 Bitmap enabledBitmap = ((BitmapDrawable) normalDrawable).getBitmap(); Bitmap disabledBitmap = Bitmap.createBitmap(normalDrawable.getIntrinsicWidth(), normalDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(disabledBitmap); Paint paint = new Paint(); paint.setAlpha(disabledAlpha); canvas.drawBitmap(enabledBitmap, 0, 0, paint); Resources activityRes = cordova.getActivity().getResources(); disabledDrawable = new BitmapDrawable(activityRes, disabledBitmap); } StateListDrawable states = new StateListDrawable(); if (pressedDrawable != null) { states.addState(new int[] { android.R.attr.state_pressed }, pressedDrawable); } if (normalDrawable != null) { states.addState(new int[] { android.R.attr.state_enabled }, normalDrawable); } if (disabledDrawable != null) { states.addState(new int[] {}, disabledDrawable); } setBackground(view, states); }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
/** * Creates a view given the View type and an event * * @param event/*from ww w . j a v a 2 s. c o m*/ * @param advancingPage * -- true if this results from advancing through the form * @return newly created View */ private View createView(int event, boolean advancingPage, int swipeCase) { FormController formController = Collect.getInstance().getFormController(); /* setTitle(getString(R.string.app_name) + " > " + formController.getFormTitle());*/ int questioncount = formController.getFormDef().getDeepChildCount(); switch (event) { case FormEntryController.EVENT_BEGINNING_OF_FORM: progressValue = 0.0; progressUpdate(progressValue, questioncount); View startView = View.inflate(this, R.layout.form_entry_start, null); /*setTitle(getString(R.string.app_name) + " > " + formController.getFormTitle());*/ Drawable image = null; File mediaFolder = formController.getMediaFolder(); String mediaDir = mediaFolder.getAbsolutePath(); BitmapDrawable bitImage = null; // attempt to load the form-specific logo... // this is arbitrarily silly bitImage = new BitmapDrawable(getResources(), mediaDir + File.separator + "form_logo.png"); if (bitImage != null && bitImage.getBitmap() != null && bitImage.getIntrinsicHeight() > 0 && bitImage.getIntrinsicWidth() > 0) { image = bitImage; } if (image == null) { // show the opendatakit zig... // image = // getResources().getDrawable(R.drawable.opendatakit_zig); ((ImageView) startView.findViewById(R.id.form_start_bling)).setVisibility(View.GONE); } else { ImageView v = ((ImageView) startView.findViewById(R.id.form_start_bling)); v.setImageDrawable(image); v.setContentDescription(formController.getFormTitle()); } // change start screen based on navigation prefs String navigationChoice = PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_NAVIGATION, PreferencesActivity.KEY_NAVIGATION); Boolean useSwipe = false; Boolean useButtons = false; ImageView ia = ((ImageView) startView.findViewById(R.id.image_advance)); ImageView ib = ((ImageView) startView.findViewById(R.id.image_backup)); TextView ta = ((TextView) startView.findViewById(R.id.text_advance)); TextView tb = ((TextView) startView.findViewById(R.id.text_backup)); TextView d = ((TextView) startView.findViewById(R.id.description)); if (navigationChoice != null) { if (navigationChoice.contains(PreferencesActivity.NAVIGATION_SWIPE)) { useSwipe = true; } if (navigationChoice.contains(PreferencesActivity.NAVIGATION_BUTTONS)) { useButtons = true; } } if (useSwipe && !useButtons) { d.setText(getString(R.string.swipe_instructions, formController.getFormTitle())); } else if (useButtons && !useSwipe) { ia.setVisibility(View.GONE); ib.setVisibility(View.GONE); ta.setVisibility(View.GONE); tb.setVisibility(View.GONE); d.setText(getString(R.string.buttons_instructions, formController.getFormTitle())); } else { d.setText(getString(R.string.swipe_buttons_instructions, formController.getFormTitle())); } if (mBackButton.isShown()) { mBackButton.setEnabled(false); } if (mNextButton.isShown()) { mNextButton.setEnabled(true); } return startView; case FormEntryController.EVENT_END_OF_FORM: progressValue = questioncount; progressUpdate(progressValue, questioncount); View endView = View.inflate(this, R.layout.form_entry_end, null); ((ImageView) endView.findViewById(R.id.completed)) .setImageDrawable(getResources().getDrawable(R.drawable.complete_tick)); ((TextView) endView.findViewById(R.id.description)) .setText(getString(R.string.save_enter_data_description, formController.getFormTitle())); // checkbox for if finished or ready to send final CheckBox instanceComplete = ((CheckBox) endView.findViewById(R.id.mark_finished)); instanceComplete.setChecked(isInstanceComplete(true)); if (!mAdminPreferences.getBoolean(AdminPreferencesActivity.KEY_MARK_AS_FINALIZED, true)) { instanceComplete.setVisibility(View.GONE); } // edittext to change the displayed name of the instance final EditText saveAs = (EditText) endView.findViewById(R.id.save_name); // disallow carriage returns in the name InputFilter returnFilter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { if (Character.getType((source.charAt(i))) == Character.CONTROL) { return ""; } } return null; } }; saveAs.setFilters(new InputFilter[] { returnFilter }); String saveName = getSaveName(); if (saveName == null) { // no meta/instanceName field in the form -- see if we have a // name for this instance from a previous save attempt... if (getContentResolver().getType(getIntent().getData()) == InstanceColumns.CONTENT_ITEM_TYPE) { Uri instanceUri = getIntent().getData(); Cursor instance = null; try { instance = getContentResolver().query(instanceUri, null, null, null, null); if (instance.getCount() == 1) { instance.moveToFirst(); saveName = instance.getString(instance.getColumnIndex(InstanceColumns.DISPLAY_NAME)); } } finally { if (instance != null) { instance.close(); } } } if (saveName == null) { // last resort, default to the form title saveName = formController.getFormTitle(); } // present the prompt to allow user to name the form TextView sa = (TextView) endView.findViewById(R.id.save_form_as); sa.setVisibility(View.VISIBLE); saveAs.setText(saveName); saveAs.setEnabled(true); saveAs.setVisibility(View.VISIBLE); } else { // if instanceName is defined in form, this is the name -- no // revisions // display only the name, not the prompt, and disable edits TextView sa = (TextView) endView.findViewById(R.id.save_form_as); sa.setVisibility(View.GONE); saveAs.setText(saveName); saveAs.setEnabled(false); saveAs.setBackgroundColor(Color.WHITE); saveAs.setVisibility(View.VISIBLE); } // override the visibility settings based upon admin preferences if (!mAdminPreferences.getBoolean(AdminPreferencesActivity.KEY_SAVE_AS, true)) { saveAs.setVisibility(View.GONE); TextView sa = (TextView) endView.findViewById(R.id.save_form_as); sa.setVisibility(View.GONE); } // Create 'save' button ((Button) endView.findViewById(R.id.save_exit_button)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "createView.saveAndExit", instanceComplete.isChecked() ? "saveAsComplete" : "saveIncomplete"); // Form is marked as 'saved' here. if (saveAs.getText().length() < 1) { Toast.makeText(FormEntryActivity.this, R.string.save_as_error, Toast.LENGTH_SHORT).show(); } else { saveDataToDisk(EXIT, instanceComplete.isChecked(), saveAs.getText().toString()); } } }); if (mBackButton.isShown()) { mBackButton.setEnabled(true); } if (mNextButton.isShown()) { mNextButton.setEnabled(false); } return endView; case FormEntryController.EVENT_QUESTION: case FormEntryController.EVENT_GROUP: case FormEntryController.EVENT_REPEAT: ODKView odkv = null; // should only be a group here if the event_group is a field-list try { double depth = (double) formController.getFormIndex().getDepth(); double local_index = (double) formController.getFormIndex().getLocalIndex(); double instance_index = (double) formController.getFormIndex().getInstanceIndex(); Log.i("Question coint", Integer.toString(questioncount)); Log.i("Depth", Integer.toString(formController.getFormIndex().getDepth())); Log.i("Local Index", Integer.toString(formController.getFormIndex().getLocalIndex())); Log.i("Instance Index", Integer.toString(formController.getFormIndex().getInstanceIndex())); if (swipeCase == NEXT) { Log.i("progressValue", Double.toString(progressValue)); } if (swipeCase == PREVIOUS) { progressValue = progressValue - (1 - (instance_index * local_index / questioncount * depth)); Log.i("progressValue", Double.toString(progressValue)); } Log.i("progressValue", Double.toString(progressValue)); progressUpdate(progressValue, questioncount); FormEntryPrompt[] prompts = formController.getQuestionPrompts(); FormEntryCaption[] groups = formController.getGroupsForCurrentIndex(); odkv = new ODKView(this, formController.getQuestionPrompts(), groups, advancingPage); Log.i(t, "created view for group " + (groups.length > 0 ? groups[groups.length - 1].getLongText() : "[top]") + " " + (prompts.length > 0 ? prompts[0].getQuestionText() : "[no question]")); } catch (RuntimeException e) { Log.e(t, e.getMessage(), e); // this is badness to avoid a crash. try { event = formController.stepToNextScreenEvent(); createErrorDialog(e.getMessage(), DO_NOT_EXIT); } catch (JavaRosaException e1) { Log.e(t, e1.getMessage(), e1); createErrorDialog(e.getMessage() + "\n\n" + e1.getCause().getMessage(), DO_NOT_EXIT); } return createView(event, advancingPage, swipeCase); } // Makes a "clear answer" menu pop up on long-click for (QuestionWidget qw : odkv.getWidgets()) { if (!qw.getPrompt().isReadOnly()) { registerForContextMenu(qw); } } if (mBackButton.isShown() && mNextButton.isShown()) { mBackButton.setEnabled(true); mNextButton.setEnabled(true); } return odkv; default: Log.e(t, "Attempted to create a view that does not exist."); // this is badness to avoid a crash. try { event = formController.stepToNextScreenEvent(); createErrorDialog(getString(R.string.survey_internal_error), EXIT); } catch (JavaRosaException e) { Log.e(t, e.getMessage(), e); createErrorDialog(e.getCause().getMessage(), EXIT); } return createView(event, advancingPage, swipeCase); } }
From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java
/** * Loading adapter after getting a list of elements * * @param bitmap the list of objects for the adapter * @param back//from w ww. ja va2s .c o m * @param path the path for the adapter * @param openMode the type of file being created * @param results is the list of elements a result from search * @param grid whether to set grid view or list view */ public void createViews(ArrayList<LayoutElement> bitmap, boolean back, String path, final OpenMode openMode, boolean results, boolean grid) { synchronized (bitmap) { if (bitmap != null) { if (GO_BACK_ITEM) if (!path.equals("/") && (openMode == OpenMode.FILE || openMode == OpenMode.ROOT) && !path.equals(OTGUtil.PREFIX_OTG + "/") && !path.equals(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "/") && !path.equals(CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "/") && !path.equals(CloudHandler.CLOUD_PREFIX_BOX + "/") && !path.equals(CloudHandler.CLOUD_PREFIX_DROPBOX + "/")) { if (bitmap.size() == 0 || !bitmap.get(0).getSize().equals(goback)) { Bitmap iconBitmap = BitmapFactory.decodeResource(res, R.drawable.ic_arrow_left_white_24dp); bitmap.add(0, utils.newElement(new BitmapDrawable(res, iconBitmap), "..", "", "", goback, 0, false, true, "")); } } if (bitmap.size() == 0 && !results) { nofilesview.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); mSwipeRefreshLayout.setEnabled(false); } else { mSwipeRefreshLayout.setEnabled(true); nofilesview.setVisibility(View.GONE); listView.setVisibility(View.VISIBLE); } putLayoutElements(bitmap); if (grid && IS_LIST) switchToGrid(); else if (!grid && !IS_LIST) switchToList(); if (adapter == null) adapter = new RecyclerAdapter(ma, utilsProvider, bitmap, ma.getActivity()); else { adapter.generate(getLayoutElements()); } stopAnims = true; this.openMode = openMode; if (openMode != OpenMode.CUSTOM) dataUtils.addHistoryFile(path); //mSwipeRefreshLayout.setRefreshing(false); listView.setAdapter(adapter); if (!addheader) { listView.removeItemDecoration(headersDecor); listView.removeItemDecoration(dividerItemDecoration); addheader = true; } if (addheader && IS_LIST) { dividerItemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, true, SHOW_DIVIDERS); listView.addItemDecoration(dividerItemDecoration); headersDecor = new StickyRecyclerHeadersDecoration(adapter); listView.addItemDecoration(headersDecor); addheader = false; } if (!results) this.results = false; CURRENT_PATH = path; if (back) { if (scrolls.containsKey(CURRENT_PATH)) { Bundle b = scrolls.get(CURRENT_PATH); if (IS_LIST) mLayoutManager.scrollToPositionWithOffset(b.getInt("index"), b.getInt("top")); else mLayoutManagerGrid.scrollToPositionWithOffset(b.getInt("index"), b.getInt("top")); } } //floatingActionButton.show(); MAIN_ACTIVITY.updatePaths(no); listView.stopScroll(); fastScroller.setRecyclerView(listView, IS_LIST ? 1 : columns); mToolbarContainer.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { fastScroller.updateHandlePosition(verticalOffset, 112); // fastScroller.setPadding(fastScroller.getPaddingLeft(),fastScroller.getTop(),fastScroller.getPaddingRight(),112+verticalOffset); // fastScroller.updateHandlePosition(); } }); fastScroller.registerOnTouchListener(new FastScroller.onTouchListener() { @Override public void onTouch() { if (stopAnims && adapter != null) { stopAnimation(); stopAnims = false; } } }); if (buttons.getVisibility() == View.VISIBLE) MAIN_ACTIVITY.bbar(this); AppConfig.runInBackground(new Runnable() { @Override public void run() { switch (openMode) { case ROOT: case FILE: // watch the current directory File file = new File(CURRENT_PATH); if (file.isDirectory() && file.canRead()) { if (customFileObserver != null) { // already a watcher instantiated, first it should be stopped customFileObserver.stopWatching(); } customFileObserver = new CustomFileObserver(CURRENT_PATH); customFileObserver.startWatching(); } break; default: break; } } }); //MAIN_ACTIVITY.invalidateFab(openMode); } else { // list loading cancelled // TODO: Add support for cancelling list loading loadlist(home, true, OpenMode.FILE); } } }
From source file:ca.mimic.apphangar.Settings.java
static void updateMoreAppsIcon(Context context) { try {// ww w . j a v a 2 s. c o m Drawable d = new BitmapDrawable(context.getResources(), new IconHelper(mContext).cachedResourceIconHelper(MORE_APPS_PACKAGE)); PrefsFragment mGeneralSettings = (PrefsFragment) mGetFragments.getFragmentByPosition(GENERAL_TAB); mGeneralSettings.more_apps_icon_preference.setIcon(d); } catch (Exception e) { } }
From source file:ca.mimic.apphangar.Settings.java
static void updateIconPackIcon(Context context) { String iconPackPackage = prefs.prefsGet().getString(ICON_PACK_PREFERENCE, null); Drawable icon;/*from w w w . j av a 2 s.com*/ icon = context.getResources().getDrawable(R.drawable.ic_launcher); try { Tools.HangarLog("iconPackPackage: " + iconPackPackage); icon = new BitmapDrawable(context.getResources(), new IconHelper(mContext).cachedResourceIconHelper(iconPackPackage)); } catch (Exception e) { } PrefsFragment mGeneralSettings = (PrefsFragment) mGetFragments.getFragmentByPosition(GENERAL_TAB); mGeneralSettings.icon_pack_preference.setIcon(icon); }