Source:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_network, container,false); this.addMembersButton = (LinearLayout)v.findViewById(R.id.add_members); this.addMembersButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { new WithBluetoothEnabled(getActivity(), getConnectionService()).run(new Runnable() { @Override public void run() { setButtonToSearchingState(addMembersButton); isSearchingAdd = true; getConnectionService().findNewGuests(); tracker.trackAddMembersEvent(); } }); } else { Toaster.iToast(getActivity(), R.string.no_bt_support); } } }); disconnectDisband = (LinearLayout)v.findViewById(R.id.disconnect_disband_btn); userView = (LinearLayout) v.findViewById(R.id.connected_users); updateUserView(); setDisconnectDisbandBtn(); this.joinDifferentNetworkButton = (LinearLayout)v.findViewById(R.id.join_different_network_btn); joinDifferentNetworkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new WithBluetoothEnabled(getActivity(), getConnectionService()).run(new Runnable() { @Override public void run() { getConnectionService().broadcastSelfAsGuest(getActivity()); } }); } }); if(savedInstanceState != null){ isSearchingAdd = savedInstanceState.getBoolean("isSearchingAdd"); isSearchingJoinDifferent = savedInstanceState.getBoolean("isSearchingJoinDifferent"); if(isSearchingAdd) setButtonToSearchingState(addMembersButton); if(isSearchingJoinDifferent) setButtonToSearchingState(joinDifferentNetworkButton); } return v; }

Target:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_network, container,false); this.addMembersButton = (LinearLayout)v.findViewById(R.id.add_members); this.addMembersButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { new WithBluetoothEnabled(getActivity(), getConnectionService()).run(new Runnable() { @Override public void run() { setButtonToSearchingState(addMembersButton); isSearchingAdd = true; getConnectionService().findNewGuests(); tracker.trackAddMembersEvent(); } }); } else { Toaster.iToast(getActivity(), R.string.no_bt_support); } } }); disconnectDisband = (LinearLayout)v.findViewById(R.id.disconnect_disband_btn); userView = (LinearLayout) v.findViewById(R.id.connected_users); updateUserView(); setDisconnectDisbandBtn(); this.joinDifferentNetworkButton = (LinearLayout)v.findViewById(R.id.join_different_network_btn); joinDifferentNetworkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new WithBluetoothEnabled(getActivity(), getConnectionService()).run(new Runnable() { @Override public void run() { getConnectionService().broadcastSelfAsGuest(getActivity()); } }); } }); if(savedInstanceState != null){ isSearchingAdd = savedInstanceState.getBoolean(SEARCHING_ADD_TAG); isSearchingJoinDifferent = savedInstanceState.getBoolean(SEARCHING_JOIN__DIFFERENT_TAG); if(isSearchingAdd) setButtonToSearchingState(addMembersButton); if(isSearchingJoinDifferent) setButtonToSearchingState(joinDifferentNetworkButton); } return v; }