use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project android_packages_apps_Settings by DirtyUnicorns.
the class AppLaunchSettings method buildStateDropDown.
private void buildStateDropDown() {
if (mIsBrowser) {
// Browsers don't show the app-link prefs
mAppLinkState.setShouldDisableView(true);
mAppLinkState.setEnabled(false);
mAppDomainUrls.setShouldDisableView(true);
mAppDomainUrls.setEnabled(false);
} else {
// Designed order of states in the dropdown:
//
// * always
// * ask
// * never
mAppLinkState.setEntries(new CharSequence[] { getString(R.string.app_link_open_always), getString(R.string.app_link_open_ask), getString(R.string.app_link_open_never) });
mAppLinkState.setEntryValues(new CharSequence[] { Integer.toString(INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS), Integer.toString(INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK), Integer.toString(INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER) });
mAppLinkState.setEnabled(mHasDomainUrls);
if (mHasDomainUrls) {
// Present 'undefined' as 'ask' because the OS treats them identically for
// purposes of the UI (and does the right thing around pending domain
// verifications that might arrive after the user chooses 'ask' in this UI).
final int state = mPm.getIntentVerificationStatusAsUser(mPackageName, UserHandle.myUserId());
mAppLinkState.setValue(Integer.toString((state == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) ? INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK : state));
// Set the callback only after setting the initial selected item
mAppLinkState.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return updateAppLinkState(Integer.parseInt((String) newValue));
}
});
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project vlc-android by GeoffreyMetais.
the class VideoPlayerActivity method surfaceFrameAddLayoutListener.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void surfaceFrameAddLayoutListener(boolean add) {
if (mSurfaceFrame == null || add == (mOnLayoutChangeListener != null))
return;
if (add) {
mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
private final Runnable mRunnable = new Runnable() {
@Override
public void run() {
changeSurfaceLayout();
}
};
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
/* changeSurfaceLayout need to be called after the layout changed */
mHandler.removeCallbacks(mRunnable);
mHandler.post(mRunnable);
}
}
};
mSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
changeSurfaceLayout();
} else {
mSurfaceFrame.removeOnLayoutChangeListener(mOnLayoutChangeListener);
mOnLayoutChangeListener = null;
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project android-advancedrecyclerview by h6ah4i.
the class ItemSlidingAnimator method slideToOutsideOfWindowInternal.
private boolean slideToOutsideOfWindowInternal(RecyclerView.ViewHolder holder, int dir, boolean shouldAnimate, long duration, SwipeFinishInfo swipeFinish) {
if (!(holder instanceof SwipeableItemViewHolder)) {
return false;
}
final View containerView = SwipeableViewHolderUtils.getSwipeableContainerView(holder);
final ViewGroup parent = (ViewGroup) containerView.getParent();
if (parent == null) {
return false;
}
final int left = containerView.getLeft();
final int right = containerView.getRight();
final int top = containerView.getTop();
final int bottom = containerView.getBottom();
final int width = right - left;
final int height = bottom - top;
parent.getWindowVisibleDisplayFrame(mTmpRect);
final int windowWidth = mTmpRect.width();
final int windowHeight = mTmpRect.height();
int translateX = 0;
int translateY = 0;
if ((width == 0) || (height == 0)) {
// not measured yet or not shown
switch(dir) {
case DIR_LEFT:
translateX = -windowWidth;
break;
case DIR_UP:
translateY = -windowHeight;
break;
case DIR_RIGHT:
translateX = windowWidth;
break;
case DIR_DOWN:
translateY = windowHeight;
break;
default:
break;
}
shouldAnimate = false;
} else {
parent.getLocationInWindow(mTmpLocation);
final int x = mTmpLocation[0];
final int y = mTmpLocation[1];
switch(dir) {
case DIR_LEFT:
translateX = -(x + width);
break;
case DIR_UP:
translateY = -(y + height);
break;
case DIR_RIGHT:
translateX = windowWidth - (x - left);
break;
case DIR_DOWN:
translateY = windowHeight - (y - top);
break;
default:
break;
}
}
if (shouldAnimate) {
shouldAnimate = ViewCompat.isAttachedToWindow(containerView) && (containerView.getVisibility() == View.VISIBLE);
}
duration = (shouldAnimate) ? duration : 0;
boolean horizontal = (dir == DIR_LEFT || dir == DIR_RIGHT);
return animateSlideInternalCompat(holder, horizontal, translateX, translateY, duration, mSlideToOutsideOfWindowAnimationInterpolator, swipeFinish);
}
use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project android-advancedrecyclerview by h6ah4i.
the class SimpleListDividerDecorator method onDrawOver.
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
final int childCount = parent.getChildCount();
if (childCount == 0) {
return;
}
// [px]
final float xPositionThreshold = (mOverlap) ? 1.0f : (mVerticalDividerWidth + 1.0f);
// [px]
final float yPositionThreshold = (mOverlap) ? 1.0f : (mHorizontalDividerHeight + 1.0f);
// [px]
final float zPositionThreshold = 1.0f;
for (int i = 0; i < childCount - 1; i++) {
final View child = parent.getChildAt(i);
final View nextChild = parent.getChildAt(i + 1);
if ((child.getVisibility() != View.VISIBLE) || (nextChild.getVisibility() != View.VISIBLE)) {
continue;
}
// check if the next item is placed at the bottom or right
final float childBottom = child.getBottom() + child.getTranslationY();
final float nextChildTop = nextChild.getTop() + nextChild.getTranslationY();
final float childRight = child.getRight() + child.getTranslationX();
final float nextChildLeft = nextChild.getLeft() + nextChild.getTranslationX();
if (!(((mHorizontalDividerHeight != 0) && (Math.abs(nextChildTop - childBottom) < yPositionThreshold)) || ((mVerticalDividerWidth != 0) && (Math.abs(nextChildLeft - childRight) < xPositionThreshold)))) {
continue;
}
// check if the next item is placed on the same plane
final float childZ = ViewCompat.getTranslationZ(child) + ViewCompat.getElevation(child);
final float nextChildZ = ViewCompat.getTranslationZ(nextChild) + ViewCompat.getElevation(nextChild);
if (!(Math.abs(nextChildZ - childZ) < zPositionThreshold)) {
continue;
}
final float childAlpha = child.getAlpha();
final float nextChildAlpha = nextChild.getAlpha();
final int tx = (int) (child.getTranslationX() + 0.5f);
final int ty = (int) (child.getTranslationY() + 0.5f);
if (mHorizontalDividerHeight != 0) {
final int left = child.getLeft();
final int right = child.getRight();
final int top = child.getBottom() - (mOverlap ? mHorizontalDividerHeight : 0);
final int bottom = top + mHorizontalDividerHeight;
mHorizontalDrawable.setAlpha((int) ((0.5f * 255) * (childAlpha + nextChildAlpha) + 0.5f));
mHorizontalDrawable.setBounds(left + tx, top + ty, right + tx, bottom + ty);
mHorizontalDrawable.draw(c);
}
if (mVerticalDividerWidth != 0) {
final int left = child.getRight() - (mOverlap ? mVerticalDividerWidth : 0);
final int right = left + mVerticalDividerWidth;
final int top = child.getTop();
final int bottom = child.getBottom();
mVerticalDrawable.setAlpha((int) ((0.5f * 255) * (childAlpha + nextChildAlpha) + 0.5f));
mVerticalDrawable.setBounds(left + tx, top + ty, right + tx, bottom + ty);
mVerticalDrawable.draw(c);
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project open-event-android by fossasia.
the class HeaderPositionCalculator method isStickyHeaderBeingPushedOffscreen.
private boolean isStickyHeaderBeingPushedOffscreen(RecyclerView recyclerView, View stickyHeader) {
View viewAfterHeader = getFirstViewUnobscuredByHeader(recyclerView, stickyHeader);
int firstViewUnderHeaderPosition = recyclerView.getChildAdapterPosition(viewAfterHeader);
if (firstViewUnderHeaderPosition == RecyclerView.NO_POSITION) {
return false;
}
boolean isReverseLayout = mOrientationProvider.isReverseLayout(recyclerView);
if (firstViewUnderHeaderPosition > 0 && hasNewHeader(firstViewUnderHeaderPosition, isReverseLayout)) {
View nextHeader = mHeaderProvider.getHeader(recyclerView, firstViewUnderHeaderPosition);
mDimensionCalculator.initMargins(mTempRect1, nextHeader);
mDimensionCalculator.initMargins(mTempRect2, stickyHeader);
if (mOrientationProvider.getOrientation(recyclerView) == LinearLayoutManager.VERTICAL) {
int topOfNextHeader = viewAfterHeader.getTop() - mTempRect1.bottom - nextHeader.getHeight() - mTempRect1.top;
int bottomOfThisHeader = recyclerView.getPaddingTop() + stickyHeader.getBottom() + mTempRect2.top + mTempRect2.bottom;
if (topOfNextHeader < bottomOfThisHeader) {
return true;
}
} else {
int leftOfNextHeader = viewAfterHeader.getLeft() - mTempRect1.right - nextHeader.getWidth() - mTempRect1.left;
int rightOfThisHeader = recyclerView.getPaddingLeft() + stickyHeader.getRight() + mTempRect2.left + mTempRect2.right;
if (leftOfNextHeader < rightOfThisHeader) {
return true;
}
}
}
return false;
}
Aggregations