Skip to content

Commit 82179a6

Browse files
committed
first commit
0 parents  commit 82179a6

File tree

79 files changed

+1730
-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.

79 files changed

+1730
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.3"
6+
defaultConfig {
7+
applicationId "com.bin.david.dialogplus"
8+
minSdkVersion 16
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.3.1'
28+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
29+
testCompile 'junit:junit:4.12'
30+
compile 'com.android.support:appcompat-v7:25.3.1'
31+
compile 'com.android.support:recyclerview-v7:25.3.1'
32+
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.28'
33+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
34+
compile project(':dialoglib')
35+
}

app/proguard-rules.pro

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in E:\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+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.bin.david.dialogplus;
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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
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.bin.david.dialogplus", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.bin.david.dialogplus">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.bin.david.dialogplus;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.support.v7.widget.LinearLayoutManager;
6+
import android.support.v7.widget.RecyclerView;
7+
import android.view.View;
8+
import android.widget.CheckBox;
9+
import android.widget.TextView;
10+
11+
import com.bin.david.dialoglib.BaseDialog;
12+
import com.bin.david.dialogplus.utils.DensityUtil;
13+
import com.chad.library.adapter.base.BaseQuickAdapter;
14+
import com.chad.library.adapter.base.BaseViewHolder;
15+
16+
17+
import java.util.List;
18+
19+
/**
20+
* Created by huang on 2017/9/7.
21+
*/
22+
23+
public class BaseCheckDialog<T> {
24+
25+
private View popView;
26+
private BaseDialog dialog;
27+
private BaseQuickAdapter<T,BaseViewHolder> quickAdapter;
28+
private int selectPosition =-1;
29+
private OnCheckChangeListener<T> listener;
30+
private String title;
31+
private boolean isFillHeight;
32+
private BaseDialog.Builder builder;
33+
34+
public BaseCheckDialog(String title, OnCheckChangeListener<T> listener) {
35+
this.listener = listener;
36+
this.title = title;
37+
}
38+
public BaseCheckDialog(String title, OnCheckChangeListener<T> listener,BaseDialog.Builder builder) {
39+
this.listener = listener;
40+
this.title = title;
41+
this.builder = builder;
42+
}
43+
/**
44+
* 显示
45+
* @param context 上下文
46+
* @param isNewData 是否是新数据
47+
* @param list 数据源
48+
*/
49+
public void show(Context context,boolean isNewData,List<T> list){
50+
show(context,isNewData?-1:selectPosition,list);
51+
}
52+
53+
54+
/**
55+
* 显示
56+
* @param context 上下文
57+
* @param defaultPosition 默认选中的位置
58+
* @param list 数据源
59+
*/
60+
public void show(Context context,int defaultPosition, List<T> list){
61+
selectPosition = defaultPosition;
62+
if(popView == null) {
63+
popView = View.inflate(context, R.layout.pop_base_check, null);
64+
TextView textView = (TextView) popView.findViewById(R.id.tv_check_title);
65+
textView.setText(title);
66+
final RecyclerView recyclerView = (RecyclerView) popView.findViewById(R.id.recyclerView);
67+
recyclerView.setHasFixedSize(true);
68+
recyclerView.setLayoutManager(new LinearLayoutManager(context));
69+
quickAdapter = new BaseQuickAdapter<T,BaseViewHolder>(R.layout.item_pop_calculator,list) {
70+
@Override
71+
protected void convert(BaseViewHolder helper, T item) {
72+
int position = helper.getAdapterPosition();
73+
CheckBox checkBox = helper.getView(R.id.cb_check);
74+
checkBox.setChecked(position == selectPosition);
75+
helper.setText(R.id.tv_indicator_title,listener.getItemText(item));
76+
77+
}
78+
};
79+
recyclerView.setAdapter(quickAdapter);
80+
quickAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
81+
@Override
82+
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
83+
selectPosition = position;
84+
quickAdapter.notifyDataSetChanged();
85+
listener.onItemClick(quickAdapter.getData().get(position),position);
86+
recyclerView.postDelayed(new Runnable() {
87+
@Override
88+
public void run() {
89+
dismiss();
90+
}
91+
},30);
92+
93+
}
94+
});
95+
}else{
96+
quickAdapter.setNewData(list);
97+
quickAdapter.notifyDataSetChanged();
98+
}
99+
boolean isFillHeight = BaseDialog.getScreen((Activity) context).getHeight()
100+
- list.size()* DensityUtil.dip2px(context,50) <= 0;
101+
if(dialog == null) {
102+
if(builder != null){
103+
dialog = builder.setContentView(popView).create();
104+
}else {
105+
dialog = new BaseDialog.Builder(context)
106+
.setFillWidth(true)
107+
.setFillHeight(isFillHeight)
108+
.setContentView(popView)
109+
.create();
110+
}
111+
}else if (isFillHeight != this.isFillHeight){
112+
dialog.notifyHeight(isFillHeight);
113+
}
114+
this.isFillHeight = isFillHeight;
115+
dialog.show();
116+
}
117+
118+
119+
120+
public void dismiss(){
121+
if(dialog != null && dialog.isShowing()){
122+
dialog.dismiss();
123+
}
124+
}
125+
126+
public interface OnCheckChangeListener<T>{
127+
String getItemText(T t);
128+
void onItemClick(T t, int position);
129+
}
130+
}

0 commit comments

Comments
 (0)