Change factory method signature
This commit is contained in:
parent
d1f3fae2c3
commit
1a9471d3c7
@ -28,8 +28,9 @@ public class AddLabelDialog extends AppCompatDialogFragment {
|
||||
/**
|
||||
* @param text the initial text
|
||||
*/
|
||||
public static AddLabelDialog newInstance(CharSequence text) {
|
||||
public static AddLabelDialog newInstance(OnLabelSetListener l, CharSequence text) {
|
||||
AddLabelDialog dialog = new AddLabelDialog();
|
||||
dialog.mOnLabelSetListener = l;
|
||||
dialog.mInitialText = text;
|
||||
return dialog;
|
||||
}
|
||||
@ -61,8 +62,4 @@ public class AddLabelDialog extends AppCompatDialogFragment {
|
||||
})
|
||||
.create();
|
||||
}
|
||||
|
||||
public void setOnLabelSetListener(OnLabelSetListener onLabelSetListener) {
|
||||
mOnLabelSetListener = onLabelSetListener;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,13 @@ public class TimerViewHolder extends BaseViewHolder<Timer> {
|
||||
|
||||
@OnClick(R.id.label)
|
||||
void openLabelEditor() {
|
||||
AddLabelDialog dialog = AddLabelDialog.newInstance(mLabel.getText());
|
||||
AddLabelDialog dialog = AddLabelDialog.newInstance(new AddLabelDialog.OnLabelSetListener() {
|
||||
@Override
|
||||
public void onLabelSet(CharSequence label) {
|
||||
mLabel.setText(label);
|
||||
// TODO: persist change. Use TimerController and its update()
|
||||
}
|
||||
}, mLabel.getText());
|
||||
// TODO: This is bad! Use a Controller instead!
|
||||
AppCompatActivity act = (AppCompatActivity) getContext();
|
||||
dialog.show(act.getSupportFragmentManager(), "TAG");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user