Simplify all command and convert them to Kotlin

This commit is contained in:
2020-12-26 22:22:04 -06:00
parent 373f21e247
commit 0a5622c78e
24 changed files with 193 additions and 408 deletions

View File

@@ -54,7 +54,7 @@ public class PerformanceTest extends BaseAndroidTest
for (int i = 0; i < 1_000; i++)
{
Habit model = modelFactory.buildHabit();
new CreateHabitCommand(modelFactory, habitList, model).execute();
new CreateHabitCommand(modelFactory, habitList, model).run();
}
db.setTransactionSuccessful();
db.endTransaction();
@@ -70,7 +70,7 @@ public class PerformanceTest extends BaseAndroidTest
for (int i = 0; i < 5_000; i++)
{
Timestamp timestamp = new Timestamp(i * DAY_LENGTH);
new CreateRepetitionCommand(habitList, habit, timestamp, 1).execute();
new CreateRepetitionCommand(habitList, habit, timestamp, 1).run();
}
db.setTransactionSuccessful();
db.endTransaction();

View File

@@ -19,6 +19,7 @@
package org.isoron.uhabits.activities.habits.edit
import android.annotation.*
import android.content.res.*
import android.graphics.*
import android.os.*
@@ -224,9 +225,15 @@ class EditHabitActivity : AppCompatActivity() {
habit.type = habitType
val command = if (habitId >= 0) {
component.editHabitCommandFactory.create(component.habitList, original, habit)
EditHabitCommand(
component.habitList,
habitId,
habit)
} else {
component.createHabitCommandFactory.create(component.habitList, habit)
CreateHabitCommand(
component.modelFactory,
component.habitList,
habit)
}
component.commandRunner.run(command)
finish()
@@ -265,6 +272,7 @@ class EditHabitActivity : AppCompatActivity() {
}
}
@SuppressLint("StringFormatMatches")
private fun populateFrequency() {
binding.booleanFrequencyPicker.text = when {
freqNum == 1 && freqDen == 1 -> getString(R.string.every_day)

View File

@@ -52,10 +52,6 @@ public interface HabitsApplicationComponent
@AppContext
Context getContext();
CreateHabitCommandFactory getCreateHabitCommandFactory();
EditHabitCommandFactory getEditHabitCommandFactory();
GenericImporter getGenericImporter();
HabitCardListCache getHabitCardListCache();