Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException(mAnimationFactory) Bug Fix #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 @@ -8,7 +8,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.2.3'
// This does not break the build when Android Studio is missing the JRebel for Android plugin.
classpath 'com.zeroturnaround.jrebel.android:jr-android-gradle:0.8.+'

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed Feb 22 18:36:29 KST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ protected void onDraw(Canvas canvas) {
final int width = getMeasuredWidth();
final int height = getMeasuredHeight();

// don't bother drawing if there is nothing to draw on
if(width <= 0 || height <= 0) return;
// don't bother drawing if there is nothing to draw on
if (width <= 0 || height <= 0) return;

// build a new canvas if needed i.e first pass or new dimensions
if (mBitmap == null || mCanvas == null || mOldHeight != height || mOldWidth != width) {
Expand Down Expand Up @@ -207,8 +207,8 @@ public boolean onTouch(View v, MotionEvent event) {
if (mDismissOnTouch) {
hide();
}
if(mTargetTouchable && mTarget.getBounds().contains((int)event.getX(), (int)event.getY())){
if(mDismissOnTargetTouch){
if (mTargetTouchable && mTarget.getBounds().contains((int) event.getX(), (int) event.getY())) {
if (mDismissOnTargetTouch) {
hide();
}
return false;
Expand All @@ -219,11 +219,11 @@ public boolean onTouch(View v, MotionEvent event) {

private void notifyOnDisplayed() {

if(mListeners != null){
for (IShowcaseListener listener : mListeners) {
listener.onShowcaseDisplayed(this);
}
}
if (mListeners != null) {
for (IShowcaseListener listener : mListeners) {
listener.onShowcaseDisplayed(this);
}
}
}

private void notifyOnDismissed() {
Expand Down Expand Up @@ -337,8 +337,7 @@ private void applyLayoutParams() {
/**
* Only apply the layout params if we've actually changed them, otherwise we'll get stuck in a layout loop
*/
if (layoutParamsChanged)
mContentBox.setLayoutParams(contentLP);
if (layoutParamsChanged) mContentBox.setLayoutParams(contentLP);
}
}

Expand Down Expand Up @@ -418,25 +417,24 @@ private void setFadeDuration(long fadeDurationInMillis) {
mFadeDurationInMillis = fadeDurationInMillis;
}

private void setTargetTouchable(boolean targetTouchable){
private void setTargetTouchable(boolean targetTouchable) {
mTargetTouchable = targetTouchable;
}

private void setDismissOnTargetTouch(boolean dismissOnTargetTouch){
private void setDismissOnTargetTouch(boolean dismissOnTargetTouch) {
mDismissOnTargetTouch = dismissOnTargetTouch;
}

public void addShowcaseListener(IShowcaseListener showcaseListener) {

if(mListeners != null)
mListeners.add(showcaseListener);
if (mListeners != null) mListeners.add(showcaseListener);
}

public void removeShowcaseListener(MaterialShowcaseSequence showcaseListener) {

if ((mListeners != null) && mListeners.contains(showcaseListener)) {
mListeners.remove(showcaseListener);
}
if ((mListeners != null) && mListeners.contains(showcaseListener)) {
mListeners.remove(showcaseListener);
}
}

void setDetachedListener(IDetachedListener detachedListener) {
Expand Down Expand Up @@ -564,20 +562,20 @@ public Builder setTitleText(CharSequence text) {

/**
* Set whether or not the target view can be touched while the showcase is visible.
*
* <p>
* False by default.
*/
public Builder setTargetTouchable(boolean targetTouchable){
public Builder setTargetTouchable(boolean targetTouchable) {
showcaseView.setTargetTouchable(targetTouchable);
return this;
}

/**
* Set whether or not the showcase should dismiss when the target is touched.
*
* <p>
* True by default.
*/
public Builder setDismissOnTargetTouch(boolean dismissOnTargetTouch){
public Builder setDismissOnTargetTouch(boolean dismissOnTargetTouch) {
showcaseView.setDismissOnTargetTouch(dismissOnTargetTouch);
return this;
}
Expand Down Expand Up @@ -716,8 +714,7 @@ public void removeFromWindow() {
getViewTreeObserver().removeGlobalOnLayoutListener(mLayoutListener);
mLayoutListener = null;

if (mPrefsManager != null)
mPrefsManager.close();
if (mPrefsManager != null) mPrefsManager.close();

mPrefsManager = null;

Expand Down Expand Up @@ -783,28 +780,35 @@ public void hide() {
}

public void fadeIn() {
setVisibility(INVISIBLE);
if (mAnimationFactory == null) {
setVisibility(View.VISIBLE);
notifyOnDisplayed();
} else {
setVisibility(INVISIBLE);

mAnimationFactory.fadeInView(this, mFadeDurationInMillis,
new IAnimationFactory.AnimationStartListener() {
@Override
public void onAnimationStart() {
setVisibility(View.VISIBLE);
notifyOnDisplayed();
}
mAnimationFactory.fadeInView(this, mFadeDurationInMillis, new IAnimationFactory.AnimationStartListener() {
@Override
public void onAnimationStart() {
setVisibility(View.VISIBLE);
notifyOnDisplayed();
}
);
});
}
}

public void fadeOut() {

mAnimationFactory.fadeOutView(this, mFadeDurationInMillis, new IAnimationFactory.AnimationEndListener() {
@Override
public void onAnimationEnd() {
setVisibility(INVISIBLE);
removeFromWindow();
}
});
if (mAnimationFactory == null) {
setVisibility(INVISIBLE);
removeFromWindow();
} else {
mAnimationFactory.fadeOutView(this, mFadeDurationInMillis, new IAnimationFactory.AnimationEndListener() {
@Override
public void onAnimationEnd() {
setVisibility(INVISIBLE);
removeFromWindow();
}
});
}
}

public void resetSingleUse() {
Expand Down Expand Up @@ -838,10 +842,8 @@ public static int getSoftButtonsBarSizePort(Activity activity) {
int usableHeight = metrics.heightPixels;
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight)
return realHeight - usableHeight;
else
return 0;
if (realHeight > usableHeight) return realHeight - usableHeight;
else return 0;
}
return 0;
}
Expand Down
13 changes: 11 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
apply plugin: 'com.android.application'
// This does not break the build when Android Studio is missing the JRebel for Android plugin.
apply plugin: 'com.zeroturnaround.jrebel.android'

android {
compileSdkVersion 23
Expand All @@ -19,6 +17,17 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}


applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = outputFile.name.replace('.apk', "-${versionName}.apk")
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}

dependencies {
Expand Down