Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Offline mode implementation #277

Merged
merged 8 commits into from
May 12, 2022
Merged

Offline mode implementation #277

merged 8 commits into from
May 12, 2022

Conversation

Tsathogguaa
Copy link
Collaborator

Making necessary preparation to implement the offline usage of the app. Mostly done. Some of the code that is added is in the form of commentaries, as the required parts to compile those lines have yet to be implemented.

Have to discuss test conditions with the team.

@zwierski zwierski self-requested a review May 12, 2022 14:38
@Tsathogguaa
Copy link
Collaborator Author

Making necessary preparation to implement the offline usage of the app. Mostly done. Some of the code that is added is in the form of commentaries, as the required parts to compile those lines have yet to be implemented.

Have to discuss test conditions with the team.

Quick note about why the code in DownloadManager is commented and not tested:

The tests would require both a download and an API call, both of them are not stable things to test. If the LyricsBelongGameActivity tests can be injected somehow, then I can suggest testing this piece of code as well, otherwise the tests may fail very often, both because of the API and the download activity. Since our coverage is low and I currently do not need this piece of code(not until next week's PR), I left the code commented to not decrease the coverage for no use.

var media = File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "extract_of_$currentSong.getTrackName()")
mediaPlayer = AudioPlayer.playAudio(media.absolutePath)
*/
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just put these modifications into GameManager instead? I deleted BuzzerGameManager when refactoring and put all the equivalent functions into GameManager instead so you should find it there

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done on local, will push soon once I make sure the merge was successful

page = "1"
songsPerPage = "100"
totalPages = "20"
totalSongs = "2000"
Copy link
Collaborator

@zwierski zwierski May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These vars don't seem to be modified anywhere in the class: maybe it'd be more readable to turn them into private vals / constants that you directly initialise as they're declared.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, will do it

var records = File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "records.txt")


if(!records.exists() || records.length() == 0L) {
Copy link
Collaborator

@zwierski zwierski May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after if for readability if (!records.exists() || records.length() == 0L)

Copy link
Collaborator Author

@Tsathogguaa Tsathogguaa May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done on local

var reader = BufferedReader(FileReader(records))
var currentLine = reader.readLine()

while(currentLine != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after while


while(currentLine != null) {
var trimmed = currentLine.trim()
if(trimmed.isNotEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after if

var trimmed = currentLine.trim()
if(trimmed.isNotEmpty()) {
val split = trimmed.split("-")
if(split.size == 2) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after if

private fun recordProperties() {
var properties = File(applicationContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "properties.txt")

if(!properties.exists()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after if

Copy link
Collaborator

@zwierski zwierski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Commented on a few quick readability changes.

@Tsathogguaa
Copy link
Collaborator Author

Good job! Commented on a few quick readability changes.

Went over them and committed the changes. Can you quickly check if they are better now?

Copy link
Collaborator

@zwierski zwierski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

return songList
}

/**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

val totalPages = "20"
val totalSongs = "2000"


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space


init {
try {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra spaces

Copy link
Collaborator

@laurislopata laurislopata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor readability comments

@codeclimate
Copy link

codeclimate bot commented May 12, 2022

Code Climate has analyzed commit 8b297d0 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 83.3% (80% is the threshold).

This pull request will bring the total coverage in the repository to 80.3% (0.2% change).

View more on Code Climate.

@Tsathogguaa Tsathogguaa merged commit 38f4b93 into main May 12, 2022
@Tsathogguaa Tsathogguaa deleted the tsathogguaa/offline_mode branch May 12, 2022 18:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants