parent
6687ce099d
commit
3b47bb7e7f
@ -0,0 +1,11 @@
|
|||||||
|
package fr.uca.iut.clfreville2.teaiswarm
|
||||||
|
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.network.GiteaService
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.network.RepositoryService
|
||||||
|
|
||||||
|
object TeaIsWarm {
|
||||||
|
|
||||||
|
val service: RepositoryService by lazy {
|
||||||
|
GiteaService()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package fr.uca.iut.clfreville2.teaiswarm.fragment
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.R
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.REPOSITORY_NAME
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.REPOSITORY_OWNER
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.TeaIsWarm
|
||||||
|
import fr.uca.iut.clfreville2.teaiswarm.model.RepositoryIdentifier
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
class CodeViewFragment : Fragment(R.layout.code_view_fragment) {
|
||||||
|
|
||||||
|
private lateinit var content: TextView
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val service = TeaIsWarm.service
|
||||||
|
val bundle = requireArguments()
|
||||||
|
val repository = RepositoryIdentifier(
|
||||||
|
bundle.getString(REPOSITORY_OWNER)!!,
|
||||||
|
bundle.getString(REPOSITORY_NAME)!!
|
||||||
|
)
|
||||||
|
content = view.findViewById(R.id.code_content_view)
|
||||||
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
|
val contents = service.retrieveFileContents(repository, bundle.getString(FILE_PATH)!!)
|
||||||
|
content.text = contents.content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
package fr.uca.iut.clfreville2.teaiswarm.model
|
||||||
|
|
||||||
|
data class FileContent(val type: FileType, val size: Int, val content: String, val last_commit_sha: String)
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/code_content_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in new issue