Merge branch 'anim' into dev_1.1.2
This commit is contained in:
@@ -5,8 +5,6 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -24,11 +22,10 @@ import com.mogo.module.v2x.listener.AdapterCallback;
|
||||
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.animation.V2XAnimationManager;
|
||||
import com.mogo.module.v2x.utils.animation.AnimationResources;
|
||||
import com.mogo.module.v2x.view.V2XNetworkLoadingView;
|
||||
import com.mogo.utils.CheckUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class V2XShareEventsFragment extends MvpFragment implements AdapterCallback {
|
||||
|
||||
@@ -37,13 +34,10 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
private V2XShareEventAdapter adapter;
|
||||
private ArrayList dataArrayList = new ArrayList();
|
||||
private int pageNum = 1;
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
private V2XShareNetworkModel v2XShareNetworkModel;
|
||||
|
||||
//动画
|
||||
private ImageView loadingImageView;
|
||||
private V2XAnimationManager v2XAnimationManager;
|
||||
private Button reloadBUtton;
|
||||
private V2XNetworkLoadingView loadingView;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -53,7 +47,6 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
@Override
|
||||
protected void initViews() {
|
||||
v2XShareNetworkModel = new V2XShareNetworkModel(getContext());
|
||||
v2XAnimationManager = new V2XAnimationManager();
|
||||
initRecyclerView();
|
||||
initData();
|
||||
}
|
||||
@@ -72,11 +65,11 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
LinearLayoutManager linearLayoutManager =
|
||||
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
loadingView = mRootView.findViewById(R.id.network_loading_imageview);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
loadingImageView = mRootView.findViewById(R.id.loading_imageview);
|
||||
v2XAnimationManager.animationWithTarget(loadingImageView, AnimationResources.loadingRes, 100);
|
||||
loadingView.start();
|
||||
getShareEventResponse();
|
||||
}
|
||||
|
||||
@@ -84,6 +77,9 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
* 获取热心指数,分享列表等分享内容
|
||||
* */
|
||||
private void getShareEventResponse() {
|
||||
if (CheckUtils.isNetworkConnected(getContext()) == false) {
|
||||
Log.d(TAG, "网络异常");
|
||||
}
|
||||
v2XShareNetworkModel.getShareEventResponse(pageNum, 10, new V2XRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
@@ -102,7 +98,7 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
loadingError(true);
|
||||
// loadingError(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -148,40 +144,17 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
dataArrayList.add(item);
|
||||
}
|
||||
adapter.notifyDataSetChanged();
|
||||
v2XAnimationManager.stop();
|
||||
animatioonAcction(View.INVISIBLE);
|
||||
}
|
||||
|
||||
/*
|
||||
* error界面
|
||||
* */
|
||||
private void loadingError(boolean error) {
|
||||
reloadBUtton = mRootView.findViewById(R.id.loading_error);
|
||||
if (error) {
|
||||
reloadBUtton.setVisibility(View.VISIBLE);
|
||||
reloadBUtton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
v2XShareNetworkModel.getShareEventList(pageNum, 10, new V2XRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
loadSuccessWithShareEventList(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
reloadBUtton.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
private void animatioonAcction(int visible) {
|
||||
if (visible == View.VISIBLE) {
|
||||
loadingView.start();
|
||||
} else {
|
||||
|
||||
loadingView.stop();
|
||||
}
|
||||
v2XAnimationManager.stop();
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected ShareEventsPresenter createPresenter() {
|
||||
@@ -191,9 +164,9 @@ public class V2XShareEventsFragment extends MvpFragment implements AdapterCallba
|
||||
|
||||
@Override
|
||||
public void loadMoreShareEventList() {
|
||||
Log.d(TAG,"page--"+pageNum);
|
||||
v2XAnimationManager.start();
|
||||
pageNum+=1;
|
||||
Log.d(TAG, "page--" + pageNum);
|
||||
animatioonAcction(View.VISIBLE);
|
||||
pageNum += 1;
|
||||
v2XShareNetworkModel.getShareEventList(pageNum, 10, new V2XRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.module.v2x.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
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 ImageView loadView;
|
||||
private TextView textView;
|
||||
private V2XAnimationManager v2XAnimationManager;
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (v2XAnimationManager != null) {
|
||||
v2XAnimationManager.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -85,7 +85,8 @@
|
||||
android:gravity="center_horizontal|top"
|
||||
android:text="车友认同次数"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16px"/>
|
||||
android:textSize="16px"
|
||||
android:paddingBottom="22px"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/road_case_share_list"
|
||||
@@ -11,26 +11,21 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:overScrollMode="never"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" >
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"></androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/loading_error"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="重新加载"
|
||||
android:visibility="gone"
|
||||
android:textSize="30sp">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
</Button>
|
||||
<com.mogo.module.v2x.view.V2XNetworkLoadingView
|
||||
android:id="@+id/network_loading_imageview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<ImageView
|
||||
android:layout_height="200px"
|
||||
android:layout_width="200px"
|
||||
android:id="@+id/loading_imageview"
|
||||
android:layout_centerInParent="true" >
|
||||
</ImageView>
|
||||
</com.mogo.module.v2x.view.V2XNetworkLoadingView>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/loading_liner_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/loading_imageview"
|
||||
android:layout_width="200px"
|
||||
android:layout_height="200px"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/v_to_x_loading_car0000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loading_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/loading_text"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="top|center"
|
||||
android:paddingTop="25px"
|
||||
android:alpha="0.7"
|
||||
android:text="正在获取信息…"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18px" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
Reference in New Issue
Block a user