Август 2022

Weather app #18 : Location

MainFragment import android.Manifestimport android.content.pm.PackageManagerimport android.os.Bundleimport android.util.Logimport androidx.fragment.app.Fragmentimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport android.widget.Toastimport androidx.activity.result.ActivityResultLauncherimport androidx.activity.result.contract.ActivityResultContractsimport androidx.core.app.ActivityCompatimport androidx.fragment.app.FragmentActivityimport androidx.fragment.app.activityViewModelsimport com.android.volley.Requestimport com.android.volley.toolbox.StringRequestimport com.android.volley.toolbox.Volleyimport com.google.android.gms.location.FusedLocationProviderClientimport com.google.android.gms.location.LocationRequestimport com.google.android.gms.location.LocationServicesimport com.google.android.gms.tasks.CancellationTokenSourceimport com.google.android.material.tabs.TabLayoutMediatorimport com.meter_alc_rgb.weatherappcursey.MainViewModelimport com.meter_alc_rgb.weatherappcursey.Rimport com.meter_alc_rgb.weatherappcursey.adapters.VpAdapterimport com.meter_alc_rgb.weatherappcursey.adapters.WeatherModelimport com.meter_alc_rgb.weatherappcursey.databinding.FragmentMainBindingimport com.squareup.picasso.Picassoimport org.json.JSONObjectconst val API_KEY = “Ваш API ключ”class MainFragment : Fragment() { private lateinit var fLocationClient: FusedLocationProviderClient private val fList = listOf( HoursFragment.newInstance(), DaysFragment.newInstance() ) private val tList = listOf( “Hours”, “Days” ) private lateinit var pLauncher: ActivityResultLauncher<String> private lateinit var… Подробнее »Weather app #18 : Location

Weather app #17 : Оброботка нажатий на список дней.

MainFragment import android.Manifestimport android.os.Bundleimport android.util.Logimport androidx.fragment.app.Fragmentimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport android.widget.Toastimport androidx.activity.result.ActivityResultLauncherimport androidx.activity.result.contract.ActivityResultContractsimport androidx.fragment.app.FragmentActivityimport androidx.fragment.app.activityViewModelsimport com.android.volley.Requestimport com.android.volley.toolbox.StringRequestimport com.android.volley.toolbox.Volleyimport com.google.android.material.tabs.TabLayoutMediatorimport com.meter_alc_rgb.weatherappcursey.MainViewModelimport com.meter_alc_rgb.weatherappcursey.Rimport com.meter_alc_rgb.weatherappcursey.adapters.VpAdapterimport com.meter_alc_rgb.weatherappcursey.adapters.WeatherModelimport com.meter_alc_rgb.weatherappcursey.databinding.FragmentMainBindingimport com.squareup.picasso.Picassoimport org.json.JSONObjectconst val API_KEY = “Ваш API ключ”class MainFragment : Fragment() { private val fList = listOf( HoursFragment.newInstance(), DaysFragment.newInstance() ) private val tList = listOf( “Hours”, “Days” ) private lateinit var pLauncher: ActivityResultLauncher<String> private lateinit var binding: FragmentMainBinding private val model: MainViewModel by activityViewModels() override fun onCreateView(… Подробнее »Weather app #17 : Оброботка нажатий на список дней.

Weather app #16 : Список прогноза по дням

MainFragment import android.Manifestimport android.os.Bundleimport android.util.Logimport androidx.fragment.app.Fragmentimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport android.widget.Toastimport androidx.activity.result.ActivityResultLauncherimport androidx.activity.result.contract.ActivityResultContractsimport androidx.fragment.app.FragmentActivityimport androidx.fragment.app.activityViewModelsimport com.android.volley.Requestimport com.android.volley.toolbox.StringRequestimport com.android.volley.toolbox.Volleyimport com.google.android.material.tabs.TabLayoutMediatorimport com.meter_alc_rgb.weatherappcursey.MainViewModelimport com.meter_alc_rgb.weatherappcursey.Rimport com.meter_alc_rgb.weatherappcursey.adapters.VpAdapterimport com.meter_alc_rgb.weatherappcursey.adapters.WeatherModelimport com.meter_alc_rgb.weatherappcursey.databinding.FragmentMainBindingimport com.squareup.picasso.Picassoimport org.json.JSONObjectconst val API_KEY = “Ваш API ключь”class MainFragment : Fragment() { private val fList = listOf( HoursFragment.newInstance(), DaysFragment.newInstance() ) private val tList = listOf( “Hours”, “Days” ) private lateinit var pLauncher: ActivityResultLauncher<String> private lateinit var binding: FragmentMainBinding private val model: MainViewModel by activityViewModels() override fun onCreateView(… Подробнее »Weather app #16 : Список прогноза по дням

Weather App JetPack Compose #7 : getData()

build.gradle (module dependencies) dependencies { implementation “com.android.volley:volley:1.2.1” implementation “com.google.accompanist:accompanist-pager:0.19.0” implementation “com.google.accompanist:accompanist-pager-indicators:0.19.0” implementation ‘androidx.core:core-ktx:1.7.0’ implementation “androidx.compose.ui:ui:$compose_version” implementation “androidx.compose.material:material:$compose_version” implementation “androidx.compose.ui:ui-tooling-preview:$compose_version” implementation ‘androidx.lifecycle:lifecycle-runtime-ktx:2.3.1’ implementation ‘androidx.activity:activity-compose:1.3.1’ implementation(“io.coil-kt:coil-compose:2.0.0-rc01”) testImplementation ‘junit:junit:4.13.2’ androidTestImplementation ‘androidx.test.ext:junit:1.1.3’ androidTestImplementation ‘androidx.test.espresso:espresso-core:3.4.0’ androidTestImplementation “androidx.compose.ui:ui-test-junit4:$compose_version” debugImplementation “androidx.compose.ui:ui-tooling:$compose_version” debugImplementation “androidx.compose.ui:ui-test-manifest:$compose_version”} MainActivity import android.content.Contextimport android.os.Bundleimport android.util.Logimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.compose.foundation.Imageimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.ui.Modifierimport androidx.compose.ui.draw.alphaimport androidx.compose.ui.layout.ContentScaleimport androidx.compose.ui.res.painterResourceimport com.android.volley.Requestimport com.android.volley.toolbox.StringRequestimport com.android.volley.toolbox.Volleyimport com.meter_alc_rgb.weatherappcomposey.screens.MainCardimport com.meter_alc_rgb.weatherappcomposey.screens.TabLayoutimport com.meter_alc_rgb.weatherappcomposey.ui.theme.WeatherAppComposeYThemeconst val API_KEY = “Ваш API KEY”class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?)… Подробнее »Weather App JetPack Compose #7 : getData()

Weather app #15 : Список прогноза по часам

HoursFragment import android.os.Bundleimport android.util.Logimport androidx.fragment.app.Fragmentimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport androidx.fragment.app.activityViewModelsimport androidx.recyclerview.widget.LinearLayoutManagerimport com.meter_alc_rgb.weatherappcursey.MainViewModelimport com.meter_alc_rgb.weatherappcursey.Rimport com.meter_alc_rgb.weatherappcursey.adapters.WeatherAdapterimport com.meter_alc_rgb.weatherappcursey.adapters.WeatherModelimport com.meter_alc_rgb.weatherappcursey.databinding.FragmentHoursBindingimport org.json.JSONArrayimport org.json.JSONObjectclass HoursFragment : Fragment() { private lateinit var binding: FragmentHoursBinding private lateinit var adapter: WeatherAdapter private val model: MainViewModel by activityViewModels() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { binding = FragmentHoursBinding.inflate(inflater, container, false) return binding.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) initRcView() model.liveDataCurrent.observe(viewLifecycleOwner){ adapter.submitList(getHoursList(it)) }… Подробнее »Weather app #15 : Список прогноза по часам

Weather app #14 : Показ прогноза на экране

MainFragment import android.Manifestimport android.content.Contextimport android.content.Intentimport android.content.pm.PackageManagerimport android.location.Geocoderimport android.location.Locationimport android.location.LocationManagerimport android.os.Bundleimport android.os.Looperimport android.provider.Settingsimport android.util.Logimport androidx.fragment.app.Fragmentimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport android.widget.Toastimport androidx.activity.result.ActivityResultLauncherimport androidx.activity.result.contract.ActivityResultContractsimport androidx.appcompat.app.AppCompatActivityimport androidx.core.app.ActivityCompatimport androidx.fragment.app.FragmentActivityimport androidx.fragment.app.activityViewModelsimport com.android.volley.Requestimport com.android.volley.toolbox.StringRequestimport com.android.volley.toolbox.Volleyimport com.google.android.gms.location.*import com.google.android.gms.tasks.*import com.google.android.material.tabs.TabLayoutMediatorimport com.meter_alc_rgb.weatherappcurse.MainViewModelimport com.meter_alc_rgb.weatherappcurse.Rimport com.meter_alc_rgb.weatherappcurse.adapters.VpAdapterimport com.meter_alc_rgb.weatherappcurse.adapters.WeatherItemimport com.meter_alc_rgb.weatherappcurse.databinding.FragmentMainBindingimport com.meter_alc_rgb.weatherappcurse.utils.DialogManagerimport com.meter_alc_rgb.weatherappcurse.utils.TimeUtilsimport com.squareup.picasso.Picassoimport org.json.JSONObjectimport java.lang.NumberFormatExceptionconst val API_KEY = “Ваш API ключ”class MainFragment : Fragment() { private var mFusedLocationClient: FusedLocationProviderClient? = null private val model : MainViewModel by activityViewModels() private val fList = listOf<Fragment>( HoursFragment.newInstance(), DaysFragment.newInstance()… Подробнее »Weather app #14 : Показ прогноза на экране