Commit 9f498f81 authored by Erik Duisters's avatar Erik Duisters

Use butterknife for view binding

Summary: Use butterknife for view binding

Reviewers: #kde_connect, nicolasfella

Reviewed By: #kde_connect, nicolasfella

Subscribers: nicolasfella, kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D17411
parent 4158956d
......@@ -80,6 +80,9 @@ dependencies {
implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0' //For SSL certificate generation
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
// Testing
androidTestImplementation 'org.mockito:mockito-core:1.10.19'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.1'// Because mockito has some problems with dex environment
......
......@@ -34,6 +34,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MainActivity extends AppCompatActivity {
private static final int MENU_ENTRY_ADD_DEVICE = 1; //0 means no-selection
......@@ -50,8 +53,10 @@ public class MainActivity extends AppCompatActivity {
public static final String PAIRING_ACCEPTED = "accepted";
public static final String PAIRING_REJECTED = "rejected";
private NavigationView mNavigationView;
private DrawerLayout mDrawerLayout;
@BindView(R.id.navigation_drawer) NavigationView mNavigationView;
@BindView(R.id.drawer_layout) DrawerLayout mDrawerLayout;
@BindView(R.id.toolbar) Toolbar mToolbar;
TextView mNavViewDeviceName;
private String mCurrentDevice;
private int mCurrentMenuEntry;
......@@ -69,12 +74,13 @@ public class MainActivity extends AppCompatActivity {
ThemeUtil.setUserPreferredTheme(this);
setContentView(R.layout.activity_main);
mDrawerLayout = findViewById(R.id.drawer_layout);
mNavigationView = findViewById(R.id.navigation_drawer);
ButterKnife.bind(this);
View mDrawerHeader = mNavigationView.getHeaderView(0);
mNavViewDeviceName = mDrawerHeader.findViewById(R.id.device_name);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
......@@ -386,7 +392,6 @@ public class MainActivity extends AppCompatActivity {
}
private void updateDeviceNameFromMenu(String newDeviceName) {
final TextView nameView = mNavigationView.findViewById(R.id.device_name);
nameView.setText(newDeviceName);
mNavViewDeviceName.setText(newDeviceName);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment