Skip to content

Instantly share code, notes, and snippets.

View erdalkaymak's full-sized avatar

erdalkaymak

View GitHub Profile
private fun translateText(sourceText: String, fromLang: String, toLang: String, mTextView:TextView?) {
val setting: MLRemoteTranslateSetting =
MLRemoteTranslateSetting.Factory()
.setSourceLangCode(fromLang)
.setTargetLangCode(toLang)
.create()
val mlRemoteTranslator: MLRemoteTranslator =
MLTranslatorFactory.getInstance().getRemoteTranslator(setting)
if(!TextUtils.isEmpty(sourceText)){
dependencies{
implementation 'com.huawei.hms:ml-computer-translate:2.1.0.300'
}
<!-- Location permission. This permission is sensitive and needs to be dynamically applied for in the code after being declared. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
// HMS Awareness Kit
implementation 'com.huawei.hms:awareness:1.0.8.301'
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/gradient_white"
tools:context=".ui.weather.ViewPagerWeatherFragment">
<FrameLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.weather.WeeklyWeatherDetailFragment">
<TextView
android:id="@+id/detail_high_textview"
android:layout_height="wrap_content"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="2dp"
android:elevation="10dp"
app:cardBackgroundColor="@color/colorEditTextBackground">
<LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.weather.WeeklyWeatherDetailFragment">
<TextView
android:id="@+id/detail_high_weekly_textview"
android:layout_height="wrap_content"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardElevation="2dp"
android:elevation="10dp"
app:cardBackgroundColor="@color/colorEditTextBackground">
<LinearLayout
private fun initialize() {
val fragmentList = arrayListOf<Fragment>(
HourlyWeatherDetailFragment(), WeeklyWeatherDetailFragment()
)
val tabTitles = arrayListOf(
"Hourly Weather", "Weekly Weather"
)
val adapter = ViewPagerWeatherAdapter(
fragmentList,