Skip to content

Commit

Permalink
fixed stale app geotag display. compiles. untested.
Browse files Browse the repository at this point in the history
  • Loading branch information
williamvanderkamp committed Mar 24, 2015
1 parent 1c63c4e commit 632c2a6
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.ObjectStreamException;
import java.io.Serializable;

import hoopsnake.geosource.data.AppGeotagField;
import io.nlopez.smartlocation.OnLocationUpdatedListener;
import io.nlopez.smartlocation.SmartLocation;

Expand Down Expand Up @@ -44,6 +45,12 @@ public double getLatitude()
// private LocationManager locationManager;
// private static final int TWO_MINUTES_IN_MILLIS = 120000;

public void setRegisteredField(AppGeotagField registeredField) {
this.registeredField = registeredField;
}

private AppGeotagField registeredField = null;

/**
* @precond context is not null.
* @postcond This geotag's location and timestamp are updated to their last known values.
Expand All @@ -59,15 +66,19 @@ public void onLocationUpdated(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();

SmartLocation.with(context).location().stop();
if (registeredField != null)
registeredField.onContentUpdated();
}
});
}

@Override
public String toString()
{
return "Geotag:\ntime in millis: " + timestamp + "\nlongitude: " + longitude + "\nlatitude: " + latitude;
if (exists())
return "Geotag:\ntime in millis: " + timestamp + "\nlongitude: " + longitude + "\nlatitude: " + latitude;
else
return "Geotag not yet determined.";
}

public boolean exists()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
import java.util.concurrent.locks.ReentrantLock;

import ServerClientShared.FieldWithContent;
import ServerClientShared.FieldWithoutContent;
import ServerClientShared.GeotagFieldWithContent;
import ServerClientShared.GeotagFieldWithoutContent;
import ServerClientShared.ImageFieldWithContent;
import ServerClientShared.ImageFieldWithoutContent;
import ServerClientShared.Incident;
import ServerClientShared.StringFieldWithContent;
import ServerClientShared.StringFieldWithoutContent;
import hoopsnake.geosource.comm.TaskReceiveIncidentSpec;
import hoopsnake.geosource.comm.TaskSendIncident;
import hoopsnake.geosource.data.AppField;
import hoopsnake.geosource.data.AppIncident;
Expand Down Expand Up @@ -124,6 +122,7 @@ private void initializeAppIncidentFromSharedPref(SharedPreferences sharedPref)

private void initializeAppIncidentFromServer(Bundle extras)
{
//get a geotag as fast as possible.
geotag.update(IncidentActivity.this);

String channelName = extras.getString(PARAM_STRING_CHANNEL_NAME);
Expand Down Expand Up @@ -178,7 +177,7 @@ public void renderIncidentFromScratch()
{
assertNotNull(field);

View v = field.getContentViewRepresentation(RequestCode.FIELD_ACTION_REQUEST_CODE.ordinal());
View v = field.getFieldViewRepresentation(RequestCode.FIELD_ACTION_REQUEST_CODE.ordinal());
assertNotNull(v);

incidentDisplay.addView(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,11 @@ public void setContent(Serializable content)

wrappedField.setContent(content);
}

// @Override
// public View getFieldViewRepresentation(final int requestCodeForIntent)
// {
// //TODO implement this.
//// LinearLayout lView = activity.getLayoutInflater().inflate(R.layout.field_view_holder, null);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String getContentStringRepresentation()
}

@Override
public View getContentViewRepresentation(final int requestCodeForIntent)
public View getFieldViewRepresentation(final int requestCodeForIntent)
{
if (contentIsFilled())
return getFilledContentViewRepresentation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public interface AppField {
* @return a View representing this field, to be displayed by the UI. This view should be up-to-date
* with the field's content status: if content is not null, return a view showing the filled version.
*/
public View getContentViewRepresentation(final int requestCodeForIntent);
public View getFieldViewRepresentation(final int requestCodeForIntent);

/**
* When the result from this field being selected by the UI is returned, execute the correct action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
public class AppGeotagField extends AbstractAppField {

private TextView tv;

public AppGeotagField(GeotagFieldWithContent fieldToWrap, IncidentActivity activity) {
super(fieldToWrap, activity);
}
Expand All @@ -32,8 +34,8 @@ public boolean contentIsFilled()
}

@Override
public View getContentViewRepresentation(int requestCodeForIntent) {
TextView tv = (TextView) activity.getLayoutInflater().inflate(R.layout.field_geotag_view, null);
public View getFieldViewRepresentation(int requestCodeForIntent) {
tv = (TextView) activity.getLayoutInflater().inflate(R.layout.field_geotag_view, null);
//This is for the faded out effect. (rather than setText().)
tv.setHint(getContentStringRepresentation());
return tv;
Expand All @@ -47,4 +49,18 @@ public boolean contentIsSuitable(Serializable content)

@Override
public void onResultFromSelection(int resultCode, Intent data) {}

public void onContentUpdated()
{
if (tv != null)
tv.setHint(getContentStringRepresentation());
}

@Override
public void setContent(Serializable content)
{
super.setContent(content);

((Geotag) content).setRegisteredField(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface AppIncident

/**
* @precond geotag not null.
* @postcond this incident's geotag (location and timestamp) are updated to the given values.
* @postcond this incident's geotag is updated to the new one.
* @param geotag
*/
public void setGeotag(Geotag geotag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private String getPromptStringForUi() {
}

@Override
public View getContentViewRepresentation(final int requestCodeForIntent) {
public View getFieldViewRepresentation(final int requestCodeForIntent) {
//TODO both these lines seem to work for the same purpose. Which is better?
EditText contentEditor = (EditText) activity.getLayoutInflater().inflate(R.layout.field_edit_text, null);

Expand Down
2 changes: 0 additions & 2 deletions Geosource-Android/app/src/main/res/drawable/distribute.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ for dir in "${DIRS[@]}"; do
cd ../..;
done

cd ../..

exit
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public GeotagFieldWithContent(GeotagFieldWithoutContent fieldWithoutContent) {
super(fieldWithoutContent);
}

/** this will actually be a geotag but i can't import that in serverclientshared, so I can't verify against that type. */
/** TODO this will actually be a geotag but i can't import that in serverclientshared, so I can't verify against that type. */
@Override
public boolean contentMatchesType(Serializable content) {
return content != null;
return true;
}

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
Expand Down

0 comments on commit 632c2a6

Please sign in to comment.