-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/30 migrate issuelist to a fragment tab #31
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
n2oliver
wants to merge
16
commits into
luisfernandezbr:develop
Choose a base branch
from
n2oliver:feature/30-migrate-issuelist-to-a-fragment-tab
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c673a37
Adding feature of issues listing
n2oliver 5fb20f7
Merge remote-tracking branch 'origin/feature/23-adding-feature-of-iss…
n2oliver 095fa3c
Adding activity RepoDetailsActivity and its layout and changing the d…
n2oliver 2188639
Adding navigation up support to toolbar and fixing the relative layou…
n2oliver 5aa866b
Creating and addin RepoDetailsPagerAdapter to repo_detail_viewpager, …
n2oliver 6903b05
Removing the default text string of fragments
n2oliver 718dcd3
Adding funcionalities from IssueListActivity to the IssuesFragment. O…
d0bd97f
Fixing return of IssuesFragment.kt to fix the visibility of the fragment
n2oliver ba86bf2
Removing toolbar from activity_issues_list (that will be the fragment…
n2oliver 5811119
Renaming IssuesFragment to IssuesListFragment and activity_issues_lis…
n2oliver bd27a7f
Removing access to IssueListActivity and access function of PullReque…
n2oliver 83586b6
Optimizing imports from RepoListActivity
n2oliver e52f250
Removing not used fragment.
c21643a
Renaming TabLayout and ViewPager components
20a08e7
Tranferring titles to string resources and getting them by applicatio…
4384a55
Creating companion object to store constants on RepoDetailsPagerAdapt…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/java/br/com/luisfernandez/github/client/repodetails/BranchesFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
|
||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/br/com/luisfernandez/github/client/repodetails/CollaboratorsFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
|
||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/br/com/luisfernandez/github/client/repodetails/CommitsFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
|
||
} |
124 changes: 124 additions & 0 deletions
124
app/src/main/java/br/com/luisfernandez/github/client/repodetails/IssuesListFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package br.com.luisfernandez.github.client.repodetails | ||
|
||
import android.arch.lifecycle.Observer | ||
import android.os.Bundle | ||
import android.support.v4.app.Fragment | ||
import android.support.v7.widget.LinearLayoutManager | ||
import android.support.v7.widget.RecyclerView | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import br.com.luisfernandez.github.client.R | ||
import br.com.luisfernandez.github.client.extensions.setGone | ||
import br.com.luisfernandez.github.client.extensions.setVisible | ||
import br.com.luisfernandez.github.client.http.model.GitHubErrorBody | ||
import br.com.luisfernandez.github.client.http.model.ServerError | ||
import br.com.luisfernandez.github.client.issuelist.IssueListAdapter | ||
import br.com.luisfernandez.github.client.issuelist.IssueListView | ||
import br.com.luisfernandez.github.client.issuelist.IssueListViewModel | ||
import br.com.luisfernandez.github.client.pojo.IssueResponse | ||
import br.com.luisfernandez.github.client.repodetails.RepoDetailsPagerAdapter.Companion.OWNER | ||
import br.com.luisfernandez.github.client.repodetails.RepoDetailsPagerAdapter.Companion.REPONAME | ||
import kotlinx.android.synthetic.main.fragment_issues_list.* | ||
import kotlinx.android.synthetic.main.view_state_empty.* | ||
import kotlinx.android.synthetic.main.view_state_error.* | ||
import kotlinx.android.synthetic.main.view_state_loading.* | ||
import org.koin.android.viewmodel.ext.android.viewModel | ||
|
||
class IssuesListFragment : Fragment(), IssueListView { | ||
|
||
lateinit var owner: String | ||
lateinit var repoName: String | ||
val viewModel by viewModel<IssueListViewModel>() | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
|
||
val rootView = inflater.inflate(R.layout.fragment_issues_list, container, false) | ||
|
||
val recyclerView = rootView.findViewById(R.id.recyclerView) as RecyclerView | ||
|
||
recyclerView.layoutManager = LinearLayoutManager(rootView.context) | ||
recyclerView.setHasFixedSize(true) | ||
|
||
setupArguments() | ||
|
||
setupViewModel() | ||
|
||
viewModel.loadIssueList(owner, repoName) | ||
|
||
return rootView | ||
|
||
} | ||
|
||
private fun setupArguments() { | ||
owner = arguments!!.getString(OWNER) | ||
repoName = arguments!!.getString(REPONAME) | ||
} | ||
|
||
private fun setupViewModel() { | ||
viewModel.issueList.observe(this, Observer { | ||
issueList -> | ||
showContent(issueList!!) | ||
}) | ||
|
||
viewModel.serverError.observe(this, Observer { | ||
serverError -> | ||
handleError(serverError!!) | ||
}) | ||
} | ||
|
||
override fun handleError(serverError: ServerError<GitHubErrorBody>) { | ||
this.showErrorState() | ||
|
||
if (serverError.errorBody != null) { | ||
textErrorMessage.text = serverError.errorBody!!.message | ||
} else { | ||
textErrorMessage.text = serverError.errorMessage | ||
} | ||
|
||
buttonRetry.setOnClickListener { _ -> | ||
showLoading() | ||
viewModel.loadIssueList(owner, repoName) | ||
} | ||
} | ||
|
||
private fun showErrorState() { | ||
layoutProgress.setGone() | ||
layoutEmpty.setGone() | ||
layoutError.setVisible() | ||
recyclerView.setGone() | ||
} | ||
|
||
override fun showLoading() { | ||
layoutProgress.setVisible() | ||
layoutEmpty.setGone() | ||
layoutError.setGone() | ||
recyclerView.setGone() | ||
} | ||
|
||
override fun showEmpty() { | ||
layoutProgress.setGone() | ||
layoutEmpty.setVisible() | ||
layoutError.setGone() | ||
recyclerView.setGone() | ||
} | ||
|
||
override fun showContent(content: List<IssueResponse>) { | ||
if (content.isEmpty()) { | ||
showEmpty() | ||
} else { | ||
layoutProgress.setGone() | ||
layoutEmpty.setGone() | ||
layoutError.setGone() | ||
recyclerView.setVisible() | ||
|
||
recyclerView.adapter = this.getIssueListAdapter(content) | ||
} | ||
} | ||
|
||
private fun getIssueListAdapter(content: List<IssueResponse>): IssueListAdapter { | ||
return IssueListAdapter( | ||
content as ArrayList<IssueResponse> | ||
) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/br/com/luisfernandez/github/client/repodetails/PullRequestsFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
|
||
} |
45 changes: 45 additions & 0 deletions
45
app/src/main/java/br/com/luisfernandez/github/client/repodetails/RepoDetailsActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(this, supportFragmentManager, owner, repoName) | ||
viewPagerRepoDetail.adapter = fragmentAdapter | ||
|
||
tabLayoutRepoDetail.setupWithViewPager(viewPagerRepoDetail) | ||
} | ||
|
||
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 | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
app/src/main/java/br/com/luisfernandez/github/client/repodetails/RepoDetailsPagerAdapter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package br.com.luisfernandez.github.client.repodetails | ||
|
||
import android.content.Context | ||
import android.support.v4.app.Fragment | ||
import android.support.v4.app.FragmentManager | ||
import android.support.v4.app.FragmentPagerAdapter | ||
import android.os.Bundle | ||
import br.com.luisfernandez.github.client.R | ||
|
||
class RepoDetailsPagerAdapter(private val context: Context, fm: FragmentManager, owner: String, repoName: String): | ||
FragmentPagerAdapter(fm) { | ||
|
||
companion object { | ||
const val OWNER = "OWNER" | ||
const val REPONAME = "REPONAME" | ||
} | ||
|
||
val owner = owner | ||
val repoName = repoName | ||
|
||
override fun getCount(): Int { | ||
return 5 | ||
} | ||
|
||
override fun getItem(position: Int): Fragment { | ||
val bundle = Bundle() | ||
bundle.putString(OWNER, owner) | ||
bundle.putString(REPONAME, repoName) | ||
|
||
var fragment = when(position) { | ||
0 -> PullRequestsFragment() | ||
1 -> IssuesListFragment() | ||
2 -> CommitsFragment() | ||
3 -> CollaboratorsFragment() | ||
4 -> BranchesFragment() | ||
|
||
else -> PullRequestsFragment() | ||
} | ||
|
||
fragment.arguments = bundle | ||
|
||
return fragment | ||
} | ||
|
||
override fun getPageTitle(position: Int): CharSequence? { | ||
return when(position){ | ||
0 -> context.getString(R.string.titlePullRequestsTab) | ||
1 -> context.getString(R.string.titleIssuesTab) | ||
2 -> context.getString(R.string.titleCommitsTab) | ||
3 -> context.getString(R.string.titleCollaboratorsTab) | ||
4 -> context.getString(R.string.titleBranchesTab) | ||
|
||
else -> context.getString(R.string.titlePullRequestsTab) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acho que isso pode dar problemas nos casos de onRestoreInstance(). Vamos aguardar após o merge e testamos juntos.