Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kayoxu committed Dec 24, 2019
1 parent e4a0176 commit 6c56ec7
Show file tree
Hide file tree
Showing 9 changed files with 654 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions androidlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

}

Expand All @@ -31,4 +35,9 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'com.google.android.material:material:1.2.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.2.0-alpha01'

implementation 'com.github.kayoxu:Android-PickerView:1.1.2'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.kayoxu.androidlib.dialog.common;

import android.app.SearchManager;
import android.content.Context;
import android.view.View;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import com.bigkoo.pickerview.R;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;


/**
* TFBlueAndroidXNew
* com.kayoxu.commonlib.widget
* <p>
* Created by kayoxu on 2019-08-19 20:16.
* Copyright © 2019 kayoxu. All rights reserved.
*/
public class IBottomSheetDialog extends BottomSheetDialog {
int peekHeight = 0;
private BottomSheetBehavior behavior;

public IBottomSheetDialog(@NonNull Context context) {
super(context);
}

public IBottomSheetDialog(@NonNull Context context, int theme) {
super(context, theme);
}

public IBottomSheetDialog(@NonNull Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}

@Override
protected void onStart() {
super.onStart();

}

@Override
public void show() {
super.show();
if (peekHeight == 0) {
View container = findViewById(R.id.content_layout);

if (null != container) {
container.measure(0, 0);
peekHeight = container.getMeasuredHeight();
}
// FrameLayout bottomSheet = (FrameLayout) findViewById(R.id.design_bottom_sheet);
if (null != getBehavior()) {
behavior.setPeekHeight(peekHeight);
}
}
}

@NonNull
@Override
public BottomSheetBehavior getBehavior() {
if (null == behavior) {
FrameLayout bottomSheet = (FrameLayout) findViewById(R.id.design_bottom_sheet);
if (null != bottomSheet) {
behavior = BottomSheetBehavior.from(bottomSheet);
}
}

return behavior;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.kayoxu.androidlib.dialog.common;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.NumberPicker;

import java.lang.reflect.Field;



public class INumberPicker extends NumberPicker {

Context context;

public INumberPicker(Context context) {
super(context);
this.context = context;
}

public INumberPicker(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}

public INumberPicker(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
}


@Override
public void addView(View child) {
super.addView(child);
updateView(child);
}

@Override
public void addView(View child, int width, int height) {
super.addView(child, width, height);
updateView(child);
}

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
super.addView(child, index, params);
updateView(child);
}

@Override
public void addView(View child, ViewGroup.LayoutParams params) {
super.addView(child, params);
updateView(child);
}

public void updateView(View view) {
setDatePickerDividerColor(this);
setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);

if (view instanceof EditText) {
//这里修改显示字体的属性,主要修改颜色和大小
// ((EditText) view).setTextColor(Color.parseColor("#FF0000"));
// ((EditText) view).setTextSize(14);
}
}

private void setDatePickerDividerColor(NumberPicker picker) {
Field[] pickerFields = NumberPicker.class.getDeclaredFields();
for (Field pf : pickerFields) {
if (pf.getName().equals("mSelectionDivider")) {
pf.setAccessible(true);
try {
//设置分割线的颜色值
pf.set(picker, new ColorDrawable(Color.parseColor("#B8B8B8")));
} catch (IllegalArgumentException | Resources.NotFoundException | IllegalAccessException e) {
e.printStackTrace();
}
break;
}
}

// 分割线高度
for (Field pf : pickerFields) {
if (pf.getName().equals("mSelectionDividerHeight")) {
pf.setAccessible(true);
try {
// int result = dp2px(context, 1);
int result = 3;
pf.set(picker, result);
} catch (Exception e) {
e.printStackTrace();
}
break;
}
}
}

public int dp2px(Context context, float dpValue) {
float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.kayoxu.androidlib.dialog;

public class ddd {
}
Loading

0 comments on commit 6c56ec7

Please sign in to comment.