Example usage for android.widget ImageView setImageDrawable

List of usage examples for android.widget ImageView setImageDrawable

Introduction

In this page you can find the example usage for android.widget ImageView setImageDrawable.

Prototype

public void setImageDrawable(@Nullable Drawable drawable) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

From source file:com.abroad.ruianju.im.util.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from  w  ww . ja  v a  2  s  . c  o  m*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        //            final TransitionDrawable td =
        //                    new TransitionDrawable(new Drawable[] {
        //                            new ColorDrawable(android.R.color.transparent),
        //                            drawable
        //                    });
        //            // Set background to loading bitmap
        //            imageView.setBackgroundDrawable(
        //                    new BitmapDrawable(mResources, mLoadingBitmap));
        //
        //            imageView.setImageDrawable(td);
        //            td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.crazyapk.util.bitmap.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and disk
 * cache will be used if an {@link ImageCache} has been set using
 * {@link ImageWorker#setImageCache(ImageCache)}. If the image is found in the memory cache, it
 * is set immediately, otherwise an {@link AsyncTask} will be created to asynchronously load the
 * bitmap.//  w ww. ja va  2s.co  m
 *
 * @param data The URL of the image to download.
 * @param imageView The ImageView to bind the downloaded image to.
 */
public void loadImage(Object data, ImageView imageView, int corner) {
    mCorner = corner;
    if (data == null) {
        return;
    }
    Bitmap bitmap = null;
    if (mImageCache != null) {
        bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }
    //+    LogUtil.v("Bitmap Corner", ""+mCorner);
    if (bitmap != null) {
        // Bitmap found in memory cache
        if (corner > 0)
            bitmap = toRoundCorner(bitmap, mCorner);
        imageView.setImageBitmap(bitmap);
    } else if (cancelPotentialWork(data, imageView)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView, mCorner);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);

        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been pulled from the
        // framework and slightly modified. Refer to the docs at the top of the class
        // for more info on what was changed.
        task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR, data);
    }
}

From source file:com.baseproject.image.ImageWorker.java

public void loadImage(Object data, ImageView imageView, ImageCallback imageCallback) {
    Bitmap bitmap = null;//from w  ww  . j  a v a 2s. c o  m

    if (mImageCache != null) {
        bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (bitmap != null) {
        // Bitmap found in memory cache
        if (null != imageView) {
            imageView.setImageBitmap(bitmap);
        }
        if (imageCallback != null) {
            imageCallback.imageLoaded(bitmap, String.valueOf(data));
        }
    } else if (cancelPotentialWork(data, imageView)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView, imageCallback);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mContext.getResources(), mLoadingBitmap, task);
        if (null != imageView) {
            imageView.setImageDrawable(asyncDrawable);
        }
        task.execute(data);
    }
}

From source file:com.he5ed.lib.cloudprovider.picker.ItemFragment.java

/**
 * Update the view with item information
 *
 * @param rootView to be updated/*from w ww  .  ja  va2  s  .c o  m*/
 */
private void updateView(View rootView) {

    ImageView headerImage = (ImageView) rootView.findViewById(R.id.header_image_view);
    TextView title = (TextView) rootView.findViewById(R.id.title_text_view);
    TextView type = (TextView) rootView.findViewById(R.id.type_text_view);
    TextView path = (TextView) rootView.findViewById(R.id.path_text_view);
    TextView created = (TextView) rootView.findViewById(R.id.created_text_view);
    TextView modified = (TextView) rootView.findViewById(R.id.modified_text_view);
    // setup simple date formatter
    SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy");
    if (mItem instanceof CFile) {
        CFile file = (CFile) mItem;
        title.setText(file.getName());
        type.setText(R.string.type_file);
        path.setText(file.getPath());
        if (file.getCreated() != null)
            created.setText(sdf.format(file.getCreated()));
        if (file.getModified() != null)
            modified.setText(sdf.format(file.getModified()));
        new GetThumbnailTask().execute(file);
        headerImage.setImageDrawable(GraphicUtils.setTint(getResources(),
                R.drawable.ic_insert_drive_file_black_48dp, Color.parseColor("#9E9E9E")));

    } else if (mItem instanceof CFolder) {
        CFolder folder = (CFolder) mItem;
        title.setText(folder.getName());
        type.setText(R.string.type_file);
        path.setText(folder.getPath());
        if (folder.getCreated() != null)
            created.setText(sdf.format(folder.getCreated()));
        if (folder.getModified() != null)
            modified.setText(sdf.format(folder.getModified()));

        headerImage.setImageDrawable(GraphicUtils.setTint(getResources(), R.drawable.ic_folder_black_48dp,
                Color.parseColor("#9E9E9E")));
    }
    // expand app bar
    AppBarLayout appbar = (AppBarLayout) rootView.findViewById(R.id.app_bar);
    appbar.setExpanded(true);
}

