Skip to content

Instantly share code, notes, and snippets.

👑
Solving Problems

Jemshit Iskenderov jemshit

👑
Solving Problems
Block or report user

Report or block jemshit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jemshit
jemshit / MediaPlayerStateMachine.kt
Last active Aug 15, 2019
Android MediaPlayer has internal state of its own, but there is no get method for it. State diagram is here: https://developer.android.com/images/mediaplayer_state_diagram.gif. Invocation of method that is not allowed at current state results in exception. To avoid such exception and track states of MediaPlayer, MediaPlayerStateMachine is writte…
View MediaPlayerStateMachine.kt
import android.util.Log
fun emptyMPStateMachineLogger(tag: String, message: String) {
// NoOp
}
fun defaultMPStateMachineLogger(tag: String, message: String) {
Log.d(tag, message)
}
@jemshit
jemshit / AndroidResourceProvider.kt
Last active Mar 18, 2019
Android Resource Provider for Presenter in MVP
View AndroidResourceProvider.kt
import android.content.Context
import android.support.annotation.*
import android.support.v4.content.ContextCompat
import interface_adapters.ResourceProvider
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Singleton
@Singleton
class AndroidResourceProvider
View ColdReactiveDataExpiration.java
import com.jakewharton.rxrelay2.BehaviorRelay;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observable;
import java.util.concurrent.TimeUnit;
public class ColdReactiveDataExpiration {
// Problems to solve:
// 1- UI components should be notified when data is updated
View HotReactiveDataExpiration.java
import com.jakewharton.rx.ReplayingShare;
import com.jakewharton.rxrelay2.PublishRelay;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observable;
import java.util.concurrent.TimeUnit;
public class HotReactiveDataExpiration {
// Problems to solve:
View HotReactiveData.java
import com.jakewharton.rx.ReplayingShare;
import com.jakewharton.rxrelay2.PublishRelay;
import com.jakewharton.rxrelay2.Relay;
import io.reactivex.Observable;
import java.util.concurrent.TimeUnit;
public class HotReactiveData {
// Problems to solve:
@jemshit
jemshit / flavor_names_build.gradle
Created Mar 27, 2017 — forked from keyboardsurfer/flavor_names_build.gradle
Version names for application variants
View flavor_names_build.gradle
android {
applicationVariants.all { variant ->
def flavor = variant.mergedFlavor
def name = flavor.getVersionName()
def versionName = name + '-' + variant.properties.get('flavorName')
if (variant.buildType.isDebuggable()) {
versionName += '-debug';
}
flavor.versionName = versionName;
}
@jemshit
jemshit / BaseFragment.java
Created Dec 1, 2016
Do something when Fragment is visible
View BaseFragment.java
public class BaseFragment extends Fragment {
private boolean fragmentResume=false;
private boolean fragmentVisible=false;
private boolean fragmentOnCreated=false;
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
@jemshit
jemshit / proguard-rules.pro
Last active Oct 22, 2019
Proguard rules for common Android libraries
View proguard-rules.pro
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
### RxJava, RxAndroid (https://gist.github.com/kosiara/487868792fbd3214f9c9)
-keep class rx.schedulers.Schedulers {
public static <methods>;
@jemshit
jemshit / .bash_profile
Last active Oct 26, 2018
Custom .bash_profile for MacOs
View .bash_profile
#### cd to the path of the front Finder window
cdf() {
target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'`
if [ "$target" != "" ]; then
cd "$target"; pwd
else
echo 'No Finder window found' >&2
fi
}
@jemshit
jemshit / README.md
Created Sep 15, 2016 — forked from joyrexus/README.md
curl tutorial
View README.md

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

You can’t perform that action at this time.