-
Notifications
You must be signed in to change notification settings - Fork 5
Feature с добавленными датаклассами #22
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
base: master
Are you sure you want to change the base?
Changes from all commits
688af1a
3359b22
de356ee
b5cb108
a6f2961
06a2915
a75db0a
776e381
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,13 @@ android { | |
| kotlinOptions { | ||
| jvmTarget = '1.8' | ||
| } | ||
|
|
||
|
|
||
| buildFeatures { | ||
|
|
||
| viewBinding true | ||
|
|
||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ## This file must *NOT* be checked into Version Control Systems, | ||
| # as it contains information specific to your local configuration. | ||
| # | ||
| # Location of the SDK. This is only used by Gradle. | ||
| # For customization when using a Version Control System, please read the | ||
| # header note. | ||
| #Fri May 28 20:01:59 MSK 2021 | ||
| sdk.dir=C\:\\Users\\Natalya\\AppData\\Local\\Android\\Sdk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package ru.mail.fancywork.model.fancyLib | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
|
|
||
| enum class Difficulty { | ||
| UNDEFINED, EASY, MEDIUM, HARD, EXTREMELY_HARD | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package ru.mail.fancywork.model.fancyLib | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
|
|
||
| import android.graphics.Bitmap | ||
|
|
||
| data class FancyPicture( | ||
| val id: String, | ||
| val title: String, | ||
| val image: Bitmap, | ||
| val colors: List<List<String>> | ||
| ) { | ||
| // todo id generator | ||
| // todo difficulty definer | ||
|
|
||
| var author: String = "unknown" | ||
| var difficulty: Difficulty = Difficulty.UNDEFINED | ||
|
|
||
| constructor( | ||
| id: String, | ||
| title: String, | ||
| image: Bitmap, | ||
| colors: List<List<String>>, | ||
| author: String, | ||
| difficulty: Difficulty | ||
| ) : this(id, title, image, colors) { | ||
| this.author = author | ||
| this.difficulty = difficulty | ||
| } | ||
|
|
||
| fun getProportions(): Pair<Int, Int>? { | ||
| if (colors.isEmpty() || colors[0].isEmpty()) { | ||
| return null | ||
| } | ||
|
|
||
| return Pair(colors.size, colors[0].size) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,49 @@ | ||
| package ru.mail.fancywork.ui.primary | ||
|
|
||
| import android.content.Intent | ||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
| import android.view.View | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import androidx.recyclerview.widget.LinearLayoutManager | ||
| import androidx.recyclerview.widget.RecyclerView | ||
| import ru.mail.fancywork.R | ||
| import ru.mail.fancywork.controller.Controller | ||
| import ru.mail.fancywork.ui.auth.AuthActivity | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
|
|
||
| private val controller = Controller() | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main) | ||
| } | ||
|
|
||
| // todo google auth | ||
| public fun loginGoogle(view: View) { | ||
| // БОРЕМСЯ С КОДСТАЙЛОМ | ||
| findViewById<androidx.appcompat.widget.Toolbar>(R.id.top_bar) | ||
| .setOnMenuItemClickListener { item -> | ||
| when (item.itemId) { | ||
| R.id.logout -> { | ||
| controller.logOut() | ||
| startActivity(Intent(this, AuthActivity::class.java)) | ||
| finish() | ||
| true | ||
| } | ||
| else -> false | ||
| } | ||
| } | ||
|
|
||
| var worksList: RecyclerView = findViewById(R.id.rv_works) | ||
| var ar: ArrayList<Int> = ArrayList() | ||
| ar.add(6) | ||
| ar.add(5) | ||
| ar.add(4) | ||
| var adapter = WorksListAdapter(ar) | ||
|
|
||
| worksList.adapter = adapter | ||
| worksList.layoutManager = LinearLayoutManager(this.applicationContext) | ||
| } | ||
|
|
||
| // todo local auth | ||
| public fun loginWithoutGoogle(view: View) { | ||
| // todo open recycle view activity | ||
| public fun add(view:View){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
| //todo открыть активити просмотра вышивки | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package ru.mail.fancywork.ui.primary | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
|
|
||
| import android.view.LayoutInflater | ||
| import android.view.ViewGroup | ||
| import androidx.recyclerview.widget.RecyclerView | ||
| import ru.mail.fancywork.databinding.WorkItemInRvBinding | ||
|
|
||
| class WorksListAdapter( | ||
| private var worksList: List<Int>//dataclasses | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
| ) : RecyclerView.Adapter<WorksListAdapter.ViewHolder>() { | ||
|
|
||
| inner class ViewHolder(val binding: WorkItemInRvBinding) : RecyclerView.ViewHolder(binding.root) | ||
|
|
||
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
| val binding = | ||
| WorkItemInRvBinding.inflate(LayoutInflater.from(parent.context), parent, false) | ||
| return ViewHolder(binding) | ||
| } | ||
|
|
||
| override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
|
|
||
| with(holder) { | ||
| with(worksList[position]) { | ||
| binding.name.text = "ВЫЩЩЩИВКА" | ||
| binding.difficulty.rating = 4F | ||
| var str = "размер: " + worksList[position] + "x" + worksList[position] + "\nцветов: 5" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ktlint] reported by reviewdog 🐶 |
||
|
|
||
| binding.info.text = str | ||
|
|
||
| // binding.cardLayout.setOnClickListener { | ||
| // //todo открываем активити просмотра | ||
| // notifyDataSetChanged() | ||
| // } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun getItemCount(): Int { | ||
| return worksList.size | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <solid android:color="@color/lightBackground"/> | ||
|
|
||
| <stroke android:width="1.5dp" | ||
| android:color="@color/white" | ||
| /> | ||
|
|
||
| <padding android:left="1dp" | ||
| android:top="1dp" | ||
| android:right="1dp" | ||
| android:bottom="1dp" | ||
| /> | ||
|
|
||
| <corners android:bottomRightRadius="7dp" | ||
| android:bottomLeftRadius="7dp" | ||
| android:topLeftRadius="7dp" | ||
| android:topRightRadius="7dp"/> | ||
| </shape> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ktlint] reported by reviewdog 🐶
Unnecessary semicolon