loading迁移common

This commit is contained in:
liujing
2020-09-23 19:28:32 +08:00
parent 044edc9e58
commit 1989ea703c
23 changed files with 54 additions and 54 deletions

View File

@@ -24,7 +24,7 @@ import com.mogo.module.v2x.network.V2XRefreshCallback;
import com.mogo.module.v2x.network.V2XShareNetworkModel;
import com.mogo.module.v2x.presenter.ShareEventsPresenter;
import com.mogo.module.v2x.utils.ThreadUtils;
import com.mogo.module.v2x.view.V2XNetworkLoadingView;
import com.mogo.module.common.view.NetworkLoadingView;
import java.util.ArrayList;
@@ -39,7 +39,7 @@ public class V2XShareEventsFragment extends MvpFragment<V2XShareEventsFragment,
private V2XShareNetworkModel v2XShareNetworkModel;
//动画
private V2XNetworkLoadingView loadingView;
private NetworkLoadingView loadingView;
@Override
protected int getLayoutId() {
@@ -182,9 +182,13 @@ public class V2XShareEventsFragment extends MvpFragment<V2XShareEventsFragment,
private void animatioonAcction(int visible) {
if (visible == View.VISIBLE) {
loadingView.start();
if (loadingView != null) {
loadingView.start();
}
} else {
loadingView.stop();
if (loadingView != null) {
loadingView.stop();
}
}
}

View File

@@ -15,7 +15,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -39,11 +38,8 @@ import com.mogo.module.v2x.adapter.V2XSurroundingAdapter;
import com.mogo.module.v2x.entity.panel.SurroundingConstruction;
import com.mogo.module.v2x.listener.SurroundingItemClickListener;
import com.mogo.module.v2x.presenter.SurroundingEventPresenter;
import com.mogo.module.v2x.utils.animation.AnimationResources;
import com.mogo.module.v2x.utils.animation.V2XAnimationManager;
import com.mogo.module.v2x.view.SurroundingEventView;
import com.mogo.module.v2x.view.SurroundingMarginDecoration;
import com.mogo.module.v2x.view.V2XNetworkLoadingView;
import com.mogo.module.common.view.NetworkLoadingView;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.utils.WorkThreadHandler;
@@ -75,7 +71,7 @@ public class V2XSurroundingFragment extends MvpFragment<SurroundingEventView, Su
private SurroundingEventPresenter surroundingEventPresenter;
private List<SurroundingConstruction> poiInfosList = new ArrayList<>();
private IMogoServiceApis mApis;
private V2XNetworkLoadingView mloadingImage;
private NetworkLoadingView mloadingImage;
@Override

View File

@@ -1,9 +0,0 @@
package com.mogo.module.v2x.utils.animation;
interface Animation {
void start();
void stop();
}

View File

@@ -1,36 +0,0 @@
package com.mogo.module.v2x.utils.animation;
import com.mogo.module.v2x.R;
public class AnimationResources {
public static final int loadingRes[] = {
// R.drawable.v_to_x_loading_car0000,
// R.drawable.v_to_x_loading_car0002,
// R.drawable.v_to_x_loading_car0004,
// R.drawable.v_to_x_loading_car0006,
// R.drawable.v_to_x_loading_car0008,
// R.drawable.v_to_x_loading_car0010,
// R.drawable.v_to_x_loading_car0012,
// R.drawable.v_to_x_loading_car0014,
// R.drawable.v_to_x_loading_car0016,
// R.drawable.v_to_x_loading_car0018,
// R.drawable.v_to_x_loading_car0020,
// R.drawable.v_to_x_loading_car0022,
// R.drawable.v_to_x_loading_car0024,
// R.drawable.v_to_x_loading_car0025,
// R.drawable.v_to_x_loading_car0027,
// R.drawable.v_to_x_loading_car0029,
// R.drawable.v_to_x_loading_car0031,
// R.drawable.v_to_x_loading_car0033,
// R.drawable.v_to_x_loading_car0035,
// R.drawable.v_to_x_loading_car0037,
// R.drawable.v_to_x_loading_car0039,
// R.drawable.v_to_x_loading_car0041,
// R.drawable.v_to_x_loading_car0043,
// R.drawable.v_to_x_loading_car0045,
// R.drawable.v_to_x_loading_car0047,
// R.drawable.v_to_x_loading_car0048,
};
}

View File

@@ -1,27 +0,0 @@
package com.mogo.module.v2x.utils.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();
}
}
}

