Suppose I have an Activity with its layout and, using ButterKnife and the ViewHolder Pattern, I create a nested class in which I step the View root and inject the ButterKnife in it. The goal would be for example, instead of passing View by View to an auxiliary class, I passed the ViewHolder Pattern user class. Here is an example:
public class LoginActivity extends AppCompatActivity {
private ViewHolder viewHolder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
viewHolder = new ViewHolder(findViewById(R.id.layout_raiz));
// faz algumas tarefas que poderiam deixar o código
// da Activity sujo
new VerificarLogin(viewHolder);
}
static class ViewHolder {
@BindView(R.id.et1)
EditText email;
@BindView(R.id.et2)
EditText senha;
ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
}
The question is:
1) Would creating such a standard for Activity be a bad practice? Should this be used only when it was necessary to "recycle" Views?
2) Passing a ViewHolder as a parameter is a bad practice? (assuming that in the helper class I use all views within the ViewHolder)
3) Using this type of practice in Activity, and passing as a parameter (as in the example above), should I configure the viewHolder = null object when the Activity was destroyed?