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
... | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
TextView dateTextView = findViewById(R.id.tvDate); | |
MyExample myExample = MyExample.getInstance(); | |
dateTextView.setText((new Date(myExample.getDate())).toString()); | |
} | |
... |
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
... | |
dependencies { | |
... | |
compile 'com.google.dagger:dagger:2.13' | |
annotationProcessor 'com.google.dagger:dagger-compiler:2.13' | |
} |
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
... | |
<TextView | |
android:id="@+id/tvDate" | |
android:layout_width="wrap_content" | |
... |
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
... | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
TextView dateTextView = findViewById(R.id.tvDate); | |
... |
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 com.larkintuckerllc.dagger; | |
interface MyExample { | |
long getDate(); | |
} |
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 com.larkintuckerllc.dagger; | |
import java.util.Date; | |
class MyExampleImpl implements MyExample { | |
private long mDate; | |
MyExampleImpl() { | |
mDate = new Date().getTime(); |
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 com.larkintuckerllc.dagger; | |
import javax.inject.Singleton; | |
import dagger.Module; | |
import dagger.Provides; | |
@Module | |
class MyModule { | |
@Provides |
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 com.larkintuckerllc.dagger; | |
import javax.inject.Singleton; | |
import dagger.Component; | |
@Singleton | |
@Component(modules = MyModule.class) | |
interface MyComponent { | |
void inject(MainActivity mainActivity); |
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
... | |
<application | |
... | |
android:theme="@style/AppTheme" | |
android:name=".MyApplication" | |
... |
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
import android.app.Application; | |
public class MyApplication extends Application { | |
private MyComponent mMyComponent; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
mMyComponent = createMyComponent(); | |
} |
OlderNewer