ButterKnife 8.0 に更新で @Bind → @BindView など

更新されています.

Butter_Knife

Version 8.0.0 (2016-04-25)

- @Bind becomes @BindView and @BindViews (one view and multiple views, respectively).
- Calls to bind now return an Unbinder instance which can be used to null references. - This replaces the unbind API and adds support for being able to clear listeners.
- New: @BindArray binds String, CharSequence, and int arrays and TypeArray to fields.
- New: @BindBitmap binds Bitmap instances from resources to fields.
- @BindDrawable now supports a tint field which accepts a theme attribute.

-The runtime and compiler are now split into two artifacts.

compile 'com.jakewharton:butterknife:8.0.0'
apt 'com.jakewharton:butterknife-compiler:8.0.0'

- New: apply overloads which accept a single view and arrays of views.
- ProGuard rules now ship inside of the library and are included automatically.
- @Optional annotation is back to mark methods as being optional.

butterknife/CHANGELOG.md at master · JakeWharton/butterknife

明示することで, バインドできるリソース範囲を広げながら処理速度は落とさない.

あと, proguard 記述は不要なのだとさ.

Butter Knife


2分で作れる「About Page」にみる Intent の作り方

Pocket の開発者の方なのかな.

以下のような記述のみで「About Page」が作成できるようです.


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View aboutPage = new AboutPage(this)
                .isRTL(false)
                .setImage(R.drawable.dummy_image)
                .addGroup("Connect with us")
                .addEmail("elmehdi.sakout@gmail.com")
                .addFacebook("the.medy")
                .addTwitter("medyo80")
                .addYoutube("UCdPQtdWIsg7_pi4mrRu46vA")
                .addPlayStore("com.ideashower.readitlater.pro")
                .addInstagram("medyo80")
                .addGitHub("medyo")
                .create();

        setContentView(aboutPage);
    }

medyo/android-about-page: Create an awesome About Page for your Android App in 2 minutes

こんなかんじになります.

20160425-115827_1

下の方の各アイテムをタップすると, 作成されたそれぞれの Intent で startActivity されるわけですが.


mContext.startActivity(element.getIntent());

どんな Intent なのか見てみましょう.

メール


Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{email});

Facebook


Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);

if (AboutPageUtils.isAppInstalled(mContext, "com.facebook.katana")){
  intent.setPackage("com.facebook.katana");
  int versionCode = 0;
  try {
    versionCode = mContext.getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode;
  } catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
  }

  if (versionCode >= 3002850) {
    Uri uri = Uri.parse("fb://facewebmodal/f?href=" + "http://facebook.com/" + id);
    intent.setData(uri);
  } else {
    Uri uri = Uri.parse("fb://page/"+id);
    intent.setData(uri);
  }
}else{
  intent.setData( Uri.parse("http://facebook.com/" + id));
}

Facebookアプリを入れている場合は, そのバージョンのよってセットする Uri を分けているようです.

Twitter


Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);

if (AboutPageUtils.isAppInstalled(mContext, "com.twitter.android")){
  intent.setPackage("com.twitter.android");
  intent.setData(Uri.parse(String.format("twitter://user?user_id=%s",id)));
}else{
  intent.setData(Uri.parse(String.format("http://twitter.com/%s",id)));
}

Play Store


Uri uri = Uri.parse("market://details?id=" + id);
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);

YouTube


Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(String.format("http://youtube.com/channel/%s", id)));

if (AboutPageUtils.isAppInstalled(mContext, "com.google.android.youtube")){
  intent.setPackage("com.google.android.youtube");
}

Instagram


Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://instagram.com/_u/"+id));

if (AboutPageUtils.isAppInstalled(mContext, "com.instagram.android")){
  intent.setPackage("com.instagram.android");
}

GitHub


Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(String.format("https://github.com/%s", id)));

まとめ

ユーザに, ブラウザで開くか, アプリで開くか, の選択の余地を与えず, インストールしているかの判断の後, パッケージ指定で独自スキームの Uri を渡して投げる, てのが今のやり方か.

それがおまえらのやり方か!!


自分のまわりの原発や火山やミサイル発射施設からの半径(距離) をマップにメモしておく

もし何かあったら怖い場所や施設.

ありますよね.

ないですか?

ありますよね.

どこかの国でミサイルが発射されたとき

「500kmてどこまで飛んで来るの?」

ありますよね.

スマホアプリで確認しておきましょう.

半径Nキロメートル_-_Google_Play_の_Android_アプリ

半径Nキロメートル - Google Play の Android アプリ

まず, スマホで住所や場所のキーワードを入力します.

Google 検索に入力する雰囲気でいいです.

正式な名称でなくてもかまいません. サジェスチョンされます.

以下, 一覧サイトからコピペでもかまいません.

日本の原子力発電所 - Wikipedia

活火山 - Wikipedia

そして, 距離を適当に入力します.

20160423-041426

そんなかんじで原発などを入力してみました.

実際に健康被害が出るのは10万人とか100万人に1人程度の確率ですが、
これを危険と見なすのなら、100km圏外に逃げるべきです。

福島原発から、最低何キロ離れれば安全地帯?についての答え - ... - Yahoo!知恵袋

20160423-035324

20160423-035545

20160423-035353

火山を入力するまでもなく,

「日本人は覚悟が必要である」

と思いました.