diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java
index 0ae29eaf50..70031c1331 100644
--- a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java
+++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/fragment/ShareEventsFragment.java
@@ -5,6 +5,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -29,6 +30,8 @@ import com.zhidao.mogo.module.event.panel.network.HostConstant;
import com.zhidao.mogo.module.event.panel.network.EventApiService;
import com.zhidao.mogo.module.event.panel.network.ShareEventParameter;
import com.zhidao.mogo.module.event.panel.presenter.ShareEventsPresenter;
+import com.zhidao.mogo.module.event.panel.util.animation.AnimationManager;
+import com.zhidao.mogo.module.event.panel.util.animation.AnimationResources;
import java.util.ArrayList;
import java.util.HashMap;
@@ -47,6 +50,11 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
private EventApiService eventApiService;
private int pageNum = 1;
final CountDownLatch countDownLatch = new CountDownLatch(2);
+ private IMogoNetwork network;
+
+ //动画
+ private ImageView loadingImageView;
+ private AnimationManager animationHandler;
@Override
protected int getLayoutId() {
@@ -55,6 +63,9 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
@Override
protected void initViews() {
+ network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getContext());
+ eventApiService = network.create(EventApiService.class, HostConstant.getNetHost());
+ animationHandler = new AnimationManager();
initRecyclerView();
initData();
}
@@ -76,9 +87,8 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
}
private void initData() {
- IMogoNetwork network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getContext());
- this.eventApiService = network.create(EventApiService.class, HostConstant.getNetHost());
-
+ loadingImageView = mRootView.findViewById(R.id.loading_imageview);
+ animationHandler.animationWithTarget(loadingImageView, AnimationResources.loadingRes,300);
getShareEventDescription();
getShareEventList(pageNum, 10);
}
@@ -101,7 +111,6 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
if (resultData != null && resultData.getResult() != null
&& resultData.getResult().getEnthusiasmIndex() != null) {
dataArrayList.add(resultData.getResult().getEnthusiasmIndex());
- adapter.notifyDataSetChanged();
Log.d(TAG, "热心指数---:" + resultData.getResult().getEnthusiasmIndex());
}
countDownLatch.countDown();
@@ -162,11 +171,11 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
} else {
//空白
item.setViewType(ShareEventItemEnum.ITEM_TYPE_SHARE_EMPTY);
-
dataArrayList.add(item);
}
adapter.notifyDataSetChanged();
countDownLatch.countDown();
+ animationHandler.stop();
}
@Override
diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/Animation.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/Animation.java
new file mode 100644
index 0000000000..4e1a3a0ce5
--- /dev/null
+++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/Animation.java
@@ -0,0 +1,9 @@
+package com.zhidao.mogo.module.event.panel.util.animation;
+
+interface Animation {
+
+ void start();
+
+ void stop();
+
+}
diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/AnimationManager.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/AnimationManager.java
new file mode 100644
index 0000000000..3fa896dbb2
--- /dev/null
+++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/AnimationManager.java
@@ -0,0 +1,47 @@
+package com.zhidao.mogo.module.event.panel.util.animation;
+
+import android.graphics.drawable.AnimationDrawable;
+import android.widget.ImageView;
+
+import com.mogo.utils.ThreadPoolService;
+import com.mogo.utils.UiThreadHandler;
+
+public class AnimationManager implements Animation {
+
+ private ImageView targetImageView;
+ private Animation delegate;
+ private boolean isStarted = false;
+
+ public void animationWithTarget(ImageView imageView, int[] resources, int duration) {
+ targetImageView = imageView;
+ ThreadPoolService.execute(() -> {
+ final AnimationDrawable drawable = new AnimationDrawable();
+ for (int i = 0; i < resources.length; i++) {
+ drawable.addFrame(targetImageView.getResources().getDrawable(resources[i]), duration);
+ }
+ UiThreadHandler.post(() -> {
+ targetImageView.setBackground(drawable);
+ delegate = new DelegateDrawable(drawable);
+ });
+ });
+
+ }
+
+ synchronized public void start() {
+ if (delegate != null && !isStarted) {
+ isStarted = true;
+ delegate.start();
+ }
+ }
+
+ synchronized public void stop() {
+ if (delegate != null && isStarted) {
+ isStarted = false;
+ delegate.stop();
+ }
+ }
+
+ public void release() {
+ delegate = null;
+ }
+}
diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/AnimationResources.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/AnimationResources.java
new file mode 100644
index 0000000000..5e38307a31
--- /dev/null
+++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/AnimationResources.java
@@ -0,0 +1,11 @@
+package com.zhidao.mogo.module.event.panel.util.animation;
+
+import com.zhidao.mogo.module.event.panel.R;
+
+public class AnimationResources {
+ public static final int loadingRes[] = {
+ R.drawable.icon_enthusiasm_choose,
+ R.drawable.icon_enthusiasm_unchoose,
+ };
+
+}
diff --git a/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/DelegateDrawable.java b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/DelegateDrawable.java
new file mode 100644
index 0000000000..272b9c31e2
--- /dev/null
+++ b/modules/mogo-module-event-panel/src/main/java/com/zhidao/mogo/module/event/panel/util/animation/DelegateDrawable.java
@@ -0,0 +1,27 @@
+package com.zhidao.mogo.module.event.panel.util.animation;
+
+import android.graphics.drawable.AnimationDrawable;
+
+public class DelegateDrawable implements Animation {
+
+ private AnimationDrawable drawable;
+
+ public DelegateDrawable(AnimationDrawable drawable) {
+ this.drawable = drawable;
+ }
+
+
+ @Override
+ public void start() {
+ if (drawable != null) {
+ drawable.start();
+ }
+ }
+
+ @Override
+ public void stop() {
+ if (drawable != null) {
+ drawable.stop();
+ }
+ }
+}
diff --git a/modules/mogo-module-event-panel/src/main/res/layout/module_event_panel_share_recylerview.xml b/modules/mogo-module-event-panel/src/main/res/layout/module_event_panel_share_recylerview.xml
index 6d61dcb641..d005968276 100644
--- a/modules/mogo-module-event-panel/src/main/res/layout/module_event_panel_share_recylerview.xml
+++ b/modules/mogo-module-event-panel/src/main/res/layout/module_event_panel_share_recylerview.xml
@@ -1,14 +1,29 @@
-
+ android:layout_height="match_parent" >
+
+
+
+
+
+
+
+