2019-04-02 17:41:53 +08:00
|
|
|
package com.novelbook.android;
|
|
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import android.support.design.widget.AppBarLayout;
|
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
import com.astuetz.PagerSlidingTabStrip;
|
|
|
|
import com.novelbook.android.adapter.MyPagerAdapter;
|
2019-04-03 16:21:00 +08:00
|
|
|
import com.novelbook.android.db.Chapter;
|
2019-04-02 17:41:53 +08:00
|
|
|
import com.novelbook.android.utils.FileUtils;
|
|
|
|
import com.novelbook.android.utils.PageFactory;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
|
|
|
|
|
|
|
|
public class MarkActivity extends Activity_base {
|
|
|
|
|
|
|
|
@BindView(R.id.toolbar)
|
|
|
|
Toolbar toolbar;
|
|
|
|
@BindView(R.id.appbar)
|
|
|
|
AppBarLayout appbar;
|
|
|
|
@BindView(R.id.tabs)
|
|
|
|
PagerSlidingTabStrip tabs;
|
|
|
|
@BindView(R.id.pager)
|
|
|
|
ViewPager pager;
|
|
|
|
|
|
|
|
// @Bind(R.id.lv_catalogue)
|
|
|
|
// ListView lv_catalogue;
|
|
|
|
|
|
|
|
private PageFactory pageFactory;
|
|
|
|
private Config config;
|
|
|
|
private Typeface typeface;
|
2019-04-03 16:21:00 +08:00
|
|
|
private ArrayList<Chapter> catalogueList = new ArrayList<>();
|
2019-04-02 17:41:53 +08:00
|
|
|
private DisplayMetrics dm;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getLayoutRes() {
|
|
|
|
return R.layout.zactivity_mark;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void initViews() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void setTitle() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void initData() {
|
|
|
|
pageFactory = PageFactory.getInstance();
|
|
|
|
config = Config.getInstance();
|
|
|
|
dm = getResources().getDisplayMetrics();
|
|
|
|
typeface = config.getTypeface();
|
|
|
|
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
//设置导航图标
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (getSupportActionBar() != null) {
|
2019-04-05 23:59:31 +08:00
|
|
|
getSupportActionBar().setTitle(pageFactory.getBookName());
|
2019-04-02 17:41:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
setTabsValue();
|
2019-04-05 23:59:31 +08:00
|
|
|
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager(),pageFactory.getNovle().getId()));
|
2019-04-02 17:41:53 +08:00
|
|
|
tabs.setViewPager(pager);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setTabsValue() {
|
|
|
|
// 设置Tab是自动填充满屏幕的
|
|
|
|
tabs.setShouldExpand(true);//所有初始化要在setViewPager方法之前
|
|
|
|
// 设置Tab的分割线是透明的
|
|
|
|
tabs.setDividerColor(Color.TRANSPARENT);
|
|
|
|
// 设置Tab底部线的高度
|
|
|
|
tabs.setUnderlineHeight((int) TypedValue.applyDimension(
|
|
|
|
TypedValue.COMPLEX_UNIT_DIP, 1, dm));
|
|
|
|
// 设置Tab Indicator的高度
|
|
|
|
tabs.setIndicatorHeight((int) TypedValue.applyDimension(
|
|
|
|
TypedValue.COMPLEX_UNIT_DIP, 2, dm));
|
|
|
|
// 设置Tab标题文字的大小
|
|
|
|
tabs.setTextSize((int) TypedValue.applyDimension(
|
|
|
|
TypedValue.COMPLEX_UNIT_SP, 16, dm));
|
|
|
|
//设置Tab标题文字的字体
|
|
|
|
tabs.setTypeface(typeface,0);
|
|
|
|
// 设置Tab Indicator的颜色
|
|
|
|
tabs.setIndicatorColor(getResources().getColor(R.color.colorAccent));
|
|
|
|
// 取消点击Tab时的背景色
|
|
|
|
tabs.setTabBackground(0);
|
|
|
|
|
|
|
|
// pagerSlidingTabStrip.setDividerPadding(18);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void initListener() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|