forked from tunitowen/DevDrawer
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit reimplements the UI with JetPack Compose.
- Loading branch information
Showing
108 changed files
with
4,414 additions
and
1,420 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
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,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">DevDrawer2 (Debug)</string> | ||
<string name="app_name" translatable="false">DevDrawer2 (Debug)</string> | ||
</resources> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,26 @@ | ||
package de.psdev.devdrawer | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.annotation.CallSuper | ||
import androidx.annotation.StringRes | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.LifecycleCoroutineScope | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.viewbinding.ViewBinding | ||
import de.psdev.devdrawer.analytics.TrackingService | ||
import javax.inject.Inject | ||
|
||
abstract class BaseFragment<T : ViewBinding> : Fragment() { | ||
open class BaseFragment : Fragment() { | ||
|
||
@Inject | ||
lateinit var trackingService: TrackingService | ||
|
||
private var _binding: T? = null | ||
// This property is only valid between onCreateView and onDestroyView. | ||
protected val binding get() = _binding!! | ||
|
||
protected var toolbarTitle: CharSequence | ||
get() = requireActivity().title | ||
set(value) { | ||
requireActivity().title = value | ||
} | ||
|
||
final override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View = createViewBinding(inflater, container, savedInstanceState).also { viewBinding -> | ||
_binding = viewBinding | ||
}.root | ||
|
||
protected abstract fun createViewBinding( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): T | ||
|
||
@CallSuper | ||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
val Fragment.viewLifecycleScope: LifecycleCoroutineScope | ||
get() = viewLifecycleOwner.lifecycleScope | ||
|
||
protected fun updateToolbarTitle(@StringRes resId: Int) { | ||
requireActivity().setTitle(resId) | ||
trackingService.trackScreen(this::class.java, getString(resId)) | ||
} | ||
|
||
val Fragment.viewLifecycleScope: LifecycleCoroutineScope | ||
get() = viewLifecycleOwner.lifecycleScope | ||
|
||
} | ||
} |
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.