Commit fd2f4fb2 authored by Kristin Muterspaw's avatar Kristin Muterspaw
Browse files

Added a spinner that shows up when you first connect to a bluetooth sensor...

Added a spinner that shows up when you first connect to a bluetooth sensor that stays up until connected.
parent 51860f26
......@@ -3,6 +3,7 @@ package fieldscience.cs.earlham.edu.fieldday;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
......@@ -76,7 +77,7 @@ public class SensorSampleActivity extends Activity {
public int streamStatusId = 0;
private Context context;
private ArrayAdapter<aSensor> adapter;
private ProgressBar pictureSaving;
private ProgressDialog progress;
File baseDir;
Uri pictureUri;
......@@ -99,12 +100,12 @@ public class SensorSampleActivity extends Activity {
@Override
public void onReceive(Context context, Intent intent) {
if (SensorSampleService.ACTION_CONNECTED.equals(intent.getAction())){
Log.d("SensorSampleActivity", "Received Connected Message!");
enableButtons();
ArrayList<aSensor> sensors = intent.getParcelableArrayListExtra(SensorSampleService.SENSOR_LIST);
adapter.clear();
adapter.addAll(sensors);
adapter.notifyDataSetChanged();
progress.dismiss();
} else if (SensorSampleService.ACTION_UPDATED_LIST.equals(intent.getAction())) {
ArrayList<aSensor> sensors = intent.getParcelableArrayListExtra(SensorSampleService.SENSOR_LIST);
adapter.clear();
......@@ -136,6 +137,11 @@ public class SensorSampleActivity extends Activity {
sampleButton.setImageDrawable(res.getDrawable(R.drawable.sample_unavailable, null));
sampleButton.setClickable(false);
streamButton.setClickable(false);
progress = new ProgressDialog(this);
progress.setMessage("Please wait. Connecting to sensor.");
progress.setCancelable(false);
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.show();
}
ListView mSensors = (ListView) findViewById(android.R.id.list);
......@@ -404,8 +410,8 @@ public class SensorSampleActivity extends Activity {
streamOn = res.getDrawable(R.drawable.stream_pushed, null);
streamOff = res.getDrawable(R.drawable.stream_button, null);
pictureButton = (Button) findViewById(R.id.addPictureButton);
pictureSaving = (ProgressBar) findViewById(R.id.pictureSpinner);
pictureSaving.setVisibility(View.INVISIBLE);
//pictureSaving = (ProgressBar) findViewById(R.id.pictureSpinner);
//pictureSaving.setVisibility(View.INVISIBLE);
spot = "";
baseDir = new File(directory);
......@@ -505,7 +511,7 @@ public class SensorSampleActivity extends Activity {
public void savePhoto(Bitmap b, String pictureName){
try {
pictureSaving.setVisibility(View.VISIBLE);
//pictureSaving.setVisibility(View.VISIBLE);
File sd = Environment.getExternalStorageDirectory();
if (sd.canWrite()) {
File baseDir = new File(directory);
......@@ -541,7 +547,7 @@ public class SensorSampleActivity extends Activity {
t.setGravity(Gravity.CENTER, 0, 0);
t.show();
}
pictureSaving.setVisibility(View.INVISIBLE);
// pictureSaving.setVisibility(View.INVISIBLE);
} catch (IOException e) {
e.printStackTrace();
Log.e("SensorSampleActivity", "Error saving bitmap");
......
......@@ -184,12 +184,5 @@
android:onClick="takePicture"
android:text="Add Picture" />
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="48dip"
android:layout_height="48dip"
android:id="@+id/pictureSpinner"
android:progressDrawable="@drawable/circular_spinner"
android:layout_centerInParent="true" />
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment