Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: serso/android-linear-layout-manager
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Fgabz/android-linear-layout-manager
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 11 commits
  • 11 files changed
  • 3 contributors

Commits on Jun 22, 2015

  1. Copy the full SHA
    b4a5cac View commit details
  2. Decorations are now measured properly

    Previously first/last flags were not taken into account and
    offsets were cached sometimes in LayoutParams
    sergeys-opera committed Jun 22, 2015
    Copy the full SHA
    fccd858 View commit details
  3. Wrong positions were used for item decorations

    Use adapter positions instead of view positions for
    determining first and last items
    sergeys-opera committed Jun 22, 2015
    Copy the full SHA
    7cadda9 View commit details
  4. On API <= 18, when vertical RecyclerView is inside ScrollView, we alw…

    …ays have heightSize == 0 and heightMode == UNSPECIFIED. In this case calculated measuredHeight == 0 and RecycleView is not visible at all. So, we shouldn't take specSize into account if specMode is UNSPECIFIED.
    rusmonster authored and sergeys-opera committed Jun 22, 2015
    Copy the full SHA
    227a123 View commit details
  5. When horzontal RecyclerView with layout_height=="wrap_content" does n…

    …ot fit horizontally, it fills all available height, because super.onMeasure() is used in this case. This patch fixes this.
    rusmonster authored and sergeys-opera committed Jun 22, 2015
    Copy the full SHA
    19833c5 View commit details
  6. According to the documentation we should pass size instead of spec to…

    … getChildMeasureSpec(). This patch fixes the incorrect measuring children's height in horizontal RecycleView, when children have layout_height="wrap_content"
    rusmonster authored and sergeys-opera committed Jun 22, 2015
    Copy the full SHA
    8859124 View commit details
  7. If allowBackup="false" in main app AndroidManifest, build fails with:

    > Manifest merger failed : Attribute application@allowBackup value=(false) from AndroidManifest.xml:23:4
      	Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:19:2 to override
    
    So, we shouldn't specify allowBackup explicitly in library manifest.
    rusmonster authored and sergeys-opera committed Jun 22, 2015
    Copy the full SHA
    7279b09 View commit details
  8. Last divider is invisible, when recyclerView has only one item and Di…

    …viderItemDecoration.first == false.
    
    This patch fixes it.
    rusmonster committed Jun 22, 2015
    Copy the full SHA
    de10bc7 View commit details
  9. Merge pull request #6 from rusmonster/bugfix/last-divider-not-shown

    Last divider is invisible, when recyclerView has only one item and Di…
    serso committed Jun 22, 2015
    Copy the full SHA
    f6148f1 View commit details

Commits on Jun 23, 2015

  1. Copy the full SHA
    b4603c3 View commit details
  2. New version

    sergeys-opera committed Jun 23, 2015
    Copy the full SHA
    11b8432 View commit details
2 changes: 1 addition & 1 deletion .idea/libraries/material_0_1_3.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/libraries/support_v4_22_0_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="org.solovyev.android.views" external.system.module.version="0.3" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="org.solovyev.android.views" external.system.module.version="0.4" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
@@ -82,7 +82,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -80,6 +80,18 @@ archivesBaseName = "linear-layout-manager-app"
version = version_name()

