Example usage for android.graphics BitmapFactory decodeResource

List of usage examples for android.graphics BitmapFactory decodeResource

Introduction

In this page you can find the example usage for android.graphics BitmapFactory decodeResource.

Prototype

public static Bitmap decodeResource(Resources res, int id) 

Source Link

Document

Synonym for #decodeResource(Resources,int,android.graphics.BitmapFactory.Options) with null Options.

Usage

From source file:com.edible.ocr.CaptureActivity.java

/**
 * Displays information relating to the result of OCR, and requests a translation if necessary.
 * //from   w  ww  .ja va2  s  .  c  o  m
 * @param ocrResult Object representing successful OCR results
 * @return True if a non-null result was received for OCR
 */
boolean handleOcrDecode(OcrResult ocrResult) {
    lastResult = ocrResult;

    // Test whether the result is null
    if (ocrResult.getText() == null || ocrResult.getText().equals("")) {
        Toast toast = Toast.makeText(this, "OCR failed. Please try again.", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
        return false;
    }

    // Turn off capture-related UI elements
    shutterButton.setVisibility(View.GONE);
    statusViewBottom.setVisibility(View.GONE);
    statusViewTop.setVisibility(View.GONE);
    cameraButtonView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView bitmapImageView = (ImageView) findViewById(R.id.image_view);
    lastBitmap = ocrResult.getBitmap();
    if (lastBitmap == null) {
        bitmapImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    } else {
        bitmapImageView.setImageBitmap(lastBitmap);
    }

    // Display the recognized text
    TextView sourceLanguageTextView = (TextView) findViewById(R.id.source_language_text_view);
    sourceLanguageTextView.setText(sourceLanguageReadable);
    TextView ocrResultTextView = (TextView) findViewById(R.id.ocr_result_text_view);
    ocrResultTextView.setText(stripNoise(ocrResult.getText()));
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - ocrResult.getText().length() / 4);
    ocrResultTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView translationLanguageLabelTextView = (TextView) findViewById(
            R.id.translation_language_label_text_view);
    TextView translationLanguageTextView = (TextView) findViewById(R.id.translation_language_text_view);
    TextView translationTextView = (TextView) findViewById(R.id.translation_text_view);
    if (isTranslationActive) {
        // Handle translation text fields
        translationLanguageLabelTextView.setVisibility(View.VISIBLE);
        translationLanguageTextView.setText(targetLanguageReadable);
        translationLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL);
        translationLanguageTextView.setVisibility(View.VISIBLE);

        // Activate/re-activate the indeterminate progress indicator
        translationTextView.setVisibility(View.GONE);
        progressView.setVisibility(View.VISIBLE);
        setProgressBarVisibility(true);

        // Get the translation asynchronously
        new TranslateAsyncTask(this, sourceLanguageCodeTranslation, targetLanguageCodeTranslation,
                stripNoise(ocrResult.getText())).execute();
    } else {
        translationLanguageLabelTextView.setVisibility(View.GONE);
        translationLanguageTextView.setVisibility(View.GONE);
        translationTextView.setVisibility(View.GONE);
        progressView.setVisibility(View.GONE);
        setProgressBarVisibility(false);
    }
    return true;
}

From source file:com.example.SmartBoard.DrawingView.java

public void onDrawColorDropper(Canvas canvas, int dropX, int dropY) {
    Bitmap dropperImage = BitmapFactory.decodeResource(getResources(), R.drawable.drop_color_iconpng);
    canvas.drawBitmap(dropperImage, dropX, dropY, drawPaint);
}

From source file:com.klinker.android.twitter.utils.NotificationUtils.java

