rename,动画隐藏

This commit is contained in:
liujing
2020-08-03 11:06:58 +08:00
parent 556b5f22d7
commit 6f0c69fc3c
13 changed files with 30 additions and 26 deletions

View File

@@ -25,14 +25,14 @@ import com.mogo.utils.DateTimeUtils;
import java.util.ArrayList;
public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public class V2XShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
private ArrayList dataArrayList;
private final LayoutInflater shareLayoutInflater;
private IMogoServiceApis mApis;
private AdapterCallback callback;
public ShareEventAdapter(Context context, ArrayList dataArrayList, AdapterCallback callback) {
public V2XShareEventAdapter(Context context, ArrayList dataArrayList, AdapterCallback callback) {
this.context = context;
this.dataArrayList = dataArrayList;
this.callback = callback;
@@ -45,22 +45,22 @@ public class ShareEventAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
//根据viewType创建自定义布局
if (viewType == ShareEventItemEnum.ITEM_TYPE_NUM_DES) {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_description, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_description, parent,
false);
shareDescriptionViewHolder holder = new shareDescriptionViewHolder(v);
return holder;
} else if (viewType == ShareEventItemEnum.ITEM_TYPE_SHARE_LIST) {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_item, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_item, parent,
false);
shareItemViewHolder holder = new shareItemViewHolder(v);
return holder;
} else if (viewType == ShareEventItemEnum.ITEM_TYPE_SHARE_EMPTY) {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_empty, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_empty, parent,
false);
shareEmptyViewHolder holder = new shareEmptyViewHolder(v);
return holder;
} else {
View v = shareLayoutInflater.inflate(R.layout.module_event_panel_share_load_status, parent,
View v = shareLayoutInflater.inflate(R.layout.module_v2x_event_share_load_status, parent,
false);
shareLoadStatusViewHolder holder = new shareLoadStatusViewHolder(v);
return holder;

View File

@@ -14,7 +14,7 @@ import com.mogo.module.v2x.R;
public class ScenarioHistoryIllegalParkVH extends V2XBaseViewHolder<V2XHistoryScenarioData> {
public ScenarioHistoryIllegalParkVH(@NonNull ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.module_event_panel_share_item, viewGroup, false));
.inflate(R.layout.module_v2x_event_share_item, viewGroup, false));
}
@Override

View File

