-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Description:
The app currently uses findViewById for view access, which is less performant and more error-prone than ViewBinding.
Current State:
- findViewById calls throughout activities
- Manual view casting and null checks
- Potential for runtime crashes if view IDs change
Benefits of ViewBinding:
- Type Safety: Generated classes ensure correct view types
- Null Safety: Only views that exist in layout are accessible
- Performance: No findViewById lookups at runtime
- IDE Support: Better autocomplete and refactoring
Fix Instructions:
- Enable ViewBinding in build.gradle:
android {
buildFeatures {
viewBinding = true
}
}- Update activities to use ViewBinding:
class ModernPOSActivity : AppCompatActivity() {
private lateinit var binding: ActivityModernPosBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityModernPosBinding.inflate(layoutInflater)
setContentView(binding.root)
// Access views via binding
binding.amountDisplay.text = "Amount"
binding.submitButton.setOnClickListener { ... }
}
}Migration Strategy:
- Start with new activities/fragments
- Gradually migrate existing ones
- Keep both approaches during transition
Priority: Medium - improves performance and safety
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog