Cleaned up code in location fragment

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-06-02 16:17:21 -04:00
parent 4874a12020
commit c5c02e3984

View File

@@ -40,9 +40,10 @@ import com.google.android.maps.GeoPoint;
*/ */
public class LocationInfomationFragment extends Fragment implements GeoPointLocationListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, OnLocationSelectedListener, SearchRequestedListener { public class LocationInfomationFragment extends Fragment implements GeoPointLocationListener, OnClickListener, OnCheckedChangeListener, OnSeekBarChangeListener, OnLocationSelectedListener, SearchRequestedListener {
private ContentValues mInfo;
private OnContentChangedListener mListener;
private static final String TAG = "RingerInformationHowActivity"; private static final String TAG = "RingerInformationHowActivity";
private final ContentValues mInfo;
private final OnContentChangedListener mListener;
private final EnableScrollingListener mEnableScrollingListener;
private SeekBar mRadius; private SeekBar mRadius;
private MapFragment mMap; private MapFragment mMap;
private ToggleButton mMapEditToggle; private ToggleButton mMapEditToggle;
@@ -50,14 +51,13 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
private GeoPoint mPoint; private GeoPoint mPoint;
private SkyHook mSkyHook; private SkyHook mSkyHook;
private View view; private View view;
private EnableScrollingListener mEnableScrollingListener;
/** /**
* Creates a new MapFragment * Creates a new MapFragment
* @author ricky barrette * @author ricky barrette
* @param ringerInformationActivity * @param ringerInformationActivity
*/ */
public LocationInfomationFragment(ContentValues info, OnContentChangedListener listener, EnableScrollingListener enabledListener) { public LocationInfomationFragment(final ContentValues info, final OnContentChangedListener listener, final EnableScrollingListener enabledListener) {
this.mInfo = info; this.mInfo = info;
this.mListener = listener; this.mListener = listener;
this.mEnableScrollingListener = enabledListener; this.mEnableScrollingListener = enabledListener;
@@ -68,7 +68,7 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
view.findViewById(R.id.buttons).setVisibility(isChecked ? View.VISIBLE : View.GONE); view.findViewById(R.id.buttons).setVisibility(isChecked ? View.VISIBLE : View.GONE);
if(mEnableScrollingListener != null) if(mEnableScrollingListener != null)
@@ -92,13 +92,11 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
public void onClick(View v) { public void onClick(final View v) {
switch (v.getId()){ switch (v.getId()){
case R.id.mark_my_location: case R.id.mark_my_location:
if(this.mPoint != null){ if(this.mPoint != null)
onLocationSelected(mPoint); onLocationSelected(mPoint);
this.mMap.setMapCenter(mPoint);
}
break; break;
case R.id.my_location: case R.id.my_location:
if(this.mPoint != null) if(this.mPoint != null)
@@ -116,7 +114,7 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
view = inflater.inflate(R.layout.map_info_fragment, container, false); view = inflater.inflate(R.layout.map_info_fragment, container, false);
this.mSkyHook = new SkyHook(this.getActivity()); this.mSkyHook = new SkyHook(this.getActivity());
@@ -165,7 +163,7 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
* @see com.TwentyCodes.android.location.GeoPointLocationListener#onFirstFix(boolean) * @see com.TwentyCodes.android.location.GeoPointLocationListener#onFirstFix(boolean)
*/ */
@Override @Override
public void onFirstFix(boolean isFirstFix) { public void onFirstFix(final boolean isFirstFix) {
if (isFirstFix) if (isFirstFix)
mMap.enableGPSProgess(); mMap.enableGPSProgess();
else else
@@ -192,14 +190,17 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
public void onLocationChanged(GeoPoint point, int accuracy) { public void onLocationChanged(final GeoPoint point, final int accuracy) {
this.mPoint = point; this.mPoint = point;
} }
/* /**
* Called when a location has been selected
* (non-Javadoc)
* @see com.TwentyCodes.android.location.OnLocationSelectedListener#onLocationSelected(com.google.android.maps.GeoPoint)
*/ */
@Override @Override
public void onLocationSelected(GeoPoint point) { public void onLocationSelected(final GeoPoint point) {
if(point != null){ if(point != null){
if(Debug.DEBUG) if(Debug.DEBUG)
Log.d(TAG, "onLocationSelected() "+ point.toString()); Log.d(TAG, "onLocationSelected() "+ point.toString());
@@ -207,13 +208,11 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
if(this.mRadiusOverlay != null) if(this.mRadiusOverlay != null)
this.mRadiusOverlay.setLocation(point); this.mRadiusOverlay.setLocation(point);
if(this.mMap != null){ if(this.mMap != null)
this.mMap.setMapCenter(point); this.mMap.setMapCenter(point);
// this.mMap.setZoom((this.mMap.getMap().getMaxZoomLevel() - 5));
}
if(this.mListener != null){ if(this.mListener != null){
ContentValues info = new ContentValues(); final ContentValues info = new ContentValues();
info.put(RingerDatabase.KEY_LOCATION, point.toString()); info.put(RingerDatabase.KEY_LOCATION, point.toString());
this.mListener.onInfoContentChanged(info); this.mListener.onInfoContentChanged(info);
} }
@@ -236,13 +235,13 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
switch (seekBar.getId()){ switch (seekBar.getId()){
case R.id.radius: case R.id.radius:
this.mRadiusOverlay.setRadius(progress); this.mRadiusOverlay.setRadius(progress);
this.mMap.invalidate(); this.mMap.invalidate();
if(this.mListener != null){ if(this.mListener != null){
ContentValues info = new ContentValues(); final ContentValues info = new ContentValues();
info.put(RingerDatabase.KEY_RADIUS, progress); info.put(RingerDatabase.KEY_RADIUS, progress);
this.mListener.onInfoContentChanged(info); this.mListener.onInfoContentChanged(info);
} }
@@ -272,9 +271,7 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
} }
@Override @Override
public void onStartTrackingTouch(SeekBar seekBar) { public void onStartTrackingTouch(final SeekBar seekBar) {
// TODO Auto-generated method stub
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -288,9 +285,6 @@ public class LocationInfomationFragment extends Fragment implements GeoPointLoca
} }
@Override @Override
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(final SeekBar seekBar) {
// TODO Auto-generated method stub
} }
} }