Skip to content

Commit

Permalink
Merge branch 'FroyoSupport'
Browse files Browse the repository at this point in the history
  • Loading branch information
emir-hasanbegovic committed Mar 28, 2014
2 parents a65e004 + 192ecbb commit 1f2cecf
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Include the Parchment library in your pom.xml file as follows:
<dependency>
<groupId>mobi.parchment</groupId>
<artifactId>parchment</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
<type>apklib</type>
</dependency>
```
Expand All @@ -29,7 +29,7 @@ or, to your build.gradle as follows:

```java
dependencies {
compile 'mobi.parchment:parchment:1.5.4@aar'
compile 'mobi.parchment:parchment:1.5.5@aar'
}
```

Expand Down
2 changes: 1 addition & 1 deletion library/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mobi.parchment"
android:versionCode="2"
android:versionName="1.5.4" >
android:versionName="1.5.5" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
2 changes: 1 addition & 1 deletion library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>mobi.parchment</groupId>
<artifactId>parchment</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
<packaging>apklib</packaging>
<name>Parchment</name>
<description>Android scrolling library</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ protected void onLayout(final boolean changed, final int left, final int top, fi
childTouchListener.computeScrollOffset();
final Animation animation = childTouchListener.getAnimation();

final int viewLeft = 0;
final int viewTop = 0;
final int viewRight = right - left;
final int viewBottom = bottom - top;
final int leftSize = MeasureSpec.getSize(left);
final int rightSize = MeasureSpec.getSize(right);
final int topSize = MeasureSpec.getSize(top);
final int bottomSize = MeasureSpec.getSize(bottom);

if (layoutManager != null) {
layoutManager.layout(this, animation, changed, viewLeft, viewTop, viewRight, viewBottom);
layoutManager.layout(this, animation, changed, leftSize, topSize, rightSize, bottomSize);
}

if (isLayoutRequested()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.view.View;
import android.view.ViewGroup;

import mobi.parchment.widget.adapterview.utilities.ViewGroupUtilities;

/**
* Created by Emir Hasanbegovic on 2014-03-03.
*/
Expand Down Expand Up @@ -48,8 +50,8 @@ public int getViewBreadth(final View view) {

public int getViewGroupSize(final ViewGroup viewGroup) {
if (isVerticalScroll())
return viewGroup.getMeasuredHeight();
return viewGroup.getMeasuredWidth();
return ViewGroupUtilities.getViewGroupMeasuredHeight(viewGroup);
return ViewGroupUtilities.getViewGroupMeasuredWidth(viewGroup);
}

public int getDrawSize(int left, int top, int right, int bottom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import java.util.ArrayList;
import java.util.List;

import mobi.parchment.widget.adapterview.utilities.ViewGroupUtilities;

/**
* Created by Emir Hasanbegovic on 2014-03-03.
*/
Expand Down Expand Up @@ -50,7 +52,7 @@ public int getBottom() {
return mStartOffset + height;
}

final int viewGroupHeight = mViewGroup.getMeasuredHeight();
final int viewGroupHeight = ViewGroupUtilities.getViewGroupMeasuredHeight(mViewGroup);
return viewGroupHeight - mCellSpacing;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.ArrayList;
import java.util.List;

import mobi.parchment.widget.adapterview.utilities.ViewGroupUtilities;

/**
* Created by Emir Hasanbegovic on 2014-03-03.
*/
Expand Down Expand Up @@ -145,7 +147,7 @@ public int getMeasuredHeight(final ViewGroup viewGroup, final int cellSpacing, f
return gridItemHeight * numberOfGridItemsPerColumn + numberOfCellSpacings * cellSpacing;
}

final int viewGroupHeight = viewGroup.getMeasuredHeight();
final int viewGroupHeight = ViewGroupUtilities.getViewGroupMeasuredHeight(viewGroup);
return viewGroupHeight - 2 * cellSpacing;
}

Expand Down Expand Up @@ -179,7 +181,7 @@ public int getGridItemWidth(final ViewGroup viewGroup, final int cellSpacing, fi

public int getMeasuredWidth(final ViewGroup viewGroup, final int cellSpacing, final float ratio) {
if (mIsVerticalScroll) {
final int viewGroupWidth = viewGroup.getMeasuredWidth();
final int viewGroupWidth = ViewGroupUtilities.getViewGroupMeasuredWidth(viewGroup);
return viewGroupWidth - 2 * cellSpacing;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mobi.parchment.widget.adapterview.AdapterViewManager;
import mobi.parchment.widget.adapterview.LayoutManager;
import mobi.parchment.widget.adapterview.OnSelectedListener;
import mobi.parchment.widget.adapterview.utilities.ViewGroupUtilities;

import java.util.List;

Expand All @@ -29,7 +30,7 @@ public View getView(final Group group) {

private int getMaxMeasureWidth() {
final ViewGroup viewGroup = getViewGroup();
final int viewGroupWidth = viewGroup.getWidth();
final int viewGroupWidth = ViewGroupUtilities.getViewGroupMeasuredWidth(viewGroup);
final int cellSpacing = mGridLayoutManagerAttributes.getCellSpacing();

if (isVerticalScroll()) {
Expand All @@ -45,7 +46,7 @@ private int getMaxMeasureWidth() {

private int getMaxMeasureHeight() {
final ViewGroup viewGroup = getViewGroup();
final int viewGroupHeight = viewGroup.getHeight();
final int viewGroupHeight = ViewGroupUtilities.getViewGroupMeasuredHeight(viewGroup);
final int cellSpacing = mGridLayoutManagerAttributes.getCellSpacing();

if (isVerticalScroll()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import mobi.parchment.widget.adapterview.LayoutManager;
import mobi.parchment.widget.adapterview.LayoutManagerAttributes;
import mobi.parchment.widget.adapterview.OnSelectedListener;
import mobi.parchment.widget.adapterview.utilities.ViewGroupUtilities;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -67,7 +68,8 @@ protected int getMaxMeasureHeight(int position) {
private int getMaxMeasureHeight() {
final int cellSpacing = getCellSpacing();
final ViewGroup viewGroup = getViewGroup();
final int maxHeight = viewGroup.getMeasuredHeight() - cellSpacing * 2;
final int viewGroupMeasuredHeight = ViewGroupUtilities.getViewGroupMeasuredHeight(viewGroup);
final int maxHeight = viewGroupMeasuredHeight - cellSpacing * 2;
return maxHeight;
}

Expand All @@ -79,7 +81,8 @@ protected int getMaxMeasureWidth(int position) {
private int getMaxMeasureWidth() {
final int cellSpacing = getCellSpacing();
final ViewGroup viewGroup = getViewGroup();
final int maxWidth = viewGroup.getMeasuredWidth() - cellSpacing * 2;
final int viewGroupMeasuredWidth = ViewGroupUtilities.getViewGroupMeasuredWidth(viewGroup);
final int maxWidth = viewGroupMeasuredWidth - cellSpacing * 2;
return maxWidth;
}

Expand Down Expand Up @@ -129,7 +132,8 @@ public List<View> getViews(final View view) {
private int getHorizontalMeasureSpec(){
final int cellSpacing = getCellSpacing();
if (isVerticalScroll()){
final int maxMeasureWidth = mViewGroup.getMeasuredWidth() - cellSpacing * 2;
final int viewGroupMeasuredWidth = ViewGroupUtilities.getViewGroupMeasuredWidth(mViewGroup);
final int maxMeasureWidth = viewGroupMeasuredWidth - cellSpacing * 2;
return View.MeasureSpec.makeMeasureSpec(maxMeasureWidth, View.MeasureSpec.AT_MOST);
}
return View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
Expand All @@ -140,7 +144,8 @@ private int getVerticalMeasureSpec(){
if (isVerticalScroll()){
return View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
}
final int maxMeasureHeight = mViewGroup.getMeasuredHeight() - cellSpacing * 2;
final int viewGroupMeasuredHeight = ViewGroupUtilities.getViewGroupMeasuredHeight(mViewGroup);
final int maxMeasureHeight = viewGroupMeasuredHeight - cellSpacing * 2;
return View.MeasureSpec.makeMeasureSpec(maxMeasureHeight, View.MeasureSpec.AT_MOST);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package mobi.parchment.widget.adapterview.utilities;

import android.view.View;
import android.view.ViewGroup;

/**
* Created by Emir Hasanbegovic on 2014-03-27.
*/
public class ViewGroupUtilities {

public static int getViewGroupMeasuredHeight(final ViewGroup viewGroup){
final int viewGroupHeightMeasureSpec = viewGroup.getMeasuredHeight();
final int viewGroupHeightSize = View.MeasureSpec.getSize(viewGroupHeightMeasureSpec);
return viewGroupHeightSize;
}

public static int getViewGroupMeasuredWidth(final ViewGroup viewGroup){
final int viewGroupWidthMeasureSpec = viewGroup.getMeasuredWidth();
final int viewGroupWidthSize = View.MeasureSpec.getSize(viewGroupWidthMeasureSpec);
return viewGroupWidthSize;
}

}
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {
dependencies {
compile 'com.squareup.picasso:picasso:2.2.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'mobi.parchment:parchment:1.5.4@aar'
compile 'mobi.parchment:parchment:1.5.5@aar'
}

android {
Expand Down
2 changes: 1 addition & 1 deletion sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>mobi.parchment</groupId>
<artifactId>parchment</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
<optional>true</optional>
<type>apklib</type>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions sample/res/layout/activity_simple_grid_definition_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
parchment:ratio="1.618"
android:background="@drawable/background"
android:id="@+id/parchment_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="match_parent"
android:layout_height="match_parent"/>
6 changes: 3 additions & 3 deletions sample/res/layout/activity_simple_gridview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
parchment:cellSpacing="20dp"
parchment:orientation="vertical"
parchment:gravity="top"
parchment:isPerfectGrid="true"
parchment:isPerfectGrid="false"
parchment:snapPosition="onScreenWithCellSpacing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_width="match_parent"
android:layout_height="match_parent"/>
5 changes: 5 additions & 0 deletions sample/src/main/java/mobi/parchment/ProductsAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public long getItemId(final int position) {
return product.mId;
}

@Override
public boolean hasStableIds() {
return true;
}

private View getView(final Context context, final View convertView, final ViewGroup viewGroup) {
if (convertView == null) {
final LayoutInflater layoutInflater = LayoutInflater.from(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,24 @@ protected void onCreate(Bundle savedInstanceState) {
mGridDefinitionView = (GridDefinitionView<BaseAdapter>) findViewById(R.id.parchment_view);

final List<GridItemDefinition> gridItemDefinitions = new ArrayList<GridItemDefinition>();
// gridItemDefinitions.add(new GridItemDefinition(0, 0, 1, 2));
// gridItemDefinitions.add(new GridItemDefinition(0, 2, 2, 1));
// gridItemDefinitions.add(new GridItemDefinition(1, 0, 2, 1));
// gridItemDefinitions.add(new GridItemDefinition(2, 1, 1, 2));
// gridItemDefinitions.add(new GridItemDefinition(1, 1, 1, 1));


gridItemDefinitions.add(new GridItemDefinition(0, 0, 6, 4));
mGridDefinitionView.addGridGroupDefinition(gridItemDefinitions);
gridItemDefinitions.clear();

gridItemDefinitions.add(new GridItemDefinition(0, 0, 2, 2));
gridItemDefinitions.add(new GridItemDefinition(2, 0, 2, 2));
gridItemDefinitions.add(new GridItemDefinition(0, 2, 4, 4));
gridItemDefinitions.add(new GridItemDefinition(4, 0, 2, 3));
gridItemDefinitions.add(new GridItemDefinition(0, 2, 4, 4));
gridItemDefinitions.add(new GridItemDefinition(4, 3, 2, 3));
mGridDefinitionView.addGridGroupDefinition(gridItemDefinitions);
gridItemDefinitions.clear();

gridItemDefinitions.add(new GridItemDefinition(2, 4, 2, 2));
gridItemDefinitions.add(new GridItemDefinition(4, 4, 2, 2));
gridItemDefinitions.add(new GridItemDefinition(2, 0, 4, 4));
gridItemDefinitions.add(new GridItemDefinition(0, 0, 2, 3));
gridItemDefinitions.add(new GridItemDefinition(2, 0, 4, 4));
gridItemDefinitions.add(new GridItemDefinition(0, 3, 2, 3));
gridItemDefinitions.add(new GridItemDefinition(2, 4, 2, 2));
gridItemDefinitions.add(new GridItemDefinition(4, 4, 2, 2));
mGridDefinitionView.addGridGroupDefinition(gridItemDefinitions);

mGridDefinitionView.setAdapter(getProductsAdapter());
Expand Down

0 comments on commit 1f2cecf

Please sign in to comment.