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

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.scalified:viewmover:1.1.2'
}

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

Changelog

Complete Changelog

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.
  • animationListener - an animation listener, which is used to listen view animation events. 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();
Animation.AnimationListener animationListener = new Animation.AnimationListener() {
    @Override
    public void onAnimationStart(Animation animation) {
    }

    @Override
    public void onAnimationEnd(Animation animation) {
    }

    @Override
    public void onAnimationRepeat(Animation animation) {
    }
};

// Declare moving parameters
MovingParams params;

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

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

// 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 2016 Scalified <http://www.scalified.com>

  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.

Scalified Links

viewmover's People

Contributors

vbaidak avatar

Stargazers

 avatar  avatar  avatar Cindy Z avatar obvyah avatar ZhuYilin avatar chonamdoo avatar Patrick MacDowell avatar Nguyễn Thiện Hoàng avatar Mohamed Fathy avatar f-t-i-o-i avatar Henry avatar zkk avatar Jungle avatar Vladislav Bauer avatar Sudhakar avatar  avatar Abdullah Essa avatar Simon Dorociak avatar qinqun avatar Yomi Olatunji avatar JBarbosa avatar Igor Morais avatar anz avatar Rafał Kobyłko avatar  avatar SirVon Thomas avatar  avatar 尚晓东 avatar Mohammed Sazid Al Rashid avatar Don avatar Fabian Shallari avatar  avatar  avatar hs avatar  avatar Igor Kozlov avatar 韩海龙 avatar tiny Flutter team avatar Jeffrey Zhao avatar  avatar Tony Dieppa avatar  avatar Roy.Luo avatar Billy R avatar Gautam Chaudhary avatar he shiqi avatar dusunboy avatar Kent avatar yoshimaa avatar  avatar trietbui85 avatar Ángel Soliño avatar zhoubing avatar Ahmed Aljuaid avatar Vyacheslav Rusakov avatar Pranav Lathigara avatar Keishin Yokomaku avatar ixy avatar JC avatar  avatar kkk avatar Amine Laadhari avatar Wade avatar Bogdan Melnychuk avatar  avatar

Watchers

James Cloos avatar  avatar 尚晓东 avatar tiny Flutter team avatar  avatar  avatar

viewmover's Issues

how to make this thing work?

ViewMover mover = ViewMoverFactory.createInstance(movable1);
        MovingParams params = new MovingParams(getContext(), 100.0f, 100.0f);
        mover.move(params);

where movable1 is my TextView.
Nothing happens, except strange logging info...
Can you provide some more examples?

Multiple dex files define Lorg/slf4j/ILoggerFactory;

With 1.1.0 I have this exception:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/slf4j/ILoggerFactory;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

After looking at the dependencies I see:

+--- com.github.shell-software:viewmover:1.1.0
| +--- com.github.shell-software:uitools:1.1.0
| | --- org.slf4j:slf4j-api:1.7.9
| --- org.slf4j:slf4j-api:1.7.9

So I have to exclude slf4j from dependencies. Like this:
compile('com.github.shell-software:viewmover:1.1.0')
{
exclude group: 'org.slf4j', module: 'slf4j-api'
}

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.