Skip to content

Commit a3f1ac6

Browse files
Added library for Parallax effect, view pager and list of images behind this pager
1 parent bff0843 commit a3f1ac6

Some content is hidden

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

45 files changed

+1111
-0
lines changed

.gitignore

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

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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
defaultConfig {
6+
applicationId "com.yoksnod.parallaxbackroundviewpager"
7+
minSdkVersion 21
8+
targetSdkVersion 28
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-optimize.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'com.android.support:appcompat-v7:28.0.0'
24+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25+
testImplementation 'junit:junit:4.12'
26+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
27+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28+
implementation project(':parallaxbackgroundviewpagerlibrary')
29+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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

app/src/main/AndroidManifest.xml

Lines changed: 21 additions & 0 deletions
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.yoksnod.parallaxbackroundviewpager">
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 android:name=".MainActivity">
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
</application>
20+
21+
</manifest>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.yoksnod.parallaxbackroundviewpager;
2+
3+
import android.os.Bundle;
4+
import android.support.v4.app.Fragment;
5+
import android.support.v4.app.FragmentManager;
6+
import android.support.v4.app.FragmentPagerAdapter;
7+
import android.support.v7.app.AppCompatActivity;
8+
9+
import com.yoksnod.parallaxbackgroundviewpager.ParallaxBackgroundPageListener;
10+
import com.yoksnod.parallaxbackgroundviewpager.ParallaxBackgroundViewPager;
11+
12+
import java.util.ArrayList;
13+
import java.util.List;
14+
15+
public class MainActivity extends AppCompatActivity {
16+
17+
private ParallaxBackgroundViewPager pager;
18+
private FragmentPagerAdapter adapter;
19+
20+
@Override
21+
protected void onCreate(Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
setContentView(R.layout.activity_main);
24+
pager = findViewById(R.id.pager);
25+
26+
final List<Integer> items = new ArrayList<>();
27+
items.add(R.id.img3);
28+
items.add(R.id.img2);
29+
items.add(R.id.img1);
30+
31+
adapter = new ParallaxFragmentPagerAdapter(getSupportFragmentManager(), items);
32+
pager.setAdapter(adapter);
33+
pager.addOnPageChangeListener(new ParallaxBackgroundPageListener(this, pager, adapter, items));
34+
pager.startAutoScroll();
35+
}
36+
37+
private class ParallaxFragmentPagerAdapter extends FragmentPagerAdapter {
38+
39+
private final List<Integer> items;
40+
41+
public ParallaxFragmentPagerAdapter(FragmentManager fragmentManager, List<Integer> items) {
42+
super(fragmentManager);
43+
this.items = items;
44+
}
45+
46+
@Override
47+
public Fragment getItem(int i) {
48+
return new PictureFragment();
49+
}
50+
51+
52+
@Override
53+
public int getCount() {
54+
return items.size();
55+
}
56+
}
57+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.yoksnod.parallaxbackroundviewpager;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.NonNull;
5+
import android.support.annotation.Nullable;
6+
import android.support.v4.app.Fragment;
7+
import android.view.LayoutInflater;
8+
import android.view.View;
9+
import android.view.ViewGroup;
10+
11+
public class PictureFragment extends Fragment {
12+
13+
@Nullable
14+
@Override
15+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
16+
return inflater.inflate(R.layout.item, container, false);
17+
}
18+
}
17.5 MB
Loading
18.1 MB
Loading
22.6 MB
Loading

0 commit comments

Comments
 (0)