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
| fun <T> Flow<T>.throttle(waitMillis: Int) = flow { | |
| coroutineScope { | |
| val context = coroutineContext | |
| var nextMillis = 0L | |
| var delayPost: Deferred<Unit>? = null | |
| collect { | |
| val current = SystemClock.uptimeMillis() | |
| if (nextMillis < current) { | |
| nextMillis = current + waitMillis |
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 com.example.rzagorski.coordinatorawareautocompletetextviewapp; | |
| import android.content.Context; | |
| import android.support.annotation.Nullable; | |
| import android.support.design.widget.CoordinatorLayout; | |
| import android.support.design.widget.Snackbar; | |
| import android.support.v7.widget.AppCompatAutoCompleteTextView; | |
| import android.util.AttributeSet; | |
| import android.view.View; | |
| import android.view.ViewGroup; |
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
| @Override | |
| public boolean fling(int velocityX, int velocityY) { | |
| LinearLayoutManager linearLayoutManager = (LinearLayoutManager) getLayoutManager(); | |
| //these four variables identify the views you see on screen. | |
| int lastVisibleView = linearLayoutManager.findLastVisibleItemPosition(); | |
| int firstVisibleView = linearLayoutManager.findFirstVisibleItemPosition(); | |
| View firstView = linearLayoutManager.findViewByPosition(firstVisibleView); | |
| View lastView = linearLayoutManager.findViewByPosition(lastVisibleView); |
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 CustomLayout extends LinearLayout { | |
| @SuppressWarnings("unchecked") @Override public Parcelable onSaveInstanceState() { | |
| Parcelable saveInstanceState = super.onSaveInstanceState(); | |
| SavedState savedState = new SavedState(saveInstanceState); | |
| savedState.childrenStates = new SparseArray(); | |
| for (int i = 0; i < getChildCount(); i++) { | |
| getChildAt(i).saveHierarchyState(savedState.childrenStates); | |
| } | |
| return savedState; |
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
| /** | |
| * This would be the activity which registers the receiver class via it's interface | |
| */ | |
| public class MainActivity implements NetworkStateReceiver.NetworkStateReceiverListener { | |
| private NetworkStateReceiver networkStateReceiver; // Receiver that detects network state changes | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| /***/ |
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.content.Context | |
| import android.support.annotation.IntRange | |
| import android.support.v7.widget.LinearLayoutManager | |
| import android.support.v7.widget.OrientationHelper | |
| import android.support.v7.widget.RecyclerView | |
| import android.util.AttributeSet | |
| import android.view.View | |
| class PreloadLinearLayoutManager(context: Context?, |
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.util.HashMap | |
| import java.util.LinkedHashSet | |
| open class TwoQCache<K, V>(maxSize: Int) { | |
| private val map: HashMap<K, V> = HashMap(0, 0.75f) |
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 com.furkantektas.braingames.ui; | |
| import android.content.Context; | |
| import android.content.res.TypedArray; | |
| import android.support.v7.widget.CardView; | |
| import android.util.AttributeSet; | |
| import com.furkantektas.braingames.R; | |
| /** |
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.util.HashMap; | |
| import java.util.LinkedHashMap; | |
| import java.util.Map; | |
| import android.os.SystemClock; | |
| public class TimeExpiringLruCache<K, V> { | |
| private final LinkedHashMap<K, V> map; | |
| private final HashMap<K, Long> validityTime; |
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
| -- Remove the history from | |
| rm -rf .git | |
| -- recreate the repos from the current content only | |
| git init && git add . && git status | |
| git commit -m "Initial commit" | |
| -- push to the github remote repos ensuring you overwrite history | |
| git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git | |
| git push -u --force origin master |
NewerOlder