I'm like in a kind of a vicious circle. I'm trying to implement MVVM pattern into my app, but to instantiate ViewModel the next way:
ViewModel loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
it's necessary to extend AppCompat, but when I extend AppCompatActivity in my BaseActivity class I get an exception of type:
"You need to use a Theme.AppCompat theme (or descendant) with this activity"
And the problem is I cannot use AppCompat theme in manifest because I'm already using
android:theme="@style/Theme.myTheme.TitleBar"
TitleBar:
<resources>
<!--parent="@style/Theme.AppCompat"-->
<style name="Theme.myTheme.TitleBar" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>
</style>
</resources>
and then I configure the ActionBar in code and then in BaseActivity:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
So I don't know how to combine extending AppCompatActivity with custom title feature.
Edit 1: In reply to @CommonsWare
If I set
android:theme="@style/Theme.AppCompat.NoActionBar"
in my Manifest file then I get thenext exception:
"You cannot combine custom titles with other title features"
as soon as the app starts, in the first line of the next piece of code which creates the drawer menu container:
// HACK: "steal" the first child of decor view
ViewGroup decor = (ViewGroup) ((Activity)context).getWindow().getDecorView();
View child = decor.getChildAt(0);
decor.removeView(child);
FrameLayout container = drawer.findViewById(R.id.container); // This is the container we defined just now.
container.addView(child);
So I guess no luck yet :(