fix various crashes

This commit is contained in:
Phillip Thelen 2016-10-01 19:42:25 +02:00
parent 3313edac15
commit e0dfda1b21
5 changed files with 31 additions and 34 deletions

View file

@ -403,7 +403,7 @@ public class LoginActivity extends BaseActivity
e.printStackTrace();
}
if (this.isRegistering || userAuthResponse.getNewUser()) {
if (userAuthResponse.getNewUser()) {
this.startSetupActivity();
} else {
AmplitudeManager.sendEvent("login", AmplitudeManager.EVENT_CATEGORY_BEHAVIOUR, AmplitudeManager.EVENT_HITTYPE_EVENT);

View file

@ -107,7 +107,7 @@ public class GroupInformationFragment extends BaseFragment {
QrCodeManager qrCodeManager = new QrCodeManager(this.getContext());
qrCodeManager.setUpView(qrLayout);
if (user.getInvitations().getParty() != null && user.getInvitations().getParty().getId() != null) {
if (user != null && user.getInvitations().getParty() != null && user.getInvitations().getParty().getId() != null) {
viewBinding.setInvitation(user.getInvitations().getParty());
}
}

View file

@ -84,16 +84,6 @@ public class PartyFragment extends BaseMainFragment {
});
}, throwable -> {
});
} else {
// AlertDialog.Builder builder = new AlertDialog.Builder(activity)
// .setMessage(activity.getString(R.string.no_party_message))
// .setNeutralButton(android.R.string.ok, (dialog, which) -> {
// activity.getSupportFragmentManager().popBackStackImmediate();
// });
// builder.show();
// if (tabLayout != null) {
// tabLayout.removeAllTabs();
// }
}
@ -112,7 +102,9 @@ public class PartyFragment extends BaseMainFragment {
}
private void updateGroupUI() {
viewPagerAdapter.notifyDataSetChanged();
if (viewPagerAdapter != null) {
viewPagerAdapter.notifyDataSetChanged();
}
if (tabLayout != null) {
if (group == null) {
@ -137,7 +129,7 @@ public class PartyFragment extends BaseMainFragment {
PartyFragment.this.activity.supportInvalidateOptionsMenu();
if (group.quest != null && group.quest.key != null && !group.quest.key.isEmpty()) {
if (group != null && group.quest != null && group.quest.key != null && !group.quest.key.isEmpty()) {
contentCache.GetQuestContent(group.quest.key, content -> {
if (groupInformationFragment != null) {
groupInformationFragment.setQuestContent(content);

View file

@ -492,7 +492,9 @@ public class TasksFragment extends BaseMainFragment implements OnCheckedChangeLi
);
}
}
this.activity.fillFilterDrawer(items);
if (isAdded()) {
this.activity.fillFilterDrawer(items);
}
}else {
items.add(new EditTagsSectionDrawer().withEditing(this.editingTags).withName(getString(R.string.filter_drawer_filter_tags)));
items.add(new EditTextDrawer());
@ -506,7 +508,9 @@ public class TasksFragment extends BaseMainFragment implements OnCheckedChangeLi
);
}
}
this.activity.fillFilterDrawer(items);
if (isAdded()) {
this.activity.fillFilterDrawer(items);
}
}
}
}

View file

@ -79,26 +79,27 @@ public class HabitButtonWidgetService extends Service {
private void updateData(Task task) {
RemoteViews remoteViews = new RemoteViews(this.getPackageName(), R.layout.widget_habit_button);
remoteViews.setTextViewText(R.id.habit_title, task.text);
if (task != null) {
remoteViews.setTextViewText(R.id.habit_title, task.text);
if (!task.getUp()) {
remoteViews.setViewVisibility(R.id.btnPlusWrapper, View.GONE);
remoteViews.setOnClickPendingIntent(R.id.btnPlusWrapper, null);
} else {
remoteViews.setViewVisibility(R.id.btnPlusWrapper, View.VISIBLE);
remoteViews.setInt(R.id.btnPlus, "setBackgroundColor", resources.getColor(task.getLightTaskColor()));
remoteViews.setOnClickPendingIntent(R.id.btnPlusWrapper, getPendingIntent(task.getId(), TaskDirection.up.toString(), taskMapping.get(task.getId())));
if (!task.getUp()) {
remoteViews.setViewVisibility(R.id.btnPlusWrapper, View.GONE);
remoteViews.setOnClickPendingIntent(R.id.btnPlusWrapper, null);
} else {
remoteViews.setViewVisibility(R.id.btnPlusWrapper, View.VISIBLE);
remoteViews.setInt(R.id.btnPlus, "setBackgroundColor", resources.getColor(task.getLightTaskColor()));
remoteViews.setOnClickPendingIntent(R.id.btnPlusWrapper, getPendingIntent(task.getId(), TaskDirection.up.toString(), taskMapping.get(task.getId())));
}
if (!task.getDown()) {
remoteViews.setViewVisibility(R.id.btnMinusWrapper, View.GONE);
remoteViews.setOnClickPendingIntent(R.id.btnMinusWrapper, null);
} else {
remoteViews.setViewVisibility(R.id.btnMinusWrapper, View.VISIBLE);
remoteViews.setInt(R.id.btnMinus, "setBackgroundColor", resources.getColor(task.getMediumTaskColor()));
remoteViews.setOnClickPendingIntent(R.id.btnMinusWrapper, getPendingIntent(task.getId(), TaskDirection.down.toString() , taskMapping.get(task.getId())));
}
appWidgetManager.updateAppWidget(taskMapping.get(task.getId()), remoteViews);
}
if (!task.getDown()) {
remoteViews.setViewVisibility(R.id.btnMinusWrapper, View.GONE);
remoteViews.setOnClickPendingIntent(R.id.btnMinusWrapper, null);
} else {
remoteViews.setViewVisibility(R.id.btnMinusWrapper, View.VISIBLE);
remoteViews.setInt(R.id.btnMinus, "setBackgroundColor", resources.getColor(task.getMediumTaskColor()));
remoteViews.setOnClickPendingIntent(R.id.btnMinusWrapper, getPendingIntent(task.getId(), TaskDirection.down.toString() , taskMapping.get(task.getId())));
}
appWidgetManager.updateAppWidget(taskMapping.get(task.getId()), remoteViews);
}
@Override