Skip to content

Commit

Permalink
v1.9 demo updated
Browse files Browse the repository at this point in the history
  • Loading branch information
woxingxiao committed Feb 22, 2017
1 parent 02802a3 commit f271a75
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 60 deletions.
Binary file modified apk/sample.apk
Binary file not shown.
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.xw.samlpe.bubbleseekbar"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
targetSdkVersion 25
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand All @@ -34,8 +34,8 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
compile project(':bubbleseekbar')
}
24 changes: 23 additions & 1 deletion app/src/main/java/com/xw/samlpe/bubbleseekbar/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
public class MainActivity extends AppCompatActivity {

BubbleSeekBar mBubbleSeekBar0;
BubbleSeekBar mBubbleSeekBar1;
BubbleSeekBar mBubbleSeekBar2;
BubbleSeekBar mBubbleSeekBar3;
BubbleSeekBar mBubbleSeekBar4;
BubbleSeekBar mBubbleSeekBar5;
BubbleSeekBar mBubbleSeekBar6;
BubbleSeekBar mBubbleSeekBar8;
BubbleSeekBar mBubbleSeekBar9;
TextView mProgressText;
ObservableScrollView mObsScrollView;

Expand All @@ -33,17 +39,25 @@ protected void onCreate(Bundle savedInstanceState) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
mBubbleSeekBar0 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_0);
mBubbleSeekBar1 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_1);
mBubbleSeekBar2 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_2);
mBubbleSeekBar3 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_3);
mBubbleSeekBar4 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_4);
mBubbleSeekBar5 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_5);
mBubbleSeekBar6 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_6);
mBubbleSeekBar8 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_8);
mBubbleSeekBar9 = (BubbleSeekBar) findViewById(R.id.bubble_seek_bar_9);
mProgressText = (TextView) findViewById(R.id.progress_text);
mObsScrollView = (ObservableScrollView) findViewById(R.id.scroll_view);
mObsScrollView = (ObservableScrollView) findViewById(R.id.content_main);

setSupportActionBar(toolbar);

assert fab != null;
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mObsScrollView.smoothScrollTo(0, 0);

int progress = new Random().nextInt(100);
mBubbleSeekBar0.setProgress(progress);
Snackbar.make(view, "set random progress = " + progress, Snackbar.LENGTH_SHORT).show();
Expand Down Expand Up @@ -77,7 +91,15 @@ public void onProgressChanged(float progress) {
@Override
public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {
// 调用修正偏移方法
mBubbleSeekBar0.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar1.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar2.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar3.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar4.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar5.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar6.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar8.correctOffsetWhenContainerOnScrolling();
mBubbleSeekBar9.correctOffsetWhenContainerOnScrolling();
}
});

Expand Down
139 changes: 87 additions & 52 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
<com.xw.samlpe.bubbleseekbar.ObservableScrollView
android:id="@+id/content_main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand Down Expand Up @@ -104,59 +104,94 @@
android:text="@string/tips"
android:textSize="12sp"/>

<com.xw.samlpe.bubbleseekbar.ObservableScrollView
android:id="@+id/scroll_view"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="112dp"
android:background="@color/color_red_light">
android:layout_height="wrap_content"
android:background="@color/color_red_light"
android:orientation="vertical"
android:paddingBottom="8dp">

<LinearLayout
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="@string/fixed"
android:textSize="12sp"/>

<com.xw.repo.BubbleSeekBar
android:id="@+id/bubble_seek_bar_6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="10"
app:bsb_min="0"
app:bsb_progress="5"
app:bsb_second_track_color="@color/color_blue"
app:bsb_track_color="@color/colorPrimary"
app:bsb_track_size="4dp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="8dp"
android:gravity="bottom"
android:text="@string/fixed"
android:textSize="12sp"/>

<com.xw.repo.BubbleSeekBar
android:id="@+id/bubble_seek_bar_6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="10"
app:bsb_min="0"
app:bsb_progress="5"
app:bsb_second_track_color="@color/color_blue"
app:bsb_track_color="@color/colorPrimary"
app:bsb_track_size="4dp"/>

<TextView
android:layout_width="match_parent"
android:layout_height="32dp"
android:layout_marginLeft="8dp"
android:gravity="bottom"
android:text="@string/not_fix"
android:textSize="12sp"/>

<com.xw.repo.BubbleSeekBar
android:id="@+id/bubble_seek_bar_7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="10"
app:bsb_min="0"
app:bsb_progress="5"
app:bsb_second_track_color="@color/color_blue"
app:bsb_track_color="@color/colorPrimary"
app:bsb_track_size="4dp"/>

<Space
android:layout_width="match_parent"
android:layout_height="32dp"/>
</LinearLayout>
</com.xw.samlpe.bubbleseekbar.ObservableScrollView>
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="@string/not_fix"
android:textSize="12sp"/>

<com.xw.repo.BubbleSeekBar
android:id="@+id/bubble_seek_bar_7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsb_max="10"
app:bsb_min="0"
app:bsb_progress="5"
app:bsb_second_track_color="@color/color_blue"
app:bsb_track_color="@color/colorPrimary"
app:bsb_track_size="4dp"/>
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/touch_to_seek"
android:textSize="12sp"/>

<com.xw.repo.BubbleSeekBar
android:id="@+id/bubble_seek_bar_8"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_marginTop="8dp"
app:bsb_touch_to_seek="true"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/touch_to_seek_auto_adjust"
android:textSize="12sp"/>

<com.xw.repo.BubbleSeekBar
android:id="@+id/bubble_seek_bar_9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:bsb_auto_adjust_section_mark="true"
app:bsb_second_track_color="@color/color_blue"
app:bsb_section_count="5"
app:bsb_show_progress_in_float="true"
app:bsb_show_section_mark="true"
app:bsb_show_text="true"
app:bsb_show_thumb_text="true"
app:bsb_text_position="bottom"
app:bsb_thumb_text_color="@color/colorPrimary"
app:bsb_thumb_text_size="18sp"
app:bsb_touch_to_seek="true"/>

<Space
android:layout_width="match_parent"
android:layout_height="60dp"/>
</LinearLayout>
</ScrollView>
</com.xw.samlpe.bubbleseekbar.ObservableScrollView>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<string name="tips">下面演示BubbleSeekBar嵌套在可滑动的容器中时,监听滑动修正Bubble的位置偏移。(上下滑动,观察Bubble位置)</string>
<string name="fixed">已修正</string>
<string name="not_fix">未修正</string>
<string name="touch_to_seek">touch track to seek</string>
<string name="touch_to_seek_auto_adjust">touch track to seek and auto adjust</string>
</resources>
File renamed without changes
Binary file added screenshot/demo2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f271a75

Please sign in to comment.