uploadArchives {
doFirst {
// for some reason Gradle :uploadArchives tries to upload null.txt.asc and null.map artifacts.
// As we don't want those let's filter them now (note that these files are not included in the
// list of project artifacts, so their origin is not clear)
configurations.archives.artifacts.removeAll { artifact ->
def removing = artifact.classifier == null && (artifact.type == 'txt.asc' || artifact.type == 'map')
if (removing) {
println "Removing artifacts: ${artifact.name}-${artifact.classifier}.${artifact.type}"
}
return removing
}
}
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
@@ -95,7 +107,7 @@ uploadArchives {
pom.project {
name 'Linear Layout Manager App'
packaging 'apk'
description 'Linera Layout Manager sample application'
description 'Linear Layout Manager sample application'
url 'https://github.com/serso/android-linear-layout-manager'

scm {
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/divider.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size
android:width="30dp"
android:height="10dp"/>
<solid android:color="#ffd4d4d4"/>
</shape>
1 change: 1 addition & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
<style name="ListItem">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">left|center_vertical</item>
<item name="android:orientation">horizontal</item>
<item name="android:background">@drawable/material_clickable_selector</item>
<item name="android:padding">5dp</item>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

public int version_code() {
return 3
return 4
}

public String version_name() {
return '0.3'
return '0.4'
}

public int android_sdk_version() {
2 changes: 1 addition & 1 deletion lib/lib.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":lib" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="org.solovyev.android.views" external.system.module.version="0.3" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":lib" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="org.solovyev.android.views" external.system.module.version="0.4" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
6 changes: 1 addition & 5 deletions lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -20,8 +20,4 @@
~ Site: http://se.solovyev.org
-->

<manifest package="org.solovyev.android.views.llm"
xmlns:android="http://schemas.android.com/apk/res/android">

<application android:allowBackup="true"/>
</manifest>
<manifest package="org.solovyev.android.views.llm" />
Original file line number Diff line number Diff line change
@@ -13,16 +13,24 @@
public class DividerItemDecoration extends RecyclerView.ItemDecoration {

private Drawable divider;
private int dividerHeight;
private int dividerWidth;
private boolean first = false;
private boolean last = false;

@SuppressWarnings("UnusedDeclaration")
public DividerItemDecoration(Context context, AttributeSet attrs) {
final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.listDivider});
divider = a.getDrawable(0);
setDivider(a.getDrawable(0));
a.recycle();
}

private void setDivider(Drawable divider) {
this.divider = divider;
this.dividerHeight = divider == null ? 0 : divider.getIntrinsicHeight();
this.dividerWidth = divider == null ? 0 : divider.getIntrinsicWidth();
}

@SuppressWarnings("UnusedDeclaration")
public DividerItemDecoration(Context context, AttributeSet attrs, boolean showFirstDivider,
boolean showLastDivider) {
@@ -33,7 +41,7 @@ public DividerItemDecoration(Context context, AttributeSet attrs, boolean showFi

@SuppressWarnings("UnusedDeclaration")
public DividerItemDecoration(Drawable divider) {
this.divider = divider;
setDivider(divider);
}

@SuppressWarnings("UnusedDeclaration")
@@ -47,24 +55,30 @@ public DividerItemDecoration(Drawable divider, boolean showFirstDivider,
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
if (divider == null) {
super.getItemOffsets(outRect, view, parent, state);
return;
}

final int position = ((RecyclerView.LayoutParams) view.getLayoutParams()).getViewLayoutPosition();
final boolean firstItem = position == 0;
final boolean lastItem = position == parent.getAdapter().getItemCount() - 1;
final boolean dividerBefore = first || !firstItem;
final boolean dividerAfter = last && lastItem;

if (getOrientation(parent) == LinearLayoutManager.VERTICAL) {
outRect.top = divider.getIntrinsicHeight();
outRect.bottom = -outRect.top;
outRect.top = dividerBefore ? dividerHeight : 0;
outRect.bottom = dividerAfter ? dividerHeight : 0;
} else {
outRect.left = divider.getIntrinsicWidth();
outRect.right = -outRect.left;
outRect.left = dividerBefore ? dividerWidth : 0;
outRect.right = dividerAfter ? dividerWidth : 0;
}
}

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (divider == null) {
super.onDrawOver(c, parent, state);
super.onDraw(c, parent, state);
return;
}

@@ -75,27 +89,32 @@ public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state)

final int orientation = getOrientation(parent);
final int childCount = parent.getChildCount();
final int adapterCount = parent.getAdapter().getItemCount();

final boolean vertical = orientation == LinearLayoutManager.VERTICAL;
final int size;
if (vertical) {
size = divider.getIntrinsicHeight();
size = dividerHeight;
left = parent.getPaddingLeft();
right = parent.getWidth() - parent.getPaddingRight();
} else {
size = divider.getIntrinsicWidth();
size = dividerWidth;
top = parent.getPaddingTop();
bottom = parent.getHeight() - parent.getPaddingBottom();
}

for (int i = first ? 0 : 1; i < childCount; i++) {
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int position = params.getViewLayoutPosition();
if (position == 0 && !first) {
continue;
}
if (vertical) {
top = child.getTop() - params.topMargin;
top = child.getTop() - params.topMargin - size;
bottom = top + size;
} else {
left = child.getLeft() - params.leftMargin;
left = child.getLeft() - params.leftMargin - size;
right = left + size;
}
divider.setBounds(left, top, right, bottom);
@@ -105,15 +124,18 @@ public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state)
if (last && childCount > 0) {
final View child = parent.getChildAt(childCount - 1);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
if (vertical) {
top = child.getBottom() + params.bottomMargin;
bottom = top + size;
} else {
left = child.getRight() + params.rightMargin;
right = left + size;
final int position = params.getViewLayoutPosition();
if (position == adapterCount - 1) {
if (vertical) {
top = child.getBottom() + params.bottomMargin;
bottom = top + size;
} else {
left = child.getRight() + params.rightMargin;
right = left + size;
}
divider.setBounds(left, top, right, bottom);
divider.draw(c);
}
divider.setBounds(left, top, right, bottom);
divider.draw(c);
}
}

Loading