Skip to content
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

Convert util package into Kotlin #187

Merged
merged 13 commits into from
Oct 19, 2019

Conversation

laco-dev
Copy link
Contributor

@laco-dev laco-dev commented Oct 12, 2019

Fixes issue
  • No issue
This PR changes:

Convert to

CustomPagerSnapHelper RadioWithTextButton RegexUtil SingleMediaScanner SquareFrameLayout SquareImageView UiUtil

Except to

  • TouchImageView is open source project
  • CameraUtil is converting by 이다혜 in contributon team.

Change to

  1. Use to static method by top-level function
    • After convert into kotlin that, It would be solved

BaseActivity BaseFragment AlbumActivity AlbumController DetailActivity PickerActivity PickerController RegexTest

  1. Wrong description
    • Change description of deprecated message

FishBunCreator

  1. Change SAM and interface to high-order-function

CustomPagerSnapHelper SingleMediaScanner

Add to

  • RadioWithTextButton was used whether selected text or drawable. So I added RadioType sealed class.
  • In the after, separate status by type variable.
    e.g)
with(radioType) {
    isRadioText { // text mode
        ...
    } isRadioDrawable { // drawable mode
       ...
    } isRadioNone { // no select
        ...
    }
}
  • Move setTextSizeForWidth method to DrawUtil (RadioWithTextButton >> DrawUtil)

Etc

  • Using tips: isLandscape function in UiUtil
context.isLandscape { // kotlin
    // ...
}

isLandscape { // kotlin, in Context(Activity)
    // ...
}

if (isLandscape()) { // kotlin, in Context(Activity)
    // ...
}

if (UiUtil.isLandscape(context)) // Java
    // ...
}

feature:
    - remove `ScanListener` abstract class(replace high-order-function)
feature:
    - Change `checkGif_isCorrect` test(static method)
feature:
    - Distribute Radio Type (Text, Drawable, None) with sealed
    - Fix wrong words (unselect, drawTextCentred)
     - isChecked -> isSelected
     - unSelect -> unselect
…/github.com/laco-dev/FishBun into feature/java-to-kotlin/util

# Conflicts:
#	FishBun/src/main/java/com/sangcomz/fishbun/util/RadioWithTextButton.java
@laco-dev laco-dev force-pushed the feature/java-to-kotlin/util branch from b897bfa to 0ab6696 Compare October 12, 2019 04:19
…ature/java-to-kotlin/util

# Conflicts:
#	FishBun/src/androidTest/java/com/sangcomz/fishbun/util/RadioWithTextButtonTest.kt
#	FishBun/src/main/java/com/sangcomz/fishbun/util/RadioWithTextButton.java
@laco-dev laco-dev force-pushed the feature/java-to-kotlin/util branch from ca6ad95 to 35e3f65 Compare October 12, 2019 04:36
@codecov
Copy link

codecov bot commented Oct 12, 2019

Codecov Report

Merging #187 into develop will increase coverage by 0.14%.
The diff coverage is 47.7%.

Impacted file tree graph

@@             Coverage Diff              @@
##             develop    #187      +/-   ##
============================================
+ Coverage       3.14%   3.28%   +0.14%     
- Complexity         0       1       +1     
============================================
  Files             31      32       +1     
  Lines           1654    1613      -41     
  Branches         202     198       -4     
============================================
+ Hits              52      53       +1     
+ Misses          1600    1558      -42     
  Partials           2       2
Impacted Files Coverage Δ Complexity Δ
...c/main/java/com/sangcomz/fishbun/BaseActivity.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...c/main/java/com/sangcomz/fishbun/BaseFragment.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...c/main/java/com/sangcomz/fishbun/FishBunCreator.kt 0% <ø> (ø) 0 <0> (ø) ⬇️
...a/com/sangcomz/fishbun/ui/album/AlbumActivity.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...va/com/sangcomz/fishbun/util/SingleMediaScanner.kt 0% <0%> (ø) 0 <0> (?)
...com/sangcomz/fishbun/util/CustomPagerSnapHelper.kt 0% <0%> (ø) 0 <0> (?)
...com/sangcomz/fishbun/ui/detail/DetailActivity.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...m/sangcomz/fishbun/ui/picker/PickerController.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../src/main/java/com/sangcomz/fishbun/util/UiUtil.kt 0% <0%> (ø) 0 <0> (?)
.../java/com/sangcomz/fishbun/util/SquareImageView.kt 0% <0%> (ø) 0 <0> (?)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 23b04cc...35e3f65. Read the comment docs.

@sangcomz sangcomz self-requested a review October 17, 2019 13:45
@sangcomz
Copy link
Owner

I have a question. What are the advantages of moving setTextSizeForWidth to DrawUtil?

(When I look at my old code, I wonder why I declared it a static method. 🤔)

@laco-dev
Copy link
Contributor Author

laco-dev commented Oct 18, 2019

@sangcomz

static method has features. from this site

  1. It never can't use instance variable
  2. No side effects
  3. Reused
    ...

setTextSizeForWidth was private static method in RadioTextButton. But It had been tested in RadioWithTextButtonTest.

I don't know why test private method really (Let me know why?). Also kotlin can't use private or protected method directly (e.g in testcode).
(VisibleForTesting annotation could use until protected or package private)

If to keep private method, Test code has to use reflection or another public method.
This site makes I was helped.

@sangcomz
Copy link
Owner

You don't need to change to a private method.

I was wondering why I just moved it. But I got some understanding. Thank you. @laco-dev

@sangcomz sangcomz merged commit 3d1cb7f into sangcomz:develop Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants