mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Rotate refresh icon when refreshing. Fixes #65
This commit is contained in:
parent
cab560ee88
commit
02c2123088
4 changed files with 40 additions and 1 deletions
8
Habitica/res/anim/clockwise_rotate.xml
Normal file
8
Habitica/res/anim/clockwise_rotate.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:fromDegrees="0"
|
||||
android:toDegrees="360"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:duration="1000"
|
||||
android:interpolator="@android:anim/linear_interpolator" />
|
||||
6
Habitica/res/layout/refresh_actionview.xml
Normal file
6
Habitica/res/layout/refresh_actionview.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_refresh_white"
|
||||
style="@style/Widget.AppCompat.ActionButton"/>
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
android:title="@string/action_refresh"
|
||||
android:orderInCategory="103"
|
||||
app:showAsAction="ifRoom"
|
||||
android:actionViewClass="android.widget.ImageButton"
|
||||
/>
|
||||
|
||||
</menu>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.databinding.DataBindingUtil;
|
||||
|
|
@ -18,6 +19,8 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -88,6 +91,8 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
public ViewPager viewPager;
|
||||
Drawer filterDrawer;
|
||||
|
||||
MenuItem refreshItem;
|
||||
|
||||
private MaterialDialog faintDialog;
|
||||
|
||||
FloatingActionMenu floatingMenu;
|
||||
|
|
@ -178,13 +183,28 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
filterDrawer.openDrawer();
|
||||
return true;
|
||||
case R.id.action_reload:
|
||||
mAPIHelper.retrieveUser(new HabitRPGUserCallback(activity));
|
||||
refreshItem = item;
|
||||
refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
/* Attach a rotating ImageView to the refresh item as an ActionView */
|
||||
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
ImageView iv = (ImageView) inflater.inflate(R.layout.refresh_actionview, null);
|
||||
|
||||
Animation rotation = AnimationUtils.loadAnimation(getActivity(), R.anim.clockwise_rotate);
|
||||
rotation.setRepeatCount(Animation.INFINITE);
|
||||
iv.startAnimation(rotation);
|
||||
|
||||
refreshItem.setActionView(iv);
|
||||
|
||||
mAPIHelper.retrieveUser(new HabitRPGUserCallback(activity));
|
||||
}
|
||||
|
||||
public void loadTaskLists() {
|
||||
android.support.v4.app.FragmentManager fragmentManager = getChildFragmentManager();
|
||||
|
||||
|
|
@ -307,6 +327,10 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
|
|||
|
||||
public void updateUserData(HabitRPGUser user) {
|
||||
super.updateUserData(user);
|
||||
if (refreshItem != null) {
|
||||
refreshItem.getActionView().clearAnimation();
|
||||
refreshItem.setActionView(null);
|
||||
}
|
||||
if (this.user != null) {
|
||||
FillTagFilterDrawer(user.getTags());
|
||||
TaskRecyclerViewFragment fragment = ViewFragmentsDictionary.get(2);
|
||||
|
|
|
|||
Loading…
Reference in a new issue