modular-views

An attempt at the modularization of Views to handle touch/draw delegation between registerable modules.

Лицензия

Лицензия

Группа

Группа

com.guardanis
Идентификатор

Идентификатор

modular-views
Последняя версия

Последняя версия

1.0.8
Дата

Дата

Тип

Тип

aar
Описание

Описание

modular-views
An attempt at the modularization of Views to handle touch/draw delegation between registerable modules.
Ссылка на сайт

Ссылка на сайт

https://github.com/mattsilber/modular-views
Система контроля версий

Система контроля версий

https://github.com/mattsilber/modular-views.git

Скачать modular-views

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.guardanis/modular-views/ -->
<dependency>
    <groupId>com.guardanis</groupId>
    <artifactId>modular-views</artifactId>
    <version>1.0.8</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.guardanis/modular-views/
implementation 'com.guardanis:modular-views:1.0.8'
// https://jarcasting.com/artifacts/com.guardanis/modular-views/
implementation ("com.guardanis:modular-views:1.0.8")
'com.guardanis:modular-views:aar:1.0.8'
<dependency org="com.guardanis" name="modular-views" rev="1.0.8">
  <artifact name="modular-views" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.guardanis', module='modular-views', version='1.0.8')
)
libraryDependencies += "com.guardanis" % "modular-views" % "1.0.8"
[com.guardanis/modular-views "1.0.8"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

modular-views

Download

I'm tired of creating custom Views when I want to draw something on the Canvas and/or handling touch events. This is an attempt at solving that by registering modularized components that can each handle those delegations.

Installation

    repositories {
        mavenCentral()
    }

    dependencies {
        compile('com.guardanis:modular-views:1.0.8')
    }

ModularView

A ModularView (or one of the other base View classes) contains a ModularController and contains helper methods for registering/unregistering the ViewModule components.

Implemented ModularView types

  • ModularView
  • ModularImageView
  • ModularTextView

ViewModule

The base ViewModule is what child components must extend in order to be implemented. The ModularController then handles the delegation of touch and drawing events to all of its children.

The default behavior of the ModularController for errors during onTouch(View, MotionEvent) and draw(Canvas) is to log the Exception and continue. My personal opinion is that I'd rather a rendering failure than a flat out crash by some meaningless edgecase.

AnimationModule

The AnimationModule is a special-case ViewModule that implements Runnable and handles most of heavy lifting for the animation. Children must override onAnimationUpdate() to change the data, and call onAnimationCompleted() once the animation has finished.

Calling start() or start(AnimationEventListener) will start the animation Thread. The AnimationEventListener you pass in with the call to start will be triggered on the View's thread during onAnimationCompleted().

ShatterModule

The ShatterModule is an example AnimationModule to showcase what can actually be done with modularization.

ModularImageView v = (ModularImageView)findViewById(R.id.some_modular_view);
v.registerModule(new ShatterModule());

v.getModule(ShatterModule.class).start();

Drawing order

By default, there is no ordering to the drawing calls except that AnimationModules are drawn after ViewModules. If you want to explicitly set the ordering (including mixing AnimationModules behind ViewModule layers), you need to call setDrawingPrioritiesOrder(List) or setDrawingPrioritiesOrder(Class[]) on the controller (or use the helper methods of the same name in the base classes). The order entered should be from first drawn (background) to last drawn (foreground).

Moved to MavenCentral

As of version 1.0.8, modular-views will be hosted on MavenCentral. Versions 1.0.7 and below will remain on JCenter.

Limitations / To Do's

  • Implement more ModularControllers for other types of Views/layouts
  • Implement prioritizing the touch events

Версии библиотеки

Версия
1.0.8