2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 06:05:12 +00:00

Fix lint warning: Avoid non-default constructors in fragments

Summary: It is common practice to use a static newInstance to create new fragment instances instead of using non-default constructors

Reviewers: #kde_connect, nicolasfella

Reviewed By: #kde_connect, nicolasfella

Subscribers: kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D17390
This commit is contained in:
Erik Duisters
2018-12-06 19:09:47 +01:00
parent 6e8d9e8419
commit 96a1edfb76
2 changed files with 7 additions and 3 deletions

View File

@@ -73,11 +73,15 @@ public class DeviceFragment extends Fragment {
public DeviceFragment() {
}
public DeviceFragment(String deviceId, boolean fromDeviceList) {
public static DeviceFragment newInstance(String deviceId, boolean fromDeviceList) {
DeviceFragment frag = new DeviceFragment();
Bundle args = new Bundle();
args.putString(ARG_DEVICE_ID, deviceId);
args.putBoolean(ARG_FROM_DEVICE_LIST, fromDeviceList);
this.setArguments(args);
frag.setArguments(args);
return frag;
}
@Override

View File

@@ -295,7 +295,7 @@ public class MainActivity extends AppCompatActivity {
} else {
mNavigationView.setCheckedItem(mCurrentMenuEntry);
}
setContentFragment(new DeviceFragment(deviceId, fromDeviceList));
setContentFragment(DeviceFragment.newInstance(deviceId, fromDeviceList));
} else {
mCurrentMenuEntry = MENU_ENTRY_ADD_DEVICE;
mNavigationView.setCheckedItem(mCurrentMenuEntry);