Skip to content

Instantly share code, notes, and snippets.

View bitsydarel's full-sized avatar

Darel Bitsy bitsydarel

View GitHub Profile
void main() {
runApp(_SwitchingThemeApp());
}
/// Properties that help me keep track of the example being run.
bool _useMaterial = false;
class _SwitchingThemeApp extends StatefulWidget {
@override
_SwitchingThemeAppState createState() => _SwitchingThemeAppState();
@bitsydarel
bitsydarel / BottomNavigationViewBehavior.kt
Created February 15, 2018 18:30
Layout behavior for Bottom Navigation View to hide and show on scroll. Root ViewGroup should be CoordinatorLayout.
class BottomNavigationViewBehaviour(context: Context, attrs: AttributeSet) : CoordinatorLayout.Behavior<BottomNavigationView>(context, attrs) {
private var height: Int = 0
override fun onLayoutChild(parent: CoordinatorLayout?, child: BottomNavigationView?, layoutDirection: Int): Boolean {
height = child!!.height
return super.onLayoutChild(parent, child, layoutDirection)
}
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: BottomNavigationView, directTargetChild: View, target: View, axes: Int, type: Int): Boolean {
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
/*
* Copyright (C) 2017 Darel Bitsy
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
public void saveCurrentWeatherForCity(final String cityName, final Currently currently) {
final SQLiteDatabase writableDatabase = userCitiesDatabase.getWritableDatabase();
final Cursor query = userCitiesDatabase.getReadableDatabase().rawQuery(String.format("SELECT %s FROM %s WHERE %s=\"%s\"",
CITY_NAME, CURRENT_TABLE_NAME, CITY_NAME, cityName), null);
final ContentValues databaseInsert = new ContentValues();
databaseInsert.put(CITY_NAME, cityName);
databaseInsert.put(CURRENT_TIME, currently.getTime());
databaseInsert.put(CURRENT_SUMMARY, currently.getSummary());
public interface IAuthProvider {
public login() {}
public logout() {}
public singup() {}
}
public interface IAuthManager {
IAuthProvider provider;
IAuthManager() {}
/**
* Created by Darel Bitsy on 04/04/17.
* User sqlite Helper to create and configure the user cities database
*/
public class UserCitiesDatabase extends SQLiteOpenHelper {
private static final String DB_NAME = "user_city_list";
private static final int VERSION = 1;
protected void shareScreenShot() throws IOException {
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
} else {
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
shareIntent.setType("image/jpeg");