Skip to content

Commit

Permalink
Fix AutoScrollViewPagerInnerDemo Bug
Browse files Browse the repository at this point in the history
Add viewpagerindicator to AutoScrollViewPager demo
  • Loading branch information
Trinea committed Apr 26, 2014
1 parent 70c973f commit 3249fcb
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 211 deletions.
10 changes: 2 additions & 8 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cn.trinea.android.demo"
android:versionCode="44"
android:versionName="3.1.2" >
android:versionCode="45"
android:versionName="3.1.3" >

<uses-sdk android:minSdkVersion="14" />

Expand Down Expand Up @@ -89,12 +89,6 @@
android:label="@string/auto_scroll_view_pager_activity_title"
android:theme="@style/AppTheme" >
</activity>
<activity
android:name=".AutoScrollViewPagerSingleDemo"
android:configChanges="orientation|keyboardHidden"
android:label="@string/auto_scroll_view_pager_single_activity_title"
android:theme="@style/AppTheme" >
</activity>
<activity
android:name=".AutoScrollViewPagerInnerDemo"
android:configChanges="orientation|keyboardHidden"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,4 @@
#####13. BroadcastReceiver Demo
使用示例:[BroadcastReceiver Demo](http://www.cnblogs.com/trinea/archive/2012/11/09/2763182.html)

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Trinea/androiddemo/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/9aacf0f4a496e0647f415dbfa2df098a "githalytics.com")](http://githalytics.com/Trinea/android-demo)

5 changes: 3 additions & 2 deletions project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
# Project target.
target=android-14
proguard.config=proguard.cfg
android.library.reference.1=../android-auto-scroll-view-pager
android.library.reference.2=../android-common
android.library.reference.1=..\\android-auto-scroll-view-pager
android.library.reference.2=..\\android-common
android.library.reference.3=../../OpenCode/Android-ViewPagerIndicator/library
22 changes: 15 additions & 7 deletions res/layout/auto_scroll_view_pager_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >

<Button
android:id="@+id/auto_scroll_view_pager_single"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/auto_scroll_view_pager_single" />

<Button
android:id="@+id/auto_scroll_view_pager_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/auto_scroll_view_pager_single"
android:layout_marginBottom="@dimen/dp_40"
android:text="@string/auto_scroll_view_pager_inner" />

<cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager
android:id="@+id/view_pager"
android:layout_width="@dimen/view_pager_witdh"
android:layout_height="@dimen/view_pager_height"
android:layout_below="@+id/auto_scroll_view_pager_inner" />

<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/view_pager"
android:layout_centerHorizontal="true"
android:padding="@dimen/dp_8" />

<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
12 changes: 6 additions & 6 deletions res/layout/auto_scroll_view_pager_inner_fragment_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager
android:id="@+id/view_pager"
android:layout_width="450dp"
android:layout_height="200dp" />
android:layout_width="@dimen/view_pager_witdh"
android:layout_height="@dimen/view_pager_height" />

<TextView
android:id="@+id/view_pager_index"
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/view_pager"
android:layout_alignBottom="@+id/view_pager"
android:layout_centerHorizontal="true"
android:textSize="14sp" />
android:padding="@dimen/dp_8" />

</RelativeLayout>
27 changes: 0 additions & 27 deletions res/layout/auto_scroll_view_pager_single_demo.xml

This file was deleted.

5 changes: 3 additions & 2 deletions res/layout/border_scroll_view_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TextView
android:id="@+id/top_text"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_height="@dimen/dp_20"
android:gravity="center"
android:text="top text" />

Expand All @@ -40,14 +40,15 @@
<TextView
android:id="@+id/bottom_text"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_height="@dimen/dp_20"
android:layout_below="@+id/text2"
android:gravity="center"
android:text="bottom text" />
</RelativeLayout>
</cn.trinea.android.common.view.BorderScrollView>

<include
android:id="@+id/trinea_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
Expand Down
16 changes: 8 additions & 8 deletions res/layout/download_manager_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp" >
android:paddingTop="@dimen/dp_20" >

<Button
android:id="@+id/download_button"
Expand All @@ -14,7 +14,7 @@
android:id="@+id/download_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginLeft="@dimen/dp_20"
android:ellipsize="end"
android:singleLine="true"
android:visibility="gone" />
Expand All @@ -25,7 +25,7 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/download_size"
android:layout_marginRight="50dp"
android:layout_marginRight="@dimen/dp_50"
android:ellipsize="end"
android:singleLine="true"
android:visibility="gone" />
Expand All @@ -36,14 +36,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/download_size"
android:layout_marginLeft="20dp"
android:layout_marginRight="50dp"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_50"
android:visibility="gone" />

<Button
android:id="@+id/download_cancel"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="40dp"
android:layout_width="@dimen/dp_40"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/download_progress"
android:layout_alignParentRight="true"
Expand All @@ -57,8 +57,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="70dp"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_70"
android:gravity="left" />

<include
Expand Down
4 changes: 2 additions & 2 deletions res/layout/image_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<ImageView
android:id="@+id/image_list_image"
android:layout_width="300dp"
android:layout_height="500dp"
android:layout_width="@dimen/image_width"
android:layout_height="@dimen/image_height"
android:layout_centerInParent="true"
android:contentDescription="@string/image_content" />

Expand Down
3 changes: 2 additions & 1 deletion res/layout/image_sdcard_cache_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
android:layout_height="match_parent"
android:layout_above="@+id/trinea_info_layout"
android:layout_gravity="center"
android:spacing="4dp" />
android:spacing="@dimen/dp_4" />

<include
android:id="@+id/trinea_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
Expand Down
4 changes: 2 additions & 2 deletions res/layout/search_view_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
android:id="@+id/search_info"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_marginLeft="8dp"
android:layout_marginLeft="@dimen/dp_8"
android:gravity="center_vertical"
android:textSize="18sp" />
android:textSize="@dimen/sp_16" />

<include
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion res/layout/slide_one_page_gallery_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
android:layout_height="match_parent"
android:layout_above="@+id/trinea_info_layout"
android:layout_gravity="center"
android:spacing="4dp" />
android:spacing="@dimen/dp_4" />

<include
android:id="@+id/trinea_info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
Expand Down
7 changes: 7 additions & 0 deletions res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
<dimen name="page_margin">15dp</dimen>
<dimen name="dp_4">4dp</dimen>
<dimen name="dp_8">8dp</dimen>
<dimen name="dp_20">20dp</dimen>
<dimen name="dp_40">40dp</dimen>
<dimen name="dp_50">50dp</dimen>
<dimen name="dp_70">70dp</dimen>
<dimen name="sp_16">16sp</dimen>
<dimen name="search_view_margin_left">55dp</dimen>
<dimen name="divider_height">2px</dimen>
<dimen name="view_pager_witdh">450dp</dimen>
<dimen name="view_pager_height">150dp</dimen>
<dimen name="image_width">300dp</dimen>
<dimen name="image_height">500dp</dimen>

</resources>
1 change: 0 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<string name="imagecache_demo_activity_title">ImageCache Demo</string>
<string name="dropdownlistview_demo_activity_title">Drop Down And Load More ListView Demo</string>
<string name="auto_scroll_view_pager_activity_title">Auto Scroll ViewPager Demo</string>
<string name="auto_scroll_view_pager_single_activity_title">Auto Scroll Single Pager Demo</string>
<string name="auto_scroll_view_pager_inner_activity_title">Auto Scroll Inner Pager Demo</string>
<string name="borderscrollview_demo_activity_title">onBottom onTop ScrollView Demo</string>
<string name="search_view_demo_activity_title">SearchView Demo</string>
Expand Down
64 changes: 52 additions & 12 deletions src/cn/trinea/android/demo/AutoScrollViewPagerDemo.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package cn.trinea.android.demo;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import cn.trinea.android.demo.adapter.ImagePagerAdapter;
import cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager;

import com.viewpagerindicator.CirclePageIndicator;

/**
* AutoScrollViewPagerDemo
Expand All @@ -13,31 +20,64 @@
*/
public class AutoScrollViewPagerDemo extends BaseActivity {

private Button singleVieaPager;
private Button innerVieaPager;
private AutoScrollViewPager viewPager;
private CirclePageIndicator indicator;

private Button innerViewPagerDemo;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.auto_scroll_view_pager_demo);

singleVieaPager = (Button)findViewById(R.id.auto_scroll_view_pager_single);
innerVieaPager = (Button)findViewById(R.id.auto_scroll_view_pager_inner);
viewPager = (AutoScrollViewPager)findViewById(R.id.view_pager);
indicator = (CirclePageIndicator)findViewById(R.id.indicator);

singleVieaPager.setOnClickListener(new OnClickListener() {
List<Integer> imageIdList = new ArrayList<Integer>();
imageIdList.add(R.drawable.banner1);
imageIdList.add(R.drawable.banner2);
imageIdList.add(R.drawable.banner3);
imageIdList.add(R.drawable.banner4);
viewPager.setAdapter(new ImagePagerAdapter(context, imageIdList));
indicator.setViewPager(viewPager);

@Override
public void onClick(View v) {
startActivity(new Intent(context, AutoScrollViewPagerSingleDemo.class));
viewPager.setInterval(2000);
viewPager.startAutoScroll();

}
});
innerVieaPager.setOnClickListener(new OnClickListener() {
// the more properties whose you can set
// // set whether stop auto scroll when touching, default is true
// viewPager.setStopScrollWhenTouch(false);
// // set whether automatic cycle when auto scroll reaching the last or first item
// // default is true
// viewPager.setCycle(false);
// /** set auto scroll direction, default is AutoScrollViewPager#RIGHT **/
// viewPager.setDirection(AutoScrollViewPager.LEFT);
// // set how to process when sliding at the last or first item
// // default is AutoScrollViewPager#SLIDE_BORDER_NONE
// viewPager.setBorderProcessWhenSlide(AutoScrollViewPager.SLIDE_BORDER_CYCLE);
// viewPager.setScrollDurationFactor(3);
// viewPager.setBorderAnimation(false);

innerViewPagerDemo = (Button)findViewById(R.id.auto_scroll_view_pager_inner);
innerViewPagerDemo.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
startActivity(new Intent(context, AutoScrollViewPagerInnerDemo.class));

}
});
}

@Override
protected void onPause() {
super.onPause();
// stop auto scroll when onPause
viewPager.stopAutoScroll();
}

@Override
protected void onResume() {
super.onResume();
// start auto scroll when onResume
viewPager.startAutoScroll();
}
}
Loading

0 comments on commit 3249fcb

Please sign in to comment.