I have the following class hierarchy:
BaseActivity:
public abstract class BaseActivity extends AppCompatActivity {
protected abstract void bindView();
}
ASubActivity:
public class ASubActivity extends BaseActivity {
@Override
protected void bindView() {
//No implementation
}
}
BSubActivity:
public class BSubActivity extends BaseActivity {
private Toolbar toolbar;
@Override
protected void bindView() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
}
...
}
I find this to be a bit ugly. I would rather just not have the bindView() method in the ASubActivity. Is there a best practice way to do this?
NOTE: the BaseActity does contain some other abstract methods that are used by both subclasses.
One way would be to put
bindView()in an interface instead ofBaseActivityand have onlyBSubActivityimplement that interface:Then there would be no need to have
bindView()BSubActivity.Another way would be to not make
bindView()an abstract method: