new novel project

This commit is contained in:
mwang 2019-02-02 17:27:23 +08:00
parent 99702e788b
commit cab4703572
18 changed files with 564 additions and 24 deletions

View File

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="Gradle: com.google.android:support-v4:r7@jar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.android/support-v4/r7/24d0f6da34c3a2bfcf736ab42d51c91ac821ee22/support-v4-r7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.android/support-v4/r7/7ba1bec42f82297895e2a2631168a0c86e392e34/support-v4-r7-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -57,4 +57,5 @@ dependencies {
api 'com.github.bumptech.glide:glide:4.6.1'
api 'org.xutils:xutils:3.5.0'
implementation 'com.google.code.gson:gson:2.8.5'
// implementation 'com.viewpagerindicator:library:2.4.1'
}

View File

@ -18,7 +18,7 @@
<activity
android:name=".Main4Activity"
android:label="@string/title_activity_main4"
android:theme="@style/ToolBarTheme.NoActionBar"></activity>
android:theme="@style/ToolBarTheme.NoActionBar" />
<activity
android:name=".Main3Activity"
android:label="@string/title_activity_main3" />

View File

@ -4,6 +4,9 @@ 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.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -11,6 +14,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.deiniu.zhuike.utils.MyViewPager;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
@ -18,6 +22,7 @@ import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.loader.ImageLoader;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -83,7 +88,10 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
View v= inflater.inflate(R.layout.fragment_jingxuan, container, false);
ButterKnife.bind(this, v);
testBanner(banner,this);
testBanner(banner2,new BannerListioner2());
// testBanner2(banner2,new BannerListioner2());
initTuijianPagers();
return v;
}
@ -95,8 +103,8 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
@BindView(R.id.banner)
Banner banner;
@BindView(R.id.banner2)
Banner banner2;
// @BindView(R.id.banner2)
// Banner banner2;
private ArrayList<String> list_path;
private ArrayList<String> list_title;
@ -151,6 +159,66 @@ public class Fragment_jingxuan extends BasicFragment implements OnBannerListener
Glide.with(context).load((String) path).into(imageView);
}
}
//cycle viewpagers
//---------tabs-------------
@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) {
mTitle = new String[]{"精选", "榜单", "书单"};
mFragments = new ArrayList<>();
mFragments.add(new Fragment_jingxuan_tuijian());
mFragments.add(new Fragment_jingxuan_tuijian());
mFragments.add(new Fragment_jingxuan_tuijian());
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];
}
};
mViewpagerTuijian.setAdapter(mAdapter);
}
}
class BannerListioner1 implements OnBannerListener {
@ -165,4 +233,6 @@ class BannerListioner2 implements OnBannerListener {
public void OnBannerClick(int position) {
Log.i("第二个banner", "你点了第二个banner 第"+position+"张轮播图");
}
}
}

View File

