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
@Module | |
abstract class FragmentModule { | |
@ContributesAndroidInjector | |
abstract fun contributeNewsFragment(): NewsFragment | |
@ContributesAndroidInjector | |
abstract fun contributeNewDetailsFragment(): NewDetailsFragment | |
} |
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
@Module | |
abstract class ViewModelModule { | |
@Binds | |
abstract fun bindViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory | |
@Binds | |
@IntoMap | |
@ViewModelKey(MainViewModel::class) | |
abstract fun bindMainViewModel(mainViewModel: MainViewModel): ViewModel |
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.fevziomurtekin.hackernewsapp | |
import android.app.Application | |
import com.fevziomurtekin.di.onlineNewsApp | |
import org.koin.android.ext.android.startKoin | |
class BaseApplication : Application(){ | |
override fun onCreate() { | |
super.onCreate() |
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.fevziomurtekin.di | |
import com.fevziomurtekin.hackernewsapp.data.network.RetroInterface | |
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory | |
import okhttp3.OkHttpClient | |
import okhttp3.logging.HttpLoggingInterceptor | |
import org.koin.dsl.module.applicationContext | |
import retrofit2.Retrofit | |
import retrofit2.converter.gson.GsonConverterFactory | |
import java.util.concurrent.TimeUnit |
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 fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
when(requestCode){ | |
SPEECH_INPUT->{ | |
if(resultCode== Activity.RESULT_OK | |
&& data !=null){ | |
val result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS) | |
edittext.text=Editable.Factory.getInstance().newEditable(result[0]) | |
sendMessage(send) | |
} |
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
private fun appendText(message: String, type: Int) { | |
val layout: FrameLayout | |
when (type) { | |
USER -> layout = appendUserText() | |
BOT -> layout = appendBotText() | |
else -> layout = appendBotText() | |
} | |
layout.isFocusableInTouchMode = true | |
linear_chat.addView(layout) | |
val tv = layout.findViewById<TextView>(R.id.chatMsg) |
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
fun onResult(response: DetectIntentResponse?) { | |
try { | |
if (response != null) { | |
var botReply:String="" | |
if(response.queryResult.fulfillmentText==" ") | |
botReply= response.queryResult.fulfillmentMessagesList[0].text.textList[0].toString() | |
else | |
botReply= response.queryResult.fulfillmentText | |
appendText(botReply, BOT) |
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
private fun initAsisstantVoice() { | |
asistan_voice= TextToSpeech(applicationContext,object : TextToSpeech.OnInitListener { | |
override fun onInit(status: Int) { | |
if (status!=TextToSpeech.ERROR){ | |
asistan_voice?.language=Locale("tr") | |
} | |
} | |
}) |
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
private fun sendMicrophoneMessage(view:View){ | |
val intent: Intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) | |
intent.putExtra( | |
RecognizerIntent.EXTRA_LANGUAGE_MODEL, | |
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM | |
) | |
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()) | |
intent.putExtra( | |
RecognizerIntent.EXTRA_PROMPT, | |
getString(R.string.speech_prompt) |
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
class RequestTask : AsyncTask<Void, Void, DetectIntentResponse> { | |
var activity: Activity? = null | |
private var session: SessionName? = null | |
private var sessionsClient: SessionsClient? = null | |
private var queryInput: QueryInput? = null | |
constructor(activity: Activity,session:SessionName,sessionsClient: SessionsClient,queryInput: QueryInput){ | |
this.activity=activity |