mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 19:59:00 +00:00
Fix floating menu button
This commit is contained in:
parent
8b7cbcac8f
commit
422b79a2a3
6 changed files with 172 additions and 129 deletions
|
|
@ -75,5 +75,17 @@
|
|||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabMode="fixed" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/floating_menu_wrapper"
|
||||
app:layout_behavior="com.habitrpg.android.habitica.ui.helpers.FloatingActionMenuBehavior"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="8dp" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
90
Habitica/res/layout/floating_menu_tasks.xml
Normal file
90
Habitica/res/layout/floating_menu_tasks.xml
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.github.clans.fab.FloatingActionMenu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/fab.menu"
|
||||
app:layout_behavior="com.habitrpg.android.habitica.ui.helpers.FloatingActionMenuBehavior"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
fab:menu_fab_size="normal"
|
||||
fab:menu_labels_paddingTop="8dp"
|
||||
fab:menu_labels_paddingRight="8dp"
|
||||
fab:menu_labels_paddingBottom="8dp"
|
||||
fab:menu_labels_paddingLeft="8dp"
|
||||
|
||||
fab:menu_colorNormal="@color/brand"
|
||||
fab:menu_colorPressed="@color/brand_400"
|
||||
fab:menu_colorRipple="#FFFFFF"
|
||||
fab:menu_animationDelayPerItem="50"
|
||||
fab:menu_icon="@drawable/fab_add"
|
||||
fab:menu_buttonSpacing="2dp">
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.habit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Habit" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.daily"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Daily" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.todo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Todo" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.reward"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Reward" />
|
||||
|
||||
</com.github.clans.fab.FloatingActionMenu>
|
||||
|
|
@ -1,98 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
android:layout_height="match_parent">
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<com.github.clans.fab.FloatingActionMenu
|
||||
android:id="@+id/fab.menu"
|
||||
app:layout_behavior="com.habitrpg.android.habitica.ui.helpers.FloatingActionMenuBehavior"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
fab:menu_fab_size="normal"
|
||||
fab:menu_labels_paddingTop="8dp"
|
||||
fab:menu_labels_paddingRight="8dp"
|
||||
fab:menu_labels_paddingBottom="8dp"
|
||||
fab:menu_labels_paddingLeft="8dp"
|
||||
|
||||
fab:menu_colorNormal="@color/brand"
|
||||
fab:menu_colorPressed="@color/brand_400"
|
||||
fab:menu_colorRipple="#FFFFFF"
|
||||
fab:menu_animationDelayPerItem="50"
|
||||
fab:menu_icon="@drawable/fab_add"
|
||||
fab:menu_buttonSpacing="2dp">
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.habit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Habit" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.daily"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Daily" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.todo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Todo" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/fab.new.reward"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
fab:fab_colorNormal="@color/brand"
|
||||
fab:fab_colorPressed="@color/brand_400"
|
||||
fab:fab_colorRipple="#FFFFFF"
|
||||
|
||||
fab:fab_shadowColor="#000"
|
||||
fab:fab_elevationCompat="6dp"
|
||||
|
||||
android:src="@drawable/fab_add"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="New Reward" />
|
||||
|
||||
</com.github.clans.fab.FloatingActionMenu>
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@ import android.content.Intent;
|
|||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.CollapsingToolbarLayout;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.core.CrashlyticsCore;
|
||||
|
|
@ -49,8 +53,15 @@ import retrofit.client.Response;
|
|||
*/
|
||||
public class MainActivity extends InstabugAppCompatActivity implements HabitRPGUserCallback.OnUserReceived {
|
||||
|
||||
public enum SnackbarDisplayType {
|
||||
NORMAL, FAILURE, DROP
|
||||
}
|
||||
|
||||
BaseFragment activeFragment;
|
||||
|
||||
@InjectView(R.id.floating_menu_wrapper)
|
||||
FrameLayout floatingMenuWrapper;
|
||||
|
||||
@InjectView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
|
|
@ -152,6 +163,7 @@ public class MainActivity extends InstabugAppCompatActivity implements HabitRPGU
|
|||
fragment.setUser(user);
|
||||
fragment.setActivity(this);
|
||||
fragment.setTabLayout(detail_tabs);
|
||||
fragment.setFloatingMenuWrapper(floatingMenuWrapper);
|
||||
|
||||
if (getSupportFragmentManager().getFragments() == null) {
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment).commit();
|
||||
|
|
@ -248,4 +260,24 @@ public class MainActivity extends InstabugAppCompatActivity implements HabitRPGU
|
|||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
public void showSnackbar(String content) {
|
||||
showSnackbar(content, SnackbarDisplayType.NORMAL);
|
||||
}
|
||||
|
||||
public void showSnackbar(String content, SnackbarDisplayType displayType) {
|
||||
Snackbar snackbar = Snackbar.make(floatingMenuWrapper, content, Snackbar.LENGTH_LONG);
|
||||
View snackbarView = snackbar.getView();
|
||||
|
||||
if (displayType == SnackbarDisplayType.FAILURE) {
|
||||
|
||||
//change Snackbar's background color;
|
||||
snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.worse_10));
|
||||
} else if (displayType == SnackbarDisplayType.DROP) {
|
||||
TextView tv = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
|
||||
tv.setMaxLines(5);
|
||||
snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.best_10));
|
||||
}
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,24 @@ package com.habitrpg.android.habitica.ui.fragments;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.APIHelper;
|
||||
import com.habitrpg.android.habitica.MainActivity;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.callbacks.TaskScoringCallback;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.mikepenz.materialdrawer.interfaces.OnCheckedChangeListener;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
|
@ -27,6 +34,7 @@ public abstract class BaseFragment extends Fragment {
|
|||
|
||||
public MainActivity activity;
|
||||
public TabLayout tabLayout;
|
||||
public FrameLayout floatingMenuWrapper;
|
||||
public APIHelper mAPIHelper;
|
||||
protected HabitRPGUser user;
|
||||
public boolean usesTabLayout;
|
||||
|
|
@ -44,6 +52,10 @@ public abstract class BaseFragment extends Fragment {
|
|||
this.tabLayout = tabLayout;
|
||||
}
|
||||
|
||||
public void setFloatingMenuWrapper(FrameLayout view) {
|
||||
this.floatingMenuWrapper = view;
|
||||
}
|
||||
|
||||
public void setActivity(MainActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
|
@ -66,6 +78,10 @@ public abstract class BaseFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
if (floatingMenuWrapper != null) {
|
||||
floatingMenuWrapper.removeAllViews();
|
||||
}
|
||||
|
||||
// Receive Events
|
||||
try {
|
||||
EventBus.getDefault().register(this);
|
||||
|
|
@ -94,4 +110,6 @@ public abstract class BaseFragment extends Fragment {
|
|||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import android.view.ViewGroup;
|
|||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
@ -81,10 +82,6 @@ import retrofit.client.Response;
|
|||
|
||||
public class TasksFragment extends BaseFragment implements TaskScoringCallback.OnTaskScored, OnCheckedChangeListener {
|
||||
|
||||
public enum SnackbarDisplayType {
|
||||
NORMAL, FAILURE, DROP
|
||||
}
|
||||
|
||||
static final int TASK_CREATED_RESULT = 1;
|
||||
static final int TASK_UPDATED_RESULT = 2;
|
||||
|
||||
|
|
@ -116,29 +113,30 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
|
||||
|
||||
viewPager = (ViewPager) v.findViewById(R.id.view_pager);
|
||||
floatingMenu = (FloatingActionMenu) v.findViewById(R.id.fab_menu);
|
||||
FloatingActionButton habit_fab = (FloatingActionButton) v.findViewById(R.id.fab_new_habit);
|
||||
FrameLayout frame = (FrameLayout) inflater.inflate(R.layout.floating_menu_tasks, floatingMenuWrapper, true);
|
||||
floatingMenu = (FloatingActionMenu) frame.findViewById(R.id.fab_menu);
|
||||
FloatingActionButton habit_fab = (FloatingActionButton) floatingMenu.findViewById(R.id.fab_new_habit);
|
||||
habit_fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openNewTaskActivity("habit");
|
||||
}
|
||||
});
|
||||
FloatingActionButton daily_fab = (FloatingActionButton) v.findViewById(R.id.fab_new_daily);
|
||||
FloatingActionButton daily_fab = (FloatingActionButton) floatingMenu.findViewById(R.id.fab_new_daily);
|
||||
daily_fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openNewTaskActivity("daily");
|
||||
}
|
||||
});
|
||||
FloatingActionButton todo_fab = (FloatingActionButton) v.findViewById(R.id.fab_new_todo);
|
||||
FloatingActionButton todo_fab = (FloatingActionButton) floatingMenu.findViewById(R.id.fab_new_todo);
|
||||
todo_fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openNewTaskActivity("todo");
|
||||
}
|
||||
});
|
||||
FloatingActionButton reward_fab = (FloatingActionButton) v.findViewById(R.id.fab_new_reward);
|
||||
FloatingActionButton reward_fab = (FloatingActionButton) floatingMenu.findViewById(R.id.fab_new_reward);
|
||||
reward_fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
@ -352,7 +350,7 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
notifyUser(data.getExp(), data.getHp(), data.getGp(), data.getLvl(), data.getDelta());
|
||||
if (data.get_tmp() != null) {
|
||||
if (data.get_tmp().getDrop() != null) {
|
||||
showSnackbar(data.get_tmp().getDrop().getDialog(), SnackbarDisplayType.DROP);
|
||||
activity.showSnackbar(data.get_tmp().getDrop().getDialog(), MainActivity.SnackbarDisplayType.DROP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -377,32 +375,14 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
|
||||
// endregion
|
||||
|
||||
private void showSnackbar(String content) {
|
||||
showSnackbar(content, SnackbarDisplayType.NORMAL);
|
||||
}
|
||||
|
||||
private void showSnackbar(String content, SnackbarDisplayType displayType) {
|
||||
Snackbar snackbar = Snackbar.make(floatingMenu, content, Snackbar.LENGTH_LONG);
|
||||
View snackbarView = snackbar.getView();
|
||||
|
||||
if (displayType == SnackbarDisplayType.FAILURE) {
|
||||
|
||||
//change Snackbar's background color;
|
||||
snackbarView.setBackgroundColor(ContextCompat.getColor(activity, R.color.worse_10));
|
||||
} else if (displayType == SnackbarDisplayType.DROP) {
|
||||
TextView tv = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
|
||||
tv.setMaxLines(5);
|
||||
snackbarView.setBackgroundColor(ContextCompat.getColor(activity, R.color.best_10));
|
||||
}
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
//region Events
|
||||
|
||||
public void onEvent(CreateTagCommand event) {
|
||||
Tag t = new Tag();
|
||||
t.setName(event.tagName);
|
||||
t.save();
|
||||
t.async().save();
|
||||
|
||||
mAPIHelper.apiService.createTag(t, new Callback<List<Tag>>() {
|
||||
@Override
|
||||
|
|
@ -412,7 +392,7 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
showSnackbar("Error: " + error.getMessage(), SnackbarDisplayType.FAILURE);
|
||||
activity.showSnackbar("Error: " + error.getMessage(), MainActivity.SnackbarDisplayType.FAILURE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -449,7 +429,7 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
final String rewardKey = event.Reward.getId();
|
||||
|
||||
if (user.getStats().getGp() < event.Reward.getValue()) {
|
||||
showSnackbar("Not enough Gold", SnackbarDisplayType.FAILURE);
|
||||
activity.showSnackbar("Not enough Gold", MainActivity.SnackbarDisplayType.FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -459,7 +439,7 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
int maxHp = user.getStats().getMaxHealth();
|
||||
|
||||
if (currentHp == maxHp) {
|
||||
showSnackbar("You don't need to buy an health potion", SnackbarDisplayType.FAILURE);
|
||||
activity.showSnackbar("You don't need to buy an health potion", MainActivity.SnackbarDisplayType.FAILURE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -482,12 +462,12 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
break;
|
||||
}
|
||||
|
||||
showSnackbar("Buy Reward Successful " + event.Reward.getText());
|
||||
activity.showSnackbar("Buy Reward Successful " + event.Reward.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
showSnackbar("Buy Reward Error " + event.Reward.getText(), SnackbarDisplayType.FAILURE);
|
||||
activity.showSnackbar("Buy Reward Error " + event.Reward.getText(), MainActivity.SnackbarDisplayType.FAILURE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
@ -517,13 +497,13 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
private void notifyUser(double xp, double hp, double gold,
|
||||
int lvl, double delta) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
SnackbarDisplayType displayType = SnackbarDisplayType.NORMAL;
|
||||
MainActivity.SnackbarDisplayType displayType = MainActivity.SnackbarDisplayType.NORMAL;
|
||||
if (lvl > user.getStats().getLvl()) {
|
||||
displayLevelUpDialog(lvl);
|
||||
|
||||
this.mAPIHelper.retrieveUser(new HabitRPGUserCallback(activity));
|
||||
user.getStats().setLvl((int) lvl);
|
||||
showSnackbar(message.toString());
|
||||
activity.showSnackbar(message.toString());
|
||||
} else {
|
||||
com.magicmicky.habitrpgwrapper.lib.models.Stats stats = user.getStats();
|
||||
|
||||
|
|
@ -532,7 +512,7 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
user.getStats().setExp(xp);
|
||||
}
|
||||
if (hp != stats.getHp()) {
|
||||
displayType = SnackbarDisplayType.FAILURE;
|
||||
displayType = MainActivity.SnackbarDisplayType.FAILURE;
|
||||
message.append(" - ").append(round(stats.getHp() - hp, 2)).append(" HP");
|
||||
user.getStats().setHp(hp);
|
||||
}
|
||||
|
|
@ -540,11 +520,11 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
message.append(" + ").append(round(gold - stats.getGp(), 2)).append(" GP");
|
||||
stats.setGp(gold);
|
||||
} else if (gold < stats.getGp()) {
|
||||
displayType = SnackbarDisplayType.FAILURE;
|
||||
displayType = MainActivity.SnackbarDisplayType.FAILURE;
|
||||
message.append(" - ").append(round(stats.getGp() - gold, 2)).append(" GP");
|
||||
stats.setGp(gold);
|
||||
}
|
||||
showSnackbar(message.toString(), displayType);
|
||||
activity.showSnackbar(message.toString(), displayType);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -691,7 +671,6 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
if (t != null) {
|
||||
tagFilterMap.put(t.getId(), b);
|
||||
filterChangedHandler.hit();
|
||||
showSnackbar(t.getName() + " : " + b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue