mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
fix notifications for task completion
This commit is contained in:
parent
c0c3e047b2
commit
4a92a2c214
3 changed files with 15 additions and 6 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.habitrpg.android.habitica"
|
package="com.habitrpg.android.habitica"
|
||||||
android:versionCode="165"
|
android:versionCode="166"
|
||||||
android:versionName="1.0"
|
android:versionName="1.0"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:installLocation="auto" >
|
android:installLocation="auto" >
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import rx.functions.Action0;
|
||||||
import static com.habitrpg.android.habitica.helpers.MathHelper.round;
|
import static com.habitrpg.android.habitica.helpers.MathHelper.round;
|
||||||
import static com.habitrpg.android.habitica.ui.helpers.UiUtils.showSnackbar;
|
import static com.habitrpg.android.habitica.ui.helpers.UiUtils.showSnackbar;
|
||||||
|
|
||||||
public class NotifyUserUseCase extends UseCase<NotifyUserUseCase.RequestValues, Void> {
|
public class NotifyUserUseCase extends UseCase<NotifyUserUseCase.RequestValues, Stats> {
|
||||||
|
|
||||||
public static final int MIN_LEVEL_FOR_SKILLS = 11;
|
public static final int MIN_LEVEL_FOR_SKILLS = 11;
|
||||||
private LevelUpUseCase levelUpUseCase;
|
private LevelUpUseCase levelUpUseCase;
|
||||||
|
|
@ -31,8 +31,8 @@ public class NotifyUserUseCase extends UseCase<NotifyUserUseCase.RequestValues,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Observable<Void> buildUseCaseObservable(RequestValues r) {
|
protected Observable<Stats> buildUseCaseObservable(RequestValues r) {
|
||||||
return Observable.from(() -> {
|
return Observable.defer(() -> {
|
||||||
Stats stats = r.user.getStats();
|
Stats stats = r.user.getStats();
|
||||||
|
|
||||||
if (r.lvl > stats.getLvl()) {
|
if (r.lvl > stats.getLvl()) {
|
||||||
|
|
@ -49,7 +49,7 @@ public class NotifyUserUseCase extends UseCase<NotifyUserUseCase.RequestValues,
|
||||||
showSnackbar(r.context, r.snackbarTargetView, pair.first, pair.second);
|
showSnackbar(r.context, r.snackbarTargetView, pair.first, pair.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return Observable.just(stats);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1280,6 +1280,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTaskDataReceived(TaskDirectionData data, Task task) {
|
public void onTaskDataReceived(TaskDirectionData data, Task task) {
|
||||||
|
|
||||||
if (task.type.equals("reward")) {
|
if (task.type.equals("reward")) {
|
||||||
|
|
||||||
showSnackbar(this, floatingMenuWrapper, getString(R.string.notification_purchase, task.getText()), SnackbarDisplayType.NORMAL);
|
showSnackbar(this, floatingMenuWrapper, getString(R.string.notification_purchase, task.getText()), SnackbarDisplayType.NORMAL);
|
||||||
|
|
@ -1288,12 +1289,20 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
||||||
|
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
notifyUserUseCase.observable(new NotifyUserUseCase.RequestValues(this, floatingMenuWrapper, this::retrieveUser,
|
notifyUserUseCase.observable(new NotifyUserUseCase.RequestValues(this, floatingMenuWrapper, this::retrieveUser,
|
||||||
user, data.getExp(), data.getHp(), data.getGp(), data.getMp(), data.getLvl()));
|
user, data.getExp(), data.getHp(), data.getGp(), data.getMp(), data.getLvl()))
|
||||||
|
.subscribe(aVoid -> {
|
||||||
|
user.getStats().hp = data.getHp();
|
||||||
|
user.getStats().exp = data.getExp();
|
||||||
|
user.getStats().mp = data.getMp();
|
||||||
|
user.getStats().gp = data.getGp();
|
||||||
|
setUserData(true);
|
||||||
|
}, throwable -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
displayItemDropUseCase.observable(new DisplayItemDropUseCase.RequestValues(data, this, floatingMenuWrapper))
|
displayItemDropUseCase.observable(new DisplayItemDropUseCase.RequestValues(data, this, floatingMenuWrapper))
|
||||||
.subscribe(aVoid -> {}, throwable -> {});
|
.subscribe(aVoid -> {}, throwable -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue