mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
add more usecases / extract them from MainActivity
This commit is contained in:
parent
6106bb2fa3
commit
cb7395bc4f
8 changed files with 249 additions and 58 deletions
|
|
@ -15,5 +15,6 @@ public interface TaskRepository extends BaseRepository {
|
|||
|
||||
Observable<TaskList> refreshTasks(TasksOrder tasksOrder);
|
||||
|
||||
Observable<TaskDirectionData> scoreHabit(Task task, boolean up);
|
||||
Observable<TaskDirectionData> taskChecked(Task task, boolean up);
|
||||
Observable<Task> scoreChecklistItem(String taskId, String itemId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class TaskRepositoryImpl extends BaseRepositoryImpl<TaskLocalRepository>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Observable<TaskDirectionData> scoreHabit(Task task, boolean up) {
|
||||
public Observable<TaskDirectionData> taskChecked(Task task, boolean up) {
|
||||
return this.apiClient.postTaskDirection(task.getId(), (up ? TaskDirection.up : TaskDirection.down).toString())
|
||||
.doOnNext(res -> {
|
||||
// save local task changes
|
||||
|
|
@ -43,4 +43,10 @@ public class TaskRepositoryImpl extends BaseRepositoryImpl<TaskLocalRepository>
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Observable<Task> scoreChecklistItem(String taskId, String itemId){
|
||||
return apiClient.scoreChecklistItem(taskId, itemId).doOnNext(res -> {
|
||||
this.localRepository.saveTask(res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.habitrpg.android.habitica.interactors;
|
||||
|
||||
import com.habitrpg.android.habitica.data.TaskRepository;
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread;
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor;
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
public class BuyRewardUseCase extends UseCase<BuyRewardUseCase.RequestValues, TaskDirectionData> {
|
||||
|
||||
private TaskRepository taskRepository;
|
||||
private SoundManager soundManager;
|
||||
|
||||
@Inject
|
||||
public BuyRewardUseCase(TaskRepository taskRepository, SoundManager soundManager,
|
||||
ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
|
||||
super(threadExecutor, postExecutionThread);
|
||||
this.taskRepository = taskRepository;
|
||||
this.soundManager = soundManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Observable<TaskDirectionData> buildUseCaseObservable(BuyRewardUseCase.RequestValues requestValues) {
|
||||
return taskRepository.taskChecked(requestValues.task, false).doOnNext(res -> {
|
||||
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundReward);
|
||||
});
|
||||
}
|
||||
|
||||
public static final class RequestValues implements UseCase.RequestValues {
|
||||
protected final Task task;
|
||||
|
||||
public RequestValues(Task task) {
|
||||
this.task = task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.habitrpg.android.habitica.interactors;
|
||||
|
||||
import com.habitrpg.android.habitica.data.TaskRepository;
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread;
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor;
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
public class ChecklistCheckUseCase extends UseCase<ChecklistCheckUseCase.RequestValues, Task> {
|
||||
|
||||
private TaskRepository taskRepository;
|
||||
|
||||
@Inject
|
||||
public ChecklistCheckUseCase(TaskRepository taskRepository, ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
|
||||
super(threadExecutor, postExecutionThread);
|
||||
this.taskRepository = taskRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Observable<Task> buildUseCaseObservable(ChecklistCheckUseCase.RequestValues requestValues) {
|
||||
return taskRepository.scoreChecklistItem(requestValues.taskId, requestValues.itemId);
|
||||
}
|
||||
|
||||
public static final class RequestValues implements UseCase.RequestValues {
|
||||
|
||||
protected final String itemId;
|
||||
|
||||
protected final String taskId;
|
||||
|
||||
public RequestValues(String taskId, String itemId) {
|
||||
this.taskId = taskId;
|
||||
this.itemId = itemId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.habitrpg.android.habitica.interactors;
|
||||
|
||||
import com.habitrpg.android.habitica.data.TaskRepository;
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread;
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor;
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
public class DailyCheckUseCase extends UseCase<DailyCheckUseCase.RequestValues, TaskDirectionData> {
|
||||
|
||||
private TaskRepository taskRepository;
|
||||
private SoundManager soundManager;
|
||||
|
||||
@Inject
|
||||
public DailyCheckUseCase(TaskRepository taskRepository, SoundManager soundManager,
|
||||
ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
|
||||
super(threadExecutor, postExecutionThread);
|
||||
this.taskRepository = taskRepository;
|
||||
this.soundManager = soundManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Observable<TaskDirectionData> buildUseCaseObservable(DailyCheckUseCase.RequestValues requestValues) {
|
||||
return taskRepository.taskChecked(requestValues.task, requestValues.Up).doOnNext(res -> {
|
||||
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundDaily);
|
||||
});
|
||||
}
|
||||
|
||||
public static final class RequestValues implements UseCase.RequestValues {
|
||||
|
||||
protected boolean Up = false;
|
||||
|
||||
protected final Task task;
|
||||
|
||||
public RequestValues(Task task, boolean up) {
|
||||
this.task = task;
|
||||
this.Up = up;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@ import rx.Observable;
|
|||
|
||||
public class HabitScoreUseCase extends UseCase<HabitScoreUseCase.RequestValues, TaskDirectionData> {
|
||||
|
||||
|
||||
private TaskRepository taskRepository;
|
||||
private SoundManager soundManager;
|
||||
|
||||
|
|
@ -27,7 +26,7 @@ public class HabitScoreUseCase extends UseCase<HabitScoreUseCase.RequestValues,
|
|||
|
||||
@Override
|
||||
protected Observable<TaskDirectionData> buildUseCaseObservable(RequestValues requestValues) {
|
||||
return taskRepository.scoreHabit(requestValues.habit, requestValues.Up).doOnNext(res -> {
|
||||
return taskRepository.taskChecked(requestValues.habit, requestValues.Up).doOnNext(res -> {
|
||||
|
||||
soundManager.loadAndPlayAudio(requestValues.Up ? SoundManager.SoundPlusHabit : SoundManager.SoundMinusHabit);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.habitrpg.android.habitica.interactors;
|
||||
|
||||
import com.habitrpg.android.habitica.data.TaskRepository;
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread;
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor;
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
public class TodoCheckUseCase extends UseCase<TodoCheckUseCase.RequestValues, TaskDirectionData> {
|
||||
|
||||
private TaskRepository taskRepository;
|
||||
private SoundManager soundManager;
|
||||
|
||||
@Inject
|
||||
public TodoCheckUseCase(TaskRepository taskRepository, SoundManager soundManager,
|
||||
ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread) {
|
||||
super(threadExecutor, postExecutionThread);
|
||||
this.taskRepository = taskRepository;
|
||||
this.soundManager = soundManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Observable<TaskDirectionData> buildUseCaseObservable(TodoCheckUseCase.RequestValues requestValues) {
|
||||
return taskRepository.taskChecked(requestValues.task, requestValues.Up).doOnNext(res -> {
|
||||
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundTodo);
|
||||
});
|
||||
}
|
||||
|
||||
public static final class RequestValues implements UseCase.RequestValues {
|
||||
|
||||
protected boolean Up = false;
|
||||
|
||||
protected final Task task;
|
||||
|
||||
public RequestValues(Task task, boolean up) {
|
||||
this.task = task;
|
||||
this.Up = up;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,10 @@
|
|||
package com.habitrpg.android.habitica.ui.activities;
|
||||
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.habitrpg.android.habitica.interactors.BuyRewardUseCase;
|
||||
import com.habitrpg.android.habitica.interactors.ChecklistCheckUseCase;
|
||||
import com.habitrpg.android.habitica.interactors.DailyCheckUseCase;
|
||||
import com.habitrpg.android.habitica.interactors.TodoCheckUseCase;
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.IApiClient;
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.HostConfig;
|
||||
|
|
@ -196,6 +200,18 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
@Inject
|
||||
HabitScoreUseCase habitScoreUseCase;
|
||||
|
||||
@Inject
|
||||
DailyCheckUseCase dailyCheckUseCase;
|
||||
|
||||
@Inject
|
||||
TodoCheckUseCase todoCheckUseCase;
|
||||
|
||||
@Inject
|
||||
BuyRewardUseCase buyRewardUseCase;
|
||||
|
||||
@Inject
|
||||
ChecklistCheckUseCase checklistCheckUseCase;
|
||||
|
||||
private Drawer drawer;
|
||||
private Drawer filterDrawer;
|
||||
private AccountHeader accountHeader;
|
||||
|
|
@ -244,10 +260,10 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
LanguageHelper languageHelper = new LanguageHelper(sharedPreferences.getString("language","en"));
|
||||
LanguageHelper languageHelper = new LanguageHelper(sharedPreferences.getString("language", "en"));
|
||||
Locale.setDefault(languageHelper.getLocale());
|
||||
Configuration configuration = new Configuration();
|
||||
if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN){
|
||||
if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
configuration.locale = languageHelper.getLocale();
|
||||
} else {
|
||||
configuration.setLocale(languageHelper.getLocale());
|
||||
|
|
@ -256,7 +272,6 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
getResources().getDisplayMetrics());
|
||||
|
||||
|
||||
|
||||
if (!HabiticaApplication.checkUserAuthentication(this, hostConfig)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -351,10 +366,10 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
}
|
||||
|
||||
private void updateWidget(Class widgetClass) {
|
||||
Intent intent = new Intent(this,widgetClass);
|
||||
Intent intent = new Intent(this, widgetClass);
|
||||
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
int ids[] = AppWidgetManager.getInstance(getApplication()).getAppWidgetIds(new ComponentName(getApplication(), widgetClass));
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,ids);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +417,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
|
||||
Preferences preferences = user.getPreferences();
|
||||
|
||||
if(preferences!= null) {
|
||||
if (preferences != null) {
|
||||
apiClient.setLanguageCode(preferences.getLanguage());
|
||||
}
|
||||
|
||||
|
|
@ -882,13 +897,12 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
this.drawer.setSelectionAtPosition(this.activeFragment.fragmentSidebarPosition, false);
|
||||
}
|
||||
|
||||
private void setTranslatedFragmentTitle(BaseMainFragment fragment){
|
||||
if(fragment!= null && fragment.customTitle() != null){
|
||||
getSupportActionBar().setTitle(fragment.customTitle());
|
||||
}
|
||||
else if(user != null && user.getProfile() != null){
|
||||
getSupportActionBar().setTitle(user.getProfile().getName());
|
||||
}
|
||||
private void setTranslatedFragmentTitle(BaseMainFragment fragment) {
|
||||
if (fragment != null && fragment.customTitle() != null) {
|
||||
getSupportActionBar().setTitle(fragment.customTitle());
|
||||
} else if (user != null && user.getProfile() != null) {
|
||||
getSupportActionBar().setTitle(user.getProfile().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void onBackPressed() {
|
||||
|
|
@ -913,13 +927,13 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
if (resultCode == SELECT_CLASS_RESULT) {
|
||||
if (this.apiClient != null) {
|
||||
this.apiClient.retrieveUser(true)
|
||||
|
||||
|
||||
.subscribe(new HabitRPGUserCallback(this), throwable -> {
|
||||
});
|
||||
}
|
||||
} else if (requestCode == GEM_PURCHASE_REQUEST) {
|
||||
this.apiClient.retrieveUser(true)
|
||||
|
||||
|
||||
.subscribe(new HabitRPGUserCallback(this), throwable -> {
|
||||
});
|
||||
}
|
||||
|
|
@ -949,7 +963,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
@Subscribe
|
||||
public void onEvent(EquipCommand event) {
|
||||
this.apiClient.equipItem(event.type, event.key)
|
||||
.subscribe(new ItemsCallback(this, this.user), throwable -> {
|
||||
.subscribe(new ItemsCallback(this, this.user), throwable -> {
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -958,7 +972,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
this.user.setBalance(this.user.getBalance() - event.balanceDiff);
|
||||
this.setUserData(false);
|
||||
apiClient.unlockPath(event.path)
|
||||
|
||||
|
||||
.subscribe(new UnlockCallback(this, this.user), throwable -> {
|
||||
});
|
||||
}
|
||||
|
|
@ -984,13 +998,13 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
observable = apiClient.purchaseItem(event.item.purchaseType, event.item.key);
|
||||
}
|
||||
observable
|
||||
|
||||
|
||||
.doOnNext(aVoid -> {
|
||||
showSnackbar(this, floatingMenuWrapper, getString(R.string.successful_purchase, event.item.text), SnackbarDisplayType.NORMAL);
|
||||
})
|
||||
.subscribe(buyResponse -> {
|
||||
apiClient.retrieveUser(false)
|
||||
|
||||
|
||||
.subscribe(new HabitRPGUserCallback(this), throwable -> {
|
||||
});
|
||||
}, throwable -> {
|
||||
|
|
@ -1066,12 +1080,10 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
}, throwable -> {
|
||||
});
|
||||
} else {
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundReward);
|
||||
// user created Rewards
|
||||
apiClient.postTaskDirection(rewardKey, TaskDirection.down.toString())
|
||||
|
||||
.subscribe(new TaskScoringCallback(this, rewardKey), throwable -> {
|
||||
});
|
||||
buyRewardUseCase.observable(new BuyRewardUseCase.RequestValues(event.Reward))
|
||||
.subscribe(res -> {
|
||||
onTaskDataReceived(res, event.Reward);
|
||||
}, error -> {});
|
||||
}
|
||||
|
||||
//Update the users gold
|
||||
|
|
@ -1110,7 +1122,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
@Subscribe
|
||||
public void onEvent(SellItemCommand event) {
|
||||
this.apiClient.sellItem(event.item.getType(), event.item.getKey())
|
||||
|
||||
|
||||
.subscribe(habitRPGUser -> {
|
||||
user.setItems(habitRPGUser.getItems());
|
||||
user.save();
|
||||
|
|
@ -1126,7 +1138,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
return;
|
||||
}
|
||||
this.apiClient.hatchPet(event.usingEgg.getKey(), event.usingHatchingPotion.getKey())
|
||||
|
||||
|
||||
.subscribe(new ItemsCallback(user1 -> {
|
||||
FrameLayout petWrapper = (FrameLayout) getLayoutInflater().inflate(R.layout.pet_imageview, null);
|
||||
SimpleDraweeView petImageView = (SimpleDraweeView) petWrapper.findViewById(R.id.pet_imageview);
|
||||
|
|
@ -1164,7 +1176,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
}
|
||||
final Pet pet = event.usingPet;
|
||||
this.apiClient.feedPet(event.usingPet.getKey(), event.usingFood.getKey())
|
||||
|
||||
|
||||
.subscribe(feedResponse -> {
|
||||
MainActivity.this.user.getItems().getPets().put(pet.getKey(), feedResponse.value);
|
||||
MainActivity.this.user.getItems().getFood().put(event.usingFood.getKey(), event.usingFood.getOwned() - 1);
|
||||
|
|
@ -1251,7 +1263,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
displayLevelUpDialog(lvl);
|
||||
|
||||
this.apiClient.retrieveUser(true)
|
||||
|
||||
|
||||
.subscribe(new HabitRPGUserCallback(this), throwable -> {
|
||||
});
|
||||
user.getStats().setLvl(lvl);
|
||||
|
|
@ -1312,7 +1324,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
.setPositiveButton(R.string.faint_button, (dialog, which) -> {
|
||||
faintDialog = null;
|
||||
apiClient.revive()
|
||||
|
||||
|
||||
.subscribe(new MergeUserCallback(MainActivity.this, MainActivity.this.user), throwable -> {
|
||||
});
|
||||
})
|
||||
|
|
@ -1428,7 +1440,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
Map<String, Object> updateData = new HashMap<>();
|
||||
updateData.put(path, true);
|
||||
apiClient.updateUser(updateData)
|
||||
|
||||
|
||||
.subscribe(new MergeUserCallback(this, user), throwable -> {
|
||||
});
|
||||
this.overlayFrameLayout.removeView(this.activeTutorialView);
|
||||
|
|
@ -1482,29 +1494,32 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
|
||||
@Subscribe
|
||||
public void onEvent(TaskCheckedCommand event) {
|
||||
apiClient.postTaskDirection(event.Task.getId(), (event.Task.getCompleted() ? TaskDirection.down : TaskDirection.up).toString())
|
||||
|
||||
.subscribe(new TaskScoringCallback(this, event.Task.getId()), throwable -> {
|
||||
event.Task.completed = !event.Task.completed;
|
||||
event.Task.save();
|
||||
EventBus.getDefault().post(new TaskUpdatedEvent(event.Task));
|
||||
});
|
||||
|
||||
switch(event.Task.type){
|
||||
switch (event.Task.type) {
|
||||
case Task.TYPE_DAILY: {
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundDaily);
|
||||
} break;
|
||||
dailyCheckUseCase.observable(new DailyCheckUseCase.RequestValues(event.Task, !event.Task.getCompleted()))
|
||||
.subscribe(res -> {
|
||||
EventBus.getDefault().post(new TaskUpdatedEvent(event.Task));
|
||||
}, error -> {
|
||||
});
|
||||
}
|
||||
break;
|
||||
case Task.TYPE_TODO: {
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundTodo);
|
||||
} break;
|
||||
todoCheckUseCase.observable(new TodoCheckUseCase.RequestValues(event.Task, !event.Task.getCompleted()))
|
||||
.subscribe(res -> {
|
||||
EventBus.getDefault().post(new TaskUpdatedEvent(event.Task));
|
||||
}, error -> {
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(ChecklistCheckedCommand event) {
|
||||
apiClient.scoreChecklistItem(event.task.getId(), event.item.getId())
|
||||
|
||||
.subscribe(new TaskUpdateCallback(), throwable -> {
|
||||
checklistCheckUseCase.observable(new ChecklistCheckUseCase.RequestValues(event.task.getId(), event.item.getId()))
|
||||
.subscribe(res -> {
|
||||
EventBus.getDefault().post(new TaskUpdatedEvent(event.task));
|
||||
}, error -> {
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1514,8 +1529,6 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
.subscribe(res -> {
|
||||
onTaskDataReceived(res, event.habit);
|
||||
}, error -> {
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1524,12 +1537,10 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
Task task = event.task;
|
||||
if (event.created) {
|
||||
this.apiClient.createItem(task)
|
||||
|
||||
.subscribe(new TaskCreationCallback(), throwable -> {
|
||||
});
|
||||
} else {
|
||||
this.apiClient.updateTask(task.getId(), task)
|
||||
|
||||
.subscribe(new TaskUpdateCallback(), throwable -> {
|
||||
});
|
||||
}
|
||||
|
|
@ -1629,7 +1640,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
|
||||
@Subscribe
|
||||
public void onEvent(OpenFullProfileCommand cmd) {
|
||||
if(cmd.MemberId.equals("system"))
|
||||
if (cmd.MemberId.equals("system"))
|
||||
return;
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
@ -1645,8 +1656,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
this.filterDrawer.removeItemByPosition(position);
|
||||
}
|
||||
|
||||
public void updateFilterDrawerItem (IDrawerItem item, int position) {
|
||||
public void updateFilterDrawerItem(IDrawerItem item, int position) {
|
||||
this.filterDrawer.removeItemByPosition(position);
|
||||
this.filterDrawer.addItemAtPosition(item,position);
|
||||
this.filterDrawer.addItemAtPosition(item, position);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue