0% found this document useful (0 votes)
5 views5 pages

Professor Profile Management in Android

The document is a Kotlin class for an Android activity named ProfProfileActivity, which manages the profile of a professor. It includes functionalities for displaying the professor's information, handling profile picture changes, and retrieving lessons authored by the professor from a Firestore database. The activity utilizes various UI components and libraries, such as Glide for image loading and RecyclerView for displaying a list of lessons.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Professor Profile Management in Android

The document is a Kotlin class for an Android activity named ProfProfileActivity, which manages the profile of a professor. It includes functionalities for displaying the professor's information, handling profile picture changes, and retrieving lessons authored by the professor from a Firestore database. The activity utilizes various UI components and libraries, such as Glide for image loading and RecyclerView for displaying a list of lessons.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package [Link].

ui

import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link].*
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link].R
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import [Link].*

class ProfProfileActivity : AppCompatActivity() {

lateinit var lessonRecyclerView: RecyclerView


lateinit var latestLessonsAdapter: LatestLessonsAdapter
lateinit var inputPicForLessons: LinearLayout
lateinit var userProfilePic: ImageView
var isprofileImagecChanged = false

private var selectedImage: Uri? = null


lateinit var uploadedImage: ImageView

lateinit var profProfilePicture: ImageView

private lateinit var auth: FirebaseAuth


private lateinit var db: FirebaseFirestore
private var currentUser: FirebaseUser? = null

// Les informations des profs


lateinit var profName: TextView

private val TAG = "ProfProfileActivity"


override fun onCreate(savedInstanceState: Bundle?) {
[Link](savedInstanceState)
setContentView([Link].activity_prof_profile)

val userUuid1 = intent?.getStringExtra("userUuid1")


val intentedUserId = intent?.getStringExtra("intentedUserId")

supportActionBar?.setDisplayHomeAsUpEnabled(true)

profProfilePicture = findViewById([Link].iv_prof_profile_pic)
userProfilePic = findViewById([Link].iv_user_profil_pic)
profName = findViewById([Link].tv_prof_name)

auth = [Link]
db = [Link]
currentUser = [Link]

val userImageFromIntent = [Link]("userProfilePhoto")


[Link](this).load(userImageFromIntent).into(profProfilePicture)

//TODO: essaie de fixer d'autres conditions ici

val pickUpProfileImage =
registerForActivityResult([Link]()){
[Link] {
selectedImage = it
[Link](this).load(selectedImage).into(profProfilePicture)
isprofileImagecChanged = true
}
}

[Link] {
[Link]("image/*")
}

setUpLessonRecyclerView()

if (intentedUserId != currentUser!!.uid){
if (intentedUserId != null) {
[Link]("users").document(intentedUserId)
.get()
.addOnSuccessListener {result->
if (result != null){
var user = [Link](User::[Link])
user?.let {
[Link] = intentedUserId
setDestinationUserInfos(user)
}
}
}
}
}else{
[Link]("users").document(currentUser!!.uid)
.get()
.addOnSuccessListener {result->
if (result != null){
var user = [Link](User::[Link])
user?.let {
[Link] = currentUser!!.uid
setDestinationUserInfos(user)
}
}
}
}

// Affichage des informations du destinationUser ou TargetUser -


IntentedUser
if (currentUser != null){
if (userUuid1 != null) {

[Link]("users").document(userUuid1).get().addOnSuccessListener {result->
if (result != null){
var user = [Link](User::[Link])
user?.let {
[Link] = currentUser!!.uid
setProfInfos(user)
}
}
}
}
}

private val lessons = mutableListOf<Lesson>()


private fun setUpLessonRecyclerView() {

lessonRecyclerView = findViewById([Link].rv_latest_publication_lessons)
latestLessonsAdapter = LatestLessonsAdapter(lessons)
[Link] {
layoutManager = LinearLayoutManager(this@ProfProfileActivity)
adapter = latestLessonsAdapter
}
}

private fun setDestinationUserInfos(user: User) {


supportActionBar?.title = [Link]
[Link] = [Link]

// Mise en place de l'image de profile de l'utilisateur


if ([Link] == "Femme"){

[Link](this).load([Link]).placeholder([Link].avatar_user_woman).into(pr
ofProfilePicture)

[Link](this).load([Link]).placeholder([Link].avatar_user_woman).into(us
erProfilePic)
} else {
[Link](this).load([Link]).placeholder([Link].avatar_user_man).into(prof
ProfilePicture)

[Link](this).load([Link]).placeholder([Link].avatar_user_man).into(user
ProfilePic)
}

[Link]("users").document([Link])
.get()
.addOnSuccessListener { documentSnapshot ->
val userName = [Link]("fullname")
[Link]("lessons")
.whereEqualTo("author", userName)
.get()
.addOnSuccessListener { documents ->
for (document in documents) {
val author = [Link]("author")
val content = [Link]("content")
val image = [Link]("image")
val title = [Link]("title")
[Link](Lesson(author?: "", title?:"", image?:"",
content?:""))
}
[Link] = lessons
}
}

private fun setProfInfos(user: User) {


supportActionBar?.title = [Link]
[Link] = [Link]

// Mise en place de l'image de profile de l'utilisateur


if ([Link] == "Femme"){

[Link](this).load([Link]).placeholder([Link].avatar_user_woman).into(pr
ofProfilePicture)

[Link](this).load([Link]).placeholder([Link].avatar_user_woman).into(us
erProfilePic)
} else {

[Link](this).load([Link]).placeholder([Link].avatar_user_man).into(prof
ProfilePicture)

[Link](this).load([Link]).placeholder([Link].avatar_user_man).into(user
ProfilePic)
}

//TODO: même resultat, tjrs problème non résolu. Y'a que deux items dans le
recyclerView
val sentQuery = [Link]("lessons")
.whereEqualTo("author", [Link])
.orderBy("title", [Link])
[Link] { snapshot, exception ->
if (exception != null){
Log.e("ProfProfileActivity", "Error getting lessons")
return@addSnapshotListener
}
for (document in snapshot!!.documents){
var lesson = [Link](Lesson::[Link])
lesson?.let {
if (![Link](lesson)){
[Link](lesson)
}
if([Link]()){
[Link] = lessons
}
}
}
}
}

override fun onResume() {


[Link]()

if (selectedImage != null){
Log.d("imageInProfProfile", [Link]())
Intent(this, ProfilePictureChangedActivity::[Link]).also {
[Link]("selectedImage", [Link]())
startActivity(it)
}
finish()
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when ([Link]) {
[Link] -> {
// Naviguer vers l'activité parente en utilisant NavUtils
Intent(this, MainActivity::[Link]).also {
startActivity(it)
}
return true
}
}
return [Link](item)
}

You might also like