public static void notifySecondMentions(Context context, int secondAccount) {
    MentionsDataSource data = MentionsDataSource.getInstance(context);
    int numberNew = data.getUnreadCount(secondAccount);

    int smallIcon = R.drawable.ic_stat_icon;
    Bitmap largeIcon;//from  w ww .j a v  a2  s  .c om

    Intent resultIntent = new Intent(context, SwitchAccountsRedirect.class);

    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);

    NotificationCompat.Builder mBuilder;

    String title = context.getResources().getString(R.string.app_name) + " - "
            + context.getResources().getString(R.string.sec_acc);
    ;
    String name = null;
    String message;
    String messageLong;

    String tweetText = null;
    NotificationCompat.Action replyAction = null;
    if (numberNew == 1) {
        name = data.getNewestName(secondAccount);

        SharedPreferences sharedPrefs = context.getSharedPreferences(
                "com.klinker.android.twitter_world_preferences",
                Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
        // if they are muted, and you don't want them to show muted mentions
        // then just quit
        if (sharedPrefs.getString("muted_users", "").contains(name)
                && !sharedPrefs.getBoolean("show_muted_mentions", false)) {
            return;
        }

        message = context.getResources().getString(R.string.mentioned_by) + " @" + name;
        tweetText = data.getNewestMessage(secondAccount);
        messageLong = "<b>@" + name + "</b>: " + tweetText;
        largeIcon = getImage(context, name);

        Intent reply = new Intent(context, NotificationComposeSecondAcc.class);

        sharedPrefs.edit().putString("from_notification_second", "@" + name).commit();
        long id = data.getLastIds(secondAccount)[0];
        PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0);
        sharedPrefs.edit().putLong("from_notification_long_second", id).commit();
        sharedPrefs.edit()
                .putString("from_notification_text_second",
                        "@" + name + ": "
                                + TweetLinkUtils.removeColorHtml(tweetText, AppSettings.getInstance(context)))
                .commit();

        // Create the remote input
        RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel("@" + name + " ").build();

        // Create the notification action
        replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_action_reply_dark,
                context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput)
                        .build();

    } else { // more than one mention
        message = numberNew + " " + context.getResources().getString(R.string.new_mentions);
        messageLong = "<b>" + context.getResources().getString(R.string.mentions) + "</b>: " + numberNew + " "
                + context.getResources().getString(R.string.new_mentions);
        largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark);
    }

    Intent markRead = new Intent(context, MarkReadSecondAccService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

    AppSettings settings = AppSettings.getInstance(context);

    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverTwo.class);

    mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
            .setContentText(TweetLinkUtils.removeColorHtml(message, settings)).setSmallIcon(smallIcon)
            .setLargeIcon(largeIcon).setContentIntent(resultPendingIntent).setAutoCancel(true)
            .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
            .setPriority(NotificationCompat.PRIORITY_HIGH);

    if (numberNew == 1) {
        mBuilder.addAction(replyAction);
        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(
                settings.addonTheme ? messageLong.replaceAll("FF8800", settings.accentColor) : messageLong)));
    } else {
        NotificationCompat.InboxStyle inbox = getMentionsInboxStyle(numberNew, secondAccount, context,
                TweetLinkUtils.removeColorHtml(message, settings));

        mBuilder.setStyle(inbox);
    }
    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }

    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }

    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);

    if (settings.notifications) {

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

        notificationManager.notify(9, mBuilder.build());

        // if we want to wake the screen on a new message
        if (settings.wakeScreen) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                    | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
            wakeLock.acquire(5000);
        }

        // Pebble notification
        if (context
                .getSharedPreferences("com.klinker.android.twitter_world_preferences",
                        Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE)
                .getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title, messageLong);
        }

        // Light Flow notification
        sendToLightFlow(context, title, messageLong);
    }
}

From source file:com.bt.heliniumstudentapp.MainActivity.java

protected static void setStatusBar(Activity context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        context.getWindow().setStatusBarColor(Color.TRANSPARENT);

        if (context == mainContext)
            drawerDL.setStatusBarBackgroundColor(ContextCompat.getColor(context, darkPrimaryColor));
        else/*from  w w  w  . j  a  v a2 s.  co  m*/
            context.getWindow().setStatusBarColor(ContextCompat.getColor(context, darkPrimaryColor));

        context.setTaskDescription(new ActivityManager.TaskDescription(context.getString(R.string.app_name),
                BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher),
                ContextCompat.getColor(context, primaryColor)));

    }
}

From source file:com.android.mail.utils.NotificationUtils.java

