调整界面

This commit is contained in:
mwang 2019-04-11 23:24:50 +08:00
parent b816fcd07a
commit 4679e86098
9 changed files with 297 additions and 101 deletions

View File

@ -26,7 +26,8 @@ public static String TAG ="com.novelbook.android.paihangbang";
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
public static String EXTR_FN="fn";
public static String EXTR_TITLE="title";
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
@ -51,7 +52,9 @@ public static String TAG ="com.novelbook.android.paihangbang";
}
String title = getIntent().getStringExtra("BANGNAME");
String title = getIntent().getStringExtra(EXTR_TITLE);
String fn = getIntent().getStringExtra(EXTR_FN);
title+="";
this.setTitle(title);
}
@ -69,7 +72,7 @@ public static String TAG ="com.novelbook.android.paihangbang";
if(mFragments ==null || mFragments.size() ==0){
mTitle = new String[]{"周榜", "月榜", "总榜"};
mFragments = new ArrayList<>();
mFragments.add(new Fragment_booklist());
mFragments.add( Fragment_booklist.newInstance("a",1)); //目的地不清楚
mFragments.add(new Fragment_booklist());
mFragments.add(new Fragment_booklist());

View File

@ -38,6 +38,7 @@ import com.novelbook.android.BookActivity;
import com.novelbook.android.R;
import com.novelbook.android.ReadActivity;
import com.novelbook.android.adapter.BookListAdapter;
import com.novelbook.android.bean.NovelBlock;
import com.novelbook.android.db.Novel;
import com.novelbook.android.netsubscribe.BookSubscribe;
import com.novelbook.android.netutils.OnSuccessAndFaultListener;
@ -291,10 +292,12 @@ public abstract class BasicFragment extends Fragment {
//-------------------------------------------------------------------------------------book list adapter end--------------------------------------------------
void showPaihangbang(String type) { //show paihangbang activity
void showPaihangbang(Object obj) { //show paihangbang activity
NovelBlock nb = (NovelBlock) obj;
Intent intent = new Intent(activity, Activity_paihangbang.class);
intent.putExtra("BANGNAME",type);
intent.putExtra(Activity_paihangbang.EXTR_FN,nb.getFn() );
intent.putExtra(Activity_paihangbang.EXTR_TITLE,nb.getTitle() );
startActivity(intent);
}

View File

@ -9,6 +9,7 @@ import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@ -90,7 +91,16 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
Button btnMore2;
@BindView(R.id.buttonMore3)
Button btnMore3;
@BindView(R.id.buttonMore4)
Button btnMore4;
@BindView(R.id.llBlock1)
LinearLayout ll1;
@BindView(R.id.llBlock2)
LinearLayout ll2;
@BindView(R.id.llBlock3)
LinearLayout ll3;
@BindView(R.id.llBlock4)
LinearLayout ll4;
private List<Fragment> mFragments;
private ArrayList<View> mList;
@ -100,6 +110,9 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
private List<String> list_title;
private FirstPage mFirstPage;
private int INDEX_BANNER =1;
private int INDEX_TUIJIAN =2;
private int blockIndex =3; //从第3个block 开始处理
public Fragment_jingxuan() {
// Required empty public constructor
@ -205,31 +218,77 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
mFinishedData_l = initData(mFinishedData_l, 'A');
mFinishedData_g = initData(mFinishedData_g, 'G');
*/
ll1.setVisibility(View.GONE);
ll2.setVisibility(View.GONE);
ll3.setVisibility(View.GONE);
ll4.setVisibility(View.GONE);
blockIndex=3;
if(mBlocks ==null || mBlocks.size() ==0){
return;
}
if(mBlocks.size()>0) {
blockIndex--;
if(mBlocks.size()>blockIndex) {
ll1.setVisibility(View.VISIBLE);
mHotNewData_l = mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself());
mHotNewData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1);
tvBlock1.setText(mBlocks.get(blockIndex).getName());
loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock1);
if(TextUtils.isEmpty(mBlocks.get(blockIndex).getTitle())){
btnMore1.setVisibility(View.GONE);
}else {
btnMore1.setTag(mBlocks.get(blockIndex));
}
mHotNewData_l = mBlocks.get(0).getNs();
tvBlock1.setText(mBlocks.get(0).getName());
loadImageView(mBlocks.get(0).getIcon(),imageViewBlock1);
btnMore1.setTag(mBlocks.get(0).getName());
blockIndex++;
}
// mHotNewData_g = initData(mHotNewData_g, 'D');
if(mBlocks.size()>1) {
mHotLianZaiData_l = mBlocks.get(1).getNs();//initData(mHotLianZaiData_l, 'C');
tvBlock2.setText(mBlocks.get(1).getName());
loadImageView(mBlocks.get(1).getIcon(),imageViewBlock2);
btnMore2.setTag(mBlocks.get(1).getName());
if(mBlocks.size()>blockIndex) {
ll2.setVisibility(View.VISIBLE);
mHotLianZaiData_l = mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself());
mHotLianZaiData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1);
tvBlock2.setText(mBlocks.get(blockIndex).getName());
loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock2);
if(TextUtils.isEmpty(mBlocks.get(blockIndex).getTitle())){
btnMore2.setVisibility(View.GONE);
}else {
btnMore2.setTag(mBlocks.get(blockIndex));
}
blockIndex++;
}
// mHotLianZaiData_g = initData(mHotLianZaiData_g, 'D');
// mFinishedData_l = mBlocks.get(2).getNs(); //initData(mFinishedData_l, 'A');
if(mBlocks.size()>2) {
mFinishedData_g = mBlocks.get(2).getNs();// initData(mFinishedData_g, 'G');
tvBlock3.setText(mBlocks.get(2).getName());
loadImageView(mBlocks.get(2).getIcon(),imageViewBlock3);
btnMore3.setTag(mBlocks.get(2).getName());
if(mBlocks.size()> blockIndex ) {
ll3.setVisibility(View.VISIBLE);
mFinishedData_l= mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself());
mFinishedData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1);
tvBlock3.setText(mBlocks.get(blockIndex).getName());
loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock3);
if(TextUtils.isEmpty(mBlocks.get(blockIndex).getTitle())){
btnMore3.setVisibility(View.GONE);
}else {
btnMore3.setTag(mBlocks.get(blockIndex));
}
}
if(mBlocks.size()> blockIndex ) {
ll4.setVisibility(View.VISIBLE);
mFinishedData_l= mBlocks.get(blockIndex).getNs().subList(0,mBlocks.get(blockIndex).getOneself());
mFinishedData_g = mBlocks.get(blockIndex).getNs().subList(mBlocks.get(blockIndex).getOneself(),mBlocks.get(blockIndex).getNs().size()-1);
tvBlock3.setText(mBlocks.get(blockIndex).getName());
loadImageView(mBlocks.get(blockIndex).getIcon(),imageViewBlock3);
if(TextUtils.isEmpty(mBlocks.get(blockIndex).getTitle())){
btnMore4.setVisibility(View.GONE);
}else {
btnMore4.setTag(mBlocks.get(blockIndex));
}
}
testBanner(banner, this);
initialBookList();
initTuijianPagers();
@ -256,16 +315,19 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
switch (view.getId()) {
case R.id.buttonMore1:
showPaihangbang(btnMore1.getTag().toString());
showPaihangbang(btnMore1.getTag());
break;
case R.id.buttonMoreTuijian:
showPaihangbang("推荐");
break;
case R.id.buttonMore2:
showPaihangbang(btnMore2.getTag().toString());
showPaihangbang(btnMore2.getTag());
break;
case R.id.buttonMore3:
showPaihangbang(btnMore3.getTag().toString());
showPaihangbang(btnMore3.getTag());
break;
case R.id.buttonMore4:
showPaihangbang(btnMore4.getTag());
break;
case R.id.buttonCatePingfen:
showPaihangbang("评分");
@ -353,8 +415,17 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
if (mFragments == null || mFragments.size() == 0) {
// mTitle = new String[]{"精选", "榜单", "书单"};
mFragments = new ArrayList<>();
for(NovelBlock block : mBlocks ){
mFragments.add(Fragment_jingxuan_tuijian.newInstance(block.getNs()));
NovelBlock block = mBlocks.get(1);
List<Novel> nvs = new ArrayList<Novel>();
for(Novel novel : block.getNs() ){
if(nvs.size()<3){
nvs.add(novel);
}else {
mFragments.add(Fragment_jingxuan_tuijian.newInstance(nvs));
nvs = new ArrayList<Novel>();
nvs.add(novel);
}
}
Log.d(TAG, "initial fragments in tabs ");
@ -405,6 +476,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
void initialBookList() {
int spanCnt =4;
OnItemClickListener onItemClickListener = new OnItemClickListener() {
@Override
@ -431,7 +503,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
rvHotNewL.setAdapter(new BookListAdapter(activity, mHotNewData_l, R.layout.recycle_list_item_horizon, onItemClickListener));
}
if(mHotNewData_g!=null) {
rvHotNewG.setLayoutManager(new GridLayoutManager(activity, 3));
rvHotNewG.setLayoutManager(new GridLayoutManager(activity, spanCnt));
rvHotNewG.setAdapter(new BookListAdapter(activity, mHotNewData_g, R.layout.recycle_list_item, new OnItemClickListener() {
@ -481,7 +553,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
}));
}
if(mHotLianZaiData_g!=null) {
rvLianZaiG.setLayoutManager(new GridLayoutManager(activity, 3));
rvLianZaiG.setLayoutManager(new GridLayoutManager(activity, spanCnt));
rvLianZaiG.setAdapter(new BookListAdapter(activity, mHotLianZaiData_g, R.layout.recycle_list_item, new OnItemClickListener() {
@ -532,7 +604,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
}));
}
if(mFinishedData_g!=null) {
rvFinishG.setLayoutManager(new GridLayoutManager(activity, 3));
rvFinishG.setLayoutManager(new GridLayoutManager(activity, spanCnt));
rvFinishG.setAdapter(new BookListAdapter(activity, mFinishedData_g, R.layout.recycle_list_item, new OnItemClickListener() {

View File

@ -86,7 +86,7 @@ public class activity_cates extends Activity_base {
private void fillData() {
List<Cataloge> cates = new ArrayList<>();
for(Cataloge cate:mCataloges){
if(cate.getNovelCount()>0){
if(cate!=null && cate.getNovelCount()>0){
cates.add(cate);
}
}

View File

@ -5,11 +5,39 @@ import com.novelbook.android.db.Novel;
import java.util.List;
public class NovelBlock{
private String name;
private String fn;
private String title;
private int oneself;
//private int displayModel;
private String name;
private String icon;
private List<String> pictures;
private List<Novel> ns;
public String getFn() {
return fn;
}
public void setFn(String fn) {
this.fn = fn;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getOneself() {
return oneself;
}
public void setOneself(int oneself) {
this.oneself = oneself;
}
public String getName() {
return name;
}

View File

@ -24,8 +24,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
android:paddingBottom="30dp"
android:orientation="vertical">
<com.youth.banner.Banner
android:id="@+id/banner"
android:layout_width="match_parent"
@ -46,26 +47,27 @@
android:layout_gravity="center_horizontal"
android:layout_margin="6dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/googleg_standard_color_18"
android:layout_gravity="left"
/>
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="left"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:text="重磅推荐"
android:layout_marginLeft="2dp"
android:textColor="#212121" />
<Button
android:id="@+id/buttonMoreTuijian"
style="@style/buttonRightMore"
android:visibility="gone"
android:text="更多>"
android:visibility="gone"
/>
@ -75,31 +77,33 @@
android:id="@+id/viewpager_tuijian"
android:layout_width="match_parent"
android:layout_height="wrap_content"></com.novelbook.android.utils.MyViewPager>
</LinearLayout>
<LinearLayout
android:id="@+id/dot_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="3dp"
android:gravity="center"
android:orientation="horizontal" />
<LinearLayout
android:id="@+id/dot_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="3dp"
android:gravity="center"
android:orientation="horizontal" />
<!--
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titleIndictator"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
-->
<!--
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titleIndictator"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
-->
<!--火热新书 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/ghostwhite"
<!--火热新书 -->
<LinearLayout
android:id="@+id/llBlock1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="horizontal" />
<LinearLayout style="@style/llGraySplit" />
<LinearLayout
@ -113,17 +117,17 @@
android:id="@+id/imageBlock1"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/googleg_standard_color_18"
android:layout_gravity="left"
/>
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:id="@+id/tvBlock1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="left"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:text="火热新书"
android:layout_marginLeft="2dp"
android:textColor="#212121" />
<Button
@ -134,7 +138,6 @@
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
@ -151,14 +154,20 @@
android:layout_height="match_parent"
android:divider="#ffff0000"
android:dividerHeight="10dp"
android:nestedScrollingEnabled="false" />
<LinearLayout style="@style/llGraySplit" />
</LinearLayout>
<!-- <include layout="@layout/fragment_jingxuan_book_list"></include> -->
<LinearLayout style="@style/llGraySplit"/>
<!--热门连载 -->
<LinearLayout
android:id="@+id/llBlock2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--热门连载 -->
<LinearLayout
android:layout_width="match_parent"
@ -171,17 +180,17 @@
android:id="@+id/imageBlock2"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/googleg_standard_color_18"
android:layout_gravity="left"
/>
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:id="@+id/tvBlock2"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="left"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:text="热门连载"
android:layout_marginLeft="2dp"
android:textColor="#212121" />
<Button
@ -212,12 +221,20 @@
android:nestedScrollingEnabled="false"
/>
<LinearLayout style="@style/llGraySplit" />
</LinearLayout>
<!-- <include layout="@layout/fragment_jingxuan_book_list"></include> -->
<!--完本精选 -->
<LinearLayout
android:id="@+id/llBlock3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout style="@style/llGraySplit"/>
<!-- <include layout="@layout/fragment_jingxuan_book_list"></include> -->
<!--完本精选 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
@ -229,17 +246,17 @@
android:id="@+id/imageBlock3"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/googleg_standard_color_18"
android:layout_gravity="left"
/>
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:id="@+id/tvBlock3"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="left"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:text="完本精选"
android:layout_marginLeft="2dp"
android:textColor="#212121" />
<Button
@ -271,14 +288,80 @@
android:nestedScrollingEnabled="false"
android:paddingBottom="40dp" />
<!-- <include layout="@layout/fragment_jingxuan_book_list"></include> -->
<LinearLayout style="@style/llGraySplit" />
</LinearLayout>
<!-- <include layout="@layout/fragment_jingxuan_book_list"></include> -->
<LinearLayout
android:id="@+id/llBlock4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_margin="6dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBlock4"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="left"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:id="@+id/tvBlock4"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="left"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:text="完本精选"
android:textColor="#212121" />
<Button
android:id="@+id/buttonMore4"
style="@style/buttonRightMore"
android:text="更多>"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#ffff0000"
android:dividerHeight="10dp"
android:nestedScrollingEnabled="false"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvG"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#ffff0000"
android:dividerHeight="10dp"
android:nestedScrollingEnabled="false"
android:paddingBottom="40dp" />
<LinearLayout style="@style/llGraySplit" />
</LinearLayout>
<LinearLayout style="@style/llGraySplit" />
</LinearLayout>
<!-- <include layout="@layout/fragment_jingxuan_book_list"></include> -->
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>

View File

@ -1,24 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="120dp"
android:layout_height="165dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1"
android:padding="5dp">
android:padding="0dp">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_weight="1"
android:gravity="center"
android:scaleType="fitStart"
style="@style/NovelImage"
android:src="@drawable/googleg_standard_color_18" />
<CheckBox
android:id="@+id/id_check_box"
@ -32,10 +29,11 @@
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_height="30dp"
android:gravity="top|center"
android:text="天龙八部"
android:text="天龙八部天龙八部天龙八部"
android:lines="1"
android:maxLength="5"
android:textColor="#212121" />
<!--
<TextView

View File

@ -2,24 +2,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_marginBottom="5dp"
android:layout_weight="1">
<ImageView
android:id="@+id/imageView"
android:layout_margin="10dp"
android:layout_width="80dp"
android:layout_height="80dp"
style="@style/NovelImage"
android:layout_weight="0"
android:gravity="left"
android:gravity="left|center_vertical"
android:src="@drawable/googleg_standard_color_18" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:gravity="top"
android:layout_weight="1">
<TextView
@ -35,17 +34,18 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
style="@style/TextViewNovelType"
android:id="@+id/category"
android:text="武侠小说"
/>
<TextView
android:id="@+id/author"
style="@style/TextViewNovelAuthor"
android:text="金庸"
/>
<TextView
style="@style/TextViewNovelType"
android:id="@+id/category"
android:text="武侠小说"
/>
</LinearLayout>
<TextView

View File

@ -128,16 +128,24 @@
</style>
<style name="llGallaryImage">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">100dp</item>
<item name="android:layout_height">120dp</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center</item>
</style>
<style name="NovelImage">
<item name="android:layout_width">80dp</item>
<item name="android:layout_height">100dp</item>
<item name="android:layout_weight">1</item>
<item name="android:gravity">center</item>
<item name="android:scaleType">fitStart</item>
</style>
<style name="llGallary">
<item name="android:orientation">vertical</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">120dp</item>
<item name="android:layout_height">165dp</item>
<item name="android:gravity">center</item>
<item name="android:background">@drawable/item_selector</item>
<item name="android:clickable">true</item>
@ -263,6 +271,7 @@
</style>
<style name="TextViewNovelAuthor">
<item name="android:layout_marginLeft">10dp</item>
<item name="android:textColor">#212121</item>
<item name="android:textSize">12sp</item>
<item name="android:layout_width">wrap_content</item>