新・ブログ出版局管理人ブログ

スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書く事で広告が消せます。
このページのトップへ

ActivityGroupを使った電子ペーパーの制御

alexの電子ペーパーの簡単なサンプルを作りました。

HelloEpd.zip をダウンロード

res/layout に epd.xml というレイアウトを定義します。重要なのは this.epd.setVdsActive(true); で、これをしないと電子ペーパーに何も表示されません。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/epdLayout" android:orientation="vertical"
android:layout_width="600px" android:layout_height="800px"
android:visibility="invisible">
</LinearLayout>

これを HelloActivity という Activity から次のように使用します。

public class HelloActivity extends Activity {
private EpdRender epd = new EpdRender() {
public boolean onEpdScreenPainting(View view, Canvas canvas) {
float width = (float) getEpdScreenWidth();
float height = (float) getEpdScreenHeight();

Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setTextSize(30);

String text = HelloActivity.this.getString(R.string.hello);
float textWidth = paint.measureText(text);
canvas.drawText(text, (width - textWidth) / 2, height / 2, paint);

return true;
}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.epd);

LinearLayout epdLayout = (LinearLayout) findViewById(R.id.epdLayout);
this.epd.bindLayout(epdLayout);
this.epd.updateEpdView();
}

@Override
protected void onResume() {
super.onResume();
this.epd.setVdsActive(true);
}

@Override
protected void onStop() {
super.onStop();
this.epd.setVdsActive(false);
}
}

このActivityは、ActivityGroup(サンプルではMainActivity)から次のコードで起動します。

LocalActivityManager m = this.getLocalActivityManager();
Intent intent = new Intent(MainActivity.this, HelloActivity.class);
m.startActivity("HELLO", intent);

これで、 ActivityGroup 側でタッチパネルに情報を表示しつつ、 HelloActivity で電子ペーパーを更新することができます。

EpdRender の updateEpdView() は、電子ペーパー全体を更新します。

partialUpdateEpdView(Rect rect) は、部分的に電子ペーパーは更新するもののようですが、どうも動作しないようです。

partialUpdateEpdView(int left, int top, Bitmap mInfoBitmap, boolean merge) は問題なく動作します。left, topはそれぞれ表示開始位置の左と上の位置(ピクセル)、mInfoBitmapは表示される画像です。mergeはよく分かりません…

サンプル内のPartialUpdateActivityで部分的な更新をデモしています。
このページのトップへ

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック

トラックバック URL
http://miyabet.blog119.fc2.com/tb.php/1-b6536bc9
この記事にトラックバックする(FC2ブログユーザー)
このページのトップへ

FC2Ad

FC2ブログ

プロフィール

Author:miyabet
ブログ出版局は
http://print.cssj.jp/
です。

最新記事

最新コメント

最新トラックバック

月別アーカイブ

カテゴリ

未分類 (1)
alex (1)
CopperReader (12)
Java (1)
CopperPDF (5)
電子書籍 (3)

検索フォーム

RSSリンクの表示

リンク

このブログをリンクに追加する

QRコード

QR