-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from techery/feature/scroll_controller_addition
Feature :: scroll controller addition
- Loading branch information
Showing
17 changed files
with
235 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...addition/src/main/java/io/techery/progresshint/addition/ProgressHintScrollController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.techery.progresshint.addition; | ||
|
||
import android.view.View; | ||
import android.view.ViewTreeObserver; | ||
import io.techery.progresshint.ProgressHintDelegate; | ||
import io.techery.progresshint.ProgressHintDelegate.SeekBarHintDelegateHolder; | ||
|
||
public class ProgressHintScrollController implements ViewTreeObserver.OnScrollChangedListener { | ||
|
||
private final View container; | ||
private final ProgressHintDelegate delegate; | ||
|
||
public static ProgressHintScrollController register(View container, SeekBarHintDelegateHolder holder) { | ||
ProgressHintScrollController controller = new ProgressHintScrollController(container, holder); | ||
container.getViewTreeObserver().addOnScrollChangedListener(controller); | ||
return controller; | ||
} | ||
|
||
ProgressHintScrollController(View container, SeekBarHintDelegateHolder holder) { | ||
this.container = container; | ||
this.delegate = holder.getHintDelegate(); | ||
} | ||
|
||
@Override public void onScrollChanged() { | ||
if (delegate.isPopupVisible()) { | ||
if (!delegate.isWidgetFullyVisible(container)) delegate.hidePopup(); | ||
} else if (delegate.isPopupAlwaysShown() && delegate.isWidgetFullyVisible(container)) { | ||
delegate.showPopup(); | ||
} | ||
} | ||
|
||
public void dispose() { | ||
container.getViewTreeObserver().removeOnScrollChangedListener(this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
library-addition/src/main/java/io/techery/progresshint/addition/ViewUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.techery.progresshint.addition; | ||
|
||
import android.view.View; | ||
|
||
final class ViewUtil { | ||
|
||
static int getRelativeTop(View view, View container) { | ||
if (view.getParent() == container) return view.getTop(); | ||
else return view.getTop() + getRelativeTop((View) view.getParent(), container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.progresshint" | ||
> | ||
package="com.example.progresshint"> | ||
|
||
<application | ||
android:name=".App" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" | ||
> | ||
android:name=".App" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" | ||
> | ||
android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".ScrollActivity"/> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package com.example.progresshint; | ||
|
||
import android.app.Application; | ||
import com.squareup.leakcanary.LeakCanary; | ||
|
||
public class App extends Application { | ||
|
||
@Override public void onCreate() { | ||
super.onCreate(); | ||
LeakCanary.install(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
sample/src/main/java/com/example/progresshint/ScrollActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.example.progresshint; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import io.techery.progresshint.addition.ProgressHintScrollController; | ||
import io.techery.progresshint.addition.widget.SeekBar; | ||
import io.techery.progresshint.addition.widget.VerticalSeekBar; | ||
|
||
public class ScrollActivity extends AppCompatActivity { | ||
|
||
@BindView(R.id.scroll_container) View scrollView; | ||
@BindView(R.id.seekbar1) SeekBar seekBar1; | ||
@BindView(R.id.seekbar2) VerticalSeekBar seekBar2; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_scroll); | ||
ButterKnife.bind(this); | ||
|
||
seekBar1.setProgress(10); | ||
seekBar2.setProgress(20); | ||
|
||
ProgressHintScrollController.register(scrollView, seekBar1); | ||
ProgressHintScrollController.register(scrollView, seekBar2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
> | ||
|
||
<View | ||
android:layout_width="wrap_content" | ||
android:layout_height="200dp" | ||
android:background="#58961e" | ||
/> | ||
|
||
<ScrollView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/scroll_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
> | ||
|
||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
> | ||
|
||
<View | ||
android:layout_width="wrap_content" | ||
android:layout_height="200dp" | ||
android:background="#1e3e96" | ||
/> | ||
|
||
<io.techery.progresshint.addition.widget.SeekBar | ||
android:id="@+id/seekbar1" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:popupAlwaysShown="true" | ||
app:popupStyle="follow" | ||
/> | ||
|
||
<View | ||
android:layout_width="wrap_content" | ||
android:layout_height="200dp" | ||
android:background="#961e8e" | ||
/> | ||
|
||
<com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper | ||
android:layout_width="wrap_content" | ||
android:layout_height="100dp" | ||
android:layout_gravity="left" | ||
app:layout_marginBottomPercent="10%" | ||
app:layout_marginLeftPercent="30%" | ||
app:layout_marginTopPercent="10%" | ||
> | ||
|
||
<io.techery.progresshint.addition.widget.VerticalSeekBar | ||
android:id="@+id/seekbar2" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:splitTrack="false" | ||
app:popupAlwaysShown="true" | ||
app:popupStyle="fixed" | ||
app:seekBarRotation="CW90" | ||
/> | ||
<!-- Rotation: CW90 or CW270 --> | ||
</com.h6ah4i.android.widget.verticalseekbar.VerticalSeekBarWrapper> | ||
|
||
<View | ||
android:layout_width="wrap_content" | ||
android:layout_height="500dp" | ||
android:background="#ba3720" | ||
/> | ||
|
||
</LinearLayout> | ||
</ScrollView> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters