Search code examples
androidfirebaseandroid-activityfirebase-realtime-databaseandroid-actionbar-compat

How to modify Action Bar buttons based on a specific Condition in a certain Activity


I am developing an android application using the firebase quickstart code samples. My app is an E- Auction app, there are three tabs shown to the user Fixed Price , Auction and My Listing. The first two tabs contains the posts by all the community in the respective category either fixed price or up for auction.
The My Listing tab contains the posts that the user has posted. The Posts appear in a card view. If a post is clicked an activity starts where the entire post is detailed. I want to show a delete icon in the action bar of detailed view activity such that the delete icon is visible only if the currently logged in user is viewing his own post. That is, the ability to delete a post should reside with the user only. I am using firebase for database. I have setup the delete process but I need to link it with this functionality.

Please Help


Solution

  • A quick solution would be to attach each user's uid to their post then compare it to that of the current user when retrieved.

    if(post_uid==current_uid){
    showdelete();
    }