get Seek Bar Value from progress, min/max value - Android java.lang

Android examples for java.lang:Integer

Description

get Seek Bar Value from progress, min/max value

Demo Code

import android.net.Uri;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.StrikethroughSpan;
import android.util.Log;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static int getSeekBarValue(int progress, int minValue,
            int midValue, int maxValue) {
        if (progress < 0) {
            return 0;
        }// w ww  .  j a  va2  s  .  c  om

        if (progress <= 50) {
            return (int) ((midValue - minValue) * (progress / 50.00))
                    + minValue;
        } else {
            int overValue = (int) ((progress - 50) * (maxValue - midValue) / 50.00);
            return midValue + overValue;
        }
    }

}

Related Tutorials