Skip to content

Commit

Permalink
#331: Step template view refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
malsolec committed Aug 11, 2018
1 parent dc88215 commit a764894
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class StepTemplate {

private Long soundId;

private Integer durationTime;

@ToOne(joinProperty = "taskTemplateId")
private TaskTemplate taskTemplate;

Expand All @@ -51,13 +53,15 @@ public class StepTemplate {
@Generated(hash = 1320587426)
private transient StepTemplateDao myDao;

@Generated(hash = 439029214)
public StepTemplate(Long id, String name, int order, Long pictureId, Long soundId, long taskTemplateId) {
@Generated(hash = 672659171)
public StepTemplate(Long id, String name, int order, Long pictureId, Long soundId, Integer durationTime,
long taskTemplateId) {
this.id = id;
this.name = name;
this.order = order;
this.pictureId = pictureId;
this.soundId = soundId;
this.durationTime = durationTime;
this.taskTemplateId = taskTemplateId;
}

Expand Down Expand Up @@ -114,6 +118,14 @@ public void setSoundId(Long soundId) {
this.soundId = soundId;
}

public Integer getDurationTime() {
return this.durationTime;
}

public void setDurationTime(Integer durationTime) {
this.durationTime = durationTime;
}

@Generated(hash = 309141312)
private transient Long taskTemplate__resolvedKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,36 @@ public StepTemplateRepository(DaoSession daoSession) {
this.daoSession = daoSession;
}

public long create(String name, int order, Long pictureId, Long soundId, Long taskTemplateId) {
public long create(String name, int order, Long pictureId, Long soundId, Long taskTemplateId, Integer stepDuration) {
StepTemplate stepTemplate = new StepTemplate();
stepTemplate.setName(name);
stepTemplate.setOrder(order);
stepTemplate.setSoundId(soundId);
stepTemplate.setPictureId(pictureId);
stepTemplate.setTaskTemplateId(taskTemplateId);
stepTemplate.setDurationTime(stepDuration);

return daoSession.getStepTemplateDao().insert(stepTemplate);
}

public void update(Long stepId, String name, int order, Long pictureId, Long soundId, Long taskTemplateId) {
public long create(StepTemplate stepTemplate) {
return daoSession.getStepTemplateDao().insert(stepTemplate);
}

public void update(Long stepId, String name, int order, Long pictureId, Long soundId, Long taskTemplateId, Integer stepDuration) {
StepTemplate stepTemplate = new StepTemplate();
stepTemplate.setId(stepId);
stepTemplate.setName(name);
stepTemplate.setOrder(order);
stepTemplate.setSoundId(soundId);
stepTemplate.setPictureId(pictureId);
stepTemplate.setTaskTemplateId(taskTemplateId);
stepTemplate.setDurationTime(stepDuration);

daoSession.getStepTemplateDao().update(stepTemplate);
}

public void update(StepTemplate stepTemplate) {
daoSession.getStepTemplateDao().update(stepTemplate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public final class SoundComponent {
@Inject
AssetsHelper assetsHelper;


private Long soundId;
private ImageButton playSoundIcon;
private Context context;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//package pg.autyzm.friendly_plans.manager_app.view.step_create;
//
//public class PictureManager {
//
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//package pg.autyzm.friendly_plans.manager_app.view.step_create;
//
//import android.content.Context;
//import android.view.View;
//import android.widget.EditText;
//import android.widget.ImageButton;
//import pg.autyzm.friendly_plans.manager_app.view.components.SoundComponent;
//
//public class SoudManager {
// private final EditText soundFileName;
// private final ImageButton clearSound;
//
// private Long soundId;
// private SoundComponent soundComponent;
//
//
// public SoudManager(EditText soundFileName,
// ImageButton clearSound,
// ImageButton playSoundIcon,
// Context applicationContext) {
// this.soundFileName = soundFileName;
// this.clearSound = clearSound;
//
// soundComponent = SoundComponent.getSoundComponent(
// soundId, playSoundIcon, applicationContext, appComponent);
// }
//
// protected void clearSound() {
// soundFileName.setText("");
// soundId = null;
// clearSound.setVisibility(View.INVISIBLE);
// soundComponent.setSoundId(null);
// soundComponent.stopActions();
// }
//
//}
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,92 @@

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import database.entities.Asset;
import database.entities.StepTemplate;
import pg.autyzm.friendly_plans.BR;

public class StepCreateData extends BaseObservable {

private String stepName;
private String pictureName;
private String soundName;
private static final String REGEX_TRIM_NAME = "_([\\d]*)(?=\\.)";
private static final String EMPTY_VALUE = "";

public StepCreateData(String stepName, String pictureName, String soundName) {
this.stepName = stepName;
this.pictureName = pictureName;
this.soundName = soundName;
private StepTemplate stepTemplate = new StepTemplate();
private Long taskId;

public StepCreateData(Long taskId) {
this.taskId = taskId;
}

public Long getTaskId() {
return taskId;
}

@Bindable
public String getStepName() {
return stepName;
return stepTemplate.getName();
}

public void setStepName(String stepName) {
this.stepName = stepName;
this.stepTemplate.setName(stepName);
notifyPropertyChanged(BR.stepName);
}

@Bindable
public String getPictureName() {
return pictureName;
return getAssetFileName(stepTemplate.getPicture());
}

public void setPictureName(String pictureName) {
this.pictureName = pictureName;
this.stepTemplate.setPicture(getAsset(pictureName, this.stepTemplate.getPicture()));
notifyPropertyChanged(BR.pictureName);
}

@Bindable
public String getSoundName() {
return soundName;
return getAssetFileName(stepTemplate.getSound());
}

public void setSoundName(String soundName) {
this.soundName = soundName;
this.stepTemplate.setSound(getAsset(soundName, this.stepTemplate.getSound()));
notifyPropertyChanged(BR.soundName);
}

@Bindable
public String getStepDuration() {
return stepTemplate.getDurationTime().toString();
}

public void setStepDuration(String stepDuration) {
this.stepTemplate.setDurationTime(Integer.valueOf(stepDuration));
notifyPropertyChanged(BR.stepDuration);
}

public StepTemplate getStepTemplate() {
return stepTemplate;
}

public void setStepTemplate(StepTemplate stepTemplate) {
this.stepTemplate = stepTemplate;
}

private Asset getAsset(String fileName, Asset asset) {
if (fileName == null) {
return null;
}

if (asset == null) {
asset = new Asset();
}
asset.setFilename(fileName);

return asset;
}

private String getAssetFileName(Asset asset) {
if (asset == null) {
return EMPTY_VALUE;
}

return asset.getFilename().replace(REGEX_TRIM_NAME, "");
}
}
Loading

0 comments on commit a764894

Please sign in to comment.