Skip to content

Feature/28 adding navigation screen of repository content by tabs #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
android:screenOrientation="portrait"
android:name=".issuelist.IssueListActivity_" />

<activity
android:label="@string/app_name"
android:screenOrientation="portrait"
android:name=".repodetails.RepoDetailsActivity_" />

<meta-data
android:name="io.fabric.ApiKey"
android:value="e31ee77a076b044cb52e3fedbad573fac9b5ee96" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PullRequestListActivity : AppCompatActivity(), PullRequestListView {

recyclerView.layoutManager = layoutManager
recyclerView.setHasFixedSize(true)
//

setupViewModel()

viewModel.loadPullRequestList(owner, repoName)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package br.com.luisfernandez.github.client.repodetails


import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import br.com.luisfernandez.github.client.R

class BranchesFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.fragment_branches, container, false)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package br.com.luisfernandez.github.client.repodetails


import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import br.com.luisfernandez.github.client.R

class CollaboratorsFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.fragment_collaborators, container, false)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package br.com.luisfernandez.github.client.repodetails


import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import br.com.luisfernandez.github.client.R

class CommitsFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.fragment_commits, container, false)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package br.com.luisfernandez.github.client.repodetails


import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import br.com.luisfernandez.github.client.R

class IssuesFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.fragment_issues, container, false)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package br.com.luisfernandez.github.client.repodetails


import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import br.com.luisfernandez.github.client.R

class PullRequestsFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.fragment_pull_requests, container, false)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package br.com.luisfernandez.github.client.repodetails

import android.annotation.SuppressLint
import android.support.v7.app.AppCompatActivity
import br.com.luisfernandez.github.client.R
import kotlinx.android.synthetic.main.activity_repo_details.*
import org.androidannotations.annotations.AfterViews
import org.androidannotations.annotations.EActivity
import org.androidannotations.annotations.Extra

@SuppressLint("Registered")
@EActivity(R.layout.activity_repo_details)
class RepoDetailsActivity : AppCompatActivity() {

@Extra
lateinit var owner: String

@Extra
lateinit var repoName: String

@AfterViews
fun afterViews() {
this.configToolbar()

val fragmentAdapter = RepoDetailsPagerAdapter(supportFragmentManager)
repo_detail_viewpager.adapter = fragmentAdapter

repo_detail_tablayout.setupWithViewPager(repo_detail_viewpager)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideal é seguir o padrão de nomenclatura de ids nas views:
buttonSubmit
ao invés de
submit_button

}

private fun configToolbar() {
setSupportActionBar(toolbar)
supportActionBar?.let {
title = repoName
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.setDisplayShowTitleEnabled(true)
}
}

override fun onSupportNavigateUp(): Boolean {
onBackPressed()
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package br.com.luisfernandez.github.client.repodetails

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter

class RepoDetailsPagerAdapter(fm: FragmentManager):
FragmentPagerAdapter(fm) {

override fun getCount(): Int {
return 5
}

override fun getItem(position: Int): Fragment {
return when(position) {
0 -> PullRequestsFragment()
1 -> IssuesFragment()
2 -> CommitsFragment()
3 -> CollaboratorsFragment()
4 -> BranchesFragment()

else -> PullRequestsFragment()
}
}

override fun getPageTitle(position: Int): CharSequence? {
return when(position){
0 -> "PullRequests"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Será que não faria mais sentido adicionarmos esses textos no arquivo de strings?

1 -> "Issues"
2 -> "Commits"
3 -> "Collaborators"
4 -> "Branches"

else -> "PullRequests"
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import br.com.luisfernandez.github.client.http.model.ServerError
import br.com.luisfernandez.github.client.issuelist.IssueListActivity_
import br.com.luisfernandez.github.client.pojo.Repo
import br.com.luisfernandez.github.client.pullrequest.PullRequestListActivity_
import br.com.luisfernandez.github.client.repodetails.RepoDetailsActivity_
import com.crashlytics.android.answers.Answers
import com.crashlytics.android.answers.SearchEvent
import com.miguelcatalan.materialsearchview.MaterialSearchView
Expand Down Expand Up @@ -128,7 +129,7 @@ class RepoListActivity : AppCompatActivity(), RepoListView {
private fun getOnItemClickListener(): OnItemClickListener<Repo> {
return object : OnItemClickListener<Repo> {
override fun onItemClick(type: Repo) {
goToPullRequestActivity(type)
goToRepoDetailsActivity(type)
}
}
}
Expand Down Expand Up @@ -165,6 +166,14 @@ class RepoListActivity : AppCompatActivity(), RepoListView {
.start()
}

private fun goToRepoDetailsActivity(type: Repo) {
RepoDetailsActivity_
.intent(this@RepoListActivity)
.owner(type.owner.login)
.repoName(type.name)
.start()
}

private fun loadMoreContent() {
[email protected] = true
recyclerView.post { repoListAdapter.showFooter() }
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/res/layout/activity_repo_details.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:animateLayoutChanges="true">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/AppTheme.AppBarOverlay" />

<android.support.design.widget.TabLayout
android:id="@+id/repo_detail_tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
android:layout_below="@+id/toolbar"/>

<android.support.v4.view.ViewPager
android:id="@+id/repo_detail_viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"
android:layout_below="@+id/repo_detail_tablayout"/>

</RelativeLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_branches.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".repodetails.BranchesFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="Conteúdo da aba Branches"
android:gravity="center"/>

</RelativeLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_collaborators.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".repodetails.CollaboratorsFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="Conteúdo da aba Collaborators"
android:gravity="center"/>

</RelativeLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_commits.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".repodetails.CommitsFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="Conteúdo da aba Commits"
android:gravity="center"/>

</RelativeLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_issues.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".repodetails.IssuesFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="Conteúdo da aba Issues"
android:gravity="center"/>

</RelativeLayout>
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_pull_requests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".repodetails.PullRequestsFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="24sp"
android:text="Conteúdo da aba PullRequests"
android:gravity="center"/>

</RelativeLayout>