Skip to content

Fixes for issues #40, #38, #43, #42, #44, #45, #36 & #47 #41

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildscript {
ext.gradle_tools_version = '3.2.0'
ext.support_version = '28.0.0'
ext.support_version = '1.1.0'
ext.glide_version = '4.7.1'

repositories {
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ POM_LICENCE_URL=http://opensource.org/licenses/MIT
POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=cleveroad
POM_DEVELOPER_NAME=Cleveroad
POM_DEVELOPER_NAME=Cleveroad
android.useAndroidX=true
android.enableJetifier=true
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
targetSdkVersion 28
versionCode 8
versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}
buildTypes {
Expand All @@ -21,6 +21,6 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$support_version"
implementation "androidx.appcompat:appcompat:$support_version"
}
//apply from: 'gradle-mvn-push.gradle'
9 changes: 2 additions & 7 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cleveroad.adaptivetablelayout">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true" />
<manifest package="com.cleveroad.adaptivetablelayout">

<application />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.ViewGroup;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.util.SparseArrayCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.collection.SparseArrayCompat;
import androidx.core.view.ViewCompat;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -820,6 +821,15 @@ private void recycleViewHolders(boolean isRecycleAll) {
}

removeKeys(headerKeysToRemove, mHeaderRowViewHolders);

//top left header view holder
if (mLeftTopViewHolder != null) {
// recycle view holder
if (isRecycleAll) {
recycleViewHolder(mLeftTopViewHolder);
mLeftTopViewHolder = null;
}
}
}


Expand Down Expand Up @@ -867,31 +877,36 @@ private void addViewHolders(Rect filledArea) {
int topRow = mManager.getRowByYWithShift(filledArea.top, mSettings.getCellMargin());
int bottomRow = mManager.getRowByYWithShift(filledArea.bottom, mSettings.getCellMargin());

for (int i = topRow; i <= bottomRow; i++) {
for (int j = leftColumn; j <= rightColumn; j++) {
// item view holders
ViewHolder viewHolder = mViewHolders.get(i, j);
if (viewHolder == null && mAdapter != null) {
addViewHolder(i, j, ViewHolderType.ITEM);
int columnCount = mManager.getColumnCount();
if (columnCount > 0) {
if (mManager.getRowCount() > 0) {
for (int i = topRow; i <= bottomRow; i++) {
for (int j = leftColumn; j <= rightColumn; j++) {
// item view holders
ViewHolder viewHolder = mViewHolders.get(i, j);
if (viewHolder == null && mAdapter != null) {
addViewHolder(i, j, ViewHolderType.ITEM);
}
}

// row view headers holders
ViewHolder viewHolder = mHeaderRowViewHolders.get(i);
if (viewHolder == null && mAdapter != null) {
addViewHolder(i, isRTL() ? columnCount : 0, ViewHolderType.ROW_HEADER);
} else if (viewHolder != null && mAdapter != null) {
refreshHeaderRowViewHolder(viewHolder);
}
}
}

// row view headers holders
ViewHolder viewHolder = mHeaderRowViewHolders.get(i);
if (viewHolder == null && mAdapter != null) {
addViewHolder(i, isRTL() ? mManager.getColumnCount() : 0, ViewHolderType.ROW_HEADER);
} else if (viewHolder != null && mAdapter != null) {
refreshHeaderRowViewHolder(viewHolder);
}
}

for (int i = leftColumn; i <= rightColumn; i++) {
// column view header holders
ViewHolder viewHolder = mHeaderColumnViewHolders.get(i);
if (viewHolder == null && mAdapter != null) {
addViewHolder(0, i, ViewHolderType.COLUMN_HEADER);
} else if (viewHolder != null && mAdapter != null) {
refreshHeaderColumnViewHolder(viewHolder);
for (int i = leftColumn; i <= rightColumn; i++) {
// column view header holders
ViewHolder viewHolder = mHeaderColumnViewHolders.get(i);
if (viewHolder == null && mAdapter != null) {
addViewHolder(0, i, ViewHolderType.COLUMN_HEADER);
} else if (viewHolder != null && mAdapter != null) {
refreshHeaderColumnViewHolder(viewHolder);
}
}
}

Expand Down Expand Up @@ -1637,12 +1652,8 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve

@Override
public void notifyDataSetChanged() {
recycleViewHolders(true);
mVisibleArea.set(mState.getScrollX(),
mState.getScrollY(),
mState.getScrollX() + mSettings.getLayoutWidth(),
mState.getScrollY() + mSettings.getLayoutHeight());
addViewHolders(mVisibleArea);
initItems();
notifyLayoutChanged();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ void clear() {
}

void init(int rowCount, int columnCount) {
if (rowCount < 0) {
rowCount = 0;
}
if (columnCount < 0) {
columnCount = 0;
}
// create objects
mRowHeights = new int[rowCount];
mColumnWidths = new int[columnCount];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleveroad.adaptivetablelayout;

import android.os.Bundle;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

interface DataAdaptiveTableLayoutAdapter<VH extends ViewHolder> extends AdaptiveTableAdapter<VH> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.IntDef;
import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

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

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.ViewGroup;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.SparseArray;

import java.util.ArrayDeque;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.cleveroad.adaptivetablelayout;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.view.GestureDetectorCompat;
import androidx.annotation.Nullable;
import androidx.core.view.GestureDetectorCompat;
import android.view.GestureDetector;
import android.view.MotionEvent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.IntDef;
import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.SparseArrayCompat;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.SparseArrayCompat;

import java.util.Collection;
import java.util.LinkedList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.view.View;

/**
* A {@link ViewHolder} describes an item view and metadata about its place within the {@link AdaptiveTableLayout}.
*/
interface ViewHolder {
public interface ViewHolder {
/**
* @return item represents the item of the {@link AdaptiveTableLayout}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.view.View;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cleveroad.adaptivetablelayout;

import android.support.annotation.IntDef;
import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
3 changes: 0 additions & 3 deletions library/src/main/res/values/strings.xml

This file was deleted.

14 changes: 7 additions & 7 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "com.cleveroad.tablelayout"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 29
versionCode 8
versionName "1.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -20,10 +20,10 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:design:$support_version"
implementation "androidx.appcompat:appcompat:$support_version"
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
// compile 'com.facebook.android:facebook-android-sdk:4.24.0'

//Glide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.graphics.ColorUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.Loader;
import androidx.annotation.NonNull;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.Loader;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
Expand Down
Loading