{"action":"created","comment":{"url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/comments/208168695","pull_request_review_id":143909957,"id":208168695,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODE2ODY5NQ==","diff_hunk":"@@ -0,0 +1,109 @@\n+package ru.yandex.moykoshelek.ui.transaction\n+\n+import android.arch.lifecycle.Observer\n+import android.arch.lifecycle.ViewModelProvider\n+import android.arch.lifecycle.ViewModelProviders\n+import android.os.Bundle\n+import android.view.View\n+import android.widget.*\n+import kotlinx.android.synthetic.main.fragment_add_transaction.*\n+import org.jetbrains.anko.forEachChild\n+import org.jetbrains.anko.sdk25.coroutines.onCheckedChange\n+import ru.terrakok.cicerone.Router\n+import ru.yandex.moykoshelek.R\n+import ru.yandex.moykoshelek.ui.balance.CardsPagerAdapter\n+import ru.yandex.moykoshelek.data.datasource.local.entities.Transaction\n+import ru.yandex.moykoshelek.data.entities.TransactionTypes\n+import ru.yandex.moykoshelek.extensions.getCurrentDateTime\n+import ru.yandex.moykoshelek.ui.common.BaseFragment\n+import ru.yandex.moykoshelek.ui.Screens\n+import java.util.*\n+import javax.inject.Inject\n+\n+\n+class AddTransactionFragment : BaseFragment() {\n+\n+    override val layoutRes = R.layout.fragment_add_transaction\n+    override val TAG = Screens.ADD_TRANSACTION_SCREEN\n+\n+    @Inject\n+    lateinit var router: Router\n+\n+    @Inject\n+    lateinit var viewModel: AddTransactionViewModel\n+\n+    @Inject\n+    lateinit var factory: ViewModelProvider.Factory\n+\n+    lateinit var cardAdapter: CardsPagerAdapter\n+\n+    override fun onActivityCreated(savedInstanceState: Bundle?) {\n+        super.onActivityCreated(savedInstanceState)\n+        viewModel = ViewModelProviders.of(this, factory).get(AddTransactionViewModel::class.java)\n+        initObservers()\n+    }\n+\n+    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {\n+        super.onViewCreated(view, savedInstanceState)\n+        setupViewPager()\n+        in_radio.onCheckedChange { _, isChecked ->\n+            if (isChecked) {\n+                transaction_category.adapter = ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, resources.getStringArray(R.array.transaction_income_categories))\n+            } else {\n+                transaction_category.adapter = ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, resources.getStringArray(R.array.transaction_expense_categories))\n+            }\n+        }\n+        period_check_box.onCheckedChange { _, isChecked ->\n+            if (isChecked) {\n+                period_edit_text.visibility = View.VISIBLE\n+            } else {\n+                period_edit_text.visibility = View.GONE\n+            }\n+        }\n+        submit_button.setOnClickListener { createTransaction() }\n+    }\n+\n+    private fun createTransaction() {\n+        add_transaction_layout.forEachChild {\n+            if (it.visibility == View.VISIBLE && it is EditText && it.text.isEmpty()) {\n+                it.error = \"Пожалуйста заполните поле\"\n+                return\n+            }\n+        }\n+        val transaction = Transaction()\n+        transaction.cost = transaction_amount.text.toString().toDouble()\n+        transaction.placeholder = \"Moscow, Russia\"\n+        transaction.type = if (in_radio.isChecked) TransactionTypes.IN else TransactionTypes.OUT\n+        val wallet = viewModel.getWallet(cards_viewpager.currentItem)\n+        transaction.currency = wallet.currency\n+        transaction.walletId = wallet.id\n+        transaction.date = getCurrentDateTime()\n+        transaction.category = transaction_category.selectedItem.toString()\n+        if (period_check_box.isChecked) {\n+            viewModel.executePeriodTransaction(transaction, period_edit_text.text.toString().toInt())\n+        } else {\n+            viewModel.executeTransaction(transaction)\n+        }\n+        router.backTo(Screens.BALANCE_SCREEN)\n+    }\n+\n+    private fun setupViewPager() {","path":"app/src/main/java/ru/yandex/moykoshelek/ui/transaction/AddTransactionFragment.kt","position":90,"original_position":90,"commit_id":"8e627596eae900f0878589cf1b3373da14351ed8","original_commit_id":"8e627596eae900f0878589cf1b3373da14351ed8","user":{"login":"st235","id":14966197,"node_id":"MDQ6VXNlcjE0OTY2MTk3","avatar_url":"https://avatars2.githubusercontent.com/u/14966197?v=4","gravatar_id":"","url":"https://api.github.com/users/st235","html_url":"https://github.com/st235","followers_url":"https://api.github.com/users/st235/followers","following_url":"https://api.github.com/users/st235/following{/other_user}","gists_url":"https://api.github.com/users/st235/gists{/gist_id}","starred_url":"https://api.github.com/users/st235/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/st235/subscriptions","organizations_url":"https://api.github.com/users/st235/orgs","repos_url":"https://api.github.com/users/st235/repos","events_url":"https://api.github.com/users/st235/events{/privacy}","received_events_url":"https://api.github.com/users/st235/received_events","type":"User","site_admin":false},"body":"похожий метод тоже видел","created_at":"2018-08-07T09:55:39Z","updated_at":"2018-08-07T09:59:11Z","html_url":"https://github.com/allerria/MoyKoshelek/pull/2#discussion_r208168695","pull_request_url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/comments/208168695"},"html":{"href":"https://github.com/allerria/MoyKoshelek/pull/2#discussion_r208168695"},"pull_request":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2","id":206327231,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2MzI3MjMx","html_url":"https://github.com/allerria/MoyKoshelek/pull/2","diff_url":"https://github.com/allerria/MoyKoshelek/pull/2.diff","patch_url":"https://github.com/allerria/MoyKoshelek/pull/2.patch","issue_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues/2","number":2,"state":"closed","locked":false,"title":"dev","user":{"login":"allerria","id":34130785,"node_id":"MDQ6VXNlcjM0MTMwNzg1","avatar_url":"https://avatars2.githubusercontent.com/u/34130785?v=4","gravatar_id":"","url":"https://api.github.com/users/allerria","html_url":"https://github.com/allerria","followers_url":"https://api.github.com/users/allerria/followers","following_url":"https://api.github.com/users/allerria/following{/other_user}","gists_url":"https://api.github.com/users/allerria/gists{/gist_id}","starred_url":"https://api.github.com/users/allerria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allerria/subscriptions","organizations_url":"https://api.github.com/users/allerria/orgs","repos_url":"https://api.github.com/users/allerria/repos","events_url":"https://api.github.com/users/allerria/events{/privacy}","received_events_url":"https://api.github.com/users/allerria/received_events","type":"User","site_admin":false},"body":"Изменена структура проекта.\nОбщий рефакторинг.\nПриведение к чистой архитектуре и MVVM.\nДобавлен функционал периодичных транзакций.\nПланируется отображение периодичных транзакций с возможностью отписки от них.\nПеренесу строки в ресурсы, подправлю грамматику, дименшнены тоже перенесу.\nДобавлю и заполню экраны из прошлых дз(статистика, настройка, о приложении)\nПриболел на пару дней, не успел, извините.","created_at":"2018-08-06T08:41:25Z","updated_at":"2018-08-07T09:59:11Z","closed_at":"2018-08-06T08:42:14Z","merged_at":"2018-08-06T08:42:14Z","merge_commit_sha":"77456a04116c85ac6d4852d2cc1a95e8485bdcd8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2/commits","review_comments_url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2/comments","review_comment_url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues/2/comments","statuses_url":"https://api.github.com/repos/allerria/MoyKoshelek/statuses/8e627596eae900f0878589cf1b3373da14351ed8","head":{"label":"allerria:dev","ref":"dev","sha":"8e627596eae900f0878589cf1b3373da14351ed8","user":{"login":"allerria","id":34130785,"node_id":"MDQ6VXNlcjM0MTMwNzg1","avatar_url":"https://avatars2.githubusercontent.com/u/34130785?v=4","gravatar_id":"","url":"https://api.github.com/users/allerria","html_url":"https://github.com/allerria","followers_url":"https://api.github.com/users/allerria/followers","following_url":"https://api.github.com/users/allerria/following{/other_user}","gists_url":"https://api.github.com/users/allerria/gists{/gist_id}","starred_url":"https://api.github.com/users/allerria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allerria/subscriptions","organizations_url":"https://api.github.com/users/allerria/orgs","repos_url":"https://api.github.com/users/allerria/repos","events_url":"https://api.github.com/users/allerria/events{/privacy}","received_events_url":"https://api.github.com/users/allerria/received_events","type":"User","site_admin":false},"repo":{"id":143007654,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMwMDc2NTQ=","name":"MoyKoshelek","full_name":"allerria/MoyKoshelek","owner":{"login":"allerria","id":34130785,"node_id":"MDQ6VXNlcjM0MTMwNzg1","avatar_url":"https://avatars2.githubusercontent.com/u/34130785?v=4","gravatar_id":"","url":"https://api.github.com/users/allerria","html_url":"https://github.com/allerria","followers_url":"https://api.github.com/users/allerria/followers","following_url":"https://api.github.com/users/allerria/following{/other_user}","gists_url":"https://api.github.com/users/allerria/gists{/gist_id}","starred_url":"https://api.github.com/users/allerria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allerria/subscriptions","organizations_url":"https://api.github.com/users/allerria/orgs","repos_url":"https://api.github.com/users/allerria/repos","events_url":"https://api.github.com/users/allerria/events{/privacy}","received_events_url":"https://api.github.com/users/allerria/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/allerria/MoyKoshelek","description":"Yandex mobile school, first app in kotlin","fork":true,"url":"https://api.github.com/repos/allerria/MoyKoshelek","forks_url":"https://api.github.com/repos/allerria/MoyKoshelek/forks","keys_url":"https://api.github.com/repos/allerria/MoyKoshelek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allerria/MoyKoshelek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allerria/MoyKoshelek/teams","hooks_url":"https://api.github.com/repos/allerria/MoyKoshelek/hooks","issue_events_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues/events{/number}","events_url":"https://api.github.com/repos/allerria/MoyKoshelek/events","assignees_url":"https://api.github.com/repos/allerria/MoyKoshelek/assignees{/user}","branches_url":"https://api.github.com/repos/allerria/MoyKoshelek/branches{/branch}","tags_url":"https://api.github.com/repos/allerria/MoyKoshelek/tags","blobs_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/refs{/sha}","trees_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allerria/MoyKoshelek/statuses/{sha}","languages_url":"https://api.github.com/repos/allerria/MoyKoshelek/languages","stargazers_url":"https://api.github.com/repos/allerria/MoyKoshelek/stargazers","contributors_url":"https://api.github.com/repos/allerria/MoyKoshelek/contributors","subscribers_url":"https://api.github.com/repos/allerria/MoyKoshelek/subscribers","subscription_url":"https://api.github.com/repos/allerria/MoyKoshelek/subscription","commits_url":"https://api.github.com/repos/allerria/MoyKoshelek/commits{/sha}","git_commits_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/commits{/sha}","comments_url":"https://api.github.com/repos/allerria/MoyKoshelek/comments{/number}","issue_comment_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues/comments{/number}","contents_url":"https://api.github.com/repos/allerria/MoyKoshelek/contents/{+path}","compare_url":"https://api.github.com/repos/allerria/MoyKoshelek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allerria/MoyKoshelek/merges","archive_url":"https://api.github.com/repos/allerria/MoyKoshelek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allerria/MoyKoshelek/downloads","issues_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues{/number}","pulls_url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls{/number}","milestones_url":"https://api.github.com/repos/allerria/MoyKoshelek/milestones{/number}","notifications_url":"https://api.github.com/repos/allerria/MoyKoshelek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allerria/MoyKoshelek/labels{/name}","releases_url":"https://api.github.com/repos/allerria/MoyKoshelek/releases{/id}","deployments_url":"https://api.github.com/repos/allerria/MoyKoshelek/deployments","created_at":"2018-07-31T11:53:25Z","updated_at":"2018-08-06T08:42:19Z","pushed_at":"2018-08-06T21:28:55Z","git_url":"git://github.com/allerria/MoyKoshelek.git","ssh_url":"git@github.com:allerria/MoyKoshelek.git","clone_url":"https://github.com/allerria/MoyKoshelek.git","svn_url":"https://github.com/allerria/MoyKoshelek","homepage":null,"size":3566,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"allerria:master","ref":"master","sha":"e419134d14e0646d0e4d744382af75715aeb4bd0","user":{"login":"allerria","id":34130785,"node_id":"MDQ6VXNlcjM0MTMwNzg1","avatar_url":"https://avatars2.githubusercontent.com/u/34130785?v=4","gravatar_id":"","url":"https://api.github.com/users/allerria","html_url":"https://github.com/allerria","followers_url":"https://api.github.com/users/allerria/followers","following_url":"https://api.github.com/users/allerria/following{/other_user}","gists_url":"https://api.github.com/users/allerria/gists{/gist_id}","starred_url":"https://api.github.com/users/allerria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allerria/subscriptions","organizations_url":"https://api.github.com/users/allerria/orgs","repos_url":"https://api.github.com/users/allerria/repos","events_url":"https://api.github.com/users/allerria/events{/privacy}","received_events_url":"https://api.github.com/users/allerria/received_events","type":"User","site_admin":false},"repo":{"id":143007654,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMwMDc2NTQ=","name":"MoyKoshelek","full_name":"allerria/MoyKoshelek","owner":{"login":"allerria","id":34130785,"node_id":"MDQ6VXNlcjM0MTMwNzg1","avatar_url":"https://avatars2.githubusercontent.com/u/34130785?v=4","gravatar_id":"","url":"https://api.github.com/users/allerria","html_url":"https://github.com/allerria","followers_url":"https://api.github.com/users/allerria/followers","following_url":"https://api.github.com/users/allerria/following{/other_user}","gists_url":"https://api.github.com/users/allerria/gists{/gist_id}","starred_url":"https://api.github.com/users/allerria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allerria/subscriptions","organizations_url":"https://api.github.com/users/allerria/orgs","repos_url":"https://api.github.com/users/allerria/repos","events_url":"https://api.github.com/users/allerria/events{/privacy}","received_events_url":"https://api.github.com/users/allerria/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/allerria/MoyKoshelek","description":"Yandex mobile school, first app in kotlin","fork":true,"url":"https://api.github.com/repos/allerria/MoyKoshelek","forks_url":"https://api.github.com/repos/allerria/MoyKoshelek/forks","keys_url":"https://api.github.com/repos/allerria/MoyKoshelek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allerria/MoyKoshelek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allerria/MoyKoshelek/teams","hooks_url":"https://api.github.com/repos/allerria/MoyKoshelek/hooks","issue_events_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues/events{/number}","events_url":"https://api.github.com/repos/allerria/MoyKoshelek/events","assignees_url":"https://api.github.com/repos/allerria/MoyKoshelek/assignees{/user}","branches_url":"https://api.github.com/repos/allerria/MoyKoshelek/branches{/branch}","tags_url":"https://api.github.com/repos/allerria/MoyKoshelek/tags","blobs_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/refs{/sha}","trees_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allerria/MoyKoshelek/statuses/{sha}","languages_url":"https://api.github.com/repos/allerria/MoyKoshelek/languages","stargazers_url":"https://api.github.com/repos/allerria/MoyKoshelek/stargazers","contributors_url":"https://api.github.com/repos/allerria/MoyKoshelek/contributors","subscribers_url":"https://api.github.com/repos/allerria/MoyKoshelek/subscribers","subscription_url":"https://api.github.com/repos/allerria/MoyKoshelek/subscription","commits_url":"https://api.github.com/repos/allerria/MoyKoshelek/commits{/sha}","git_commits_url":"https://api.github.com/repos/allerria/MoyKoshelek/git/commits{/sha}","comments_url":"https://api.github.com/repos/allerria/MoyKoshelek/comments{/number}","issue_comment_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues/comments{/number}","contents_url":"https://api.github.com/repos/allerria/MoyKoshelek/contents/{+path}","compare_url":"https://api.github.com/repos/allerria/MoyKoshelek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allerria/MoyKoshelek/merges","archive_url":"https://api.github.com/repos/allerria/MoyKoshelek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allerria/MoyKoshelek/downloads","issues_url":"https://api.github.com/repos/allerria/MoyKoshelek/issues{/number}","pulls_url":"https://api.github.com/repos/allerria/MoyKoshelek/pulls{/number}","milestones_url":"https://api.github.com/repos/allerria/MoyKoshelek/milestones{/number}","notifications_url":"https://api.github.com/repos/allerria/MoyKoshelek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allerria/MoyKoshelek/labels{/name}","releases_url":"https://api.github.com/repos/allerria/MoyKoshelek/releases{/id}","deployments_url":"https://api.github.com/repos/allerria/MoyKoshelek/deployments","created_at":"2018-07-31T11:53:25Z","updated_at":"2018-08-06T08:42:19Z","pushed_at":"2018-08-06T21:28:55Z","git_url":"git://github.com/allerria/MoyKoshelek.git","ssh_url":"git@github.com:allerria/MoyKoshelek.git","clone_url":"https://github.com/allerria/MoyKoshelek.git","svn_url":"https://github.com/allerria/MoyKoshelek","homepage":null,"size":3566,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2"},"html":{"href":"https://github.com/allerria/MoyKoshelek/pull/2"},"issue":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/issues/2"},"comments":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/allerria/MoyKoshelek/statuses/8e627596eae900f0878589cf1b3373da14351ed8"}},"author_association":"OWNER"}}
{"actor":{"display_login":"st235"}}