Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want the users to see their profile button if they are logged then they should see "sign out" and if they are not logged then they should see "Follow" but its not working as per the code.Here is my code

if(uid == currentUserUid){
    //MyPage
    fragmentView?.account_btn_follow_signout?.text = getString(R.string.signout)
    fragmentView?.account_btn_follow_signout?.setOnClickListener {
        activity?.finish()
        startActivity(Intent(activity,MainActivity::class.java))
        auth?.signOut()
        }
}
if (uid!=currentUserUid){
    //OtherUserPage
    fragmentView?.account_btn_follow_signout?.text = getString(R.string.follow)
    fragmentView?.account_btn_follow_signout?.setOnClickListener {
        requestFollow()
    }

}


What I have tried:

I am trying to show the logged user "sign out" text and the other users "Follow" text
Posted
Comments
David Crow 17-Jul-20 10:44am    
So when you step through the code using the debugger, what happens?
Member 14883729 18-Jul-20 7:18am    
Sorry I not noticed my problem properly. My actual problem is I am making an app like instagram where the users can upload their pics so I made a profile fragment where the users can find their posts and no. of followers. But when I open my profile fragment its not showing me anything according to my code but if I navigate to other users account then I am getting to see their posts , no. of followers etc. So my problem is why I can not find those things in my own profile fragment
David Crow 18-Jul-20 15:06pm    
Set a breakpoint on the if(uid == currentUserUid) statement to find out why it's not evaluating to true.
Member 14883729 18-Jul-20 15:41pm    
Sorry actually I am new to kotlin and android studio so I don't know how to do that. Can u show that code
David Crow 18-Jul-20 22:21pm    
1) Run ==> Toggle Line Breakpoint
2) Run ==> Run app
3) When the breakpoint is hit, see what the value of uid and currentUserUid are.

Is this code that you actually wrote?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900