From source file:cn.com.wo.bitmap.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from   ww w  .j a  va2s. c  om*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable, boolean isBackground) {
    if (mFadeInBitmap && !isBackground) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        int index = 0;
        if (imageView.getTag() != null)
            index = (Integer) imageView.getTag();
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap[index]));
        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
        if (ImageFetcher.isDebug)
            Log.i(ImageFetcher.TAG, "setImageDrawable src");
    } else {
        if (isBackground) {
            if (ImageFetcher.isDebug)
                Log.i(ImageFetcher.TAG, "setImageDrawable isBackground");
            imageView.setBackgroundDrawable(null);
            imageView.setBackgroundDrawable(drawable);
        } else {
            if (ImageFetcher.isDebug)
                Log.i(ImageFetcher.TAG, "setImageDrawable src");
            imageView.setImageDrawable(drawable);
        }
    }
}

From source file:com.fireplace.market.fads.util.ImageWorker.java

/**
 * Load an image specified by the data parameter into an ImageView (override
 * {@link ImageWorker#processBitmap(Object)} to define the processing
 * logic). A memory and disk cache will be used if an {@link ImageCache} has
 * been set using {@link ImageWorker#setImageCache(ImageCache)}. If the
 * image is found in the memory cache, it is set immediately, otherwise an
 * {@link JbAsyncTask} will be created to asynchronously load the bitmap.
 * /*  w  ww  .  ja  va2  s. c  om*/
 * @param data
 *            The URL of the image to download.
 * @param imageView
 *            The ImageView to bind the downloaded image to.
 */
public void loadImage(Object data, ImageView imageView, Boolean local) {
    if (data == null) {
        return;
    }

    Bitmap bitmap = null;

    if (mImageCache != null) {
        bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data));
    }

    if (bitmap != null) {
        // Bitmap found in memory cache
        imageView.setImageBitmap(bitmap);
    } else if (!local && cancelPotentialWork(data, imageView)) {
        final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
        final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task);
        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been
        // pulled from the
        // framework and slightly modified. Refer to the docs at the top of
        // the class
        // for more info on what was changed.
        task.executeOnExecutor(JbAsyncTask.DUAL_THREAD_EXECUTOR, data);

    } else if (local) {
        final BitmapLocalWorkerTask task = new BitmapLocalWorkerTask(imageView);
        final AsyncLocalDrawable asyncDrawable = new AsyncLocalDrawable(mResources, mLoadingBitmap, task);

        imageView.setImageDrawable(asyncDrawable);

        // NOTE: This uses a custom version of AsyncTask that has been
        // pulled from the
        // framework and slightly modified. Refer to the docs at the top of
        // the class
        // for more info on what was changed.
        task.executeOnExecutor(JbAsyncTask.DUAL_THREAD_EXECUTOR, data);

    }
}

From source file:com.google.android.apps.muzei.MuzeiActivity.java

