├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── android
│ │ └── mytestapplication
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── android
│ │ │ └── mytestapplication
│ │ │ ├── FourFragment.java
│ │ │ ├── MainActivity.java
│ │ │ ├── OneFragment.java
│ │ │ ├── TestLazyFragment.java
│ │ │ ├── ThreeFragment.java
│ │ │ ├── TwoFragment.java
│ │ │ ├── customvView
│ │ │ └── CustomNavigatorBar.java
│ │ │ └── lazyfragment
│ │ │ └── LazyFragment.java
│ └── res
│ │ ├── drawable
│ │ ├── banner.png
│ │ ├── ic_launcher.png
│ │ ├── leftarrow.png
│ │ ├── message_wzcx.png
│ │ └── rightarrow.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── custom_title_bar.xml
│ │ ├── fourfragment.xml
│ │ ├── fragment.xml
│ │ ├── item.xml
│ │ ├── test.xml
│ │ ├── threefragment.xml
│ │ └── twofragment.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── android
│ └── mytestapplication
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | # Built application files
10 | *.apk
11 | *.ap_
12 |
13 | # Files for the ART/Dalvik VM
14 | *.dex
15 |
16 | # Java class files
17 | *.class
18 |
19 | # Generated files
20 | bin/
21 | gen/
22 | out/
23 |
24 | # Gradle files
25 | .gradle/
26 | build/
27 |
28 | # Local configuration file (sdk path, etc)
29 | local.properties
30 |
31 | # Proguard folder generated by Eclipse
32 | proguard/
33 |
34 | # Log Files
35 | *.log
36 |
37 | # Android Studio Navigation editor temp files
38 | .navigation/
39 |
40 | # Android Studio captures folder
41 | captures/
42 |
43 | # Intellij
44 | *.iml
45 | .idea/workspace.xml
46 |
47 | # Keystore files
48 | *.jks
49 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CustomNavigatorBar
2 | 由于项目中经常用到此种组合控件,就封装了下,具体效果看下图,老司机可以绕道哈!
3 |
4 | 
5 |
6 |
7 | #####一、主要功能
8 |
9 | * 支持左右图标动态设置
10 | * 支持左右、中间文字动态修改
11 | * 支持字体大小、颜色修改
12 | * 支持左右图标,左中右文字隐藏显示
13 | * 支持左右图标和文案的点击监听
14 |
15 | #####二、基本使用方式
16 |
17 | ~~~
18 |
39 | ~~~
40 |
41 | ####三、基本属性介绍
42 | | 属性名 | 属性说明 | 属性值 |
43 | |:-------------: |:-------------:|:-----:|
44 | | titleBarBackground | 标题栏背景色| color,reference,默认为white |
45 | | leftImage | 左边图片| reference|
46 | | leftImageVisiable | 左边图片是否可见 | boolean,默认为true,显示控件 |
47 | | leftText| 左边文案 | string,reference |
48 | | leftTextVisibale| 左边文案是否可见 | boolean,默认为true,显示控件 |
49 | | leftTextFontSize| 左边文案字体大小 | dimension,reference,默认为16sp |
50 | | leftTextColor| 左边文案字体颜色 | color,reference |
51 | | midText| 中间文案 | string,reference |
52 | | midTextVisiable| 中间文案是否可见 | boolean,默认为true,显示控件 |
53 | | midTextFontSize| 中间文案字体大小 | dimension,reference,默认为18sp |
54 | | midTextFontColor| 中间文案字体颜色 | color,reference |
55 | | rightText| 右边文案 | color,reference |
56 | | rightTextVisible| 右边文案是否可见 | boolean,默认为true,显示控件 |
57 | | rightTextFontSize| 右边文案字体大小 | dimension,reference,默认为16sp |
58 | | rightTextColor| 右边文案字体颜色 | color,reference |
59 | | rightImage| 右边图片 | reference |
60 | | rightImageVisible| 右边图片是否可见 | boolean,默认为true,显示控件 |
61 |
62 | ####四、组合控件类
63 | ~~~
64 | package com.example.android.customvView;
65 |
66 | import android.content.Context;
67 | import android.content.res.TypedArray;
68 | import android.graphics.Color;
69 | import android.graphics.drawable.Drawable;
70 | import android.util.AttributeSet;
71 | import android.util.TypedValue;
72 | import android.view.LayoutInflater;
73 | import android.view.View;
74 | import android.widget.ImageView;
75 | import android.widget.RelativeLayout;
76 | import android.widget.TextView;
77 |
78 | import com.example.android.R;
79 |
80 | /**
81 | * Created by WangLu on 2016/12/6.
82 | * E-mail:wang_lu90125@163.com
83 | */
84 |
85 | public class CustomNavigatorBar extends RelativeLayout implements View.OnClickListener {
86 |
87 | private ImageView leftImage;
88 | private TextView leftText;
89 | private TextView midText;
90 | private ImageView rightImage;
91 | private TextView rightText;
92 | private OnCustomClickListener customClickListener ;
93 |
94 | public CustomNavigatorBar(Context context) {
95 | this(context,null);
96 | }
97 |
98 | public CustomNavigatorBar(Context context, AttributeSet attrs) {
99 | this(context, attrs,0);
100 | }
101 |
102 | public CustomNavigatorBar(Context context, AttributeSet attrs, int defStyleAttr) {
103 | super(context, attrs, defStyleAttr);
104 | iniView(context);
105 | /**
106 | * 两种初始化的不同,请看下面注释讲解
107 | */
108 | initOneType(context, attrs);//第一种初始化
109 | // initTwoType(context, attrs);//第二种初始化
110 | }
111 |
112 | private void iniView(Context context) {
113 | View view = LayoutInflater.from(context).inflate(R.layout.custom_title_bar, this, true);
114 | leftImage = (ImageView) view.findViewById(R.id.left_image);
115 | leftText = (TextView) view.findViewById(R.id.left_text);
116 | midText = (TextView) view.findViewById(R.id.mid_text);
117 | rightText = (TextView) view.findViewById(R.id.right_text);
118 | rightImage = (ImageView) view.findViewById(R.id.right_image);
119 |
120 | }
121 |
122 | /**
123 | * 有兴趣的请参考鸿洋大神的自定义讲解
124 | *
125 | * 初始化属性值:这种写法,不管你在布局中有没有使用该属性,都会执行getXXX方法赋值
126 | *假设一个场景:
127 | * private int attr_mode = 1;//默认为1
128 | * //然后你在写getXXX方法的时候,是这么写的:
129 | * attr_mode = array.getInt(i, 0);
130 | *
131 | * 可能你的自定义属性有个默认的值,然后你在写赋值的时候,一看是整形,就默默的第二个参数就给了个0,
132 | * 然而用户根本没有在布局文件里面设置这个属性,你却在运行时将其变为了0(而不是默认值),而第二种就不存在这个问题。
133 | * 当然这个场景可以由规范的书写代码的方式来避免,(把默认值提取出来,都设置对就好了)。
134 | *
135 | * 场景二:
136 | *
137 | * 其实还有个场景,假设你是继承自某个View,父类的View已经对该成员变量进行赋值了,然后你这边需要根据用户的设置情况,
138 | * 去更新这个值,第一种写法,如果用户根本没有设置,你可能就将父类的赋值给覆盖了。
139 | *
140 | * @param context
141 | * @param attrs
142 | */
143 | private void initTwoType(Context context, AttributeSet attrs) {
144 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomNavigatorBar);
145 | if (null != typedArray) {
146 | Drawable leftDrawable = typedArray.getDrawable(R.styleable.CustomNavigatorBar_leftImage);
147 | leftImage.setImageDrawable(leftDrawable);
148 |
149 | boolean leftImageVisible = typedArray.getBoolean(R.styleable.CustomNavigatorBar_leftImageVisiable, false);
150 | if (leftImageVisible) {
151 | leftImage.setVisibility(View.VISIBLE);
152 | } else {
153 | leftImage.setVisibility(View.GONE);
154 | }
155 |
156 | typedArray.recycle();
157 | }
158 | }
159 |
160 | /**注:如果switch报错,请改为if-else
161 | * 初始化属性值:这种写法,只有在布局中设置了该属性值后,才会调用getXXX()方法赋值
162 | * @param context
163 | * @param attrs
164 | */
165 | private void initOneType(Context context, AttributeSet attrs) {
166 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomNavigatorBar);
167 | int totalAttributes = typedArray.getIndexCount();
168 | for (int i = 0 ; i
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 | ~~~
431 |
432 | ####六、组合控件布局(custom_title_bar.xml)
433 | 为什么使用merge,因为组合控件已经extends RelativeLayout,如果根布局还是用viewGroup的话,会使布局重复嵌套,影响View的绘制性能;
434 |
435 | ~~~
436 |
437 |
438 |
439 |
448 |
449 |
459 |
460 |
470 |
471 |
479 |
480 |
489 |
490 |
497 |
498 |
499 | ~~~
500 |
501 | ####七、具体使用
502 |
503 | ~~~
504 | CustomNavigatorBar customNavigatorBar = (CustomNavigatorBar) findViewById(R.id.customView);
505 | /**
506 | * 第一种监听的具体实现
507 | */
508 | customNavigatorBar.setLeftImageOnClickListener(new View.OnClickListener() {
509 | @Override
510 | public void onClick(View view) {
511 | Toast.makeText(MainActivity.this,"left",Toast.LENGTH_SHORT).show();
512 | }
513 | });
514 |
515 | /**
516 | * 第二种监听的具体实现
517 | */
518 | customNavigatorBar.addViewClickListener(new CustomNavigatorBar.OnCustomClickListener() {
519 | @Override
520 | public void onClickListener(View rootView) {
521 | switch (rootView.getId()) {
522 | case R.id.right_image:
523 | Toast.makeText(MainActivity.this,"right_image is clicked",Toast.LENGTH_SHORT).show();
524 | break ;
525 | case R.id.left_image:
526 | Toast.makeText(MainActivity.this,"left_image is clicked",Toast.LENGTH_SHORT).show();
527 | break ;
528 | }
529 | }
530 | });
531 | ~~~
532 |
533 | ###如有什么问题,敬请提出,十分感谢!希望越来越好,谢谢!
534 | ####如果喜欢,还请点击喜欢支持一下了,谢谢O(∩_∩)O~。
535 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 | defaultConfig {
7 | applicationId "com.example.android.mytestapplication"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.0.1'
28 | testCompile 'junit:junit:4.12'
29 | compile 'com.android.support:design:25.0.1'
30 | }
31 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\Android\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/android/mytestapplication/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.android.mytestapplication", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/FourFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 |
6 | import com.example.android.mytestapplication.lazyfragment.LazyFragment;
7 |
8 | /**
9 | * Created by WangLu on 2016/11/29.
10 | * E-mail:wang_lu90125@163.com
11 | */
12 |
13 | public class FourFragment extends LazyFragment {
14 |
15 | private TextView textView;
16 | String mTitle;
17 |
18 | /* public FourFragment() {
19 | mTitle = getArguments().getString("title");
20 | }*/
21 |
22 | @Override
23 | protected int getLayoutID() {
24 | return R.layout.fragment;
25 | }
26 |
27 | @Override
28 | protected void iniView(View view) {
29 | mTitle = getArguments().getString("title");
30 | textView = (TextView) view.findViewById(R.id.textView);
31 | textView.setText(mTitle);
32 | }
33 |
34 | @Override
35 | protected void initializeSuccessButInvisible() {
36 | System.out.println("-----FourFragment---------initializeSuccessButInvisible-------------");
37 | }
38 |
39 | @Override
40 | protected void lazyLoad() {
41 | System.out.println("-----FourFragment---------lazyLoad-------------");
42 | }
43 |
44 | @Override
45 | protected void refreshDataSources() {
46 | super.refreshDataSources();
47 | System.out.println("-----FourFragment---------refreshDataSources-------------");
48 | }
49 |
50 | @Override
51 | public void setUserVisibleHint(boolean isVisibleToUser) {
52 | super.setUserVisibleHint(isVisibleToUser);
53 | System.out.println("---FourFragment--------setUserVisibleHint-----------------"+isVisibleToUser);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Color;
6 | import android.os.Message;
7 | import android.support.design.widget.CollapsingToolbarLayout;
8 | import android.support.design.widget.TabLayout;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v4.app.FragmentPagerAdapter;
11 | import android.support.v4.view.ViewPager;
12 | import android.support.v4.widget.SwipeRefreshLayout;
13 | import android.support.v7.app.AppCompatActivity;
14 | import android.os.Bundle;
15 | import android.support.v7.widget.DividerItemDecoration;
16 | import android.support.v7.widget.LinearLayoutManager;
17 | import android.support.v7.widget.RecyclerView;
18 | import android.support.v7.widget.Toolbar;
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import android.webkit.WebResourceRequest;
23 | import android.webkit.WebView;
24 | import android.webkit.WebViewClient;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import com.example.android.mytestapplication.customvView.CustomNavigatorBar;
29 |
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | import static android.R.id.list;
34 |
35 | public class MainActivity extends AppCompatActivity {
36 |
37 | private SwipeRefreshLayout swipeRefreshLayout;
38 | private TabLayout tabLayout;
39 | private ViewPager viewPager;
40 | private ViewPager upViewPager;
41 | private FragmentPagerAdapter fragmentPagerAdapter;
42 | private RecyclerView recyclerView;
43 |
44 | @Override
45 | protected void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | setContentView(R.layout.activity_main);
48 |
49 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
50 | setSupportActionBar(toolbar);
51 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
52 |
53 | init();
54 |
55 | // initRecyclerView();
56 |
57 |
58 | toolbar.setNavigationOnClickListener(new View.OnClickListener(){
59 |
60 | @Override
61 | public void onClick(View view) {
62 | onBackPressed();
63 | }
64 | });
65 |
66 | // final WebView webView = (WebView) findViewById(R.id.webView);
67 | // webView.loadUrl("http://www.baidu.com");
68 | // webView.setWebViewClient(new WebViewClient(){
69 | // @Override
70 | // public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
71 | // return true;
72 | // }
73 | //
74 | // @Override
75 | // public void onPageFinished(WebView view, String url) {
76 | // super.onPageFinished(view, url);
77 | //// swipeRefreshLayout.setRefreshing(false);
78 | // }
79 | //
80 | // @Override
81 | // public void onPageStarted(WebView view, String url, Bitmap favicon) {
82 | // super.onPageStarted(view, url, favicon);
83 | //// swipeRefreshLayout.setRefreshing(true);
84 | // }
85 | //
86 | // });
87 | //
88 | // CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbarLayout);
89 | // collapsingToolbarLayout.setCollapsedTitleTextColor(Color.GREEN);
90 | //
91 | // swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
92 | // swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
93 | // @Override
94 | // public void onRefresh() {
95 | // webView.reload();
96 | // }
97 | // });
98 |
99 |
100 | }
101 |
102 | // private void initRecyclerView() {recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
103 | // recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
104 | // MyRecyclerAdapter adapter = new MyRecyclerAdapter(this);
105 | // recyclerView.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));
106 | // recyclerView.setAdapter(adapter);
107 | //
108 | // List list_adapter = new ArrayList<>();
109 | // for (int i = 0 ;i<20 ;i++) {
110 | // list_adapter.add("item----->" + i);
111 | // }
112 | // adapter.addList(list_adapter);
113 | // adapter.notifyDataSetChanged();
114 | // }
115 | //
116 | // class MyRecyclerAdapter extends RecyclerView.Adapter{
117 | // List list_adapter = null ;
118 | // LayoutInflater inflater ;
119 | //
120 | // public MyRecyclerAdapter(Context context ) {
121 | // inflater = LayoutInflater.from(context);
122 | //
123 | // }
124 | //
125 | // public void addList(List list) {
126 | // list_adapter = list ;
127 | // }
128 | //
129 | // @Override
130 | // public MyRecyclerAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
131 | // MyViewHolder viewHolder = new MyViewHolder(inflater.inflate(R.layout.item,parent,false));
132 | // return viewHolder ;
133 | // }
134 | //
135 | // @Override
136 | // public void onBindViewHolder(MyRecyclerAdapter.MyViewHolder holder, int position) {
137 | // holder.textView.setText(list_adapter.get(position));
138 | // }
139 | //
140 | // @Override
141 | // public int getItemCount() {
142 | // return list_adapter.size();
143 | // }
144 | //
145 | // class MyViewHolder extends RecyclerView.ViewHolder{
146 | //
147 | // TextView textView ;
148 | //
149 | // public MyViewHolder(View itemView) {
150 | // super(itemView);
151 | // textView = (TextView) itemView.findViewById(R.id.textView);
152 | // }
153 | //
154 | // }
155 | //
156 | //
157 | // }
158 |
159 |
160 | private void init() {
161 | tabLayout = (TabLayout) findViewById(R.id.tabs);
162 | viewPager = (ViewPager) findViewById(R.id.viewPager);
163 | setUpViewPager(viewPager);
164 | tabLayout.setupWithViewPager(viewPager);
165 | tabLayout.setTabMode(TabLayout.MODE_FIXED);
166 | }
167 |
168 | private List list;
169 | private List title;
170 |
171 | public void setUpViewPager(ViewPager viewPager) {
172 | list = new ArrayList<>();
173 | title = new ArrayList<>();
174 | // for (int i = 0 ;i<4;i++) {
175 | // OneFragment fragment = new OneFragment();
176 | // Bundle data = new Bundle();
177 | // data.putInt("id", 0);
178 | // data.putString("title", "title:"+i);
179 | // fragment.setArguments(data);
180 | //
181 | // list.add(fragment);
182 | // title.add("title:"+i);
183 | // }
184 |
185 |
186 | OneFragment oneFragment = new OneFragment();
187 | Bundle data1 = new Bundle();
188 | data1.putInt("id", 0);
189 | data1.putString("title", "oneFragment");
190 | oneFragment.setArguments(data1);
191 | list.add(oneFragment);
192 | title.add("推荐");
193 |
194 | TwoFragment twoFragment = new TwoFragment();
195 | Bundle data2 = new Bundle();
196 | data2.putInt("id", 1);
197 | data2.putString("title", "twoFragment");
198 | twoFragment.setArguments(data2);
199 | list.add(twoFragment);
200 | title.add("视频");
201 |
202 | ThreeFragment threeFragment = new ThreeFragment();
203 | Bundle data3 = new Bundle();
204 | data3.putInt("id", 2);
205 | data3.putString("title", "threeFragment");
206 | threeFragment.setArguments(data3);
207 | list.add(threeFragment);
208 | title.add("体育");
209 |
210 | FourFragment fourFragment = new FourFragment();
211 | Bundle data4 = new Bundle();
212 | data4.putInt("id", 3);
213 | data4.putString("title", "fourFragment");
214 | fourFragment.setArguments(data4);
215 | list.add(fourFragment);
216 | title.add("关注");
217 |
218 |
219 | fragmentPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
220 | @Override
221 | public int getCount() {
222 | return list.size();
223 | }
224 |
225 | @Override
226 | public Fragment getItem(int position) {
227 | return list.get(position);
228 | }
229 |
230 | @Override
231 | public CharSequence getPageTitle(int position) {
232 | return title.get(position);
233 | }
234 | };
235 | viewPager.setAdapter(fragmentPagerAdapter);
236 | }
237 | }
238 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/OneFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 | import android.widget.Toast;
6 |
7 | import com.example.android.mytestapplication.customvView.CustomNavigatorBar;
8 | import com.example.android.mytestapplication.lazyfragment.LazyFragment;
9 |
10 | /**
11 | * Created by WangLu on 2016/11/29.
12 | * E-mail:wang_lu90125@163.com
13 | */
14 |
15 | public class OneFragment extends LazyFragment {
16 |
17 | private TextView textView;
18 | String mTitle ;
19 |
20 | /* public OneFragment() {
21 | mTitle = getArguments().getString("title");
22 | }*/
23 |
24 | @Override
25 | protected int getLayoutID() {
26 | return R.layout.test;
27 | }
28 |
29 | @Override
30 | protected void iniView(View view) {
31 | mTitle = getArguments().getString("title");
32 |
33 | CustomNavigatorBar customNavigatorBar = (CustomNavigatorBar) getView(R.id.customView);
34 |
35 |
36 | /**
37 | * 第一种监听的具体实现
38 | */
39 | customNavigatorBar.setLeftImageOnClickListener(new View.OnClickListener() {
40 | @Override
41 | public void onClick(View view) {
42 | Toast.makeText(getActivity(),"left",Toast.LENGTH_SHORT).show();
43 | }
44 | });
45 |
46 | /**
47 | * 第二种监听的具体实现
48 | */
49 | customNavigatorBar.addViewClickListener(new CustomNavigatorBar.OnCustomClickListener() {
50 | @Override
51 | public void onClickListener(View rootView) {
52 | switch (rootView.getId()) {
53 | case R.id.right_image:
54 | Toast.makeText(getActivity(),"right_image is clicked",Toast.LENGTH_SHORT).show();
55 | break ;
56 | case R.id.left_image:
57 | Toast.makeText(getActivity(),"left_image is clicked",Toast.LENGTH_SHORT).show();
58 | break ;
59 | }
60 | }
61 | });
62 |
63 | }
64 |
65 | @Override
66 | protected void initializeSuccessButInvisible() {
67 | System.out.println("-----OneFragment---------initializeSuccessButInvisible-------------");
68 | }
69 |
70 | @Override
71 | protected void lazyLoad() {
72 | System.out.println("-----OneFragment---------lazyLoad-------------");
73 | }
74 |
75 | @Override
76 | protected void refreshDataSources() {
77 | super.refreshDataSources();
78 | System.out.println("-----OneFragment---------refreshDataSources-------------");
79 | }
80 |
81 | @Override
82 | public void setUserVisibleHint(boolean isVisibleToUser) {
83 | super.setUserVisibleHint(isVisibleToUser);
84 | System.out.println("---OneFragment--------setUserVisibleHint-----------------"+isVisibleToUser);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/TestLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.example.android.mytestapplication.lazyfragment.LazyFragment;
10 |
11 | /**
12 | * Created by WangLu on 2016/11/29.
13 | * E-mail:wang_lu90125@163.com
14 | */
15 |
16 | public class TestLazyFragment extends LazyFragment {
17 |
18 | private boolean isPrepare ;
19 |
20 | @Nullable
21 | @Override
22 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
23 | isPrepare = true ;
24 |
25 | lazyLoad();//加载数据
26 | return super.onCreateView(inflater, container, savedInstanceState);
27 | }
28 |
29 | @Nullable
30 | @Override
31 | protected int getLayoutID() {
32 | return 0;
33 | }
34 |
35 | @Override
36 | protected void iniView(View view) {
37 |
38 | }
39 |
40 |
41 | @Override
42 | protected void initializeSuccessButInvisible() {
43 |
44 | }
45 |
46 | @Override
47 | protected void lazyLoad() {
48 | // //加载数据的条件:1.初始化完毕 ; 2.当前的Fragment对用户可见
49 | // if (isPrepare && isVisible) {
50 | //
51 | // }else{
52 | // //否则 什么都不加载
53 | // return ;
54 | // }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/ThreeFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 |
6 | import com.example.android.mytestapplication.lazyfragment.LazyFragment;
7 |
8 | /**
9 | * Created by WangLu on 2016/11/29.
10 | * E-mail:wang_lu90125@163.com
11 | */
12 |
13 | public class ThreeFragment extends LazyFragment {
14 |
15 | private TextView textView;
16 | String mTitle;
17 |
18 | /* public ThreeFragment() {
19 |
20 | mTitle = getArguments().getString("title");
21 | }*/
22 |
23 | @Override
24 | protected int getLayoutID() {
25 | return R.layout.fragment;
26 | }
27 |
28 | @Override
29 | protected void iniView(View view) {
30 | mTitle = getArguments().getString("title");
31 | textView = (TextView) view.findViewById(R.id.textView);
32 | textView.setText(mTitle);
33 | }
34 |
35 | @Override
36 | protected void initializeSuccessButInvisible() {
37 | System.out.println("-----ThreeFragment---------initializeSuccessButInvisible-------------");
38 | }
39 |
40 | @Override
41 | protected void lazyLoad() {
42 | System.out.println("-----ThreeFragment---------lazyLoad-------------");
43 | }
44 |
45 | @Override
46 | protected void refreshDataSources() {
47 | super.refreshDataSources();
48 | System.out.println("-----ThreeFragment---------refreshDataSources-------------");
49 | }
50 |
51 | @Override
52 | public void setUserVisibleHint(boolean isVisibleToUser) {
53 | super.setUserVisibleHint(isVisibleToUser);
54 | System.out.println("---ThreeFragment--------setUserVisibleHint-----------------"+isVisibleToUser);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/TwoFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import android.view.View;
4 | import android.widget.TextView;
5 |
6 | import com.example.android.mytestapplication.lazyfragment.LazyFragment;
7 |
8 | /**
9 | * Created by WangLu on 2016/11/29.
10 | * E-mail:wang_lu90125@163.com
11 | */
12 |
13 | public class TwoFragment extends LazyFragment {
14 |
15 | private TextView textView;
16 | String mTitle;
17 |
18 | /* public TwoFragment() {
19 |
20 | mTitle = getArguments().getString("title");
21 | }*/
22 | @Override
23 | protected int getLayoutID() {
24 | return R.layout.fragment;
25 | }
26 |
27 | @Override
28 | protected void iniView(View view) {
29 | mTitle = getArguments().getString("title");
30 | textView = (TextView) view.findViewById(R.id.textView);
31 | textView.setText(mTitle);
32 | }
33 |
34 | @Override
35 | protected void initializeSuccessButInvisible() {
36 | System.out.println("-----TwoFragment---------initializeSuccessButInvisible-------------");
37 | }
38 |
39 | @Override
40 | protected void lazyLoad() {
41 | System.out.println("-----TwoFragment---------lazyLoad-------------");
42 | }
43 | @Override
44 | protected void refreshDataSources() {
45 | super.refreshDataSources();
46 | System.out.println("-----TwoFragment---------refreshDataSources-------------");
47 | }
48 | @Override
49 | public void setUserVisibleHint(boolean isVisibleToUser) {
50 | super.setUserVisibleHint(isVisibleToUser);
51 | System.out.println("---TwoFragment--------setUserVisibleHint-----------------"+isVisibleToUser);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/android/mytestapplication/customvView/CustomNavigatorBar.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication.customvView;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.graphics.drawable.Drawable;
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.widget.ImageView;
12 | import android.widget.RelativeLayout;
13 | import android.widget.TextView;
14 |
15 | import com.example.android.mytestapplication.R;
16 |
17 | /**
18 | * Created by WangLu on 2016/12/6.
19 | * E-mail:wang_lu90125@163.com
20 | */
21 |
22 | public class CustomNavigatorBar extends RelativeLayout implements View.OnClickListener {
23 |
24 | private ImageView leftImage;
25 | private TextView leftText;
26 | private TextView midText;
27 | private ImageView rightImage;
28 | private TextView rightText;
29 | private OnCustomClickListener customClickListener ;
30 |
31 | public CustomNavigatorBar(Context context) {
32 | this(context,null);
33 | }
34 |
35 | public CustomNavigatorBar(Context context, AttributeSet attrs) {
36 | this(context, attrs,0);
37 | }
38 |
39 | public CustomNavigatorBar(Context context, AttributeSet attrs, int defStyleAttr) {
40 | super(context, attrs, defStyleAttr);
41 | iniView(context);
42 | /**
43 | * 两种初始化的不同,请看下面注释讲解
44 | */
45 | initOneType(context, attrs);//第一种初始化
46 | // initTwoType(context, attrs);//第二种初始化
47 | }
48 |
49 | private void iniView(Context context) {
50 | View view = LayoutInflater.from(context).inflate(R.layout.custom_title_bar, this, true);
51 | leftImage = (ImageView) view.findViewById(R.id.left_image);
52 | leftText = (TextView) view.findViewById(R.id.left_text);
53 | midText = (TextView) view.findViewById(R.id.mid_text);
54 | rightText = (TextView) view.findViewById(R.id.right_text);
55 | rightImage = (ImageView) view.findViewById(R.id.right_image);
56 |
57 | }
58 |
59 | /**
60 | * 有兴趣的请参考鸿洋大神的自定义讲解
61 | *
62 | * 初始化属性值:这种写法,不管你在布局中有没有使用该属性,都会执行getXXX方法赋值
63 | *假设一个场景:
64 | * private int attr_mode = 1;//默认为1
65 | * //然后你在写getXXX方法的时候,是这么写的:
66 | * attr_mode = array.getInt(i, 0);
67 | *
68 | * 可能你的自定义属性有个默认的值,然后你在写赋值的时候,一看是整形,就默默的第二个参数就给了个0,
69 | * 然而用户根本没有在布局文件里面设置这个属性,你却在运行时将其变为了0(而不是默认值),而第二种就不存在这个问题。
70 | * 当然这个场景可以由规范的书写代码的方式来避免,(把默认值提取出来,都设置对就好了)。
71 | *
72 | * 场景二:
73 | *
74 | * 其实还有个场景,假设你是继承自某个View,父类的View已经对该成员变量进行赋值了,然后你这边需要根据用户的设置情况,
75 | * 去更新这个值,第一种写法,如果用户根本没有设置,你可能就将父类的赋值给覆盖了。
76 | *
77 | * @param context
78 | * @param attrs
79 | */
80 | private void initTwoType(Context context, AttributeSet attrs) {
81 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomNavigatorBar);
82 | if (null != typedArray) {
83 | Drawable leftDrawable = typedArray.getDrawable(R.styleable.CustomNavigatorBar_leftImage);
84 | leftImage.setImageDrawable(leftDrawable);
85 |
86 | boolean leftImageVisible = typedArray.getBoolean(R.styleable.CustomNavigatorBar_leftImageVisiable, false);
87 | if (leftImageVisible) {
88 | leftImage.setVisibility(View.VISIBLE);
89 | } else {
90 | leftImage.setVisibility(View.GONE);
91 | }
92 |
93 | typedArray.recycle();
94 | }
95 | }
96 |
97 | /**注:如果switch报错,请改为if-else
98 | * 初始化属性值:这种写法,只有在布局中设置了该属性值后,才会调用getXXX()方法赋值
99 | * @param context
100 | * @param attrs
101 | */
102 | private void initOneType(Context context, AttributeSet attrs) {
103 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomNavigatorBar);
104 | int totalAttributes = typedArray.getIndexCount();
105 | for (int i = 0 ; i
77 | * @return
78 | */
79 | protected T getView(@Nullable int resourcesId){
80 | return (T) view.findViewById(resourcesId);
81 | }
82 |
83 | /**
84 | * reset all state
85 | */
86 | @Override
87 | public void onDestroyView() {
88 | super.onDestroyView();
89 | isInitialized = false ;
90 | isLoadDataSuccess = false ;
91 | }
92 |
93 | /**
94 | * 刷新数据的方法
95 | * 空实现
96 | * 如果需要刷新数据 需要重写
97 | */
98 | protected void refreshDataSources() {
99 | }
100 |
101 | protected abstract int getLayoutID();
102 |
103 | protected abstract void iniView(View view);
104 |
105 | protected abstract void initializeSuccessButInvisible();
106 |
107 | protected abstract void lazyLoad();
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/drawable/banner.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/leftarrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/drawable/leftarrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/message_wzcx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/drawable/message_wzcx.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/rightarrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/drawable/rightarrow.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
31 |
32 |
40 |
41 |
46 |
47 |
48 |
53 |
54 |
55 |
56 |
61 |
62 |
63 |
68 |
69 |
70 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_title_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 |
14 |
24 |
25 |
35 |
36 |
44 |
45 |
54 |
55 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fourfragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
12 |
13 |
34 |
35 |
38 |
39 |
59 |
62 |
63 |
83 |
84 |
87 |
88 |
108 |
111 |
112 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/threefragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/twofragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MyTestApplication
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/android/mytestapplication/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.android.mytestapplication;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wangluAndroid/CustomNavigatorBar/d63c6be1a3dbaba3b0a989d0eb35fae6bb925817/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------