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

Function custom view #2

Merged
merged 3 commits into from
Dec 31, 2019
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
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) {}

}