private static Bitmap getIcon(final Context context, final int resId) {
    final Bitmap cachedIcon = sNotificationIcons.get(resId);
    if (cachedIcon != null) {
        return cachedIcon;
    }/*  www .  ja  v a  2s.  c o m*/

    final Bitmap icon = BitmapFactory.decodeResource(context.getResources(), resId);
    sNotificationIcons.put(resId, icon);

    return icon;
}

From source file:com.android.mail.utils.NotificationUtils.java

private static Bitmap getDefaultWearableBg(Context context) {
    Bitmap bg = sDefaultWearableBg.get();
    if (bg == null) {
        bg = BitmapFactory.decodeResource(context.getResources(), R.drawable.bg_email);
        sDefaultWearableBg = new WeakReference<>(bg);
    }//  w w  w.  j  a v  a  2  s  . c  o  m
    return bg;
}

From source file:com.android.argb.edhlc.Utils.java

public static Drawable getRoundedImage(Activity activity, String playerName, String playerDeck) {
    File p1CroppedImageFile = new File(activity.getFilesDir(),
            "image_" + playerName + "_" + playerDeck + ".png");
    Bitmap bitmap;/*from ww  w  . j  a  va  2  s .c om*/
    if (p1CroppedImageFile.isFile())
        bitmap = BitmapFactory.decodeFile(p1CroppedImageFile.getAbsolutePath());
    else
        bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.avatar_holder);
    RoundedAvatarDrawable roundedImage = new RoundedAvatarDrawable(Utils.getSquareBitmap(bitmap));
    roundedImage.setAntiAlias(true);
    return roundedImage;
}

From source file:es.upv.riromu.arbre.main.MainActivity.java

private void updateVisibility()

{
    Boolean done = false;/*from w ww .j  a v  a 2 s .c  o m*/
    TextView imc = (TextView) findViewById(R.id.textView);
    //   imc.setBackgroundColor(Color.rgb(255, 255, 255));
    RangeSeekBar<Integer> rangeSeekBar = (RangeSeekBar<Integer>) findViewById(R.id.rangeseekbar);
    rangeSeekBar.setSelectedMinValue(MIN_TH);
    rangeSeekBar.setSelectedMaxValue(MAX_TH);

    ImageView imv = (ImageView) findViewById(R.id.image_intro);

    if (state[CROP_IMAGE]) {
        rangeSeekBar.setVisibility(View.VISIBLE);
    }
    if (!state[CROP_IMAGE]) {
        rangeSeekBar.setVisibility(View.GONE);
    }

    if (state[TREAT_IMAGE] && state[CROP_IMAGE] && (!state[SHOW_HISTOGRAM])) {
        state[TREAT_IMAGE] = false;
        imv.setImageBitmap(croppedimage);
        done = true;
    }

    if (state[TREAT_IMAGE] && (!state[CROP_IMAGE]) && (!state[SHOW_HISTOGRAM]) && (!done)) {
        state[TREAT_IMAGE] = false;

        imv.setImageBitmap(image);
        ImageButton cropButton = (ImageButton) findViewById(R.id.button_crop);
        cropButton.setVisibility(View.VISIBLE);
        imc.setVisibility(View.GONE);
        ImageButton sendButton = (ImageButton) findViewById(R.id.button_send);
        sendButton.setVisibility(View.GONE);
        ImageButton histButton = (ImageButton) findViewById(R.id.button_histogram);
        histButton.setVisibility(View.GONE);
        ImageButton revertButton = (ImageButton) findViewById(R.id.button_revert);
        revertButton.setVisibility(View.GONE);
        ImageView imagePalette = (ImageView) findViewById(R.id.palette);
        imagePalette.setVisibility(View.GONE);
        done = true;
    }
    if ((!state[TREAT_IMAGE]) && state[CROP_IMAGE] && (!state[SHOW_HISTOGRAM]) && (!done)) {
        state[CROP_IMAGE] = false;
        try {
            InputStream is = getContentResolver().openInputStream(image_uri);
            imv.setImageBitmap(BitmapFactory.decodeStream(is));
            is.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, "File not found" + e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, "File not found" + e.getMessage());
        }
        croppedimage.recycle();
        done = true;
    }
    if ((!state[TREAT_IMAGE]) && (!state[CROP_IMAGE]) && (!state[SHOW_HISTOGRAM]) && (!done)) {
        image.recycle();
        image_uri = null;
        imv.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.platanus_hispanica));
        done = true;
    }
    if ((state[SHOW_HISTOGRAM]) && (!done)) {
        state[SHOW_HISTOGRAM] = false;
        rangeSeekBar.setVisibility(View.VISIBLE);
        imv.setImageBitmap(treatedimage);
        imc.setVisibility(View.VISIBLE);
        //                imc.setBackgroundColor(Color.rgb(colours[COLOUR_R], colours[COLOUR_G], colours[COLOUR_B]));

    }
}

