Skip to content

Commit

Permalink
Prepare empty fragments for active / archived repositories
Browse files Browse the repository at this point in the history
Related: #54
  • Loading branch information
alexandr7035 committed Sep 17, 2021
1 parent 252728d commit 99293a7
Show file tree
Hide file tree
Showing 20 changed files with 271 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ class MainActivity : AppCompatActivity() {
// Dynamically change initial fragment
val navGraph = navController.navInflater.inflate(R.navigation.nav_graph)
if (token != getString(R.string.shared_pref_default_string_value)) {
// FIXME later. Debug
//navGraph.startDestination = R.id.profileFragment
navGraph.startDestination = R.id.contributionsFragment
navGraph.startDestination = R.id.profileFragment
}
else {
navGraph.startDestination = R.id.loginFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ReposFragment : Fragment() {


binding.toReposListBtn.setOnClickListener {
navController.navigate(R.id.action_reposFragment_to_repositoriesListFragment)
navController.navigate(R.id.action_reposFragment_to_repositoriesListHostFragment)
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.alexandr7035.gitstat.view.repositories

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.alexandr7035.gitstat.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [ActiveRepositoriesFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class ActiveRepositoriesFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_active_repositories, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment ActiveRepositoriesFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
ActiveRepositoriesFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.alexandr7035.gitstat.view.repositories

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.alexandr7035.gitstat.R

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
* A simple [Fragment] subclass.
* Use the [ArchivedRepositoriesFragment.newInstance] factory method to
* create an instance of this fragment.
*/
class ArchivedRepositoriesFragment : Fragment() {
// TODO: Rename and change types of parameters
private var param1: String? = null
private var param2: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
param1 = it.getString(ARG_PARAM1)
param2 = it.getString(ARG_PARAM2)
}
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_archived_repositories, container, false)
}

companion object {
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment ArchivedRepositoriesFragment.
*/
// TODO: Rename and change types and number of parameters
@JvmStatic
fun newInstance(param1: String, param2: String) =
ArchivedRepositoriesFragment().apply {
arguments = Bundle().apply {
putString(ARG_PARAM1, param1)
putString(ARG_PARAM2, param2)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alexandr7035.gitstat.view
package com.alexandr7035.gitstat.view.repositories

import android.annotation.SuppressLint
import android.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class RepositoriesFragmentsAdapter(fragment: Fragment): FragmentStateAdapter(fra
override fun createFragment(position: Int): Fragment {

val fragment = when (position) {
1 -> RepositoriesListFragment()
else -> RepositoriesListFragment()
1 -> ActiveRepositoriesFragment()
else -> ArchivedRepositoriesFragment()
}

return fragment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alexandr7035.gitstat.view
package com.alexandr7035.gitstat.view.repositories

import android.content.Context
import android.content.SharedPreferences
Expand All @@ -14,9 +14,10 @@ import com.alexandr7035.gitstat.core.App
import com.alexandr7035.gitstat.core.Language
import com.alexandr7035.gitstat.data.local.model.RepositoryEntity
import com.alexandr7035.gitstat.databinding.FragmentRepositoriesListBinding
import com.alexandr7035.gitstat.view.filters.ReposFilters
import com.alexandr7035.gitstat.view.filters.RepositoriesFiltersDialog
import com.alexandr7035.gitstat.view.filters.RepositoriesSorter
import com.alexandr7035.gitstat.view.MainViewModel
import com.alexandr7035.gitstat.view.repositories.filters.ReposFilters
import com.alexandr7035.gitstat.view.repositories.filters.RepositoriesFiltersDialog
import com.alexandr7035.gitstat.view.repositories.filters.RepositoriesSorter
import com.google.gson.Gson


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.alexandr7035.gitstat.R
import com.alexandr7035.gitstat.databinding.FragmentBaseRepositoriesListBinding
import com.alexandr7035.gitstat.databinding.FragmentHostRepositoriesListBinding
import com.google.android.material.tabs.TabLayoutMediator

class FragmentBaseRepositoriesList : Fragment() {
class RepositoriesListHostFragment : Fragment() {

private var binding: FragmentBaseRepositoriesListBinding? = null

private val PAGES_COUNT = 3
private var binding: FragmentHostRepositoriesListBinding? = null

val tabTitles = listOf(
getString(R.string.active),
getString(R.string.archived)
"Active",
"Archived"
)

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FragmentBaseRepositoriesListBinding.inflate(inflater, container, false)
binding = FragmentHostRepositoriesListBinding.inflate(inflater, container, false)
return binding!!.root
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alexandr7035.gitstat.view.filters
package com.alexandr7035.gitstat.view.repositories.filters

import android.annotation.SuppressLint
import android.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alexandr7035.gitstat.view.filters
package com.alexandr7035.gitstat.view.repositories.filters

// Defaults in the constructor
data class ReposFilters(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alexandr7035.gitstat.view.filters
package com.alexandr7035.gitstat.view.repositories.filters

import android.os.Bundle
import android.view.LayoutInflater
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alexandr7035.gitstat.view.filters
package com.alexandr7035.gitstat.view.repositories.filters

import com.alexandr7035.gitstat.data.local.model.RepositoryEntity
import java.util.*
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/background_tab.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_selected="true">
<shape>
<solid android:color="@color/gray_400"/>
<corners android:radius="10dp"/>
</shape>
</item>

<item>
<shape>
<solid android:color="@color/white"/>
<corners android:radius="10dp"/>
</shape>

</item>


</selector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/background_tablayout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<corners android:radius="10dp"/>
</shape>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_active_repositories.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="20dp"
android:clipToPadding="false"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.alexandr7035.gitstat.view.repositories.RepositoriesListFragment">

</androidx.recyclerview.widget.RecyclerView>
13 changes: 13 additions & 0 deletions app/src/main/res/layout/fragment_archived_repositories.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="20dp"
android:clipToPadding="false"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.alexandr7035.gitstat.view.repositories.RepositoriesListFragment">

</androidx.recyclerview.widget.RecyclerView>
60 changes: 60 additions & 0 deletions app/src/main/res/layout/fragment_host_repositories_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".FragmentBaseRepositoriesList">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
app:title="@string/repos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:navigationIcon="?attr/actionModeCloseDrawable"
android:background="@color/white"
android:elevation="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

<com.google.android.material.tabs.TabLayout
android:layout_marginTop="10dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:tabIndicatorHeight="0dp"
android:id="@+id/tabLayout"
android:background="@drawable/background_tablayout"
android:layout_width="0dp"
android:layout_height="30dp"
app:tabTextColor="@color/black"
app:tabSelectedTextColor="@color/white"
app:tabBackground="@drawable/background_tab"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">

<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Active"/>

<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Archived"/>

</com.google.android.material.tabs.TabLayout>

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tabLayout" />

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_repositories_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.alexandr7035.gitstat.view.RepositoriesListFragment">
tools:context="com.alexandr7035.gitstat.view.repositories.RepositoriesListFragment">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
Expand Down
20 changes: 17 additions & 3 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,31 @@
android:label="fragment_repos"
tools:layout="@layout/fragment_repos" >
<action
android:id="@+id/action_reposFragment_to_repositoriesListFragment"
app:destination="@id/repositoriesListFragment" />
android:id="@+id/action_reposFragment_to_repositoriesListHostFragment"
app:destination="@id/repositoriesListHostFragment" />
</fragment>
<fragment
android:id="@+id/repositoriesListFragment"
android:name="com.alexandr7035.gitstat.view.RepositoriesListFragment"
android:name="com.alexandr7035.gitstat.view.repositories.RepositoriesListFragment"
android:label="fragment_repositories_list"
tools:layout="@layout/fragment_repositories_list" />
<fragment
android:id="@+id/contributionsFragment"
android:name="com.alexandr7035.gitstat.view.ContributionsFragment"
android:label="fragment_contributions"
tools:layout="@layout/fragment_contributions" />
<fragment
android:id="@+id/activeRepositoriesFragment"
android:name="com.alexandr7035.gitstat.view.repositories.ActiveRepositoriesFragment"
android:label="fragment_active_repositories"
tools:layout="@layout/fragment_active_repositories" />
<fragment
android:id="@+id/archivedRepositoriesFragment"
android:name="com.alexandr7035.gitstat.view.repositories.ArchivedRepositoriesFragment"
android:label="fragment_archived_repositories"
tools:layout="@layout/fragment_archived_repositories" />
<fragment
android:id="@+id/repositoriesListHostFragment"
android:name="com.alexandr7035.gitstat.view.repositories.RepositoriesListHostFragment"
android:label="RepositoriesListHostFragment" />
</navigation>
Loading

0 comments on commit 99293a7

Please sign in to comment.