This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Preferred Languages fixes * Fix last item not being refreshed after and addition
- Loading branch information
1 parent
2ccdfe4
commit 0bf3cb7
Showing
27 changed files
with
331 additions
and
176 deletions.
There are no files selected for viewing
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
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
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
91 changes: 91 additions & 0 deletions
91
app/src/common/shared/org/mozilla/vrbrowser/ui/views/FadingFrameLayout.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,91 @@ | ||
package org.mozilla.vrbrowser.ui.views; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Color; | ||
import android.graphics.LinearGradient; | ||
import android.graphics.Paint; | ||
import android.graphics.PorterDuff; | ||
import android.graphics.PorterDuffXfermode; | ||
import android.graphics.Rect; | ||
import android.graphics.Shader; | ||
import android.util.AttributeSet; | ||
import android.widget.FrameLayout; | ||
|
||
public class FadingFrameLayout extends FrameLayout { | ||
|
||
private static final int[] FADE_COLORS_REVERSE = new int[]{Color.BLACK, Color.TRANSPARENT}; | ||
|
||
private Paint mPaint; | ||
private Rect mRect; | ||
private boolean mDirty; | ||
|
||
public FadingFrameLayout(Context context) { | ||
super(context); | ||
init(); | ||
} | ||
|
||
public FadingFrameLayout(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
init(); | ||
} | ||
|
||
public FadingFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
PorterDuffXfermode mode = new PorterDuffXfermode(PorterDuff.Mode.DST_IN); | ||
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); | ||
mPaint.setXfermode(mode); | ||
|
||
mRect = new Rect(); | ||
} | ||
|
||
@Override | ||
public void setPadding(int left, int top, int right, int bottom) { | ||
if (getPaddingRight() != right) { | ||
mDirty = true; | ||
} | ||
super.setPadding(left, top, right, bottom); | ||
} | ||
|
||
@Override | ||
protected void onSizeChanged(int w, int h, int oldw, int oldh) { | ||
super.onSizeChanged(w, h, oldw, oldh); | ||
if (w != oldw) { | ||
mDirty = true; | ||
} | ||
} | ||
|
||
@Override | ||
protected void dispatchDraw(Canvas canvas) { | ||
int newWidth = getWidth(), newHeight = getHeight(); | ||
if (getVisibility() == GONE || newWidth == 0 || newHeight == 0) { | ||
super.dispatchDraw(canvas); | ||
return; | ||
} | ||
|
||
if (mDirty) { | ||
int actualWidth = getWidth() - getPaddingLeft() - getPaddingRight(); | ||
int size = Math.min(getHorizontalFadingEdgeLength(), actualWidth); | ||
int l = getPaddingLeft() + actualWidth - size; | ||
int t = getPaddingTop(); | ||
int r = l + size; | ||
int b = getHeight() - getPaddingBottom(); | ||
mRect.set(l, t, r, b); | ||
LinearGradient gradient = new LinearGradient(l, t, r, t, FADE_COLORS_REVERSE, null, Shader.TileMode.CLAMP); | ||
mPaint.setShader(gradient); | ||
} | ||
|
||
int count = canvas.saveLayer(0.0f, 0.0f, (float) getWidth(), (float) getHeight(), null, Canvas.ALL_SAVE_FLAG); | ||
super.dispatchDraw(canvas); | ||
|
||
if (isHorizontalFadingEdgeEnabled() && getHorizontalFadingEdgeLength() > 0) { | ||
canvas.drawRect(mRect, mPaint); | ||
} | ||
canvas.restoreToCount(count); | ||
} | ||
|
||
} |
Oops, something went wrong.