@@ -56,7 +56,7 @@ class EventPanelFragment : MvpFragment<EventPanelFragment, EventPanelPresenter>(
fragments = arrayOf(
ScenarioHistoryFragment(),
SurroundingEventFragment(),
ShareEventsFragment()
V2XShareEventsFragment()
)
//禁用预加载
vpEventPanel.offscreenPageLimit = ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT

View File

@@ -10,7 +10,7 @@ class MyShareFragment : MvpFragment<MyShareFragment, MySharePresenter>() {
*
* @return
*/
override fun getLayoutId(): Int = R.layout.module_event_panel_share_item
override fun getLayoutId(): Int = R.layout.module_v2x_event_share_item
/**
* 初始化控件必须在初始化完成之后才可以实例化presenter避免

View File

@@ -16,7 +16,7 @@ import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.commons.network.SubscribeImpl;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.adapter.ShareEventAdapter;
import com.mogo.module.v2x.adapter.V2XShareEventAdapter;
import com.mogo.module.v2x.entity.panel.ShareEventDescription;
import com.mogo.module.v2x.entity.panel.ShareEventItem;
import com.mogo.module.v2x.entity.panel.ShareEventItemEnum;
@@ -26,7 +26,7 @@ import com.mogo.module.v2x.network.EventApiService;
import com.mogo.module.v2x.network.HttpConstant;
import com.mogo.module.v2x.network.ShareEventParameter;
import com.mogo.module.v2x.presenter.ShareEventsPresenter;
import com.mogo.module.v2x.utils.animation.AnimationManager;
import com.mogo.module.v2x.utils.animation.V2XAnimationManager;
import com.mogo.module.v2x.utils.animation.AnimationResources;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.network.IMogoNetwork;
@@ -40,11 +40,11 @@ import java.util.concurrent.CountDownLatch;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public class ShareEventsFragment extends MvpFragment implements AdapterCallback {
public class V2XShareEventsFragment extends MvpFragment implements AdapterCallback {
private static final String TAG = "ShareEventsFragment";
private RecyclerView recyclerView;
private ShareEventAdapter adapter;
private V2XShareEventAdapter adapter;
private ArrayList dataArrayList = new ArrayList();
private EventApiService eventApiService;
private int pageNum = 1;
@@ -53,18 +53,18 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
//动画
private ImageView loadingImageView;
private AnimationManager animationHandler;
private V2XAnimationManager v2XAnimationManager;
@Override
protected int getLayoutId() {
return R.layout.module_event_panel_share_recylerview;
return R.layout.module_v2x_event_share_recylerview;
}
@Override
protected void initViews() {
network = (IMogoNetwork) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_NETWORK).navigation(getContext());
eventApiService = network.create(EventApiService.class, HttpConstant.Companion.getNetHost());
animationHandler = new AnimationManager();
v2XAnimationManager = new V2XAnimationManager();
initRecyclerView();
initData();
}
@@ -78,7 +78,7 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
private void initRecyclerView() {
recyclerView = mRootView.findViewById(R.id.road_case_share_list);
adapter = new ShareEventAdapter(getActivity(), dataArrayList, this);
adapter = new V2XShareEventAdapter(getActivity(), dataArrayList, this);
recyclerView.setAdapter(adapter);
LinearLayoutManager linearLayoutManager =
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
@@ -87,7 +87,7 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
private void initData() {
loadingImageView = mRootView.findViewById(R.id.loading_imageview);
animationHandler.animationWithTarget(loadingImageView, AnimationResources.loadingRes,300);
v2XAnimationManager.animationWithTarget(loadingImageView, AnimationResources.loadingRes,100);
getShareEventDescription();
getShareEventList(pageNum, 10);
}
@@ -131,7 +131,7 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
ShareEventParameter parameter = new ShareEventParameter("ZD802B1932L00622", page, 10);
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("data", GsonUtil.jsonFromObject(parameter));
v2XAnimationManager.start();
eventApiService.getShareEventList(parameters)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@@ -174,7 +174,7 @@ public class ShareEventsFragment extends MvpFragment implements AdapterCallback
}
adapter.notifyDataSetChanged();
countDownLatch.countDown();
animationHandler.stop();
v2XAnimationManager.stop();
}
@Override

View File

@@ -2,10 +2,10 @@ package com.mogo.module.v2x.presenter;
import com.mogo.commons.mvp.IView;
import com.mogo.commons.mvp.Presenter;
import com.mogo.module.v2x.fragment.ShareEventsFragment;
import com.mogo.module.v2x.fragment.V2XShareEventsFragment;
public class ShareEventsPresenter extends Presenter <ShareEventsFragment>{
public class ShareEventsPresenter extends Presenter <V2XShareEventsFragment>{
public ShareEventsPresenter(IView view) {
super((ShareEventsFragment) view);
super((V2XShareEventsFragment) view);
}
}

View File

@@ -1,12 +1,13 @@
package com.mogo.module.v2x.utils.animation;
import android.graphics.drawable.AnimationDrawable;
import android.view.View;
import android.widget.ImageView;
import com.mogo.utils.ThreadPoolService;
import com.mogo.utils.UiThreadHandler;
public class AnimationManager implements Animation {
public class V2XAnimationManager implements Animation {
private ImageView targetImageView;
private Animation delegate;
@@ -22,6 +23,7 @@ public class AnimationManager implements Animation {
UiThreadHandler.post(() -> {
targetImageView.setBackground(drawable);
delegate = new DelegateDrawable(drawable);
start();
});
});
@@ -30,6 +32,7 @@ public class AnimationManager implements Animation {
@Override
synchronized public void start() {
if (delegate != null && !isStarted) {
targetImageView.setVisibility(View.VISIBLE);
isStarted = true;
delegate.start();
}
@@ -40,6 +43,7 @@ public class AnimationManager implements Animation {
if (delegate != null && isStarted) {
isStarted = false;
delegate.stop();
targetImageView.setVisibility(View.INVISIBLE);
}
}

View File

@@ -9,6 +9,6 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/module_event_panel_share_item" />
tools:listitem="@layout/module_v2x_event_share_item" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -13,7 +13,7 @@
android:overScrollMode="never"
android:background="#000000"
tools:itemCount="1"
tools:listitem="@layout/module_event_panel_share_description"
tools:listitem="@layout/module_v2x_event_share_description"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" >
</androidx.recyclerview.widget.RecyclerView>