├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable
│ │ │ │ ├── hero.png
│ │ │ │ ├── translate.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── anim
│ │ │ │ └── translate.xml
│ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── irshulx
│ │ │ └── glitcheffectdemo
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── irshulx
│ │ │ └── glitcheffectdemo
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── irshulx
│ │ └── glitcheffectdemo
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── glitch-text
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ └── attrs.xml
│ │ │ ├── drawable
│ │ │ │ └── mine_history_icon.png
│ │ │ └── anim
│ │ │ │ └── transition1.xml
│ │ ├── AndroidManifest.xml
│ │ ├── assets
│ │ │ └── fonts
│ │ │ │ ├── Poppins-Black.ttf
│ │ │ │ └── Poppins-Bold.ttf
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── irshulx
│ │ │ └── glitchtext
│ │ │ ├── FontCache.java
│ │ │ ├── AnimTextView.java
│ │ │ └── GlitchTextEffect.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── irshulx
│ │ │ └── glitchtext
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── irshulx
│ │ └── glitchtext
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── _config.yml
├── settings.gradle
├── screens
├── ezgif.gif
├── ezgif-3.gif
└── img_css-glitch-effect-animation.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
└── misc.xml
├── gradle.properties
├── .gitignore
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/glitch-text/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-hacker
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':glitch-text'
2 |
--------------------------------------------------------------------------------
/screens/ezgif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/screens/ezgif.gif
--------------------------------------------------------------------------------
/glitch-text/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/screens/ezgif-3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/screens/ezgif-3.gif
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | GlitchEffectDemo
3 |
4 |
--------------------------------------------------------------------------------
/glitch-text/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Glitchtext
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/hero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/drawable/hero.png
--------------------------------------------------------------------------------
/screens/img_css-glitch-effect-animation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/screens/img_css-glitch-effect-animation.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/glitch-text/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/glitch-text/src/main/assets/fonts/Poppins-Black.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/glitch-text/src/main/assets/fonts/Poppins-Black.ttf
--------------------------------------------------------------------------------
/glitch-text/src/main/assets/fonts/Poppins-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/glitch-text/src/main/assets/fonts/Poppins-Bold.ttf
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/glitch-text/src/main/res/drawable/mine_history_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/irshu355/Android-Glitch-Text-Effect/HEAD/glitch-text/src/main/res/drawable/mine_history_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/translate.xml:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/glitch-text/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - #ff0000
5 | - #00ff00
6 | - #0000ff
7 |
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Dec 22 20:45:25 IST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - #570aa9
5 | - #fc00fc
6 | - #03fcfc
7 | - #ffffff
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #fff
4 | #1e033a
5 | #0ff
6 |
7 | #fff
8 | #f0f
9 | #0ff
10 |
11 |
12 |
--------------------------------------------------------------------------------
/glitch-text/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/github/irshulx/glitcheffectdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitcheffectdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/glitch-text/src/test/java/com/github/irshulx/glitchtext/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitchtext;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/translate.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 |
16 |
17 |
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/glitch-text/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/glitch-text/src/main/java/com/github/irshulx/glitchtext/FontCache.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitchtext;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 |
6 | import java.util.Hashtable;
7 |
8 | /**
9 | * Created by IRSHU on 23/12/2017.
10 | */
11 | public class FontCache {
12 |
13 | private static Hashtable fontCache = new Hashtable();
14 |
15 | public static Typeface get(String name, Context context) {
16 | Typeface tf = fontCache.get(name);
17 | if (tf == null) {
18 | try {
19 | tf = Typeface.createFromAsset(context.getAssets(), name);
20 | } catch (Exception e) {
21 | return null;
22 | }
23 | fontCache.put(name, tf);
24 | }
25 | return tf;
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/glitch-text/src/main/res/anim/transition1.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/glitch-text/src/androidTest/java/com/github/irshulx/glitchtext/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitchtext;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.github.irshulx.glitchtext.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/irshulx/glitcheffectdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitcheffectdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.github.irshulx.glitcheffectdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | *.jks
45 |
46 | # External native build folder generated in Android Studio 2.2 and later
47 | .externalNativeBuild
48 |
49 | # Google Services (e.g. APIs or Firebase)
50 | google-services.json
51 |
52 | # Freeline
53 | freeline.py
54 | freeline/
55 | freeline_project_description.json
56 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.github.irshulx.glitcheffectdemo"
7 | minSdkVersion 19
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:26.1.0'
24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
25 | testImplementation 'junit:junit:4.12'
26 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
28 | compile project(':glitch-text')
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/irshulx/glitcheffectdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitcheffectdemo;
2 |
3 | import android.app.ActionBar;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.Gravity;
7 | import android.view.ViewGroup;
8 | import android.widget.FrameLayout;
9 | import android.widget.LinearLayout;
10 |
11 | import com.github.irshulx.glitchtext.AnimTextView;
12 | import com.github.irshulx.glitchtext.GlitchTextEffect;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_main);
23 | // List colors = new ArrayList<>();
24 | // colors.add(R.color.colorPrimaryDark);
25 | // colors.add(R.color.color_pink);
26 | // colors.add(R.color.color_light_blue);
27 | // colors.add(R.color.color_front);
28 | //FrameLayout layout = findViewById(R.id.frame);
29 | // GlitchTextEffect effect = new GlitchTextEffect(this,colors,"DISTRESS");
30 | // effect.setTextSize(60);
31 | // effect.setNoise(6);
32 | // effect.start();
33 | // layout.addView(effect);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/glitch-text/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'glitch-text-effect'
6 | publishedGroupId = 'com.github.irshulx'
7 | libraryName = 'glitch-text-effect'
8 | artifact = 'glitch-text-effect'
9 | libraryDescription = 'A library to add glitch effect to a text string'
10 | siteUrl = 'https://irshulx.github.io/Android-Glitch-Text-Effect/'
11 | gitUrl = 'https://github.com/irshuLx/Android-Glitch-Text-Effect.git'
12 | libraryVersion = '1.0.1'
13 | developerId = 'irshuLx'
14 | developerName = 'Irshu'
15 | developerEmail = 'irshu@outlook.com'
16 | licenseName = 'The Apache Software License, Version 2.0'
17 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
18 | allLicenses = ["Apache-2.0"]
19 | }
20 |
21 | android {
22 | compileSdkVersion 26
23 |
24 |
25 |
26 | defaultConfig {
27 | minSdkVersion 19
28 | targetSdkVersion 26
29 | versionCode 1
30 | versionName "1.0"
31 |
32 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
33 |
34 | }
35 |
36 | buildTypes {
37 | release {
38 | minifyEnabled false
39 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40 | }
41 | }
42 |
43 | }
44 |
45 | dependencies {
46 | implementation fileTree(dir: 'libs', include: ['*.jar'])
47 |
48 | implementation 'com.android.support:appcompat-v7:26.1.0'
49 | testImplementation 'junit:junit:4.12'
50 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
51 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
52 | }
53 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
54 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
55 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/glitch-text/src/main/java/com/github/irshulx/glitchtext/AnimTextView.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitchtext;
2 |
3 | /**
4 | * Created by IRSHU on 24/12/2017.
5 | */
6 |
7 | import android.graphics.Paint;
8 |
9 | import android.content.Context;
10 | import android.graphics.Bitmap;
11 | import android.graphics.BitmapFactory;
12 | import android.graphics.Canvas;
13 | import android.graphics.Color;
14 | import android.graphics.Matrix;
15 | import android.graphics.Paint;
16 | import android.graphics.Path;
17 | import android.graphics.PathMeasure;
18 | import android.util.AttributeSet;
19 | import android.view.View;
20 | import android.widget.Toast;
21 |
22 | public class AnimTextView extends View {
23 |
24 | Paint paint;
25 |
26 | Bitmap bm;
27 | int bm_offsetX, bm_offsetY;
28 |
29 | Path animPath;
30 | PathMeasure pathMeasure;
31 | float pathLength;
32 |
33 | float step; //distance each step
34 | float distance; //distance moved
35 |
36 | float[] pos;
37 | float[] tan;
38 |
39 | Matrix matrix;
40 |
41 | public AnimTextView(Context context) {
42 | super(context);
43 | initMyView();
44 | }
45 |
46 | public AnimTextView(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | initMyView();
49 | }
50 |
51 | public AnimTextView(Context context, AttributeSet attrs, int defStyleAttr) {
52 | super(context, attrs, defStyleAttr);
53 | initMyView();
54 | }
55 |
56 | public void initMyView(){
57 | paint = new Paint();
58 | paint.setColor(Color.BLUE);
59 | paint.setStrokeWidth(1);
60 | paint.setStyle(Paint.Style.STROKE);
61 |
62 | bm = BitmapFactory.decodeResource(getResources(), R.drawable.mine_history_icon);
63 | bm_offsetX = bm.getWidth()/2;
64 | bm_offsetY = bm.getHeight()/2;
65 |
66 | animPath = new Path();
67 | animPath.moveTo(100, 100);
68 | animPath.lineTo(200, 100);
69 | animPath.lineTo(300, 50);
70 | animPath.lineTo(400, 150);
71 | animPath.lineTo(100, 300);
72 | animPath.lineTo(600, 300);
73 | animPath.lineTo(100, 100);
74 | animPath.close();
75 |
76 | pathMeasure = new PathMeasure(animPath, false);
77 | pathLength = pathMeasure.getLength();
78 |
79 | Toast.makeText(getContext(), "pathLength: " + pathLength, Toast.LENGTH_LONG).show();
80 |
81 | step = 1;
82 | distance = 0;
83 | pos = new float[2];
84 | tan = new float[2];
85 |
86 | matrix = new Matrix();
87 | }
88 |
89 | @Override
90 | protected void onDraw(Canvas canvas) {
91 |
92 | canvas.drawPath(animPath, paint);
93 |
94 | if(distance < pathLength){
95 | pathMeasure.getPosTan(distance, pos, tan);
96 |
97 | matrix.reset();
98 | float degrees = (float)(Math.atan2(tan[1], tan[0])*180.0/Math.PI);
99 | //matrix.postRotate(degrees, bm_offsetX, bm_offsetY);
100 | matrix.postTranslate(pos[0]-bm_offsetX, pos[1]-bm_offsetY);
101 |
102 | canvas.drawBitmap(bm, matrix, null);
103 |
104 | distance += step;
105 | }else{
106 | distance = 0;
107 | }
108 |
109 | invalidate();
110 | }
111 |
112 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [  ](https://bintray.com/irshu/maven/glitch-text-effect/_latestVersion)
2 |
3 | # Android-Glitch-Text-Effect
4 |
5 | An Android library to add a glitch effect into a string. This project was inspired by the codepen, https://codepen.io/ihatetomatoes/pen/8a16e11e6d6206f5eb1ed7a37fbbe1dc.
6 |
7 | Demo screen below was captured at a limited 25fps
8 |
9 |  
10 |
11 |
12 | Download
13 | ------------
14 | gradle:
15 |
16 | compile 'com.github.irshulx:glitch-text-effect:1.0.1'
17 |
18 | or maven:
19 |
20 |
21 | com.github.irshulx
22 | glitch-text-effect
23 | 1.0.1
24 | pom
25 |
26 |
27 |
28 | A gist of this library is available at https://gist.github.com/irshuLx/138c1dc0af5262e3ca0c5f5db014d7ef
29 |
30 | Usage
31 | --------------
32 |
33 |
41 |
42 |
43 |
44 | or programmatically:
45 |
46 | List colors = new ArrayList<>();
47 | colors.add(R.color.colorPrimaryDark);
48 | colors.add(R.color.colorPink);
49 | colors.add(R.color.colorLightBlue);
50 | colors.add(R.color.colorFront);
51 |
52 | GlitchTextEffect effect = new GlitchTextEffect(this,colors,"PURGE");
53 | effect.setTextSize(60);
54 | effect.setSpeed(70); //duration of a single cycle animation
55 | effect.setNoise(6); //the noise quotient of the effect
56 | effect.start(); // required to call for programmatic initiation
57 | layout.addView(effect);
58 |
59 | The logic is to stack textviews on a FrameLayout and animate their positions in opposite directions. The no. of textviews added is proportional to the number of colors in the array.
60 |
61 | 
62 |
63 | API
64 | --------------
65 |
66 | void setTextSize(int size); // set the textsize in sp
67 |
68 | void setNoise(int level); // set the noise level, recommended between 5-10
69 |
70 | void setFontFile(String fileName); // set the font to be used, eg: "fonts/Poppins-Black.ttf"
71 |
72 | void setSpeed(int speed); // speed in ms, recommends 50-200
73 |
74 |
75 | ##License
76 |
77 |
78 | Licensed under the Apache License, Version 2.0 (the "License");
79 | you may not use this file except in compliance with the License.
80 | You may obtain a copy of the License at
81 |
82 | http://www.apache.org/licenses/LICENSE-2.0
83 |
84 | Unless required by applicable law or agreed to in writing, software
85 | distributed under the License is distributed on an "AS IS" BASIS,
86 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
87 | See the License for the specific language governing permissions and
88 | limitations under the License.
89 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/glitch-text/src/main/java/com/github/irshulx/glitchtext/GlitchTextEffect.java:
--------------------------------------------------------------------------------
1 | package com.github.irshulx.glitchtext;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.text.TextUtils;
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 | import android.view.Gravity;
10 | import android.view.View;
11 | import android.view.animation.AccelerateDecelerateInterpolator;
12 | import android.view.animation.Animation;
13 | import android.view.animation.AnimationSet;
14 | import android.view.animation.TranslateAnimation;
15 | import android.widget.FrameLayout;
16 | import android.widget.TextView;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | /**
22 | * Created by IRSHU on 22/12/2017.
23 | */
24 |
25 | public class GlitchTextEffect extends FrameLayout{
26 | private List colors = new ArrayList<>();
27 | private int noise=10;
28 | private String text;
29 | List textViews = new ArrayList<>();
30 | private AnimationSet animationSet;
31 | private int speed =70;
32 | private boolean reverse =false;
33 | private int textSize = 50;
34 | private String fontFile="fonts/Poppins-Black.ttf";
35 | private int gravity = Gravity.CENTER;
36 |
37 | public GlitchTextEffect(Context context,List colors, String text) {
38 | super(context);
39 | this.text = text;
40 | this.colors = colors;
41 | setLayerType(View.LAYER_TYPE_HARDWARE,null);
42 | }
43 | public void start(){
44 | init();
45 | }
46 | public GlitchTextEffect(Context context, AttributeSet attrs) {
47 | super(context, attrs);
48 | loadStateFromAttrs(attrs);
49 | }
50 |
51 | private void loadStateFromAttrs(AttributeSet attributeSet) {
52 | if (attributeSet == null) {
53 | throw new IllegalArgumentException(
54 | "Configurations not found");
55 | }
56 |
57 | TypedArray a = null;
58 | try {
59 | a = getContext().obtainStyledAttributes(attributeSet, R.styleable.GlitchTextEffect);
60 | this.noise = a.getInteger(R.styleable.GlitchTextEffect_noise,this.noise);
61 | this.textSize = a.getInteger(R.styleable.GlitchTextEffect_textSize,this.textSize);
62 | this.speed = a.getInteger(R.styleable.GlitchTextEffect_speed,this.speed);
63 | String fontFile = a.getString(R.styleable.GlitchTextEffect_fontLocation);
64 | this.text = a.getString(R.styleable.GlitchTextEffect_text);
65 | if(TextUtils.isEmpty(this.text)){
66 | throw new IllegalArgumentException(
67 | "Text not specified, please include app:text attribute");
68 | }
69 | int colorsResId = a.getResourceId(R.styleable.GlitchTextEffect_textColors, 0);
70 | if (colorsResId == 0) {
71 | throw new IllegalArgumentException(
72 | "IntegerListPreference: error - colors not specified, please include app:textColors");
73 | }
74 | TypedArray ta = getContext().getResources().obtainTypedArray(R.array.glitch_colors);
75 | for (int i = 0; i < ta.length(); i++) {
76 | int color = Color.parseColor(ta.getString(i));
77 | colors.add(color);
78 | }
79 |
80 | this.fontFile = TextUtils.isEmpty(fontFile)?this.fontFile:fontFile;
81 |
82 | start();
83 |
84 | } finally {
85 | if (a != null) {
86 | a.recycle(); // ensure this is always called
87 | }
88 | }
89 | }
90 |
91 | public void setTextSize(int textSize) {
92 | this.textSize = textSize;
93 | }
94 |
95 | public void setFontFile(String fontFile) {
96 | this.fontFile = fontFile;
97 | }
98 |
99 | public void setGravity(int gravity){
100 | this.gravity = gravity;
101 | }
102 |
103 | public void setNoise(int noise){
104 | this.noise = noise;
105 | }
106 |
107 | public void setSpeed(int speed){
108 | this.speed = speed;
109 | }
110 |
111 |
112 | private void init() {
113 | for(int i = 0 ; i