Skip to content

Conversation

Copy link

Copilot AI commented Aug 7, 2025

This PR implements row click listener functionality for the RecyclerView TableView, enabling users to interact with table rows for editing or other actions as requested in the issue.

Changes Made

1. Added OnRowClickListener Interface

Created a clean callback interface that provides both the clicked movie data and its position:

interface OnRowClickListener {
    fun onRowClick(movie: MovieModel, position: Int)
}

2. Enhanced TableViewAdapter

  • Added setOnRowClickListener() method to register click callbacks
  • Implemented selective click handling - only content rows are clickable
  • Header row is explicitly protected from clicks to prevent confusion
  • Click listener provides complete movie data and position for easy integration
// Content rows get click listeners
itemView.setOnClickListener {
    onRowClickListener?.onRowClick(modal, rowPos - 1)
}

// Header row is protected
itemView.setOnClickListener(null)
itemView.isClickable = false

3. Updated MainActivity

  • Implements the OnRowClickListener interface
  • Demonstrates functionality with detailed Toast messages showing clicked row information
  • Includes TODO comments for easy integration with edit activities

Usage Example

val adapter = TableViewAdapter(movieList)
adapter.setOnRowClickListener { movie, position ->
    // Start edit activity
    startActivity(Intent(this, EditMovieActivity::class.java).apply {
        putExtra("movie_data", movie)
        putExtra("position", position)
    })
}

Key Features

  • Minimal impact: Only 39 lines added across 2 files, no breaking changes
  • Selective interaction: Header row protected, only data rows are clickable
  • Complete data access: Callback provides both movie object and list position
  • Integration ready: Designed for seamless connection to edit activities
  • Optional functionality: TableView works normally with or without click listener

The implementation follows Android best practices and maintains the existing table structure while adding the requested user interaction capability.

Fixes #5.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Author

Copilot AI commented Aug 7, 2025

@monsterbrain 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits August 7, 2025 12:05
Co-authored-by: monsterbrain <10105094+monsterbrain@users.noreply.github.com>
Co-authored-by: monsterbrain <10105094+monsterbrain@users.noreply.github.com>
Copilot AI changed the title [WIP] ClickListener Add row click listener functionality to TableView for user interaction Aug 7, 2025
Copilot AI requested a review from monsterbrain August 7, 2025 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClickListener

2 participants