This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean dispatchTouchEvent(MotionEvent ev) { | |
final int action = ev.getAction(); | |
final float xf = ev.getX(); | |
final float yf = ev.getY(); | |
final float scrolledXFloat = xf + mScrollX; | |
final float scrolledYFloat = yf + mScrollY; | |
final Rect frame = mTempRect; | |
boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0; | |
if (action == MotionEvent.ACTION_DOWN) { | |
if (mMotionTarget != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SnappingLinearLayoutManager extends LinearLayoutManager { | |
private RecyclerView.SmoothScroller smoothScroller; | |
public SnappingLinearLayoutManager(Context context) { | |
super(context, VERTICAL, false); | |
} | |
@Override | |
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, | |
int position) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomSpan { | |
private Context mContext; | |
private SpannableStringBuilder mSpannableString; | |
private int mStart; | |
private int mEnd; | |
public CustomSpan(Context context) { | |
mContext = context; | |
mSpannableString = new SpannableStringBuilder(""); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomTypefaceSpan extends MetricAffectingSpan { | |
private final Typeface mTypeface; | |
public CustomTypefaceSpan(final Typeface typeface) { | |
this.mTypeface = typeface; | |
} | |
@Override | |
public void updateDrawState(final TextPaint drawState) { | |
apply(drawState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v4.app.Fragment; | |
import android.support.v4.view.ViewPager; | |
/** | |
* Created: chiemy | |
* Date: 17/1/4 | |
* Description: 为解决 ViewPager 内 Fragment 嵌套 ViewPager, setUserVisibleHint 方法不准确的问题的帮助类 | |
*/ | |
public class NestedFragmentHelper implements ViewPager.OnPageChangeListener { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created: chiemy | |
* Date: 16/11/22 | |
* Description: 可控制显示时长, 可点击的Toast | |
*/ | |
public class ExtendToast { | |
public static final int LENGTH_ALWAYS = 0; | |
public static final int LENGTH_SHORT = 2; | |
private Toast toast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Bitmap getScreenshotFromRecyclerView(RecyclerView view) { | |
RecyclerView.Adapter adapter = view.getAdapter(); | |
Bitmap bigBitmap = null; | |
if (adapter != null) { | |
int size = adapter.getItemCount(); | |
int height = 0; | |
Paint paint = new Paint(); | |
int iHeight = 0; | |
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Bitmap blurBitmap(Bitmap bitmap){ | |
//Let's create an empty bitmap with the same size of the bitmap we want to blur | |
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); | |
//Instantiate a new Renderscript | |
RenderScript rs = RenderScript.create(getApplicationContext()); | |
//Create an Intrinsic Blur Script using the Renderscript | |
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2014 Chris Banes | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private AudioManager.OnAudioFocusChangeListener mOnAudioFocusChangeListener; | |
//… | |
mOnAudioFocusChangeListener = new AudioManager.OnAudioFocusChangeListener() { | |
@Override | |
public void onAudioFocusChange(int focusChange) { | |
switch (focusChange) { | |
case AudioManager.AUDIOFOCUS_GAIN: | |
Log.i(TAG, "AUDIOFOCUS_GAIN"); | |
// Set volume level to desired levels |
NewerOlder