Java Code Examples for com.codename1.io.Util#register()

The following examples show how to use com.codename1.io.Util#register() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SocialChat.java    From codenameone-demos with GNU General Public License v2.0 5 votes vote down vote up
public void init(Object context) {
    theme = UIManager.initFirstTheme("/theme");
    
    Style iconFontStyle = UIManager.getInstance().getComponentStyle("LargeIconFont");
    FontImage fnt = FontImage.create(" \ue80f ", iconFontStyle);
    userPlaceholder = fnt.toEncodedImage();
    mask = theme.getImage("rounded-mask.png");
    roundPlaceholder = EncodedImage.createFromImage(userPlaceholder.scaled(mask.getWidth(), mask.getHeight()).applyMask(mask.createMask()), false);
    fullName = Preferences.get("fullName", null);
    uniqueId = Preferences.get("uniqueId", null);
    imageURL = Preferences.get("imageURL", null);
    
    if(Storage.getInstance().exists("recentContacts")) {
        recentContacts = (java.util.List<String>)Storage.getInstance().readObject("recentContacts");
    }
    
    Util.register("Message", Message.class);

    Display.getInstance().addEdtErrorHandler((evt) -> {
            evt.consume();
            Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
            Log.p("OS " + Display.getInstance().getPlatformName());
            Log.p("Error " + evt.getSource());
            Log.p("Current Form " + Display.getInstance().getCurrent().getName());
            Log.e((Throwable)evt.getSource());
            Log.sendLog();
        });
}
 
Example 2
Source File: Receipt.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Registers this class as externalizable so that it can be serialized.
 */
static void registerExternalizable() {
    if (!isExternalizableRegistered()) {
        Util.register("com.codename1.payment.Receipt", Receipt.class);
        setExternalizableRegistered(true);
    }
    
}
 
Example 3
Source File: Purchase.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a list of purchases that haven't yet been sent to the server.  You can
 * use this for diagnostic and debugging purposes periodically in the app to 
 * make sure there aren't a queue of purchases that aren't getting submitted
 * to the server.
 * @return List of receipts that haven't been sent to the server.
 */
public List<Receipt> getPendingPurchases() {
    synchronized(PENDING_PURCHASE_KEY) {
        Storage s = Storage.getInstance();
        Util.register(new Receipt());
        if (s.exists(PENDING_PURCHASE_KEY)) {
            return (List<Receipt>)s.readObject(PENDING_PURCHASE_KEY);
        } else {
            return new ArrayList<Receipt>();
        }
    }
}
 
Example 4
Source File: Login.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The AccessToken of this service
 *
 * @return the token
 */
public AccessToken getAccessToken() {
    if (token == null) {
        Util.register(new AccessToken());
        token = (AccessToken)Storage.getInstance().readObject(getClass().getName()+"AccessToken");
    }
    return token;
}
 
Example 5
Source File: PropertyIndex.java    From CodenameOne with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invoking this method will allow a property object to be serialized seamlessly
 */
public void registerExternalizable() {
    Util.register(getName(), parent.getClass());
}
 
Example 6
Source File: ParseRegistry.java    From parse4cn1 with Apache License 2.0 3 votes vote down vote up
/**
 * Registers all externalizable classes defined in the parse4cn1 library.
 * <p>
 * <b>Note: User-defined externalizable custom types stored in {@link ParseObject} or
 * any of its sub-classes <em>must</em> be 
 * {@link com.codename1.io.Util#register(java.lang.String, java.lang.Class) registered} 
 * by the user otherwise persistence of any ParseObject containing such custom types will fail.</b>
 */
public static void registerExternalizableClasses() {
    Util.register(ExternalizableParseObject.getClassName(), ExternalizableParseObject.class);
    Util.register(ExternalizableJsonEntity.getClassName(), ExternalizableJsonEntity.class);
    Util.register(ParseFile.getClassName(), ParseFile.class);
    Util.register(ParseRelation.getClassName(), ParseRelation.class);
    Util.register(ParseGeoPoint.getClassName(), ParseGeoPoint.class);
}
 
Example 7
Source File: CachedDataService.java    From CodenameOne with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Makes sure the cached data class is properly registered as an externalizable. This must
 * be invoked for caching to work
 */
public static void register() {        
    Util.register("CachedData", CachedData.class);
}