Skip to content

Instantly share code, notes, and snippets.

View amrishodiq's full-sized avatar

Amri Shodiq amrishodiq

  • Depok, Jawa Barat, Indonesia
View GitHub Profile
@amrishodiq
amrishodiq / StringUtilities.java
Created September 22, 2011 23:23
Blackberry - method to read resource text file (in res directory)
/**
* I use this method to get contents of JSON formatted file that I put into res
* directory to deliver default data for my application.
* Visit my blog at http://web.durianapp.com
*/
public static String getResFileContent(String filename) {
InputStream is = null;
try {
@amrishodiq
amrishodiq / TakingPictureScreen.java
Created September 23, 2011 06:50
Blackberry - Use this snippet as an example of how to capture image using native camera in Blackberry
/**
* To use this example, you need to grap my repository on
* https://github.com/amrishodiq/Blackberry-Development-Tutorial/tree/master/TakingPicture/src/com/durianberry/takingpicture
*/
public final class TakingPictureScreen extends MainScreen implements
PictureTakerListener, FieldChangeListener {
private ButtonField button;
private BitmapField photoField;
public TakingPictureScreen() {
@amrishodiq
amrishodiq / DeleteFile.java
Created September 27, 2011 07:29
Blackberry - Delete a file
public static void deleteFile(String path) {
if (path.startsWith("file://")) {
// do nothing
} else if (!path.startsWith("/"))
path = "file:///" + path;
else if (path.startsWith("//"))
path = "file:/" + path;
else
path = "file://" + path;
@amrishodiq
amrishodiq / SaveBytesToFile.java
Created September 27, 2011 02:35
Blackberry - Save bytes to file
public static synchronized String saveToFile(String basePath, byte[] data)
throws IOException {
try {
if (basePath.startsWith("file://")) {
// do nothing
} else if (!basePath.startsWith("/"))
basePath = "file:///" + basePath;
else if (basePath.startsWith("//"))
basePath = "file:/" + basePath;
else
@amrishodiq
amrishodiq / GetFileContents.java
Created September 27, 2011 03:47
Blackberry - Get file contents
/**
* Method to get all bytes from a file.
*
* @param path
* @return
* @throws IOException
*/
public static byte[] getFileContent(String path) throws IOException {
FileConnection file = null;
@amrishodiq
amrishodiq / SingletonClass.java
Created October 5, 2011 17:20
Java: Singleton concept implementation
package com.durianapp.tutorial;
/**
* @author amrishodiq
*/
public class SingletonClass {
// inilah variable yang menyimpan satu-satunya instance class SingletonClass
private static SingletonClass instance;
@amrishodiq
amrishodiq / app.js
Created October 28, 2011 09:13
Sencha Touch 2 Tutorial Part 1
Ext.application({
name: 'App',
launch: function()
{
alert("Yaa. Akhirnya jalan juga.");
}
});
@amrishodiq
amrishodiq / app.js
Created October 28, 2011 09:21
Sencha Touch 2 Tutorial Part 2
Ext.application({
name: 'App',
launch: function()
{
Ext.create("Ext.TabPanel", {
fullscreen: true,
items: [
{
title: 'Home',
iconCls: 'home',
@amrishodiq
amrishodiq / app.js
Created October 28, 2011 09:30
Sencha Touch 2 Tutorial Part 3
Ext.application({
name: 'App',
launch: function()
{
Ext.create("Ext.TabPanel", {
fullscreen: true,
tabBarPosition: 'bottom',
items: [
{
@amrishodiq
amrishodiq / app.js
Created October 28, 2011 09:42
Sencha Touch 2 Tutorial Part 4
Ext.application({
name: 'App',
launch: function()
{
Ext.create("Ext.TabPanel", {
fullscreen: true,
tabBarPosition: 'bottom',
items: [
{