Skip to content

Commit

Permalink
ScrollView bug when the scroll listener is not called
Browse files Browse the repository at this point in the history
  • Loading branch information
boxme committed Jun 4, 2015
1 parent 7dd370b commit 3fe677e
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 32 deletions.
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ android {
}
}

repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
mavenLocal()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/res/layout/fragment_first_scroll_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,6 @@

<include layout="@layout/header_placeholder"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="@string/long_text"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="@string/short_text"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="@string/long_text"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="@string/long_text"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:text="@string/long_text"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'

classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
78 changes: 78 additions & 0 deletions parallaxviewpager/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

version = "1.0.0"
group = "com.github.boxme"

def siteUrl = 'https://github.com/boxme/ParallaxHeaderViewPager'
def gitUrl = 'https://github.com/boxme/ParallaxHeaderViewPager.git'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
resourcePrefix "parallaxviewpager__"

defaultConfig {
minSdkVersion 11
Expand All @@ -18,9 +27,78 @@ android {
}
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = "maven"
name = "ParallaxViewPager"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["MIT"]
publish = true
}
}

install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name 'Scrollable fragments within a viewpager that allows for parallax image and sticky bar effects '
url siteUrl
licenses {
license {
name 'The MIT License'
url 'https://github.com/boxme/AsyncManager/blob/master/LICENSE'
}
}
developers {
developer {
id 'boxme'
name 'Desmond Ng'
email 'desmond.ng.yang.yi@gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl

}
}
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ScrollView;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ScrollView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import android.support.v4.util.SparseArrayCompat;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;

/**
* Created by desmond on 1/6/15.
*/
public class ParallaxViewPagerChangeListener implements ViewPager.OnPageChangeListener {

public static final String TAG = ParallaxViewPagerChangeListener.class.getSimpleName();

protected ViewPager mViewPager;
protected ParallaxFragmentPagerAdapter mAdapter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.desmond.parallaxviewpager;

import android.util.Log;
import android.widget.ScrollView;

/**
* Created by desmond on 1/6/15.
*/
public class ScrollViewFragment extends ScrollTabHolderFragment {

public static final String TAG = ScrollViewFragment.class.getSimpleName();

protected static final int NO_SCROLL_X = 0;

protected NotifyingScrollView mScrollView;
Expand All @@ -16,6 +19,7 @@ protected void setScrollViewOnScrollListener() {
@Override
public void onScrollChanged(ScrollView view, int l, int t, int oldl, int oldt) {

Log.d(TAG, "position " + mPosition);
if (mScrollTabHolder != null) {
mScrollTabHolder.onScrollViewScroll(view, l, t, oldl, oldt, mPosition);
}
Expand All @@ -28,5 +32,9 @@ public void adjustScroll(int scrollHeight, int headerHeight) {
if (mScrollView == null) return;

mScrollView.scrollTo(NO_SCROLL_X, headerHeight - scrollHeight);

if (mScrollTabHolder != null) {
mScrollTabHolder.onScrollViewScroll(mScrollView, 0, 0, 0, 0, mPosition);
}
}
}

0 comments on commit 3fe677e

Please sign in to comment.