This file contains hidden or 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.text.Layout | |
| import android.text.Spannable | |
| import android.text.method.LinkMovementMethod | |
| import android.text.style.ClickableSpan | |
| import android.text.style.URLSpan | |
| import android.view.MotionEvent | |
| import android.widget.TextView | |
| abstract class UrlSpanLinkMovementMethod : LinkMovementMethod() { |
This file contains hidden or 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
| val gson = GsonBuilder().create() | |
| val data: HashMap<String, JsonElement> = gson.fromJson(gsonString, object : TypeToken<HashMap<String, JsonElement>>() { | |
| }.type) | |
| JsonCleaner.removeJsonEmptyPart(data) | |
| val newData = gson.toJson(data) |
This file contains hidden or 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
| package ch.deletescape.lawnchair.lawnfeed; | |
| import android.app.Activity; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.content.pm.PackageManager; | |
| import android.os.Bundle; | |
| import android.os.Handler; | |
| import android.os.Looper; | |
| import android.os.ResultReceiver; |
This file contains hidden or 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
| //计算RecyclerView GridView的 每个 item的左右间距,以下是使所有的item左右间距相等 | |
| int rowIndex= 2;//item在当前行的位置 从0开始 | |
| int spanSize = xxx;//GridView每行的item 个数 | |
| int margin = xxx;//要设置的间距 | |
| int marginStart = (spanSize-rowIndex)/spanSize*margin; | |
| int marginEnd = (rowIndex+1)/spanSize*margin; |
This file contains hidden or 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 static void clearPaddingBeforeLollipop(CardView cardView) { | |
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | |
| cardView.setMaxCardElevation(0); | |
| } | |
| } |
This file contains hidden or 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 FillParentTabLayout extends TabLayout { | |
| public FillParentTabLayout(Context context) { | |
| super(context); | |
| } | |
| public FillParentTabLayout(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| } |
This file contains hidden or 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
| SpannableString spanString = new SpannableString("span styled msg"); | |
| spanString.setSpan(new ScaleBgSpan(ContextCompat.getColor(mContext, R.color.green_5e), | |
| ContextCompat.getColor(mContext, R.color.white_color), | |
| DensityUtil.sp2px(mContext, 12), 12), 0, | |
| spanString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | |
| SpannableStringBuilder builder = new SpannableStringBuilder(); | |
| builder.append(spanString); | |
| builder.append(" "); | |
| builder.append("other msg"); |
This file contains hidden or 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 CardViewUtil { | |
| public static void clearPaddingBeforeLollipop(CardView cardView) { | |
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { | |
| cardView.setMaxCardElevation(0); | |
| } | |
| } | |
| } |
This file contains hidden or 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
| shopTabRecyclerBinding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
| private boolean scrollUp = true; | |
| private long showTime = 2000; | |
| private Runnable disappearRunnable = new Runnable() { | |
| @Override | |
| public void run() { | |
| shopTabRecyclerBinding.homeScrollUpIco.animate().alpha(0).setListener(new AnimatorListenerAdapter() { | |
| @Override | |
| public void onAnimationEnd(Animator animation) { |
This file contains hidden or 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 Rxjava2Test { | |
| public static void main1(String[] args) { | |
| //停止某个定时任务 | |
| PublishSubject stop = PublishSubject.create(); | |
| final Observable<Long> observable = Observable.interval(1, TimeUnit.SECONDS).takeUntil(stop); | |
| observable.subscribe(new Consumer<Long>() { | |
| @Override | |
| public void accept(Long aLong) throws Exception { | |
| //do something | |
| } |
NewerOlder