Skip to content

Latest commit

 

History

History
114 lines (79 loc) · 4.3 KB

File metadata and controls

114 lines (79 loc) · 4.3 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

ViewAnimationController (also referred to as KAnimationController) is an Android library that provides a fluent API for creating and managing view animations. The library simplifies complex animation sequences by providing a declarative, chainable interface for positioning, transforming, and animating Android views.

Project Structure

This is a multi-module Android project with two main modules:

  • kanimationcontroller/: The core library module containing all animation logic
  • example/: Demo application showcasing library usage

Build Configuration

  • Min SDK: 15
  • Target SDK: 25
  • Compile SDK: 25
  • Build Tools: 25.0.1
  • Android Gradle Plugin: 2.3.0

Repository Migration

This project recently migrated from JCenter to Maven Central. The root build.gradle now uses:

  • google() - for Android dependencies
  • mavenCentral() - for other dependencies

Build Commands

# Build the entire project
./gradlew build

# Build only the library module
./gradlew :kanimationcontroller:build

# Build the example app
./gradlew :example:build

# Install example app to connected device
./gradlew :example:installDebug

# Run tests
./gradlew test

# Run instrumented tests (requires connected device/emulator)
./gradlew connectedAndroidTest

# Clean build artifacts
./gradlew clean

Architecture

Core Animation System

The library uses a fluent builder pattern with three main components:

  1. BaseAnimationObject (BaseAnimationObject.java)

    • Primary API for defining animations on Android Views
    • Wraps a View and accumulates animation instructions via method chaining
    • Stores animation operations as a list of IAnimateSet objects
    • Each method (e.g., scaleX(), moveToCenterHorizontal()) adds an IAnimateSet to the internal list
    • Animations are executed when start() or startDelay() is called
  2. IAnimateSet Interface (IAnimateSet.java)

    • Contract for individual animation operations
    • Each concrete implementation represents a specific animation type (e.g., ScaleX, TransY, Alpha, Width, Height)
    • animateView(View) applies the animation to the target view
    • getValue() / setValue() allow querying and modifying animation values
  3. AnimationQueue (AnimationQueue.java)

    • Orchestrates multiple BaseAnimationObject instances
    • Two execution modes:
      • startByQueue(): Animations play sequentially, one after another
      • startTogether(): All animations play simultaneously
    • Each queue item can have an individual delay
    • Provides callbacks via AnimatedCallback interface:
      • finished(): Called when entire queue completes
      • eachQueueFinished(BaseAnimationObject): Called after each individual animation

Animation Types

The library provides concrete implementations of IAnimateSet for:

  • Position: X, Y, TransX, TransY, TransXBy, TransYBy
  • Scale: ScaleX, ScaleY
  • Rotation: RotationX, RotationY, RotationXBy, RotationYBy
  • Dimensions: Width, Height
  • Visibility: Alpha
  • Utility: Reset, Pos

Positioning System

BaseAnimationObject includes relative positioning methods that calculate coordinates based on other animation objects:

  • Alignment: moveToCenterHorizontal(), moveToCenterVertical(), goToLeft(), goToRight(), goToTop(), goToBottom()
  • Stacking: stackToLeftOf(), stackToRightOf(), stackToTopOf(), stackToBottomOf()
  • Margins: marginLeft(), marginRight(), marginTop(), marginBottom()

These methods account for scaled dimensions when calculating positions, making it easier to create responsive layouts.

Working with RelativeLayout

The README notes that RelativeLayout is "friendly" with KAnimationController, suggesting this library works best when animating views within RelativeLayout containers.

Development Notes

  • The library uses Android's built-in View.animate() ViewPropertyAnimator under the hood
  • Duration is set via setDuration() and applies to the entire animation chain
  • Custom animations can be added via addCustomAnimation(IAnimateSet)
  • The newAnimate() method creates a fresh BaseAnimationObject for the same view, clearing previous animations