mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-23 06:07:16 +00:00
fix several crashes
This commit is contained in:
parent
d1fb5770f0
commit
ba747d55ee
14 changed files with 102 additions and 66 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="41"
|
||||
android:versionCode="42"
|
||||
android:versionName="0.0.27"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
|
|
|||
|
|
@ -87,6 +87,57 @@
|
|||
android:layout_margin="5dp"
|
||||
android:visibility="@{quest != null ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:visibility="@{quest != null && !group.quest.active ? View.VISIBLE : View.GONE}">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestAccept"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_success"
|
||||
android:text="@string/quest.accept"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getParty().getQuest().RSVPNeeded? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestReject"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_danger"
|
||||
android:text="@string/quest.reject"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getParty().getQuest().RSVPNeeded? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestBegin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_warning"
|
||||
android:text="@string/quest.begin"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getId().equals(group.quest.leader) ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_danger"
|
||||
android:text="@string/quest.cancel"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getId().equals(group.quest.leader) ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -203,51 +254,6 @@
|
|||
android:visibility="@{(!user.getId().equals(group.quest.leader) && group.quest.members.containsKey(user.getId()))? View.VISIBLE : View.GONE}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp"
|
||||
android:visibility="@{!group.quest.active? View.VISIBLE : View.GONE}">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestAccept"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_success"
|
||||
android:text="@string/quest.accept"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getParty().getQuest().RSVPNeeded? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestReject"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_danger"
|
||||
android:text="@string/quest.reject"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getParty().getQuest().RSVPNeeded? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestBegin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_warning"
|
||||
android:text="@string/quest.begin"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getId().equals(group.quest.leader) ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnQuestCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/btn_danger"
|
||||
android:text="@string/quest.cancel"
|
||||
android:textColor="@android:color/white"
|
||||
android:visibility="@{user.getId().equals(group.quest.leader) ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
|
|
|||
|
|
@ -253,4 +253,8 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="outfit_weapon">Weapon</string>
|
||||
<string name="wear_costume">Wear Costume</string>
|
||||
<string name="equipped">Equipped</string>
|
||||
<string name="quest_pending">Pending</string>
|
||||
<string name="quest_accepted">Accepted</string>
|
||||
<string name="quest_rejected">Rejected</string>
|
||||
<string name="quest_participants">Participants</string>
|
||||
</resources>
|
||||
|
|
@ -3,8 +3,10 @@ package com.habitrpg.android.habitica;
|
|||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
||||
import com.amplitude.api.Amplitude;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
|
|
@ -249,6 +251,7 @@ public class APIHelper implements ErrorHandler, Profiler {
|
|||
showConnectionProblemDialog(R.string.network_error_no_network_body);
|
||||
return cause;
|
||||
} else if (cause.getKind().equals(RetrofitError.Kind.HTTP)) {
|
||||
Crashlytics.getInstance().core.log(Log.INFO, "Habitica", "Error loading " + cause.getUrl());
|
||||
retrofit.client.Response response = cause.getResponse();
|
||||
|
||||
ErrorResponse res = null;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.habitrpg.android.habitica.callbacks;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
|
||||
import retrofit.Callback;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.habitrpg.android.habitica.callbacks;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.habitrpg.android.habitica.events.SkillUsedEvent;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Skill;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.habitrpg.android.habitica.callbacks;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.UnlockResponse;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
|
||||
protected abstract int getLayoutResId();
|
||||
|
||||
private boolean destroyed;
|
||||
|
||||
public boolean isDestroyed(){
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -32,4 +38,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
destroyed = true;
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
public Drawer drawer;
|
||||
public Drawer filterDrawer;
|
||||
protected HostConfig hostConfig;
|
||||
protected HabitRPGUser user;
|
||||
public HabitRPGUser user;
|
||||
private AccountHeader accountHeader;
|
||||
private BaseMainFragment activeFragment;
|
||||
private AvatarWithBarsViewModel avatarInHeader;
|
||||
|
|
@ -227,6 +227,9 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
if (this.activeFragment != null && fragment.getClass() == this.activeFragment.getClass()) {
|
||||
return;
|
||||
}
|
||||
if (this.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
this.activeFragment = fragment;
|
||||
fragment.setArguments(getIntent().getExtras());
|
||||
fragment.mAPIHelper = mAPIHelper;
|
||||
|
|
@ -235,6 +238,7 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
fragment.setTabLayout(detail_tabs);
|
||||
fragment.setFloatingMenuWrapper(floatingMenuWrapper);
|
||||
|
||||
|
||||
if (getSupportFragmentManager().getFragments() == null) {
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment).commitAllowingStateLoss();
|
||||
} else {
|
||||
|
|
@ -496,7 +500,7 @@ public class MainActivity extends BaseActivity implements HabitRPGUserCallback.O
|
|||
drawer.getDrawerLayout().closeDrawer(GravityCompat.END);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
|
||||
this.activeFragment.updateUserData(user);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by franzejr on 28/11/15.
|
||||
*/
|
||||
public class AccountDetailsFragment extends BasePreferencesFragment {
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -116,6 +116,9 @@ public class AvatarCustomizationFragment extends BaseMainFragment {
|
|||
}
|
||||
|
||||
int spanCount = (int) (width / itemWidth);
|
||||
if (spanCount == 0) {
|
||||
spanCount = 1;
|
||||
}
|
||||
layoutManager.setSpanCount(spanCount);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,12 +52,17 @@ public class AvatarSetupFragment extends BaseFragment {
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view == null)
|
||||
if (view == null) {
|
||||
view = inflater.inflate(R.layout.fragment_setup_avatar, container, false);
|
||||
}
|
||||
|
||||
ButterKnife.bind(this, view);
|
||||
this.adapter = new CustomizationSetupAdapter();
|
||||
this.adapter.userSize = this.user.getPreferences().getSize();
|
||||
if (this.user != null) {
|
||||
this.adapter.userSize = this.user.getPreferences().getSize();
|
||||
} else {
|
||||
this.adapter.userSize = "slim";
|
||||
}
|
||||
this.adapter.user = this.user;
|
||||
this.layoutManager = new GridLayoutManager(activity, 2);
|
||||
this.layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
|
|
|
|||
|
|
@ -133,7 +133,9 @@ public class GroupInformationFragment extends Fragment {
|
|||
return;
|
||||
}
|
||||
questCollectViewAdapter.setQuestContent(quest);
|
||||
questCollectViewAdapter.setQuestProgress(group.quest.getProgress());
|
||||
if (group.quest.getProgress() != null) {
|
||||
questCollectViewAdapter.setQuestProgress(group.quest.getProgress());
|
||||
}
|
||||
bossHpBar.valueBarLayout.setVisibility((quest.boss != null && quest.boss.hp > 0) ? View.VISIBLE : View.GONE);
|
||||
bossRageBar.valueBarLayout.setVisibility((quest.boss != null && quest.boss.rage_value > 0) ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
|
@ -158,13 +160,13 @@ public class GroupInformationFragment extends Fragment {
|
|||
if (group.quest.active) {
|
||||
questResponse.setText("");
|
||||
} else if (questresponse == null) {
|
||||
questResponse.setText("Pending");
|
||||
} else if (questresponse.booleanValue() == true) {
|
||||
questResponse.setText("Accepted");
|
||||
questResponse.setTextColor(Color.parseColor("#2db200"));
|
||||
} else if (questresponse.booleanValue() == false) {
|
||||
questResponse.setText("Rejected");
|
||||
questResponse.setTextColor(Color.parseColor("#b30409"));
|
||||
questResponse.setText(R.string.quest_pending);
|
||||
} else if (questresponse) {
|
||||
questResponse.setText(R.string.quest_accepted);
|
||||
questResponse.setTextColor(getResources().getColor(R.color.good_10));
|
||||
} else {
|
||||
questResponse.setText(R.string.quest_rejected);
|
||||
questResponse.setTextColor(getResources().getColor(R.color.worse_10));
|
||||
}
|
||||
questMemberView.post(new Runnable() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -104,14 +104,17 @@ public class PartyFragment extends BaseMainFragment {
|
|||
|
||||
public void setViewPagerAdapter() {
|
||||
android.support.v4.app.FragmentManager fragmentManager = getChildFragmentManager();
|
||||
if (this.user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
UserParty party = user.getParty();
|
||||
UserParty party = this.user.getParty();
|
||||
|
||||
if(party == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
viewPager.setAdapter(new FragmentPagerAdapter(fragmentManager) {
|
||||
this.viewPager.setAdapter(new FragmentPagerAdapter(fragmentManager) {
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue