diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..6b7301e --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,60 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +apply plugin: 'kotlin-kapt' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.rifqimfahmi.foorballapps" + minSdkVersion 17 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + + implementation "com.google.android.material:material:$rootProject.material" + + // Coroutine + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutine" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutine" + + // Retrofit + implementation "com.squareup.retrofit2:retrofit:$rootProject.retrofit" + implementation "com.squareup.retrofit2:converter-moshi:$rootProject.retrofit" + implementation "com.squareup.moshi:moshi-kotlin:$rootProject.moshi" + implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$rootProject.retrofit_coroutine_adapter" + + // Network image loader + implementation "com.squareup.picasso:picasso:$rootProject.picasso" + + // room + implementation "androidx.room:room-runtime:$rootProject.room_version" + kapt "androidx.room:room-compiler:$rootProject.room_version" + testImplementation "androidx.room:room-testing:$rootProject.room_version" + + // Lifecycle + implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycle_version" + kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.lifecycle_version" + testImplementation "androidx.arch.core:core-testing:$rootProject.lifecycle_version" +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/rifqimfahmi/foorballapps/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/rifqimfahmi/foorballapps/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..3cc8585 --- /dev/null +++ b/app/src/androidTest/java/com/rifqimfahmi/foorballapps/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.rifqimfahmi.foorballapps + +import androidx.test.InstrumentationRegistry +import androidx.test.runner.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("com.rifqimfahmi.foorballapps", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..352072d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/ViewModelFactory.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/ViewModelFactory.kt new file mode 100644 index 0000000..a01b503 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/ViewModelFactory.kt @@ -0,0 +1,45 @@ +package com.rifqimfahmi.foorballapps + +import android.app.Application +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import com.rifqimfahmi.foorballapps.data.source.SportRepository +import com.rifqimfahmi.foorballapps.data.source.local.SportDb +import com.rifqimfahmi.foorballapps.data.source.remote.SportServiceFactory +import com.rifqimfahmi.foorballapps.features.matches.MatchesViewModel + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +class ViewModelFactory private constructor( + private val application: Application, + private val sportRepository: SportRepository +) : ViewModelProvider.NewInstanceFactory() { + override fun create(modelClass: Class): T = + with(modelClass) { + when { + isAssignableFrom(MatchesViewModel::class.java) -> + MatchesViewModel(application, sportRepository) + else -> + error("Invalid View Model class") + } + } as T + + companion object { + @Volatile + private var INSTANCE: ViewModelFactory? = null + + fun getInstance(application: Application): ViewModelFactory { + return INSTANCE ?: synchronized(ViewModelFactory::class.java) { + ViewModelFactory( + application, + SportRepository.getInstance( + SportDb.getDatabase(application.applicationContext).sportDao(), + SportServiceFactory.getService() + ) + ).also { INSTANCE = it } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/custom/NonSwipeAbleViewPager.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/custom/NonSwipeAbleViewPager.kt new file mode 100644 index 0000000..2be4289 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/custom/NonSwipeAbleViewPager.kt @@ -0,0 +1,19 @@ +package com.rifqimfahmi.foorballapps.custom + +import android.annotation.SuppressLint +import android.content.Context +import android.util.AttributeSet +import android.view.MotionEvent +import androidx.viewpager.widget.ViewPager + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class NonSwipeAbleViewPager(context: Context, attrs: AttributeSet?) : ViewPager(context, attrs) { + + @SuppressLint("ClickableViewAccessibility") + override fun onTouchEvent(ev: MotionEvent?): Boolean = false + + override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean = false +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/SportRepository.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/SportRepository.kt new file mode 100644 index 0000000..3bdf209 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/SportRepository.kt @@ -0,0 +1,24 @@ +package com.rifqimfahmi.foorballapps.data.source + +import com.rifqimfahmi.foorballapps.data.source.local.SportDao +import com.rifqimfahmi.foorballapps.data.source.remote.SportService + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class SportRepository ( + val sportDb: SportDao, + val sportService: SportService +) { + + companion object { + private var INSTANCE: SportRepository? = null + + fun getInstance(sportDb: SportDao, sportService: SportService) : SportRepository = + INSTANCE ?: synchronized(SportRepository::class.java) { + SportRepository(sportDb, sportService) + .also { INSTANCE = it } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/local/SportDao.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/local/SportDao.kt new file mode 100644 index 0000000..96285dc --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/local/SportDao.kt @@ -0,0 +1,17 @@ +package com.rifqimfahmi.foorballapps.data.source.local + +import androidx.room.Dao +import androidx.room.Query +import com.rifqimfahmi.foorballapps.vo.Match + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +@Dao +interface SportDao { + + @Query("SELECT * FROM matches") + fun getMatches(): List + +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/local/SportDb.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/local/SportDb.kt new file mode 100644 index 0000000..a15b482 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/local/SportDb.kt @@ -0,0 +1,31 @@ +package com.rifqimfahmi.foorballapps.data.source.local + +import android.content.Context +import androidx.room.Database +import androidx.room.Room +import androidx.room.RoomDatabase +import com.rifqimfahmi.foorballapps.vo.Match + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ +@Database(entities = [Match::class], version = 2) +abstract class SportDb : RoomDatabase() { + + abstract fun sportDao(): SportDao + + companion object { + + @Volatile + private var INSTANCE: SportDb? = null + + fun getDatabase(context: Context) : SportDb { + return INSTANCE ?: synchronized(this) { + Room.databaseBuilder(context.applicationContext, SportDb::class.java, "sport_db") + .fallbackToDestructiveMigration() + .build() + .also { INSTANCE = it } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/remote/SportService.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/remote/SportService.kt new file mode 100644 index 0000000..5a8b297 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/remote/SportService.kt @@ -0,0 +1,9 @@ +package com.rifqimfahmi.foorballapps.data.source.remote + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +interface SportService { + +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/remote/SportServiceFactory.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/remote/SportServiceFactory.kt new file mode 100644 index 0000000..c828c29 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/data/source/remote/SportServiceFactory.kt @@ -0,0 +1,32 @@ +package com.rifqimfahmi.foorballapps.data.source.remote + +import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory +import retrofit2.Retrofit +import retrofit2.converter.moshi.MoshiConverterFactory + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +class SportServiceFactory { + companion object { + + @Volatile + private var INSTANCE: SportService? = null + + private const val BASE_URL = "https://www.thesportsdb.com/api/v1/json/1/" + + fun getService() : SportService { + return INSTANCE ?: synchronized(this) { + val instance = Retrofit.Builder() + .baseUrl(BASE_URL) + .addConverterFactory(MoshiConverterFactory.create()) + .addCallAdapterFactory(CoroutineCallAdapterFactory()) + .build() + .create(SportService::class.java) + INSTANCE = instance + instance + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/FavoritesFragment.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/FavoritesFragment.kt new file mode 100644 index 0000000..dbed73b --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/FavoritesFragment.kt @@ -0,0 +1,35 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import com.rifqimfahmi.foorballapps.R +import com.rifqimfahmi.foorballapps.features.matches.adapter.FavoritesPagerAdapter +import kotlinx.android.synthetic.main.fragment_favorites.* + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class FavoritesFragment : Fragment() { + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.fragment_favorites, container, false) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setupViewPager() + } + + private fun setupViewPager() { + vpFavorites.adapter = FavoritesPagerAdapter(childFragmentManager) + tabFavorites.setupWithViewPager(vpFavorites) + } + + companion object { + fun newInstance() = FavoritesFragment() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/FavoritesListFragment.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/FavoritesListFragment.kt new file mode 100644 index 0000000..9edcc93 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/FavoritesListFragment.kt @@ -0,0 +1,29 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.LinearLayoutManager +import com.rifqimfahmi.foorballapps.R +import kotlinx.android.synthetic.main.list_items.* + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class FavoritesListFragment : Fragment() { + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.list_items, container, false) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + } + + companion object { + fun newInstance() = FavoritesListFragment() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesActivity.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesActivity.kt new file mode 100644 index 0000000..8e0aee7 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesActivity.kt @@ -0,0 +1,39 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.os.Bundle +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.lifecycle.Observer +import com.rifqimfahmi.foorballapps.R +import com.rifqimfahmi.foorballapps.data.source.local.SportDb +import com.rifqimfahmi.foorballapps.features.matches.adapter.MainPagerAdapter +import com.rifqimfahmi.foorballapps.util.obtainViewModel +import kotlinx.android.synthetic.main.activity_matches.* + +class MatchesActivity : AppCompatActivity() { + + private lateinit var viewModel: MatchesViewModel + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_matches) + + setSupportActionBar(tb_main) + + tb_main.setTitle(R.string.app_name) + vpMain.adapter = MainPagerAdapter(supportFragmentManager) + btmNavMain.setOnNavigationItemSelectedListener { + when (it.itemId) { + R.id.matches -> vpMain.setCurrentItem(0, false) + R.id.teams -> vpMain.setCurrentItem(1, false) + R.id.favorites -> vpMain.setCurrentItem(2, false) + } + true + } + + viewModel = obtainViewModel() + } + + fun obtainViewModel(): MatchesViewModel = obtainViewModel(MatchesViewModel::class.java) +} diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesFragment.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesFragment.kt new file mode 100644 index 0000000..bd28dde --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesFragment.kt @@ -0,0 +1,53 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.os.Bundle +import android.view.* +import android.widget.AdapterView +import androidx.fragment.app.Fragment +import com.rifqimfahmi.foorballapps.R +import com.rifqimfahmi.foorballapps.features.matches.adapter.MatchesPagerAdapter +import kotlinx.android.synthetic.main.fragment_matches.* +import kotlinx.android.synthetic.main.fragment_matches.view.* + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class MatchesFragment : Fragment(), AdapterView.OnItemSelectedListener { + + private lateinit var viewModel: MatchesViewModel + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.fragment_matches, container, false).also { + viewModel = (activity as MatchesActivity).obtainViewModel() + it.sp_leagues.onItemSelectedListener = this + } + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setHasOptionsMenu(true) + setupViewPager() + } + + private fun setupViewPager() { + vpMatches.adapter = MatchesPagerAdapter(childFragmentManager) + tabMatches.setupWithViewPager(vpMatches) + } + + override fun onNothingSelected(parent: AdapterView<*>?) { + } + + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { + viewModel.setFilterBy(position) + } + + override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { + super.onCreateOptionsMenu(menu, inflater) + inflater?.inflate(R.menu.main_menu, menu) + } + + companion object { + fun newInstance() = MatchesFragment() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesListFragment.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesListFragment.kt new file mode 100644 index 0000000..01a3651 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesListFragment.kt @@ -0,0 +1,49 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.os.Bundle +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Toast +import androidx.fragment.app.Fragment +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager +import com.rifqimfahmi.foorballapps.R +import com.rifqimfahmi.foorballapps.features.matches.adapter.MatchesRVAdapter +import kotlinx.android.synthetic.main.list_items.* +import kotlinx.android.synthetic.main.list_items.view.* + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class MatchesListFragment : Fragment() { + + private lateinit var viewModel: MatchesViewModel + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.list_items, container, false).also { view -> + viewModel = (activity as MatchesActivity).obtainViewModel() + viewModel.apply { + filterLeague.observe(parentFragment as MatchesFragment, Observer { + + }) + } + } + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setupList() + } + + private fun setupList() { + rv_list.adapter = MatchesRVAdapter() + rv_list.layoutManager = LinearLayoutManager(context) + } + + companion object { + fun newInstance() = MatchesListFragment() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesViewModel.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesViewModel.kt new file mode 100644 index 0000000..aeafb1a --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/MatchesViewModel.kt @@ -0,0 +1,25 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.app.Application +import android.content.Context +import androidx.lifecycle.AndroidViewModel +import androidx.lifecycle.MutableLiveData +import com.rifqimfahmi.foorballapps.R +import com.rifqimfahmi.foorballapps.data.source.SportRepository + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +class MatchesViewModel(context: Application, sportRepository: SportRepository) : AndroidViewModel(context) { + + // LiveData for league categories + val filterLeague = MutableLiveData() + + val context: Context = context.applicationContext // application Context to avoid leaks + + fun setFilterBy(position: Int) { + filterLeague.value = context.resources.getStringArray(R.array.leagues)[position] + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/TeamsFragment.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/TeamsFragment.kt new file mode 100644 index 0000000..bf5f509 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/TeamsFragment.kt @@ -0,0 +1,32 @@ +package com.rifqimfahmi.foorballapps.features.matches + +import android.os.Bundle +import android.view.* +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.Fragment +import com.rifqimfahmi.foorballapps.R + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class TeamsFragment : Fragment() { + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.fragment_teams, container, false) + } + + override fun onActivityCreated(savedInstanceState: Bundle?) { + super.onActivityCreated(savedInstanceState) + setHasOptionsMenu(true) + } + + override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { + super.onCreateOptionsMenu(menu, inflater) + inflater?.inflate(R.menu.main_menu, menu) + } + + companion object { + fun newInstance() = TeamsFragment() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/FavoritesPagerAdapter.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/FavoritesPagerAdapter.kt new file mode 100644 index 0000000..9bf7ce1 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/FavoritesPagerAdapter.kt @@ -0,0 +1,32 @@ +package com.rifqimfahmi.foorballapps.features.matches.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter +import com.rifqimfahmi.foorballapps.features.matches.FavoritesListFragment + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class FavoritesPagerAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm) { + + override fun getItem(position: Int): Fragment { + return when (position) { + 0 -> FavoritesListFragment.newInstance() + 1 -> FavoritesListFragment.newInstance() + else -> error("Cannot create more than two fragment") + } + } + + override fun getPageTitle(position: Int): CharSequence? { + return when (position) { + 0 -> "MATCHES" + 1 -> "TEAMS" + else -> super.getPageTitle(position) + } + } + + override fun getCount(): Int = 2 + +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MainPagerAdapter.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MainPagerAdapter.kt new file mode 100644 index 0000000..68867ce --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MainPagerAdapter.kt @@ -0,0 +1,25 @@ +package com.rifqimfahmi.foorballapps.features.matches.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter +import com.rifqimfahmi.foorballapps.features.matches.FavoritesFragment +import com.rifqimfahmi.foorballapps.features.matches.MatchesFragment +import com.rifqimfahmi.foorballapps.features.matches.TeamsFragment + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class MainPagerAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm) { + override fun getItem(position: Int): Fragment { + return when(position) { + 0 -> MatchesFragment.newInstance() + 1 -> TeamsFragment.newInstance() + 2 -> FavoritesFragment.newInstance() + else -> error("Cannot place more than 3 fragments") + } + } + + override fun getCount(): Int = 3 +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MatchesPagerAdapter.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MatchesPagerAdapter.kt new file mode 100644 index 0000000..8cee3a4 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MatchesPagerAdapter.kt @@ -0,0 +1,32 @@ +package com.rifqimfahmi.foorballapps.features.matches.adapter + +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentManager +import androidx.fragment.app.FragmentPagerAdapter +import com.rifqimfahmi.foorballapps.features.matches.MatchesListFragment + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class MatchesPagerAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm) { + + override fun getItem(position: Int): Fragment { + return when (position) { + 0 -> MatchesListFragment.newInstance() + 1 -> MatchesListFragment.newInstance() + else -> error("Cannot create more than two fragment") + } + } + + override fun getPageTitle(position: Int): CharSequence? { + return when (position) { + 0 -> "NEXT" + 1 -> "LAST" + else -> super.getPageTitle(position) + } + } + + override fun getCount(): Int = 2 + +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MatchesRVAdapter.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MatchesRVAdapter.kt new file mode 100644 index 0000000..1346463 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/features/matches/adapter/MatchesRVAdapter.kt @@ -0,0 +1,32 @@ +package com.rifqimfahmi.foorballapps.features.matches.adapter + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.rifqimfahmi.foorballapps.R + +/* + * Created by Rifqi Mulya Fahmi on 19/11/18. + */ + +class MatchesRVAdapter( + +) : RecyclerView.Adapter() { + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MatchItemHolder { + val view = LayoutInflater.from(parent.context).inflate(R.layout.item_match, parent, false) + return MatchItemHolder(view) + } + + override fun getItemCount(): Int { + return 10 + } + + override fun onBindViewHolder(holder: MatchItemHolder, position: Int) { + } + + inner class MatchItemHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/util/AppCompatExt.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/util/AppCompatExt.kt new file mode 100644 index 0000000..96cb51b --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/util/AppCompatExt.kt @@ -0,0 +1,13 @@ +package com.rifqimfahmi.foorballapps.util + +import androidx.appcompat.app.AppCompatActivity +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProviders +import com.rifqimfahmi.foorballapps.ViewModelFactory + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +fun AppCompatActivity.obtainViewModel(viewModelClass: Class) = + ViewModelProviders.of(this, ViewModelFactory.getInstance(application)).get(viewModelClass) \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Match.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Match.kt new file mode 100644 index 0000000..9b2ab6f --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Match.kt @@ -0,0 +1,15 @@ +package com.rifqimfahmi.foorballapps.vo + +import androidx.room.Entity +import androidx.room.PrimaryKey + +/* + * Created by Rifqi Mulya Fahmi on 26/11/18. + */ + +@Entity(tableName = "matches") +data class Match ( + @PrimaryKey val name: String +) { + +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Resource.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Resource.kt new file mode 100644 index 0000000..a6e58af --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Resource.kt @@ -0,0 +1,21 @@ +package com.rifqimfahmi.foorballapps.vo + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +data class Resource(val status: Status, val data: T?, val message: String?) { + companion object { + fun success(data: T?): Resource { + return Resource(Status.SUCCESS, data, null) + } + + fun error(msg: String, data: T?): Resource { + return Resource(Status.ERROR, data, msg) + } + + fun loading(data: T?): Resource { + return Resource(Status.LOADING, data, null) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Status.kt b/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Status.kt new file mode 100644 index 0000000..6de0216 --- /dev/null +++ b/app/src/main/java/com/rifqimfahmi/foorballapps/vo/Status.kt @@ -0,0 +1,11 @@ +package com.rifqimfahmi.foorballapps.vo + +/* + * Created by Rifqi Mulya Fahmi on 21/11/18. + */ + +enum class Status { + SUCCESS, + ERROR, + LOADING +} \ No newline at end of file diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_favorites.xml b/app/src/main/res/drawable/ic_favorites.xml new file mode 100644 index 0000000..a87ca09 --- /dev/null +++ b/app/src/main/res/drawable/ic_favorites.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..a0ad202 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_matches.xml b/app/src/main/res/drawable/ic_matches.xml new file mode 100644 index 0000000..e9f85c8 --- /dev/null +++ b/app/src/main/res/drawable/ic_matches.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..be5ad99 --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_teams.xml b/app/src/main/res/drawable/ic_teams.xml new file mode 100644 index 0000000..4cfd869 --- /dev/null +++ b/app/src/main/res/drawable/ic_teams.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_matches.xml b/app/src/main/res/layout/activity_matches.xml new file mode 100644 index 0000000..0998a89 --- /dev/null +++ b/app/src/main/res/layout/activity_matches.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_favorites.xml b/app/src/main/res/layout/fragment_favorites.xml new file mode 100644 index 0000000..dff4ca6 --- /dev/null +++ b/app/src/main/res/layout/fragment_favorites.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_matches.xml b/app/src/main/res/layout/fragment_matches.xml new file mode 100644 index 0000000..e14f1d9 --- /dev/null +++ b/app/src/main/res/layout/fragment_matches.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_teams.xml b/app/src/main/res/layout/fragment_teams.xml new file mode 100644 index 0000000..531def7 --- /dev/null +++ b/app/src/main/res/layout/fragment_teams.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_match.xml b/app/src/main/res/layout/item_match.xml new file mode 100644 index 0000000..19f87ed --- /dev/null +++ b/app/src/main/res/layout/item_match.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/list_items.xml b/app/src/main/res/layout/list_items.xml new file mode 100644 index 0000000..b7f8b33 --- /dev/null +++ b/app/src/main/res/layout/list_items.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_navigation_menu.xml b/app/src/main/res/menu/bottom_navigation_menu.xml new file mode 100644 index 0000000..1980140 --- /dev/null +++ b/app/src/main/res/menu/bottom_navigation_menu.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml new file mode 100644 index 0000000..a3d1be2 --- /dev/null +++ b/app/src/main/res/menu/main_menu.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..898f3ed Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dffca36 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..64ba76f Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..dae5e08 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e5ed465 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..14ed0af Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d8ae031 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2c18de9 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..beed3cd Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..bf66ca8 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,11 @@ + + + #00796b + #004c40 + #00796b + + #EEF0F2 + #FEFEFE + + #80FFFFFF + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..2685883 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,108 @@ + + Football Apps + Matches + Teams + Favorites + Search + + + English Premier League + English League Championship + Scottish Premier League + German Bundesliga + Italian Serie A + French Ligue 1 + Spanish La Liga + Greek Superleague Greece + Dutch Eredivisie + Belgian Jupiler League + Turkish Super Lig + Danish Superliga + Portuguese Primeira Liga + American Major League Soccer + Swedish Allsvenskan + Mexican Primera League + Brazilian Brasileirao + Ukrainian Premier League + Russian Football Premier League + Australian A-League + Eliteserien + Chinese Super League + _No League + Italian Serie B + Scottish Championship + English League 1 + English League 2 + Italian Lega Pro + German 2. Bundesliga + Spanish Adelante + French Ligue 2 + Swedish Superettan + Brazilian Brasileirao Serie B + Argentinian Primera Division + Polish Ekstraklasa + FIFA World Cup + Uruguayan Primera Division + American NASL + Norwegian 1. Divisjon + Welsh Premier League + UEFA Champions League + UEFA Europa League + FA Cup + Copa del Rey + Coupe de France + DFB-Pokal + UEFA Nations League + + + + 4328 + 4329 + 4330 + 4331 + 4332 + 4334 + 4335 + 4336 + 4337 + 4338 + 4339 + 4340 + 4344 + 4346 + 4347 + 4350 + 4351 + 4354 + 4355 + 4356 + 4358 + 4359 + 4367 + 4394 + 4395 + 4396 + 4397 + 4398 + 4399 + 4400 + 4401 + 4403 + 4404 + 4406 + 4422 + 4429 + 4432 + 4435 + 4457 + 4472 + 4480 + 4481 + 4482 + 4483 + 4484 + 4485 + 4490 + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..bdfe33e --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/com/rifqimfahmi/foorballapps/ExampleUnitTest.kt b/app/src/test/java/com/rifqimfahmi/foorballapps/ExampleUnitTest.kt new file mode 100644 index 0000000..b512f3f --- /dev/null +++ b/app/src/test/java/com/rifqimfahmi/foorballapps/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.rifqimfahmi.foorballapps + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..6bffdc1 --- /dev/null +++ b/build.gradle @@ -0,0 +1,37 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +ext { + coroutine = "1.0.0" + retrofit = "2.4.0" + moshi = "1.7.0" + retrofit_coroutine_adapter = "0.9.2" + picasso = "2.71828" + material = "1.0.0" + room_version = "2.1.0-alpha02" + lifecycle_version = "2.0.0" +} + +buildscript { + ext.kotlin_version = '1.3.0' + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..3d8ce0c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +android.useAndroidX=true +android.enableJetifier=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..9a4163a --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'