From a9a0b42bdcdeb4333093758f18f0967f3a8257b7 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 24 Jun 2022 23:58:51 +0700 Subject: [PATCH 01/18] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=81?= =?UTF-8?q?=D0=B2=D1=8F=D0=B7=D1=8C=20=D1=81=20=D0=91=D0=94=20Firestore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/compiler.xml | 2 +- .idea/deploymentTargetDropDown.xml | 17 ++++ .idea/gradle.xml | 3 +- .idea/misc.xml | 3 +- app/build.gradle | 31 +++--- app/google-services.json | 22 ++--- .../ui/dashboard/DashboardFragment.kt | 99 +++++++------------ .../activityes/ui/dashboard/PersonRequest.kt | 2 +- build.gradle | 13 ++- 9 files changed, 94 insertions(+), 98 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 659bf43..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..e42c194 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 625b371..7b46144 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -7,14 +7,13 @@ - diff --git a/.idea/misc.xml b/.idea/misc.xml index 4fba2c3..abb1899 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index d47eacf..3accf9e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,8 +1,8 @@ plugins { id 'com.android.application' id 'kotlin-android' - id 'com.google.gms.google-services' + id 'kotlin-android-extensions' } android { @@ -34,24 +34,31 @@ android { buildFeatures { viewBinding true } + buildToolsVersion '30.0.3' } dependencies { - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.0' - implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.2' - implementation 'androidx.annotation:annotation:1.3.0' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0' - implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' - implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' - testImplementation 'junit:junit:4.+' + implementation 'androidx.core:core-ktx:1.8.0' + implementation 'androidx.appcompat:appcompat:1.4.2' + implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.annotation:annotation:1.4.0' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1' + implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2' + implementation 'androidx.navigation:navigation-ui-ktx:2.4.2' + implementation 'com.google.firebase:firebase-firestore:24.2.0' + implementation 'com.google.android.material:material:1.6.1' + implementation 'com.google.firebase:firebase-database:20.0.5' + implementation 'com.google.firebase:firebase-auth-ktx:21.0.6' + implementation 'com.google.firebase:firebase-functions-ktx:20.1.0' + implementation 'com.google.firebase:firebase-database-ktx:20.0.5' + testImplementation 'junit:junit:' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - implementation platform('com.google.firebase:firebase-bom:29.1.0') + implementation platform('com.google.firebase:firebase-bom:30.2.0') implementation 'com.google.firebase:firebase-analytics-ktx' implementation 'com.google.firebase:firebase-auth-ktx' //авторизация implementation 'com.google.firebase:firebase-firestore-ktx' //база данных diff --git a/app/google-services.json b/app/google-services.json index ed1fc56..ac5cdce 100644 --- a/app/google-services.json +++ b/app/google-services.json @@ -1,41 +1,33 @@ { "project_info": { - "project_number": "616512963878", - "project_id": "needit-d5458", - "storage_bucket": "needit-d5458.appspot.com" + "project_number": "795793707622", + "project_id": "needitdatabase", + "storage_bucket": "needitdatabase.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:616512963878:android:77990f2f50bf9860616de7", + "mobilesdk_app_id": "1:795793707622:android:7e2e8c39717f12f41493a7", "android_client_info": { "package_name": "com.example.needit" } }, "oauth_client": [ { - "client_id": "616512963878-nccs5llrdekuphj9ppelb7nm23lennsu.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.example.needit", - "certificate_hash": "29283c9cdaef3f327e3a28f8cdb15bed876e6ddc" - } - }, - { - "client_id": "616512963878-bu9fga62pcao7npqgokigjpsm96brla9.apps.googleusercontent.com", + "client_id": "795793707622-8ohbiprm058j4mskthgg5p6clmmh54u1.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "AIzaSyBZNktC30xrxQ8FYJgYM2vyJRC6VfS2dd0" + "current_key": "AIzaSyD8t70MlvibD4bk5Qa6IsxiKmtYGX-V0kU" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { - "client_id": "616512963878-bu9fga62pcao7npqgokigjpsm96brla9.apps.googleusercontent.com", + "client_id": "795793707622-8ohbiprm058j4mskthgg5p6clmmh54u1.apps.googleusercontent.com", "client_type": 3 } ] diff --git a/app/src/main/java/com/example/needit/activityes/ui/dashboard/DashboardFragment.kt b/app/src/main/java/com/example/needit/activityes/ui/dashboard/DashboardFragment.kt index 0074b38..22388c7 100644 --- a/app/src/main/java/com/example/needit/activityes/ui/dashboard/DashboardFragment.kt +++ b/app/src/main/java/com/example/needit/activityes/ui/dashboard/DashboardFragment.kt @@ -1,10 +1,10 @@ package com.example.needit.activityes.ui.dashboard +import android.app.ProgressDialog import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.HorizontalScrollView import android.widget.TextView import androidx.fragment.app.Fragment import androidx.lifecycle.Observer @@ -13,7 +13,11 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.example.needit.databinding.FragmentDashboardBinding import com.example.needit.firebase.firestore.PostFirestore import com.example.needit.firebase.models.Post -import kotlinx.coroutines.withContext +import com.google.firebase.auth.FirebaseAuth +import com.google.firebase.auth.ktx.auth +import com.google.firebase.firestore.FirebaseFirestore +import com.google.firebase.firestore.ktx.firestore +import com.google.firebase.ktx.Firebase import java.util.* //Stegancev @@ -37,73 +41,44 @@ class DashboardFragment : Fragment() { _binding = FragmentDashboardBinding.inflate(inflater, container, false) val root: View = binding.root - val textView: TextView = binding.textDashboard - dashboardViewModel.text.observe(viewLifecycleOwner, Observer { - textView.text = it - }) - - init1() - init() - init() - init() - init() - init() - init() - init() - init() - init() - init() init() return root } private fun init()= with(binding) { - - RecycledVievDash.layoutManager= LinearLayoutManager(activity) - RecycledVievDash.adapter=adapter + RecycledVievDash.layoutManager= LinearLayoutManager(activity) + RecycledVievDash.adapter=adapter + var progressDialog = ProgressDialog(context) // Окно загрузки данных при ожидании try { - val postFire: PostFirestore = PostFirestore() - val post: Post = - Post( - "", - "", - "", - "", - "", - post_type = Post.PostType.GIVE_AWAY, - object_type = Post.ObjectType.LEISURE_GOODS, - "", - "", - Date() - ) - } catch (e:NoSuchElementException){null} - val personRequest=PersonRequest(1,"Yasha","Lava","I need new boots 43 size","Need","Pushkin street Kolotushkin House") - adapter.addReq(personRequest) - - } - private fun init1()= with(binding) { + progressDialog.setCanceledOnTouchOutside(false) + progressDialog.setMessage("Загружаем данные...") + progressDialog.show() // Показываем окно загрузки + var personaList = mutableListOf() // Инициализируем лист товаров + val db = FirebaseFirestore.getInstance() // Подключение к БД + db.collection("Stuff") // Просматриваем все элементы коллекции + .get() + .addOnSuccessListener { + result -> + for (document in result) { + personaList.add( + PersonRequest( // Из БД инициализируем список объектов PersonalRequest + document["ImageID"].toString().toInt(), + document["Name"].toString(), + document["Surname"].toString(), + document["Description"].toString(), + document["typeReq"].toString(), + document["Address"].toString() + ) + ) + progressDialog.dismiss() // Убираем окно загрузки + for (i in personaList) { // Добавлем все элементы в DashBoard + adapter.addReq(i) + } + } + } - RecycledVievDash.layoutManager= LinearLayoutManager(activity) - RecycledVievDash.adapter=adapter - try { - val postFire: PostFirestore = PostFirestore() - val post: Post = - Post( - "", - "", - "", - "", - "", - post_type = Post.PostType.GIVE_AWAY, - object_type = Post.ObjectType.LEISURE_GOODS, - "", - "", - Date() - ) - } catch (e:NoSuchElementException){null} - val personRequest=PersonRequest(0,"Alex","Tumbaev","I need a wooden box","Need","Pushkin street Kolotushkin House") - adapter.addReq(personRequest) + } catch (e:NoSuchElementException){ null } + } - } override fun onDestroyView() { super.onDestroyView() _binding = null diff --git a/app/src/main/java/com/example/needit/activityes/ui/dashboard/PersonRequest.kt b/app/src/main/java/com/example/needit/activityes/ui/dashboard/PersonRequest.kt index 23e6d96..4c6dfa4 100644 --- a/app/src/main/java/com/example/needit/activityes/ui/dashboard/PersonRequest.kt +++ b/app/src/main/java/com/example/needit/activityes/ui/dashboard/PersonRequest.kt @@ -1,4 +1,4 @@ package com.example.needit.activityes.ui.dashboard -data class PersonRequest(val ImageId:Int, val Name:String,val Surname:String,val Description:String,val typeReq:String, val adress:String) +data class PersonRequest(val ImageId:Int, val Name:String, val Surname:String, val Description:String, val typeReq:String, val address:String) //Stegancev \ No newline at end of file diff --git a/build.gradle b/build.gradle index ea99f8c..04910c7 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,17 @@ buildscript { repositories { google() mavenCentral() + maven { + url = uri("https://repo.spring.io/release") + } + maven { + url = uri("https://repository.jboss.org/maven2") + } } dependencies { - classpath 'com.android.tools.build:gradle:7.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0" - - classpath 'com.google.gms:google-services:4.3.10' + classpath "com.android.tools.build:gradle:7.0.4" + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' + classpath 'com.google.gms:google-services:4.3.12' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From 96dc2739ecf141178426fe86ba4a42751b633c7e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 25 Jun 2022 00:30:37 +0700 Subject: [PATCH 02/18] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=80=D0=B5=D1=84=D1=80=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D0=B3=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 6 ++ .../needit/activityes/Navigation_Activity.kt | 2 - .../ui/dashboard/DashboardFragment.kt | 8 --- .../ui/notifications/NotificationsFragment.kt | 72 +++++-------------- .../firebase/firestore/PostFirestore.kt | 34 --------- .../example/needit/firebase/models/Post.kt | 26 ------- .../needit/firebase/utils/Constants.kt | 6 -- app/src/main/res/layout/activity_main.xml | 7 +- .../res/layout/fragment_notifications.xml | 4 +- 9 files changed, 28 insertions(+), 137 deletions(-) delete mode 100644 app/src/main/java/com/example/needit/firebase/firestore/PostFirestore.kt delete mode 100644 app/src/main/java/com/example/needit/firebase/models/Post.kt delete mode 100644 app/src/main/java/com/example/needit/firebase/utils/Constants.kt diff --git a/.idea/misc.xml b/.idea/misc.xml index abb1899..03aac9b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,13 @@