I use Eclipse for Android development, and I already set up my code formatting style, but still have anonymous methods that I could not figure out how to format in Eclipse. Here's how Eclipse now formats anonymous methods:
// The BroadcastReceiver that listens for discovered devices and // changes the title when discovery is finished private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Utils.Log.i("BLUETOOTH: " + action); if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the // BluetoothDevice // object from the // Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); // If it already // paired, skip it, // because it been // listed already if (device.getBondState() != BluetoothDevice.BOND_BONDED) { if (mNewDevicesArrayAdapter.getCount() == 0) { mNewDevicesArrayAdapter.add(device); } btDevicesUpdateList.add(device); } } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) { mNewDevicesArrayAdapter.setItems(btDevicesUpdateList); mNewDevicesArrayAdapter.notifyDataSetChanged(); btDevicesUpdateList.clear(); mBtAdapter.startDiscovery(); } else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { if (mBtAdapter.getState() == BluetoothAdapter.STATE_ON) { switchToView(viewBluetoothOn); firstTimeDiscover(); } else if (mBtAdapter.getState() == BluetoothAdapter.STATE_OFF) { switchToView(viewBluetoothOff); } } } };
Cm? This is very trashy. What is the correct option for formatting an anonymous method declaration so that it stays on the left side and does not fall under the =
equal symbol?
source share