private void updateUiMode() {
    // TODO: this should really just use fragment transactions and transitions

    int newUiMode = UI_MODE_INTRO;
    if (mWallpaperActive) {
        newUiMode = UI_MODE_TUTORIAL;//from   w w w.j  av  a2 s  .co  m
        if (mSeenTutorial) {
            newUiMode = UI_MODE_ART_DETAIL;
        }
    }

    if (mUiMode == newUiMode) {
        return;
    }

    // Crossfade between main containers
    final View oldContainerView = getMainContainerForUiMode(mUiMode);
    final View newContainerView = getMainContainerForUiMode(newUiMode);

    if (oldContainerView != null) {
        oldContainerView.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() {
            @Override
            public void run() {
                oldContainerView.setVisibility(View.GONE);
            }
        });
    }

    if (newContainerView != null) {
        if (newContainerView.getAlpha() == 1) {
            newContainerView.setAlpha(0);
        }
        newContainerView.setVisibility(View.VISIBLE);
        newContainerView.animate().alpha(1).setDuration(1000).withEndAction(null);
    }

    // Special work
    if (newUiMode == UI_MODE_INTRO) {
        final View activateButton = findViewById(R.id.activate_muzei_button);
        activateButton.setAlpha(0);
        final AnimatedMuzeiLogoFragment logoFragment = (AnimatedMuzeiLogoFragment) getFragmentManager()
                .findFragmentById(R.id.animated_logo_fragment);
        logoFragment.reset();
        logoFragment.setOnFillStartedCallback(new Runnable() {
            @Override
            public void run() {
                activateButton.animate().alpha(1f).setDuration(500);
            }
        });
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                logoFragment.start();
            }
        }, 1000);
    }

    if (mUiMode == UI_MODE_INTRO || newUiMode == UI_MODE_INTRO) {
        FragmentManager fm = getSupportFragmentManager();
        Fragment demoFragment = fm.findFragmentById(R.id.demo_view_container);
        if (newUiMode == UI_MODE_INTRO && demoFragment == null) {
            fm.beginTransaction()
                    .add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, true)).commit();
        } else if (newUiMode != UI_MODE_INTRO && demoFragment != null) {
            fm.beginTransaction().remove(demoFragment).commit();
        }
    }

    if (newUiMode == UI_MODE_TUTORIAL) {
        float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100,
                getResources().getDisplayMetrics());
        View mainTextView = findViewById(R.id.tutorial_main_text);
        mainTextView.setAlpha(0);
        mainTextView.setTranslationY(-animateDistance / 5);

        View subTextView = findViewById(R.id.tutorial_sub_text);
        subTextView.setAlpha(0);
        subTextView.setTranslationY(-animateDistance / 5);

        final View affordanceView = findViewById(R.id.tutorial_icon_affordance);
        affordanceView.setAlpha(0);
        affordanceView.setTranslationY(animateDistance);

        View iconTextView = findViewById(R.id.tutorial_icon_text);
        iconTextView.setAlpha(0);
        iconTextView.setTranslationY(animateDistance);

        AnimatorSet set = new AnimatorSet();
        set.setStartDelay(500);
        set.setDuration(250);
        set.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f),
                ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f));
        set.start();

        set = new AnimatorSet();
        set.setStartDelay(2000);

        // Bug in older versions where set.setInterpolator didn't work
        Interpolator interpolator = new OvershootInterpolator();
        ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0);
        ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0);
        ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0);
        ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0);
        a1.setInterpolator(interpolator);
        a2.setInterpolator(interpolator);
        a3.setInterpolator(interpolator);
        a4.setInterpolator(interpolator);
        set.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f),
                ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    ImageView emanateView = (ImageView) findViewById(R.id.tutorial_icon_emanate);
                    AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources()
                            .getDrawable(R.drawable.avd_tutorial_icon_emanate, getTheme());
                    emanateView.setImageDrawable(avd);
                    avd.start();
                }
            });
        }
        set.start();
    }

    mPanScaleProxyView.setVisibility(newUiMode == UI_MODE_ART_DETAIL ? View.VISIBLE : View.GONE);

    mUiMode = newUiMode;

    maybeUpdateArtDetailOpenedClosed();
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * this function will initialize the ui showing the current image and reload
 * everything to make sure it is shown correctly
 *///from ww  w .ja va 2 s .  com
