From 57710b0f310eb312d36c33deac605e46d6438e92 Mon Sep 17 00:00:00 2001 From: WindFantasy Date: Thu, 28 Jul 2016 14:49:03 +0800 Subject: [PATCH 1/3] add a set gravity to SimpleDialog message view method --- .../main/java/com/rey/material/app/SimpleDialog.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/material/src/main/java/com/rey/material/app/SimpleDialog.java b/material/src/main/java/com/rey/material/app/SimpleDialog.java index 33edbbd9..d70bc53d 100644 --- a/material/src/main/java/com/rey/material/app/SimpleDialog.java +++ b/material/src/main/java/com/rey/material/app/SimpleDialog.java @@ -163,6 +163,18 @@ private void initMessageView(){ mMessage.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); } + /** + * Set a gravity to this message view + * @param gravity + * @return The SimpleDialog for chaining methods. + */ + public SimpleDialog messageGravity(int gravity){ + if(mMessage == null) + initMessageView(); + mMessage.setGravity(gravity); + return this; + } + /** * Set a message text to this SimpleDialog. * @param message From be7e7a0fe1448a18955856bca64d05c00e6f7259 Mon Sep 17 00:00:00 2001 From: WindFantasy Date: Tue, 23 Aug 2016 11:10:11 +0800 Subject: [PATCH 2/3] change many onTouchEvent implements --- app/src/main/java/com/rey/material/app/ContactView.java | 3 +-- material/build.gradle | 3 --- material/src/main/java/com/rey/material/widget/Button.java | 2 +- .../src/main/java/com/rey/material/widget/CheckedTextView.java | 2 +- .../src/main/java/com/rey/material/widget/CompoundButton.java | 2 +- .../java/com/rey/material/widget/FloatingActionButton.java | 2 +- .../src/main/java/com/rey/material/widget/FrameLayout.java | 2 +- .../src/main/java/com/rey/material/widget/ImageButton.java | 2 +- material/src/main/java/com/rey/material/widget/ImageView.java | 2 +- .../src/main/java/com/rey/material/widget/LinearLayout.java | 2 +- .../src/main/java/com/rey/material/widget/RelativeLayout.java | 2 +- material/src/main/java/com/rey/material/widget/TextView.java | 2 +- 12 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/rey/material/app/ContactView.java b/app/src/main/java/com/rey/material/app/ContactView.java index 10cb0a5e..2f4c2c5f 100644 --- a/app/src/main/java/com/rey/material/app/ContactView.java +++ b/app/src/main/java/com/rey/material/app/ContactView.java @@ -15,7 +15,6 @@ import android.graphics.Shader; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.os.Build; import android.support.annotation.NonNull; import android.support.v4.view.GravityCompat; import android.text.TextUtils; @@ -159,7 +158,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return mRippleManager.onTouchEvent(this, event) || result; + return result && mRippleManager.onTouchEvent(this, event); } public void setAvatarBitmap(Bitmap bm){ diff --git a/material/build.gradle b/material/build.gradle index 38b9c1fe..9b453434 100644 --- a/material/build.gradle +++ b/material/build.gradle @@ -31,6 +31,3 @@ dependencies { } // Place it at the end of the file -apply from: "$rootProject.projectDir/dist/distInfo.gradle" -apply from: "$rootProject.projectDir/dist/bintray.gradle" -apply from: "$rootProject.projectDir/dist/maven.gradle" diff --git a/material/src/main/java/com/rey/material/widget/Button.java b/material/src/main/java/com/rey/material/widget/Button.java index 7a1e8da8..bdeb3977 100644 --- a/material/src/main/java/com/rey/material/widget/Button.java +++ b/material/src/main/java/com/rey/material/widget/Button.java @@ -122,7 +122,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/CheckedTextView.java b/material/src/main/java/com/rey/material/widget/CheckedTextView.java index 1bf60fce..a5d2a99f 100644 --- a/material/src/main/java/com/rey/material/widget/CheckedTextView.java +++ b/material/src/main/java/com/rey/material/widget/CheckedTextView.java @@ -151,6 +151,6 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/CompoundButton.java b/material/src/main/java/com/rey/material/widget/CompoundButton.java index ebb5a7db..39a3da4f 100644 --- a/material/src/main/java/com/rey/material/widget/CompoundButton.java +++ b/material/src/main/java/com/rey/material/widget/CompoundButton.java @@ -229,7 +229,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } @Override diff --git a/material/src/main/java/com/rey/material/widget/FloatingActionButton.java b/material/src/main/java/com/rey/material/widget/FloatingActionButton.java index ed9e7342..4dfd0b8d 100644 --- a/material/src/main/java/com/rey/material/widget/FloatingActionButton.java +++ b/material/src/main/java/com/rey/material/widget/FloatingActionButton.java @@ -502,7 +502,7 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { return false; boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } @Override diff --git a/material/src/main/java/com/rey/material/widget/FrameLayout.java b/material/src/main/java/com/rey/material/widget/FrameLayout.java index cd7b0f49..80c59804 100644 --- a/material/src/main/java/com/rey/material/widget/FrameLayout.java +++ b/material/src/main/java/com/rey/material/widget/FrameLayout.java @@ -110,7 +110,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/ImageButton.java b/material/src/main/java/com/rey/material/widget/ImageButton.java index f286ae96..b729c684 100644 --- a/material/src/main/java/com/rey/material/widget/ImageButton.java +++ b/material/src/main/java/com/rey/material/widget/ImageButton.java @@ -110,7 +110,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/ImageView.java b/material/src/main/java/com/rey/material/widget/ImageView.java index 38b36430..3018867d 100644 --- a/material/src/main/java/com/rey/material/widget/ImageView.java +++ b/material/src/main/java/com/rey/material/widget/ImageView.java @@ -113,7 +113,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/LinearLayout.java b/material/src/main/java/com/rey/material/widget/LinearLayout.java index e01e7806..f5410f33 100644 --- a/material/src/main/java/com/rey/material/widget/LinearLayout.java +++ b/material/src/main/java/com/rey/material/widget/LinearLayout.java @@ -113,7 +113,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/RelativeLayout.java b/material/src/main/java/com/rey/material/widget/RelativeLayout.java index f1528859..613c4961 100644 --- a/material/src/main/java/com/rey/material/widget/RelativeLayout.java +++ b/material/src/main/java/com/rey/material/widget/RelativeLayout.java @@ -110,7 +110,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } } diff --git a/material/src/main/java/com/rey/material/widget/TextView.java b/material/src/main/java/com/rey/material/widget/TextView.java index d372113f..4a03c452 100644 --- a/material/src/main/java/com/rey/material/widget/TextView.java +++ b/material/src/main/java/com/rey/material/widget/TextView.java @@ -128,7 +128,7 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return getRippleManager().onTouchEvent(this, event) || result; + return result && getRippleManager().onTouchEvent(this, event); } public void setOnSelectionChangedListener(OnSelectionChangedListener listener){ From 50aeb6ece14a291ca48451bd761bde0282aa43d2 Mon Sep 17 00:00:00 2001 From: WindFantasy Date: Wed, 7 Sep 2016 15:19:58 +0800 Subject: [PATCH 3/3] fix bug --- app/src/main/java/com/rey/material/app/ContactView.java | 4 +++- material/src/main/java/com/rey/material/widget/Button.java | 4 +++- .../main/java/com/rey/material/widget/CheckedTextView.java | 4 +++- .../main/java/com/rey/material/widget/CompoundButton.java | 4 +++- .../java/com/rey/material/widget/FloatingActionButton.java | 6 ++++-- .../src/main/java/com/rey/material/widget/FrameLayout.java | 4 +++- .../src/main/java/com/rey/material/widget/ImageButton.java | 4 +++- .../src/main/java/com/rey/material/widget/ImageView.java | 4 +++- .../src/main/java/com/rey/material/widget/LinearLayout.java | 4 +++- .../main/java/com/rey/material/widget/RelativeLayout.java | 4 +++- .../src/main/java/com/rey/material/widget/TextView.java | 4 +++- 11 files changed, 34 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/rey/material/app/ContactView.java b/app/src/main/java/com/rey/material/app/ContactView.java index 2f4c2c5f..6bdc7ce1 100644 --- a/app/src/main/java/com/rey/material/app/ContactView.java +++ b/app/src/main/java/com/rey/material/app/ContactView.java @@ -158,7 +158,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && mRippleManager.onTouchEvent(this, event); + if(result) + mRippleManager.onTouchEvent(this, event); + return result; } public void setAvatarBitmap(Bitmap bm){ diff --git a/material/src/main/java/com/rey/material/widget/Button.java b/material/src/main/java/com/rey/material/widget/Button.java index bdeb3977..150d2373 100644 --- a/material/src/main/java/com/rey/material/widget/Button.java +++ b/material/src/main/java/com/rey/material/widget/Button.java @@ -122,7 +122,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/CheckedTextView.java b/material/src/main/java/com/rey/material/widget/CheckedTextView.java index a5d2a99f..97a23444 100644 --- a/material/src/main/java/com/rey/material/widget/CheckedTextView.java +++ b/material/src/main/java/com/rey/material/widget/CheckedTextView.java @@ -151,6 +151,8 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/CompoundButton.java b/material/src/main/java/com/rey/material/widget/CompoundButton.java index 39a3da4f..90a1e188 100644 --- a/material/src/main/java/com/rey/material/widget/CompoundButton.java +++ b/material/src/main/java/com/rey/material/widget/CompoundButton.java @@ -229,7 +229,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } @Override diff --git a/material/src/main/java/com/rey/material/widget/FloatingActionButton.java b/material/src/main/java/com/rey/material/widget/FloatingActionButton.java index 4dfd0b8d..3d890518 100644 --- a/material/src/main/java/com/rey/material/widget/FloatingActionButton.java +++ b/material/src/main/java/com/rey/material/widget/FloatingActionButton.java @@ -501,8 +501,10 @@ public boolean onTouchEvent(@NonNull MotionEvent event) { if(action == MotionEvent.ACTION_DOWN && ! mBackground.isPointerOver(event.getX(), event.getY())) return false; - boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + boolean result = super.onTouchEvent(event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } @Override diff --git a/material/src/main/java/com/rey/material/widget/FrameLayout.java b/material/src/main/java/com/rey/material/widget/FrameLayout.java index 80c59804..f2ddf3e2 100644 --- a/material/src/main/java/com/rey/material/widget/FrameLayout.java +++ b/material/src/main/java/com/rey/material/widget/FrameLayout.java @@ -110,7 +110,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/ImageButton.java b/material/src/main/java/com/rey/material/widget/ImageButton.java index b729c684..41301c3b 100644 --- a/material/src/main/java/com/rey/material/widget/ImageButton.java +++ b/material/src/main/java/com/rey/material/widget/ImageButton.java @@ -110,7 +110,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/ImageView.java b/material/src/main/java/com/rey/material/widget/ImageView.java index 3018867d..76d8a678 100644 --- a/material/src/main/java/com/rey/material/widget/ImageView.java +++ b/material/src/main/java/com/rey/material/widget/ImageView.java @@ -113,7 +113,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/LinearLayout.java b/material/src/main/java/com/rey/material/widget/LinearLayout.java index f5410f33..959c669f 100644 --- a/material/src/main/java/com/rey/material/widget/LinearLayout.java +++ b/material/src/main/java/com/rey/material/widget/LinearLayout.java @@ -113,7 +113,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/RelativeLayout.java b/material/src/main/java/com/rey/material/widget/RelativeLayout.java index 613c4961..138e2edf 100644 --- a/material/src/main/java/com/rey/material/widget/RelativeLayout.java +++ b/material/src/main/java/com/rey/material/widget/RelativeLayout.java @@ -110,7 +110,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } } diff --git a/material/src/main/java/com/rey/material/widget/TextView.java b/material/src/main/java/com/rey/material/widget/TextView.java index 4a03c452..42a43260 100644 --- a/material/src/main/java/com/rey/material/widget/TextView.java +++ b/material/src/main/java/com/rey/material/widget/TextView.java @@ -128,7 +128,9 @@ public void setOnClickListener(OnClickListener l) { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { boolean result = super.onTouchEvent(event); - return result && getRippleManager().onTouchEvent(this, event); + if(result) + getRippleManager().onTouchEvent(this, event); + return result; } public void setOnSelectionChangedListener(OnSelectionChangedListener listener){