Skip to content

Commit

Permalink
Merge pull request #11 from jmatsu/fix_height_of_trigger
Browse files Browse the repository at this point in the history
Activate WaveView#setMaxDropHeight
  • Loading branch information
amyu committed Nov 16, 2015
2 parents cfaacc0 + d7e7f9e commit 97452d6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ public void setMaxDropHeight(int maxDropHeight) {
} else {
mUpdateMaxDropHeight = maxDropHeight;
mDropHeightUpdated = true;
if (getViewTreeObserver().isAlive()) {
getViewTreeObserver().removeOnPreDrawListener(this);
getViewTreeObserver().addOnPreDrawListener(this);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@

</jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout>

<SeekBar
android:id="@+id/seekbar_of_drop_height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:layout_alignParentBottom="true"
/>

</RelativeLayout>

</LinearLayout>

0 comments on commit 97452d6

Please sign in to comment.