Skip to content

Instantly share code, notes, and snippets.

View shannah's full-sized avatar

Steve Hannah shannah

View GitHub Profile
@shannah
shannah / CodeRAD2TransitionExample.xml
Created June 15, 2021 13:59
Example using CodeRAD bindings and transitions on layout attribute
<?xml version="1.0"?>
<border xsi:noNamespaceSchemaLocation="StartPage.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- Watch screencast of this example at
https://youtu.be/vY60zLo6f5E
-->
<title>Start Page</title>
<!-- Define a tag for the layout property.
This will add a property to the auto-generated view model class.
-->
@shannah
shannah / GeofenceListenerImpl.java
Last active June 4, 2021 12:15 — forked from codenameone/GeofenceListenerImpl.java
Sample usage of the Codename One geofence API to track location
public class GeofenceListenerImpl implements GeofenceListener {
@Override
public void onExit(String id) {
}
@Override
public void onEntered(String id) {
if(!Display.getInstance().isMinimized()) {
Display.getInstance().callSerially(() -> {
Dialog.show("Welcome", "Thanks for arriving", "OK", null);
<?xml version="1.0" ?>
<border safeArea="true" rad-implements="LoginViewSchema">
<y layout-constraint="north">
<import>
import com.codename1.rad.components.loginform.*;
</import>
<private>
<var name="loginDelegate"
lookup="LoginViewDelegate"/>
</private>
@shannah
shannah / MainFormController.java
Created April 6, 2021 12:06
Example using ProfileAvatarView and handling PROFILE_AVATAR_CLICKED action.
package ca.weblite.jabberwocky.controllers;
import ca.weblite.jabberwocky.controllers.BaseFormController;
import ca.weblite.jabberwocky.models.UserProfile;
import com.codename1.rad.controllers.Controller;
import com.codename1.rad.models.Entity;
import com.codename1.rad.nodes.ActionNode;
import com.codename1.rad.nodes.ViewNode;
import com.codename1.rad.schemas.Thing;
import com.codename1.rad.ui.entityviews.ProfileAvatarView;
@shannah
shannah / batsh.php
Created February 4, 2021 18:50
A simple PHP script for compiling Batsh scripts to bash and windows bat scripts. This is a thin wrapper around the hosted batsh compiler at https://batsh.org
<?php
/**
Copyright (c) 2021 Steve Hannah
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
#ifndef __CN1GLOBALS__
#define __CN1GLOBALS__
#include <stdio.h>
#include <stdlib.h>
#include "cn1_class_method_index.h"
#include <pthread.h>
#include <setjmp.h>
#include <math.h>
@shannah
shannah / HTMLBuilder.java
Last active July 22, 2020 13:22
Sample output from ComponentImageGenerator
// Excerpt from https://github.com/shannah/ComponentImageGenerator/blob/master/src/com/codename1/compgen/MainTestRunner.java
// Project https://github.com/shannah/ComponentImageGenerator
public String generateHtml() {
HTMLBuilder sb = new HTMLBuilder();
sb.appendRaw("<!doctype html>").newLine()
.open("html")
.open("head")
.open("title").append("Codename One Components").close()
.close()
// Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
package com.codename1.impl.javase.cef;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
Form hi = new Form("Hi World", new BorderLayout());
TextArea input = new TextArea();
TextArea output = new TextArea();
output.setEditable(false);
Button execute = new Button("Run");
execute.addActionListener(evt->{
BrowserComponent bc = CN.getSharedJavascriptContext().ready().get();
bc.execute("callback.onSuccess(window.eval(${0}))", new Object[]{input.getText()}, res->{
output.setText(res.toString());
package com.codename1.samples;
import com.codename1.io.Log;
import static com.codename1.ui.CN.updateNetworkThreadCount;
import com.codename1.ui.Component;
import com.codename1.ui.Form;
import com.codename1.ui.Graphics;
import com.codename1.ui.geom.Dimension;
import com.codename1.ui.geom.GeneralPath;
import com.codename1.ui.geom.Point;