Created
September 21, 2012 02:56
-
-
Save ChrisRisner/3759507 to your computer and use it in GitHub Desktop.
GeoDemo-Android-2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/scrollview" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" > | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" > | |
<TextView | |
android:id="@+id/lblAddPoiHeader" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Add New Point of Interest" | |
android:textAppearance="?android:attr/textAppearanceLarge" /> | |
<Button | |
android:id="@+id/btnSelectImage" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="Select Image" /> | |
<ImageView | |
android:id="@+id/imgSelectedImage" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:src="@drawable/androidmarker" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="30dp" > | |
<Button | |
android:id="@+id/btnGetSAS" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="Get SAS" /> | |
</LinearLayout> | |
<TextView | |
android:id="@+id/lblSASDetails" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="30dp" | |
android:text="SAS Details" /> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_marginTop="30dp" > | |
<Button | |
android:id="@+id/btnSavePOI" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:text="Save Point of Interest" /> | |
</LinearLayout> | |
</LinearLayout> | |
</ScrollView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_add_point_of_interest); | |
mActivity = this; | |
// Get UI Controls | |
mBtnGetSAS = (Button) findViewById(R.id.btnGetSAS); | |
mBtnSavePOI = (Button) findViewById(R.id.btnSavePOI); | |
mBtnSelectImage = (Button) findViewById(R.id.btnSelectImage); | |
mImgSelectedImage = (ImageView) findViewById(R.id.imgSelectedImage); | |
mLblSASDetails = (TextView) findViewById(R.id.lblSASDetails); | |
mBtnGetSAS.setEnabled(false); | |
mBtnSavePOI.setEnabled(false); | |
Intent myIntent = getIntent(); | |
mCurrentLocation = (Location) myIntent.getParcelableExtra("currentLocation"); | |
// Image select handler | |
mBtnSelectImage.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
selectImage(); | |
} | |
}); | |
// Get SAS Handler | |
mBtnGetSAS.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// Start progress dialog and start async task | |
mProgressDialog = new ProgressDialog(mActivity); | |
mProgressDialog.setMessage("Requesting SAS URL"); | |
mProgressDialog.show(); | |
new GetSASTask().execute(); | |
} | |
}); | |
// Save POI handler | |
mBtnSavePOI.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// Start progress dialog and start async task | |
mProgressDialog = new ProgressDialog(mActivity); | |
mProgressDialog.setMessage("Uploading Point of Interest"); | |
mProgressDialog.show(); | |
new PostPointOfInterestTask().execute(); | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fire off intent to select image from gallary | |
protected void selectImage() { | |
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | |
intent.setType("image/*"); | |
startActivityForResult(intent, 1111); | |
} | |
// Result handler for any intents started with startActivityForResult | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
try { | |
//handle result from gallary select | |
if (requestCode == 1111) { | |
Uri currImageURI = data.getData(); | |
this.mImageUrl = currImageURI; | |
//Set the image view's image by using imageUri | |
mImgSelectedImage.setImageURI(currImageURI); | |
mBtnGetSAS.setEnabled(true); | |
mBtnSavePOI.setEnabled(false); | |
} | |
} catch (Exception ex) { | |
Log.e("Add point of interest activity", "Error in onActivityResult: " + ex.getMessage()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Activity mActivity; | |
private Button mBtnGetSAS, mBtnSavePOI, mBtnSelectImage; | |
private TextView mLblSASDetails; | |
private ImageView mImgSelectedImage; | |
private ProgressDialog mProgressDialog; | |
private String _blobImagePostString = null; | |
private Uri mImageUrl; | |
private Location mCurrentLocation; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Constants { | |
public static final String kFindPOIUrl = "http://yoursubdomain.azurewebsites.net/api/Location/FindPointsOfInterestWithinRadius"; | |
public static final String kBlobSASUrl = "http://yoursubdomain.azurewebsites.net/api/blobsas/get?container=%s&blobname=%s"; | |
public static final String kAddPOIUrl = "http://yoursubdomain.azurewebsites.net/api/location/postpointofinterest/"; | |
public static final String kContainerName = "test"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LocationListener locationListener = new LocationListener() { | |
public void onLocationChanged(Location location) { | |
// Called when a new location is found by the network location | |
// provider. | |
makeUseOfNewLocation(location); | |
mCurrentLocation = location; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
if (requestCode == 1234) { | |
// Check to see if a POI was created | |
if (resultCode == 4321) { | |
Toast.makeText(getApplicationContext(), "New POI Created!", | |
Toast.LENGTH_SHORT).show(); | |
loadPointsFromServer(mCurrentLocation); | |
} else { | |
Toast.makeText(getApplicationContext(), "Nothing was done", | |
Toast.LENGTH_SHORT).show(); | |
} | |
} else | |
super.onActivityResult(requestCode, resultCode, data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment