Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lokeshdesai403 committed Sep 2, 2018
0 parents commit 092acf0
Show file tree
Hide file tree
Showing 70 changed files with 1,731 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
@@ -0,0 +1 @@
/build
36 changes: 36 additions & 0 deletions app/build.gradle
@@ -0,0 +1,36 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.android4dev.recyclerview"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.android.support:design:28.0.0-rc01'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,24 @@
package com.android4dev.recyclerview

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("com.android4dev.recyclerview", appContext.packageName)
}
}
42 changes: 42 additions & 0 deletions app/src/main/AndroidManifest.xml
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android4dev.recyclerview">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".HomeActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RecyclerViewLinearLayoutActivity"
android:screenOrientation="portrait" />
<activity
android:name=".RecyclerViewGridLayoutActivity"
android:screenOrientation="portrait" />

<activity
android:name=".RecyclerViewStaggeredGridActivity"
android:screenOrientation="portrait" />

<activity
android:name=".RecyclerViewHeaderFooterActivity"
android:screenOrientation="portrait" />

<activity
android:name=".RecyclerViewLoadMoreDataActivity"
android:screenOrientation="portrait" />

</application>

</manifest>
52 changes: 52 additions & 0 deletions app/src/main/java/com/android4dev/recyclerview/HomeActivity.kt
@@ -0,0 +1,52 @@
package com.android4dev.recyclerview

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.android4dev.recyclerview.R.id.*
import com.android4dev.recyclerview.base.BaseActivity
import kotlinx.android.synthetic.main.activity_home.*

class HomeActivity : BaseActivity(), View.OnClickListener {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
initView()
}

private fun initView() {
buttonSimpleRecyclerView.setOnClickListener(this)
buttonGridRecyclerView.setOnClickListener(this)
buttonViewTypeRecyclerView.setOnClickListener(this)
buttonStaggeredRecyclerView.setOnClickListener(this)
buttonLoadMoreRecyclerView.setOnClickListener(this)
}

override fun onClick(clickView: View?) {
val intent: Intent
when (clickView!!.id) {
R.id.buttonSimpleRecyclerView -> {
intent = Intent(this@HomeActivity, RecyclerViewLinearLayoutActivity::class.java)
startActivity(intent)
}
R.id.buttonGridRecyclerView -> {
intent = Intent(this@HomeActivity, RecyclerViewGridLayoutActivity::class.java)
startActivity(intent)
}
R.id.buttonViewTypeRecyclerView -> {
intent = Intent(this@HomeActivity, RecyclerViewHeaderFooterActivity::class.java)
startActivity(intent)
}
R.id.buttonStaggeredRecyclerView -> {
intent = Intent(this@HomeActivity, RecyclerViewStaggeredGridActivity::class.java)
startActivity(intent)
}
R.id.buttonLoadMoreRecyclerView -> {
intent = Intent(this@HomeActivity, RecyclerViewLoadMoreDataActivity::class.java)
startActivity(intent)
}
}
}
}
@@ -0,0 +1,56 @@
package com.android4dev.recyclerview

import android.os.Bundle
import android.support.v7.widget.GridLayoutManager
import com.android4dev.recyclerview.adapter.MovieListGridRecyclerAdapter
import com.android4dev.recyclerview.base.BaseActivity
import com.android4dev.recyclerview.model.MovieModel
import com.android4dev.recyclerview.recyclerview_helper.GridItemDecoration
import kotlinx.android.synthetic.main.activity_main.*

class RecyclerViewGridLayoutActivity : BaseActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initView()
}

private fun initView() {
recyclerViewMovies.layoutManager = GridLayoutManager(this,2)

//This will for default android divider
recyclerViewMovies.addItemDecoration(GridItemDecoration(10, 2))

val movieListAdapter = MovieListGridRecyclerAdapter()
recyclerViewMovies.adapter = movieListAdapter
movieListAdapter.setMovieList(generateDummyData())
}

private fun generateDummyData(): List<MovieModel> {
val listOfMovie = mutableListOf<MovieModel>()

var movieModel = MovieModel(1, "Avengers", 500, "16 Feb 2018", R.drawable.ic_avengers)
listOfMovie.add(movieModel)

movieModel = MovieModel(2, "Avengers: Age of Ultron", 400, "17 March 2018", R.drawable.ic_avengers_2)
listOfMovie.add(movieModel)

movieModel = MovieModel(3, "Iron Man 3", 550, "17 April 2018", R.drawable.ic_ironman_3)
listOfMovie.add(movieModel)

movieModel = MovieModel(4, "Avengers: Infinity War", 1500, "15 Jan 2018", R.drawable.ic_avenger_five)
listOfMovie.add(movieModel)

movieModel = MovieModel(5, "Thor: Ragnarok", 200, "17 March 2018", R.drawable.ic_thor)
listOfMovie.add(movieModel)

movieModel = MovieModel(6, "Black Panther", 250, "17 May 2018", R.drawable.ic_panther)
listOfMovie.add(movieModel)

movieModel = MovieModel(7, "Logan", 320, "17 Dec 2018", R.drawable.ic_logan)
listOfMovie.add(movieModel)

return listOfMovie
}
}

0 comments on commit 092acf0

Please sign in to comment.