Skip to content

Instantly share code, notes, and snippets.

@lognaturel
lognaturel / gist:232395ee1079ff9e4b1b8e7096c3afaf
Last active February 14, 2023 13:15
Use DatePicker spinners in API 24
/**
* Workaround for this bug: https://code.google.com/p/android/issues/detail?id=222208
* In Android 7.0 Nougat, spinner mode for the DatePicker in DatePickerDialog is
* incorrectly displayed as calendar, even when the theme specifies otherwise.
*
* Modified slightly from the equivalent fix for TimePicker from @jeffdgr8:
* https://gist.github.com/jeffdgr8/6bc5f990bf0c13a7334ce385d482af9f
*/
private void fixSpinner(Context context, int year, int month, int dayOfMonth) {
// The spinner vs not distinction probably started in lollipop but applying this
@jeffdgr8
jeffdgr8 / TimePickerDialogFixedNougatSpinner.java
Last active February 14, 2023 13:15
TimePickerDialog with fixed android:timePickerMode spinner in Nougat
package my.packagename;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.TimePicker;
import java.lang.reflect.Constructor;
@kiliman
kiliman / DynamicFragmentView.cs
Last active February 5, 2016 18:49
Dynamic Layout in MvvmCross for Android
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
var tabConfig = ViewModel.TabConfig;
var tabId = tabConfig["id"].ToString();
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
_scrollView = new ScrollView(Activity);
var layout = BuildLayout(inflater, tabConfig);
@jamsoft
jamsoft / BaseViewController.cs
Last active May 8, 2017 12:26 — forked from redent/ParentViewController.Keyboard.cs
Parent view controller to handle keyboard notifications to center views in the screen. UIScrollView related methods moved to an extension class.
using Cirrious.MvvmCross.Touch.Views;
using UIKit;
using CoreGraphics;
using Foundation;
namespace MyApp.Touch.Views
{
public class BaseViewController<TViewModel> : MvxViewController where TViewModel : MyBaseViewModelType
{
#region Fields
@Cheesebaron
Cheesebaron / CircularProgressDrawable.cs
Created July 9, 2015 08:42
CircularProgressDrawable, based on castorflex's Java implementation here: https://gist.github.com/castorflex/4e46a9dc2c3a4245a28e
[Register("dk.ostebaronen.droid.CircularProgressDrawable")]
public class CircularProgressDrawable
: Drawable
, IAnimatable
{
private static readonly IInterpolator AngleInterpolator = new LinearInterpolator();
private static readonly IInterpolator SweepInterpolator = new DecelerateInterpolator();
private static readonly RectF _bounds = new RectF();
private const int AngleAnimatorDuration = 2000;
@kjeremy
kjeremy / MvxAppCompatSpinner.cs
Last active August 29, 2015 14:14
AppCompat-v22 Tinting for MvvmCross
/// <summary>
/// Tint-aware version of MvxSpinner so that it's styled properly
/// with AppCompat V21
/// </summary>
public class MvxAppCompatSpinner : MvxSpinner, ITintableBackgroundView
{
private static readonly int[] TintAttrs =
{
Android.Resource.Attribute.Background,
Android.Resource.Attribute.PopupBackground
@steveliles
steveliles / Foreground.java
Last active January 22, 2024 18:06
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;