-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from eveliotc/fix-ripples
Fix ripples hotspot and some refactoring
- Loading branch information
Showing
10 changed files
with
239 additions
and
196 deletions.
There are no files selected for viewing
134 changes: 134 additions & 0 deletions
134
wally/src/main/java/com/musenkishi/wally/views/OverlayLinearLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* Copyright (C) 2014 Evelio Tarazona Caceres | ||
* Copyright (C) 2014 Freddie (Musenkishi) Lust-Hed | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.musenkishi.wally.views; | ||
|
||
import android.annotation.TargetApi; | ||
import android.content.Context; | ||
import android.content.res.TypedArray; | ||
import android.graphics.Canvas; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Build; | ||
import android.util.AttributeSet; | ||
import android.widget.LinearLayout; | ||
|
||
import com.musenkishi.wally.R; | ||
|
||
import static android.os.Build.VERSION_CODES.LOLLIPOP; | ||
|
||
/** | ||
* {@link android.widget.LinearLayout} but with foreground/overlay drawable capability | ||
*/ | ||
public class OverlayLinearLayout extends LinearLayout { | ||
private Drawable mOverlayDrawable; | ||
|
||
public OverlayLinearLayout(Context context) { | ||
super(context); | ||
initSelf(context, null, 0, 0); | ||
} | ||
|
||
public OverlayLinearLayout(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
initSelf(context, attrs, 0, 0); | ||
} | ||
|
||
public OverlayLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
initSelf(context, attrs, defStyleAttr, 0); | ||
} | ||
|
||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
public OverlayLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
super(context, attrs, defStyleAttr, defStyleRes); | ||
initSelf(context, attrs, defStyleAttr, defStyleRes); | ||
} | ||
|
||
private void initSelf(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
if (attrs != null) { | ||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.OverlayLinearLayout); | ||
setOverlayDrawable(a.getDrawable(R.styleable.OverlayLinearLayout_overlay)); | ||
a.recycle(); | ||
} | ||
} | ||
|
||
@Override | ||
public void draw(Canvas canvas) { | ||
super.draw(canvas); | ||
|
||
if (mOverlayDrawable != null) { | ||
mOverlayDrawable.draw(canvas); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onSizeChanged(int w, int h, int oldw, int oldh) { | ||
super.onSizeChanged(w, h, oldw, oldh); | ||
|
||
if (mOverlayDrawable != null) { | ||
mOverlayDrawable.setBounds(0, 0, w, h); | ||
} | ||
} | ||
|
||
@Override | ||
protected void drawableStateChanged() { | ||
super.drawableStateChanged(); | ||
|
||
Drawable d = mOverlayDrawable; | ||
if (d != null && d.isStateful()) { | ||
d.setState(getDrawableState()); | ||
} | ||
} | ||
|
||
@Override | ||
protected boolean verifyDrawable(Drawable who) { | ||
return super.verifyDrawable(who) || (who == mOverlayDrawable); | ||
} | ||
|
||
@Override | ||
public void jumpDrawablesToCurrentState() { | ||
super.jumpDrawablesToCurrentState(); | ||
if (mOverlayDrawable != null) { | ||
mOverlayDrawable.jumpToCurrentState(); | ||
} | ||
} | ||
|
||
@Override | ||
@TargetApi(LOLLIPOP) | ||
public void drawableHotspotChanged(float x, float y) { | ||
super.drawableHotspotChanged(x, y); | ||
if (mOverlayDrawable != null) { | ||
mOverlayDrawable.setHotspot(x, y); | ||
} | ||
} | ||
|
||
private void setOverlayDrawable(Drawable overlayDrawable) { | ||
if (mOverlayDrawable != null) { | ||
mOverlayDrawable.setCallback(null); | ||
unscheduleDrawable(mOverlayDrawable); | ||
} | ||
mOverlayDrawable = overlayDrawable; | ||
if (mOverlayDrawable != null) { | ||
setWillNotDraw(false); | ||
mOverlayDrawable.setCallback(this); | ||
if (mOverlayDrawable.isStateful()) { | ||
mOverlayDrawable.setState(getDrawableState()); | ||
} | ||
} else { | ||
setWillNotDraw(true); | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
wally/src/main/res/layout-v21/view_cell_thumb_tile_saved.xml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.