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

Realm Japan meetup #20 Java

358791a9c91e7615ffe62c7c6e02e470?s=47 zaki50
November 25, 2016

Realm Japan meetup #20 Java

358791a9c91e7615ffe62c7c6e02e470?s=128

zaki50

November 25, 2016
Tweet

Transcript

  1. Realm meetup #20 my@realm.io

  2. #realm_jp my@realm.io

  3. Makoto Yamazaki Realm Inc. / uPhyca Inc. my@realm.io

  4. Recent Updates my@realm.io

  5. Realm Java 2.2.1 (was 2.0.0) my@realm.io

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

    ॳظԽϝιουҎ֎Ͱ͸Context͕ෆཁʹ • RealmLogΫϥεʹΑΔϩά੍ޚ • ϞσϧΫϥεͰΦϒδΣΫτͷॳظ஋ΛఆٛՄೳʹ • isManaged()ϝιουΛ௥Ճ my@realm.io
  7. Realm Mobile PlatformରԠ my@realm.io realm { syncEnabled = true }

    appͷbuild.gradeʹ ৄࡉ͸ bit.ly/RMP_JAVA
  8. Realm Java 2.0.1-2.0.2 • syncEnabled falseͷࡍʹෆཁͳINTERNETύʔϛογϣϯΛཁٻ͢Δ όά (#3505) • syncEnabled

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

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

    ObservableΛunsubscribeͨ͠ࡍͷϝϞϦʔϦʔΫ(#3552) • #3596Ͱͷमਖ਼Ͱɺ೉ಡԽ͕͓͜ͳΘΕͳ͘ͳΔόάͷमਖ਼(#3689) • Realm.insert͕ελοΫΦʔόʔϑϩʔ͢Δόά(#3732) my@realm.io
  11. Realm Java 2.2.0-2.2.1(όάमਖ਼) • KotlinͰϞσϧΫϥε͕ଘࡏ͠ͳ͍৔߹ʹΤϥʔʹͳΔόά(#3746) • 2.1ͰͷProGuardઃఆ͕built-in shrinkerͰΤϥʔʹͳΔ(#3714) • Realmߋ৽ޙʹωΠςΟϒϥΠϒϥϦͷϩʔυ͕ΤϥʔʹͳΔ(#3775)

    • શRealmΫϩʔζޙʹRealm.getLocalinstanceCount()ͰNPE(#3791) my@realm.io
  12. annotationProcessor my@realm.io android-aptϓϥάΠϯ͕ඞཁͳ৔߹͸໌ࣔతʹapply͍ͯͩ͘͠͞ ద༻͢Δ৔߹͸RealmͷϓϥάΠϯΑΓ΋લͰʂ

  13. annotationProcessor my@realm.io https://developer.android.com/studio/releases/gradle-plugin.html

  14. annotationProcessor my@realm.io from https://github.com/realm/realm-java/pull/3754 android-aptϓϥάΠϯ͕طʹద༻͞Ε͍ͯΔ৔߹͸ apt Λɺະద༻ͷ৔߹͸Լهͷදʹै͍·͢ɻ

  15. annotationProcessor my@realm.io android-aptϓϥάΠϯ͕ඞཁͳ৔߹͸໌ࣔతʹapply͍ͯͩ͘͠͞ ద༻͢Δ৔߹͸RealmͷϓϥάΠϯΑΓ΋લͰʂ

  16. Object Server APIมߋ • Ϋϥε໊มߋ(User-> SyncUser, Credentials->SyncCredentials, Session->SyncSession) • SyncManager.setLogLevel()Λഇࢭ(RealmLog.setLevel()΁ͷ౷߹)

    • SyncUser.all()ͷ௥Ճ • SyncUser.getManagementRealm()ͱPermission APIͷ௥Ճ my@realm.io
  17. Permission API my@realm.io 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;
 }
  18. Permission API my@realm.io 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();
 }
  19. Permission API my@realm.io 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());
 }
 });
  20. Ξϯέʔτͷճ౴Λ͓ئ͍͠·͢ jp@realm.io http://bit.ly/RealmJP_20