code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
public boolean getAutoDismiss()
{
return mAutoDismiss;
}
|
Get whether the prompt should dismiss itself when a touch event occurs outside the focal.
@return True - prompt will dismiss when touched outside the focal, false - no
action taken.
|
getAutoDismiss
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setAutoFinish(final boolean autoFinish)
{
mAutoFinish = autoFinish;
return (T) this;
}
|
Set whether the prompt should finish itself when a touch event occurs inside the focal.
Default is true.
Listen for the {@link MaterialTapTargetPrompt#STATE_FOCAL_PRESSED} event in the
{@link #setPromptStateChangeListener(MaterialTapTargetPrompt.PromptStateChangeListener)} to handle the prompt
target being pressed.
@param autoFinish True - prompt will finish when touched inside the focal, false - no
action taken.
@return This Builder object to allow for chaining of calls to set methods
|
setAutoFinish
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
public boolean getAutoFinish()
{
return mAutoFinish;
}
|
Get if the prompt should finish itself when a touch event occurs inside the focal.
@return True if the prompt should finish itself when a touch event occurs inside the focal.
|
getAutoFinish
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setCaptureTouchEventOutsidePrompt(
final boolean captureTouchEventOutsidePrompt)
{
mCaptureTouchEventOutsidePrompt = captureTouchEventOutsidePrompt;
return (T) this;
}
|
Set if the prompt should stop touch events outside the prompt from passing to underlying
views. Default is false.
@param captureTouchEventOutsidePrompt True to capture touch events out side the prompt
@return This Builder object to allow for chaining of calls to set methods
|
setCaptureTouchEventOutsidePrompt
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
public boolean getCaptureTouchEventOutsidePrompt()
{
return mCaptureTouchEventOutsidePrompt;
}
|
Get if the prompt should stop touch events outside the prompt from passing to underlying views.
@return True if touch events will not be passed to views below the prompt.
|
getCaptureTouchEventOutsidePrompt
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setTextGravity(final int gravity)
{
mPrimaryTextGravity = gravity;
mSecondaryTextGravity = gravity;
return (T) this;
}
|
Set the primary and secondary text horizontal layout gravity.
Default: {@link Gravity#START}
@param gravity The horizontal gravity
@return This Builder object to allow for chaining of calls to set methods
|
setTextGravity
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setPrimaryTextGravity(final int gravity)
{
mPrimaryTextGravity = gravity;
return (T) this;
}
|
Set the primary text horizontal layout gravity.
Default: {@link Gravity#START}
@param gravity The horizontal gravity
@return This Builder object to allow for chaining of calls to set methods
|
setPrimaryTextGravity
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
public int getPrimaryTextGravity()
{
return mPrimaryTextGravity;
}
|
Gets the gravity for the primary text.
@return The primary texts gravity.
|
getPrimaryTextGravity
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setSecondaryTextGravity(final int gravity)
{
mSecondaryTextGravity = gravity;
return (T) this;
}
|
Set the secondary text horizontal layout gravity.
Default: {@link Gravity#START}
@param gravity The horizontal gravity
@return This Builder object to allow for chaining of calls to set methods
|
setSecondaryTextGravity
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
public int getSecondaryTextGravity()
{
return mSecondaryTextGravity;
}
|
Gets the gravity for the secondary text.
@return The secondary texts gravity.
|
getSecondaryTextGravity
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setClipToView(@Nullable final View view)
{
mClipToView = view;
return (T) this;
}
|
Set the view to clip the prompt to.
The prompt won't draw outside the bounds of this view.
Default: {@link android.R.id#content}
<p>
Null can be used to stop the prompt being clipped to a view.
@param view The view to clip to
@return This Builder object to allow for chaining of calls to set methods
|
setClipToView
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@Nullable
public View getClipToView()
{
return mClipToView;
}
|
Get the view that the prompt canvas is clipped to.
The prompt won't draw outside the bounds of this view.
@return The view that the prompt canvas is clipped to.
|
getClipToView
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setBackButtonDismissEnabled(final boolean enabled)
{
mBackButtonDismissEnabled = enabled;
return (T) this;
}
|
Back button can be used to dismiss the prompt.
Default: true
@param enabled True for back button dismiss enabled
@return This Builder object to allow for chaining of calls to set methods
|
setBackButtonDismissEnabled
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
public boolean getBackButtonDismissEnabled()
{
return mBackButtonDismissEnabled;
}
|
Will the pressing the system back button dismiss the prompt.
@return True if pressing the system back button will dismiss the prompt, false otherwise.
|
getBackButtonDismissEnabled
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setIgnoreStatusBar(final boolean enabled)
{
mIgnoreStatusBar = enabled;
return (T) this;
}
|
Indicates whether to ignore system status bar. Drawing area will be increased to the top of
screen regardless of status bar if this flag is true (status bar should be transparent to see
any effect from this)
Default: false
@param enabled true for drawing behind system status bar
@return This Builder object to allow for chaining of calls to set methods
|
setIgnoreStatusBar
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
public boolean getIgnoreStatusBar()
{
return mIgnoreStatusBar;
}
|
Get ignore status bar flag
@return true if status bar should be ignored, otherwise false
|
getIgnoreStatusBar
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setPromptBackground(@NonNull final PromptBackground promptBackground)
{
mPromptBackground = promptBackground;
return (T) this;
}
|
Sets the renderer for the prompt background.
@param promptBackground The background shape to use.
@return This Builder object to allow for chaining of calls to set methods
|
setPromptBackground
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setPromptFocal(@NonNull final PromptFocal promptFocal)
{
mPromptFocal = promptFocal;
return (T) this;
}
|
Sets the renderer for the prompt focal.
@param promptFocal The focal shape to use.
@return This Builder object to allow for chaining of calls to set methods
|
setPromptFocal
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public T setPromptText(@NonNull final PromptText promptText)
{
mPromptText = promptText;
return (T) this;
}
|
Set the {@link PromptText} implementation to use to render the prompt text.
@param promptText The prompt text implementation.
@return This Builder object to allow for chaining of calls to set methods
|
setPromptText
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public PromptText getPromptText()
{
return mPromptText;
}
|
Get the {@link PromptText} implementation used to render the prompt text.
@return This Builder object to allow for chaining of calls to set methods
|
getPromptText
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@Nullable
public MaterialTapTargetPrompt create()
{
if (!mTargetSet || (mPrimaryText == null && mSecondaryText == null))
{
return null;
}
final MaterialTapTargetPrompt mPrompt = MaterialTapTargetPrompt.createDefault(this);
if (mAnimationInterpolator == null)
{
mAnimationInterpolator = new AccelerateDecelerateInterpolator();
}
if (mIconDrawable != null)
{
mIconDrawable.mutate();
mIconDrawable.setBounds(0, 0, mIconDrawable.getIntrinsicWidth(), mIconDrawable.getIntrinsicHeight());
if (mHasIconDrawableTint)
{
if (mIconDrawableTintList != null)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
mIconDrawable.setTintList(mIconDrawableTintList);
}
}
else
{
mIconDrawable.setColorFilter(mIconDrawableColourFilter, mIconDrawableTintMode);
mIconDrawable.setAlpha(Color.alpha(mIconDrawableColourFilter));
}
}
}
mPromptBackground.setColour(getBackgroundColour());
mPromptFocal.setColour(getFocalColour());
mPromptFocal.setRippleAlpha(150);
mPromptFocal.setDrawRipple(getIdleAnimationEnabled());
if (mPromptFocal instanceof CirclePromptFocal)
{
((CirclePromptFocal) mPromptFocal).setRadius(getFocalRadius());
}
return mPrompt;
}
|
Creates an {@link MaterialTapTargetPrompt} with the arguments supplied to this
builder.
<p>
Calling this method does not display the prompt. If no additional
processing is needed, {@link #show()} may be called instead to both
create and display the prompt.
</p>
<p>
Will return null if a valid target has not been set or the primary text is null.
To check that a valid target has been set call {@link #isTargetSet()}.
</p>
@return The created builder or null if no target
|
create
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@Nullable
public MaterialTapTargetPrompt show()
{
final MaterialTapTargetPrompt mPrompt = create();
if (mPrompt != null)
{
mPrompt.show();
}
return mPrompt;
}
|
Creates a {@link MaterialTapTargetPrompt} with the arguments supplied to this
builder and immediately displays the prompt.
<p>
Calling this method is functionally identical to:
</p>
<pre>
MaterialTapTargetPrompt prompt = builder.create();
prompt.show();
</pre>
<p>
Will return null if a valid target has not been set or the primary text and secondary
text are null.
To check that a valid target has been set call {@link #isTargetSet()}.
</p>
@return The created builder or null if no target
|
show
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@Nullable
public MaterialTapTargetPrompt showFor(final long milliseconds)
{
final MaterialTapTargetPrompt mPrompt = create();
if (mPrompt != null)
{
mPrompt.showFor(milliseconds);
}
return mPrompt;
}
|
Creates a {@link MaterialTapTargetPrompt} with the arguments supplied to this
builder and immediately displays the prompt for the number of milliseconds supplied.
<p>
Calling this method is functionally identical to:
</p>
<pre>
MaterialTapTargetPrompt prompt = builder.create();
prompt.showFor(milliseconds);
</pre>
<p>
Will return null if a valid target has not been set or the primary text and secondary
text are null.
To check that a valid target has been set call {@link #isTargetSet()}.
</p>
@param milliseconds The number of milliseconds to show the prompt for.
@return The created builder or null if no target
|
showFor
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptOptions.java
|
Apache-2.0
|
@NonNull
public RectF getBounds()
{
return mTextBounds;
}
|
Get the window position for the prompt text.
@return The prompt text bounds.
|
getBounds
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java
|
Apache-2.0
|
public void prepare(@NonNull PromptOptions options,
boolean clipToBounds, @NonNull Rect clipBounds)
{
mClipToBounds = clipToBounds;
mClipBounds = clipBounds;
final CharSequence primaryText = options.getPrimaryText();
if (primaryText != null)
{
mPaintPrimaryText = new TextPaint();
@ColorInt final int primaryTextColour = options.getPrimaryTextColour();
mPaintPrimaryText.setColor(primaryTextColour);
mPaintPrimaryText.setAlpha(Color.alpha(primaryTextColour));
mPaintPrimaryText.setAntiAlias(true);
mPaintPrimaryText.setTextSize(options.getPrimaryTextSize());
PromptUtils.setTypeface(mPaintPrimaryText, options.getPrimaryTextTypeface(), options.getPrimaryTextTypefaceStyle());
mPrimaryTextAlignment = PromptUtils.getTextAlignment(options.getResourceFinder().getResources(),
options.getPrimaryTextGravity(), primaryText);
}
final CharSequence secondaryText = options.getSecondaryText();
if (secondaryText != null)
{
mPaintSecondaryText = new TextPaint();
@ColorInt final int secondaryTextColour = options.getSecondaryTextColour();
mPaintSecondaryText.setColor(secondaryTextColour);
mPaintSecondaryText.setAlpha(Color.alpha(secondaryTextColour));
mPaintSecondaryText.setAntiAlias(true);
mPaintSecondaryText.setTextSize(options.getSecondaryTextSize());
PromptUtils.setTypeface(mPaintSecondaryText, options.getSecondaryTextTypeface(),
options.getSecondaryTextTypefaceStyle());
mSecondaryTextAlignment = PromptUtils.getTextAlignment(options.getResourceFinder().getResources(),
options.getSecondaryTextGravity(), secondaryText);
}
final RectF focalBounds = options.getPromptFocal().getBounds();
final float focalCentreX = focalBounds.centerX();
final float focalCentreY = focalBounds.centerY();
final boolean verticalTextPositionAbove = focalCentreY > clipBounds.centerY();
final boolean horizontalTextPositionLeft = focalCentreX > clipBounds.centerX();
final float maxWidth = PromptUtils.calculateMaxWidth(options.getMaxTextWidth(),
clipToBounds ? clipBounds : null,
options.getResourceFinder().getPromptParentView().getWidth(),
options.getTextPadding());
createTextLayout(options, maxWidth, 1);
final float primaryTextWidth = PromptUtils.calculateMaxTextWidth(mPrimaryTextLayout);
final float secondaryTextWidth = PromptUtils.calculateMaxTextWidth(mSecondaryTextLayout);
final float textWidth = Math.max(primaryTextWidth, secondaryTextWidth);
final float focalPadding = options.getFocalPadding();
final float textPadding = options.getTextPadding();
if (PromptUtils.containsInset(clipBounds,
(int) (88 * options.getResourceFinder().getResources().getDisplayMetrics().density),
(int) focalCentreX, (int) focalCentreY))
{
mPrimaryTextLeft = clipBounds.left;
final float width = Math.min(textWidth, maxWidth);
if (horizontalTextPositionLeft)
{
mPrimaryTextLeft = focalCentreX - width + focalPadding;
}
else
{
mPrimaryTextLeft = focalCentreX - width - focalPadding;
}
if (mPrimaryTextLeft < clipBounds.left + textPadding)
{
mPrimaryTextLeft = clipBounds.left + textPadding;
}
if (mPrimaryTextLeft + width > clipBounds.right - textPadding)
{
mPrimaryTextLeft = clipBounds.right - textPadding - width;
}
}
else
{
if (horizontalTextPositionLeft)
{
mPrimaryTextLeft = (clipToBounds ? clipBounds.right :
options.getResourceFinder().getPromptParentView().getRight()) - textPadding - textWidth;
}
else
{
mPrimaryTextLeft = (clipToBounds ? clipBounds.left :
options.getResourceFinder().getPromptParentView().getLeft()) + textPadding;
}
}
if (verticalTextPositionAbove)
{
mPrimaryTextTop = focalBounds.top - focalPadding;
if (mPrimaryTextLayout != null)
{
mPrimaryTextTop -= mPrimaryTextLayout.getHeight();
}
}
else
{
mPrimaryTextTop = focalBounds.bottom + focalPadding;
}
float primaryTextHeight = 0;
if (mPrimaryTextLayout != null)
{
primaryTextHeight = mPrimaryTextLayout.getHeight();
}
float textHeight;
if (mSecondaryTextLayout != null)
{
textHeight = mSecondaryTextLayout.getHeight();
if (verticalTextPositionAbove)
{
mPrimaryTextTop -= textHeight;
if (mPrimaryTextLayout != null)
{
mPrimaryTextTop -= options.getTextSeparation();
}
}
if (mPrimaryTextLayout != null)
{
mSecondaryTextOffsetTop = primaryTextHeight + options.getTextSeparation();
}
textHeight += mSecondaryTextOffsetTop;
}
else
{
textHeight = primaryTextHeight;
}
mSecondaryTextLeft = mPrimaryTextLeft;
mPrimaryTextLeftChange = 0;
mSecondaryTextLeftChange = 0;
final float change = maxWidth - textWidth;
if (PromptUtils.isRtlText(mPrimaryTextLayout, options.getResourceFinder().getResources()))
{
mPrimaryTextLeftChange = change;
}
if (PromptUtils.isRtlText(mSecondaryTextLayout, options.getResourceFinder().getResources()))
{
mSecondaryTextLeftChange = change;
}
mTextBounds.left = mPrimaryTextLeft;// - change;
mTextBounds.top = mPrimaryTextTop;
mTextBounds.right = mTextBounds.left + textWidth;
mTextBounds.bottom = mTextBounds.top + textHeight;
}
|
Recalculates the primary and secondary text positions.
|
prepare
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptText.java
|
Apache-2.0
|
public static boolean isPointInCircle(final float x, final float y,
@NonNull final PointF circleCentre,
final float radius)
{
return Math.pow(x - circleCentre.x, 2) + Math.pow(y - circleCentre.y, 2) < Math.pow(radius, 2);
}
|
Determines if a point is in the centre of a circle with a radius from the point.
@param x The x position in the view.
@param y The y position in the view.
@param circleCentre The circle centre position
@param radius The radius of the circle.
@return True if the point (x, y) is in the circle.
|
isPointInCircle
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
@SuppressLint("RtlHardcoded")
@NonNull
public static Layout.Alignment getTextAlignment(@NonNull final Resources resources,
final int gravity,
@Nullable final CharSequence text)
{
final int absoluteGravity;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
{
int realGravity = gravity;
final int layoutDirection = resources.getConfiguration().getLayoutDirection();
if (text != null && layoutDirection == View.LAYOUT_DIRECTION_RTL
&& new Bidi(text.toString(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft())
{
if (gravity == Gravity.START)
{
realGravity = Gravity.END;
}
else if (gravity == Gravity.END)
{
realGravity = Gravity.START;
}
}
absoluteGravity = Gravity.getAbsoluteGravity(realGravity, layoutDirection);
}
else
{
if ((gravity & Gravity.START) == Gravity.START)
{
absoluteGravity = Gravity.LEFT;
}
else if ((gravity & Gravity.END) == Gravity.END)
{
absoluteGravity = Gravity.RIGHT;
}
else
{
absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
}
}
final Layout.Alignment alignment;
switch (absoluteGravity)
{
case Gravity.RIGHT:
alignment = Layout.Alignment.ALIGN_OPPOSITE;
break;
case Gravity.CENTER_HORIZONTAL:
alignment = Layout.Alignment.ALIGN_CENTER;
break;
default:
alignment = Layout.Alignment.ALIGN_NORMAL;
break;
}
return alignment;
}
|
Gets the absolute text alignment value based on the supplied gravity and the activities
layout direction.
@param gravity The gravity to convert to absolute values
@return absolute layout direction
|
getTextAlignment
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
@NonNull
public static StaticLayout createStaticTextLayout(@NonNull final CharSequence text,
@NonNull final TextPaint paint,
final int maxTextWidth,
@NonNull final Layout.Alignment textAlignment,
final float alphaModifier)
{
final SpannableStringBuilder wrappedText = new SpannableStringBuilder(text);
wrappedText.setSpan(new AlphaSpan(alphaModifier), 0, wrappedText.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
final StaticLayout layout;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
final StaticLayout.Builder builder = StaticLayout.Builder.obtain(wrappedText, 0, text.length(), paint, maxTextWidth);
builder.setAlignment(textAlignment);
layout = builder.build();
}
else
{
layout = new StaticLayout(wrappedText, paint, maxTextWidth, textAlignment, 1f, 0f, false);
}
return layout;
}
|
Creates a static text layout. Uses the {@link android.text.StaticLayout.Builder} if
available.
@param text The text to be laid out, optionally with spans
@param paint The base paint used for layout
@param maxTextWidth The width in pixels
@param textAlignment Alignment for the resulting {@link StaticLayout}
@param alphaModifier The modification to apply to the alpha value between 0 and 1.
@return the newly constructed {@link StaticLayout} object
|
createStaticTextLayout
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
public static void scale(@NonNull final PointF origin, @NonNull final RectF base,
@NonNull final RectF out,
final float scale, final boolean even)
{
if (scale == 1)
{
out.set(base);
return;
}
final float horizontalFromCentre = base.centerX() - base.left;
final float verticalFromCentre = base.centerY() - base.top;
if (even && scale > 1)
{
final float minChange = Math.min(horizontalFromCentre * scale - horizontalFromCentre,
verticalFromCentre * scale - verticalFromCentre);
out.left = base.left - minChange;
out.top = base.top - minChange;
out.right = base.right + minChange;
out.bottom = base.bottom + minChange;
}
else
{
out.left = origin.x - horizontalFromCentre * scale * ((origin.x - base.left) / horizontalFromCentre);
out.top = origin.y - verticalFromCentre * scale * ((origin.y - base.top) / verticalFromCentre);
out.right = origin.x + horizontalFromCentre * scale * ((base.right - origin.x) / horizontalFromCentre);
out.bottom = origin.y + verticalFromCentre * scale * ((base.bottom - origin.y) / verticalFromCentre);
}
}
|
Scales a rectangle.
@param origin The point to scale from.
@param base The rectangle at scale 1.0.
@param out The rectangle to put the scaled size in.
@param scale The amount to scale the rectangle by.
@param even Should the rectangle be scaled evenly in both directions.
|
scale
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
public static boolean isRtlText(@Nullable final Layout layout, @NonNull final Resources resources)
{
boolean result = false;
if (layout != null)
{
// Treat align opposite as right to left by default
result = layout.getAlignment() == Layout.Alignment.ALIGN_OPPOSITE;
// If the first character is a right to left character
final boolean textIsRtl = layout.isRtlCharAt(0);
// If the text and result are right to left then false otherwise use the textIsRtl value
result = (!(result && textIsRtl) && !(!result && !textIsRtl)) || textIsRtl;
if (!result && layout.getAlignment() == Layout.Alignment.ALIGN_NORMAL
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
{
// If the layout and text are right to left and the alignment is normal then rtl
result = resources.getConfiguration()
.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
else if (layout.getAlignment() == Layout.Alignment.ALIGN_OPPOSITE && textIsRtl)
{
result = false;
}
}
return result;
}
|
Determines if the text in the supplied layout is displayed right to left.
@param layout The layout to check.
@return True if the text in the supplied layout is displayed right to left. False otherwise.
|
isRtlText
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
public static float calculateMaxWidth(final float maxTextWidth, @Nullable final Rect clipBounds, final int parentWidth, final float textPadding)
{
return Math.max(80, Math.min(maxTextWidth, (clipBounds != null ? clipBounds.right - clipBounds.left : parentWidth) - (textPadding * 2)));
}
|
Calculates the maximum width that the prompt can be.
@return Maximum width in pixels that the prompt can be.
|
calculateMaxWidth
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
public static float calculateMaxTextWidth(@Nullable final Layout textLayout)
{
float maxTextWidth = 0f;
if (textLayout != null)
{
for (int i = 0, count = textLayout.getLineCount(); i < count; i++)
{
maxTextWidth = Math.max(maxTextWidth, textLayout.getLineWidth(i));
}
}
return maxTextWidth;
}
|
Calculates the maximum width line in a text layout.
@param textLayout The text layout
@return The maximum length line
|
calculateMaxTextWidth
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
public static boolean containsInset(@NonNull final Rect bounds,
final int inset, final int x, final int y)
{
return x > bounds.left + inset
&& x < bounds.right - inset
&& y > bounds.top + inset
&& y < bounds.bottom - inset;
}
|
Determines if a point is within a rectangle that has been inset.
@param bounds The rectangle bounds.
@param inset The amount that the rectangle is inset by.
@param x The point x coordinate.
@param y The point y coordinate.
@return True if the point is within the inset rectangle, false otherwise.
|
containsInset
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/PromptUtils.java
|
Apache-2.0
|
@NonNull
@Override
protected DisplayMetrics getDisplayMetrics() {
Display defaultDisplay = mWindowManager.getDefaultDisplay();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
defaultDisplay.getRealMetrics(mBaseMetrics);
} else {
defaultDisplay.getMetrics(mBaseMetrics);
}
return mBaseMetrics;
}
|
{@link ImmersiveModeCompatPromptBackground} implementation that renders the prompt background as a rectangle for supporting immersive mode.
|
getDisplayMetrics
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/backgrounds/ImmersiveModeCompatPromptBackground.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/backgrounds/ImmersiveModeCompatPromptBackground.java
|
Apache-2.0
|
private float calculateX(final float angle, final float radius, final float centreX)
{
return centreX + radius * (float) Math.cos(Math.toRadians(angle));
}
|
Calculates the x position on a circle for an angle and centre point x.
@param angle The angle on the circle to get the x position for.
@param radius The circle radius.
@param centreX The centre x position for the circle.
@return The calculated x position for the angle.
|
calculateX
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/CirclePromptFocal.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/CirclePromptFocal.java
|
Apache-2.0
|
@NonNull
public RectanglePromptFocal setCornerRadius(final float rx, final float ry)
{
mRx = rx;
mRy = ry;
return this;
}
|
Set the radius for the rectangle corners.
@param rx The x-radius of the oval used to round the corners
@param ry The y-radius of the oval used to round the corners
@return This prompt focal
|
setCornerRadius
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java
|
Apache-2.0
|
@NonNull
public RectanglePromptFocal setTargetPadding(@Dimension final float padding)
{
mPadding = padding;
return this;
}
|
Set the padding between the target bounds and the rectangle edge.
@param padding The distance from the target edge to the rectangle edge.
@return This prompt focal.
|
setTargetPadding
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/focals/RectanglePromptFocal.java
|
Apache-2.0
|
public void addStateChanger(final int state)
{
this.stateChangers.add(state);
}
|
Add a state that will trigger the sequence to move on.
@see MaterialTapTargetPrompt#STATE_REVEALING
@see MaterialTapTargetPrompt#STATE_REVEALED
@see MaterialTapTargetPrompt#STATE_FOCAL_PRESSED
@see MaterialTapTargetPrompt#STATE_FINISHING
@see MaterialTapTargetPrompt#STATE_FINISHED
@see MaterialTapTargetPrompt#STATE_NON_FOCAL_PRESSED
@see MaterialTapTargetPrompt#STATE_DISMISSING
@see MaterialTapTargetPrompt#STATE_DISMISSED
@param state The state that triggers the sequence to move on.
|
addStateChanger
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
Apache-2.0
|
public void removeStateChanger(final int state)
{
this.stateChangers.remove((Integer) state);
}
|
Remove a specific state changer.
@see MaterialTapTargetPrompt#STATE_REVEALING
@see MaterialTapTargetPrompt#STATE_REVEALED
@see MaterialTapTargetPrompt#STATE_FOCAL_PRESSED
@see MaterialTapTargetPrompt#STATE_FINISHING
@see MaterialTapTargetPrompt#STATE_FINISHED
@see MaterialTapTargetPrompt#STATE_NON_FOCAL_PRESSED
@see MaterialTapTargetPrompt#STATE_DISMISSING
@see MaterialTapTargetPrompt#STATE_DISMISSED
@param state The state to remove.
|
removeStateChanger
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
Apache-2.0
|
public void setSequenceListener(@Nullable final MaterialTapTargetSequence.SequenceCompleteListener listener)
{
this.sequenceListener = listener;
}
|
Set the listener for this sequence item completing.
@param listener The item finish listener.
|
setSequenceListener
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
Apache-2.0
|
@NonNull
public SequenceState getState()
{
return this.sequenceState;
}
|
Get the prompt state that this sequence item uses.
@return The prompt state.
|
getState
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
Apache-2.0
|
public void finish()
{
final MaterialTapTargetPrompt prompt = this.sequenceState.getPrompt();
if (prompt != null)
{
prompt.finish();
}
}
|
Calls {@link MaterialTapTargetPrompt#finish()} on this items states prompt.
|
finish
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
Apache-2.0
|
public void dismiss()
{
final MaterialTapTargetPrompt prompt = this.sequenceState.getPrompt();
if (prompt != null)
{
prompt.dismiss();
}
}
|
Calls {@link MaterialTapTargetPrompt#dismiss()} on this items states prompt.
|
dismiss
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItem.java
|
Apache-2.0
|
@Override
protected void show(@NonNull final MaterialTapTargetPrompt prompt)
{
prompt.showFor(milliseconds);
}
|
Constructor.
@param state The prompt that this item will show.
@param milliseconds The number of milliseconds to show the prompt for.
|
show
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItemShowFor.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceItemShowFor.java
|
Apache-2.0
|
@Nullable
public MaterialTapTargetPrompt getPrompt()
{
return this.prompt;
}
|
Get the stored prompt.
@return The prompt.
|
getPrompt
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceState.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceState.java
|
Apache-2.0
|
@Nullable
@Override
public MaterialTapTargetPrompt getPrompt()
{
if (this.prompt == null)
{
this.prompt = this.promptOptions.create();
}
return this.prompt;
}
|
Constructor.
@param promptOptions The builder to create the prompt from.
|
getPrompt
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceStatePromptOptions.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/main/java/uk/co/samuelwall/materialtaptargetprompt/extras/sequence/SequenceStatePromptOptions.java
|
Apache-2.0
|
public static PromptOptions createPromptOptions()
{
return createPromptOptions(false);
}
|
Creates a new {@link PromptOptions} by calling {@link #createPromptOptions(boolean)} with
false as parameter.
@return The created prompt.
|
createPromptOptions
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
Apache-2.0
|
public static PromptOptions createPromptOptions(final boolean mock)
{
final ResourceFinder resourceFinder;
if (mock)
{
resourceFinder = mock(ResourceFinder.class);
final Resources resources = mock(Resources.class);
when(resourceFinder.getResources()).thenReturn(resources);
final DisplayMetrics displayMetrics = new DisplayMetrics();
when(resources.getDisplayMetrics()).thenReturn(displayMetrics);
}
else
{
resourceFinder = new ActivityResourceFinder(Robolectric.buildActivity(Activity.class)
.create().get());
}
return new PromptOptions(resourceFinder);
}
|
Creates a new {@link PromptOptions}.
With mock as false a {@link ActivityResourceFinder} will be used.
With mock as true a mocked {@link ResourceFinder} will be created with the
{@link ResourceFinder#getResources()} method mocked.
@param mock True to mock the {@link ResourceFinder} or use a {@link ActivityResourceFinder}.
@return The created prompt.
|
createPromptOptions
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
Apache-2.0
|
public static PromptOptions createPromptOptionsWithTestResourceFinder()
{
return new PromptOptions(new TestResourceFinder(Robolectric.buildActivity(Activity.class)
.create().get()));
}
|
Creates a new {@link PromptOptions} with {@link TestResourceFinder}.
@return The created options.
|
createPromptOptionsWithTestResourceFinder
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
Apache-2.0
|
public static void initSequenceItem(final MaterialTapTargetPrompt prompt, final SequenceItem item)
{
prompt.mView.mPromptOptions.setSequenceListener(item);
}
|
Calls {@link PromptOptions#setSequenceListener(MaterialTapTargetPrompt.PromptStateChangeListener)}
with the supplied sequence item.
@param prompt The prompt to add the listener to.
@param item The listener to add.
|
initSequenceItem
|
java
|
sjwall/MaterialTapTargetPrompt
|
library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/library/src/test/java/uk/co/samuelwall/materialtaptargetprompt/UnitTestUtils.java
|
Apache-2.0
|
@NotNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Dialog dialog = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.fragment_bottom_sheet, null);
dialog.setContentView(contentView);
dialog.setOnShowListener(dialog1 -> new MaterialTapTargetPrompt.Builder(new DialogResourceFinder(getDialog()), 0)
.setPrimaryText(R.string.search_prompt_title)
.setSecondaryText(R.string.search_prompt_description)
.setAnimationInterpolator(new FastOutSlowInInterpolator())
.setMaxTextWidth(R.dimen.tap_target_menu_max_width)
.setIcon(R.drawable.ic_search)
.setTarget(R.id.bs_search)
.show());
return dialog;
}
|
Example {@link BottomSheetDialogFragment} that shows a prompt when displayed.
|
onCreateDialog
|
java
|
sjwall/MaterialTapTargetPrompt
|
sample/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/BottomSheetDialogFragmentExample.java
|
https://github.com/sjwall/MaterialTapTargetPrompt/blob/master/sample/src/main/java/uk/co/samuelwall/materialtaptargetprompt/sample/BottomSheetDialogFragmentExample.java
|
Apache-2.0
|
private void initLeakCanary() {
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
LeakCanary.install(this);
}
|
use LeakCanary to check mey leak
|
initLeakCanary
|
java
|
ittianyu/BottomNavigationViewEx
|
app/src/main/java/com/ittianyu/bottomnavigationviewexsample/common/base/BaseApplication.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/app/src/main/java/com/ittianyu/bottomnavigationviewexsample/common/base/BaseApplication.java
|
MIT
|
public BottomNavigationViewInner setTextVisibility(boolean visibility) {
this.textVisibility = visibility;
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in mButtons
private BottomNavigationItemView[] mButtons;
3. set text size in mButtons
private final TextView mLargeLabel
private final TextView mSmallLabel
4. change mItemHeight to only icon size in mMenuView
*/
// 1. get mMenuView
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. change field mShiftingMode value in mButtons
for (BottomNavigationItemView button : mButtons) {
TextView mLargeLabel = getField(button.getClass(), button, "largeLabel");
TextView mSmallLabel = getField(button.getClass(), button, "smallLabel");
if (!visibility) {
// if not record the font size, record it
if (!visibilityTextSizeRecord && !animationRecord) {
visibilityTextSizeRecord = true;
mLargeLabelSize = mLargeLabel.getTextSize();
mSmallLabelSize = mSmallLabel.getTextSize();
}
// if not visitable, set font size to 0
mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0);
mSmallLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, 0);
} else {
// if not record the font size, we need do nothing.
if (!visibilityTextSizeRecord)
break;
// restore it
mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLargeLabelSize);
mSmallLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mSmallLabelSize);
}
}
// 4 change mItemHeight to only icon size in mMenuView
if (!visibility) {
// if not record mItemHeight
if (!visibilityHeightRecord) {
visibilityHeightRecord = true;
mItemHeight = getItemHeight();
}
// change mItemHeight to only icon size in mMenuView
// private final int mItemHeight;
// change mItemHeight
// System.out.println("mLargeLabel.getMeasuredHeight():" + getFontHeight(mSmallLabelSize));
setItemHeight(mItemHeight - getFontHeight(mSmallLabelSize));
} else {
// if not record the mItemHeight, we need do nothing.
if (!visibilityHeightRecord)
return this;
// restore mItemHeight
setItemHeight(mItemHeight);
}
mMenuView.updateMenuView();
return this;
}
|
change the visibility of text
@param visibility
|
setTextVisibility
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
private static int getFontHeight(float fontSize) {
Paint paint = new Paint();
paint.setTextSize(fontSize);
Paint.FontMetrics fm = paint.getFontMetrics();
return (int) Math.ceil(fm.descent - fm.top) + 2;
}
|
get text height by font size
@param fontSize
@return
|
getFontHeight
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner enableAnimation(boolean enable) {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in mButtons
private BottomNavigationItemView[] mButtons;
3. chang mShiftAmount to 0 in mButtons
private final int mShiftAmount
change mScaleUpFactor and mScaleDownFactor to 1f in mButtons
private final float mScaleUpFactor
private final float mScaleDownFactor
4. change label font size in mButtons
private final TextView mLargeLabel
private final TextView mSmallLabel
*/
// 1. get mMenuView
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. change field mShiftingMode value in mButtons
for (BottomNavigationItemView button : mButtons) {
TextView mLargeLabel = getField(button.getClass(), button, "largeLabel");
TextView mSmallLabel = getField(button.getClass(), button, "smallLabel");
// if disable animation, need animationRecord the source value
if (!enable) {
if (!animationRecord) {
animationRecord = true;
mShiftAmount = getField(button.getClass(), button, "shiftAmount");
mScaleUpFactor = getField(button.getClass(), button, "scaleUpFactor");
mScaleDownFactor = getField(button.getClass(), button, "scaleDownFactor");
mLargeLabelSize = mLargeLabel.getTextSize();
mSmallLabelSize = mSmallLabel.getTextSize();
// System.out.println("mShiftAmount:" + mShiftAmount + " mScaleUpFactor:"
// + mScaleUpFactor + " mScaleDownFactor:" + mScaleDownFactor
// + " mLargeLabel:" + mLargeLabelSize + " mSmallLabel:" + mSmallLabelSize);
}
// disable
setField(button.getClass(), button, "shiftAmount", 0);
setField(button.getClass(), button, "scaleUpFactor", 1);
setField(button.getClass(), button, "scaleDownFactor", 1);
// let the mLargeLabel font size equal to mSmallLabel
mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mSmallLabelSize);
// debug start
// mLargeLabelSize = mLargeLabel.getTextSize();
// System.out.println("mLargeLabel:" + mLargeLabelSize);
// debug end
} else {
// haven't change the value. It means it was the first call this method. So nothing need to do.
if (!animationRecord)
return this;
// enable animation
setField(button.getClass(), button, "shiftAmount", mShiftAmount);
setField(button.getClass(), button, "scaleUpFactor", mScaleUpFactor);
setField(button.getClass(), button, "scaleDownFactor", mScaleDownFactor);
// restore
mLargeLabel.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLargeLabelSize);
}
}
mMenuView.updateMenuView();
return this;
}
|
enable or disable click item animation(text scale and icon move animation in no item shifting mode)
@param enable It means the text won't scale and icon won't move when active it in no item shifting mode if false.
|
enableAnimation
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
@Deprecated
public BottomNavigationViewInner enableShiftingMode(boolean enable) {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. change field mShiftingMode value in mMenuView
private boolean mShiftingMode = true;
*/
// 1. get mMenuView
// BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. change field mShiftingMode value in mMenuView
// setField(mMenuView.getClass(), mMenuView, "isShifting", enable);
// mMenuView.updateMenuView();
setLabelVisibilityMode(enable ? 0 : 1);
return this;
}
|
@Deprecated use {@link #setLabelVisibilityMode }
enable the shifting mode for navigation
@param enable It will has a shift animation if true. Otherwise all items are the same width.
|
enableShiftingMode
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
@Deprecated
public BottomNavigationViewInner enableItemShiftingMode(boolean enable) {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in this mMenuView
private BottomNavigationItemView[] mButtons;
3. change field mShiftingMode value in mButtons
private boolean mShiftingMode = true;
*/
// 1. get mMenuView
// BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get buttons
// BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. change field mShiftingMode value in mButtons
// for (BottomNavigationItemView button : mButtons) {
// button.setShifting(enable);
// }
// mMenuView.updateMenuView();
setItemHorizontalTranslationEnabled(enable);
return this;
}
|
@Deprecated use {@link #setItemHorizontalTranslationEnabled(boolean)}
enable the shifting mode for each item
@param enable It will has a shift animation for item if true. Otherwise the item text always be shown.
|
enableItemShiftingMode
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public int getCurrentItem() {
/*
1. get field in this class
private final BottomNavigationMenuView mMenuView;
2. get field in mMenuView
private BottomNavigationItemView[] mButtons;
3. get menu and traverse it to get the checked one
*/
// 2. get mButtons
BottomNavigationItemView[] mButtons = getBottomNavigationItemViews();
// 3. get menu and traverse it to get the checked one
Menu menu = getMenu();
for (int i = 0; i < mButtons.length; i++) {
if (menu.getItem(i).isChecked()) {
return i;
}
}
return 0;
}
|
get the current checked item position
@return index of item, start from 0.
|
getCurrentItem
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public int getMenuItemPosition(MenuItem item) {
// get item id
int itemId = item.getItemId();
// get meunu
Menu menu = getMenu();
int size = menu.size();
for (int i = 0; i < size; i++) {
if (menu.getItem(i).getItemId() == itemId) {
return i;
}
}
return -1;
}
|
get menu item position in menu
@param item
@return position if success, -1 otherwise
|
getMenuItemPosition
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setCurrentItem(int index) {
setSelectedItemId(getMenu().getItem(index).getItemId());
return this;
}
|
set the current checked item
@param index start from 0.
|
setCurrentItem
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner clearIconTintColor() {
getBottomNavigationMenuView().setIconTintList(null);
return this;
}
|
The lib has a default icon tint color. You can call this method to clear it if no need.
It usually used when you set two image for item.
@return
|
clearIconTintColor
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationItemView[] getBottomNavigationItemViews() {
if (null != mButtons)
return mButtons;
/*
* 1 private final BottomNavigationMenuView mMenuView;
* 2 private BottomNavigationItemView[] mButtons;
*/
BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
mButtons = getField(mMenuView.getClass(), mMenuView, "buttons");
return mButtons;
}
|
get private mButtons in mMenuView
@return
|
getBottomNavigationItemViews
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationItemView getBottomNavigationItemView(int position) {
return getBottomNavigationItemViews()[position];
}
|
get private mButton in mMenuView at position
@param position
@return
|
getBottomNavigationItemView
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public ImageView getIconAt(int position) {
/*
* 1 private final BottomNavigationMenuView mMenuView;
* 2 private BottomNavigationItemView[] mButtons;
* 3 private ImageView mIcon;
*/
BottomNavigationItemView mButtons = getBottomNavigationItemView(position);
ImageView mIcon = getField(BottomNavigationItemView.class, mButtons, "icon");
return mIcon;
}
|
get icon at position
@param position
@return
|
getIconAt
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public TextView getSmallLabelAt(int position) {
/*
* 1 private final BottomNavigationMenuView mMenuView;
* 2 private BottomNavigationItemView[] mButtons;
* 3 private final TextView mSmallLabel;
*/
BottomNavigationItemView mButtons = getBottomNavigationItemView(position);
TextView mSmallLabel = getField(BottomNavigationItemView.class, mButtons, "smallLabel");
return mSmallLabel;
}
|
get small label at position
Each item has tow label, one is large, another is small.
@param position
@return
|
getSmallLabelAt
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public TextView getLargeLabelAt(int position) {
/*
* 1 private final BottomNavigationMenuView mMenuView;
* 2 private BottomNavigationItemView[] mButtons;
* 3 private final TextView mLargeLabel;
*/
BottomNavigationItemView mButtons = getBottomNavigationItemView(position);
TextView mLargeLabel = getField(BottomNavigationItemView.class, mButtons, "largeLabel");
return mLargeLabel;
}
|
get large label at position
Each item has tow label, one is large, another is small.
@param position
@return
|
getLargeLabelAt
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setSmallTextSize(float sp) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
getSmallLabelAt(i).setTextSize(sp);
}
mMenuView.updateMenuView();
return this;
}
|
set all item small TextView size
Each item has tow label, one is large, another is small.
Small one will be shown when item state is normal
Large one will be shown when item checked.
@param sp
|
setSmallTextSize
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setLargeTextSize(float sp) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
TextView tvLarge = getLargeLabelAt(i);
if (null != tvLarge)
tvLarge.setTextSize(sp);
}
mMenuView.updateMenuView();
return this;
}
|
set all item large TextView size
Each item has tow label, one is large, another is small.
Small one will be shown when item state is normal.
Large one will be shown when item checked.
@param sp
|
setLargeTextSize
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setTextSize(float sp) {
setLargeTextSize(sp);
setSmallTextSize(sp);
return this;
}
|
set all item large and small TextView size
Each item has tow label, one is large, another is small.
Small one will be shown when item state is normal
Large one will be shown when item checked.
@param sp
|
setTextSize
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setIconSizeAt(int position, float width, float height) {
ImageView icon = getIconAt(position);
// update size
ViewGroup.LayoutParams layoutParams = icon.getLayoutParams();
layoutParams.width = dp2px(getContext(), width);
layoutParams.height = dp2px(getContext(), height);
icon.setLayoutParams(layoutParams);
mMenuView.updateMenuView();
return this;
}
|
set item ImageView size which at position
@param position position start from 0
@param width in dp
@param height in dp
|
setIconSizeAt
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setIconSize(float width, float height) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
setIconSizeAt(i, width, height);
}
return this;
}
|
set all item ImageView size
@param width in dp
@param height in dp
|
setIconSize
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setIconSize(float dpSize) {
setItemIconSize(dp2px(getContext(),dpSize));
return this;
}
|
set all item ImageView size
@param dpSize in dp
|
setIconSize
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setItemHeight(int height) {
// 1. get mMenuView
final BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. set private final int mItemHeight in mMenuView
setField(mMenuView.getClass(), mMenuView, "itemHeight", height);
mMenuView.updateMenuView();
return this;
}
|
set menu item height
@param height in px
|
setItemHeight
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public int getItemHeight() {
// 1. get mMenuView
final BottomNavigationMenuView mMenuView = getBottomNavigationMenuView();
// 2. get private final int mItemHeight in mMenuView
return getField(mMenuView.getClass(), mMenuView, "itemHeight");
}
|
get menu item height
@return in px
|
getItemHeight
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public static int dp2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
|
dp to px
@param context
@param dpValue dp
@return px
|
dp2px
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setTypeface(Typeface typeface, int style) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
getLargeLabelAt(i).setTypeface(typeface, style);
getSmallLabelAt(i).setTypeface(typeface, style);
}
mMenuView.updateMenuView();
return this;
}
|
set Typeface for all item TextView
@attr ref android.R.styleable#TextView_typeface
@attr ref android.R.styleable#TextView_textStyle
|
setTypeface
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setTypeface(Typeface typeface) {
int count = getItemCount();
for (int i = 0; i < count; i++) {
getLargeLabelAt(i).setTypeface(typeface);
getSmallLabelAt(i).setTypeface(typeface);
}
mMenuView.updateMenuView();
return this;
}
|
set Typeface for all item TextView
@attr ref android.R.styleable#TextView_typeface
|
setTypeface
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
private <T> T getField(Class targetClass, Object instance, String fieldName) {
try {
Field field = targetClass.getDeclaredField(fieldName);
field.setAccessible(true);
return (T) field.get(instance);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
|
get private filed in this specific object
@param targetClass
@param instance the filed owner
@param fieldName
@param <T>
@return field if success, null otherwise.
|
getField
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
private void setField(Class targetClass, Object instance, String fieldName, Object value) {
try {
Field field = targetClass.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(instance, value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
|
change the field value
@param targetClass
@param instance the filed owner
@param fieldName
@param value
|
setField
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setupWithViewPager(final ViewPager viewPager) {
return setupWithViewPager(viewPager, false);
}
|
This method will link the given ViewPager and this BottomNavigationViewInner together so that
changes in one are automatically reflected in the other. This includes scroll state changes
and clicks.
@param viewPager
|
setupWithViewPager
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setupWithViewPager(final ViewPager viewPager, boolean smoothScroll) {
if (mViewPager != null) {
// If we've already been setup with a ViewPager, remove us from it
if (mPageChangeListener != null) {
mViewPager.removeOnPageChangeListener(mPageChangeListener);
}
}
if (null == viewPager) {
mViewPager = null;
super.setOnNavigationItemSelectedListener(null);
return this;
}
mViewPager = viewPager;
// Add our custom OnPageChangeListener to the ViewPager
if (mPageChangeListener == null) {
mPageChangeListener = new BottomNavigationViewExOnPageChangeListener(this);
}
viewPager.addOnPageChangeListener(mPageChangeListener);
// Now we'll add a navigation item selected listener to set ViewPager's current item
OnNavigationItemSelectedListener listener = getOnNavigationItemSelectedListener();
mMyOnNavigationItemSelectedListener = new MyOnNavigationItemSelectedListener(viewPager, this, smoothScroll, listener);
super.setOnNavigationItemSelectedListener(mMyOnNavigationItemSelectedListener);
return this;
}
|
This method will link the given ViewPager and this BottomNavigationViewInner together so that
changes in one are automatically reflected in the other. This includes scroll state changes
and clicks.
@param viewPager
@param smoothScroll whether ViewPager changed with smooth scroll animation
|
setupWithViewPager
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setIconsMarginTop(int marginTop) {
for (int i = 0; i < getItemCount(); i++) {
setIconMarginTop(i, marginTop);
}
return this;
}
|
set margin top for all icons
@param marginTop in px
|
setIconsMarginTop
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
public BottomNavigationViewInner setIconMarginTop(int position, int marginTop) {
/*
1. BottomNavigationItemView
2. private final int mDefaultMargin;
*/
BottomNavigationItemView itemView = getBottomNavigationItemView(position);
setField(BottomNavigationItemView.class, itemView, "defaultMargin", marginTop);
mMenuView.updateMenuView();
return this;
}
|
set margin top for icon
@param position
@param marginTop in px
|
setIconMarginTop
|
java
|
ittianyu/BottomNavigationViewEx
|
widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
https://github.com/ittianyu/BottomNavigationViewEx/blob/master/widget/src/main/java/com/ittianyu/bottomnavigationviewex/BottomNavigationViewInner.java
|
MIT
|
@Override
public int compareTo(@NonNull PendingDismissData other) {
// Sort by descending position
return other.position - position;
}
|
Called when the item has been dismissed by swiping to the left.
@param recyclerView The originating {@link android.support.v7.widget.RecyclerView}.
@param reverseSortedPositions An array of positions to dismiss, sorted in descending
order for convenience.
|
compareTo
|
java
|
heruoxin/Clip-Stack
|
app/src/main/java/com/catchingnow/tinyclipboardmanager/SwipeableRecyclerViewTouchListener.java
|
https://github.com/heruoxin/Clip-Stack/blob/master/app/src/main/java/com/catchingnow/tinyclipboardmanager/SwipeableRecyclerViewTouchListener.java
|
MIT
|
public final void setAccountAuthenticatorResult(Bundle result) {
mResultBundle = result;
}
|
Set the result that is to be sent as the result of the request that caused this
Activity to be launched. If result is null or this method is never called then
the request will be canceled.
@param result this is returned as the result of the AbstractAccountAuthenticator request
|
setAccountAuthenticatorResult
|
java
|
Leaking/WeGit
|
app/src/main/java/com/quinn/githubknife/ui/activity/LoginActivity.java
|
https://github.com/Leaking/WeGit/blob/master/app/src/main/java/com/quinn/githubknife/ui/activity/LoginActivity.java
|
Apache-2.0
|
public static boolean isImage(String name) {
if (TextUtils.isEmpty(name))
return false;
name = name.toLowerCase(US);
for (String extension : IMAGE_EXTENSIONS)
if (name.endsWith(extension))
return true;
return false;
}
|
Created by Bernat on 10/09/2014
Is the the given file name a image file?
@param name
@return true if the name has a markdown extension, false otherwise
|
isImage
|
java
|
Leaking/WeGit
|
app/src/main/java/com/quinn/githubknife/utils/FileUtils.java
|
https://github.com/Leaking/WeGit/blob/master/app/src/main/java/com/quinn/githubknife/utils/FileUtils.java
|
Apache-2.0
|
public static CharSequence getRelativeTime(final Date date) {
long now = System.currentTimeMillis();
if (Math.abs(now - date.getTime()) > 60000)
return DateUtils.getRelativeTimeSpanString(date.getTime(), now,
MINUTE_IN_MILLIS, FORMAT_SHOW_DATE | FORMAT_SHOW_YEAR
| FORMAT_NUMERIC_DATE);
else
return "just now";
}
|
Get relative time for date
@param date
@return relative time
|
getRelativeTime
|
java
|
Leaking/WeGit
|
app/src/main/java/com/quinn/githubknife/utils/TimeUtils.java
|
https://github.com/Leaking/WeGit/blob/master/app/src/main/java/com/quinn/githubknife/utils/TimeUtils.java
|
Apache-2.0
|
private static byte[] encode3to4(byte[] source, int srcOffset,
int numSigBytes, byte[] destination, int destOffset) {
byte[] ALPHABET = _STANDARD_ALPHABET;
int inBuff = (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0)
| (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0)
| (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0);
switch (numSigBytes) {
case 3:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f];
destination[destOffset + 3] = ALPHABET[(inBuff) & 0x3f];
return destination;
case 2:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f];
destination[destOffset + 3] = EQUALS_SIGN;
return destination;
case 1:
destination[destOffset] = ALPHABET[(inBuff >>> 18)];
destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
destination[destOffset + 2] = EQUALS_SIGN;
destination[destOffset + 3] = EQUALS_SIGN;
return destination;
default:
return destination;
}
}
|
<p>
Encodes up to three bytes of the array <var>source</var> and writes the
resulting four Base64 bytes to <var>destination</var>. The source and
destination arrays can be manipulated anywhere along their length by
specifying <var>srcOffset</var> and <var>destOffset</var>. This method
does not check to make sure your arrays are large enough to accomodate
<var>srcOffset</var> + 3 for the <var>source</var> array or
<var>destOffset</var> + 4 for the <var>destination</var> array. The
actual number of significant bytes in your array is given by
<var>numSigBytes</var>.
</p>
<p>
This is the lowest level of the encoding methods with all possible
parameters.
</p>
@param source
the array to convert
@param srcOffset
the index where conversion begins
@param numSigBytes
the number of significant bytes in your array
@param destination
the array to hold the conversion
@param destOffset
the index where output will be put
@return the <var>destination</var> array
@since 1.3
|
encode3to4
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
Apache-2.0
|
public static String encode(String string) {
byte[] bytes;
try {
bytes = string.getBytes(PREFERRED_ENCODING);
} catch (UnsupportedEncodingException e) {
bytes = string.getBytes();
}
return encodeBytes(bytes);
}
|
Encode string as a byte array in Base64 annotation.
@param string
@return The Base64-encoded data as a string
|
encode
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
Apache-2.0
|
public static String encodeBytes(byte[] source) {
return encodeBytes(source, 0, source.length);
}
|
Encodes a byte array into Base64 notation.
@param source
The data to convert
@return The Base64-encoded data as a String
@throws NullPointerException
if source array is null
@throws IllegalArgumentException
if source array, offset, or length are invalid
@since 2.0
|
encodeBytes
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
Apache-2.0
|
public static String encodeBytes(byte[] source, int off, int len) {
byte[] encoded = encodeBytesToBytes(source, off, len);
try {
return new String(encoded, PREFERRED_ENCODING);
} catch (UnsupportedEncodingException uue) {
return new String(encoded);
}
}
|
Encodes a byte array into Base64 notation.
@param source
The data to convert
@param off
Offset in array where conversion should begin
@param len
Length of data to convert
@return The Base64-encoded data as a String
@throws NullPointerException
if source array is null
@throws IllegalArgumentException
if source array, offset, or length are invalid
@since 2.0
|
encodeBytes
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
Apache-2.0
|
public static byte[] encodeBytesToBytes(byte[] source, int off, int len) {
if (source == null)
throw new NullPointerException("Cannot serialize a null array.");
if (off < 0)
throw new IllegalArgumentException("Cannot have negative offset: "
+ off);
if (len < 0)
throw new IllegalArgumentException("Cannot have length offset: " + len);
if (off + len > source.length)
throw new IllegalArgumentException(
String
.format(
"Cannot have offset of %d and length of %d with array of length %d",
off, len, source.length));
// Bytes needed for actual encoding
int encLen = (len / 3) * 4 + (len % 3 > 0 ? 4 : 0);
byte[] outBuff = new byte[encLen];
int d = 0;
int e = 0;
int len2 = len - 2;
for (; d < len2; d += 3, e += 4)
encode3to4(source, d + off, 3, outBuff, e);
if (d < len) {
encode3to4(source, d + off, len - d, outBuff, e);
e += 4;
}
if (e <= outBuff.length - 1) {
byte[] finalOut = new byte[e];
System.arraycopy(outBuff, 0, finalOut, 0, e);
return finalOut;
} else
return outBuff;
}
|
Similar to {@link #encodeBytes(byte[], int, int)} but returns a byte
array instead of instantiating a String. This is more efficient if you're
working with I/O streams and have large data sets to encode.
@param source
The data to convert
@param off
Offset in array where conversion should begin
@param len
Length of data to convert
@return The Base64-encoded data as a String if there is an error
@throws NullPointerException
if source array is null
@throws IllegalArgumentException
if source array, offset, or length are invalid
@since 2.3.1
|
encodeBytesToBytes
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/Base64.java
|
Apache-2.0
|
public synchronized byte[] getBuf(int len) {
for (int i = 0; i < mBuffersBySize.size(); i++) {
byte[] buf = mBuffersBySize.get(i);
if (buf.length >= len) {
mCurrentSize -= buf.length;
mBuffersBySize.remove(i);
mBuffersByLastUse.remove(buf);
return buf;
}
}
return new byte[len];
}
|
Returns a buffer from the pool if one is available in the requested size, or allocates a new
one if a pooled one is not available.
@param len the minimum size, in bytes, of the requested buffer. The returned buffer may be
larger.
@return a byte[] buffer is always returned.
|
getBuf
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/ByteArrayPool.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/ByteArrayPool.java
|
Apache-2.0
|
public synchronized void returnBuf(byte[] buf) {
if (buf == null || buf.length > mSizeLimit) {
return;
}
mBuffersByLastUse.add(buf);
int pos = Collections.binarySearch(mBuffersBySize, buf, BUF_COMPARATOR);
if (pos < 0) {
pos = -pos - 1;
}
mBuffersBySize.add(pos, buf);
mCurrentSize += buf.length;
trim();
}
|
Returns a buffer to the pool, throwing away old buffers if the pool would exceed its allotted
size.
@param buf the buffer to return to the pool.
|
returnBuf
|
java
|
Leaking/WeGit
|
httpknife/src/main/java/com/quinn/httpknife/http/ByteArrayPool.java
|
https://github.com/Leaking/WeGit/blob/master/httpknife/src/main/java/com/quinn/httpknife/http/ByteArrayPool.java
|
Apache-2.0
|
public void setIcon(final Icon icon) {
updateIcon(icon);
invalidateSelf();
}
|
Loads and draws given {@link Icon}.
@param icon
|
setIcon
|
java
|
Leaking/WeGit
|
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
Apache-2.0
|
public void setIconColor(int color) {
mIconPaint.setColor(color);
invalidateSelf();
}
|
Set a color for the {@link Icon}.
@param color
|
setIconColor
|
java
|
Leaking/WeGit
|
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
Apache-2.0
|
public void setIconPadding(int iconPadding) {
mIconPadding = iconPadding;
if (mDrawContour) {
mIconPadding += mContourWidth;
}
invalidateSelf();
}
|
Set a padding for the {@link Icon}.
@param iconPadding
|
setIconPadding
|
java
|
Leaking/WeGit
|
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
Apache-2.0
|
public void setContour(int contourColor, int contourWidth) {
setContourColor(contourColor);
setContourWidth(contourWidth);
invalidateSelf();
}
|
Set contour params for the {@link Icon}.
You should call {@link #drawContour(boolean)} method to enable contour.
@param contourColor
@param contourWidth
|
setContour
|
java
|
Leaking/WeGit
|
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
Apache-2.0
|
public void setContourColor(int contourColor) {
mContourPaint.setColor(contourColor);
invalidateSelf();
}
|
Set contour color for the {@link Icon}.
You should call {@link #drawContour(boolean)} method to enable contour.
@param contourColor
|
setContourColor
|
java
|
Leaking/WeGit
|
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
Apache-2.0
|
public void setContourWidth(int contourWidth) {
mContourWidth = contourWidth;
mContourPaint.setStrokeWidth(mContourWidth);
invalidateSelf();
}
|
Set contour width for the {@link Icon}.
You should call {@link #drawContour(boolean)} method to enable contour.
@param contourWidth
|
setContourWidth
|
java
|
Leaking/WeGit
|
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.