Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nisrulz committed Feb 16, 2020
2 parents 9ee7771 + fbb9670 commit 1785a75
Show file tree
Hide file tree
Showing 31 changed files with 444 additions and 277 deletions.
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

ko_fi: nisrulz
liberapay: nisrulz
custom: https://www.paypal.me/nisrulz/5usd
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where `{latest version}` corresponds to published version in [ ![Download](https

Usage Example:
```gradle
def recyclerViewVersion="1.0.0"
def recyclerViewVersion="1.1.0"
// Required
implementation "androidx.recyclerview:recyclerview:${recyclerViewVersion}"
Expand Down
43 changes: 9 additions & 34 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,28 @@
*/

apply plugin: 'com.android.application'
apply from: '../dependencies.gradle'

android {
compileSdkVersion versions.compileSdk
// Configs
apply from: "$rootProject.projectDir/configs/common.gradle"

android {
defaultConfig {
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
applicationId "github.nisrulz.projectrecyclerviewhelper"
versionCode versions.appVersionCode
versionName versions.appVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
textOutput "stdout"
textReport true
checkAllWarnings true
warningsAsErrors true
showAll true
explainIssues true
abortOnError false
lintConfig file("$projectDir/lint.xml")
versionCode Versions.appCode
versionName Versions.appName
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

// Testing
testImplementation unitTestLibs
androidTestImplementation androidTestsLibs
// Appcompat
implementation Dependencies.appCompat

// Card View
implementation supportDeps.cardView

// Support Appcompat
implementation "androidx.appcompat:appcompat:$versions.supportAppCompat"
implementation Dependencies.cardview

// Required
implementation "androidx.recyclerview:recyclerview:$versions.supportRecyclerView"
implementation Dependencies.recyclerView

// ---------- RecyclerViewHelper ----------
// From Maven Repo
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.nisrulz.projectrecyclerviewhelper">
package="github.nisrulz.projectrecyclerviewhelper">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@
package github.nisrulz.projectrecyclerviewhelper;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.ItemTouchHelper;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

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

import java.util.ArrayList;

import github.nisrulz.recyclerviewhelper.RVHItemClickListener;
import github.nisrulz.recyclerviewhelper.RVHItemDividerDecoration;
import github.nisrulz.recyclerviewhelper.RVHItemTouchHelperCallback;
import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,22 @@

package github.nisrulz.projectrecyclerviewhelper;

import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import github.nisrulz.recyclerviewhelper.RVHAdapter;
import github.nisrulz.recyclerviewhelper.RVHViewHolder;

import androidx.recyclerview.widget.RecyclerView;

import java.util.Collections;
import java.util.List;

import github.nisrulz.recyclerviewhelper.RVHAdapter;
import github.nisrulz.recyclerviewhelper.RVHViewHolder;

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ItemViewHolder>
implements RVHAdapter {

public class ItemViewHolder extends RecyclerView.ViewHolder implements RVHViewHolder {

final TextView txt;

public ItemViewHolder(View itemView) {
super(itemView);
txt = itemView.findViewById(R.id.txt);
}

@Override
public void onItemClear() {
System.out.println("Item is unselected");
}

@Override
public void onItemSelected(int actionstate) {
System.out.println("Item is selected");
}
}

private final List<String> dataList;

public MyAdapter(List<String> dataList) {
Expand Down Expand Up @@ -94,4 +77,24 @@ private void swap(int firstPosition, int secondPosition) {
Collections.swap(dataList, firstPosition, secondPosition);
notifyItemMoved(firstPosition, secondPosition);
}

public class ItemViewHolder extends RecyclerView.ViewHolder implements RVHViewHolder {

final TextView txt;

public ItemViewHolder(View itemView) {
super(itemView);
txt = itemView.findViewById(R.id.txt);
}

@Override
public void onItemClear() {
System.out.println("Item is unselected");
}

@Override
public void onItemSelected(int actionstate) {
System.out.println("Item is selected");
}
}
}
14 changes: 7 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_fruits"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:id="@+id/rv_fruits"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
42 changes: 21 additions & 21 deletions app/src/main/res/layout/rv_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@
-->

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3">

<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:src="@drawable/ic_reorder_grey_600_24dp"
android:contentDescription="Reorder Handle" />
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="Reorder Handle"
android:padding="10dp"
android:src="@drawable/ic_reorder_grey_600_24dp" />

<TextView
android:id="@+id/txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:padding="20dp"
android:textColor="@color/colorAccent" />
android:id="@+id/txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:padding="20dp"
android:textColor="@color/colorAccent" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="10dp"
android:src="@drawable/ic_compare_arrows_indigo_a400_24dp"
android:contentDescription="Swipe Direction icon" />
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="Swipe Direction icon"
android:padding="10dp"
android:src="@drawable/ic_compare_arrows_indigo_a400_24dp" />
</LinearLayout>

</androidx.cardview.widget.CardView>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package github.nisrulz.projectrecyclerviewhelper;

import static org.junit.Assert.*;
import org.junit.Test;

import org.junit.*;
import static org.junit.Assert.assertEquals;

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
Expand Down
23 changes: 13 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,24 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
// Gradle will not find vars defined in an external file when referring to them
// in the buildscript block, unless you link it from the buildscript block, too.
apply from: 'dependencies.gradle'

repositories {
google()
jcenter()
}

dependencies {
// See dependencies.gradle for declaration of plugins.
classpath gradlePlugins
classpath Plugins.android

// Publish to Jcenter/Bintray
classpath Plugins.bintray
classpath Plugins.androidMaven

// Kotlin Plugin
classpath Plugins.kotlin

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Expand All @@ -36,8 +43,4 @@ allprojects {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
5 changes: 5 additions & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.iml
.gradle
/.idea
/build
gradle.properties
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repositories {
jcenter()
}

plugins {
`kotlin-dsl`
}
19 changes: 19 additions & 0 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2016 Nishant Srivastava
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

object Config {
const val testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Loading

0 comments on commit 1785a75

Please sign in to comment.