Skip to content

Commit

Permalink
finalize bugfix update
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Oct 3, 2017
1 parent 9631457 commit 12b2462
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Habitica/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.habitrpg.android.habitica"
android:versionCode="1937"
android:versionName="1.2"
android:versionCode="1938"
android:versionName="1.2.1"
android:screenOrientation="portrait"
android:installLocation="auto" >

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,16 @@ public Observable<Void> deleteMessage(ChatMessage chatMessage) {
public Observable<PostChatMessageResult> postGroupChat(String groupId, HashMap<String, String> messageObject) {
return apiClient.postGroupChat(groupId, messageObject)
.map(postChatMessageResult -> {
postChatMessageResult.message.groupId = groupId;
if (postChatMessageResult != null) {
postChatMessageResult.message.groupId = groupId;
}
return postChatMessageResult;
})
.doOnNext(postChatMessageResult -> localRepository.save(postChatMessageResult.message));
.doOnNext(postChatMessageResult -> {
if (postChatMessageResult != null) {
localRepository.save(postChatMessageResult.message);
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public int getContributorColor() {
}

public int getContributorForegroundColor() {
int rColor = android.R.color.white;
return rColor;
return android.R.color.white;
}

public String getUserId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,11 @@ public int getLoginIncentives() {
public void setLoginIncentives(int loginIncentives) {
this.loginIncentives = loginIncentives;
}

public int getContributorColor() {
if (contributor != null) {
return contributor.getContributorColor();
}
return android.R.color.black;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public void onEvent(FeedCommand event) {
// endregion

public void displayTaskScoringResponse(TaskScoringResult data) {
if (user != null) {
if (user != null && data != null) {
notifyUserUseCase.observable(new NotifyUserUseCase.RequestValues(this, floatingMenuWrapper,
user, data.experienceDelta, data.healthDelta, data.goldDelta, data.manaDelta, data.hasLeveledUp))
.subscribe(aVoid -> {}, RxErrorHandler.handleEmptyError());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public void bind(final ChatMessage msg) {
setLikeProperties();

if (userBackground != null) {
if (msg.sent != null && msg.sent.equals("true")) {
DataBindingUtils.setRoundedBackgroundInt(userBackground, sendingUser.getContributor().getContributorColor());
if (msg.sent != null && msg.sent.equals("true") && sendingUser != null) {
DataBindingUtils.setRoundedBackgroundInt(userBackground, sendingUser.getContributorColor());
} else {
DataBindingUtils.setRoundedBackgroundInt(userBackground, msg.getContributorColor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

import javax.inject.Inject;

import rx.android.schedulers.AndroidSchedulers;


public class PartyFragment extends BaseMainFragment {

Expand Down Expand Up @@ -72,6 +74,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
.first()
//delay, so that realm can save party first
.delay(500, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(group -> {
PartyFragment.this.group = group;
updateGroupUI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,52 +205,55 @@ void onCloseClicked() {

@OnClick(R.id.buyButton)
void onBuyButtonClicked() {
if (shopItem.canBuy(user)) {
Observable<Void> observable;
if ((shopIdentifier!= null && shopIdentifier.equals(Shop.TIME_TRAVELERS_SHOP)) || "mystery_set".equals(shopItem.purchaseType)) {
if (shopItem.purchaseType.equals("gear")) {
observable = inventoryRepository.purchaseMysterySet(shopItem.categoryIdentifier);
if (shopItem.isValid()) {
if (shopItem.canBuy(user)) {
Observable<Void> observable;
if ((shopIdentifier != null && shopIdentifier.equals(Shop.TIME_TRAVELERS_SHOP)) || "mystery_set".equals(shopItem.purchaseType)) {
if (shopItem.purchaseType.equals("gear")) {
observable = inventoryRepository.purchaseMysterySet(shopItem.categoryIdentifier);
} else {
observable = inventoryRepository.purchaseHourglassItem(shopItem.purchaseType, shopItem.key);
}
} else if (shopItem.purchaseType.equals("quests") && shopItem.getCurrency().equals("gold")) {
observable = inventoryRepository.purchaseQuest(shopItem.key);
} else if ("gold".equals(shopItem.currency) && !"gem".equals(shopItem.key)) {
observable = inventoryRepository.buyItem(user, shopItem.key, shopItem.value).flatMap(buyResponse -> Observable.just(null));
} else {
observable = inventoryRepository.purchaseHourglassItem(shopItem.purchaseType, shopItem.key);
observable = inventoryRepository.purchaseItem(shopItem.purchaseType, shopItem.key);
}
} else if (shopItem.purchaseType.equals("quests") && shopItem.getCurrency().equals("gold")) {
observable = inventoryRepository.purchaseQuest(shopItem.key);
} else if ("gold".equals(shopItem.currency) && !"gem".equals(shopItem.key)) {
observable = inventoryRepository.buyItem(user, shopItem.key, shopItem.value).flatMap(buyResponse -> Observable.just(null));
} else {
observable = inventoryRepository.purchaseItem(shopItem.purchaseType, shopItem.key);
}
observable
.doOnNext(aVoid -> {
ShowSnackbarEvent event = new ShowSnackbarEvent();
event.title = getContext().getString(R.string.successful_purchase, shopItem.text);
event.type = HabiticaSnackbar.SnackbarDisplayType.NORMAL;
event.rightIcon = priceLabel.getCompoundDrawables()[0];
event.rightTextColor = priceLabel.getCurrentTextColor();
event.rightText = "-"+priceLabel.getText();
EventBus.getDefault().post(event);
})
.flatMap(buyResponse -> userRepository.retrieveUser(false, true))
.flatMap(user1 -> inventoryRepository.retrieveInAppRewards())
.subscribe(buyResponse -> {}, throwable -> {
if (throwable.getClass().isAssignableFrom(retrofit2.HttpException.class)) {
retrofit2.HttpException error = (retrofit2.HttpException) throwable;
if (error.code() == 401 && shopItem.getCurrency().equals("gems")) {
EventBus.getDefault().post(new OpenGemPurchaseFragmentCommand());
observable
.doOnNext(aVoid -> {
ShowSnackbarEvent event = new ShowSnackbarEvent();
event.title = getContext().getString(R.string.successful_purchase, shopItem.text);
event.type = HabiticaSnackbar.SnackbarDisplayType.NORMAL;
event.rightIcon = priceLabel.getCompoundDrawables()[0];
event.rightTextColor = priceLabel.getCurrentTextColor();
event.rightText = "-" + priceLabel.getText();
EventBus.getDefault().post(event);
})
.flatMap(buyResponse -> userRepository.retrieveUser(false, true))
.flatMap(user1 -> inventoryRepository.retrieveInAppRewards())
.subscribe(buyResponse -> {
}, throwable -> {
if (throwable.getClass().isAssignableFrom(retrofit2.HttpException.class)) {
retrofit2.HttpException error = (retrofit2.HttpException) throwable;
if (error.code() == 401 && shopItem.getCurrency().equals("gems")) {
EventBus.getDefault().post(new OpenGemPurchaseFragmentCommand());
}
}
}
});
} else {
InsufficientCurrencyDialog dialog = null;
if ("gold".equals(shopItem.currency)) {
dialog = new InsufficientGoldDialog(getContext());
} else if ("gems".equals(shopItem.currency)) {
dialog = new InsufficientGemsDialog(getContext());
} else if ("hourglasses".equals(shopItem.currency)) {
dialog = new InsufficientHourglassesDialog(getContext());
}
if (dialog != null) {
dialog.show();
});
} else {
InsufficientCurrencyDialog dialog = null;
if ("gold".equals(shopItem.currency)) {
dialog = new InsufficientGoldDialog(getContext());
} else if ("gems".equals(shopItem.currency)) {
dialog = new InsufficientGemsDialog(getContext());
} else if ("hourglasses".equals(shopItem.currency)) {
dialog = new InsufficientHourglassesDialog(getContext());
}
if (dialog != null) {
dialog.show();
}
}
}
dismiss();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ protected void showToastForTaskDirection(Context context, TaskScoringResult data
if (userRepository == null) {
HabiticaApplication.getComponent().inject(this);
}
if (data != null) {
Pair<SpannableStringBuilder, HabiticaSnackbar.SnackbarDisplayType> pair = NotifyUserUseCase.getNotificationAndAddStatsToUserAsText(context, data.experienceDelta, data.healthDelta, data.goldDelta, data.manaDelta);
Toast toast = Toast.makeText(context, pair.first, Toast.LENGTH_LONG);
toast.show();
}
}

abstract public int layoutResourceId();
Expand Down

0 comments on commit 12b2462

Please sign in to comment.