private void initUI() {
    // set the actionBar title and subtitle
    if (actionBar != null) {
        actionBar.setTitle(R.string.send_image);
        actionBar.setSubtitle(name);
        //      actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor
        //              (R.color.action_bar_transparent)));
        //      // set the statusBar color
        //      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        //        getActivity().getWindow().setStatusBarColor(getResources().getColor(R
        //                .color.action_bar_transparent));
    }

    // instantiate the ViewPager
    viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager);
    viewPager.setAdapter(new MyPagerAdapter());
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            changePage(position, false, false);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    //Cancel button pressed
    getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // just return to the chatFragment
            mListener.onReturnClick();
        }
    });
    //Send button pressed
    getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // create the progressDialog that is to be shown while saving
            // the image
            ProgressDialog progressDialog = new ProgressDialog(getContext());
            if (images.size() > 1)
                progressDialog.setTitle(
                        String.format(getResources().getString(R.string.sending_images), images.size()));
            else
                progressDialog.setTitle(R.string.sending_image);
            // run the sendImage in a new thread because I am saving the
            // image and this should be done in a new thread
            new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start();
        }
    });

    // generate the overview only if there are at least 2 images
    if (images.size() > 1) {
        // the layoutParams for the imageView which has the following attributes:
        // width = height = 65dp
        // margin = 5dp
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE);
        int a = Constants.dipToPixel(getContext(), 65);
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a);
        int b = Constants.dipToPixel(getContext(), 5);
        imageViewParams.setMargins(b, b, b, b);
        // the layoutParams for the backgroundView which has the following
        // attributes:
        // width = height = 71dp
        // margin = 2dp
        int c = Constants.dipToPixel(getContext(), 71);
        RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c);
        int d = Constants.dipToPixel(getContext(), 2);
        backgroundParams.setMargins(d, d, d, d);
        // the layoutParams for the relativeLayout containing the image and
        // the background which has the following attributes:
        // width = height = wrap_content
        LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content);
        linearLayout.removeAllViewsInLayout();
        int i = 0;
        for (Message msg : images) {
            // set up the imageView
            ImageView imageView = new ImageView(getContext());
            imageView.setLayoutParams(imageViewParams);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            // load the bitmap async
            AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a,
                    true);
            imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker));
            imageView.setOnClickListener(new overviewSelectListener(i++));
            bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri()));
            // set up the background
            View background = new View(getContext());
            background.setLayoutParams(backgroundParams);
            background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark));
            // make it invisible in the beginning
            background.setVisibility(View.GONE);

            // create the relativeLayout containing them
            RelativeLayout relativeLayout = new RelativeLayout(getContext());
            relativeLayout.setLayoutParams(relativeLayoutParams);
            relativeLayout.addView(background);
            relativeLayout.addView(imageView);
            // combination of Message and overviewViews
            msg.setLayout(relativeLayout);
            msg.setBackground(background);
            linearLayout.addView(relativeLayout);
        }
    } else
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE);
    changePage(current, true, true);
    showSystemUI();
}

From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java

/**
 * Override methods / listeners/*from   w  w w .  j  a v  a  2s. c o  m*/
 */
