-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[CHORE/#12] 기초 세팅
- Loading branch information
Showing
13 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 2 additions & 1 deletion
3
.../java/com/release/keyneez/MainActivity.kt → ...keyneez/presentation/main/MainActivity.kt
This file contains 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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/release/keyneez/util/DiffCallback.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.release.keyneez.util | ||
|
||
import androidx.recyclerview.widget.DiffUtil | ||
|
||
class DiffCallback<T : Any>( | ||
val onItemsTheSame: (T, T) -> Boolean, | ||
val onContentsTheSame: (T, T) -> Boolean | ||
) : DiffUtil.ItemCallback<T>() { | ||
override fun areItemsTheSame(oldItem: T, newItem: T): Boolean = | ||
onItemsTheSame(oldItem, newItem) | ||
|
||
override fun areContentsTheSame(oldItem: T, newItem: T): Boolean = | ||
onContentsTheSame(oldItem, newItem) | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/release/keyneez/util/OnSingleClickListener.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.release.keyneez.util | ||
|
||
import android.os.SystemClock | ||
import android.view.View | ||
|
||
class OnSingleClickListener( | ||
private var interval: Int = 600, | ||
private var onSingleClick: (View) -> Unit | ||
) : View.OnClickListener { | ||
|
||
private var lastClickTime: Long = 0 | ||
|
||
override fun onClick(v: View) { | ||
val elapsedRealtime = SystemClock.elapsedRealtime() | ||
if ((elapsedRealtime - lastClickTime) < interval) { | ||
return | ||
} | ||
lastClickTime = elapsedRealtime | ||
onSingleClick(v) | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.release.keyneez.util | ||
|
||
sealed class UiState { | ||
object Success : UiState() | ||
data class Failure(val code: Int?) : UiState() | ||
object Error : UiState() | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/release/keyneez/util/binding/BindingActivity.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.release.keyneez.util.binding | ||
|
||
import android.os.Bundle | ||
import androidx.annotation.LayoutRes | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
|
||
abstract class BindingActivity<T : ViewDataBinding>( | ||
@LayoutRes private val layoutRes: Int | ||
) : AppCompatActivity() { | ||
protected lateinit var binding: T | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = DataBindingUtil.setContentView(this, layoutRes) | ||
binding.lifecycleOwner = this | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/release/keyneez/util/binding/BindingFragment.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.release.keyneez.util.binding | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.annotation.LayoutRes | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
import androidx.fragment.app.Fragment | ||
import com.release.keyneez.R | ||
|
||
abstract class BindingFragment<T : ViewDataBinding>( | ||
@LayoutRes private val layoutRes: Int | ||
) : Fragment() { | ||
private var _binding: T? = null | ||
protected val binding get() = _binding ?: error(getString(R.string.binding_error)) | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
_binding = DataBindingUtil.inflate(inflater, layoutRes, container, false) | ||
binding.lifecycleOwner = viewLifecycleOwner | ||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/release/keyneez/util/extension/ActivityExt.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.release.keyneez.util.extension | ||
|
||
import android.app.Activity | ||
import android.view.View | ||
|
||
/** hide keyboard from activity window */ | ||
fun Activity.hideKeyboard() { | ||
hideKeyboard(currentFocus ?: View(this)) | ||
} |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/release/keyneez/util/extension/ContextExt.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.release.keyneez.util.extension | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
import android.widget.Toast | ||
import com.google.android.material.snackbar.Snackbar | ||
|
||
/** hide keyboard from window */ | ||
fun Context.hideKeyboard(view: View) { | ||
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager | ||
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) | ||
} | ||
|
||
/** Make a Snackbar to display a message for 1.5 seconds */ | ||
fun Context.showSnackbar(view: View, msg: String) { | ||
Snackbar.make(view, msg, Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
/** Make a Toast to display a message for 1.5 seconds */ | ||
fun Context.showToast(msg: String) { | ||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
fun Context.dpToPx(dp: Int): Int { | ||
val scale = resources.displayMetrics.density | ||
return (dp * scale).toInt() | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/release/keyneez/util/extension/MutableLiveDataExt.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.release.keyneez.util.extension | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
|
||
fun <T> MutableLiveData<T>.notifyObserver() { | ||
this.value = this.value | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/release/keyneez/util/extension/ViewExt.kt
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.release.keyneez.util.extension | ||
|
||
import android.view.View | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.release.keyneez.util.OnSingleClickListener | ||
|
||
/** Register a callback to be invoked when this view is clicked. If this view was clicked within 1 second, the callback will not be invoked. */ | ||
fun View.setOnSingleClickListener(onSingleClick: (View) -> Unit) { | ||
setOnClickListener(OnSingleClickListener { onSingleClick(it) }) | ||
} | ||
|
||
/** Make a Snackbar to display a message for 1.5 seconds */ | ||
fun View.showSnackbar(message: String) { | ||
Snackbar.make(this, message, Snackbar.LENGTH_SHORT).show() | ||
} |
This file contains 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 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