View injection with Butterknife

This commit is contained in:
Paul Hawke 2017-09-27 21:53:00 -05:00
parent 9aa021695b
commit b305acd395

View file

@ -18,6 +18,8 @@ import android.widget.Toast;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import dagger.android.AndroidInjection; import dagger.android.AndroidInjection;
import fr.free.nrw.commons.BuildConfig; import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.PageTitle; import fr.free.nrw.commons.PageTitle;
@ -41,10 +43,12 @@ public class LoginActivity extends AccountAuthenticatorActivity {
@Inject @Named("application_preferences") SharedPreferences prefs = null; @Inject @Named("application_preferences") SharedPreferences prefs = null;
@Inject @Named("default_preferences") SharedPreferences defaultPrefs; @Inject @Named("default_preferences") SharedPreferences defaultPrefs;
private Button loginButton; @BindView(R.id.loginButton) Button loginButton;
private EditText usernameEdit; @BindView(R.id.signupButton) Button signupButton;
private EditText passwordEdit; @BindView(R.id.loginUsername) EditText usernameEdit;
private EditText twoFactorEdit; @BindView(R.id.loginPassword) EditText passwordEdit;
@BindView(R.id.loginTwoFactor) EditText twoFactorEdit;
ProgressDialog progressDialog; ProgressDialog progressDialog;
private LoginTextWatcher textWatcher = new LoginTextWatcher(); private LoginTextWatcher textWatcher = new LoginTextWatcher();
@ -54,12 +58,7 @@ public class LoginActivity extends AccountAuthenticatorActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
ButterKnife.bind(this);
loginButton = (Button) findViewById(R.id.loginButton);
Button signupButton = (Button) findViewById(R.id.signupButton);
usernameEdit = (EditText) findViewById(R.id.loginUsername);
passwordEdit = (EditText) findViewById(R.id.loginPassword);
twoFactorEdit = (EditText) findViewById(R.id.loginTwoFactor);
usernameEdit.addTextChangedListener(textWatcher); usernameEdit.addTextChangedListener(textWatcher);
passwordEdit.addTextChangedListener(textWatcher); passwordEdit.addTextChangedListener(textWatcher);