Skip to content

Instantly share code, notes, and snippets.

@Elvis10ten
Created November 24, 2017 12:20
Show Gist options
  • Save Elvis10ten/d47ed85ec63f9048682d5da6bf805ecb to your computer and use it in GitHub Desktop.
Save Elvis10ten/d47ed85ec63f9048682d5da6bf805ecb to your computer and use it in GitHub Desktop.
package com.mobymagic.shazamclone.utils
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
object FragmentUtils {
fun addIfNotExist(fm: FragmentManager, containerRes: Int, fragment: Fragment, tag: String) {
val existingFragmentWithTag = fm.findFragmentByTag(tag)
if(existingFragmentWithTag == null) {
fm.beginTransaction().add(containerRes, fragment, tag).commit()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment