Edited the Food Fragment Kotlin file, small changes to Settings Java, changed RecyclerView in Food Layout to match_parent

This commit is contained in:
Deniz Düzgören
2019-04-30 19:24:13 +02:00
parent a45e5cdfa0
commit d690a2604a
6 changed files with 134 additions and 17 deletions
+66 -13
View File
@@ -1,13 +1,66 @@
*.iml # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
.gradle # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
/local.properties
/.idea/caches # User-specific stuff
/.idea/libraries .idea/**/workspace.xml
/.idea/modules.xml .idea/**/tasks.xml
/.idea/workspace.xml .idea/**/usage.statistics.xml
/.idea/navEditor.xml .idea/**/dictionaries
/.idea/assetWizardSettings.xml .idea/**/shelf
.DS_Store
/build # Generated files
/captures .idea/**/contentModel.xml
.externalNativeBuild
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+1
View File
@@ -53,6 +53,7 @@ dependencies {
annotationProcessor "androidx.room:room-compiler:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1"
} }
repositories { repositories {
mavenCentral() mavenCentral()
@@ -1,4 +1,61 @@
package com.denizd.substitutionplan package com.denizd.substitutionplan
class FoodFragment { import android.content.SharedPreferences
import android.os.Bundle
import android.preference.PreferenceManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.madapps.prefrences.EasyPrefrences
class FoodFragment : Fragment(R.layout.food_layout) {
private lateinit var foodArrayList: ArrayList<Food>
private lateinit var recyclerView: RecyclerView
private val mAdapter = FoodAdapter(foodArrayList)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.food_layout, null)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val pullToRefresh = getView()?.findViewById(R.id.pullToRefresh) as SwipeRefreshLayout
val prefs = PreferenceManager.getDefaultSharedPreferences(activity) as SharedPreferences
val edit = prefs.edit() as SharedPreferences.Editor
val easyPrefs = EasyPrefrences(context!!)
val foodListPopulation = ArrayList<String>(easyPrefs.getListString("foodListPrefs"))
try {
recyclerView = getView()?.findViewById(R.id.linear_food) as RecyclerView
recyclerView.hasFixedSize()
recyclerView.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL ,false)
recyclerView.adapter = mAdapter
try {
recyclerView.removeAllViews()
} catch (e: NullPointerException) {}
for (i in 0..foodListPopulation.size) {
foodArrayList.add(Food(foodListPopulation[i]))
mAdapter.setFood(foodArrayList)
recyclerView.scheduleLayoutAnimation()
}
} catch (e: NullPointerException) {}
if (prefs.getBoolean("autoRefresh", false)) {
pullToRefresh.isRefreshing = true
// coroutines
}
pullToRefresh.setOnRefreshListener {
pullToRefresh.isRefreshing = true
// coroutines
}
}
} }
@@ -556,7 +556,7 @@ public class FragmentSettings extends Fragment {
alertDialogDev.setView(dialogView); alertDialogDev.setView(dialogView);
alertDialogDev.show(); alertDialogDev.show();
} else if (dialogEditText.getText().toString().equals("Tim Bergling")) { } else if (dialogEditText.getText().toString().equals("2018-04-20")) {
Toast.makeText(getActivity(), "◢ ◤", Toast.makeText(getActivity(), "◢ ◤",
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
+1 -1
View File
@@ -18,7 +18,7 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/linear_food" android:id="@+id/linear_food"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layoutAnimation="@anim/layout_animation_fall_down"> android:layoutAnimation="@anim/layout_animation_fall_down">
</androidx.recyclerview.widget.RecyclerView> </androidx.recyclerview.widget.RecyclerView>