This repository was archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
#172. Redesign records list. #182
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,10 @@ import com.blogspot.e_kanivets.moneytracker.controller.PreferenceController | |
| import com.blogspot.e_kanivets.moneytracker.controller.data.AccountController | ||
| import com.blogspot.e_kanivets.moneytracker.controller.data.ExchangeRateController | ||
| import com.blogspot.e_kanivets.moneytracker.controller.data.RecordController | ||
| import com.blogspot.e_kanivets.moneytracker.entity.RecordAdapterData | ||
| import com.blogspot.e_kanivets.moneytracker.entity.HeaderItem | ||
| import com.blogspot.e_kanivets.moneytracker.entity.Period | ||
| import com.blogspot.e_kanivets.moneytracker.entity.RecordItem | ||
| import com.blogspot.e_kanivets.moneytracker.entity.data.Record | ||
| import com.blogspot.e_kanivets.moneytracker.report.ReportMaker | ||
| import com.blogspot.e_kanivets.moneytracker.ui.AppRateDialog | ||
|
|
@@ -26,6 +29,7 @@ import javax.inject.Inject | |
| class MainActivity : BaseDrawerActivity() { | ||
|
|
||
| private lateinit var recordList: List<Record> | ||
| private val recordAdapterDataList: MutableList<RecordAdapterData> = mutableListOf() | ||
| private lateinit var period: Period | ||
| private lateinit var recordAdapter: RecordAdapter | ||
|
|
||
|
|
@@ -91,8 +95,7 @@ class MainActivity : BaseDrawerActivity() { | |
| private fun editRecord(position: Int) { | ||
| AnswersProxy.get().logButton("Edit Record") | ||
|
|
||
| // Minus one because of list view's header view | ||
| val record = recordList[position - 1] | ||
| val record = recordList[position - 1 - getCountHeadersItems(position - 1)] | ||
| startAddRecordActivity(record, AddRecordActivity.Mode.MODE_EDIT, record.type) | ||
| } | ||
|
|
||
|
|
@@ -134,17 +137,43 @@ class MainActivity : BaseDrawerActivity() { | |
| override fun update() { | ||
| recordList = recordController.getRecordsForPeriod(period) | ||
| recordList = recordList.reversed() | ||
| updateRecordAdapterDataList() | ||
|
|
||
| val currency = currencyController.readDefaultCurrency() | ||
|
|
||
| val reportMaker = ReportMaker(rateController) | ||
| val report = reportMaker.getRecordReport(currency, period, recordList) | ||
|
|
||
| recordAdapter.setRecords(recordList, report, currency, reportMaker.currencyNeeded(currency, recordList)) | ||
| recordAdapter.setRecords(recordAdapterDataList, report, currency, reportMaker.currencyNeeded(currency, recordList)) | ||
|
|
||
| fillDefaultAccount() | ||
| } | ||
|
|
||
| private fun getCountHeadersItems(position: Int): Int { | ||
|
Owner
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. Smart, but I would take one more look on the places where we use |
||
| var countHeadersItems = 0 | ||
| for (inOfData in 0 until position) { | ||
| if (recordAdapterDataList[inOfData] is HeaderItem) { | ||
| countHeadersItems++ | ||
| } | ||
| } | ||
| return countHeadersItems | ||
| } | ||
|
|
||
| private fun updateRecordAdapterDataList() { | ||
|
||
| recordAdapterDataList.clear() | ||
|
|
||
| var lastDate = EMPTY_DATE | ||
| for (record in recordList) { | ||
| if (formatController.formatDateToString(record.time) != lastDate) { | ||
| lastDate = formatController.formatDateToString(record.time) | ||
| recordAdapterDataList.add(HeaderItem(lastDate)) | ||
| } | ||
|
|
||
| recordAdapterDataList.add(RecordItem(record)) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private fun showAppRateDialog() { | ||
| AnswersProxy.get().logEvent("Show App Rate Dialog") | ||
| val dialog = AppRateDialog(this) | ||
|
|
@@ -170,6 +199,7 @@ class MainActivity : BaseDrawerActivity() { | |
|
|
||
| companion object { | ||
| private const val REQUEST_ACTION_RECORD = 6 | ||
| private const val EMPTY_DATE = "empty_date" | ||
|
||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
getRecordItemswill be more appropriate, I believe :)