This file contains hidden or 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
@Module | |
public abstract class ActivityBindingModule { | |
@ActivityScoped | |
@ContributesAndroidInjector(modules = {QuakesModule.class}) | |
abstract QuakesActivity ratesActivity(); | |
} |
This file contains hidden or 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
@ActivityScoped | |
public class MessageFragment extends DaggerFragment implements BaseView { | |
private TextView mMessageTextView; | |
private MessageViewModel mViewModel; | |
@Inject | |
ViewModelProvider.Factory viewModelFactory; | |
@Inject |
This file contains hidden or 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
@Module | |
public abstract class MessageModule { | |
@FragmentScoped | |
@ContributesAndroidInjector | |
abstract MessageFragment messageFragment(); | |
} |
This file contains hidden or 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
@AppScoped | |
public class MessageViewModel extends ViewModel{ | |
@NonNull | |
private final MessageRepository mRepository; | |
@Inject | |
public MessageViewModel(@NonNull MessageRepository repository) { | |
this.mRepository = repository; | |
} |
This file contains hidden or 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
@AppScoped | |
public class MessageViewModelFactory implements ViewModelProvider.Factory { | |
private final Map<Class<? extends ViewModel>, Provider<ViewModel>> creators; | |
@Inject | |
public MessageViewModelFactory(Map<Class<? extends ViewModel>, Provider<ViewModel>> creators) { | |
this.creators = creators; | |
} | |
@SuppressWarnings("unchecked") |
This file contains hidden or 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
@Module | |
public abstract class ViewModelModule { | |
@Binds | |
@IntoMap | |
@ViewModelKey(MessageViewModel.class) | |
abstract ViewModel bindMessageViewModel(MessageViewModel messageViewModel); | |
@Binds | |
@AppScoped | |
abstract ViewModelProvider.Factory bindViewModelFactory(MessageViewModelFactory factory); |
This file contains hidden or 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 class MessageUiModel { | |
private final String mMessageText; | |
public MessageUiModel(String messageText) { | |
this.mMessageText = messageText; | |
} | |
public String getMessageText() { | |
return mMessageText; |
This file contains hidden or 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
@AppScoped | |
public class MessageRepository { | |
@Inject | |
public MessageRepository() { | |
} | |
@NonNull | |
public String getData(){ | |
return "Hello Medium!"; | |
} |
This file contains hidden or 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
private fun promptSpeechInput() { | |
val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) | |
intent.putExtra( | |
RecognizerIntent.EXTRA_LANGUAGE_MODEL, | |
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM | |
) | |
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, activity?.application?.packageName?: "") | |
speechRecognizer?.startListening(intent) | |
} |
This file contains hidden or 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
private var speechRecognizer: SpeechRecognizer? = null | |
... | |
private fun listenToSpeechInput() { | |
speechRecognizer = SpeechRecognizer.createSpeechRecognizer(context) | |
speechRecognizer?.setRecognitionListener(object: RecognitionListener { | |
... | |
override fun onResults(p0: Bundle?) { | |
speechRecognizer?.stopListening() |