-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gavryschuk Yaroslav
committed
Apr 28, 2017
0 parents
commit 3edcacd
Showing
39 changed files
with
1,248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
/.idea/ | ||
/app/proguard-rules.pro | ||
/gradle/ | ||
/gradlew.bat | ||
/gradlew | ||
/gradle.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.0" | ||
defaultConfig { | ||
applicationId "steelkiwi.com.pagerindicator" | ||
minSdkVersion 21 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.1.1' | ||
testCompile 'junit:junit:4.12' | ||
compile project (":library") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="steelkiwi.com.pagerindicator"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/steelkiwi/com/pagerindicator/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package steelkiwi.com.pagerindicator; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.CheckBox; | ||
import android.widget.CompoundButton; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
import steelkiwi.com.library.IndicatorType; | ||
import steelkiwi.com.library.view.IndicatorView; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
List<Integer> images = new ArrayList<>(); | ||
images.add(R.color.color1); | ||
images.add(R.color.color2); | ||
images.add(R.color.color3); | ||
images.add(R.color.color1); | ||
images.add(R.color.color2); | ||
images.add(R.color.color3); | ||
images.add(R.color.color1); | ||
images.add(R.color.color2); | ||
images.add(R.color.color3); | ||
|
||
TutorialAdapter adapter = new TutorialAdapter(this); | ||
|
||
final IndicatorView indicator = (IndicatorView) findViewById(R.id.indicator); | ||
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); | ||
viewPager.setAdapter(adapter); | ||
adapter.setTutorialImage(images); | ||
indicator.attachViewPager(viewPager); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
app/src/main/java/steelkiwi/com/pagerindicator/TutorialAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package steelkiwi.com.pagerindicator; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.RelativeLayout; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import steelkiwi.com.pagerindicator.custom.CustomPagerAdapter; | ||
|
||
/** | ||
* Created by yaroslav on 2/20/17. | ||
*/ | ||
|
||
public class TutorialAdapter extends CustomPagerAdapter<TutorialAdapter.ViewHolder> { | ||
|
||
private Context context; | ||
private LayoutInflater inflater; | ||
private List<Integer> tutorialImage = new ArrayList<>(); | ||
|
||
public TutorialAdapter(Context context) { | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public TutorialAdapter.ViewHolder onCreateViewHolder(ViewGroup parent) { | ||
if(inflater == null) { | ||
inflater = LayoutInflater.from(parent.getContext()); | ||
} | ||
View view = inflater.inflate(R.layout.image_layout, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(TutorialAdapter.ViewHolder viewHolder, int position) { | ||
int image = tutorialImage.get(position); | ||
viewHolder.ivTutorialImage.setBackgroundResource(image); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return tutorialImage.size(); | ||
} | ||
|
||
public void setTutorialImage(List<Integer> tutorialImage) { | ||
this.tutorialImage.clear(); | ||
this.tutorialImage.addAll(tutorialImage); | ||
notifyDataSetChanged(); | ||
} | ||
|
||
public class ViewHolder extends CustomPagerAdapter.ViewHolder { | ||
RelativeLayout ivTutorialImage; | ||
|
||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
ivTutorialImage = (RelativeLayout) itemView.findViewById(R.id.ivImage); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/steelkiwi/com/pagerindicator/custom/CustomPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package steelkiwi.com.pagerindicator.custom; | ||
|
||
import android.support.v4.view.PagerAdapter; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import java.util.LinkedList; | ||
import java.util.Queue; | ||
|
||
/** | ||
* Created by yaroslav on 2/20/17. | ||
*/ | ||
|
||
public abstract class CustomPagerAdapter <VH extends CustomPagerAdapter.ViewHolder> extends PagerAdapter { | ||
|
||
public static abstract class ViewHolder { | ||
final View itemView; | ||
|
||
public ViewHolder(View itemView) { | ||
this.itemView = itemView; | ||
} | ||
} | ||
|
||
private Queue<VH> destroyedItems = new LinkedList<>(); | ||
|
||
@Override | ||
public final Object instantiateItem(ViewGroup container, int position) { | ||
VH viewHolder = destroyedItems.poll(); | ||
if (viewHolder != null) { | ||
// Re-add existing view before rendering so that we can make change inside getView() | ||
container.addView(viewHolder.itemView); | ||
onBindViewHolder(viewHolder, position); | ||
} else { | ||
viewHolder = onCreateViewHolder(container); | ||
onBindViewHolder(viewHolder, position); | ||
container.addView(viewHolder.itemView); | ||
} | ||
return viewHolder; | ||
} | ||
|
||
@Override | ||
public final void destroyItem(ViewGroup container, int position, Object object) { | ||
container.removeView(((VH) object).itemView); | ||
destroyedItems.add((VH) object); | ||
} | ||
|
||
@Override | ||
public final boolean isViewFromObject(View view, Object object) { | ||
return ((VH) object).itemView == view; | ||
} | ||
|
||
public abstract VH onCreateViewHolder(ViewGroup parent); | ||
public abstract void onBindViewHolder(VH viewHolder, int position); | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/steelkiwi/com/pagerindicator/custom/CustomSwipePager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package steelkiwi.com.pagerindicator.custom; | ||
|
||
import android.content.Context; | ||
import android.support.v4.view.ViewPager; | ||
import android.util.AttributeSet; | ||
import android.view.animation.DecelerateInterpolator; | ||
import android.widget.Scroller; | ||
|
||
|
||
import java.lang.reflect.Field; | ||
|
||
/** | ||
* Created by yaroslav on 2/20/17. | ||
*/ | ||
|
||
public class CustomSwipePager extends ViewPager { | ||
public CustomSwipePager(Context context) { | ||
super(context); | ||
setMyScroller(); | ||
} | ||
|
||
public CustomSwipePager(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
setMyScroller(); | ||
} | ||
|
||
private void setMyScroller() { | ||
try { | ||
Class<?> viewpager = ViewPager.class; | ||
Field scroller = viewpager.getDeclaredField("mScroller"); | ||
scroller.setAccessible(true); | ||
scroller.set(this, new MyScroller(getContext())); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public class MyScroller extends Scroller { | ||
|
||
public MyScroller(Context context) { | ||
super(context, new DecelerateInterpolator()); | ||
} | ||
|
||
@Override | ||
public void startScroll(int startX, int startY, int dx, int dy, int duration) { | ||
super.startScroll(startX, startY, dx, dy, 500); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:background="@android:color/white" | ||
android:layout_height="match_parent"> | ||
|
||
|
||
<android.support.v4.view.ViewPager | ||
android:id="@+id/viewPager" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
<steelkiwi.com.library.view.IndicatorView | ||
android:id="@+id/indicator" | ||
android:layout_width="match_parent" | ||
android:layout_height="70dp" | ||
android:layout_alignParentBottom="true" | ||
app:iv_bar_color="@android:color/black" | ||
app:iv_corner_radius="4dp" | ||
app:iv_idle_color="#999999" | ||
app:iv_select_color="#555555" | ||
app:iv_size="30dp" | ||
app:iv_text_color="@android:color/white" | ||
app:iv_text_size="12sp"/> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/ivImage" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
<color name="color1">#fc7337</color> | ||
<color name="color2">#ff4d00</color> | ||
<color name="color3">#b93b04</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">PagerIndicator</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.2.2' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Oops, something went wrong.