new novel project
This commit is contained in:
parent
810a2bcb65
commit
99702e788b
|
@ -0,0 +1,10 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Gradle: com.google.android.gms:play-services-audience:16.0.0@aar">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-audience-16.0.0.aar/fa59c5b3e22de28e79fd738000b4b93f/jars/classes.jar!/" />
|
||||
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-audience-16.0.0.aar/fa59c5b3e22de28e79fd738000b4b93f/res" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,10 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Gradle: com.google.android.gms:play-services-base:16.0.1@aar">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-base-16.0.1.aar/b42b6a408eca0867c80d95996d3e5654/res" />
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-base-16.0.1.aar/b42b6a408eca0867c80d95996d3e5654/jars/classes.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,10 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Gradle: com.google.android.gms:play-services-basement:16.0.1@aar">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-basement-16.0.1.aar/079b5a747272fb2955fcb909711cd336/jars/classes.jar!/" />
|
||||
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-basement-16.0.1.aar/079b5a747272fb2955fcb909711cd336/res" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,10 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Gradle: com.google.android.gms:play-services-plus:16.0.0@aar">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-plus-16.0.0.aar/73d8d25f4b625d35bbc831ff0f59789b/res" />
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-plus-16.0.0.aar/73d8d25f4b625d35bbc831ff0f59789b/jars/classes.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -0,0 +1,10 @@
|
|||
<component name="libraryTable">
|
||||
<library name="Gradle: com.google.android.gms:play-services-tasks:16.0.1@aar">
|
||||
<CLASSES>
|
||||
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-tasks-16.0.1.aar/c05355a86430d460d91f4a335962c12b/res" />
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/play-services-tasks-16.0.1.aar/c05355a86430d460d91f4a335962c12b/jars/classes.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -43,6 +43,7 @@ dependencies {
|
|||
implementation 'com.android.support:support-vector-drawable:28.0.0'
|
||||
implementation 'com.android.support:support-v4:28.0.0'
|
||||
implementation 'android.arch.lifecycle:extensions:1.1.1'
|
||||
implementation 'com.google.android.gms:play-services-plus:16.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.deiniu.zhuike">
|
||||
|
||||
<!-- To access Google+ APIs: -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
|
@ -17,10 +18,7 @@
|
|||
<activity
|
||||
android:name=".Main4Activity"
|
||||
android:label="@string/title_activity_main4"
|
||||
android:theme="@style/ToolBarTheme.NoActionBar">
|
||||
|
||||
|
||||
</activity>
|
||||
android:theme="@style/ToolBarTheme.NoActionBar"></activity>
|
||||
<activity
|
||||
android:name=".Main3Activity"
|
||||
android:label="@string/title_activity_main3" />
|
||||
|
|
|
@ -5,6 +5,9 @@ import android.content.Context;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -15,15 +18,27 @@ import android.view.ViewGroup;
|
|||
*/
|
||||
public abstract class BasicFragment extends Fragment {
|
||||
protected OnFragmentInteractionListener mListener;
|
||||
public static String TAG ="need to be replaced";
|
||||
public static String TAG = "need to be replaced";
|
||||
Main2Activity activity;
|
||||
public BasicFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setFTag();
|
||||
// Log.d(TAG,"fragment onCreate ");
|
||||
activity =(Main2Activity)getActivity();
|
||||
|
||||
|
||||
// QLog.getLogger().e(dTAG,TAG+" "+ "onCreate");
|
||||
// mediumFontSize = activity.getMiddleSizeFont();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
Log.d(TAG,"onCreateView");
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_basic, container, false);
|
||||
}
|
||||
|
@ -32,26 +47,30 @@ public abstract class BasicFragment extends Fragment {
|
|||
setFTag();
|
||||
return TAG;
|
||||
}
|
||||
// {
|
||||
// return TAG;
|
||||
// }
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
public abstract void setFTag();
|
||||
// {
|
||||
// TAG="need to be replaced";
|
||||
//
|
||||
// }
|
||||
|
||||
public abstract void setFTag();
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -57,6 +58,7 @@ public class BlankFragment extends BasicFragment {
|
|||
@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);
|
||||
|
@ -66,6 +68,7 @@ public class BlankFragment extends BasicFragment {
|
|||
@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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package com.deiniu.zhuike;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.android.gms.plus.PlusOneButton;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* A fragment with a Google +1 button.
|
||||
* Activities that contain this fragment must implement the
|
||||
* {@link Fragment_Shelf.OnFragmentInteractionListener} interface
|
||||
* to handle interaction events.
|
||||
* Use the {@link Fragment_Shelf#newInstance} factory method to
|
||||
* 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 OnFragmentInteractionListener mListener;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
// Refresh the state of the +1 button each time the activity receives focus.
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setFTag() {
|
||||
TAG="com.deiniu.zhuike.Fragment_Shelf";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -17,7 +18,7 @@ import android.view.ViewGroup;
|
|||
* Use the {@link Fragment_bangdan#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class Fragment_bangdan extends 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";
|
||||
|
@ -54,6 +55,7 @@ public class Fragment_bangdan extends Fragment {
|
|||
@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);
|
||||
|
@ -64,45 +66,14 @@ public class Fragment_bangdan extends Fragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
Log.d(TAG,"Fragment_bangdan onCreateView");
|
||||
return inflater.inflate(R.layout.fragment_fragment_bangdan, container, false);
|
||||
}
|
||||
|
||||
// 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 onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
}
|
||||
public void setFTag() {
|
||||
TAG ="com.deiniu.zhuike.Fragment_bangdan";
|
||||
}
|
||||
|
||||
@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.
|
||||
*/
|
||||
public interface OnFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
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.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.youth.banner.Banner;
|
||||
import com.youth.banner.BannerConfig;
|
||||
import com.youth.banner.Transformer;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.d(TAG,"Fragment_bookStore 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
//---------tabs-------------
|
||||
@BindView(R.id.viewpager)
|
||||
ViewPager mViewpager;
|
||||
private List<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_jingxuan());
|
||||
mFragments.add(new Fragment_bangdan());
|
||||
mFragments.add(new Fragment_shudan());
|
||||
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);
|
||||
|
||||
|
||||
/*
|
||||
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];
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setFTag() {
|
||||
TAG="com.deiniu.zhuike.Fragment_Store";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,9 +4,23 @@ import android.content.Context;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.youth.banner.Banner;
|
||||
import com.youth.banner.BannerConfig;
|
||||
import com.youth.banner.Transformer;
|
||||
import com.youth.banner.listener.OnBannerListener;
|
||||
import com.youth.banner.loader.ImageLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -17,7 +31,7 @@ import android.view.ViewGroup;
|
|||
* Use the {@link Fragment_jingxuan#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class Fragment_jingxuan extends 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";
|
||||
|
@ -27,10 +41,10 @@ public class Fragment_jingxuan extends Fragment {
|
|||
private String mParam1;
|
||||
private String mParam2;
|
||||
|
||||
private OnFragmentInteractionListener mListener;
|
||||
|
||||
public Fragment_jingxuan() {
|
||||
// Required empty public constructor
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,6 +68,7 @@ public class Fragment_jingxuan extends 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);
|
||||
|
@ -64,45 +79,90 @@ public class Fragment_jingxuan extends Fragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_jingxuan, container, false);
|
||||
}
|
||||
|
||||
// TODO: Rename method, update argument and hook method into UI event
|
||||
public void onButtonPressed(Uri uri) {
|
||||
if (mListener != null) {
|
||||
mListener.onFragmentInteraction(uri);
|
||||
}
|
||||
Log.d(TAG," Fragment_jingxuan onCreateView");
|
||||
View v= inflater.inflate(R.layout.fragment_jingxuan, container, false);
|
||||
ButterKnife.bind(this, v);
|
||||
testBanner(banner,this);
|
||||
testBanner(banner2,new BannerListioner2());
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
}
|
||||
public void setFTag() {
|
||||
TAG ="com.deiniu.zhuike.Fragment_jingxuan";
|
||||
}
|
||||
|
||||
|
||||
@BindView(R.id.banner)
|
||||
Banner banner;
|
||||
@BindView(R.id.banner2)
|
||||
Banner banner2;
|
||||
|
||||
private ArrayList<String> list_path;
|
||||
private ArrayList<String> list_title;
|
||||
void testBanner(Banner banner,OnBannerListener listioner) {
|
||||
|
||||
//放图片地址的集合
|
||||
list_path = new ArrayList<>();
|
||||
//放标题的集合
|
||||
list_title = new ArrayList<>();
|
||||
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic21363tj30ci08ct96.jpg");
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic259ohaj30ci08c74r.jpg");
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2b16zuj30ci08cwf4.jpg");
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2e7vsaj30ci08cglz.jpg");
|
||||
list_title.add("好好学习");
|
||||
list_title.add("天天向上");
|
||||
list_title.add("热爱劳动");
|
||||
list_title.add("不搞对象");
|
||||
//设置内置样式,共有六种可以点入方法内逐一体验使用。
|
||||
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
|
||||
//设置图片加载器,图片加载器在下方
|
||||
banner.setImageLoader(new MyLoader());
|
||||
//设置图片网址或地址的集合
|
||||
banner.setImages(list_path);
|
||||
//设置轮播的动画效果,内含多种特效,可点入方法内查找后内逐一体验
|
||||
banner.setBannerAnimation(Transformer.Default);
|
||||
//设置轮播图的标题集合
|
||||
banner.setBannerTitles(list_title);
|
||||
//设置轮播间隔时间
|
||||
banner.setDelayTime(3000);
|
||||
//设置是否为自动轮播,默认是“是”。
|
||||
banner.isAutoPlay(true);
|
||||
//设置指示器的位置,小点点,左中右。
|
||||
banner.setIndicatorGravity(BannerConfig.CENTER)
|
||||
//以上内容都可写成链式布局,这是轮播图的监听。比较重要。方法在下面。
|
||||
.setOnBannerListener(listioner)
|
||||
//必须最后调用的方法,启动轮播图。
|
||||
.start();
|
||||
|
||||
}
|
||||
//轮播图的监听方法
|
||||
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
mListener = null;
|
||||
public void OnBannerClick(int position) {
|
||||
Log.i("第一个banner", "你点了第一个banner 第"+position+"张轮播图");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public interface OnFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onFragmentInteraction(Uri uri);
|
||||
//自定义的图片加载器
|
||||
private class MyLoader extends ImageLoader {
|
||||
@Override
|
||||
public void displayImage(Context context, Object path, ImageView imageView) {
|
||||
Glide.with(context).load((String) path).into(imageView);
|
||||
}
|
||||
}
|
||||
}
|
||||
class BannerListioner1 implements OnBannerListener {
|
||||
|
||||
@Override
|
||||
public void OnBannerClick(int position) {
|
||||
Log.i("第一个banner", "你点了第一个banner 第" + position + "张轮播图");
|
||||
}
|
||||
}
|
||||
class BannerListioner2 implements OnBannerListener {
|
||||
|
||||
@Override
|
||||
public void OnBannerClick(int position) {
|
||||
Log.i("第二个banner", "你点了第二个banner 第"+position+"张轮播图");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.deiniu.zhuike;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
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);
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -17,7 +18,7 @@ import android.view.ViewGroup;
|
|||
* Use the {@link Fragment_shudan#newInstance} factory method to
|
||||
* create an instance of this fragment.
|
||||
*/
|
||||
public class Fragment_shudan extends 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";
|
||||
|
@ -54,6 +55,7 @@ public class Fragment_shudan extends 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);
|
||||
|
@ -64,45 +66,16 @@ public class Fragment_shudan extends Fragment {
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
Log.d(TAG,"Fragment_shudan onCreateView");
|
||||
return inflater.inflate(R.layout.fragment_shudan, container, false);
|
||||
}
|
||||
|
||||
// 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 onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnFragmentInteractionListener) {
|
||||
mListener = (OnFragmentInteractionListener) context;
|
||||
} else {
|
||||
throw new RuntimeException(context.toString()
|
||||
+ " must implement OnFragmentInteractionListener");
|
||||
}
|
||||
public void setFTag() {
|
||||
TAG ="com.deiniu.zhuike.Fragment_shudan";
|
||||
}
|
||||
|
||||
@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.
|
||||
*/
|
||||
public interface OnFragmentInteractionListener {
|
||||
// TODO: Update argument type and name
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.deiniu.zhuike;
|
|||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.nfc.Tag;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
|
@ -13,6 +14,7 @@ import android.support.v4.app.FragmentTransaction;
|
|||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
|
@ -44,8 +46,8 @@ import java.util.ArrayList;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
public class Main2Activity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener , OnBannerListener, BasicFragment.OnFragmentInteractionListener {
|
||||
|
||||
implements NavigationView.OnNavigationItemSelectedListener , BasicFragment.OnFragmentInteractionListener {
|
||||
public MyApp app ;
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
@ -74,8 +76,8 @@ public class Main2Activity extends AppCompatActivity
|
|||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
initTabs();
|
||||
showHome();
|
||||
// initTabs();
|
||||
|
||||
|
||||
// banner = (Banner) findViewById(R.id.banner);
|
||||
|
@ -98,9 +100,9 @@ public class Main2Activity extends AppCompatActivity
|
|||
|
||||
ft.replace(R.id.realtabcontent, fragment,fragmentTag);
|
||||
// // QLog.getLogger().d(dTAG, " before commit,getSupportFragmentManager().findFragmentByTag: "+fragmentTag +", result is:"+getSupportFragmentManager().findFragmentByTag(fragmentTag));
|
||||
Fragment lastFragmeng = getSupportFragmentManager().findFragmentByTag( currentActiveFragment);
|
||||
// Fragment lastFragmeng = getSupportFragmentManager().findFragmentByTag( currentActiveFragment);
|
||||
|
||||
ft.addToBackStack(null); //add to backstack.
|
||||
ft.addToBackStack(null); //add to backstack.
|
||||
|
||||
|
||||
}
|
||||
|
@ -253,7 +255,7 @@ public class Main2Activity extends AppCompatActivity
|
|||
return true;
|
||||
case R.id.navigation_notifications:
|
||||
mTextMessage.setText(R.string.title_notifications);
|
||||
showNotes();
|
||||
showOther();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -263,74 +265,26 @@ public class Main2Activity extends AppCompatActivity
|
|||
|
||||
private void showHome() {
|
||||
|
||||
BlankFragment blankFragment = (BlankFragment) getSupportFragmentManager()
|
||||
.findFragmentByTag(BlankFragment.getFTag());
|
||||
if(blankFragment==null) blankFragment =new BlankFragment();
|
||||
showFragment(blankFragment,BlankFragment.getFTag());
|
||||
Fragment_Shelf fragment_Shelf = (Fragment_Shelf) getSupportFragmentManager()
|
||||
.findFragmentByTag(Fragment_Shelf.getFTag());
|
||||
if(fragment_Shelf==null) fragment_Shelf =new Fragment_Shelf();
|
||||
showFragment(fragment_Shelf,Fragment_Shelf.getFTag());
|
||||
|
||||
}
|
||||
private void showBookStore() {
|
||||
Fragment_bookStore fragment = (Fragment_bookStore) getSupportFragmentManager()
|
||||
.findFragmentByTag(Fragment_bookStore.getFTag());
|
||||
if(fragment ==null) fragment =new Fragment_bookStore();
|
||||
showFragment(fragment ,Fragment_bookStore.getFTag());
|
||||
}
|
||||
private void showNotes() {
|
||||
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());
|
||||
}
|
||||
|
||||
/*
|
||||
@BindView(R.id.banner)
|
||||
Banner banner;
|
||||
@BindView(R.id.banner2)
|
||||
Banner banner2;
|
||||
*/
|
||||
private ArrayList<String> list_path;
|
||||
private ArrayList<String> list_title;
|
||||
void testBanner(Banner banner) {
|
||||
|
||||
//放图片地址的集合
|
||||
list_path = new ArrayList<>();
|
||||
//放标题的集合
|
||||
list_title = new ArrayList<>();
|
||||
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic21363tj30ci08ct96.jpg");
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic259ohaj30ci08c74r.jpg");
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2b16zuj30ci08cwf4.jpg");
|
||||
list_path.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2e7vsaj30ci08cglz.jpg");
|
||||
list_title.add("好好学习");
|
||||
list_title.add("天天向上");
|
||||
list_title.add("热爱劳动");
|
||||
list_title.add("不搞对象");
|
||||
//设置内置样式,共有六种可以点入方法内逐一体验使用。
|
||||
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
|
||||
//设置图片加载器,图片加载器在下方
|
||||
banner.setImageLoader(new MyLoader());
|
||||
//设置图片网址或地址的集合
|
||||
banner.setImages(list_path);
|
||||
//设置轮播的动画效果,内含多种特效,可点入方法内查找后内逐一体验
|
||||
banner.setBannerAnimation(Transformer.Default);
|
||||
//设置轮播图的标题集合
|
||||
banner.setBannerTitles(list_title);
|
||||
//设置轮播间隔时间
|
||||
banner.setDelayTime(3000);
|
||||
//设置是否为自动轮播,默认是“是”。
|
||||
banner.isAutoPlay(true);
|
||||
//设置指示器的位置,小点点,左中右。
|
||||
banner.setIndicatorGravity(BannerConfig.CENTER)
|
||||
//以上内容都可写成链式布局,这是轮播图的监听。比较重要。方法在下面。
|
||||
.setOnBannerListener(this)
|
||||
//必须最后调用的方法,启动轮播图。
|
||||
.start();
|
||||
|
||||
}
|
||||
//轮播图的监听方法
|
||||
@Override
|
||||
public void OnBannerClick(int position) {
|
||||
Log.i("tag", "你点了第"+position+"张轮播图");
|
||||
}
|
||||
//自定义的图片加载器
|
||||
private class MyLoader extends ImageLoader {
|
||||
@Override
|
||||
public void displayImage(Context context, Object path, ImageView imageView) {
|
||||
Glide.with(context).load((String) path).into(imageView);
|
||||
}
|
||||
}
|
||||
private void getDataFromServer() {
|
||||
//url
|
||||
String url1 = "http://api.kkmh.com/v1/topic_new/discovery_list?gender=0&sa_event=eyJwcm9qZWN0Ijoia%203VhaWthbl9hcHAiLCJ0aW1lIjoxNDg3ODM5MDM5MzE1LCJwcm9wZXJ0aWVzIjp7IkhvbWVwYWdlVGFiTmFtZSI6IueDremXqCIsIlZDb21t%20dW5pdHlUYWJOYW1lIjoi54Ot6ZeoIiwiJG9zX3ZlcnNpb24iOiI0LjIuMiIsIkdlbmRlclR5cGUiOiLlpbPniYgiLCJGcm9tRmluZENhdGVnb%203J5VGFiTmFtZSI6IuWFqOmDqCIsIklzQXV0b0xvYWQiOmZhbHNlLCIkbGliX3ZlcnNpb24iOiIxLjYuMzQiLCIkbmV0d29ya190eXBlIjoiV0l%20GSSIsIiR3aWZpIjp0cnVlLCIkbWFudWZhY3R1cmVyIjoic2Ftc3VuZyIsIkZyb21GaW5kVGFiTmFtZSI6IuaOqOiNkCIsIiRzY3JlZW%205faGVpZ2h0Ijo1NzYsIkNhdGVnb3J5Ijoi5peg5rOV6I635Y-WIiwiSG9tZXBhZ2VVcGRhdGVEYXRlIjowLCJQcm9wZXJ0eUV2ZW5%200IjoiUmVhZEZpbmRQYWdlIiwiRmluZFRhYk5hbWUiOiLmjqjojZAiLCJhYnRlc3RfZ3JvdXAiOjQ2LCIkc2NyZWVuX3dpZHRoIjo%20xMDI0LCJGaW5kQ2F0ZWdvcnlUYWJOYW1lIjoi5YWo6YOoIiwiJG9zIjoiQW5kcm9pZCIsIlRyaWdnZXJQYWdlIjoiSG9tZVBhZ2%20UiLCIkY2FycmllciI6IkNNQ0MiLCIkbW9kZWwiOiJHVC1QNTIxMCIsIiRhcHBfdmVyc2lvbiI6IjMuOC4xIn0sInR5cGUiOiJ0cmFja%20yIsImRpc3RpbmN0X2lkIjoiQTo5MDUxMDQyNzYzNzU1MTA5Iiwib3JpZ2luYWxfaWQiOiJBOjkwNTEwNDI3NjM3NTUxMDkiLCJldmV%20udCI6IlJlYWRGaW5kUGFnZSJ9";
|
||||
|
@ -374,58 +328,49 @@ public class Main2Activity extends AppCompatActivity
|
|||
}
|
||||
|
||||
|
||||
//---------tabs-------------
|
||||
@BindView(R.id.viewpager)
|
||||
ViewPager mViewpager;
|
||||
private ArrayList<View> mList;
|
||||
private String[] mTitle;
|
||||
|
||||
void initTabs() {
|
||||
|
||||
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);
|
||||
|
||||
mTitle = new String[]{"精选", "榜单", "书单"};
|
||||
|
||||
|
||||
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];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentInteraction(Uri uri) {
|
||||
Toast.makeText(this,"交流,角楼",Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
|
||||
long firstTime =0;
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
|
||||
int cnt=0;
|
||||
|
||||
|
||||
long secondTime = System.currentTimeMillis();
|
||||
if (secondTime - firstTime > 800) {//如果两次按键时间间隔大于800毫秒,则不退出
|
||||
String msg= "再按一次将退出" ;
|
||||
Toast.makeText( this, msg, Toast.LENGTH_SHORT).show();
|
||||
firstTime = secondTime;//更新firstTime
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
app.exit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
try{
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
catch(Exception e){
|
||||
Log.d("mainActivity","onkeyup出错" );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,10 @@ public class MyApp extends Application {
|
|||
public void onCreate() {
|
||||
super.onCreate();
|
||||
x.Ext.init(this);
|
||||
// x.Ext.setDebug(false); //输出debug日志,开启会影响性能
|
||||
x.Ext.setDebug(false); //输出debug日志,开启会影响性能
|
||||
}
|
||||
|
||||
public boolean exit() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,18 +33,7 @@
|
|||
|
||||
<include layout="@layout/realcontent" />
|
||||
|
||||
<android.support.design.widget.BottomNavigationView
|
||||
android:id="@+id/navigation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
app:menu="@menu/navigation" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
tools:context=".Fragment_bookStore">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabMode="fixed"/>
|
||||
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</FrameLayout>
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
tools:context=".BlankFragment">
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/n_scroll_view"
|
||||
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"
|
||||
android:text="哈"
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="哈"
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="哈"
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="哈"
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</FrameLayout>
|
|
@ -9,6 +9,6 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
android:text="榜单。。。。。。榜单" />
|
||||
|
||||
</FrameLayout>
|
|
@ -7,6 +7,13 @@
|
|||
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"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
android:layout_width="match_parent"
|
||||
|
@ -21,17 +28,6 @@
|
|||
android:layout_height="150dp" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1" />
|
||||
|
||||
|
||||
|
||||
|
@ -40,34 +36,8 @@
|
|||
android:id="@+id/banner2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp" />
|
||||
<TextView
|
||||
android:id="@+id/message3"
|
||||
android:layout_width="159dp"
|
||||
android:layout_height="92dp"
|
||||
android:text="2" />
|
||||
<TextView
|
||||
android:id="@+id/message4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="28dp"
|
||||
android:layout_marginRight="28dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="3"
|
||||
app:layout_constraintBottom_toTopOf="@+id/navigation"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/n_scroll_view"
|
||||
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"
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
>
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/n_scroll_view"
|
||||
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"
|
||||
android:text=" "
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=" "
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=" "
|
||||
android:textColor="#0f0"
|
||||
android:textSize="200sp" />
|
||||
</LinearLayout>
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
|
@ -9,6 +9,6 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
android:text="书单。。。。" />
|
||||
|
||||
</FrameLayout>
|
|
@ -16,21 +16,10 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|||
<FrameLayout
|
||||
android:id="@+id/realtabcontent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewpager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabMode="fixed"/>
|
||||
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
|
@ -44,6 +33,7 @@ app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
|||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
|
|
|
@ -143,6 +143,7 @@
|
|||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:runtime:1.1.1@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:support-compat:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:cardview-v7:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-audience:16.0.0@aar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.youth.banner:banner:1.4.10@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable:28.0.0@aar" level="project" />
|
||||
|
@ -155,6 +156,7 @@
|
|||
<orderEntry type="library" name="Gradle: com.android.support:transition:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:livedata:1.1.1@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:drawerlayout:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-plus:16.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:support-v4:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.3@jar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
|
||||
|
@ -174,9 +176,11 @@
|
|||
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: android.arch.core:common:1.1.1@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:versionedparcelable:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-base:16.0.1@aar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:viewpager:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement:16.0.1@aar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: android.arch.lifecycle:common:1.1.1@jar" level="project" />
|
||||
|
@ -185,5 +189,6 @@
|
|||
<orderEntry type="library" name="Gradle: com.android.support:customview:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:swiperefreshlayout:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat:28.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-tasks:16.0.1@aar" level="project" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue