Change factory method signature

This commit is contained in:
Phillip Hsu 2016-08-30 18:50:17 -07:00
parent d1f3fae2c3
commit 1a9471d3c7
2 changed files with 9 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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");