Skip to content

Commit

Permalink
[MOD/#6] requireContext() 메서드 활용 및 Ktlint 형식 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Nov 16, 2022
1 parent 20618c7 commit 68b8ad0
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 27 deletions.
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@
</activity>
<activity
android:name=".presentation.signup.SignUpActivity"
android:exported="true" />
<activity
android:name=".HomeActivity"
android:exported="true" />
android:exported="false" />
<activity
android:name=".presentation.MainActivity"
android:exported="true" />
android:exported="false" />
</application>

</manifest>
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/sample/api/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ interface AuthService {
fun signup(
@Body request: RequestSignupDto
): Call<ResponseSignupDto>
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/sample/api/FollowerService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ interface FollowerService {
fun getFollowerList(
@Query("page") page: Int
): Call<ResponseGetFollowerListDto>
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/sample/base/UtilExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ fun Context.showSnackbar(view: View, msg: String) {
/** Toast 확장함수 */
fun Context.showToast(msg: String) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ data class RequestLoginDto(
val email: String,
@SerialName("password")
val password: String
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ data class RequestSignupDto(
@SerialName("password")
val password: String,
@SerialName("name")
val name: String,
val name: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ class MainActivity : AppCompatActivity() {
replace<T>(R.id.container_home, T::class.java.canonicalName)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FollowerAdapter(context: Context) : RecyclerView.Adapter<RecyclerView.View
false
)
)
else -> throw ClassCastException("Unkown View Type : ${viewType}")
else -> throw ClassCastException("Unkown View Type : $viewType")
}
}

Expand Down Expand Up @@ -64,10 +64,10 @@ class FollowerAdapter(context: Context) : RecyclerView.Adapter<RecyclerView.View
}

class FollowerHeaderViewHolder(private val binding: HeaderHomeFollowerBinding) :
RecyclerView.ViewHolder(binding.root) {}
RecyclerView.ViewHolder(binding.root)

companion object {
const val VIEW_TYPE_HEADER = 0
const val VIEW_TYPE_ITEM = 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import org.sopt.sample.data.remote.ResponseGetFollowerListDto

class FollowerViewModel : ViewModel() {
val followerList = mutableListOf<ResponseGetFollowerListDto.Follower>()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class HomeFragment : Fragment() {
private val followerViewModel by viewModels<FollowerViewModel>()

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentHomeBinding.inflate(inflater, container, false)
Expand Down Expand Up @@ -60,7 +61,7 @@ class HomeFragment : Fragment() {

// 팔로워가 존재하지 않는 경우
if (response.body()?.data == null) {
context?.showSnackbar(binding.root, getString(R.string.msg_home_null))
requireContext().showSnackbar(binding.root, getString(R.string.msg_home_null))
return
}

Expand All @@ -82,9 +83,9 @@ class HomeFragment : Fragment() {
VIEW_TYPE_ITEM -> return 1
else -> throw ClassCastException(
"Unkown View Type : ${
adapter.getItemViewType(
position
)
adapter.getItemViewType(
position
)
}"
)
}
Expand All @@ -94,14 +95,14 @@ class HomeFragment : Fragment() {
}
// get follower list fail
else {
context?.showSnackbar(binding.root, getString(R.string.msg_home_fail))
requireContext().showSnackbar(binding.root, getString(R.string.msg_home_fail))
Log.e("GET_FOLLOWER_LIST", "code : " + response.code())
Log.e("GET_FOLLOWER_LIST", "message : " + response.message())
}
}

override fun onFailure(call: Call<ResponseGetFollowerListDto>, t: Throwable) {
context?.showSnackbar(binding.root, getString(R.string.msg_home_fail))
requireContext().showSnackbar(binding.root, getString(R.string.msg_home_fail))
Log.e("GET_FOLLOWER_LIST", "message : " + t.message)
}
})
Expand All @@ -112,4 +113,4 @@ class HomeFragment : Fragment() {
return HomeFragment()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ class LoginActivity : AppCompatActivity() {
startActivity(intent)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class SettingFragment : Fragment() {
get() = requireNotNull(_binding) { "binding value was null." }

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentSettingBinding.inflate(inflater, container, false)
Expand Down Expand Up @@ -46,4 +47,4 @@ class SettingFragment : Fragment() {
return SettingFragment()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ class SignUpActivity : AppCompatActivity() {
})
}
}
}
}

0 comments on commit 68b8ad0

Please sign in to comment.