细节修复、部分bug修复

This commit is contained in:
huangzhuanghua
2016-09-20 18:29:19 +08:00
parent 471afcf0be
commit 384af8a9db
34 changed files with 1176 additions and 1480 deletions

View File

@ -4,8 +4,6 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.AbsListView;
import com.gh.base.BaseFragment;
import com.gh.common.util.DisplayUtils;
@ -15,13 +13,9 @@ import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBMoveTop;
import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBSlide;
import de.greenrobot.event.EventBus;
/**
* Created by LGT on 2016/8/12.
@ -32,10 +26,6 @@ public class InstallFragment extends BaseFragment {
private LinearLayoutManager linearLayoutManager;
private InstallFragmentAdapter adapter;
private int topMargin;
private int dis;
private int distance;
private boolean isEverpause;
private DataWatcher dataWatcher = new DataWatcher() {
@ -62,52 +52,11 @@ public class InstallFragment extends BaseFragment {
init(R.layout.fm_install);
topMargin = 0;
dis = 0;
distance = DisplayUtils.dip2px(getActivity(), 230)
- DisplayUtils.getInternalDimensionSize(getActivity().getResources(), "status_bar_height");
fm_install_rv_show.setHasFixedSize(true);
linearLayoutManager = new LinearLayoutManager(getActivity());
fm_install_rv_show.setLayoutManager(linearLayoutManager);
adapter = new InstallFragmentAdapter(getActivity(), fm_install_rv_show);
fm_install_rv_show.setAdapter(adapter);
fm_install_rv_show.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibility;
if (linearLayoutManager.findFirstVisibleItemPosition() >= 1) {
visibility = View.VISIBLE;
} else {
visibility = View.GONE;
}
dis += dy;
topMargin -= dy;
EventBus.getDefault().post(new EBMoveTop("top", visibility, topMargin));
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
if (dis > distance) {
EventBus.getDefault().post(new EBSlide(distance, 1, false));
} else if (dis < -distance) {
EventBus.getDefault().post(new EBSlide(0, 1, false));
} else {
EventBus.getDefault().post(new EBSlide(dis, 1, false));
}
}
}
});
}
//连接上网络事件
@ -139,29 +88,6 @@ public class InstallFragment extends BaseFragment {
// }
adapter = new InstallFragmentAdapter(getActivity(), fm_install_rv_show);
fm_install_rv_show.setAdapter(adapter);
EventBus.getDefault().post(new EBMoveTop("top", View.GONE, -topMargin));
EventBus.getDefault().post(new EBSlide(-topMargin, 1, false));
}
public void onEventMainThread(EBSlide busOne) {
if (busOne.getPosition() == 0) {
if (busOne.isReset()) {
fm_install_rv_show.scrollBy(0, distance - dis);
} else {
if (busOne.getDistance() == 0) {
fm_install_rv_show.scrollToPosition(0);
topMargin = 0;
dis = 0;
} else {
fm_install_rv_show.scrollBy(0, busOne.getDistance() - dis);
}
}
} else if (busOne.getPosition() == 0 && busOne.isReset()) {
if (adapter.isEmpty()) {
EventBus.getDefault().post(new EBMoveTop("top", View.GONE, -topMargin));
EventBus.getDefault().post(new EBSlide(-topMargin, 1, false));
}
}
}
@Override