update protype

This commit is contained in:
mwang 2019-02-24 00:21:34 +08:00
parent dd76d76870
commit 4d7ca45441
37 changed files with 806 additions and 1284 deletions

View File

@ -1,8 +1,8 @@
<component name="libraryTable">
<library name="Gradle: com.astuetz:pagerslidingtabstrip:1.0.1@aar">
<CLASSES>
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/pagerslidingtabstrip-1.0.1.aar/7d65188ecb2ce25cae3bdfe147e9695a/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/pagerslidingtabstrip-1.0.1.aar/7d65188ecb2ce25cae3bdfe147e9695a/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/pagerslidingtabstrip-1.0.1.aar/23bba10e40ab79841f4e0e2d27683055/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/pagerslidingtabstrip-1.0.1.aar/23bba10e40ab79841f4e0e2d27683055/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@ -1,8 +1,8 @@
<component name="libraryTable">
<library name="Gradle: com.umeng:fb:5.4.0@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/fb-5.4.0.aar/06eecbd39060047cda401fe0c4b13d13/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/fb-5.4.0.aar/06eecbd39060047cda401fe0c4b13d13/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/fb-5.4.0.aar/0f5e18fd6e1b236f7b295ed64212faaa/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/fb-5.4.0.aar/0f5e18fd6e1b236f7b295ed64212faaa/res" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -1,9 +1,9 @@
<component name="libraryTable">
<library name="Gradle: com.umeng:message:2.4.1@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/message-2.4.1.aar/860f6bb52819aa57bcd7bc594ba91b42/jars/libs/com.umeng.message.lib_v2.4.1.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/message-2.4.1.aar/860f6bb52819aa57bcd7bc594ba91b42/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/message-2.4.1.aar/860f6bb52819aa57bcd7bc594ba91b42/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/message-2.4.1.aar/f737d8e0c0a2199ce29e8199106061fb/jars/libs/com.umeng.message.lib_v2.4.1.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/message-2.4.1.aar/f737d8e0c0a2199ce29e8199106061fb/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/message-2.4.1.aar/f737d8e0c0a2199ce29e8199106061fb/res" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -1,8 +1,8 @@
<component name="libraryTable">
<library name="Gradle: com.zhy:okhttputils:2.6.2@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/okhttputils-2.6.2.aar/787a2bae54897313df6d97757a7e2c8e/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/okhttputils-2.6.2.aar/787a2bae54897313df6d97757a7e2c8e/res" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/okhttputils-2.6.2.aar/937d9a5f63c74659873e6bbd002f41c9/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/okhttputils-2.6.2.aar/937d9a5f63c74659873e6bbd002f41c9/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@ -1,8 +1,8 @@
<component name="libraryTable">
<library name="Gradle: org.litepal.android:core:1.3.1@aar">
<CLASSES>
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/core-1.3.1.aar/a6954567bb1ada7006d14f8f89dbcec5/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/core-1.3.1.aar/a6954567bb1ada7006d14f8f89dbcec5/jars/classes.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/core-1.3.1.aar/5999e441929375f9dd0f7c6cbf6b39cc/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/core-1.3.1.aar/5999e441929375f9dd0f7c6cbf6b39cc/res" />
</CLASSES>
<JAVADOC />
<SOURCES>

View File

@ -1,2 +1,2 @@
//include ':listviewlibrary', ':PushSDK', ':i7lvsvrs', ':zhuike', ':qy', ':app'
include ':zhuike', ':testapp'
include ':zhuike', ':testapp', ':app'

View File

