diff --git a/sample_app/res/layout/activity_main.xml b/sample_app/res/layout/activity_main.xml index e9f5fb4..49847ae 100644 --- a/sample_app/res/layout/activity_main.xml +++ b/sample_app/res/layout/activity_main.xml @@ -13,8 +13,8 @@ android:id="@+id/gridLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:paddingBottom="@dimen/activity_vertical_margin" - android:columnCount="2" > + android:columnCount="2" + android:paddingBottom="@dimen/activity_vertical_margin" > - - - \ No newline at end of file diff --git a/sample_app/res/values/colors.xml b/sample_app/res/values/colors.xml index 9e35dd2..b8f6e52 100644 --- a/sample_app/res/values/colors.xml +++ b/sample_app/res/values/colors.xml @@ -1,3 +1,3 @@ - #e0e0e0 + #66e0e0e0 diff --git a/sample_app/src/uk/co/alt236/btlescan/activities/MainActivity.java b/sample_app/src/uk/co/alt236/btlescan/activities/MainActivity.java index 29bb119..407ab2d 100644 --- a/sample_app/src/uk/co/alt236/btlescan/activities/MainActivity.java +++ b/sample_app/src/uk/co/alt236/btlescan/activities/MainActivity.java @@ -6,7 +6,6 @@ import uk.co.alt236.btlescan.adapters.LeDeviceListAdapter; import uk.co.alt236.btlescan.containers.BluetoothLeDeviceStore; import uk.co.alt236.btlescan.util.BluetoothLeScanner; import uk.co.alt236.btlescan.util.BluetoothUtils; -import uk.co.alt236.btlescan.views.RadarView; import android.app.ListActivity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; @@ -23,7 +22,6 @@ import butterknife.InjectView; public class MainActivity extends ListActivity { @InjectView(R.id.tvBluetoothLe) TextView mTvBluetoothLeStatus; @InjectView(R.id.tvBluetoothStatus) TextView mTvBluetoothStatus; - @InjectView(R.id.radarView) RadarView mRadarView; private BluetoothUtils mBluetoothUtils; private BluetoothLeScanner mScanner; @@ -40,9 +38,7 @@ public class MainActivity extends ListActivity { @Override public void run() { mDeviceStore.addDevice(deviceLe); - mLeDeviceListAdapter.clear(); - mLeDeviceListAdapter.addAll(mDeviceStore.getDeviceList()); - mLeDeviceListAdapter.notifyDataSetChanged(); + mLeDeviceListAdapter.replaceData(mDeviceStore.getDeviceList()); } }); } diff --git a/sample_app/src/uk/co/alt236/btlescan/adapters/LeDeviceListAdapter.java b/sample_app/src/uk/co/alt236/btlescan/adapters/LeDeviceListAdapter.java index 4dbc5cd..c5dc057 100644 --- a/sample_app/src/uk/co/alt236/btlescan/adapters/LeDeviceListAdapter.java +++ b/sample_app/src/uk/co/alt236/btlescan/adapters/LeDeviceListAdapter.java @@ -34,6 +34,11 @@ public class LeDeviceListAdapter extends ArrayAdapter { // } // } + public void replaceData(List list){ + clear(); + addAll(list); + } + @Override public long getItemId(int i) { return i; diff --git a/sample_app/src/uk/co/alt236/btlescan/views/RadarView.java b/sample_app/src/uk/co/alt236/btlescan/views/RadarView.java deleted file mode 100644 index 8bde7a3..0000000 --- a/sample_app/src/uk/co/alt236/btlescan/views/RadarView.java +++ /dev/null @@ -1,87 +0,0 @@ -package uk.co.alt236.btlescan.views; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Paint.Style; -import android.util.AttributeSet; -import android.util.Log; -import android.view.View; - -public class RadarView extends View{ - private Paint mRadarBackgroundPaint; - private Paint mViewBackgroundPaint; - private int mWidth; - private int mHeight; - - public RadarView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(); - } - - private void init() { - mRadarBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - mRadarBackgroundPaint.setColor(0xff101010); - mRadarBackgroundPaint.setStyle(Style.FILL); - - mViewBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - mViewBackgroundPaint.setColor(Color.BLACK); - mViewBackgroundPaint.setStyle(Style.FILL); - } - - public RadarView(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - public RadarView(Context context) { - super(context); - init(); - } - - - private int getSmallestDimension(){ - if(mWidth > mHeight){ - return mHeight; - } else { - return mWidth; - } - } - - @Override - public void onSizeChanged (int w, int h, int oldw, int oldh){ - super.onSizeChanged(w, h, oldw, oldh); - mWidth = w; - mHeight = h; - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - Log.d("TAG", "~ ONDRAW!"); - - Log.d("TAG", "~ getLeft! " + getLeft()); - Log.d("TAG", "~ getTop! " + getTop()); - Log.d("TAG", "~ getRight! " + getRight()); - Log.d("TAG", "~ getBottom! " + getBottom()); - Log.d("TAG", "~ width! " + mWidth); - Log.d("TAG", "~ height! " + mHeight); - - final int smallestDim = getSmallestDimension(); - - - canvas.drawRect( - getLeft(), - getTop(), - getRight(), - getBottom(), - mViewBackgroundPaint); - - canvas.drawCircle( - getLeft() + (mWidth / 2f), - getTop() + (mHeight / 2f), - smallestDim / 2f, - mRadarBackgroundPaint); - } -}