Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}
Expand Down
7 changes: 3 additions & 4 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ apply plugin: 'com.android.application'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.prolificinteractive'
android {
compileSdkVersion 27
buildToolsVersion "23.0.3"
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName version
}
Expand All @@ -21,5 +20,5 @@ android {
dependencies {
implementation project(':parallaxpager')
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

import com.prolificinteractive.parallaxpager.ParallaxContextWrapper;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.prolificinteractive.parallaxproject;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Wed Nov 27 15:02:51 CET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
7 changes: 3 additions & 4 deletions parallaxpager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.prolificinteractive'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
targetSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName version
}
}

dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.prolificinteractive.parallaxpager;

import android.content.Context;
import android.support.v4.view.ViewPager;

import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -124,9 +126,9 @@ private void addParallaxView(View view, int pageIndex) {
}

/**
* <b>NOTE:</b> this is exposed for use with existing code which requires a {@linkplain android.support.v4.view.ViewPager} instance.
* Please make sure that if you call methods like {@linkplain android.support.v4.view.ViewPager#setAdapter(android.support.v4.view.PagerAdapter) setAdapter()}
* or {@linkplain android.support.v4.view.ViewPager#setOnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener) setOnPageChangeListener()}
* <b>NOTE:</b> this is exposed for use with existing code which requires a {@linkplain ViewPager} instance.
* Please make sure that if you call methods like {@linkplain ViewPager#setAdapter(PagerAdapter) setAdapter()}
* or {@linkplain ViewPager#setOnPageChangeListener(ViewPager.OnPageChangeListener) setOnPageChangeListener()}
* on the instance returned, that you do so with forethought and good reason.
*
* @return the internal ViewPager, null before {@linkplain #setupChildren(int...) setupChildren()} is called
Expand All @@ -137,7 +139,7 @@ public ViewPager getViewPager() {

/**
* Set a listener to recieve page change events
* @see android.support.v4.view.ViewPager#setOnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener)
* @see ViewPager#setOnPageChangeListener(ViewPager.OnPageChangeListener)
* @param pageChangeListener the listener, or null to clear
*/
public void setOnPageChangeListener(ViewPager.OnPageChangeListener pageChangeListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import androidx.core.os.BuildCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -23,6 +24,8 @@ class ParallaxLayoutInflater extends LayoutInflater {
"android.webkit."
};

private boolean IS_AT_LEAST_Q = Build.VERSION.SDK_INT > Build.VERSION_CODES.P || BuildCompat.isAtLeastP();

private final ParallaxFactory mParallaxFactory;
// Reflection Hax
private boolean mSetPrivateFactory = false;
Expand Down Expand Up @@ -175,21 +178,28 @@ private View createCustomViewInternal(View parent, View view, String name, Conte

// If CustomViewCreation is off skip this.
if (view == null && name.indexOf('.') > -1) {
if (mConstructorArgs == null) {
mConstructorArgs = ReflectionUtils.getField(LayoutInflater.class, "mConstructorArgs");
}

final Object[] mConstructorArgsArr =
(Object[]) ReflectionUtils.getValue(mConstructorArgs, this);
final Object lastContext = mConstructorArgsArr[0];
mConstructorArgsArr[0] = parent != null ? parent.getContext() : context;
ReflectionUtils.setValue(mConstructorArgs, this, mConstructorArgsArr);
try {
view = createView(name, null, attrs);
} catch (ClassNotFoundException ignored) {
} finally {
mConstructorArgsArr[0] = lastContext;
if (IS_AT_LEAST_Q) {
try {
view = cloneInContext(context).createView(name, null, attrs);
} catch (ClassNotFoundException ignored) {
}
} else {
if (mConstructorArgs == null) {
mConstructorArgs = ReflectionUtils.getField(LayoutInflater.class, "mConstructorArgs");
}

final Object[] mConstructorArgsArr =
(Object[]) ReflectionUtils.getValue(mConstructorArgs, this);
final Object lastContext = mConstructorArgsArr[0];
mConstructorArgsArr[0] = parent != null ? parent.getContext() : context;
ReflectionUtils.setValue(mConstructorArgs, this, mConstructorArgsArr);
try {
view = createView(name, null, attrs);
} catch (ClassNotFoundException ignored) {
} finally {
mConstructorArgsArr[0] = lastContext;
ReflectionUtils.setValue(mConstructorArgs, this, mConstructorArgsArr);
}
}
}
return view;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.prolificinteractive.parallaxpager;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.LinkedList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.prolificinteractive.parallaxpager;

import android.util.Log;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import static android.content.ContentValues.TAG;

/**
* Created by chris on 17/12/14.
* For Calligraphy.
Expand All @@ -22,6 +26,8 @@ static Field getField(Class clazz, String fieldName) {

static Object getValue(Field field, Object obj) {
try {
Log.d(TAG, "getValue: field: "+field.toString());
Log.d(TAG, "getValue: obj: "+obj.toString());
return field.get(obj);
} catch (IllegalAccessException ignored) {
}
Expand Down