Skip to content

Instantly share code, notes, and snippets.

View Elvis10ten's full-sized avatar

Elvis Chidera Elvis10ten

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/discoverFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mobymagic.shazamclone.discover.DiscoverActivity" />
package com.mobymagic.shazamclone.discover
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.mobymagic.shazamclone.R
package com.mobymagic.shazamclone.discover
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.mobymagic.shazamclone.R
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/discoverFragmentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mobymagic.shazamclone.discover.DiscoverFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
override fun onCreate(savedInstanceState: Bundle?) {
...
FragmentUtils.addIfNotExist(supportFragmentManager, R.id.discoverFragmentContainer,
DiscoverFragment(), "DiscoverFragment")
}
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)
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/discoverFragmentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
tools:context="com.mobymagic.shazamclone.discover.DiscoverFragment">
<!-- SpinKit is just a progress view. We want it to show below every other view in this layout.
package com.mobymagic.shazamclone.discover
import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.click
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.isDisplayed
import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.filters.LargeTest
import android.support.test.rule.ActivityTestRule
import android.support.test.runner.AndroidJUnit4
import com.mobymagic.shazamclone.R
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/songDetailFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mobymagic.shazamclone.songdetail.SongDetailActivity" />
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/historyFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mobymagic.shazamclone.history.HistoryActivity"/>