Skip to content

Commit e607ed6

Browse files
author
fuchaoyang
committed
史上最强、最好用的选择器控件(Picker)
0 parents  commit e607ed6

File tree

77 files changed

+4879
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+4879
-0
lines changed

.gitignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/gradle.properties
2+
#Android generated
3+
bin
4+
gen
5+
lint.xml
6+
lint
7+
8+
#Eclipse
9+
.project
10+
.classpath
11+
.settings
12+
.checkstyle
13+
14+
#IntelliJ IDEA
15+
.idea
16+
*.iml
17+
*.ipr
18+
*.iws
19+
classes
20+
gen-external-apklibs
21+
22+
#gradle
23+
.gradle
24+
local.properties
25+
gradlew
26+
gradlew.bat
27+
gradle/
28+
build/
29+
30+
#vi
31+
*.swp
32+
33+
#other editors
34+
*.bak
35+
36+
#Maven
37+
target
38+
release.properties
39+
pom.xml.*
40+
41+
#Ant
42+
build.xml
43+
ant.properties
44+
proguard.cfg
45+
proguard-project.txt
46+
47+
#Other
48+
.DS_Store
49+
Thumbs.db
50+
tmp
51+
*.tgz
52+
*.lock
53+
*.lck
54+
#docs
55+
/doc/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
>史上最强、最好用的选择器控件(Picker)

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "org.jaaksi.pickerview.demo"
7+
minSdkVersion 15
8+
targetSdkVersion 26
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(include: ['*.jar'], dir: 'libs')
23+
implementation 'com.android.support:appcompat-v7:26.1.0'
24+
implementation project(':pickerview')
25+
implementation 'com.android.support:support-v4:26.1.0'
26+
compile 'com.google.code.gson:gson:2.8.0'
27+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/AndroidManifest.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.jaaksi.pickerview.demo">
4+
5+
<application
6+
android:name=".MyApplication"
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme">
13+
<activity android:name=".MainActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
</application>
21+
22+
</manifest>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.jaaksi.pickerview.demo;
2+
3+
import android.app.Activity;
4+
import android.app.Fragment;
5+
import android.os.Bundle;
6+
import android.support.annotation.Nullable;
7+
import android.support.v7.app.AppCompatActivity;
8+
9+
/**
10+
* Created by fuchaoyang on 2018/2/10.<br/>
11+
* description:
12+
*/
13+
14+
public class BaseActivity extends AppCompatActivity {
15+
protected Activity mContext;
16+
17+
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
18+
super.onCreate(savedInstanceState);
19+
mContext = this;
20+
}
21+
22+
protected void openFragment(Fragment fragment) {
23+
getFragmentManager().beginTransaction()
24+
.add(android.R.id.content, fragment)
25+
.addToBackStack(null)
26+
.commit();
27+
}
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.jaaksi.pickerview.demo;
2+
3+
import android.app.Activity;
4+
import android.app.Fragment;
5+
import android.graphics.Color;
6+
import android.os.Bundle;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
11+
/**
12+
* 创建时间:2018年02月12日13:56 <br>
13+
* 作者:fuchaoyang <br>
14+
* 描述:
15+
*/
16+
17+
public abstract class BaseFragment extends Fragment {
18+
protected Activity mActivity;
19+
20+
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
21+
Bundle savedInstanceState) {
22+
mActivity = getActivity();
23+
View view = inflater.inflate(getLayoutId(), container, false);
24+
view.setBackgroundColor(Color.WHITE);
25+
view.setClickable(true);
26+
initView(view);
27+
return view;
28+
}
29+
30+
protected abstract int getLayoutId();
31+
32+
protected abstract void initView(View view);
33+
34+
protected void openFragment(Fragment fragment) {
35+
getFragmentManager().beginTransaction()
36+
.add(android.R.id.content, fragment)
37+
.addToBackStack(null)
38+
.commit();
39+
}
40+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package org.jaaksi.pickerview.demo;
2+
3+
import android.content.Context;
4+
import android.support.annotation.ColorInt;
5+
import android.view.LayoutInflater;
6+
import android.view.View;
7+
import android.view.ViewGroup;
8+
import android.widget.ImageView;
9+
import android.widget.TextView;
10+
import org.jaaksi.pickerview.topbar.ITopBar;
11+
import org.jaaksi.pickerview.util.Util;
12+
13+
/**
14+
* Created by fuchaoyang on 2018/2/16.<br/>
15+
* description:自定义topbar
16+
*/
17+
18+
public class CustomTopBar implements ITopBar {
19+
private Context mContext;
20+
private View mTopBar, mDivider;
21+
private ImageView mBtnCancel;
22+
private TextView mBtnConfirm, mTvTitle;
23+
24+
public CustomTopBar(ViewGroup parent) {
25+
mContext = parent.getContext();
26+
mTopBar =
27+
LayoutInflater.from(mContext).inflate(R.layout.pickerview_topbar_custom, parent, false);
28+
mDivider = mTopBar.findViewById(R.id.divider);
29+
mBtnCancel = mTopBar.findViewById(R.id.btn_cancel);
30+
mBtnConfirm = mTopBar.findViewById(R.id.btn_confirm);
31+
mTvTitle = mTopBar.findViewById(R.id.tv_title);
32+
}
33+
34+
public CustomTopBar setDividerColor(@ColorInt int color) {
35+
mDivider.setBackgroundColor(color);
36+
return this;
37+
}
38+
39+
/**
40+
* 设置bottom divider line height
41+
*
42+
* @param height dp
43+
*/
44+
public CustomTopBar setDividerHeight(float height) {
45+
mDivider.getLayoutParams().height = Util.dip2px(mContext, height);
46+
mDivider.requestLayout();
47+
return this;
48+
}
49+
50+
public View getDivider() {
51+
return mDivider;
52+
}
53+
54+
@Override public View getTopBarView() {
55+
return mTopBar;
56+
}
57+
58+
@Override public ImageView getBtnCancel() {
59+
return mBtnCancel;
60+
}
61+
62+
@Override public TextView getBtnConfirm() {
63+
return mBtnConfirm;
64+
}
65+
66+
@Override public TextView getTitleView() {
67+
return mTvTitle;
68+
}
69+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.jaaksi.pickerview.demo;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.view.View;
6+
7+
/**
8+
* Created by fuchaoyang on 2018/2/10.<br/>
9+
* description:
10+
*/
11+
12+
public class MainActivity extends BaseActivity {
13+
14+
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_main);
17+
}
18+
19+
public void onClick(View view) {
20+
switch (view.getId()) {
21+
case R.id.btn_timepicker:
22+
openFragment(new TimePickerFragment());
23+
break;
24+
case R.id.btn_mixedtimepicker:
25+
openFragment(new MixedTimePickerFragment());
26+
break;
27+
case R.id.btn_optionpicker:
28+
openFragment(new OptionPickerFragment());
29+
break;
30+
case R.id.btn_test_pickerview:
31+
openFragment(new TestPickerViewFragment());
32+
break;
33+
case R.id.btn_picker_configs:
34+
openFragment(new PickerConfigFragment());
35+
break;
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)