diff --git a/app/build.gradle b/app/build.gradle index b78bed0..e9737aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,4 +27,7 @@ dependencies { implementation "com.jakewharton:butterknife:8.8.1" annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' + implementation project(path: ':dialoglib') + + } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5bff2fc..5a3616e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,3 +1,4 @@ + @@ -7,5 +8,14 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" /> - + android:theme="@style/AppTheme"> + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/nasduck/duckandroiddialog/MainActivity.java b/app/src/main/java/com/nasduck/duckandroiddialog/MainActivity.java deleted file mode 100644 index fed901c..0000000 --- a/app/src/main/java/com/nasduck/duckandroiddialog/MainActivity.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.nasduck.duckandroiddialog; - -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; - -import butterknife.ButterKnife; -import butterknife.OnClick; - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - ButterKnife.bind(this); - } - -// @OnClick(R.id.btn_toast_text) -// public void onTextToast() { -// DuckDialog.assignTextToast("hello world!!") -// .setCancelable(true) -// .buildTextToast() -// .show(getSupportFragmentManager(), ""); -// } -// -// @OnClick(R.id.btn_toast_image) -// public void onImageToast() { -// DuckDialog.assignImageToast() -// .setCancelable(true) -// .buildImageToast() -// .show(getSupportFragmentManager(), ""); -// } -// -// @OnClick(R.id.btn_toast_text_image) -// public void onTextImageToast() { -// DuckDialog.assignTextAndImageToast("hello world!!") -// .setCancelable(true) -// .buildTextImageToast() -// .show(getSupportFragmentManager(), ""); -// } -} diff --git a/app/src/main/java/com/nasduck/duckandroiddialog/TestActivity.java b/app/src/main/java/com/nasduck/duckandroiddialog/TestActivity.java new file mode 100644 index 0000000..b68d891 --- /dev/null +++ b/app/src/main/java/com/nasduck/duckandroiddialog/TestActivity.java @@ -0,0 +1,43 @@ +package com.nasduck.duckandroiddialog; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +import com.nasduck.dialoglib.Base.DuckDialog; + +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class TestActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + ButterKnife.bind(this); + } + + @OnClick(R.id.btn_toast_text) + public void onTextToast() { + DuckDialog.assignTextToast("hello world!!") + .setCancelable(true) + .buildTextToast() + .show(getSupportFragmentManager(), ""); + } + + @OnClick(R.id.btn_toast_image) + public void onImageToast() { + DuckDialog.assignImageToast() + .setCancelable(true) + .buildImageToast() + .show(getSupportFragmentManager(), ""); + } + + @OnClick(R.id.btn_toast_text_image) + public void onTextImageToast() { + DuckDialog.assignTextAndImageToast("hello world!!") + .setCancelable(true) + .buildTextImageToast() + .show(getSupportFragmentManager(), ""); + } +} diff --git a/dialoglib/src/main/java/com/nasduck/dialoglib/Base/DuckDialog.java b/dialoglib/src/main/java/com/nasduck/dialoglib/Base/DuckDialog.java index 01ed900..6371fa1 100644 --- a/dialoglib/src/main/java/com/nasduck/dialoglib/Base/DuckDialog.java +++ b/dialoglib/src/main/java/com/nasduck/dialoglib/Base/DuckDialog.java @@ -35,8 +35,8 @@ public static ImageToastConfigBean assignImageToast() { ImageToastConfigBean configBean = new ImageToastConfigBean(); configBean.setBackground(R.drawable.bg_default) .setCancelable(false) - .setHasShade(true); -// .setImage(R.mipmap.ic_launcher); + .setHasShade(true) + .setImage(R.drawable.ic_launcher); return configBean; } @@ -50,7 +50,7 @@ public static TextAndImageToastConfigBean assignTextAndImageToast(String content configBean.setBackground(R.drawable.bg_default) .setCancelable(false) .setHasShade(true) -// .setImage(R.mipmap.ic_launcher) + .setImage(R.drawable.ic_launcher) .setContentText(contentText) .setContentTextSize(16) .setContentTextColor(R.color.colorDefaultContentText); diff --git a/dialoglib/src/main/java/com/nasduck/dialoglib/toast/ImageToast.java b/dialoglib/src/main/java/com/nasduck/dialoglib/toast/ImageToast.java index 5c4854d..830bf93 100644 --- a/dialoglib/src/main/java/com/nasduck/dialoglib/toast/ImageToast.java +++ b/dialoglib/src/main/java/com/nasduck/dialoglib/toast/ImageToast.java @@ -18,8 +18,7 @@ public class ImageToast extends BaseDialogFragment { private int mImage; public ImageToast() { - mLayoutBackground = view.findViewById(R.id.background); - mIvImage = view.findViewById(R.id.iv_image); + } public static ImageToast newImageToast(ImageToastConfigBean configBean){ @@ -51,6 +50,9 @@ protected int getLayoutId() { @Override protected void initEventAndData() { + mLayoutBackground = view.findViewById(R.id.background); + mIvImage = view.findViewById(R.id.iv_image); + mLayoutBackground.setBackgroundResource(mBackground); setShade(hasShade); setCancelable(isCancelable); diff --git a/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextImageToast.java b/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextImageToast.java index d9622a8..b1518a9 100644 --- a/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextImageToast.java +++ b/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextImageToast.java @@ -23,9 +23,7 @@ public class TextImageToast extends BaseDialogFragment { private int mContentTextSize; public TextImageToast(){ - mLayoutBackground = view.findViewById(R.id.background); - mIvImage = view.findViewById(R.id.iv_image); - mTvContent = view.findViewById(R.id.tv_content); + } public static TextImageToast newTextToast(TextAndImageToastConfigBean configBean){ @@ -63,6 +61,10 @@ protected int getLayoutId() { @Override protected void initEventAndData() { + mLayoutBackground = view.findViewById(R.id.background); + mIvImage = view.findViewById(R.id.iv_image); + mTvContent = view.findViewById(R.id.tv_content); + mLayoutBackground.setBackgroundResource(mBackground); setCancelable(isCancelable); setShade(hasShade); diff --git a/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextToast.java b/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextToast.java index 6c92281..14a0ee6 100644 --- a/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextToast.java +++ b/dialoglib/src/main/java/com/nasduck/dialoglib/toast/TextToast.java @@ -20,8 +20,7 @@ public class TextToast extends BaseDialogFragment { private int mContentTextSize; public TextToast(){ - mTvContent = view.findViewById(R.id.tv_content); - mLayoutBackground = view.findViewById(R.id.background); + } public static TextToast newTextToast(TextToastConfigBean configBean){ @@ -57,6 +56,9 @@ protected int getLayoutId() { @Override protected void initEventAndData() { + mTvContent = view.findViewById(R.id.tv_content); + mLayoutBackground = view.findViewById(R.id.background); + mLayoutBackground.setBackgroundResource(mBackground); setCancelable(isCancelable); setShade(hasShade); diff --git a/dialoglib/src/main/res/drawable/ic_launcher.png b/dialoglib/src/main/res/drawable/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/dialoglib/src/main/res/drawable/ic_launcher.png differ