The video also show how to enable 3D Acceleration in VirtualBox. (Please note: In my experience of using Ubuntu on VirtualBox/Windows 10, sometimes will have problem when 3D Acceleration enabled.)
Think Java: How to Think Like a Computer Scientist Currently used at many colleges, universities, and high schools, this hands-on introduction to computer science is ideal for people with little or no programming experience. The goal of this concise book is not just to teach you Java, but to help you think like a computer scientist. You�ll learn how to program�a useful skill by itself�but you�ll also discover how to use programming as a means to an end.
Authors Allen Downey and Chris Mayfield start with the most basic concepts and gradually move into topics that are more complex, such as recursion and object-oriented programming. Each brief chapter covers the material for one week of a college course and includes exercises to help you practice what you�ve learned.
Learn one concept at a time: tackle complex topics in a series of small steps with examples
Understand how to formulate problems, think creatively about solutions, and write programs clearly and accurately
Determine which development techniques work best for you, and practice the important skill of debugging
Learn relationships among input and output, decisions and loops, classes and methods, strings and arrays
Work on exercises involving word games, graphics, puzzles, and playing cards
In lasp example of BottomSheet, I implement a OnClickListener of background to expand and collapse the bottom sheet. Without this, user cannot expand the bottom sheet if collapsed, because bottom sheet have height of 0 by default. If you want you can set the height of collapsed bottom sheet, by calling setPeekHeight() method.
/* Build.VERSION.SDK_INT: The user-visible SDK version of the framework; its possible values are defined in Build.VERSION_CODES. https://developer.android.com/reference/android/os/Build.VERSION_CODES.html */ int sdk_int = Build.VERSION.SDK_INT;
/* backgroundLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (bottomSheetBehavior.getState()){ case BottomSheetBehavior.STATE_COLLAPSED: bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); break; case BottomSheetBehavior.STATE_EXPANDED: bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); break; } } }); */ }
BottomSheetBehavior.BottomSheetCallback bottomSheetCallback = new BottomSheetBehavior.BottomSheetCallback(){ @Override public void onStateChanged(@NonNull View bottomSheet, int newState) { switch (newState){ case BottomSheetBehavior.STATE_COLLAPSED: textPrompt.setText("COLLAPSED"); break; case BottomSheetBehavior.STATE_DRAGGING: textPrompt.setText("DRAGGING"); break; case BottomSheetBehavior.STATE_EXPANDED: textPrompt.setText("EXPANDED"); break; case BottomSheetBehavior.STATE_HIDDEN: textPrompt.setText("HIDDEN"); break; case BottomSheetBehavior.STATE_SETTLING: textPrompt.setText("SETTLING"); break; default: textPrompt.setText("unknown..."); } }
@Override public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// Check if BLE is supported on the device. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, "BLUETOOTH_LE not supported in this device!", Toast.LENGTH_SHORT).show(); finish(); }
getBluetoothAdapterAndLeScanner();
// Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, "bluetoothManager.getAdapter()==null", Toast.LENGTH_SHORT).show(); finish(); return; }
listBluetoothDevice = new ArrayList<>(); adapterLeScanResult = new ArrayAdapter<BluetoothDevice>( this, android.R.layout.simple_list_item_1, listBluetoothDevice); listViewLE.setAdapter(adapterLeScanResult); listViewLE.setOnItemClickListener(scanResultOnItemClickListener);
mHandler = new Handler();
}
AdapterView.OnItemClickListener scanResultOnItemClickListener = new AdapterView.OnItemClickListener(){
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final BluetoothDevice device = (BluetoothDevice) parent.getItemAtPosition(position);
new AlertDialog.Builder(MainActivity.this) .setTitle(device.getName()) .setMessage(msg) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {
} }) .show();
} };
private String getBTDevieType(BluetoothDevice d){ String type = "";
switch (d.getType()){ case BluetoothDevice.DEVICE_TYPE_CLASSIC: type = "DEVICE_TYPE_CLASSIC"; break; case BluetoothDevice.DEVICE_TYPE_DUAL: type = "DEVICE_TYPE_DUAL"; break; case BluetoothDevice.DEVICE_TYPE_LE: type = "DEVICE_TYPE_LE"; break; case BluetoothDevice.DEVICE_TYPE_UNKNOWN: type = "DEVICE_TYPE_UNKNOWN"; break; default: type = "unknown..."; }
// Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, "bluetoothManager.getAdapter()==null", Toast.LENGTH_SHORT).show(); finish(); return; }
private void getBluetoothAdapterAndLeScanner(){ // Get BluetoothAdapter and BluetoothLeScanner. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
mScanning = false; }
/* to call startScan (ScanCallback callback), Requires BLUETOOTH_ADMIN permission. Must hold ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get results. */ private void scanLeDevice(final boolean enable) { if (enable) { listBluetoothDevice.clear(); listViewLE.invalidateViews();
// Stops scanning after a pre-defined scan period. mHandler.postDelayed(new Runnable() { @Override public void run() { mBluetoothLeScanner.stopScan(scanCallback); listViewLE.invalidateViews();
//scan specified devices only with ScanFilter ScanFilter scanFilter = new ScanFilter.Builder() .setServiceUuid(BluetoothLeService.ParcelUuid_GENUINO101_ledService) .build(); List<ScanFilter> scanFilters = new ArrayList<ScanFilter>(); scanFilters.add(scanFilter);
ScanSettings scanSettings = new ScanSettings.Builder().build();