Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
Focusing

Mert Şimşek iammert

🎧
Focusing
View GitHub Profile
@iammert
iammert / BottomBackStackController.kt
Last active Sep 29, 2021
Multiple Back Stack Controller + Navigation Component (Instagram-like backstack)
View BottomBackStackController.kt
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.util.Stack
import kotlin.collections.HashMap
class BottomBackStackController {
View NewIntentProcessor.java
public class NewIntentProcessor extends AbstractProcessor {
private static final String METHOD_PREFIX = "start";
private static final ClassName classIntent = ClassName.get("android.content", "Intent");
private static final ClassName classContext = ClassName.get("android.content", "Context");
private Filer filer;
private Messager messager;
private Elements elements;
private Map<String, String> activitiesWithPackage;
@iammert
iammert / callback.kt
Last active Jan 10, 2021
croutine_intro
View callback.kt
api.fetchUser(object: Callback{
fun onResponse(userInfo: UserInfo){
userTextView.text = userInfo.name
}
})
View FileUtils.java
public class FileUtil {
public static File getPickedPictureFile(Context context, Uri selectedImage) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, selectedImage)) {
// ExternalStorageProvider
if (isExternalStorageDocument(selectedImage)) {
View diff.java
public void updateList(ArrayList<Person> newList) {
DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new MyDiffCallback(this.persons, newList));
diffResult.dispatchUpdatesTo(this);
}
View RawCertificatePinner.java
public final class RawCertificatePinner implements OkHttpCertificatePinner{
private static final String CERTIFICATE_TYPE = "BKS";
private static final String DEFAULT_TLS_VERSION = "TLSv1.2";
private final Context context;
@RawRes
private final int certificate;
private final String certificatePassword;
@iammert
iammert / NetworkBoundSource.java
Created Jul 11, 2017
NetworkBoundSource.java
View NetworkBoundSource.java
public abstract class NetworkBoundSource<LocalType, RemoteType> {
public NetworkBoundSource(FlowableEmitter<Resource<LocalType>> emitter) {
Disposable firstDataDisposable = getLocal()
.map(Resource::loading)
.subscribe(emitter::onNext);
getRemote().map(mapper())
.subscribeOn(Schedulers.newThread())
.observeOn(Schedulers.newThread())
@iammert
iammert / dependency.gradle
Last active Aug 27, 2019
dependency.gradle
View dependency.gradle
//Room
archComponentVersion = "1.0.0-alpha3"
archRoom = "android.arch.persistence.room:runtime:$archComponentVersion"
archRoomCompiler = "android.arch.persistence.room:compiler:$archComponentVersion"
archRoomRx = "android.arch.persistence.room:rxjava2:$archComponentVersion"
archLifeCycleReactiveStreams = "android.arch.lifecycle:reactivestreams:$archComponentVersion"
//RxJava & RxAndroid
View MyDiffCallback.java
public class MyDiffCallback extends DiffUtil.Callback{
List<Person> oldPersons;
List<Person> newPersons;
public MyDiffCallback(List<Person> newPersons, List<Person> oldPersons) {
this.newPersons = newPersons;
this.oldPersons = oldPersons;
}
@iammert
iammert / gist:faa6cd996c752dcfb10a
Created Sep 16, 2015
update gitignore already commited
View gist:faa6cd996c752dcfb10a
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
git push origin master