Skip to content
Snippets Groups Projects
Commit 46dc597a authored by John Carlson's avatar John Carlson
Browse files

ref_name changed to ref with v4

parent 00c8de40
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -17,7 +17,7 @@ interface GitLabService {
 
companion object {
const val API_VERSION = "api/v4"
const val TREE_PER_PAGE = "100"
const val MAX_TREE_PER_PAGE = "100"
}
 
/* --- LOGIN --- */
Loading
Loading
@@ -290,9 +290,9 @@ interface GitLabService {
@GET(API_VERSION + "/projects/{id}/repository/contributors")
fun getContributors(@Path("id") projectId: String): Single<List<Contributor>>
 
@GET(API_VERSION + "/projects/{id}/repository/tree?per_page=" + TREE_PER_PAGE)
@GET(API_VERSION + "/projects/{id}/repository/tree?per_page=" + MAX_TREE_PER_PAGE)
fun getTree(@Path("id") projectId: Long,
@Query("ref_name") branchName: String?,
@Query("ref") ref: String?,
@Query("path") path: String?): Single<List<RepositoryTreeObject>>
 
@GET(API_VERSION + "/projects/{id}/repository/files/{file_path}")
Loading
Loading
Loading
Loading
@@ -38,6 +38,8 @@ open class BaseFragment : RxFragment() {
}
 
inner class EventReceiver {
@Suppress("unused", "UNUSED_PARAMETER")
@Subscribe
fun onReloadData(event: ReloadDataEvent) {
loadData()
Loading
Loading
Loading
Loading
@@ -52,7 +52,7 @@ class FilesFragment : ButterKnifeFragment() {
lateinit var adapterBreadcrumb: BreadcrumbAdapter
 
var project: Project? = null
var branchName: String? = null
lateinit var ref: String
var currentPath = ""
 
val filesAdapterListener = object : FileAdapter.Listener {
Loading
Loading
@@ -62,25 +62,25 @@ class FilesFragment : ButterKnifeFragment() {
 
override fun onFileClicked(treeItem: RepositoryTreeObject) {
val path = currentPath + treeItem.name
Navigator.navigateToFile(activity, project!!.id, path, branchName!!)
Navigator.navigateToFile(activity, project!!.id, path, ref)
}
 
override fun onCopyClicked(treeItem: RepositoryTreeObject) {
val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
 
// Creates a new text clip to put on the clipboard
val clip = ClipData.newPlainText(treeItem.name, treeItem.getUrl(project!!, branchName!!, currentPath).toString())
val clip = ClipData.newPlainText(treeItem.name, treeItem.getUrl(project!!, ref, currentPath).toString())
clipboard.primaryClip = clip
Snackbar.make(root, R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT)
.show()
}
 
override fun onShareClicked(treeItem: RepositoryTreeObject) {
IntentUtil.share(view!!, treeItem.getUrl(project!!, branchName!!, currentPath))
IntentUtil.share(view!!, treeItem.getUrl(project!!, ref, currentPath))
}
 
override fun onOpenInBrowserClicked(treeItem: RepositoryTreeObject) {
IntentUtil.openPage(activity as BaseActivity, treeItem.getUrl(project!!, branchName!!, currentPath).toString(), App.get().currentAccount)
IntentUtil.openPage(activity as BaseActivity, treeItem.getUrl(project!!, ref, currentPath).toString(), App.get().currentAccount)
}
}
 
Loading
Loading
@@ -91,8 +91,6 @@ class FilesFragment : ButterKnifeFragment() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
 
App.bus().register(this)
adapterFiles = FileAdapter(filesAdapterListener)
list.layoutManager = LinearLayoutManager(activity)
list.addItemDecoration(DividerItemDecoration(activity))
Loading
Loading
@@ -106,11 +104,13 @@ class FilesFragment : ButterKnifeFragment() {
 
if (activity is ProjectActivity) {
project = (activity as ProjectActivity).project
branchName = (activity as ProjectActivity).getRefRef()
ref = (activity as ProjectActivity).getRefRef()!!
loadData("")
} else {
throw IllegalStateException("Incorrect parent activity")
}
App.bus().register(this)
}
 
override fun onBackPressed(): Boolean {
Loading
Loading
@@ -131,22 +131,20 @@ class FilesFragment : ButterKnifeFragment() {
}
 
override fun loadData() {
loadData(currentPath)
}
 
fun loadData(newPath: String) {
if (view == null) {
return
}
 
if (project == null || branchName.isNullOrEmpty()) {
if (project == null || ref.isNullOrEmpty()) {
swipeRefreshLayout.isRefreshing = false
return
}
 
swipeRefreshLayout.isRefreshing = true
 
App.get().gitLab.getTree(project!!.id, branchName!!, newPath)
App.get().gitLab.getTree(project!!.id, ref, newPath)
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomSingleObserver<List<RepositoryTreeObject>>() {
 
Loading
Loading
@@ -209,10 +207,11 @@ class FilesFragment : ButterKnifeFragment() {
}
 
 
@Suppress("unused")
@Subscribe
fun onProjectReload(event: ProjectReloadEvent) {
project = event.project
branchName = event.branchName
ref = event.branchName
 
loadData("")
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment