mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Simplify all command and convert them to Kotlin
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -52,10 +52,6 @@ public interface HabitsApplicationComponent
|
||||
@AppContext
|
||||
Context getContext();
|
||||
|
||||
CreateHabitCommandFactory getCreateHabitCommandFactory();
|
||||
|
||||
EditHabitCommandFactory getEditHabitCommandFactory();
|
||||
|
||||
GenericImporter getGenericImporter();
|
||||
|
||||
HabitCardListCache getHabitCardListCache();
|
||||
|
||||
Reference in New Issue
Block a user