Commit451 / Viewtiful

Simple ViewUtils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Viewtiful

Simple view utils

Build Status

Gradle Dependency

Add the jitpack url to the project:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

then, in your app build.gradle

dependencies {
    compile "com.github.Commit451.Viewtiful:viewtiful:latest.version.here"
    //and, for kotlin extensions
    compile "com.github.Commit451.Viewtiful:viewtiful-kotlin:latest.version.here"
}

Usage

See the sample project for a comprehensive example.

Viewtiful.onPreDraw(view, new Runnable() {
    @Override
    public void run() {
        Log.d("Hello", "The view is about to draw.");
    }
});

And Kotlin:

view.onViewPreDraw(Runnable {
    Log.d("Hello", "The view is about to draw.")
    Toast.makeText(this@MainKotlinActivity, "The view is about to draw!!! How exciting", Toast.LENGTH_SHORT).show()
})

Similar examples for onGlobalLayout.

Setting padding is also made easier:

int padding = Viewtiful.dpToPx(4);
Viewtiful.setPaddingTop(padding);
Viewtiful.setPaddingBottom(padding);
Viewtiful.setPaddingLeft(padding);
Viewtiful.setPaddingRight(padding);

License

Copyright 2016 Commit 451

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.

About

Simple ViewUtils

License:Apache License 2.0


Languages

Language:Java 81.6%Language:Kotlin 18.4%