Skip to content

Commit

Permalink
[feat] #33 WebViewActivity로 이동을 위한 확장 함수 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jihyunniiii committed Jan 5, 2024
1 parent 58312f6 commit a87aafc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ package org.sopt.pingle.util.context

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import org.sopt.pingle.presentation.ui.common.WebViewActivity
import org.sopt.pingle.presentation.ui.common.WebViewActivity.Companion.WEB_VIEW_LINK

fun Context.showToast(message: String, isShort: Boolean = true) {
val duration = if (isShort) Toast.LENGTH_SHORT else Toast.LENGTH_LONG
Expand All @@ -25,3 +28,7 @@ fun Context.stringOf(@StringRes resId: Int) = getString(resId)
fun Context.colorOf(@ColorRes resId: Int) = ContextCompat.getColor(this, resId)

fun Context.drawableOf(@DrawableRes resId: Int) = ContextCompat.getDrawable(this, resId)

fun Context.navigateToWebView(link: String) = Intent(this, WebViewActivity::class.java).apply {
putExtra(WEB_VIEW_LINK, link)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.sopt.pingle.util.fragment

import android.content.Intent
import android.widget.Toast
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import org.sopt.pingle.presentation.ui.common.WebViewActivity

fun Fragment.showToast(message: String, isShort: Boolean = true) {
val duration = if (isShort) Toast.LENGTH_SHORT else Toast.LENGTH_LONG
Expand All @@ -18,3 +20,8 @@ fun Fragment.colorOf(@ColorRes resId: Int) = ContextCompat.getColor(requireConte

fun Fragment.drawableOf(@DrawableRes resId: Int) =
ContextCompat.getDrawable(requireContext(), resId)

fun Fragment.navigateToWebView(link: String) =
Intent(requireContext(), WebViewActivity::class.java).apply {
putExtra(WebViewActivity.WEB_VIEW_LINK, link)
}

0 comments on commit a87aafc

Please sign in to comment.