This file contains hidden or 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'; | |
| import 'package:flutter/services.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Sliding Login', |
This file contains hidden or 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 _MyHomePageState extends State<MyHomePage> { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| body: Stack( | |
| children: <Widget>[ | |
| Positioned( | |
| top: 0, | |
| bottom: MediaQuery.of(context).size.height / 2, | |
| width: double.maxFinite, |
This file contains hidden or 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 void onCreate() { | |
| super.onCreate(); | |
| if (DEVELOPER_MODE) { | |
| StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() | |
| .detectDiskReads() | |
| .detectDiskWrites() | |
| .detectNetwork() // ou .detectAll() | |
| .penaltyLog() | |
| .build()); |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.drawerlayout.widget.DrawerLayout | |
| xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context=".MainActivity"> | |
| <FrameLayout |
This file contains hidden or 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
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| package="com.pedromassango.alarmmanagersample"> | |
| <application | |
| ... > | |
| <activity android:name=".MainActivity"> | |
| ... | |
| </activity> | |
This file contains hidden or 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.pedromassango.programmers.extras; | |
| import android.app.ActivityManager; | |
| import android.content.Context; | |
| import android.os.Process; | |
| import android.support.v7.app.AlertDialog; | |
| import android.util.Log; | |
| import android.widget.Toast; | |
| import java.util.ArrayList; |
This file contains hidden or 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 MyApp: Application() { | |
| override fun onCreate() { | |
| super.onCreate() | |
| // call this to setup Koin with your modules | |
| startKoin(this, listOf(DependeciesModule.appModule) ) | |
| } | |
| } |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
| // we get our viewModel from Koin | |
| private val mainViewModel: MainViewModel by viewModel() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.main_activity) | |
| mainViewModel.loadData()?.observe(this, Observer{ |
This file contains hidden or 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
| object DependeciesModule { | |
| val appModule = module { | |
| // Usinlge only one instance of the giving class will run at time | |
| single { Repository() } | |
| // Koin will take care of creating ViewModel's dependencies | |
| viewModel { MainViewModel( get()) } | |
| } | |
| } |
This file contains hidden or 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
| //... Code removed for brevity | |
| class MainViewModel(private val repository: Repository) : ViewModel() { | |
| private var messageData: MutableLiveData<String>? = null | |
| fun loadData(): LiveData<String>?{ | |
| if(messageData == null){ | |
| messageData = MutableLiveData() | |
| } |