使ってみた「Google Cast SDK」その1 - CastHelloText-chrome

こんなの出てたので。

Google_Developers_Blog__Ready_to_cast__Chromecast_now_open_to_developers_with_the_Google_Cast_SDK

Google Developers Blog: Ready to cast: Chromecast now open to developers with the Google Cast SDK

YouTube動画を見てみた。

なんのことだかよくわかりません。

サンプルがあるようなので動かしてみようと。

たくさんサンプル公開されています。

Google_Cast

Google Cast

いちばん簡単そうな「CastHelloText-chrome」。

まず、WEBサーバに置いたHTMLにブラウザでアクセスして文字を入力する。

Hello_World

すると、テレビにその文字が表示されます。

Evernote

なんなんでしょうこれは!!ww

で、手順と思ったこと。

続きを読む >>


View Holder Pattern を使わない 高速 ListView だと!?

CursorAdapter だよな、これって。

...
public View newView(Context context, Cursor cursor, ViewGroup parent) {
 
    View view = LayoutInflater.from(context).inflate(R.layout_my_view, null);
 
    TextView tv = (TextView) view.findViewById(R.id.text1);
    ImageView iv = (ImageView) view.findViewById(R.id.image1);
 
    view.setTag(R.id.text1, tv);
    view.setTag(R.id.image1, iv);
 
    return view;
}
 
public void bindView(View view, Context context, Cursor cursor) {
 
    ((TextView) view.getTag(R.id.text1)).setText(cursor.getString(cursor.getColumnIndex(COL_TEXT_1)));
    ((ImageView) view.getTag(R.id.image1)).setImageResource(R.drawable.image);

}
...

タグってやつは、便利だなあ。

[Java] Fast ListView scroll without ViewHolder Pattern - Pastebin.com

android - What bindView() and newView() do in CursorAdapter - Stack Overflow


AsyncTaskLoader の使い方 (8/8) 〜 Loader の弱点を克服する

AsyncTaskLoader___Android_Developers

AsyncTaskLoader | Android Developers


目次

1. Thread と AsyncTask
2. AsyncTaskLoader の利点
3. LoaderManager の利用
4. よくある間違いと回避法
5. 基本的な Loader の実装
6. いろいろな Loader の使用例
7. データベースと CursorLoader
8. Loader の弱点を克服する


8. Loader の弱点を克服する

1. 進捗状況(progress)の更新ができない。

対応策:
LocalBroadcastManager を使う。

Activity 側。

@Override 
protected void onStart() { 
    // Receive loading status broadcasts in order to update the progress bar 
    LocalBroadcastManager.getInstance(this)
        .registerReceiver(loadingStatusReceiver, new IntentFilter(MyLoader.LOADING_ACTION)); 
    super.onStart(); 
}

@Override 
protected void onStop() { 
    super.onStop(); 
    LocalBroadcastManager.getInstance(this).unregisterReceiver(loadingStatusReceiver); 
}

Loader 側。

@Override 
public Result loadInBackground() { 
    // Show progress bar 
    Intent intent = new Intent(LOADING_ACTION).putExtra(LOADING_EXTRA, true); 
    LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); 
    try {
        return doStuff(); 
    } finally { 
        // Hide progress bar 
        intent = new Intent(LOADING_ACTION).putExtra(LOADING_EXTRA, false); 
        LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); 
    } 
}

続きを読む >>