package org.azavea.otm.filters;

import org.azavea.otm.R;

import android.view.View;
import android.widget.EditText;

public class RangeFilter extends BaseFilter {
	private double min = 0;
	private double max = 0;
	
	public RangeFilter(String key, String label) {
		this.key = key;
		this.label = label;
	}
	
	public double getMin() {
		return min;
	}
	
	public double getMax() {
		return max;
	}
	
	private String minKey() {
		return key + "_min";
	}
	
	private String maxKey() {
		return key + "_max";
	}

	@Override
	public String toQueryStringParam() {
		String params = "";
		if (min > 0) {
			params += minKey() + "=" + Double.toString(min); 
		}
		if (max > 0) {
			params += maxKey() + "=" + Double.toString(max);
		}
		return params;
	}

	@Override
	public boolean isActive() {
		return (min > 0 || max > 0) ? true : false;
	}

	@Override
	public void updateFromView(View view) {
		String min = ((EditText)view.findViewById(R.id.min))
				.getText().toString().trim();
		String max = ((EditText)view.findViewById(R.id.max))
				.getText().toString().trim();
		
		if (min != null && !"".equals(min)) {
			this.min = Double.parseDouble(min);
		} else {
			this.min = 0;
		}
			
		if (max != null && !"".equals(max)) {
			this.max = Double.parseDouble(max);
		} else {
			this.max = 0;
		}
	}

	@Override
	public void clear() {
		min = 0;
		max = 0;
	}
}

@@ -157,16 +157,51 @@
 ilter %7B%0A
+%09final private double DEFAULT = 0;%0A
 %09private
@@ -214,17 +214,23 @@
 e min = 
-0
+DEFAULT
 ;%0A%09priva
@@ -245,17 +245,23 @@
 e max = 
-0
+DEFAULT
 ;%0A%09%0A%09pub
@@ -843,17 +843,23 @@
  (min %3E 
-0
+DEFAULT
  %7C%7C max 
@@ -860,17 +860,23 @@
 %7C max %3E 
-0
+DEFAULT
 ) ? true
@@ -1222,25 +1222,31 @@
 %09this.min = 
-0
+DEFAULT
 ;%0A%09%09%7D%0A%09%09%09%0A%09%09
@@ -1347,17 +1347,23 @@
 s.max = 
-0
+DEFAULT
 ;%0A%09%09%7D%0A%09%7D
@@ -1406,17 +1406,23 @@
 %09%09min = 
-0
+DEFAULT
 ;%0A%09%09max 
@@ -1423,16 +1423,22 @@
 %09%09max = 
-0
+DEFAULT
 ;%0A%09%7D%0A%7D%0A

Make 0 a constant value, not magic number