Flipper で SQLite テーブルを直接見る

Stetho の Facebook が作成した Android / iOS どちらも使えるデバッグツールです。

👉 Open-sourcing Flipper: a new extensible debugging tool - Facebook Engineering 

👉 Flipper · Extensible mobile app debugging 

👉 facebook/flipper: A desktop debugging platform for mobile developers. 

We wanted to create a platform that gives us all the flexibility we need to build more advanced features and support for iOS. One of Flipper's core concepts is its extensibility using plugins. Plugins are written in React and we provide a set of ready-to-use UI components that allow developers to build great plugin UIs with a few lines of code.

iOSのより高度な機能とサポートを構築するために必要なすべての柔軟性を提供するプラットフォームを作成したかったのです。 Flipperのコアコンセプトの1つは、プラグインを使用した拡張性です。プラグインはReactで記述されており、開発者が数行のコードで優れたプラグインUIを構築できる、すぐに使用できるUIコンポーネントのセットを提供します。

👉 Stetho Guidance · Flipper 

dependencies、Application 内に記述しながら、セットアップ。


<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
        android:exported="true"/>


repositories {
  jcenter()
}

dependencies {
  debugImplementation 'com.facebook.flipper:flipper:0.26.0'
  debugImplementation 'com.facebook.soloader:soloader:0.5.1'
  releaseImplementation 'com.facebook.flipper:flipper-noop:0.26.0'
}


public class MyApplication extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, false);

    if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(this)) {
      final FlipperClient client = AndroidFlipperClient.getInstance(this);
      client.addPlugin(new InspectorFlipperPlugin(this, DescriptorMapping.withDefaults()));
      client.start();
    }
  }
}

👉 Getting Started · Flipper 

ここでは Database プラグインを追加します。


client.addPlugin(new DatabasesFlipperPlugin(context));

👉 Databases Plugin Setup · Flipper 

あとは、PC上のデバッグクライアントを開くと直感的に参照できるようになります。

👉 android/architecture-samples at dagger-android 

使いやすいです。動作も軽快です。


res を複数作って機能・画面別にディレクトリ分けすると分かりやすい

👉 Split layouts into subfolders in Android Studio - ProAndroidDev 

以下のコードを見ながら。

👉 GitHub - android/architecture-samples at dagger-android 

コードは、画面別にディレクトリ分けしてるが、レイアウトファイルは、複雑なファイル名で res ディレクトリ直下に一緒くたに入ってる。

ここで、build.gradle で設定記述を追加する。


android {
  sourceSets {
    main {
      res.srcDirs = [
          'src/main/res',
          'src/main/res/layouts/tasks',
          'src/main/res/layouts/taskdetail',
          'src/main/res/layouts/addedittask',
          'src/main/res/layouts/statistics',
      ]
    }

こうすることで、レイアウトファイル群を画面別に分けることができる。

Android Studio はデフォルトで、一つのディレクトリのみ


android {
  sourceSets {
    main {
      res.srcDirs = [
          'src/main/res'
      ]

と等価な設定を持ってるので、それに、画面別ディレクトリを複数追加することで、Android Studio は、リソースファイルとして複数ディレクトリからファイルを読み込むことができるようになります。

あとは、それぞれのリソースファイルを振り分けて置くだけ。

以下、やってみた動画。



実際は、レイアウトファイルがもっと多くなるはずなので、分かりやすさはより顕著になる。

👉 Split layouts into subfolders in Android Studio - ProAndroidDev 


さらば proguard、ようこそ R8。

DSL element 'useProguard' is obsolete and will be removed soon. Use 'android.enableR8' in gradle.properties to switch between R8 and Proguard..

DSL要素「useProguard」は廃止されており、まもなく削除されます。 gradle.propertiesで「android.enableR8」を使用して、R8とProguardを切り替えます。

gradle.properties


android.enableR8=true

build.gradle

とりあえずは、いけるが。

以下、編集風景。



しかし、minify とか、proguardFiles とか、どうなるの?

👉 Android Developers Blog: R8, the new code shrinker from Google, is available in Android studio 3.3 beta 


Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option

なんすかね、まったく。

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option

[Preferences]-[Kotlin Compiler] から、[Target JVM version] を 「1.8」に。

ところが、同じエラーが出たまま。

対処法

以下を、build.gradle に。


android {
  kotlinOptions {
    jvmTarget = '1.8'
  }
}

Android Studio の便利そうに見える設定機能ってほとんどがあやしくね?

👉 intellij idea - Why kotlin gradle plugin cannot build with 1.8 target? - Stack Overflow 


Tracing the Origins of 'Presentation Model' in MVVM — and Martin Fowler’s Seven-Year-Old Insight

While researching things around “MVVM,” I kept seeing the term “Presentation Model,” so I decided to look into it.

Martin Fowler mentioned it — about seven years ago.


MVVM is the Microsoft's world's name for the same pattern as Presentation Model. I haven't updated the article since.

マイクロソフトの「MVVM」パターンは「Presentation Model」と同じなので、記事は更新していません。

👉 Martin Fowler on Twitter: "@HerberthAmaral MVVM is the Microsoft's world's name for the same pattern as Presentation Model. I haven't updated the article since." / Twitter 

I looked for the sources for each of them.

Presentation Model (Martin Fowler, 2004)

Represent the state and behavior of the presentation independently of the GUI controls used in the interface

👉 Presentation Model 

MVVM (Microsoft, 2005)

Model/View/ViewModel is a variation of Model/View/Controller (MVC) that is tailored for modern UI development platforms where the View is the responsibility of a designer rather than a classic developer. The designer is generally a more graphical, artistic focused person, and does less classic coding than a traditional developer.

👉 Introduction to Model/View/ViewModel pattern for building WPF apps – Tales from the Smart Client 

Conclusion

2012年4月現在、XAMLを使用するWPFなどのテクノロジ以外で使用されるMVVMは実質Presentation Modelと変わらず、Viewの抽象化などはできない。

👉 Model View ViewModel - Wikipedia (ja) 

MVVM is a variation of Martin Fowler's Presentation Model design pattern. MVVM abstracts a view's state and behavior in the same way, but a Presentation Model abstracts a view (creates a view model) in a manner not dependent on a specific user-interface platform.

👉 Model–view–viewmodel - Wikipedia (en)