Skip to content

Commit

Permalink
Fixed the NPE on ForegroundLinearLayout and improved the hotspot on f…
Browse files Browse the repository at this point in the history
…oreground.

Check also: 61ffadb
  • Loading branch information
gabrielemariotti committed Nov 12, 2014
1 parent fa02d62 commit f5b5e4d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -202,6 +204,15 @@ protected void initAttrs(AttributeSet attrs, int defStyle) {
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void drawableHotspotChanged(float x, float y) {
super.drawableHotspotChanged(x, y);
if (mInternalMainCardLayout != null && mInternalMainCardLayout instanceof ForegroundLinearLayout) {
mInternalMainCardLayout.drawableHotspotChanged(x,y);
}
}

//--------------------------------------------------------------------------
// Card
//--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -290,6 +291,15 @@ protected void initView() {

}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void drawableHotspotChanged(float x, float y) {
super.drawableHotspotChanged(x, y);
if (mInternalMainCardLayout != null && mInternalMainCardLayout instanceof ForegroundLinearLayout) {
mInternalMainCardLayout.drawableHotspotChanged(x,y);
}
}

//--------------------------------------------------------------------------
// Card
//--------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import android.os.Build;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.LinearLayout;

import it.gmariotti.cardslib.library.R;
Expand Down Expand Up @@ -224,15 +223,15 @@ public void draw(Canvas canvas) {
}
}


@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onTouchEvent(MotionEvent e) {
public void drawableHotspotChanged(float x, float y) {
super.drawableHotspotChanged(x, y);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (e.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (mForeground != null)
mForeground.setHotspot(e.getX(), e.getY());
if (mForeground != null) {
mForeground.setHotspot(x, y);
}
}
return super.onTouchEvent(e);
}
}

0 comments on commit f5b5e4d

Please sign in to comment.