Skip to content

Commit

Permalink
#32 Migrated and removed NovelItemInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
MewX committed Jul 25, 2018
1 parent 618a5d6 commit d88cb48
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.mewx.wenku8.MyApp;
import org.mewx.wenku8.R;
import org.mewx.wenku8.global.GlobalConfig;
import org.mewx.wenku8.global.api.NovelItemInfo;
import org.mewx.wenku8.global.api.NovelItemInfoUpdate;
import org.mewx.wenku8.global.api.Wenku8API;
import org.mewx.wenku8.listener.MyOptionClickListener;
import org.mewx.wenku8.listener.MyItemClickListener;
Expand All @@ -33,19 +33,19 @@ public class NovelItemAdapter extends RecyclerView.Adapter<NovelItemAdapter.View
private MyItemClickListener mItemClickListener;
private MyOptionClickListener mMyOptionClickListener;
private MyItemLongClickListener mItemLongClickListener;
private List<NovelItemInfo> mDataset;
private List<NovelItemInfoUpdate> mDataset;

// empty list, then use append method to add list elements
public NovelItemAdapter() {
mDataset = new ArrayList<>();
}

public NovelItemAdapter(List<NovelItemInfo> dataset) {
public NovelItemAdapter(List<NovelItemInfoUpdate> dataset) {
super();
mDataset = dataset; // reference
}

public void RefreshDataset(List<NovelItemInfo> dataset) {
public void RefreshDataset(List<NovelItemInfoUpdate> dataset) {
mDataset = dataset; // reference
}

Expand All @@ -62,23 +62,23 @@ public void onBindViewHolder(@NonNull final ViewHolder viewHolder, int i) {

// set text
if(viewHolder.tvNovelTitle != null)
viewHolder.tvNovelTitle.setText(mDataset.get(i).getTitle());
viewHolder.tvNovelTitle.setText(mDataset.get(i).title);
if(viewHolder.tvNovelAuthor != null)
viewHolder.tvNovelAuthor.setText(mDataset.get(i).getAuthor());
viewHolder.tvNovelAuthor.setText(mDataset.get(i).author);
if(viewHolder.tvNovelStatus != null)
viewHolder.tvNovelStatus.setText(Wenku8API.getStatusBySTATUS(Wenku8API.getSTATUSByInt(mDataset.get(i).getStatus())));
viewHolder.tvNovelStatus.setText(mDataset.get(i).status);
if(viewHolder.tvNovelUpdate != null)
viewHolder.tvNovelUpdate.setText(mDataset.get(i).getUpdate());
viewHolder.tvNovelUpdate.setText(mDataset.get(i).update);
if(viewHolder.tvNovelIntro != null)
viewHolder.tvNovelIntro.setText(mDataset.get(i).getIntroShort());
viewHolder.tvNovelIntro.setText(mDataset.get(i).intro_short);

// need to solve flicking problem
if(LightCache.testFileExist(GlobalConfig.getFirstStoragePath() + "imgs" + File.separator + mDataset.get(i).getAid() + ".jpg"))
ImageLoader.getInstance().displayImage("file://" + GlobalConfig.getFirstStoragePath() + "imgs" + File.separator + mDataset.get(i).getAid() + ".jpg", viewHolder.ivNovelCover);
else if(LightCache.testFileExist(GlobalConfig.getSecondStoragePath() + "imgs" + File.separator + mDataset.get(i).getAid() + ".jpg"))
ImageLoader.getInstance().displayImage("file://" + GlobalConfig.getSecondStoragePath() + "imgs" + File.separator + mDataset.get(i).getAid() + ".jpg", viewHolder.ivNovelCover);
if(LightCache.testFileExist(GlobalConfig.getFirstStoragePath() + "imgs" + File.separator + mDataset.get(i).aid + ".jpg"))
ImageLoader.getInstance().displayImage("file://" + GlobalConfig.getFirstStoragePath() + "imgs" + File.separator + mDataset.get(i).aid + ".jpg", viewHolder.ivNovelCover);
else if(LightCache.testFileExist(GlobalConfig.getSecondStoragePath() + "imgs" + File.separator + mDataset.get(i).aid + ".jpg"))
ImageLoader.getInstance().displayImage("file://" + GlobalConfig.getSecondStoragePath() + "imgs" + File.separator + mDataset.get(i).aid + ".jpg", viewHolder.ivNovelCover);
else
ImageLoader.getInstance().displayImage(Wenku8API.getCoverURL(mDataset.get(i).getAid()), viewHolder.ivNovelCover);
ImageLoader.getInstance().displayImage(Wenku8API.getCoverURL(mDataset.get(i).aid), viewHolder.ivNovelCover);

}

Expand Down Expand Up @@ -110,17 +110,16 @@ public static class ViewHolder extends RecyclerView.ViewHolder implements View.O
private MyOptionClickListener mMyOptionClickListener;
private MyItemLongClickListener mLongClickListener;
public int position;
public boolean isLoading = false;

private ImageButton ibNovelOption;
public ImageView ivNovelCover;
public TextView tvNovelTitle;
public TextView tvNovelStatus;
public TextView tvNovelAuthor;
public TextView tvNovelUpdate;
public TextView tvNovelIntro;

public ViewHolder(View itemView, MyItemClickListener clickListener, MyOptionClickListener myOptionClickListener, MyItemLongClickListener longClickListener) {
ImageView ivNovelCover;
TextView tvNovelTitle;
TextView tvNovelStatus;
TextView tvNovelAuthor;
TextView tvNovelUpdate;
TextView tvNovelIntro;

ViewHolder(View itemView, MyItemClickListener clickListener, MyOptionClickListener myOptionClickListener, MyItemLongClickListener longClickListener) {
super(itemView);
this.mClickListener = clickListener;
this.mMyOptionClickListener = myOptionClickListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.mewx.wenku8.activity.NovelInfoActivity;
import org.mewx.wenku8.adapter.NovelItemAdapter;
import org.mewx.wenku8.global.GlobalConfig;
import org.mewx.wenku8.global.api.NovelItemInfo;
import org.mewx.wenku8.global.api.NovelItemInfoUpdate;
import org.mewx.wenku8.global.api.NovelListWithInfoParser;
import org.mewx.wenku8.global.api.Wenku8API;
import org.mewx.wenku8.listener.MyItemClickListener;
Expand All @@ -48,7 +48,7 @@ public class LatestFragment extends Fragment implements MyItemClickListener, MyI
private TextView mTextView;

// Novel Item info
private List<NovelItemInfo> listNovelItemInfo;
private List<NovelItemInfoUpdate> listNovelItemInfo;
private NovelItemAdapter mAdapter;
private int currentPage, totalPage; // currentP stores next reading page num, TODO: fix wrong number

Expand Down Expand Up @@ -140,9 +140,9 @@ public void onItemClick(View view, final int position) {

// go to detail activity
Intent intent = new Intent(getActivity(), NovelInfoActivity.class);
intent.putExtra("aid", listNovelItemInfo.get(position).getAid());
intent.putExtra("aid", listNovelItemInfo.get(position).aid);
intent.putExtra("from", "latest");
intent.putExtra("title", listNovelItemInfo.get(position).getTitle());
intent.putExtra("title", listNovelItemInfo.get(position).title);
if(Build.VERSION.SDK_INT < 21) {
startActivity(intent);
}
Expand Down Expand Up @@ -224,12 +224,11 @@ protected Integer doInBackground(ContentValues... params) {
// byte[] img = LightNetwork.LightHttpPost(
// Wenku8Interface.BaseURL, imgP);

NovelItemInfo ni = new NovelItemInfo();
ni.setAid(nlwi.aid);
ni.setTitle(nlwi.name);
ni.setAuthor(nlwi.hit + ""); // hit
ni.setUpdate(nlwi.push + ""); // push
ni.setIntro_short(nlwi.fav + ""); // fav
NovelItemInfoUpdate ni = new NovelItemInfoUpdate(nlwi.aid);
ni.title = nlwi.name;
ni.author = nlwi.hit + ""; // hit
ni.update = nlwi.push + ""; // push
ni.intro_short = nlwi.fav + ""; // fav
listNovelItemInfo.add(ni);
}

Expand Down

This file was deleted.

0 comments on commit d88cb48

Please sign in to comment.