Skip to content

Commit

Permalink
Merge pull request #37 from liaohuqiu/dev
Browse files Browse the repository at this point in the history
add ViewPager in Demo, release 1.0.7
  • Loading branch information
liaohuqiu committed Jan 16, 2015
2 parents 340a74b + 0deae99 commit 93e9fc1
Show file tree
Hide file tree
Showing 24 changed files with 452 additions and 17 deletions.
12 changes: 9 additions & 3 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<groupId>in.srain.cube</groupId>
<artifactId>ultra-ptr</artifactId>
<type>apklib</type>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
```
或者
Expand All @@ -68,13 +68,13 @@
<groupId>in.srain.cube</groupId>
<artifactId>ultra-ptr</artifactId>
<type>aar</type>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
```

gradle / Android Studio
```
compile 'in.srain.cube:ultra-ptr:1.0.6@aar'
compile 'in.srain.cube:ultra-ptr:1.0.7@aar'
```

#### 配置
Expand Down Expand Up @@ -244,6 +244,12 @@ ptrFrame.setPtrHandler(new PtrHandler() {
});
```

# 常见问题

* ViewPager滑动冲突: `disableWhenHorizontalMove()`

* 长按LongPressed, `setInterceptEventWhileWorking()`


# License

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pom.xml
<groupId>in.srain.cube</groupId>
<artifactId>ultra-ptr</artifactId>
<type>apklib</type>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
```
or
Expand All @@ -71,13 +71,13 @@ or
<groupId>in.srain.cube</groupId>
<artifactId>ultra-ptr</artifactId>
<type>aar</type>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
```

gradle
```
compile 'in.srain.cube:ultra-ptr:1.0.6@aar'
compile 'in.srain.cube:ultra-ptr:1.0.7@aar'
```

#### Config
Expand Down Expand Up @@ -280,6 +280,11 @@ public interface PtrUIHandler {
}
```

# Q & A

* work with ViewPager: `disableWhenHorizontalMove()`

* work with LongPressed, `setInterceptEventWhileWorking()`

# License

Expand Down
2 changes: 1 addition & 1 deletion build-template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
vars = {
'ptr_lib_version': '1.0.6',
'ptr_lib_version': '1.0.7',
'cube_sdk_version': '1.0.43-SNAPSHOT'
}

Expand Down
4 changes: 4 additions & 0 deletions ptr-demo/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
</intent-filter>
</activity>

<activity
android:name=".ui.viewpager.ViewPagerActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"></activity>

</application>

</manifest>
2 changes: 1 addition & 1 deletion ptr-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<groupId>in.srain.cube</groupId>
<artifactId>ultra-ptr</artifactId>
<type>aar</type>
<version>1.0.6</version>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>in.srain.cube</groupId>
Expand Down
5 changes: 5 additions & 0 deletions ptr-demo/res/drawable/text_view_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/cube_mints_app_base_background" android:state_pressed="true" />
<item android:drawable="@color/cube_mints_4d90fe" />
</selector>
4 changes: 2 additions & 2 deletions ptr-demo/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/id_fragment"
Expand Down
32 changes: 32 additions & 0 deletions ptr-demo/res/layout/activity_view_pager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cube_mints_f1f1f1"
android:orientation="vertical">

<in.srain.cube.views.pager.TabPageIndicator
android:id="@+id/view_pager_tab_indicator"
android:layout_width="match_parent"
android:layout_height="36dp"
android:background="@color/cube_mints_white"
android:fadingEdge="none"
android:paddingLeft="15dp"
android:paddingRight="15dp" />

<in.srain.cube.views.ptr.PtrClassicFrameLayout
android:id="@+id/view_pager_ptr_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">

<android.support.v4.view.ViewPager
android:id="@+id/view_pager_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cube_mints_white" />

</in.srain.cube.views.ptr.PtrClassicFrameLayout>


</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
android:listSelector="@android:color/transparent"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:scrollbarStyle="outsideOverlay" />
android:scrollbarStyle="outsideOverlay"
android:choiceMode="singleChoice" />

</in.srain.cube.views.ptr.PtrClassicFrameLayout>
</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/cube_mints_content_view_padding"
android:background="@color/cube_mints_4d90fe"
android:clickable="true"
android:background="@drawable/text_view_bg"
android:gravity="center"
android:text="I am a TextView"
android:textColor="@color/cube_mints_white"
Expand Down
18 changes: 18 additions & 0 deletions ptr-demo/res/layout/fragment_view_pager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cube_mints_white">

