Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to AndroidX + make RecyclerView.canScrollVerticall(-1) work #53

Merged
merged 4 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions greedo-layout-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ repositories {
}

android {
compileSdkVersion 26
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -25,8 +25,8 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':greedo-layout')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.squareup.okhttp:okhttp:2.7.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.fivehundredpx.greedo_layout_sample;

import android.support.annotation.DrawableRes;
import androidx.annotation.DrawableRes;

/**
* Created by Julian Villella on 16-02-24.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import android.content.Context;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.recyclerview.widget.RecyclerView;

import com.fivehundredpx.greedolayout.GreedoLayoutSizeCalculator.SizeCalculatorDelegate;
import com.squareup.picasso.Picasso;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ToggleButton;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import com.fivehundredpx.greedolayout.GreedoLayoutManager;
import com.fivehundredpx.greedolayout.GreedoSpacingItemDecoration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent"
tools:context="com.fivehundredpx.greedo_layout_sample.SampleActivity">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Expand Down
8 changes: 4 additions & 4 deletions greedo-layout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ repositories {
}

android {
compileSdkVersion 26
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.3.0"
}
Expand All @@ -25,8 +25,8 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}

uploadArchives {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.fivehundredpx.greedolayout;

import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.fivehundredpx.greedolayout.GreedoLayoutSizeCalculator.SizeCalculatorDelegate;

/**
Expand Down Expand Up @@ -373,6 +375,18 @@ public boolean canScrollVertically() {
return true;
}

@Override
public int computeVerticalScrollOffset(RecyclerView.State state) {
View topLeftView = getChildAt(0);
return topLeftView == null ? 0 : Math.abs(getDecoratedTop(topLeftView));
}

@Override
public int computeVerticalScrollRange(@NonNull RecyclerView.State state) {
View bottomRightView = getChildAt(getChildCount() - 1);
return bottomRightView == null ? 0 : getDecoratedBottom(bottomRightView);
}

@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
if (getChildCount() == 0 || dy == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.fivehundredpx.greedolayout;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

/**
* Created by Julian Villella on 15-07-30.
*/
Expand Down