Skip to content

Instantly share code, notes, and snippets.

// Bitmap bitmap;
//
// if (drawable instanceof BitmapDrawable) {
// BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
// if (bitmapDrawable.getBitmap() != null) {
// return bitmapDrawable.getBitmap();
// }
// }
//
// if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) {
@dingbuoyi
dingbuoyi / gist:1bfdfae8ca74708dd2c2
Created May 28, 2015 05:19
use AppCompatActivity
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Login");
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.bar_color)));
getSupportActionBar().hide();
private void initToolBar() {
toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
// App Logo
//toolbar.setLogo(R.mipmap.ic_launcher);
// Title
toolbar.setTitle("Login");
// Sub Title
//toolbar.setSubtitle("Sub title");
//toolbar.setTitleTextColor(getResources().getColor(R.color.white));
@dingbuoyi
dingbuoyi / gist:643e0a809755ab932439
Created May 7, 2015 06:39
test code for GreedDao
DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "notes-db", null);
db = helper.getWritableDatabase();
daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
boxDao = daoSession.getBoxDao();
Box box = new Box(null, "魔方", 1, "魔方描述");
boxDao.insert(box);
Logger.d("Inserted new note, ID: " + box.getId());
@dingbuoyi
dingbuoyi / gist:19080941784071ab0afa
Created January 6, 2015 09:43
aquery 上传文件
File dir = Environment.getExternalStorageDirectory();//获取SD卡目录
File file = new File(dir, "girl.jpg");//文件必须存在,自己放个同名的图片过去
AQuery aq = new AQuery(TestActivity.this);
String url = APIAgent.URL_SERVER_IMPRESSION_UPLOAD;
Map<String, Object> params = new HashMap<String, Object>();
params.put("message", "Message");
params.put("file", file);//可以传二进制数据也可以传文件
AjaxCallback<String> cb = new AjaxCallback<String>() {
@Override