From a962b8ef6cd0c620edc85ae7f2c500dea938438b Mon Sep 17 00:00:00 2001 From: Jumpei Matsuda Date: Mon, 16 Nov 2015 17:16:45 +0900 Subject: [PATCH 1/2] Fixed that the specified max height for the trigger of drop animation is ignored This adds the safe insertion of OnPreDrawListener to ViewTreeObserver. Max height is refreshed only on onPreDraw stage and it requires the observer. --- .../java/jp/co/recruit_lifestyle/android/widget/WaveView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/jp/co/recruit_lifestyle/android/widget/WaveView.java b/library/src/main/java/jp/co/recruit_lifestyle/android/widget/WaveView.java index 8125cdc..be0cb54 100644 --- a/library/src/main/java/jp/co/recruit_lifestyle/android/widget/WaveView.java +++ b/library/src/main/java/jp/co/recruit_lifestyle/android/widget/WaveView.java @@ -622,6 +622,10 @@ public void setMaxDropHeight(int maxDropHeight) { } else { mUpdateMaxDropHeight = maxDropHeight; mDropHeightUpdated = true; + if (getViewTreeObserver().isAlive()) { + getViewTreeObserver().removeOnPreDrawListener(this); + getViewTreeObserver().addOnPreDrawListener(this); + } } } From d7e7f9e3992e73f185c630cc0c447f7ae42f7f37 Mon Sep 17 00:00:00 2001 From: Jumpei Matsuda Date: Mon, 16 Nov 2015 17:12:13 +0900 Subject: [PATCH 2/2] Added the SeekBar to change the parameters of WaveView Affects sample module. Added SeekBar can change the height which is the trigger of WaveView drop animation. --- .../sample/MainActivity.java | 21 +++++++++++++++++++ sample/src/main/res/layout/activity_main.xml | 8 +++++++ 2 files changed, 29 insertions(+) diff --git a/sample/src/main/java/jp/co/recruit_lifestyle/sample/MainActivity.java b/sample/src/main/java/jp/co/recruit_lifestyle/sample/MainActivity.java index f18064c..dd9dd78 100644 --- a/sample/src/main/java/jp/co/recruit_lifestyle/sample/MainActivity.java +++ b/sample/src/main/java/jp/co/recruit_lifestyle/sample/MainActivity.java @@ -10,7 +10,10 @@ import android.view.WindowManager; import android.widget.ArrayAdapter; import android.widget.ListView; +import android.widget.SeekBar; + import java.util.ArrayList; + import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; public class MainActivity extends AppCompatActivity implements WaveSwipeRefreshLayout.OnRefreshListener { @@ -38,6 +41,24 @@ private void initView() { //mWaveSwipeRefreshLayout.setMaxDropHeight(1500); mListview = (ListView) findViewById(R.id.main_list); + + ((SeekBar) findViewById(R.id.seekbar_of_drop_height)).setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + // ignore + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + // ignore + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + float scale = (seekBar.getProgress() / 100f); + mWaveSwipeRefreshLayout.setMaxDropHeight((int) (mWaveSwipeRefreshLayout.getHeight() * scale)); + } + }); } private void setSampleData() { diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index d1ff3e8..4806a27 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -51,6 +51,14 @@ + +