Skip to content

Instantly share code, notes, and snippets.

View dyguests's full-sized avatar
:octocat:
٩(˃̶͈̀௰˂̶͈́)و

fanhl dyguests

:octocat:
٩(˃̶͈̀௰˂̶͈́)و
  • ChengDu.China
View GitHub Profile
@dyguests
dyguests / Test.md
Created March 31, 2017 08:44
Test Gist

#Test

just for test.

@dyguests
dyguests / BottomNavigationAttachViewPagerHelper.java
Last active April 11, 2017 13:08
BottomNavigationAttachViewPagerHelper,BottomNavigation,ViewPager
package com.fanhl.hbookerauthor.util;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.view.ViewPager;
/**
* BottomNavigationView Attach ViewPager Helper
*
* Created by fanhl on 2017/4/11.
*/
@dyguests
dyguests / README.md
Created April 25, 2017 11:41
android ViewUtil

android ViewUtil

@dyguests
dyguests / RxLiveData.kt
Created November 13, 2017 05:47
RxJava2 + LiveData
package com.fanhl.architecturedemo.rxjava2
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.MutableLiveData
import com.fanhl.architecturedemo.extensions.observe
import io.reactivex.Observable
/**
* desc:
* date: 2017/11/13
@dyguests
dyguests / StockTrading.java
Created November 20, 2017 06:28
see {http://www.jianshu.com/p/ba2db41cc1c9?utm_campaign=maleskine&utm_content=note&utm_medium=pc_all_hots&utm_source=recommendation} 规则: 一只股票,上午9时开盘,下午16点收盘,每个时间点对应一个价格。 1.当天什么时间买入,什么时间卖出可获得最大利润。 2.只能买卖一次(额外规则) 3.相同利润下时间段最短的优先
/**
* see {http://www.jianshu.com/p/ba2db41cc1c9?utm_campaign=maleskine&utm_content=note&utm_medium=pc_all_hots&utm_source=recommendation}
* 规则:
* 一只股票,上午9时开盘,下午16点收盘,每个时间点对应一个价格。
* 1.当天什么时间买入,什么时间卖出可获得最大利润。
* 2.只能买卖一次(额外规则)
* 3.相同利润下时间段最短的优先
*
* @author fanhl
*/
@dyguests
dyguests / seize_focus.xml
Created December 14, 2017 09:07
抢占焦点,防止页面初次进入时EditText唤起软键盘。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--防止页面刚加载出来时EditText获得焦点-->
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:focusable="true"
@dyguests
dyguests / build.gradle
Created October 11, 2018 02:20
kotlin 生成依赖库 并保留源码
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 2
versionName "1.0.1"
@dyguests
dyguests / ItemOffsetsDecoration.kt
Last active October 12, 2018 01:16
RecyclerView custom divider.
headerView.rv_vote_option.addItemDecoration(object : RecyclerView.ItemDecoration() {
val space = 10.px
override fun getItemOffsets(outRect: Rect?, view: View?, parent: RecyclerView?, state: RecyclerView.State?) {
if (parent?.getChildAdapterPosition(view) ?: 0 != voteOptions.size - 1) {
outRect?.set(0, 0, 0, space)
}
}
})
@dyguests
dyguests / RemoveEditTextFocusActivity.md
Last active October 20, 2018 07:04
EditText, clear focus on touch outside

EditText, clear focus on touch outside

Put it in your Activity and it'll apply to all EditTexts including those within fragments within that activity.

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        View v = getCurrentFocus();
        if ( v instanceof EditText) {

Rect outRect = new Rect();

@dyguests
dyguests / FindWithTag.cs
Created October 28, 2018 15:09
Unity get self instance in scene.
public static PlayerController FindWithTag()
{
var playerController = GameObject.FindWithTag(Tags.Player).GetComponent<PlayerController>();
if (playerController == null)
{
throw new Exception("playerController not found.");
}
return playerController;
}