Skip to content

Commit cd6ae4c

Browse files
author
Álvaro Blanco Cabrero
committed
First commit
0 parents  commit cd6ae4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1201
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
3+
apply plugin: 'kotlin-android'
4+
5+
apply plugin: 'kotlin-android-extensions'
6+
7+
android {
8+
compileSdkVersion 25
9+
buildToolsVersion "25.0.3"
10+
defaultConfig {
11+
applicationId "com.ablanco.parallaxsample"
12+
minSdkVersion 16
13+
targetSdkVersion 25
14+
versionCode 1
15+
versionName "1.0"
16+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17+
}
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
}
25+
26+
dependencies {
27+
compile fileTree(dir: 'libs', include: ['*.jar'])
28+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
29+
exclude group: 'com.android.support', module: 'support-annotations'
30+
})
31+
compile "com.android.support:appcompat-v7:${support_version}"
32+
compile project(':parallax')
33+
testCompile 'junit:junit:4.12'
34+
}

app/proguard-rules.pro

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/alvarobl/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.ablanco.parallaxsample;
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+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
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.ablanco.parallax", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.ablanco.parallaxsample">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<activity
13+
android:name="com.ablanco.parallaxsample.MainActivity"
14+
android:screenOrientation="portrait">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.ablanco.parallaxsample
2+
3+
import android.os.Bundle
4+
import android.support.v7.app.AppCompatActivity
5+
import android.widget.SeekBar
6+
import android.widget.Toast
7+
import com.ablanco.parallax.ParallaxView
8+
import com.ablanco.parallax.dip
9+
import kotlinx.android.synthetic.main.activity_main.*
10+
11+
class MainActivity : AppCompatActivity() {
12+
13+
override fun onCreate(savedInstanceState: Bundle?) {
14+
super.onCreate(savedInstanceState)
15+
setContentView(R.layout.activity_main)
16+
17+
cbFirstLayerParallax.setOnCheckedChangeListener { _, isChecked ->
18+
parallaxView.firstLayerAppliesParallax(isChecked)
19+
}
20+
21+
var seekProgress = (parallaxView.getParallaxMovementDistance().toFloat() / resources.displayMetrics.density).toInt()
22+
seekBar.progress = seekProgress
23+
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
24+
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
25+
if (fromUser) seekProgress = progress
26+
}
27+
28+
override fun onStartTrackingTouch(seekBar: SeekBar?) {
29+
}
30+
31+
override fun onStopTrackingTouch(seekBar: SeekBar?) {
32+
parallaxView.setParallaxMovementDistance(dip(seekProgress).toInt())
33+
Toast.makeText(this@MainActivity, seekProgress.toString(), Toast.LENGTH_SHORT).show()
34+
}
35+
})
36+
37+
rgTouchMode.setOnCheckedChangeListener { _, checkedId ->
38+
when (checkedId) {
39+
R.id.rbLifted -> parallaxView.touchMode = ParallaxView.TOUCH_MODE_LIFTED
40+
R.id.rbPressed -> parallaxView.touchMode = ParallaxView.TOUCH_MODE_PRESSED
41+
}
42+
}
43+
}
44+
}
10.3 KB
Loading
3.26 KB
Loading
52.5 KB
Loading

0 commit comments

Comments
 (0)