<ListView
android:id="@+id/view_pager_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:fadingEdge="none"
android:listSelector="@android:color/transparent"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:scrollbarStyle="outsideOverlay" />

</RelativeLayout>
18 changes: 18 additions & 0 deletions ptr-demo/res/layout/view_pager_fragment_list_view_header.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="15dp"
android:paddingTop="15dp">

<TextView
android:id="@+id/view_pager_fragment_list_view_header_title"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
android:gravity="center"
android:padding="5dp"
android:textColor="#000"
android:textSize="16sp" />

</LinearLayout>
30 changes: 30 additions & 0 deletions ptr-demo/res/layout/view_pager_indicator_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:orientation="vertical">

<TextView
android:id="@+id/view_pager_indicator_name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#000"
android:textSize="16sp" />

<TextView
android:id="@+id/view_pager_indicator_tab_current"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/cube_mints_4d90fe" />

</LinearLayout>
</LinearLayout>
2 changes: 1 addition & 1 deletion ptr-demo/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<string name="ptr_demo_block_keep_header">Keep Header while Refreshing</string>
<string name="ptr_demo_block_hide_header">Hide Header while Refreshing</string>
<string name="ptr_demo_block_with_long_press">Long Press</string>
<string name="ptr_demo_block_with_view_page">ViewPager</string>
<string name="ptr_demo_block_with_view_pager">View Pager</string>
<string name="ptr_demo_block_storehouse_header_using_string_array">StoreHouse Style \nusing string array from xml</string>
<string name="ptr_demo_storehouse_header_using_string_array_in_title">using xml:&#160;</string>
<string name="ptr_demo_block_storehouse_header_using_string">StoreHouse Style \n\nusing string</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.srain.cube.views.ptr.demo.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -15,6 +16,7 @@
import in.srain.cube.views.ptr.demo.ui.storehouse.StoreHouseUsingPointList;
import in.srain.cube.views.ptr.demo.ui.storehouse.StoreHouseUsingString;
import in.srain.cube.views.ptr.demo.ui.storehouse.StoreHouseUsingStringArray;
import in.srain.cube.views.ptr.demo.ui.viewpager.ViewPagerActivity;
import in.srain.cube.views.ptr.header.StoreHouseHeader;

import java.util.ArrayList;
Expand Down Expand Up @@ -136,10 +138,13 @@ public void onClick(View v) {
getContext().pushFragmentToBackStack(WithLongPressFragment.class, null);
}
}));
itemInfos.add(newItemInfo(R.string.ptr_demo_placeholder, R.color.cube_mints_4d90fe, new OnClickListener() {
itemInfos.add(newItemInfo(R.string.ptr_demo_block_with_view_pager, R.color.cube_mints_4d90fe, new OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getContext(), ViewPagerActivity.class);
startActivity(intent);
}
}));
itemInfos.add(newItemInfo(R.string.ptr_demo_placeholder, R.color.cube_mints_4d90fe, new OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public View createView(LayoutInflater inflater) {

@Override
public void showData(int position, JsonData itemData) {
CLog.d("test", "%s", itemData);
mImageView.loadImage(mImageLoader, itemData.optString("pic"));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package in.srain.cube.views.ptr.demo.ui.viewpager;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import in.srain.cube.image.CubeImageView;
import in.srain.cube.image.ImageLoader;
import in.srain.cube.request.JsonData;
import in.srain.cube.views.list.ViewHolderBase;
import in.srain.cube.views.ptr.demo.R;

public class ImageListViewHolder extends ViewHolderBase<JsonData> {

private ImageLoader mImageLoader;
private CubeImageView mImageView;

private ImageListViewHolder(ImageLoader imageLoader) {
mImageLoader = imageLoader;
}

@Override
public View createView(LayoutInflater inflater) {
View v = inflater.inflate(R.layout.list_view_item, null);
mImageView = (CubeImageView) v.findViewById(R.id.list_view_item_image_view);
mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
return v;
}

@Override
public void showData(int position, JsonData itemData) {
mImageView.loadImage(mImageLoader, itemData.optString("pic"));
}
}
Loading

0 comments on commit 93e9fc1

Please sign in to comment.