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 NewsListAdapter(private val retry: () -> Unit) | |
: PagedListAdapter<News, RecyclerView.ViewHolder>(NewsDiffCallback) { | |
private val DATA_VIEW_TYPE = 1 | |
private val FOOTER_VIEW_TYPE = 2 | |
private var state = State.LOADING | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { | |
return if (viewType == DATA_VIEW_TYPE) NewsViewHolder.create(parent) else ListFooterViewHolder.create(retry, parent) |
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 NewsListActivity : AppCompatActivity() { | |
private lateinit var viewModel: NewsListViewModel | |
private lateinit var newsListAdapter: NewsListAdapter | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_news_list) | |
viewModel = ViewModelProviders.of(this) |
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
abstract class BaseStatefulWidget extends StatefulWidget { | |
String getTitle(); | |
Widget body(AsyncSnapshot snapshot); | |
Future future(); | |
@override | |
State<StatefulWidget> createState() => BaseState(getTitle()); | |
} |
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
<!DOCTYPE html> | |
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Vue.js | Making API calls using Axios</title> | |
</head> | |
<body style="text-align: center"> | |
<div id="app" style="display: inline-block;margin-top: 100px"> | |
<img v-bind:src="avatar" alt=""> | |
<h1 style="margin-bottom: 0">{{name}}</h1> |
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
public class UnderMaintenance { | |
public boolean is_under_maintenance; | |
public String under_maintenance_message; | |
public UnderMaintenance() { | |
} | |
} |
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
public abstract class BaseActivity extends AppCompatActivity { | |
private AlertDialog dialog; | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
connectToFirebase(); | |
} |
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_web/material.dart'; | |
void main() => runApp(App()); | |
class App extends MaterialApp { | |
@override | |
String get title => "Chuck Norris Jokes"; | |
@override | |
ThemeData get theme => ThemeData(primarySwatch: Colors.blue); | |
@override |
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
//........................................... | |
Future<String> fetchJoke() async { | |
var url = "https://api.chucknorris.io/jokes/random?category=dev"; | |
var response = await http.get(url); | |
if (response.statusCode == 200) { | |
var jsonResponse = convert.jsonDecode(response.body); | |
return jsonResponse['value']; | |
} else { | |
return ("Unexpected error occurred."); | |
} |
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
//........................................... | |
body: FutureBuilder<String>( | |
future: fetchJoke(), | |
builder: (BuildContext context, AsyncSnapshot<String> snapshot) { | |
switch (snapshot.connectionState) { | |
case ConnectionState.none: | |
case ConnectionState.active: | |
case ConnectionState.waiting: | |
return Center(child: CircularProgressIndicator()); | |
case ConnectionState.done: |
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 PhotosListScreen extends StatefulWidget { | |
PhotosListScreen({Key key}) : super(key: key); | |
@override | |
_PhotosListScreenState createState() => _PhotosListScreenState(); | |
} | |
class _PhotosListScreenState extends State<PhotosListScreen> { | |
bool _hasMore; | |
int _pageNumber; | |
bool _error; | |
bool _loading; |