use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project ChipsLayoutManager by BelooS.
the class HorizontalScrollingController method createSmoothScroller.
@Override
public RecyclerView.SmoothScroller createSmoothScroller(@NonNull Context context, final int position, final int timeMs, final AnchorViewState anchor) {
return new LinearSmoothScroller(context) {
/*
* LinearSmoothScroller, at a minimum, just need to know the vector
* (x/y distance) to travel in order to get from the current positioning
* to the target.
*/
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
int visiblePosition = anchor.getPosition();
// determine scroll up or scroll down needed
return new PointF(position > visiblePosition ? 1 : -1, 0);
}
@Override
protected void onTargetFound(View targetView, RecyclerView.State state, Action action) {
super.onTargetFound(targetView, state, action);
int currentLeft = layoutManager.getPaddingLeft();
int desiredLeft = layoutManager.getDecoratedLeft(targetView);
int dx = desiredLeft - currentLeft;
// perform fit animation to move target view at top of layoutX
action.update(dx, 0, timeMs, new LinearInterpolator());
}
};
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project superCleanMaster by joyoyao.
the class SpeedyQuickReturnRecyclerViewOnScrollListener method onScrolled.
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// apply extra on scroll listener
for (RecyclerView.OnScrollListener listener : mExtraOnScrollListeners) {
listener.onScrolled(recyclerView, dx, dy);
}
int scrollY = QuickReturnUtils.getScrollY(recyclerView);
int diff = mPrevScrollY - scrollY;
if (diff > 0) {
// scrolling up
switch(mQuickReturnType) {
case HEADER:
if (mHeader.getVisibility() == View.GONE) {
mHeader.setVisibility(View.VISIBLE);
mHeader.startAnimation(mSlideHeaderDownAnimation);
}
break;
case FOOTER:
if (mFooter.getVisibility() == View.GONE) {
mFooter.setVisibility(View.VISIBLE);
mFooter.startAnimation(mSlideFooterUpAnimation);
}
break;
case BOTH:
if (mHeader.getVisibility() == View.GONE) {
mHeader.setVisibility(View.VISIBLE);
mHeader.startAnimation(mSlideHeaderDownAnimation);
}
if (mFooter.getVisibility() == View.GONE) {
mFooter.setVisibility(View.VISIBLE);
mFooter.startAnimation(mSlideFooterUpAnimation);
}
break;
case GOOGLE_PLUS:
if (mHeaderViews != null) {
for (View view : mHeaderViews) {
if (view.getVisibility() == View.GONE) {
view.setVisibility(View.VISIBLE);
view.startAnimation(mSlideHeaderDownAnimation);
}
}
}
if (mFooterViews != null) {
for (View view : mFooterViews) {
int scrollThreshold = (Integer) view.getTag(R.id.scroll_threshold_key);
if (diff > scrollThreshold) {
if (view.getVisibility() == View.GONE) {
view.setVisibility(View.VISIBLE);
view.startAnimation(mSlideFooterUpAnimation);
}
}
}
}
break;
}
} else if (diff < 0) {
// scrolling down
switch(mQuickReturnType) {
case HEADER:
if (mHeader.getVisibility() == View.VISIBLE) {
mHeader.setVisibility(View.GONE);
mHeader.startAnimation(mSlideHeaderUpAnimation);
}
break;
case FOOTER:
if (mFooter.getVisibility() == View.VISIBLE) {
mFooter.setVisibility(View.GONE);
mFooter.startAnimation(mSlideFooterDownAnimation);
}
break;
case BOTH:
if (mHeader.getVisibility() == View.VISIBLE) {
mHeader.setVisibility(View.GONE);
mHeader.startAnimation(mSlideHeaderUpAnimation);
}
if (mFooter.getVisibility() == View.VISIBLE) {
mFooter.setVisibility(View.GONE);
mFooter.startAnimation(mSlideFooterDownAnimation);
}
break;
case GOOGLE_PLUS:
if (mHeaderViews != null) {
for (View view : mHeaderViews) {
if (view.getVisibility() == View.VISIBLE) {
view.setVisibility(View.GONE);
view.startAnimation(mSlideHeaderUpAnimation);
}
}
}
if (mFooterViews != null) {
for (View view : mFooterViews) {
int scrollThreshold = (Integer) view.getTag(R.id.scroll_threshold_key);
if (diff < -scrollThreshold) {
if (view.getVisibility() == View.VISIBLE) {
view.setVisibility(View.GONE);
view.startAnimation(mSlideFooterDownAnimation);
}
}
}
}
break;
}
}
mPrevScrollY = scrollY;
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project buglife-android by Buglife.
the class ScreenshotAnnotatorActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screenshot_annotator);
mAnnotationView = (AnnotationView) findViewById(R.id.annotation_view);
Intent intent = getIntent();
intent.setExtrasClassLoader(FileAttachment.class.getClassLoader());
mAttachment = intent.getParcelableExtra(INTENT_KEY_ATTACHMENT);
intent.setExtrasClassLoader(BugContext.class.getClassLoader());
mBugContext = intent.getParcelableExtra(INTENT_KEY_BUG_CONTEXT);
File file = mAttachment.getFile();
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
mAnnotationView.setImage(bitmap);
mColorPalette = new ColorPalette.Builder(this).build();
// Annotation tools
mAnnotationToolbar = findViewById(R.id.annotation_toolbar);
mAnnotationToolbar.setBackgroundColor(mColorPalette.getColorPrimary());
mArrowTool = (ImageButton) findViewById(R.id.arrow_tool);
mLoupeTool = (ImageButton) findViewById(R.id.loupe_tool);
mBlurTool = (ImageButton) findViewById(R.id.blur_tool);
mArrowTool.setColorFilter(getToolColorFilter());
mLoupeTool.setColorFilter(getToolColorFilter());
mBlurTool.setColorFilter(getToolColorFilter());
mArrowTool.setOnClickListener(mToolClickListener);
mLoupeTool.setOnClickListener(mToolClickListener);
mBlurTool.setOnClickListener(mToolClickListener);
setSelectedTool(Annotation.Type.ARROW);
mAnnotationView.setAnnotation(Annotation.newArrowInstance());
mAnnotationView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
setToolbarsHidden(true);
break;
case MotionEvent.ACTION_UP:
setToolbarsHidden(false);
break;
}
// Must return false in order for event to propagate down
return false;
}
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
int colorPrimary = mColorPalette.getColorPrimary();
int titleTextColor = mColorPalette.getTextColorPrimary();
@DrawableRes final int homeAsUpIndicatorDrawableId;
@StringRes final int titleStringId;
if (isInitialScreenshotAnnotationActivity()) {
// If this is the initial screenshot activity, show a different title
// along with close + next buttons
homeAsUpIndicatorDrawableId = android.R.drawable.ic_menu_close_clear_cancel;
titleStringId = R.string.report_a_bug;
} else {
// Otherwise, this is a child activity of ReportActivity
homeAsUpIndicatorDrawableId = R.drawable.buglife_abc_ic_ab_back_mtrl_am_alpha;
titleStringId = R.string.screenshot_annotator_activity_label;
}
Drawable homeAsUpIndicator = ActivityUtils.getTintedDrawable(this, homeAsUpIndicatorDrawableId, mColorPalette.getTextColorPrimary());
CharSequence title = ActivityUtils.getTextWithColor(this, titleTextColor, titleStringId);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(homeAsUpIndicator);
actionBar.setBackgroundDrawable(new ColorDrawable(colorPrimary));
actionBar.setTitle(title);
}
ActivityUtils.setStatusBarColor(this, mColorPalette.getColorPrimaryDark());
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
// ClientEventReporter.getInstance(Buglife.getContext()).reportClientEvent("presented_reporter", mBugContext.getApiIdentity());
}
}, 2000);
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project xDrip by NightscoutFoundation.
the class ActivityRecognizedService method disableMotionTrackingDueToErrors.
private static void disableMotionTrackingDueToErrors(Context context) {
final long requested = getInternalPrefsLong(REQUESTED);
final long received = getInternalPrefsLong(RECEIVED);
Home.toaststaticnext("DISABLED MOTION TRACKING DUE TO FAILURES! See Error Log!");
final String msg = "Had to disable motion tracking feature as it did not seem to be working and may be incompatible with your phone. Please report this to the developers using the send logs feature: " + requested + " vs " + received + " " + JoH.getDeviceDetails();
UserError.Log.wtf(TAG, msg);
UserError.Log.ueh(TAG, msg);
Pref.setBoolean("motion_tracking_enabled", false);
// mark for disable
evaluateRequestReceivedCounters(true, context);
setInternalPrefsLong(REQUESTED, 0);
setInternalPrefsLong(RECEIVED, 0);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
Intent intent = new Intent(xdrip.getAppContext(), ErrorsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(xdrip.getAppContext(), 0, /* Request code */
intent, PendingIntent.FLAG_ONE_SHOT);
builder.setContentText("Shut down motion detection! See Error Logs - Please report to developer" + JoH.dateTimeText(JoH.tsl()));
builder.setContentIntent(pendingIntent);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle("Problem with motion detection!");
NotificationManagerCompat.from(context).notify(VEHICLE_NOTIFICATION_ERROR_ID, builder.build());
}
use of android.support.v7.widget.helper.ItemTouchHelper.DOWN in project xDrip-plus by jamorham.
the class ActivityRecognizedService method disableMotionTrackingDueToErrors.
private static void disableMotionTrackingDueToErrors(Context context) {
final long requested = getInternalPrefsLong(REQUESTED);
final long received = getInternalPrefsLong(RECEIVED);
Home.toaststaticnext("DISABLED MOTION TRACKING DUE TO FAILURES! See Error Log!");
final String msg = "Had to disable motion tracking feature as it did not seem to be working and may be incompatible with your phone. Please report this to the developers using the send logs feature: " + requested + " vs " + received + " " + JoH.getDeviceDetails();
UserError.Log.wtf(TAG, msg);
UserError.Log.ueh(TAG, msg);
Pref.setBoolean("motion_tracking_enabled", false);
// mark for disable
evaluateRequestReceivedCounters(true, context);
setInternalPrefsLong(REQUESTED, 0);
setInternalPrefsLong(RECEIVED, 0);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
Intent intent = new Intent(xdrip.getAppContext(), ErrorsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(xdrip.getAppContext(), 0, /* Request code */
intent, PendingIntent.FLAG_ONE_SHOT);
builder.setContentText("Shut down motion detection! See Error Logs - Please report to developer" + JoH.dateTimeText(JoH.tsl()));
builder.setContentIntent(pendingIntent);
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setContentTitle("Problem with motion detection!");
NotificationManagerCompat.from(context).notify(VEHICLE_NOTIFICATION_ERROR_ID, builder.build());
}
Aggregations