@ -2,17 +2,21 @@ package com.deiniu.zhuike;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import java.util.ArrayList;
import java.util.List;
@ -20,9 +24,9 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Activity_base extends AppCompatActivity {
List<String> mDatas;
BookListAdapter mAdapter;
public abstract class Activity_base extends AppCompatActivity {
@Nullable
@BindView(R.id.recycleViewBookList)
RecyclerView rvshudan;
void showBook(String bookName) { //show paihangbang activity
@ -30,16 +34,40 @@ public class Activity_base extends AppCompatActivity {
intent.putExtra("BOOKNAME",bookName);
startActivity(intent);
}
void initData() {
mDatas = new ArrayList<String>();
for (int i = 'A'; i <'K'; i++)
{
mDatas.add("小说" + (char) i);
}
/**
* 初始化布局
*/
public abstract int getLayoutRes();
protected abstract void initViews();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutRes());
ButterKnife.bind(this);
setupToolbar();
// 初始化View注入
setTitle();
initData();
initViews();
}
void initialAdapter(){
mAdapter = new BookListAdapter(this ,mDatas,R.layout.recycle_list_item_horizon,new OnItemClickListener()
@BindView(R.id.toolbar)
Toolbar toolbar;
protected void setupToolbar(){
// Toolbar toolbar = findViewById(R.id.toolbar);
// setSupportActionBar(toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
protected abstract void setTitle();
protected abstract void initData() ;
protected BookListAdapter getBookListAdapter(List<String> mDatas){
BookListAdapter mAdapter = new BookListAdapter(this ,mDatas,R.layout.recycle_list_item_horizon,new OnItemClickListener()
{
@Override
@ -63,27 +91,29 @@ public class Activity_base extends AppCompatActivity {
}
});
}
void initialBookList() {
initData();
initialAdapter();
rvshudan.setLayoutManager(new LinearLayoutManager(this));
rvshudan.setAdapter(mAdapter);
return mAdapter;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId()==android.R.id.home){ //拦截toolbar 返回事件
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
protected List<String> getFakeData(int max ){
List<String> mDatas = new ArrayList<String>();
for (int i = 0; i <max; i++)
{
mDatas.add("小说" + (char) i);
}
return mDatas;
}
@ -109,6 +139,8 @@ public class Activity_base extends AppCompatActivity {
}
}
/*
class BookListAdapter extends RecyclerView.Adapter<MyViewHolder> {
private final int EMPTY_VIEW = 1;
private final int PROGRESS_VIEW = 2;
@ -211,5 +243,6 @@ public class Activity_base extends AppCompatActivity {
}
}
*/
}

View File

@ -18,24 +18,7 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Activity_cate_books extends AppCompatActivity {
public static String TAG="com.deiniu.zhuike.Activity_cate_books";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cate_books);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ButterKnife.bind(this);
String title = getIntent().getStringExtra("CATENAME");
this.setTitle(title);
initTabs();
}
//---------tabs-------------
public class Activity_cate_books extends Activity_base {
@BindView(R.id.viewpager)
ViewPager mViewpager;
@ -45,6 +28,31 @@ public class Activity_cate_books extends AppCompatActivity {
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
public static String TAG="com.deiniu.zhuike.Activity_cate_books";
@Override
public int getLayoutRes() {
return R.layout.activity_cate_books;
}
@Override
protected void initViews() {
initTabs();
}
@Override
protected void setTitle() {
String title = getIntent().getStringExtra("CATENAME");
this.setTitle(title);
}
@Override
protected void initData() {
}
//---------tabs-------------
void initTabs() {
if(mFragments ==null || mFragments.size() ==0){

View File

@ -16,9 +16,11 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.MyViewHolder;
import java.util.ArrayList;
import java.util.List;
@ -33,27 +35,27 @@ public class Activity_createShudan extends Activity_base {
@BindView(R.id.toolbar)
Toolbar toolbar ;
BookListAdapter mAdapter;
private List<String> mData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_shudan);
ButterKnife.bind(this);
setupToolbar();
setTitle("创建书单");
initialBookList();
public int getLayoutRes() {
return R.layout.activity_create_shudan;
}
@Override
protected void initViews() {
initialBookList();
}
void initialBookList() {
initData();
initialAdapter();
rvshudan.setLayoutManager(new LinearLayoutManager(this));
rvshudan.setAdapter(mAdapter);
}
void initialAdapter(){
mAdapter = new BookListAdapter(this ,mDatas,R.layout.recycle_list_item_horizon_with_delete,new OnItemClickListener()
mAdapter = new BookListAdapter(this ,mData ,R.layout.recycle_list_item_horizon_with_delete,new OnItemClickListener()
{
@Override
@ -84,10 +86,8 @@ public class Activity_createShudan extends Activity_base {
}
void setupToolbar(){
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
protected void setupToolbar(){
super.setupToolbar();
toolbar.inflateMenu(R.menu.menu_create_shudan);//设置右上角的填充菜单
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
@ -106,6 +106,16 @@ public class Activity_createShudan extends Activity_base {
});
}
@Override
protected void setTitle() {
setTitle("创建书单");
}
@Override
protected void initData() {
mData = getFakeData(5);
}
private void saveShudan() {
}
private void publishShudan() {
@ -229,4 +239,5 @@ public class Activity_createShudan extends Activity_base {
}
}
}

View File

@ -31,17 +31,31 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Activity_paihangbang extends AppCompatActivity {
public class Activity_paihangbang extends Activity_base {
public static String TAG ="com.deiniu.zhuike.paihangbang";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@BindView(R.id.viewpager)
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
setContentView(R.layout.activity_paihangbang);
ButterKnife.bind(this);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
@Override
public int getLayoutRes() {
return R.layout.activity_paihangbang;
}
@Override
protected void initViews() {
initTabs();
}
@Override
protected void setTitle() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
@ -51,22 +65,16 @@ public static String TAG ="com.deiniu.zhuike.paihangbang";
String title = getIntent().getStringExtra("BANGNAME");
title+="";
this.setTitle(title);
initTabs();
}
@Override
protected void initData() {
}
//---------tabs-------------
@BindView(R.id.viewpager)
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
void initTabs() {
if(mFragments ==null || mFragments.size() ==0){

View File

@ -17,6 +17,7 @@ import android.widget.TextView;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import java.util.ArrayList;
import java.util.List;
@ -26,29 +27,39 @@ import butterknife.ButterKnife;
public class Activity_shudan extends Activity_base {
private List<String> mData;
private BookListAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shudan);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ButterKnife.bind(this);
String title = getIntent().getStringExtra("CATENAME");
this.setTitle(title);
public int getLayoutRes() {
return R.layout.activity_shudan;
}
@Override
protected void initViews() {
initialBookList();
}
@Override
protected void initData() {
mData = getFakeData(5);
mAdapter = getBookListAdapter( mData);
}
@Override
protected void setTitle(){
String title = getIntent().getStringExtra("NAME");
this.setTitle("书单详情" );
}
void initialBookList() {
rvshudan.setLayoutManager(new LinearLayoutManager(this));
rvshudan.setAdapter(mAdapter);
}
//------------------------列表绑定------------

View File

@ -1,29 +1,98 @@
package com.deiniu.zhuike;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
public class Activity_shudan_my extends AppCompatActivity {
import com.flyco.tablayout.SlidingTabLayout;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Activity_shudan_my extends Activity_base {
public static String TAG ="com.deiniu.zhuike.Activity_shudan_my";
@BindView(R.id.viewpager)
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
@BindView(R.id.fab)
FloatingActionButton fab;
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shudan_my);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
public int getLayoutRes() {
return R.layout.activity_shudan_my;
}
FloatingActionButton fab = findViewById(R.id.fab);
@Override
protected void initViews() {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
Intent intent = new Intent(Activity_shudan_my.this, Activity_createShudan.class);
intent.putExtra("SHUDANID",0);
startActivity(intent);
}
});
initTabs();
}
@Override
protected void setTitle() {
setTitle("我的书单");
}
@Override
protected void initData() {
}
void initTabs() {
if(mFragments ==null || mFragments.size() ==0){
mTitle = new String[]{"已发布", "草稿", "收藏"};
mFragments = new ArrayList<>();
mFragments.add(new Fragment_shudan_list());
mFragments.add(new Fragment_shudan_list());
mFragments.add(new Fragment_shudan_list());
Log.d(TAG,"initial fragments in tabs ");
}
Log.d(TAG,"set viewPager adapter ");
// FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return mFragments.get(position);
}
@Override
public int getCount() {
return mFragments.size();
}
//ViewPager与TabLayout绑定后这里获取到PageTitle就是Tab的Text
@Override
public CharSequence getPageTitle(int position) {
return mTitle[position];
}
};
mViewpager.setAdapter(mAdapter);
tabLayout.setViewPager(mViewpager);
// tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
mViewpager.setCurrentItem(0);
}
}

View File

@ -37,10 +37,16 @@ import butterknife.ButterKnife;
* A simple {@link Fragment} subclass.
*/
public abstract class BasicFragment extends Fragment {
protected OnFragmentInteractionListener mListener;
public static String TAG = "need to be replaced";
private View rootView;
protected abstract int getLayoutRes();
protected abstract void initData();
protected void initListener(){}
protected abstract void initViews();
// Main2Activity activity;
FragmentActivity activity;
public BasicFragment() {
// Required empty public constructor
}
@ -51,7 +57,7 @@ public abstract class BasicFragment extends Fragment {
// Log.d(TAG,"fragment onCreate ");
// activity =(Main2Activity)getActivity();
activity = getActivity();
initData();
// QLog.getLogger().e(dTAG,TAG+" "+ "onCreate");
// mediumFontSize = activity.getMiddleSizeFont();
@ -61,8 +67,17 @@ public abstract class BasicFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.d(TAG,"onCreateView");
View view = inflater.inflate(getLayoutRes(), container, false);
rootView = view;
// 初始化View注入
ButterKnife.bind(this,view);
initListener();
initViews();
return view;
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_basic, container, false);
}
public String getCurrentTag() {
@ -71,29 +86,8 @@ public abstract class BasicFragment extends Fragment {
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
public abstract void setFTag();
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
//--------------------------------------------------------------book list adapter------------------------------------------------
@ -104,131 +98,7 @@ public abstract class BasicFragment extends Fragment {
void onLinearOutClick(View view,int bookId);
}
*/
class BookListAdapter extends RecyclerView.Adapter<BookListAdapter.MyViewHolder> {
private final int EMPTY_VIEW = 1;
private final int PROGRESS_VIEW = 2;
private final int IMAGE_VIEW = 3;
private Context context;
private List<String> mDatas = new ArrayList<String>();
private OnItemClickListener mOnItemClickListener;
private int listItemID;
public BookListAdapter(Context context,List<String> mDatas,int listItemID,OnItemClickListener clickLitener) {
this.context = context;
this.mDatas = mDatas;
this.mOnItemClickListener = clickLitener;
this.listItemID = listItemID;
}
public BookListAdapter(Context context, OnItemClickListener clickLitener) {
this.context = context;
this.mOnItemClickListener = clickLitener;
}
@Override
public int getItemViewType(int position) {
if(mDatas.size() == 0){
return EMPTY_VIEW;
} else if(mDatas.get(position) == null){
return PROGRESS_VIEW;
} else {
return super.getItemViewType(position);
}
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
context).inflate(listItemID, parent,
false));
return holder;
}
public void setParameters(List<String> mDatas,int listItemID ) {
this.mDatas = mDatas;
this.listItemID = listItemID;
}
public void setOnItemClickLitener(OnItemClickListener mOnItemClickLitener)
{
this.mOnItemClickListener = mOnItemClickLitener;
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position)
{
holder.tvTitle.setText(mDatas.get(position));
if(holder.tvAuthor!=null) holder.tvAuthor.setText("金庸" +position);
if(holder.tvCate!=null) holder.tvCate.setText("cate"+position);
if(holder.tvDesc!=null) holder.tvDesc.setText("this is desc " +position);
// 如果设置了回调则设置点击事件
if (mOnItemClickListener != null)
{
holder.itemView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
int pos = holder.getLayoutPosition();
mOnItemClickListener.onItemClick(holder.itemView, pos);
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
int pos = holder.getLayoutPosition();
mOnItemClickListener.onItemLongClick(holder.itemView, pos);
return false;
}
});
}
}
@Override
public int getItemCount()
{
return mDatas.size();
}
public void addData(int position) {
mDatas.add(position, "Insert One");
notifyItemInserted(position);
}
public void removeData(int position) {
mDatas.remove(position);
notifyItemRemoved(position);
}
class MyViewHolder extends RecyclerView.ViewHolder
{
@BindView(R.id.imageView)
ImageView imageView;
@BindView(R.id.title)
TextView tvTitle;
@Nullable
@BindView(R.id.author)
TextView tvAuthor;
@Nullable
@BindView(R.id.category)
TextView tvCate;
@Nullable
@BindView(R.id.desc)
TextView tvDesc;
public MyViewHolder(View view)
{
super(view);
ButterKnife.bind(this, view);
//tvTitle = (TextView) view.findViewById(R.id.title);
// tvAuthor = (TextView) view.findViewById(R.id.author);
}
}
}
protected List<String> initData(List<String> mDatas,char x)
{
mDatas = new ArrayList<String>();
@ -249,7 +119,7 @@ public abstract class BasicFragment extends Fragment {
}
void showShudanDetail(int shuandanId){
Intent intent = new Intent(activity, Activity_shudan.class);
intent.putExtra("SHUDANID",shuandanId);
intent.putExtra("NAME",shuandanId);
startActivity(intent);
}

View File

@ -1,115 +0,0 @@
package com.deiniu.zhuike;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link BlankFragment.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link BlankFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class BlankFragment extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public static String getFTag() {
return "com.deiniu.zhuike.BlankFragment";
}
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public BlankFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment BlankFragment.
*/
// TODO: Rename and change types and number of parameters
public static BlankFragment newInstance(String param1, String param2) {
BlankFragment fragment = new BlankFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"BlankFragment onCreate");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.d(TAG,"BlankFragment onCreateView");
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_blank, container, false);
}
@Override
public void setFTag() {
TAG ="com.deiniu.zhuike.BlankFragment";
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
}

View File

@ -14,6 +14,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import java.util.ArrayList;
import java.util.List;
@ -21,7 +22,7 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class BookActivity extends AppCompatActivity {
public class BookActivity extends Activity_base {
BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@ -30,54 +31,20 @@ public class BookActivity extends AppCompatActivity {
Toolbar toolbar;
@BindView(R.id.rvBooklist)
RecyclerView rvBooklist;
// @BindView(R.id.blurLayout)
// BlurLayout blurLayout;
// private float movement = 150;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_book);
ButterKnife.bind(this);
setupToolbar();
String title = getIntent().getStringExtra("BOOKNAME");
this.setTitle(title);
mData =initData(mData,'D');
mAdapter = new BookListAdapter(this, mData, R.layout.recycle_list_item_shudan, new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
showBookDetail( mData.get(position));
}
@Override
public void onItemLongClick(View view, int position) {
// initDialog(position);
// mAdapter.removeData(position);
}
@Override
public void onLinearOutClick(View view, int bookId) {
}
});
initialBookList();
/*
blurLayout.animate().translationY(movement).setDuration(1500).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
movement = movement > 0 ? -150 : 150;
blurLayout.animate().translationY(movement).setDuration(1500).setListener(this).start();
}
}).start();
*/
public int getLayoutRes() {
return R.layout.activity_book;
}
void setupToolbar(){
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@Override
protected void initViews() {
initialBookList();
}
@Override
protected void setupToolbar(){
super.setupToolbar();
toolbar.inflateMenu(R.menu.menu_book);//设置右上角的填充菜单
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
@ -91,22 +58,22 @@ public class BookActivity extends AppCompatActivity {
}
});
}
private void showBookDetail(String s) {
Intent intent = new Intent(this, BookActivity.class);
intent.putExtra("BOOKNAME",s);
startActivity(intent);
@Override
protected void setTitle() {
String title = getIntent().getStringExtra("BOOKNAME");
this.setTitle(title);
}
private List<String> initData(List<String> mDatas, char z) {
mDatas = new ArrayList<String>();
for (int i = 'A'; i < z; i++)
{
mDatas.add("射雕" + (char) i);
}
return mDatas;
@Override
protected void initData() {
mData =getFakeData(5);
mAdapter = getBookListAdapter(mData);
}
//----------------绑定列表
@ -135,7 +102,7 @@ public class BookActivity extends AppCompatActivity {
super.onStop();
// blurLayout.pauseBlur();
}
/*
class BookListAdapter extends RecyclerView.Adapter< BookListAdapter.MyViewHolder> {
private final int EMPTY_VIEW = 1;
private final int PROGRESS_VIEW = 2;
@ -256,4 +223,5 @@ public class BookActivity extends AppCompatActivity {
}
}
}
*/
}

View File

@ -23,6 +23,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import com.google.android.gms.plus.PlusOneButton;
import java.util.ArrayList;
@ -41,61 +42,53 @@ import butterknife.OnClick;
* create an instance of this fragment.
*/
public class Fragment_Shelf extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
public static String getFTag() {
return "com.deiniu.zhuike.Fragment_Shelf";
}
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// The request code must be 0 or greater.
private static final int PLUS_ONE_REQUEST_CODE = 0;
// The URL to +1. Must be a valid URL.
private final String PLUS_ONE_URL = "http://developer.android.com";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private boolean[] flag ;//此处添加一个boolean类型的数组
private boolean isSelectAll =true;
@BindView(R.id.llShelfBottom)
LinearLayout llShelfBottom;
@BindView(R.id.id_recyclerview)
RecyclerView mRecyclerView;
private List<String> mDatas;
private BookListAdapter mAdapter;
public Fragment_Shelf() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_Shelf.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_Shelf newInstance(String param1, String param2) {
Fragment_Shelf fragment = new Fragment_Shelf();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"Fragment_Shelf fragment onCreate ");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
protected int getLayoutRes() {
return R.layout.fragment_fragment__shelf;
}
@Override
public void initData() {
flag = new boolean[100];
mDatas = new ArrayList<String>();
for (int i = 'A'; i < 'G'; i++)
{
mDatas.add("射雕" + (char) i);
flag[i] =false;
}
initData();
mAdapter = new BookListAdapter(activity,mDatas,R.layout.recycle_list_item,new OnItemClickListener()
{
@ -121,24 +114,9 @@ public class Fragment_Shelf extends BasicFragment {
((Main2Activity) activity).fragment_shelf=this;
}
@BindView(R.id.id_recyclerview)
RecyclerView mRecyclerView;
private List<String> mDatas;
private BookListAdapter mAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
Log.d(TAG,"fragment_shelf fragment onCreateView ");
View view = inflater.inflate(R.layout.fragment_fragment__shelf, container, false);
ButterKnife.bind(this, view);
public void initViews(){
initReceyleView();
return view;
}
@ -151,19 +129,6 @@ public class Fragment_Shelf extends BasicFragment {
}
protected void initData()
{ flag = new boolean[100];
mDatas = new ArrayList<String>();
for (int i = 'A'; i < 'G'; i++)
{
mDatas.add("射雕" + (char) i);
flag[i] =false;
}
}
public void showShelfMoreSheet() {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this.activity );
bottomSheetDialog.setContentView(R.layout.fragment_shelf_more_sheet);

View File

@ -24,41 +24,17 @@ import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link Fragment_bangdan.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_bangdan#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_bangdan extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private BandanAdapter mAdapter;
private List<String> mData;
@BindView(R.id.rvBangdan)
RecyclerView rvBandan;
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public Fragment_bangdan() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_bangdan.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_bangdan newInstance(String param1, String param2) {
Fragment_bangdan fragment = new Fragment_bangdan();
Bundle args = new Bundle();
@ -69,14 +45,14 @@ public class Fragment_bangdan extends BasicFragment {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"Fragment_bangdan onCreate");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
initData();
protected int getLayoutRes() {
return R.layout.fragment_fragment_bangdan;
}
@Override
public void initData() {
mData = initData(mData,'F');
mAdapter = new BandanAdapter(activity ,mData,R.layout.recycle_list_item_bangdan,new OnItemClickListener()
{
@ -95,49 +71,31 @@ public class Fragment_bangdan extends BasicFragment {
}
@Override
public void onLinearOutClick(View view, int bookId) {
// Toast.makeText(activity, "book "+ bookId + " clicked", Toast.LENGTH_SHORT).show();
// Toast.makeText(activity, "book "+ bookId + " clicked", Toast.LENGTH_SHORT).show();
showBookDetail( mData.get(bookId));
}
});
}
//------------------------列表绑定------------
private BandanAdapter mAdapter;
private List<String> mData;
@BindView(R.id.rvBangdan)
RecyclerView rvBandan;
private void initData() {
mData = initData(mData,'F');
}
public void initViews(){
initialBookList();
}
void initialBookList() {
rvBandan.setLayoutManager(new LinearLayoutManager(activity));
rvBandan.setAdapter(mAdapter);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
Log.d(TAG,"Fragment_bangdan onCreateView");
View v = inflater.inflate(R.layout.fragment_fragment_bangdan, container, false);
ButterKnife.bind(this, v);
initialBookList() ;
return v;
}
@Override
public void setFTag() {
TAG ="com.deiniu.zhuike.Fragment_bangdan";
}
}

View File

@ -12,8 +12,11 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import com.flyco.tablayout.SlidingTabLayout;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
@ -28,46 +31,27 @@ import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link Fragment_bookStore.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_bookStore#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_bookStore extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public static String getFTag() {
return "com.deiniu.zhuike.Fragment_bookStore";
}
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
@BindView(R.id.viewpager)
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
private OnFragmentInteractionListener mListener;
public Fragment_bookStore() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_bookStore.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_bookStore newInstance(String param1, String param2) {
Fragment_bookStore fragment = new Fragment_bookStore();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@ -77,35 +61,34 @@ public class Fragment_bookStore extends BasicFragment {
super.onCreate(savedInstanceState);
Log.d(TAG,"Fragment_bookStore fragment onCreate ");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
// mParam1 = getArguments().getString(ARG_PARAM1);
// mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.d(TAG,"Fragment_bookStore fragment onCreateView ");
View v= inflater.inflate(R.layout.fragment_book_store, container, false);
ButterKnife.bind(this, v);
initTabs();
return v;
@Override
protected int getLayoutRes() {
return R.layout.fragment_book_store;
}
@Override
public void initData() {
}
@Override
public void initViews(){
initTabs();
}
//---------tabs-------------
@BindView(R.id.viewpager)
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
void initTabs() {
if(mFragments ==null || mFragments.size() ==0){
mTitle = new String[]{"精选", "榜单", "书单"};
if(mFragments ==null || mFragments.size() ==0){
mTitle = new String[]{"精选", "榜单", "书单"};
mFragments = new ArrayList<>();
mFragments.add(new Fragment_jingxuan());
mFragments.add(new Fragment_bangdan());
@ -113,7 +96,7 @@ public class Fragment_bookStore extends BasicFragment {
Log.d(TAG,"initial fragments in tabs ");
}
Log.d(TAG,"set viewPager adapter ");
// FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
// FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(getChildFragmentManager()) {
@Override
public Fragment getItem(int position) {
@ -132,50 +115,10 @@ public class Fragment_bookStore extends BasicFragment {
};
mViewpager.setAdapter(mAdapter);
tabLayout.setViewPager(mViewpager);
// tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
// tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
mViewpager.setCurrentItem(0);
}
/*
View viewpagerA = getLayoutInflater().inflate(R.layout.fragment_jingxuan, null);
View viewpagerB = getLayoutInflater().inflate(R.layout.fragment_fragment_bangdan, null);
View viewpagerC = getLayoutInflater().inflate(R.layout.fragment_shudan, null);
mList = new ArrayList<>();
mList.add(viewpagerA);
mList.add(viewpagerB);
mList.add(viewpagerC);
mViewpager.setAdapter(new PagerAdapter() {
@Override
public int getCount(){
return mList.size();
}
@Override
public boolean isViewFromObject(View view, Object object){
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container,int position){
View view = mList.get(position);
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object){
container.removeView((View) object);
}
@Override
public CharSequence getPageTitle(int position){
return mTitle[position];
}
});
*/

View File

@ -11,7 +11,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.deiniu.zhuike.utils.BandanAdapter;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import com.google.android.gms.plus.PlusOneButton;
import java.util.List;
@ -28,48 +30,35 @@ import butterknife.ButterKnife;
* create an instance of this fragment.
*/
public class Fragment_booklist extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// The request code must be 0 or greater.
private static final int PLUS_ONE_REQUEST_CODE = 0;
// The URL to +1. Must be a valid URL.
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@BindView(R.id.rvBooklist)
RecyclerView rvBooklist;
public Fragment_booklist() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_booklist.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_booklist newInstance(String param1, String param2) {
Fragment_booklist fragment = new Fragment_booklist();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
protected int getLayoutRes() {
return R.layout.fragment_fragment_booklist;
}
@Override
public void initData() {
mData =initData(mData,'Z');
mAdapter = new BookListAdapter(activity, mData, R.layout.recycle_list_item_shudan, new OnItemClickListener() {
@ -90,52 +79,25 @@ public class Fragment_booklist extends BasicFragment {
Toast.LENGTH_SHORT).show();
}
});
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_fragment_booklist, container, false);
//Find the +1 button
ButterKnife.bind(this, view);
public void initViews(){
initialBookList();
return view;
}
//----------------绑定列表
BasicFragment.BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@BindView(R.id.rvBooklist)
RecyclerView rvBooklist;
//----------------绑定列表
void initialBookList() {
rvBooklist.setLayoutManager(new LinearLayoutManager(activity));
rvBooklist.setAdapter(mAdapter);
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void setFTag() {
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}

View File

@ -24,6 +24,7 @@ import com.bumptech.glide.Glide;
import com.deiniu.zhuike.utils.CyclePageIndicator;
import com.deiniu.zhuike.utils.MyViewPager;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
@ -38,28 +39,25 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link Fragment_jingxuan.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_jingxuan#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_jingxuan extends BasicFragment implements OnBannerListener {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
public class Fragment_jingxuan extends BasicFragment implements OnBannerListener {
private String mParam1;
private String mParam2;
//@BindView(R.id.llTuijian)
// LinearLayout llTuijian;
@BindView(R.id.banner)
Banner banner;
@BindView(R.id.dot_horizontal)
LinearLayout cyclell;
@BindView(R.id.viewpager_tuijian)
MyViewPager mViewpagerTuijian;
//@BindView(R.id.titleIndictator)
// TitlePageIndicator titleIndicator;
private List<Fragment> mFragments;
private ArrayList<View> mList;
// String[] mTitle;
private ArrayList<String> list_path;
private ArrayList<String> list_title;
@ -69,8 +67,49 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
}
public static Fragment_jingxuan newInstance(String param1, String param2) {
Fragment_jingxuan fragment = new Fragment_jingxuan();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
@Override
protected int getLayoutRes() {
return R.layout.fragment_jingxuan;
}
@Override
public void initData() {
mHotNewData_l = initData(mHotNewData_l,'B');
mHotNewData_g= initData(mHotNewData_g,'D');
mHotLianZaiData_l= initData(mHotLianZaiData_l,'C');
mHotLianZaiData_g=initData(mHotLianZaiData_g,'D');
mFinishedData_l=initData(mFinishedData_l,'A');
mFinishedData_g=initData(mFinishedData_g,'G');
}
@Override
public void initViews(){
testBanner(banner, this);
initTuijianPagers();
initialBookList();
}
@Override
public void setFTag() {
TAG ="com.deiniu.zhuike.Fragment_jingxuan";
}
@OnClick({R.id.buttonMoreHot,R.id.buttonMoreLianzai,R.id.buttonMoreTuijian,R.id.buttonMoreWanben
,R.id.buttonCatePingfen,R.id.buttonCateRegeng ,R.id.buttonCateTuijian,R.id.buttonCateShoucang,R.id.buttonCateWanjie
,R.id.buttonCatePingfen,R.id.buttonCateRegeng ,R.id.buttonCateTuijian,R.id.buttonCateShoucang,R.id.buttonCateWanjie
})
void bubmitButton(View view) {
@ -104,61 +143,6 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
break;
}
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_jingxuan.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_jingxuan newInstance(String param1, String param2) {
Fragment_jingxuan fragment = new Fragment_jingxuan();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"Fragment_jingxuan onCreate");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
initData();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
Log.d(TAG, " Fragment_jingxuan onCreateView");
View v = inflater.inflate(R.layout.fragment_jingxuan, container, false);
ButterKnife.bind(this, v);
testBanner(banner, this);
// testBanner2(banner2,new BannerListioner2());
initTuijianPagers();
initialBookList();
return v;
}
@Override
public void setFTag() {
TAG ="com.deiniu.zhuike.Fragment_jingxuan";
}
void testBanner(Banner banner,OnBannerListener listioner) {
//放图片地址的集合
@ -217,15 +201,7 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
//cycle viewpagers
//---------重磅推荐-------------
@BindView(R.id.dot_horizontal)
LinearLayout cyclell;
@BindView(R.id.viewpager_tuijian)
MyViewPager mViewpagerTuijian;
//@BindView(R.id.titleIndictator)
// TitlePageIndicator titleIndicator;
private List<Fragment> mFragments;
ArrayList<View> mList;
// String[] mTitle;
void initTuijianPagers() {
if (mFragments == null || mFragments.size() == 0) {
@ -425,30 +401,6 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
}));
}
void initData() {
mHotNewData_l = initData(mHotNewData_l,'B');
mHotNewData_g= initData(mHotNewData_g,'D');
mHotLianZaiData_l= initData(mHotLianZaiData_l,'C');
mHotLianZaiData_g=initData(mHotLianZaiData_g,'D');
mFinishedData_l=initData(mFinishedData_l,'A');
mFinishedData_g=initData(mFinishedData_g,'G');
}
}

View File

@ -13,58 +13,20 @@ import com.google.android.gms.plus.PlusOneButton;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* A fragment with a Google +1 button.
* Activities that contain this fragment must implement the
* {@link Fragment_jingxuan_tuijian.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_jingxuan_tuijian#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_jingxuan_tuijian extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// The request code must be 0 or greater.
private static final int PLUS_ONE_REQUEST_CODE = 0;
// The URL to +1. Must be a valid URL.
private final String PLUS_ONE_URL = "http://developer.android.com";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public Fragment_jingxuan_tuijian() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_jingxuan_tuijian.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_jingxuan_tuijian newInstance(String param1, String param2) {
Fragment_jingxuan_tuijian fragment = new Fragment_jingxuan_tuijian();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -89,17 +51,19 @@ public class Fragment_jingxuan_tuijian extends BasicFragment {
showBookDetail("ZXF");
break;
}
}
@Override
protected int getLayoutRes() {
return R.layout.fragment_jingxuan_tuijian;
}
@Override
public void initData() {
}
@Override
public void onResume() {
super.onResume();
public void initViews(){
}

View File

@ -1,146 +0,0 @@
package com.deiniu.zhuike;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.flyco.tablayout.SlidingTabLayout;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link Fragment_other.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_other#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_other extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
public static String getFTag() {
return "com.deiniu.zhuike.Fragment_other";
}
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public Fragment_other() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_other.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_other newInstance(String param1, String param2) {
Fragment_other fragment = new Fragment_other();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"Fragment_other fragment onCreate ");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
Log.d(TAG,"Fragment_other fragment onCreateView ");
View view = inflater.inflate(R.layout.fragment_other, container, false);
ButterKnife.bind(this, view);
initTabs();
return view;
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void setFTag() {
TAG="com.deiniu.zhuike.Fragment_other";
}
@BindView(R.id.viewpager)
ViewPager mViewpager;
@BindView(R.id.tab_layout)
SlidingTabLayout tabLayout;
private ArrayList<Fragment> mFragments;
ArrayList<View> mList;
String[] mTitle;
void initTabs() {
if(mFragments ==null || mFragments.size() ==0){
mTitle = new String[]{"最新发布", "本周最热", "最多收藏","小编推荐"};
mFragments = new ArrayList<>();
mFragments.add(new Fragment_shudan_list());
mFragments.add(new Fragment_shudan_list());
mFragments.add(new Fragment_shudan_list());
mFragments.add(new Fragment_shudan_list());
Log.d(TAG,"initial fragments in tabs ");
}
Log.d(TAG,"set viewPager adapter ");
// FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(activity.getSupportFragmentManager()) { 第一次进入没问题再次进入ViewPager的fragment时里面内容就没了,数据丢失 https://blog.csdn.net/allan_bst/article/details/64920076
FragmentPagerAdapter mAdapter = new FragmentPagerAdapter(getChildFragmentManager()) {
@Override
public Fragment getItem(int position) {
return mFragments.get(position);
}
@Override
public int getCount() {
return mFragments.size();
}
//ViewPager与TabLayout绑定后这里获取到PageTitle就是Tab的Text
@Override
public CharSequence getPageTitle(int position) {
return mTitle[position];
}
};
mViewpager.setAdapter(mAdapter);
tabLayout.setViewPager(mViewpager);
// tabLayout.setViewPager(mViewpager, mTitle, activity, mFragments);
mViewpager.setCurrentItem(0);
}
}

View File

@ -15,6 +15,7 @@ import android.widget.TextView;
import android.widget.Toast;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
@ -27,49 +28,37 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* A fragment with a Google +1 button.
* Activities that contain this fragment must implement the
* {@link Fragment_paihang.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_paihang#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_paihang extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// The request code must be 0 or greater.
private static final int PLUS_ONE_REQUEST_CODE = 0;
// The URL to +1. Must be a valid URL.
public static String getFTag() {
return "com.deiniu.zhuike.Fragment_paihang";
}
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private ArrayList<CustomTabEntity> mData1,mData2,mData3 ;
private int tab1Pos,tab2Pos,tab3Pos;
private BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@BindView(R.id.rvPaihang)
RecyclerView rvPaihang;
@BindView(R.id.tab_layout1)
CommonTabLayout tabLayout1;
@BindView(R.id.tab_layout2)
CommonTabLayout tabLayout2;
@BindView(R.id.tab_layout3)
CommonTabLayout tabLayout3;
public Fragment_paihang() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_paihang.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_paihang newInstance(String param1, String param2) {
Fragment_paihang fragment = new Fragment_paihang();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@ -78,33 +67,20 @@ public class Fragment_paihang extends BasicFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
initData();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_fragment_paihang, container, false);
ButterKnife.bind(this, view);
// if (mData1 == null)
{
initTabs();
initialBookList();
setScrollListner();
}
return view;
protected int getLayoutRes() {
return R.layout.fragment_fragment_paihang;
}
@Override
public void initData() {
private ArrayList<CustomTabEntity> mData1,mData2,mData3 ;
private int tab1Pos,tab2Pos,tab3Pos;
void initData(){
mData =initData(mData,'Z');
mData1= new ArrayList<>();
mData2 = new ArrayList<>();
@ -115,7 +91,7 @@ public class Fragment_paihang extends BasicFragment {
{
mData2.add(new TabEntry("" + (char) i,0,0) );
if(i<'D')
mData3.add(new TabEntry("" + (char) i,0,0) );
mData3.add(new TabEntry("" + (char) i,0,0) );
}
mAdapter = new BookListAdapter(activity, mData, R.layout.recycle_list_item_shudan, new OnItemClickListener() {
@ -137,6 +113,14 @@ public class Fragment_paihang extends BasicFragment {
}
});
}
@Override
public void initViews(){
initTabs();
initialBookList();
setScrollListner();
}
class TabEntry implements CustomTabEntity{
public String title;
@ -165,18 +149,8 @@ public class Fragment_paihang extends BasicFragment {
}
}
@BindView(R.id.tab_layout1)
CommonTabLayout tabLayout1;
@BindView(R.id.tab_layout2)
CommonTabLayout tabLayout2;
@BindView(R.id.tab_layout3)
CommonTabLayout tabLayout3;
private void initTabs() {
tabLayout1.setTabData(mData1);
tabLayout1.setOnTabSelectListener(new OnTabSelectListener() {
@Override
@ -241,20 +215,12 @@ public class Fragment_paihang extends BasicFragment {
//----------------绑定列表
BasicFragment.BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@BindView(R.id.rvPaihang)
RecyclerView rvPaihang;
void initialBookList() {
rvPaihang.setLayoutManager(new LinearLayoutManager(activity));
rvPaihang.setAdapter(mAdapter);
}
@ -303,9 +269,6 @@ public class Fragment_paihang extends BasicFragment {
}
@Override
public void onResume() {
super.onResume();
@ -315,19 +278,11 @@ public class Fragment_paihang extends BasicFragment {
}
@Override
public void setFTag() {
}
@Override
public void onDetach() {
super.onDetach();
}
}

View File

@ -28,22 +28,9 @@ import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* {@link Fragment_shudan.OnFragmentInteractionListener} interface
* to handle interaction events.
* Use the {@link Fragment_shudan#newInstance} factory method to
* create an instance of this fragment.
*/
public class Fragment_shudan extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private String mParam1;
private String mParam2;
public class Fragment_shudan extends BasicFragment {
@BindView(R.id.fab)
FloatingActionButton fab;
private BottomSheetDialog bottomSheetDialog;
@ -51,42 +38,27 @@ public class Fragment_shudan extends BasicFragment {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment Fragment_shudan.
*/
// TODO: Rename and change types and number of parameters
public static Fragment_shudan newInstance(String param1, String param2) {
Fragment_shudan fragment = new Fragment_shudan();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG,"Fragment_shudan onCreate");
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
protected int getLayoutRes() {
return R.layout.fragment_shudan;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
Log.d(TAG,"Fragment_shudan onCreateView");
public void initData() {
View v= inflater.inflate(R.layout.fragment_shudan, container, false);
ButterKnife.bind(this, v);
}
@Override
public void initViews(){
initTabs();
fab.setOnClickListener(new View.OnClickListener() {
@ -95,7 +67,7 @@ public class Fragment_shudan extends BasicFragment {
showShelfMoreSheet();
}
});
return v;
}
@Override
@ -190,7 +162,7 @@ public class Fragment_shudan extends BasicFragment {
btnMyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, Activity_createShudan.class);
Intent intent = new Intent(activity, Activity_shudan_my.class);
startActivity(intent);
}

View File

@ -14,6 +14,7 @@ import android.view.ViewGroup;
import android.widget.Toast;
import com.deiniu.zhuike.utils.OnItemClickListener;
import com.deiniu.zhuike.utils.adapter.BookListAdapter;
import com.google.android.gms.plus.PlusOneButton;
import java.util.ArrayList;
@ -23,20 +24,15 @@ import butterknife.BindView;
import butterknife.ButterKnife;
public class Fragment_shudan_list extends BasicFragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// The request code must be 0 or greater.
private static final int PLUS_ONE_REQUEST_CODE = 0;
// The URL to +1. Must be a valid URL.
private final String PLUS_ONE_URL = "http://developer.android.com";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private char cnt;
BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@BindView(R.id.rvShudan)
RecyclerView rvShudan;
public Fragment_shudan_list() {
// Required empty public constructor
@ -47,7 +43,7 @@ public class Fragment_shudan_list extends BasicFragment {
Fragment_shudan_list fragment = new Fragment_shudan_list();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, "" );
fragment.setArguments(args);
return fragment;
@ -57,15 +53,30 @@ public class Fragment_shudan_list extends BasicFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
protected int getLayoutRes() {
return R.layout.fragment_fragment_shudan_list;
}
@Override
public void initData() {
mData = new ArrayList<String>();
for (int i = 'A'; i < 'X'; i++)
{
mData.add("读者书单" + (char) i);
}
initData();
mAdapter = new BookListAdapter(activity, mData, R.layout.recycle_list_item_shudan, new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
showShudanDetail(position);
showShudanDetail(position);
}
@Override
@ -81,17 +92,9 @@ public class Fragment_shudan_list extends BasicFragment {
}
});
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_fragment_shudan_list, container, false);
ButterKnife.bind(this, view);
public void initViews(){
initialBookList();
return view;
}
@Override
@ -115,24 +118,12 @@ public class Fragment_shudan_list extends BasicFragment {
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
//---------------------------------------------------book cate list-------------------------------begin
BasicFragment.BookListAdapter mAdapter;
// private BookListAdapter mAdapter;
private List<String> mData;;
@BindView(R.id.rvShudan)
RecyclerView rvShudan;
private void initData() {
mData = new ArrayList<String>();
for (int i = 'A'; i < 'X'; i++)
{
mData.add("读者书单" + (char) i);
}
}
void initialBookList() {
rvShudan.setLayoutManager(new LinearLayoutManager(activity));

View File

@ -54,7 +54,7 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
public class Main2Activity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener , BasicFragment.OnFragmentInteractionListener {
implements NavigationView.OnNavigationItemSelectedListener{//} , BasicFragment.OnFragmentInteractionListener {
public MyApp app ;
public static String TAG ="com.deiniu.zhuike.Main2Activity";
@BindView(R.id.toolbar)
@ -71,29 +71,10 @@ public class Main2Activity extends AppCompatActivity
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main2);
// getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.activity_title_layout);
ButterKnife.bind(this);
creatToolbar();
setupNavi();
// botoomNavigation.setSelectedItemId(botoomNavigation.getMenu().getItem(2).getItemId());
showHome();
//swithToolbarItems();
// showBookStore();
// initTabs();
// banner = (Banner) findViewById(R.id.banner);
// testBanner(banner);
// banner2 = (Banner) findViewById(R.id.banner2);
// testBanner(banner2);
getDataFromServer();
@ -140,7 +121,7 @@ public class Main2Activity extends AppCompatActivity
// toolbar.setNavigationIcon(R.mipmap.ic_launcher_round);//设置导航栏图标
// toolbar.setLogo(R.mipmap.ic_launcher);//设置app logo
// toolbar.setTitle("Title");//设置主标题
setTitle("titleaa");
// setTitle("titleaa");
// toolbar.setSubtitle("Subtitle");//设置子标题
toolbar.inflateMenu(R.menu.main);//设置右上角的填充菜单
@ -365,10 +346,7 @@ private int bottomSelectedIndex;
}
private void showOther() {
Fragment_other fragment = (Fragment_other) getSupportFragmentManager()
.findFragmentByTag(Fragment_other.getFTag());
if(fragment ==null) fragment =new Fragment_other();
showFragment(fragment ,Fragment_other.getFTag());
}
@ -426,11 +404,6 @@ private int bottomSelectedIndex;
@Override
public void onFragmentInteraction(Uri uri) {
Toast.makeText(this,"交流,角楼",Toast.LENGTH_LONG).show();
}
long firstTime =0;
@Override

View File

@ -21,43 +21,30 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class activity_cates extends AppCompatActivity {
public class activity_cates extends Activity_base {
@BindView(R.id.recycleViewCateList)
RecyclerView mRecyclerView;
private List<String> mDatas;
private BookListAdapter mAdapter;
//@BindView(R.id.textTile)
//TextView tvTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_cates);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ButterKnife.bind(this);
// getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.activity_title_layout);
// tvTitle.setText("小说分类");
// setTitle("小说分类");
initData();
mAdapter = new BookListAdapter(this,mDatas,R.layout.recycle_list_item_cates,new OnItemClickLitener()
{
@Override
public void onItemClick(View view, int position)
{
showCateList( mDatas.get(position));
}
});
public int getLayoutRes() {
return R.layout.activity_cates;
}
@Override
protected void initViews() {
initReceyleView();
}
@Override
protected void setTitle() {
}
interface OnItemClickLitener
{
void onItemClick(View view, int position);
@ -70,15 +57,20 @@ public class activity_cates extends AppCompatActivity {
startActivity(intent);
}
@Override
protected void initData() {
mDatas = getFakeData(5);
mAdapter = new BookListAdapter(this, mDatas, R.layout.recycle_list_item_cates, new OnItemClickLitener() {
@Override
public void onItemClick(View view, int position) {
showCateList(mDatas.get(position));
private void initData() {
mDatas = new ArrayList<String>();
for (int i = 'A'; i <'K'; i++)
{
mDatas.add("小说分类" + (char) i);
}
});
}
}
void initReceyleView() {
@ -178,7 +170,7 @@ public class activity_cates extends AppCompatActivity {
class MyViewHolder extends RecyclerView.ViewHolder
{
@BindView(R.id.tvCateName)
TextView tvTitle;
TextView tvTitle;
@BindView(R.id.tvCateNums)
TextView tvNum;

View File

@ -0,0 +1,117 @@
package com.deiniu.zhuike.utils.adapter;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.deiniu.zhuike.R;
import com.deiniu.zhuike.utils.OnItemClickListener;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class BookListAdapter extends RecyclerView.Adapter< MyViewHolder> {
private final int EMPTY_VIEW = 1;
private final int PROGRESS_VIEW = 2;
private final int IMAGE_VIEW = 3;
private Context context;
private List<String> mDatas = new ArrayList<String>();
private OnItemClickListener mOnItemClickListener;
private int listItemID;
public BookListAdapter(Context context, List<String> mDatas, int listItemID, OnItemClickListener clickLitener) {
this.context = context;
this.mDatas = mDatas;
this.mOnItemClickListener = clickLitener;
this.listItemID = listItemID;
}
public BookListAdapter(Context context, OnItemClickListener clickLitener) {
this.context = context;
this.mOnItemClickListener = clickLitener;
}
@Override
public int getItemViewType(int position) {
if (mDatas.size() == 0) {
return EMPTY_VIEW;
} else if (mDatas.get(position) == null) {
return PROGRESS_VIEW;
} else {
return super.getItemViewType(position);
}
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
context).inflate(listItemID, parent,
false));
return holder;
}
public void setParameters(List<String> mDatas, int listItemID) {
this.mDatas = mDatas;
this.listItemID = listItemID;
}
public void setOnItemClickLitener(OnItemClickListener mOnItemClickLitener) {
this.mOnItemClickListener = mOnItemClickLitener;
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
holder.tvTitle.setText(mDatas.get(position));
if (holder.tvAuthor != null) holder.tvAuthor.setText("金庸" + position);
if (holder.tvCate != null) holder.tvCate.setText("cate" + position);
if (holder.tvDesc != null) holder.tvDesc.setText("this is desc " + position);
if(holder.tvNum!=null)holder.tvNum.setText("999");
// 如果设置了回调则设置点击事件
if (mOnItemClickListener != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int pos = holder.getLayoutPosition();
mOnItemClickListener.onItemClick(holder.itemView, pos);
}
});
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
int pos = holder.getLayoutPosition();
mOnItemClickListener.onItemLongClick(holder.itemView, pos);
return false;
}
});
}
}
@Override
public int getItemCount() {
return mDatas.size();
}
public void addData(int position) {
mDatas.add(position, "Insert One");
notifyItemInserted(position);
}
public void removeData(int position) {
mDatas.remove(position);
notifyItemRemoved(position);
}
}

View File

@ -0,0 +1,39 @@
package com.deiniu.zhuike.utils.adapter;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.deiniu.zhuike.R;
import butterknife.BindView;
import butterknife.ButterKnife;
public class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.imageView)
ImageView imageView;
@BindView(R.id.title)
TextView tvTitle;
@Nullable
@BindView(R.id.author)
TextView tvAuthor;
@Nullable
@BindView(R.id.category)
TextView tvCate;
@Nullable
@BindView(R.id.desc)
TextView tvDesc;
@Nullable
@BindView(R.id.tvCateNums)
TextView tvNum;
public MyViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
//tvTitle = (TextView) view.findViewById(R.id.title);
// tvAuthor = (TextView) view.findViewById(R.id.author);
}
}

View File

@ -48,51 +48,50 @@
android:id="@+id/head_img2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/side_bg" />
android:src="@mipmap/side_bg2"
android:alpha="0.6"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_width="100dp"
android:layout_height="120dp"
android:layout_margin="10dp"
android:layout_weight="0"
android:gravity="left"
android:src="@drawable/googleg_standard_color_18" />
android:scaleType="fitXY"
android:src="@mipmap/side_bg" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="left"
style="@style/TextViewHead.bold"
android:text="射雕英雄传"
android:textColor="#212121" />
android:layout_height="30dp"
/>
<TextView
android:id="@+id/desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:maxLength="70"
style="@style/TextViewHead"
android:maxLines="2"
android:text="吹牛逼的都是年轻人"
android:textColor="@color/common_google_signin_btn_text_light"
android:textSize="12sp" />
android:text="xxxxxxxxxxxxxxxxxxxxx"
/>
<LinearLayout
android:layout_width="match_parent"
@ -102,18 +101,16 @@
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextViewHead"
android:text="金庸"
android:textColor="#212121" />
/>
<TextView
android:id="@+id/category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextViewHead"
android:layout_marginLeft="5dp"
android:text="武侠小说"
android:textColor="@color/colorAccent" />
/>
</LinearLayout>
</LinearLayout>
@ -131,9 +128,10 @@
app:layout_collapseMode="pin"
app:popupTheme="@style/ToolBarTheme.PopupOverlay" >
<TextView android:id="@+id/mTextMessage"
<Button android:id="@+id/mTextMessage"
style="@style/buttonCates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="10dp"
android:text="书架" />

View File

@ -4,6 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="-2dp"
android:id="@+id/swipeLayout" >
<!-- TODO: Update blank fragment layout -->
<android.support.v7.widget.RecyclerView
@ -14,6 +15,7 @@
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"
android:paddingBottom="50dp"
android:layout_marginBottom="-2dp"
/>
</android.support.v4.widget.SwipeRefreshLayout>

View File

@ -9,6 +9,7 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- TODO: Update blank fragment layout -->
@ -34,7 +35,8 @@
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:layout_marginBottom="45dp"
>
<!-- <android.support.design.widget.TabLayout
android:id="@+id/tab_layout"

View File

@ -4,13 +4,13 @@
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:gravity="bottom|center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
android:theme="@style/ThemeOverlay.AppCompat.Light">
<ImageView
android:id="@+id/imageView"
@ -24,7 +24,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="@string/nav_header_title"
android:text="读者x"
android:gravity="center_horizontal"
android:textColor="@color/white"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView

View File

@ -38,6 +38,7 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation" />
</android.support.constraint.ConstraintLayout>

View File

@ -3,7 +3,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout style="@style/llGraySplit"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
@ -253,10 +253,5 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/ghostwhite"
android:orientation="horizontal" />
</LinearLayout>

View File

@ -6,33 +6,42 @@
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_camera"
android:icon="@drawable/ic_menu_camera"
android:title="Import" />
android:icon="@drawable/ic_mood_black_24dp"
android:title="消息通知" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="Gallery" />
android:icon="@drawable/ic_mood_black_24dp"
android:title="最近浏览" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="Slideshow" />
android:icon="@drawable/ic_mood_black_24dp"
android:title="我的书单" />
<item
android:id="@+id/nav_manage"
android:icon="@drawable/ic_menu_manage"
android:title="Tools" />
android:id="@+id/nav_huancun"
android:icon="@drawable/ic_mood_black_24dp"
android:title="缓存管理" />
<item
android:id="@+id/nav_haoping"
android:icon="@drawable/ic_mood_black_24dp"
android:title="给个好评" />
<item
android:id="@+id/nav_fenxiang"
android:icon="@drawable/ic_menu_share"
android:title="分享应用" />
<item
android:id="@+id/nav_advice"
android:icon="@drawable/ic_mood_black_24dp"
android:title="意见反馈" />
<item
android:id="@+id/nav_nightmode"
android:icon="@drawable/ic_mood_black_24dp"
android:title="夜间模式" />
<item
android:id="@+id/nav_setup"
android:icon="@drawable/ic_menu_send"
android:title="设置" />
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
android:title="Share" />
<item
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="Send" />
</menu>
</item>
</menu>

View File

@ -190,5 +190,18 @@
</style>
<style name="TextViewHead">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/white</item>
<item name="android:layout_gravity">left</item>
</style>
<style name="TextViewHead.bold">
<item name="android:textStyle">bold</item>
</style>
</resources>