Giter Site home page Giter Site logo

viewmover's Introduction

View Mover Library for Android

Build Status Maven Central Android Arsenal

Description

The Library allows to move the View within its parent container. While moving, translation animation is used

For API 16 (Jelly Bean) and higher moving performed based on view's X- and Y-axis position. For other API moving performed based on margins of the parent container

Requirements

The Library requires Android SDK version 9 (Gingerbread) and higher.

For API lower than Jelly Bean (version code 16) moving works as expected with FrameLayout and RelativeLayout. Working as expected with other layouts not guaranteed

Gradle Dependency

dependencies {
	compile 'com.github.shell-software:viewmover:1.1.0'
}

View Mover has a dependency on an external UI Tools library. If it is used already in the project it must be excluded as a transitive dependency

Activity Stream

Full ChangeLog

1.1.0 - current

  1. Fixed movement for KitKat API (due to rendering issues in KitKat)
  2. Changed the standard Android logging API to SLF4J Logging API

1.0.1 - previous

  1. Fixed NullPointerException in MovingParams

Features in the next versions:

TBD

Usage

To move the View the following steps must be performed:

  1. Create an instance of the ViewMover using ViewMoverFactory.createInstance(View) passing the View object to be moved
  2. Create the MovingParams instance, passing the necessary moving parameters
  3. Call the move(MovingParams) method on the created ViewMover object passing the MovingParams instance

Example

View view;
// ... view initialization code goes here

// Create ViewMover instance
ViewMover mover = ViewMoverFactory.createInstance(view);

// Create MovingDetails instance
MovingParams params = new MovingParams(getContext(), 300.0f, 300.0f);

// Move the view
mover.move(params);

Customization

MovingParams class contains the details of how the view must be moved:

  • xAxisDelta - X-axis delta specifies the horizontal axis distance, which View is moving at. Positive value means moving right, negative - left.
  • yAxisDelta - Y-axis delta specifies the vertical axis distance, which View is moving at. Positive value means moving down, negative - up.
  • animationDuration - the duration of translate animation, which is used to move the view. Set to 500 ms by default.
  • animationInterpolator - an animation interpolator, which is used to move the view. Not set by default.

X- and Y-axis deltas are stored in MovingParams as actual pixels. When MovingParams instance created or when setting X- or Y-axis the density-independent values are converted into real ones.

MovingParams has several public constructors, allowing to create the object with different parameters:

// Define parameters
Context context = getContext();
int rightDistance = 200.0f;
int downDistance = 200.0f;
long animationDuration = 1000;
Interpolator animationInterpolator = new AccelerateInterpolator();

// Declare moving parameters
MovingParams params;

// Create MovingParams object with distances, animation duration and animation interpolator
params = new MovingParams(context, rightDistance, upDistance, animationDuration, animationInterpolator);

// Create MovingParams object with distances and animation duration
params = new MovingParams(context, rightDistance, upDistance, animationDuration);

// Create MovingParams object with distances only
params = new MovingParams(context, rightDistance, upDistance);

// Clone an existing MovingParams object
MovingParams clonedDetails = new MovingParams(params)

MovingParams X-axis and Y-axis deltas can be changed after the object is created:

// Create MovingParams object with initial parameters
MovingParams params = new MovingParams(getContext(), 200.0f, 200.0f);

// Declare the new parameters
float xAxisDelta = 100.0f;
float yAxisDelta = 100.0f;

// Apply the new parameters to MovingParams object
params.setXAxisDelta(xAxisDelta);
params.setYAxisDelta(yAxisDelta);

Logging

To enable logging:

  1. Add the following dependency:

    dependencies {
    	compile 'com.github.tony19:logback-android-classic:1.1.1-3'
    }
  2. Create the logback.xml file in the src/main/assets with the sample configuration:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    	<appender name="LOGCAT" class="ch.qos.logback.classic.android.LogcatAppender">
    		<tagEncoder>
    			<pattern>%logger{0}</pattern>
    		</tagEncoder>
    		<encoder>
    			<pattern>%d{HH:mm:ss.SSS} [%thread] [%logger{0}] - %msg%n</pattern>
    		</encoder>
    	</appender>
    
    	<root level="TRACE" additivity="false">
    		<appender-ref ref="LOGCAT" />
    	</root>
    </configuration>

    You may wish to configure different appenders with different log levels for packages, classes etc.

    More information about LOGBack can be found @ LOGBack Project Site

  3. Add the following InvalidPackage ignore rule into lint.xml file (located @ the root of the project):

    <issue id="InvalidPackage" >
    	<ignore path="**/logback-android-core/*" />
    </issue>

License

  Copyright 2015 Shell Software Inc.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

Shell Software Inc. Links

viewmover's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.