@ -0,0 +1,90 @@
package com.deiniu.zhuike;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.plus.PlusOneButton;
/**
* 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,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_jingxuan_tuijian, container, false);
return view;
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void setFTag() {
TAG="com.deiniu.zhuike.Fragment_jingxuan_tuijian";
}
}

View File

@ -147,9 +147,9 @@ public class Main2Activity extends AppCompatActivity
//setSupportActionBar(toolbar);
// toolbar.setNavigationIcon(R.mipmap.ic_launcher_round);//设置导航栏图标
// toolbar.setLogo(R.mipmap.ic_launcher);//设置app logo
toolbar.setTitle("Title");//设置主标题
setTitle("title");
toolbar.setSubtitle("Subtitle");//设置子标题
// toolbar.setTitle("Title");//设置主标题
// setTitle("title");
// toolbar.setSubtitle("Subtitle");//设置子标题
toolbar.inflateMenu(R.menu.main);//设置右上角的填充菜单
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

View File

@ -0,0 +1,35 @@
package com.deiniu.zhuike.utils;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.View;
public class MyViewPager extends ViewPager {
public MyViewPager(Context context) {
super(context);
}
public MyViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if (h > height)
height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/colorAccent"
tools:targetApi="lollipop">
<!--为drawable 赋一个color 值,是不生效的-->
<item
android:id="@android:id/mask"
android:drawable="@color/common_google_signin_btn_text_light_disabled" />
</ripple>
<!--
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent">
<item
android:id="@android:id/mask"
android:drawable="@color/colorPrimaryDark" />
</ripple>
-->
<!--以此作为 backGround时控件初始时使用 item 作为bg ; 按压时会有一个色值渐变效果,按住不松时会显示 ripple 和 item 中颜色的混合值;
松手的瞬间会显示 ripple 中色值然后再渐变为item中的色值-->
<!--
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/colorAccent"
tools:targetApi="lollipop">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorAccent" />
<corners android:radius="10dp" />
</shape>
</item>
</ripple>
-->

View File

@ -42,6 +42,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="@dimen/fab_margin"
android:visibility="gone"
app:srcCompat="@android:drawable/ic_dialog_email" />

View File

@ -6,7 +6,6 @@
android:layout_height="match_parent"
tools:context=".Fragment_bookStore">
<!-- TODO: Update blank fragment layout -->
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"

View File

@ -11,10 +11,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="match_parent" android:orientation="vertical"
tools:context=".Fragment_jingxuan">
<android.support.v4.widget.NestedScrollView
android:id="@+id/n_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
@ -21,6 +23,8 @@
android:orientation="vertical"
>
<com.youth.banner.Banner
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/banner"
@ -28,40 +32,83 @@
android:layout_height="150dp" />
<include layout="@layout/fragment_jingxuan_cates"/>
<com.youth.banner.Banner
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/banner2"
android:layout_width="match_parent"
android:layout_height="150dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_margin="6dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="left"
android:text="重磅推荐"
android:layout_weight="1"
android:textColor="#212121" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="right"
android:gravity="right"
android:text="更多>>"
android:layout_weight="1"
android:textColor="#212121" />
</LinearLayout>
<com.deiniu.zhuike.utils.MyViewPager
android:id="@+id/viewpager_tuijian"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.deiniu.zhuike.utils.MyViewPager>
<!--
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titleIndictator"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
-->
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="哈"
android:text=" "
android:textColor="#0f0"
android:textSize="200sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="哈"
android:text=" "
android:textColor="#0f0"
android:textSize="200sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="哈"
android:text=" "
android:textColor="#0f0"
android:textSize="200sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="哈"
android:text=" "
android:textColor="#0f0"
android:textSize="200sp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
</LinearLayout>

View File

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="推荐"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="收藏"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="评分"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="完结"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="60dp"
android:layout_height="70dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="热更"
android:textColor="#212121" />
</LinearLayout>.
</LinearLayout>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="120dp"
android:layout_height="120dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="天龙八部"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="120dp"
android:layout_height="120dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="射雕英雄传"
android:textColor="#212121" />
</LinearLayout>.
<LinearLayout
android:orientation="vertical"
android:layout_width="120dp"
android:layout_height="120dp"
android:gravity="center"
android:background="@drawable/item_selector"
android:clickable="true"
android:layout_weight="1">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_weight="1"
android:gravity="center"
android:src="@drawable/googleg_standard_color_18" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="神雕侠侣"
android:textColor="#212121" />
</LinearLayout>.
</LinearLayout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ripple>

View File

@ -1,8 +1,8 @@
<resources>
<string name="app_name">zhuike</string>
<string name="title_home">Home</string>
<string name="title_dashboard">Dashboard</string>
<string name="title_notifications">Notifications</string>
<string name="title_home">书架</string>
<string name="title_dashboard">书城</string>
<string name="title_notifications">排行榜</string>
<string name="test">test</string>
<!-- TODO: Remove or change this placeholder text -->

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>

View File

@ -166,6 +166,7 @@
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.8.5@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:slidingpanelayout:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android:support-v4:r7@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:collections:28.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui:28.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:asynclayoutinflater:28.0.0@aar" level="project" />