Skip to content

Instantly share code, notes, and snippets.

View gracietti's full-sized avatar

Marcelo Gracietti gracietti

View GitHub Profile
@gracietti
gracietti / Contador de Likes
Last active October 22, 2017 19:08
Contador de Like. Enviado como tarefa para a Turma I do Projeto Mão na Massa no dia 22/Out/2017.
// Nessa tarefa, nos queremos saber quantos likes cada post recebeu.
// Já temos alguns dados de exemplo criados, simulando que alguns usuários deram like em alguns posts.
// Agora queremos passar o ID de um post e saber o total de liks recebidos por ele.
// Com essa atividade, vocês já relembrarão alguns comandos de lógica de programaço em KOTLIN.
// Dica: para implementar o contador, vocês precisaro usat FOR e IF.
@gracietti
gracietti / ListEventImagesConverter.kt
Last active August 24, 2017 12:52
Parceler converter from an Array of object (EventImages, in this case). Just replace `EventImages` by the object on the List you need to convert.
package ....models.entities.Converters
import android.os.Parcel
import org.parceler.Parcels
import org.parceler.converter.ArrayListParcelConverter
import ....models.entities.Event.EventImages
/**
* Created by gracietti on 11/08/17.
@gracietti
gracietti / RetrofitHelper + Refresh Auth0 Token
Created August 16, 2017 15:21
Changes needed on RetrofitHelper to add logics to refresh Auth0 token automatically
object RetrofitHelper {
(...)
private fun rebuildRetrofit(useAuth: Boolean) {
val client = buildOkHttpClient(useAuth)
retrofit = Retrofit.Builder()
.baseUrl(BuildConfig.API_BASE_URL)
@gracietti
gracietti / Auth0.renewAuth(refreshToken)
Last active August 16, 2017 15:13
Call to Auth0 API to get new Access Token based on existing refresh token
class SessionHelper private constructor() {
...
fun refreshCredentials(): String? {
@gracietti
gracietti / Event
Created June 6, 2017 13:55
Example of an Entity with computed properties
import Foundation
import RealmSwift
import ObjectMapper
import ObjectMapper_Realm
class Event: Object, Mappable, Identifiable, RandomizePlaceholder, TrackableEntity {
dynamic var id: Int = 0
fileprivate dynamic var stringType: String = ""
fileprivate dynamic var title = ""
import Foundation
import UIKit
class KeyboardController: NSObject {
var viewController: UIViewController
var constraint: NSLayoutConstraint
var isKeyboardHidden: Bool {
return constraint.constant == 0
}
@gracietti
gracietti / ProductContracts.swift
Created April 11, 2017 19:49
ProductContracts.swift
protocol ProductCategoriesCoreDelegate: class {
func setupSubmodules(with product: Product)
func setupView(for category: Category)
}
protocol ProductCategoriesPageDelegate: class {
func onPageChanged(_ newPageIndex: Int)
}
@gracietti
gracietti / ProductCategoriesPresenter.swift
Created April 11, 2017 19:48
ProductCategoriesPresenter.swift
import Foundation
class ProductCategoriesPresenter: ProductCategoriesPresentation {
// MARK: Properties
weak var view: ProductCategoriesView?
var router: ProductCategoriesWireframe?
var interactor: ProductCategoriesUseCase?
@gracietti
gracietti / ProductCategoriesPageViewController.swift
Created April 11, 2017 19:47
ProductCategoriesPageViewController.swift
import UIKit
class ProductCategoriesPageViewController: UIPageViewController {
// MARK: Properties
var categoriesViewPageDelegate: ProductCategoriesPageDelegate?
var pages = [UIViewController]()
// MARK: Lifecycle
@gracietti
gracietti / ProductCategoriesViewController.swift
Created April 11, 2017 19:46
ProductCategoriesViewController.swift
import Foundation
import SMPageControl
class ProductCategoriesViewController: BaseViewController {
// MARK: Constants
let categories = Constants.categories
// MARK: Properties