View File

@@ -1,71 +0,0 @@
package com.mogo.module.v2x.utils.animation;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
public class V2XAnimationManager implements Animation {
private static final String TAG = "V2XAnimationManager";
private ProgressBar targetImageView;
private boolean isStarted = false;
private int mStartIndex = 0;
private final static int MSG_LOOP = 3004;
private long INTERVAL = 100L;
private Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case MSG_LOOP:
if (isStarted) {
// targetImageView.setImageResource( AnimationResources.loadingRes[mStartIndex++ % AnimationResources.loadingRes.length] );
mHandler.sendEmptyMessageDelayed(MSG_LOOP, INTERVAL);
}
break;
}
}
};
public void animationWithTarget(ProgressBar imageView, int[] resources, int duration) {
targetImageView = imageView;
INTERVAL = duration;
start();
}
@Override
synchronized public void start() {
isStarted = true;
mHandler.sendEmptyMessage(MSG_LOOP);
if (targetImageView != null) {
targetImageView.setVisibility(View.VISIBLE);
}
}
@Override
synchronized public void stop() {
isStarted = false;
mHandler.removeMessages(MSG_LOOP);
if (targetImageView != null) {
targetImageView.setVisibility(View.INVISIBLE);
}
}
public void soptWithError() {
stop();
if (targetImageView != null) {
targetImageView.setVisibility(View.VISIBLE);
}
}
public void release() {
stop();
}
}

View File

@@ -1,97 +0,0 @@
package com.mogo.module.v2x.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.utils.animation.AnimationResources;
import com.mogo.module.v2x.utils.animation.V2XAnimationManager;
public class V2XNetworkLoadingView extends RelativeLayout {
private ProgressBar loadView;
private TextView textView;
private V2XAnimationManager v2XAnimationManager;
public Button refresButton;
private String loadingText = "正在获取信息…";
public V2XNetworkLoadingView(Context context) {
super(context);
}
public V2XNetworkLoadingView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.v2x_network_loading_item, this);
initView();
/*
添加动画图片资源
* */
setLoadingImage(AnimationResources.loadingRes);
}
public V2XNetworkLoadingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void initView() {
v2XAnimationManager = new V2XAnimationManager();
loadView = findViewById(R.id.loading_imageview);
textView = findViewById(R.id.loading_text);
refresButton = findViewById(R.id.refresh_button);
}
public void setLoadingText(String text) {
if (textView != null) {
textView.setText(text);
}
}
public void setLoadingImage(int[] resources) {
v2XAnimationManager.animationWithTarget(loadView, resources, 100);
}
public void start() {
if (v2XAnimationManager != null) {
v2XAnimationManager.start();
this.setVisibility(View.VISIBLE);
}
if (refresButton != null) {
refresButton.setVisibility(GONE);
}
if (textView != null) {
textView.setText(loadingText);
}
}
public void stop() {
if (v2XAnimationManager != null) {
v2XAnimationManager.stop();
this.setVisibility(GONE);
}
}
public void stopWithError(String errormsg, int showRefreshButton) {
if (v2XAnimationManager != null) {
v2XAnimationManager.soptWithError();
}
if (textView != null) {
textView.setText(errormsg);
}
if (refresButton != null) {
refresButton.setVisibility(showRefreshButton);
}
}
}