From source file:com.klinker.android.twitter.utils.NotificationUtils.java

public static void newInteractions(User interactor, Context context, SharedPreferences sharedPrefs,
        String type) {/*from w w  w  .j a  v a 2 s  . com*/
    String title = "";
    String text = "";
    String smallText = "";
    Bitmap icon = null;

    AppSettings settings = AppSettings.getInstance(context);

    Intent resultIntent = new Intent(context, RedirectToDrawer.class);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);

    int newFollowers = sharedPrefs.getInt("new_followers", 0);
    int newRetweets = sharedPrefs.getInt("new_retweets", 0);
    int newFavorites = sharedPrefs.getInt("new_favorites", 0);
    int newQuotes = sharedPrefs.getInt("new_quotes", 0);

    // set title
    if (newFavorites + newRetweets + newFollowers > 1) {
        title = context.getResources().getString(R.string.new_interactions);
    } else {
        title = context.getResources().getString(R.string.new_interaction_upper);
    }

    // set text
    String currText = sharedPrefs.getString("old_interaction_text", "");
    if (!currText.equals("")) {
        currText += "<br>";
    }
    if (settings.displayScreenName) {
        text = currText + "<b>" + interactor.getScreenName() + "</b> " + type;
    } else {
        text = currText + "<b>" + interactor.getName() + "</b> " + type;
    }
    sharedPrefs.edit().putString("old_interaction_text", text).commit();

    // set icon
    int types = 0;
    if (newFavorites > 0) {
        types++;
    }
    if (newFollowers > 0) {
        types++;
    }
    if (newRetweets > 0) {
        types++;
    }
    if (newQuotes > 0) {
        types++;
    }

    if (types > 1) {
        icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_icon);
    } else {
        if (newFavorites > 0) {
            icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_heart_dark);
        } else if (newRetweets > 0) {
            icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_action_repeat_dark);
        } else {
            icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark);
        }
    }

    // set shorter text
    int total = newFavorites + newFollowers + newRetweets + newQuotes;
    if (total > 1) {
        smallText = total + " " + context.getResources().getString(R.string.new_interactions_lower);
    } else {
        smallText = text;
    }

    Intent markRead = new Intent(context, ReadInteractionsService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setContentTitle(title)
            .setContentText(Html.fromHtml(
                    settings.addonTheme ? smallText.replaceAll("FF8800", settings.accentColor) : smallText))
            .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(icon).setContentIntent(resultPendingIntent)
            .setTicker(title).setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
            .setPriority(NotificationCompat.PRIORITY_HIGH).setAutoCancel(true);

    if (context.getResources().getBoolean(R.bool.expNotifications)) {
        mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(
                Html.fromHtml(settings.addonTheme ? text.replaceAll("FF8800", settings.accentColor) : text)));
    }

    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }

    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }

    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);

    if (settings.notifications) {

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

        notificationManager.notify(4, mBuilder.build());

        // if we want to wake the screen on a new message
        if (settings.wakeScreen) {
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                    | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
            wakeLock.acquire(5000);
        }

        // Pebble notification
        if (sharedPrefs.getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title, text);
        }

        // Light Flow notification
        sendToLightFlow(context, title, text);
    }
}

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   www  . j a v  a  2  s  .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);
        }
    }
}