@Override
public Object instantiateItem(ViewGroup container, int position) {
    SwipeItem slideItem = mItems.get(position);
    LinearLayout layout = null;

    switch (slideItem.iconGravity) {
    case CENTER:
    case DEFAULT:
        layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_item, null);
        break;
    case LEFT:
        layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_left_item, null);
        break;
    case RIGHT:
        layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_right_item, null);
        break;
    }

    // GET VIEW
    ImageView icon = (ImageView) layout.findViewById(R.id.swipeselector_content_icon);
    TextView title = (TextView) layout.findViewById(R.id.swipeselector_content_title);
    TextView description = (TextView) layout.findViewById(R.id.swipeselector_content_description);

    // SET VIEW
    title.setText(slideItem.title);

    if (slideItem.description == null) {
        description.setVisibility(View.GONE);
    } else {
        description.setVisibility(View.VISIBLE);
        description.setText(slideItem.description);
    }

    if (slideItem.icon == null) {
        icon.setVisibility(View.GONE);
    } else {
        icon.setImageDrawable(slideItem.icon);
        icon.setVisibility(View.VISIBLE);
    }

    // We shouldn't get here if the typeface didn't exist.
    // But just in case, because we're paranoid.
    if (mCustomTypeFace != null) {
        title.setTypeface(mCustomTypeFace);
        description.setTypeface(mCustomTypeFace);
    }

    if (mTitleTextAppearance != -1) {
        setTextAppearanceCompat(title, mTitleTextAppearance);
    }

    if (mDescriptionTextAppearance != -1) {
        setTextAppearanceCompat(description, mDescriptionTextAppearance);
    }

    switch (slideItem.titleGravity) {
    case DEFAULT:
    case CENTER:
        title.setGravity(Gravity.CENTER);
        break;
    case LEFT:
        title.setGravity(Gravity.START);
        break;
    case RIGHT:
        title.setGravity(Gravity.END);
        break;
    }

    switch (slideItem.descriptionGravity) {
    case DEFAULT:
        if (mDescriptionGravity != -1) {
            description.setGravity(mDescriptionGravity);
        } else {
            description.setGravity(Gravity.CENTER);
        }
        break;
    case CENTER:
        description.setGravity(Gravity.CENTER);
        break;
    case LEFT:
        description.setGravity(Gravity.START);
        break;
    case RIGHT:
        description.setGravity(Gravity.END);
        break;
    }

    layout.setPadding(mContentLeftPadding, mSweetSixteen, mContentRightPadding, mSweetSixteen);

    container.addView(layout);
    return layout;
}

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

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Arrays.fill(state, false);/*from   w  w w.j  a  v  a2 s .c o m*/
    Arrays.fill(colours, 255);
    compressRatio = 100;
    // state[TREAT_IMAGE]=false;
    // image = BitmapFactory.decodeResource(getResources(), R.drawable.platanus_hispanica);
    Log.i(TAG, "Trying to load OpenCV library");
    if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback)) {
        Log.e(TAG, "Cannot connect to OpenCV Manager");
    }
    setContentView(R.layout.intro_activity);
    ImageView imv = (ImageView) findViewById(R.id.image_intro);
    imv.setImageDrawable(getResources().getDrawable(R.drawable.platanus_hispanica));
    // create RangeSeekBar as Integer range between 0 and 180
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    String rangepreference = (String) sharedPref.getString("rangepreference", "H");

    RangeSeekBar<Integer> seekBar = null;

    if (rangepreference.equals("H"))
        seekBar = new RangeSeekBar<Integer>(Integer.valueOf(sharedPref.getString("minH_preference", "60")),
                Integer.valueOf(sharedPref.getString("maxH_preference", "130")), this);
    if (rangepreference.equals("S"))
        seekBar = new RangeSeekBar<Integer>(Integer.valueOf(sharedPref.getString("minS_preference", "0")),
                Integer.valueOf(sharedPref.getString("maxS_preference", "255")), this);
    if (rangepreference.equals("V"))
        seekBar = new RangeSeekBar<Integer>(Integer.valueOf(sharedPref.getString("minV_preference", "0")),
                Integer.valueOf(sharedPref.getString("maxV_preference", "255")), this);

    //RangeSeekBar<Integer> seekBar = new RangeSeekBar<Integer>(MIN_TH, MAX_TH, this);
    seekBar.setId(R.id.rangeseekbar);
    seekBar.setOnRangeSeekBarChangeListener(new RangeSeekBar.OnRangeSeekBarChangeListener<Integer>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue, Integer maxValue) {
            rangeSeekBarChanged(minValue, maxValue);
        }

    });
    setVisibility();
    // add RangeSeekBar to pre-defined layout
    ViewGroup layout = (ViewGroup) findViewById(R.id.seekbarholder);
    layout.addView(seekBar);
    //locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
}