Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
celestialphineas committed Dec 23, 2017
2 parents 28d9588 + 8cadd36 commit b3cd53d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public HabitViewHolder onCreateViewHolder(ViewGroup parent, int viewGroup) {
@Override
public void onBindViewHolder(final HabitViewHolder holder, final int position) {
final Habit habit_at_position=habitList.get(position);
habit_at_position.next_day();//renew deadline of the habit
holder.habitTitle.setText(habit_at_position.getTitle());
// Set the frequency (in the form of integer, see OperateHabitActivity for definition)
// Modify the habitFreq private variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public void onClick(View view) {
Snackbar.make(view, R.string.snack_one_item_finished, R.integer.undo_timeout)
.setAction(R.string.undo, redo)
.show();

// Lazy delete a database entry
task_at_position.setState(2);
//renew end time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class EditHabitActivity extends OperateHabitActivityBase {
private MyApplication myApplication;
private Habit habit;
private int position;
private int pos_habit_manager;//find the position in the manager
@BindView(R.id.habit_linear_layout) LinearLayoutCompat linearLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -46,7 +47,9 @@ protected void onCreate(Bundle savedInstanceState) {
position=intent.getIntExtra("position",-1);
habit=myApplication.get_habit_manager().getObjectList().get(position);
int count = 0;
pos_habit_manager=0;
for (Habit temp : myApplication.get_habit_manager().getObjectList()){// neglect the finished habit
pos_habit_manager++;
if (temp.getState()==2) continue;
else {
if (count==position){
Expand All @@ -56,6 +59,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

}
pos_habit_manager--;
// Change the lines below to synchronize data of the view and that of the model
// You may modify the lines below to set the activity's UI state
// Title
Expand Down Expand Up @@ -100,7 +104,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
habit.edit_habit(inputTitle.getText().toString(),"2020-01-01 18:21:00",
descriptionContent.getText().toString(),selectedImportance,selectedFreq);
Intent intent = new Intent();
intent.putExtra("position",position);
intent.putExtra("position",pos_habit_manager);
intent.putExtra("ID",habit.ID);
setResult(RESULT_OK, intent);
animationSubmit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class EditTaskActivity extends OperateTaskActivityBase {
private MyApplication myApplication;
private Task task;
private int position;
private int pos_task_manager;
@BindView(R.id.task_linear_layout) LinearLayoutCompat linearLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -30,7 +31,9 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent=getIntent();
position=intent.getIntExtra("position",-1);
int count = 0;
pos_task_manager=0;
for (Task temp : myApplication.get_task_manager().getObjectList()){// neglect the finished task
pos_task_manager++;//find the position in the manager
if (temp.getState()==2) continue;
else {
if (count==position){
Expand All @@ -39,7 +42,10 @@ protected void onCreate(Bundle savedInstanceState) {
count++;
}


}
pos_task_manager--;


// Change the lines below to synchronize data of the view and that of the model
// You may modify the lines below to set the activity's UI state
Expand Down Expand Up @@ -91,7 +97,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
,descriptionContent.getText().toString(),selectedImportance);

Intent intent = new Intent();
intent.putExtra("position",position);
intent.putExtra("position",pos_task_manager);
intent.putExtra("ID",task.ID);
setResult(RESULT_OK, intent);
animationSubmit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class EditTimeLeftActivity extends OperateTimeLeftActivityBase {
private MyApplication myApplication;
private TimeLeft timeLeft;
private int position;
private int pos_timeleft_manager;
@BindView(R.id.time_left_linear_layout) LinearLayoutCompat linearLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -51,7 +52,9 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent=getIntent();
position=intent.getIntExtra("position",-1);
int count = 0;
pos_timeleft_manager=0;
for (TimeLeft temp : myApplication.get_time_left_manager().getObjectList()){// neglect the finished time left item
pos_timeleft_manager++;//find the position in the manager
if (temp.getState()==2) continue;
else {
if (count==position){
Expand All @@ -61,6 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

}
pos_timeleft_manager--;
timeLeft=myApplication.get_time_left_manager().getObjectList().get(position);

// Change the lines below to synchronize data of the view and that of the model
Expand Down Expand Up @@ -126,7 +130,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
sdf.format(dueCalendar.getTime()).substring(0,16).concat(":00"),descriptionContent.getText().toString(),
selectedImportance);
Intent intent = new Intent();
intent.putExtra("position",position);
intent.putExtra("position",pos_timeleft_manager);
intent.putExtra("ID",timeLeft.ID);
setResult(RESULT_OK, intent);
animationSubmit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void onClick(View v) {
// Constructor: Type, Time Calendar, Description

for (Task task:mTaskManager.getObjectList()){
if (task.getState()==2){//task is finished ,no show
if (task.getState()==2||task.getState()==0){//task is finished or deleted ,no show
continue;
}
long millionSeconds = 0;
Expand All @@ -123,7 +123,7 @@ public void onClick(View v) {
else timelineItems.add(new TimelineItem(TASK,ca,task.getTitle()));
}
for (Habit habit:mHabitManager.getObjectList()){
if (habit.getState()==2){//task is finished ,no show
if (habit.getState()==2||habit.getState()==0){//task is finished or deleted ,no show
continue;
}
long millionSeconds = 0;
Expand All @@ -135,7 +135,7 @@ public void onClick(View v) {
timelineItems.add(new TimelineItem(HABIT,ca,habit.getTitle()));
}
for (TimeLeft timeLeft:mTimeLeftManager.getObjectList()){
if (timeLeft.getState()==2){//task is finished ,no show
if (timeLeft.getState()==2||timeLeft.getState()==0){//task is finished or deleted ,no show
continue;
}
long millionSeconds = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void deleteRecord()
}

//到了ddl,就保存当前阶段打卡,进入下一次打卡
private void next_day()
public void next_day()
{
LocalDateTime now=LocalDateTime.now();
while (!now.isBefore(nextddl))//更新总需要
Expand Down

0 comments on commit b3cd53d

Please # to comment.