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 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
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
List<A> parseAItems(String data) => _parse(data, (e) => A.fromJson(e)); | |
List<B> parseBItems(String data) => _parse(data, (e) => B.fromJson(e)); | |
List<C> parseCItems(String data) => _parse(data, (e) => C.fromJson(e)); | |
List<T> _parse<T>(String data, T convert(dynamic e)) { | |
try { | |
List<dynamic> result = jsonDecode(data); | |
return result.map((e) => convert(e)).toList(); | |
} catch(Exception) { | |
print('Error parse items'); |
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
List<A> parseAItems(String data) { | |
try { | |
List<dynamic> result = jsonDecode(data); | |
return result.map((e) => A.fromJson(e)).toList(); | |
} catch(Exception) { | |
print('Error parse A items'); | |
return []; | |
} | |
} |
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
<intent-filter> | |
<action android:name="android.intent.action.SEARCH" /> | |
</intent-filter> | |
<meta-data | |
android:name="android.app.searchable" | |
android:resource="@xml/searchable" /> |
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 Foundation | |
import SwiftUI | |
struct ContentView : View { | |
@ObservedObject var networkManager = NetworkManager() | |
var body: some View { | |
NavigationView { | |
VStack { | |
if networkManager.loading { | |
Text("Loading ...") |
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 Foundation | |
import Combine | |
import Alamofire | |
class NetworkManager: ObservableObject { | |
@Published var movies = MovieList(results: []) | |
@Published var loading = false | |
private let api_key = "" | |
private let api_url_base = "https://api.themoviedb.org/3/discover/movie?sort_by=popularity.desc&api_key=" | |
init() { |
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.vad.vs36 | |
import android.os.Bundle | |
import com.google.android.material.snackbar.Snackbar | |
import androidx.appcompat.app.AppCompatActivity | |
import android.view.Menu | |
import android.view.MenuItem | |
import kotlinx.android.synthetic.main.activity_main.* |
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 SwiftUI | |
struct ContentView : View { | |
@State var networkManager = NetworkManager() | |
var body: some View { | |
NavigationView { | |
List(networkManager.movies.results.identified(by: \.id)) { movie in | |
NavigationLink(destination: MovieDetails(movie: movie)){ | |
MovieRow(movie: movie) | |
} |
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 Combine | |
import SwiftUI | |
class NetworkManager: BindableObject { | |
var didChange = PassthroughSubject<NetworkManager, Never>() | |
var movies = MovieList(results: []){ | |
didSet { | |
didChange.send(self) | |
} | |
} |