Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Realm Japan meetup #20 Java

zaki50
November 25, 2016

Realm Japan meetup #20 Java

zaki50

November 25, 2016
Tweet

More Decks by zaki50

Other Decks in Technology

Transcript

  1. Realm Java 2.0.0 • Realm Mobile PlatformରԠʂʂʂʢϕʔλʣ • άϩʔόϧॳظԽϝιουRealm.init(Context)Λಋೖ •

    ॳظԽϝιουҎ֎Ͱ͸Context͕ෆཁʹ • RealmLogΫϥεʹΑΔϩά੍ޚ • ϞσϧΫϥεͰΦϒδΣΫτͷॳظ஋ΛఆٛՄೳʹ • isManaged()ϝιουΛ௥Ճ [email protected]
  2. Realm Java 2.0.1-2.0.2 • syncEnabled falseͷࡍʹෆཁͳINTERNETύʔϛογϣϯΛཁٻ͢Δ όά (#3505) • syncEnabled

    falseͷࡍʹωοτϫʔΫͷ઀ଓঢ়ଶ͕มΘΔͱΫϥο γϡ͢Δόά (#3505) • distinctAsync͕ɺࢦఆ͞ΕͨΫΤϦͷ৚݅Λແࢹ͢Δόά (#3537) • ಛఆͷ؀ڥͰϏϧυ࣌ʹConcurrentModificationException͕ൃੜ͢Δ όά(#3501) • Java7؀ڥͰϏϧυΤϥʔ͕ൃੜ͢Δόά (#3563) [email protected]
  3. Realm Java 2.1, 2.2(৽ػೳ) • Sync APIมߋʢϕʔλʣ • Realm.compactRealm()͕҉߸Խ͞ΕͨϑΝΠϧΛαϙʔτ •

    RealmListɺRealmResultsʹfirst(E defaultValue), last(E defaultValue) • RealmLog.setLevel(int)ʹΑΔϩάϨϕϧࢦఆΛαϙʔτ • annotationProcessor dependency configurationͷαϙʔτ [email protected]
  4. Realm Java 2.1.0-2.1.2(όάमਖ਼) • ProGuardઃఆϑΝΠϧ͕sync APIʹରԠ(#3596) • ֎෦ετϨʔδʹσʔλϕʔεϑΝΠϧΛஔ͘ͱPermissionΤϥʔʹ ͳΔόάΛमਖ਼(#3140ɺچ୺຤Ͱ͸Ұ෦ະमਖ਼) •

    ObservableΛunsubscribeͨ͠ࡍͷϝϞϦʔϦʔΫ(#3552) • #3596Ͱͷमਖ਼Ͱɺ೉ಡԽ͕͓͜ͳΘΕͳ͘ͳΔόάͷमਖ਼(#3689) • Realm.insert͕ελοΫΦʔόʔϑϩʔ͢Δόά(#3732) [email protected]
  5. Permission API [email protected] public class PermissionChange extends RealmObject {
 @PrimaryKey


    @Required
 private String id = UUID.randomUUID().toString();
 @Required
 private Date createdAt = new Date();
 @Required
 private Date updatedAt = new Date(); 
 @Required
 private String realmUrl;
 @Required
 private String userId;
 private Boolean mayRead = false;
 private Boolean mayWrite = false;
 private Boolean mayManage = false;
 private Integer statusCode = null; // null=not processed, 0=success, >0=error
 private String statusMessage;
 }
  6. Permission API [email protected] SyncUser user = ...;
 String realmUrl =

    "realms://...";
 final Realm managementRealm = user.getManagementRealm();
 try {
 final PermissionChange permissionChange = new PermissionChange(
 realmUrl,
 "*", // for all users
 true, // read
 false, // write
 false // manage
 );
 
 managementRealm.insert(permissionChange);
 } finally {
 managementRealm.close();
 }
  7. Permission API [email protected] private PermissionChange permissionChange; permissionChange = managementRealm.copyToRealm(new PermissionChange(


    realmUrl,
 “*”/* or someUser.getIdentity() */, // for all users
 true, // read
 false, // write
 null // manage
 ));
 
 permissionChange.addChangeListener(new RealmChangeListener<PermissionChange>() {
 @Override
 public void onChange(PermissionChange element) {
 Log.d("realm", "permission changed: " + element.getStatusCode());
 }
 });