GoCook Android Client
/******* Progress *******/ 在BaseFragment中增加了Progress loading View。 使用时只需调用showProgress(boolean)函数,参数为true表示显示,false隐藏。 还可以设置loading时的显示文字,默认显示“加载中...”,修改需调用setProgressMessage()方法。
/******* BaseActivity *******/ 使用Fragment时不需要创建新的Activity,只要使用BaseActivity作为载体即可。 启动Fragment的方法仍为startActivity(intent),参数intent使用FragmentHelper的getIntent()方法创建。
/***************************/
note: public class QREncodeUtil {
private static final int BLACK = 0xff000000;
public static Bitmap createQRCode(String str, int widthAndHeight) throws WriterException {
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
BitMatrix matrix = new MultiFormatWriter().encode(str,
BarcodeFormat.QR_CODE, widthAndHeight, widthAndHeight);
int width = matrix.getWidth();
int height = matrix.getHeight();
int[] pixels = new int[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (matrix.get(x, y)) {
pixels[y * width + x] = BLACK;
}
}
}
Bitmap bitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
}