Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add edit text dialog and list dialog #134

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ A message with a custom icon:
.setCustomImage(R.drawable.custom_img)
.show();

A edit text dialog:

new SweetAlertDialog(this, SweetAlertDialog.EDIT_TEXT_TYPE)
.setTitleText("Edit text")
.setContentText("Please enter the text.")
.show();

A list text dialog:

new SweetAlertDialog(this, SweetAlertDialog.LIST_TYPE)
.setTitleText("List dialog")
.setContentText("Please select list item.")
.setList(list)
.setListTextSize(20)
.show();

Bind the listener to confirm button:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
Expand All @@ -129,6 +145,35 @@ Bind the listener to confirm button:
})
.show();

Bind the listener to edit text confirm button:

new SweetAlertDialog(this, SweetAlertDialog.EDIT_TEXT_TYPE)
.setTitleText("Are you sure?")
.setTitleText("Edit text")
.setContentText("Please enter the text.")
.setEditTextConfirmClickListener(new SweetAlertDialog.OnEditTextSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sDialog, String inputText) {
sDialog.dismissWithAnimation();
}
})
.show();

Bind the listener to list:

new SweetAlertDialog(this, SweetAlertDialog.LIST_TYPE)
.setTitleText("List dialog")
.setContentText("Please select list item.")
.setList(list)
.setListTextSize(20)
.setListClickListener(new SweetAlertDialog.OnListSweetClickListener() {
@Override
public void onItemClick(SweetAlertDialog sDialog, int position, String listText) {
sDialog.dismissWithAnimation();
}
})
.show();

Show the cancel button and bind listener to it:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
Expand Down
45 changes: 45 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@ Android版的SweetAlert,清新文艺,快意灵动的甜心弹框
.setCustomImage(R.drawable.custom_img)
.show();

A edit text dialog:

new SweetAlertDialog(this, SweetAlertDialog.EDIT_TEXT_TYPE)
.setTitleText("Edit text")
.setContentText("Please enter the text.")
.show();

A list text dialog:

new SweetAlertDialog(this, SweetAlertDialog.LIST_TYPE)
.setTitleText("List dialog")
.setContentText("Please select list item.")
.setList(list)
.setListTextSize(20)
.show();

确认事件绑定:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
Expand All @@ -128,6 +144,35 @@ Android版的SweetAlert,清新文艺,快意灵动的甜心弹框
})
.show();

Bind the listener to edit text confirm button:

new SweetAlertDialog(this, SweetAlertDialog.EDIT_TEXT_TYPE)
.setTitleText("Are you sure?")
.setTitleText("Edit text")
.setContentText("Please enter the text.")
.setEditTextConfirmClickListener(new SweetAlertDialog.OnEditTextSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sDialog, String inputText) {
sDialog.dismissWithAnimation();
}
})
.show();

Bind the listener to list:

new SweetAlertDialog(this, SweetAlertDialog.LIST_TYPE)
.setTitleText("List dialog")
.setContentText("Please select list item.")
.setList(list)
.setListTextSize(20)
.setListClickListener(new SweetAlertDialog.OnListSweetClickListener() {
@Override
public void onItemClick(SweetAlertDialog sDialog, int position, String listText) {
sDialog.dismissWithAnimation();
}
})
.show();

显示取消按钮及事件绑定:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.1'
classpath 'com.android.tools.build:gradle:2.3.1'
}
}

ext {
compileSdkVersion = 21
buildToolsVersion = "19.1.0"
compileSdkVersion = 25
buildToolsVersion = "25.0.2"
}

allprojects {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Dec 02 17:43:17 CET 2014
#Tue May 02 15:42:42 JST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
4 changes: 3 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion 9
minSdkVersion 21
}

lintOptions {
Expand All @@ -18,6 +18,8 @@ android {

dependencies {
compile 'com.pnikosis:materialish-progress:1.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cn.pedant.SweetAlert;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;

public class ListRecyclerAdapter extends RecyclerView.Adapter<ListRecyclerAdapter.ViewHolder> {

private LayoutInflater mInflater;
private ArrayList<String> mData;
private OnRecyclerListener mListener;
private int mTextSize;

public ListRecyclerAdapter(Context context, ArrayList<String> data, OnRecyclerListener listener, int textSize) {
mInflater = LayoutInflater.from(context);
mData = data;
mListener = listener;
mTextSize = textSize;
}

public interface OnRecyclerListener {
void onItemClick(View v, int position);
}

@Override
public ListRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(mInflater.inflate(R.layout.list_item, parent, false));
}

@Override
public void onBindViewHolder(ViewHolder holder, final int position) {
holder.textView.setText(mData.get(position));
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListener.onItemClick(v, position);
}
});

}

@Override
public int getItemCount() {
return mData.size();
}

class ViewHolder extends RecyclerView.ViewHolder {
TextView textView;
public ViewHolder(View v) {
super(v);
textView = (TextView) v.findViewById(R.id.list_item_text);
textView.setTextSize(mTextSize);
}
}

}
Loading