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 java.io.IOException; | |
| import java.lang.annotation.Annotation; | |
| import java.lang.reflect.Type; | |
| import okhttp3.MediaType; | |
| import okhttp3.RequestBody; | |
| import okhttp3.ResponseBody; | |
| import retrofit2.Converter; | |
| import retrofit2.Retrofit; |
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
| /** | |
| * Created by yh on 2016/3/21. | |
| */ | |
| public class JsonObjectConverterFactory | |
| extends Converter.Factory { | |
| /** | |
| * Create an instance using {@code gson} for conversion. Encoding to JSON and | |
| * decoding from JSON (when no charset is specified by a header) will use UTF-8. | |
| */ |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| /** | |
| * formate string with separator in fixed length index | |
| * | |
| * @param inputCardNumber | |
| * @param separator | |
| * @return | |
| */ | |
| public static String addSeparatorToString(String inputCardNumber, String separator) { | |
| int separatorLength = 4; | |
| String formattingText = inputCardNumber.replaceAll(separator, ""); |
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
| /* | |
| * Copyright (C) 2016 The Android Open Source Project | |
| * Copyright (C) 2016 Rúben Sousa | |
| * | |
| * 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 | |
| * |
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
| float offset = 0.22f * getResources().getDisplayMetrics().widthPixels; | |
| float width = getResources().getDisplayMetrics().widthPixels - offset; | |
| DrawerLayout.LayoutParams params = | |
| (android.support.v4.widget.DrawerLayout.LayoutParams) navView.getLayoutParams(); | |
| params.width = (int) width; | |
| navView.setLayoutParams(params); |
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
| Drawable arrowDrawable = ContextCompat.getDrawable(context, R.drawable.right_3x); | |
| DrawableCompat.setTint(arrowDrawable, ContextCompat.getColor(context, R.color.common_text_color_33)); | |
| moreView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, arrowDrawable, null); |
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 FlowableExample { | |
| public static void main1(String[] args) { | |
| //reduce 操作符 结果为50+1+2 | |
| Flowable<Integer> flowable = Flowable.just(1, 2); | |
| flowable.reduce(50, (t1, t2) -> { | |
| System.out.println("f1:" + t1); | |
| System.out.println("f2:" + t2); | |
| return t1 + t2; | |
| }).subscribeWith(new SingleObserver<Integer>() { |
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 | |
| } |
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) { |
OlderNewer