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
buildscript { | |
repositories { | |
jcenter() | |
google() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:3.0.0' | |
// NOTE: Do not place your application dependencies here; they belong | |
// in the individual module build.gradle files |
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
public static MyViewModel obtainViewModel(FragmentActivity activity) { | |
Log.d(TAG, "obtainViewModel"); | |
// Use a Factory to inject dependencies into the ViewModel | |
ViewModelFactory factory = ViewModelFactory.getInstance(activity.getApplication()); | |
return ViewModelProviders.of(activity, factory).get(MyViewModel.class); |
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
@NonNull | |
private MyFragment findOrCreateViewFragment() { | |
MyFragment myFragment = (MyFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame); | |
if (myFragment == null) { | |
Log.d(TAG, "createFragment"); |
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
package xxx.xxxx.xxxxx; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.design.widget.NavigationView; | |
import android.support.v4.view.GravityCompat; | |
import android.support.v4.widget.DrawerLayout; | |
import android.support.v7.app.ActionBar; | |
import android.support.v7.app.ActionBarDrawerToggle; |