Skip to content

Commit

Permalink
Merge pull request #2 from amirisback/FunctionCustomView
Browse files Browse the repository at this point in the history
Function custom view
  • Loading branch information
amirisback authored Dec 31, 2019
2 parents c5b6802 + 76e11a4 commit 1b69d3e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 20 deletions.
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ FrogoRecyclerView Extends RecyclerView

# Special From This Custom View

isViewLinear()

fun isViewLinearVertical(dividerItem: Boolean) {}
fun isViewLinearHorizontal(dividerItem: Boolean) {}
fun isViewStaggeredGrid(spanCount: Int) {}
fun isViewGrid(spanCount: Int) {}

# Function Main From This Project

Expand All @@ -30,7 +32,7 @@ FrogoRecyclerView Extends RecyclerView
# Version Release
This Is Latest Release

$version_release = 2.0.0
$version_release = 2.0.1


# How To Use This Project
Expand Down Expand Up @@ -64,13 +66,7 @@ Add it in your root build.gradle at the end of repositories:
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:clipToPadding="false"
android:paddingTop="16dp"
tools:context=".kotlinsample.MainActivity"
tools:listitem="@layout/example_list_item" />

android:layout_height="match_parent"/>

<h3>Step 4. Create adapter</h3>

Expand All @@ -82,7 +78,6 @@ Add it in your root build.gradle at the end of repositories:
(Kotlin) - class MainActivity : AppCompatActivity(), FrogoRecyclerViewListener<ExampleModel> {
(Java) - public class DetailActivity extends AppCompatActivity implements FrogoRecyclerViewListener<ExampleModel> {


# Sample Code Kotlin and Java
<h3>Sample Code Adapter (Kotlin)</h3>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void setupAdapter(){
adapter.setupRequirement(this, listData(), R.layout.example_list_item);
FrogoRecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setAdapter(adapter);
recyclerView.isViewLinear();
recyclerView.isViewLinearVertical(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MainActivity : AppCompatActivity(),
R.layout.example_list_item
)
recycler_view.adapter = adapter
recycler_view.isViewLinear()
recycler_view.isViewLinearVertical(false)
}

override fun onItemClicked(data: ExampleModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package com.frogobox.recycler.view

import android.content.Context
import android.util.AttributeSet
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import androidx.recyclerview.widget.*


/**
* Created by Faisal Amir
Expand All @@ -23,7 +22,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager
* com.frogobox.frogoviewadapter.view
*
*/
class FrogoRecyclerView : RecyclerView {
class FrogoRecyclerView : RecyclerView, FrogoView {

constructor(context: Context) : super(context)

Expand All @@ -35,12 +34,28 @@ class FrogoRecyclerView : RecyclerView {
defStyleAttr
)

fun isViewLinear() {
layoutManager = LinearLayoutManager(context)
override fun isViewLinearVertical(dividerItem: Boolean) {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)

if (dividerItem) {
addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.VERTICAL))
}
}

fun isViewStaggeredGrid(spanCount : Int) {
override fun isViewLinearHorizontal(dividerItem: Boolean) {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)

if (dividerItem) {
addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.HORIZONTAL))
}
}

override fun isViewStaggeredGrid(spanCount: Int) {
layoutManager = StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL)
}

override fun isViewGrid(spanCount: Int) {
layoutManager = GridLayoutManager(context, spanCount)
}

}
28 changes: 28 additions & 0 deletions frogo/src/main/java/com/frogobox/recycler/view/FrogoView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.frogobox.recycler.view

/**
* Created by Faisal Amir
* FrogoBox Inc License
* =========================================
* FrogoRecyclerViewAdapter
* Copyright (C) 31/12/2019.
* All rights reserved
* -----------------------------------------
* Name : Muhammad Faisal Amir
* E-mail : [email protected]
* Github : github.com/amirisback
* LinkedIn : linkedin.com/in/faisalamircs
* -----------------------------------------
* FrogoBox Software Industries
* com.frogobox.recycler.view
*
*/

interface FrogoView {

fun isViewLinearVertical(dividerItem: Boolean) {}
fun isViewLinearHorizontal(dividerItem: Boolean) {}
fun isViewStaggeredGrid(spanCount: Int) {}
fun isViewGrid(spanCount: Int) {}

}

0 comments on commit 1b69d3e

Please sign in to comment.