Skip to content

Commit 9954317

Browse files
committed
Appintro
Appintro
1 parent 6b60816 commit 9954317

Some content is hidden

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

47 files changed

+1051
-0
lines changed

AppIntro/.gitignore

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

AppIntro/.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/gradle.xml

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/misc.xml

+46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppIntro/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

AppIntro/app/build.gradle

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.1"
6+
7+
defaultConfig {
8+
applicationId "com.samset.user.appintro"
9+
minSdkVersion 15
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
testCompile 'junit:junit:4.12'
25+
compile 'com.android.support:appcompat-v7:23.4.0'
26+
compile 'com.android.support:support-v4:23.4.0'
27+
}

AppIntro/app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in C:\Users\user\AppData\Local\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+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.samset.user.appintro;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.samset.user.appintro">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity android:name=".MainActivity">
12+
<intent-filter>
13+
<action android:name="android.intent.action.MAIN" />
14+
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
<activity android:name=".HomeActivity"></activity>
19+
</application>
20+
21+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.samset.user.appintro;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
public class HomeActivity extends AppCompatActivity {
7+
8+
@Override
9+
protected void onCreate(Bundle savedInstanceState) {
10+
super.onCreate(savedInstanceState);
11+
setContentView(R.layout.activity_home);
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.samset.user.appintro;
2+
3+
import android.support.v4.view.ViewPager;
4+
import android.view.View;
5+
6+
import com.samset.user.appintro.R;
7+
8+
/**
9+
* Created by user on 13-Sep-16.
10+
*/
11+
public class IntroPageTransformer implements ViewPager.PageTransformer {
12+
13+
@Override
14+
public void transformPage(View page, float position) {
15+
16+
// Get the page index from the tag. This makes
17+
// it possible to know which page index you're
18+
// currently transforming - and that can be used
19+
// to make some important performance improvements.
20+
int pagePosition = (int) page.getTag();
21+
22+
// Here you can do all kinds of stuff, like get the
23+
// width of the page and perform calculations based
24+
// on how far the user has swiped the page.
25+
int pageWidth = page.getWidth();
26+
float pageWidthTimesPosition = pageWidth * position;
27+
float absPosition = Math.abs(position);
28+
29+
// Now it's time for the effects
30+
if (position <= -1.0f || position >= 1.0f) {
31+
32+
// The page is not visible. This is a good place to stop
33+
// any potential work / animations you may have running.
34+
35+
} else if (position == 0.0f) {
36+
37+
// The page is selected. This is a good time to reset Views
38+
// after animations as you can't always count on the PageTransformer
39+
// callbacks to match up perfectly.
40+
41+
} else {
42+
43+
// The page is currently being scrolled / swiped. This is
44+
// a good place to show animations that react to the user's
45+
// swiping as it provides a good user experience.
46+
47+
// Let's start by animating the title.
48+
// We want it to fade as it scrolls out
49+
View title = page.findViewById(R.id.title);
50+
title.setAlpha(1.0f - absPosition);
51+
52+
// Now the description. We also want this one to
53+
// fade, but the animation should also slowly move
54+
// down and out of the screen
55+
View description = page.findViewById(R.id.description);
56+
description.setTranslationY(-pageWidthTimesPosition / 2f);
57+
description.setAlpha(1.0f - absPosition);
58+
59+
// Now, we want the image to move to the right,
60+
// i.e. in the opposite direction of the rest of the
61+
// content while fading out
62+
View placeholder = page.findViewById(R.id.iv);
63+
64+
65+
// We're attempting to create an effect for a View
66+
// specific to one of the pages in our ViewPager.
67+
// In other words, we need to check that we're on
68+
// the correct page and that the View in question
69+
// isn't null.
70+
if ( placeholder != null) {
71+
placeholder.setAlpha(1.0f - absPosition);
72+
placeholder.setTranslationX(-pageWidthTimesPosition * 1.5f);
73+
}
74+
75+
// Finally, it can be useful to know the direction
76+
// of the user's swipe - if we're entering or exiting.
77+
// This is quite simple:
78+
if (position < 0) {
79+
// Create your out animation here
80+
} else {
81+
// Create your in animation here
82+
}
83+
}
84+
}
85+
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.samset.user.appintro;
2+
3+
import android.support.v4.view.ViewPager;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
7+
import com.samset.user.appintro.adapters.MyPagerAdapter;
8+
9+
public class MainActivity extends AppCompatActivity {
10+
private ViewPager pager;
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
setContentView(R.layout.activity_main);
16+
pager = (ViewPager) findViewById(R.id.viewpager);
17+
// Set an Adapter on the ViewPager
18+
pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
19+
pager.setPageTransformer(false, new IntroPageTransformer());
20+
}
21+
22+
23+
}

0 commit comments

Comments
 (0)