我的光环,无安装、无关注时页面显示逻辑修改
This commit is contained in:
@ -4,6 +4,9 @@ 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.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseFragment;
|
||||
@ -17,6 +20,9 @@ import com.gh.gamecenter.eventbus.EBConcernChanged;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/8/12.
|
||||
@ -27,6 +33,9 @@ public class ConcernFragment extends BaseFragment {
|
||||
|
||||
private RecyclerView fm_concern_rv_show;
|
||||
private ConcernFragmentAdapter adapter;
|
||||
private LinearLayout reuse_nodata_skip;
|
||||
private TextView reuse_nodata_skip_tv_hint;
|
||||
private TextView reuse_nodata_skip_tv_btn;
|
||||
|
||||
private boolean isEverpause;
|
||||
|
||||
@ -52,12 +61,28 @@ public class ConcernFragment extends BaseFragment {
|
||||
|
||||
init(R.layout.fm_concern);
|
||||
|
||||
reuse_nodata_skip.setVisibility(View.GONE);
|
||||
reuse_nodata_skip_tv_hint.setText("暂无关注");
|
||||
reuse_nodata_skip_tv_btn.setText("查看精品推荐");
|
||||
reuse_nodata_skip_tv_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EventBus.getDefault().post(new EBSkip("GameFragment", 1));
|
||||
}
|
||||
});
|
||||
|
||||
fm_concern_rv_show.setHasFixedSize(true);
|
||||
fm_concern_rv_show.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
adapter = new ConcernFragmentAdapter(getActivity(), fm_concern_rv_show);
|
||||
adapter = new ConcernFragmentAdapter(this);
|
||||
fm_concern_rv_show.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEmpty() {
|
||||
fm_concern_rv_show.setVisibility(View.GONE);
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 关注事件
|
||||
public void onEventMainThread(EBConcernChanged changed) {
|
||||
// if (changed.isConcern()) {
|
||||
@ -71,7 +96,9 @@ public class ConcernFragment extends BaseFragment {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
adapter = new ConcernFragmentAdapter(getActivity(), fm_concern_rv_show);
|
||||
fm_concern_rv_show.setVisibility(View.VISIBLE);
|
||||
reuse_nodata_skip.setVisibility(View.GONE);
|
||||
adapter = new ConcernFragmentAdapter(this);
|
||||
fm_concern_rv_show.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
@ -25,11 +25,10 @@ import com.gh.gamecenter.GameDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.NoDataSkipViewHolder;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.listener.OnCallBackListener;
|
||||
import com.gh.gamecenter.manager.ConcernManager;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.GameManager;
|
||||
@ -43,16 +42,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/8/15.
|
||||
*/
|
||||
public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private RecyclerView fm_concern_rv_show;
|
||||
private OnCallBackListener listener;
|
||||
|
||||
private List<ConcernInfo> concernList;
|
||||
private List<GameEntity> gameList;
|
||||
@ -62,15 +58,12 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
private ArrayMap<String, String> nameMap;
|
||||
|
||||
private boolean isRemove;
|
||||
private boolean isEmpty;
|
||||
|
||||
public ConcernFragmentAdapter(Context context, RecyclerView recyclerView) {
|
||||
this.context = context;
|
||||
|
||||
fm_concern_rv_show = recyclerView;
|
||||
public ConcernFragmentAdapter(ConcernFragment fragment) {
|
||||
this.context = fragment.getActivity();
|
||||
this.listener = fragment;
|
||||
|
||||
isRemove = false;
|
||||
isEmpty = false;
|
||||
|
||||
gameList = new ArrayList<>();
|
||||
|
||||
@ -81,7 +74,7 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
concernList = concernManager.getConcernGame();
|
||||
|
||||
if (concernList == null || concernList.isEmpty()) {
|
||||
isEmpty = true;
|
||||
listener.loadEmpty();
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
@ -170,10 +163,6 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
} else if (isEmpty) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.reuse_nodata_skip, parent, false);
|
||||
return new NoDataSkipViewHolder(view);
|
||||
} else {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
@ -185,23 +174,12 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof GameNormalViewHolder && gameList.size() > position) {
|
||||
initGameNormal((GameNormalViewHolder) holder, gameList.get(position), position);
|
||||
} else if (holder instanceof NoDataSkipViewHolder) {
|
||||
NoDataSkipViewHolder viewHolder = (NoDataSkipViewHolder) holder;
|
||||
|
||||
viewHolder.reuse_nodata_skip_tv_hint.setText("暂无关注");
|
||||
viewHolder.reuse_nodata_skip_tv_btn.setText("查看精品推荐");
|
||||
viewHolder.reuse_nodata_skip_tv_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EventBus.getDefault().post(new EBSkip("GameFragment", 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (gameList.isEmpty() && (isEmpty || !isRemove)) {
|
||||
if (gameList.isEmpty() && !isRemove) {
|
||||
return 1;
|
||||
}
|
||||
if (isRemove) {
|
||||
@ -287,7 +265,4 @@ public class ConcernFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
return gameList;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return isEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@ 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.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseFragment;
|
||||
@ -16,6 +19,9 @@ import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.eventbus.EBNetworkState;
|
||||
import com.gh.gamecenter.eventbus.EBPackage;
|
||||
import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/8/12.
|
||||
@ -26,6 +32,9 @@ public class InstallFragment extends BaseFragment {
|
||||
|
||||
private RecyclerView fm_install_rv_show;
|
||||
private InstallFragmentAdapter adapter;
|
||||
private LinearLayout reuse_nodata_skip;
|
||||
private TextView reuse_nodata_skip_tv_hint;
|
||||
private TextView reuse_nodata_skip_tv_btn;
|
||||
|
||||
private boolean isEverpause;
|
||||
|
||||
@ -53,12 +62,28 @@ public class InstallFragment extends BaseFragment {
|
||||
|
||||
init(R.layout.fm_install);
|
||||
|
||||
reuse_nodata_skip.setVisibility(View.GONE);
|
||||
reuse_nodata_skip_tv_hint.setText("暂无游戏");
|
||||
reuse_nodata_skip_tv_btn.setText("查看精品推荐");
|
||||
reuse_nodata_skip_tv_btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EventBus.getDefault().post(new EBSkip("GameFragment", 1));
|
||||
}
|
||||
});
|
||||
|
||||
fm_install_rv_show.setHasFixedSize(true);
|
||||
fm_install_rv_show.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
adapter = new InstallFragmentAdapter(getActivity(), fm_install_rv_show);
|
||||
adapter = new InstallFragmentAdapter(this);
|
||||
fm_install_rv_show.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEmpty() {
|
||||
fm_install_rv_show.setVisibility(View.GONE);
|
||||
reuse_nodata_skip.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//连接上网络事件
|
||||
public void onEventMainThread(EBNetworkState busNetworkState) {
|
||||
if (busNetworkState.isNetworkConnected()) {
|
||||
@ -86,7 +111,9 @@ public class InstallFragment extends BaseFragment {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
adapter = new InstallFragmentAdapter(getActivity(), fm_install_rv_show);
|
||||
fm_install_rv_show.setVisibility(View.VISIBLE);
|
||||
reuse_nodata_skip.setVisibility(View.GONE);
|
||||
adapter = new InstallFragmentAdapter(this);
|
||||
fm_install_rv_show.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
@ -28,12 +28,11 @@ import com.gh.gamecenter.GameDetailActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder;
|
||||
import com.gh.gamecenter.adapter.viewholder.NoDataSkipViewHolder;
|
||||
import com.gh.gamecenter.db.info.ConcernInfo;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameEntity;
|
||||
import com.gh.gamecenter.entity.MyGameInfo;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.gh.gamecenter.listener.OnCallBackListener;
|
||||
import com.gh.gamecenter.manager.ConcernManager;
|
||||
import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
import com.gh.gamecenter.manager.GameManager;
|
||||
@ -49,16 +48,13 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/8/12.
|
||||
*/
|
||||
public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
|
||||
private RecyclerView fm_install_rv_show;
|
||||
private OnCallBackListener listener;
|
||||
|
||||
private ArrayList<GameEntity> gameList;
|
||||
private ArrayList<MyGameInfo> sortedList;
|
||||
@ -68,12 +64,10 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
private ArrayMap<String, String> nameMap;
|
||||
|
||||
private boolean isRemove;
|
||||
private boolean isEmpty;
|
||||
|
||||
public InstallFragmentAdapter(Context context, RecyclerView recyclerView) {
|
||||
this.context = context;
|
||||
|
||||
fm_install_rv_show = recyclerView;
|
||||
public InstallFragmentAdapter(InstallFragment fragment) {
|
||||
this.context = fragment.getActivity();
|
||||
this.listener = fragment;
|
||||
|
||||
gameList = new ArrayList<>();
|
||||
sortedList = new ArrayList<>();
|
||||
@ -82,12 +76,11 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
nameMap = new ArrayMap<>();
|
||||
|
||||
isRemove = false;
|
||||
isEmpty = false;
|
||||
|
||||
ConcernManager cManager = new ConcernManager(context);
|
||||
List<ConcernInfo> runnableGame = cManager.getInstalledGame();
|
||||
if (runnableGame.isEmpty()) {
|
||||
isEmpty = true;
|
||||
listener.loadEmpty();
|
||||
} else {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
@ -307,10 +300,6 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.game_normal_item, parent, false);
|
||||
return new GameNormalViewHolder(view);
|
||||
} else if (isEmpty) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.reuse_nodata_skip, parent, false);
|
||||
return new NoDataSkipViewHolder(view);
|
||||
} else {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
@ -322,23 +311,12 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof GameNormalViewHolder) {
|
||||
initGameNormal((GameNormalViewHolder) holder, gameList.get(position), position);
|
||||
} else if (holder instanceof NoDataSkipViewHolder) {
|
||||
NoDataSkipViewHolder viewHolder = (NoDataSkipViewHolder) holder;
|
||||
|
||||
viewHolder.reuse_nodata_skip_tv_hint.setText("暂无游戏");
|
||||
viewHolder.reuse_nodata_skip_tv_btn.setText("查看精品推荐");
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
EventBus.getDefault().post(new EBSkip("GameFragment", 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (gameList.isEmpty() && (isEmpty || !isRemove)) {
|
||||
if (gameList.isEmpty() && !isRemove) {
|
||||
return 1;
|
||||
}
|
||||
if (isRemove) {
|
||||
@ -413,7 +391,4 @@ public class InstallFragmentAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
holder.download_percentage, holder.downloadBtn, gameEntity, false);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return isEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user