Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.idea/codeStyles/Project.xml
#	.idea/misc.xml
#	build.gradle
  • Loading branch information
mohamedagamy committed Jul 19, 2019
2 parents 3d55ea3 + 954ebfa commit ae7605b
Show file tree
Hide file tree
Showing 12 changed files with 596 additions and 16 deletions.
456 changes: 456 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

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

19 changes: 11 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-kapt'
//realm must be Here
apply plugin: 'realm-android'
apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

apply plugin: 'realm-android'



android {
Expand Down Expand Up @@ -35,8 +35,8 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.core:core-ktx:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
Expand All @@ -48,6 +48,9 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'

implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'

debugImplementation 'com.facebook.stetho:stetho:1.5.1'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:name=".application.MyApp">
<activity
android:name=".ui.MainActivity"
android:label="@string/title_activity_main"
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/arabiait/myapplication/application/MyApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.arabiait.myapplication.application

import android.app.Application
import com.facebook.stetho.Stetho
import io.realm.Realm

class MyApp : Application() {

override fun onCreate() {
super.onCreate()
Realm.init(this)
Stetho.initializeWithDefaults(this)

}
}
10 changes: 10 additions & 0 deletions app/src/main/java/com/arabiait/myapplication/pojo/PojoTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.arabiait.myapplication.pojo

import io.realm.RealmObject
import io.realm.annotations.PrimaryKey

open class PojoTest(
var name: String = "",
var age: Int = 0
//@PrimaryKey var id: Long = 0
): RealmObject(){}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.RecyclerView
import com.arabiait.myapplication.R
import com.arabiait.myapplication.pojo.LatestMovies
import com.arabiait.myapplication.pojo.ResultsItem
import com.arabiait.myapplication.util.IMAGE_BASE_URL
import com.squareup.picasso.Picasso

Expand Down
50 changes: 49 additions & 1 deletion app/src/main/java/com/arabiait/myapplication/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
package com.arabiait.myapplication.ui

import android.os.Bundle
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.ActionBarDrawerToggle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GravityCompat
import com.arabiait.myapplication.R
import com.arabiait.myapplication.pojo.PojoTest
import com.google.android.material.navigation.NavigationView
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_bar_main.*
import io.realm.Realm
import io.realm.DynamicRealm
import io.realm.DynamicRealmObject
import io.realm.RealmConfiguration
import io.realm.kotlin.createObject
import io.realm.kotlin.delete




class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {

lateinit var realm: Realm
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand All @@ -24,7 +38,35 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
toggle.syncState()

nav_view.setNavigationItemSelectedListener(this)
replaceFragment(R.id.nav_upcoming)
replaceFragment(R.id.nav_upcoming) }

private fun testRealm() {
//val realmConfig = RealmConfiguration.Builder().build()
//val realm = DynamicRealm.getInstance(realmConfig)
realm = Realm.getDefaultInstance()


val pojoTestList = listOf(
PojoTest("100",100),
PojoTest("100",200),
PojoTest("100",300),
PojoTest("100",400),
PojoTest("100",500),
PojoTest("100",600),
PojoTest("100",700),
PojoTest("100",800),
PojoTest("100",900),
PojoTest("100",1000))

realm.executeTransaction { realm ->

for (item in pojoTestList){
val person = realm.createObject<PojoTest>()
person.name = item.name
person.age = item.age
}

}
}

override fun onBackPressed() {
Expand Down Expand Up @@ -68,5 +110,11 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
drawer_layout.closeDrawer(GravityCompat.START)
}

override fun onDestroy() {
realm.close()
super.onDestroy()

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import androidx.recyclerview.widget.RecyclerView
import com.arabiait.myapplication.R
import com.arabiait.myapplication.pojo.ResultsItem

class MovieAdapter(movies: List<ResultsItem>) : RecyclerView.Adapter<MovieHolder>() {
private var movieList: List<ResultsItem> = movies
class MovieAdapter(movies: List<ResultsItem?>) : RecyclerView.Adapter<MovieHolder>() {
private var movieList: List<ResultsItem?> = movies
private var LOADING_ITEM = 200
private var VIEW_ITEM = 100
private var ITEM_TYPE = 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MoviesFragment : Fragment() {
private fun reloadMovies(moviesList: GeneralResponse) {
recyclerView.apply {
layoutManager = GridLayoutManager(null, 2)
adapter = MovieAdapter(moviesList.results as List<ResultsItem>)
adapter = MovieAdapter(moviesList.results!!)
movieAdapter = adapter as MovieAdapter
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.arabia_it.baserapp.util

/**
* Created by Net6 on 11/12/2017.
*/

import android.widget.AbsListView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

abstract class EndlessScrollListener : RecyclerView.OnScrollListener {
// The minimum number of items to have below your current scroll position
// before loading more.
private var visibleThreshold = 5

constructor(visibleThreshold: Int) {
this.visibleThreshold = visibleThreshold
}

override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)

recyclerView.layoutManager?.let { layoutManager ->

val totalItemCount = layoutManager.itemCount
val visibleItemCount = layoutManager.childCount
var firstVisibleItem = 0
when (layoutManager) {
is LinearLayoutManager -> firstVisibleItem = layoutManager.findFirstVisibleItemPosition()
is GridLayoutManager -> firstVisibleItem = layoutManager.findFirstVisibleItemPosition()
else -> return
}
if (firstVisibleItem + visibleItemCount + visibleThreshold >= totalItemCount) {
onLoadMore()
}
}

}

abstract fun onLoadMore()


}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 03 09:36:52 EET 2019
#Tue Jun 11 09:44:50 EET 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

0 comments on commit ae7605b

Please sign in to comment.