-
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.
Merge remote-tracking branch 'origin/feature/BDBD-506' into stage/san…
…dbox
- Loading branch information
Showing
12 changed files
with
141 additions
and
239 deletions.
There are no files selected for viewing
13 changes: 3 additions & 10 deletions
13
app/src/main/kotlin/com/fakedevelopers/bidderbidder/ui/LoginActivity.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 |
---|---|---|
@@ -1,15 +1,8 @@ | ||
package com.fakedevelopers.bidderbidder.ui | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.fakedevelopers.bidderbidder.R | ||
import com.fakedevelopers.bidderbidder.databinding.ActivityLoginBinding | ||
import com.fakedevelopers.bidderbidder.ui.base.BaseActivity | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class LoginActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_login) | ||
} | ||
} | ||
class LoginActivity : BaseActivity<ActivityLoginBinding>(ActivityLoginBinding::inflate) |
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
19 changes: 19 additions & 0 deletions
19
app/src/main/kotlin/com/fakedevelopers/bidderbidder/ui/base/BaseActivity.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.fakedevelopers.bidderbidder.ui.base | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.viewbinding.ViewBinding | ||
|
||
abstract class BaseActivity<VB : ViewBinding>( | ||
private val bindingFactory: (LayoutInflater) -> VB | ||
) : AppCompatActivity() { | ||
|
||
protected lateinit var binding: VB | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = bindingFactory(layoutInflater) | ||
setContentView(binding.root) | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/src/main/kotlin/com/fakedevelopers/bidderbidder/ui/base/BaseFragment.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,58 @@ | ||
package com.fakedevelopers.bidderbidder.ui.base | ||
|
||
import android.content.Intent | ||
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.google.android.material.snackbar.Snackbar | ||
|
||
abstract class BaseFragment<VB : ViewDataBinding>( | ||
@LayoutRes private val layoutRes: Int | ||
) : Fragment() { | ||
|
||
private var _binding: VB? = null | ||
protected val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = DataBindingUtil.inflate(inflater, layoutRes, container, false) | ||
return binding.run { | ||
lifecycleOwner = viewLifecycleOwner | ||
root | ||
} | ||
} | ||
|
||
fun sendSnackBar( | ||
message: String, | ||
@androidx.annotation.IntRange(from = -2) length: Int = Snackbar.LENGTH_SHORT, | ||
anchorView: View? = null | ||
) { | ||
Snackbar.make( | ||
binding.root, | ||
message, | ||
length | ||
).apply { | ||
if (anchorView != null) { | ||
this.anchorView = anchorView | ||
} | ||
}.show() | ||
} | ||
|
||
fun navigateActivity(activity: Class<*>) { | ||
startActivity(Intent(requireContext(), activity)) | ||
requireActivity().finish() | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
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
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
Oops, something went wrong.