@Override public void onClick(View v) { String selectTag = v.getTag().toString(); String tempStr = selectTag.substring(0, 1); int index = Integer.parseInt(tempStr); String value = selectTag.substring(1, 2); Util.sysLog("type", "index:" + index + "\t value:" + value); switch (index) { case 1: typeZizhi = value; break; case 2: typeXinyu = value; break; case 3: typeCategory = value; break; default: break; } Util.sysLog("type", "type selected:" + v.getTag().toString()); Intent data = new Intent(); data.putExtra(EXTRA_ZIZHI, typeZizhi); data.putExtra(EXTRA_XINYU, typeXinyu); data.putExtra(EXTRA_CATE, typeCategory); setResult(Activity.RESULT_OK, data); finish(); }
/** * 是否已经登录 * * @return */ public boolean isLogin() { String name = mPrefDAO.getUserName(); String password = mPrefDAO.getUserPassword(); if (!Util.isEmpty(name) && !Util.isEmpty(password)) { Util.sysLog(TAG, "是否已经登录:YES"); return true; } Util.sysLog(TAG, "是否已经登录:NO"); return false; }
/** update cart badge */ public void updateCartNum(Context ctx) { Util.sysLog(TAG, "updateCartNum call"); if (cartBadge != null) { int num = cart.getAllItemCountRealTime(ctx); Util.sysLog(TAG, "updateCartNum:" + num); if (num > 0) { cartBadge.setText(String.valueOf(num)); cartBadge.show(); } else { cartBadge.hide(); } } }
/** * 网络是否可用 * * @return */ public boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null && activeNetInfo.isAvailable()) { Util.sysLog(TAG, "---> net work is available"); return true; } return false; }
/** 实例化 */ public void onCreate() { super.onCreate(); Util.sysLog(TAG, "===>app onCreate"); mPrefDAO = new PrefDAO(this); // 初始化图片下载对象 initImageLoader(); // 错误处理 CrashHandler crashHandler = CrashHandler.getInstance(); // 注册crashHandler crashHandler.init(getApplicationContext()); // // 发送以前没发送的报告(可选) // crashHandler.sendPreviousReportsToServer(); Log.d(TAG, "实例化远程调用接口"); mApi = new Api(); }
private void initImageLoader() { categoryLoadOption = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.product_icon_default) // resource or drawable .showImageForEmptyUri(R.drawable.product_icon_default) // resource or drawable .showImageOnFail(R.drawable.product_icon_default) // resource or drawable .resetViewBeforeLoading(false) // default .delayBeforeLoading(500) .cacheInMemory(true) // default .cacheOnDisk(true) // default .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .build(); File cacheDir = StorageUtils.getOwnCacheDirectory(getApplicationContext(), "imageloader/Cache"); Util.sysLog(TAG, "image cache path:" + cacheDir.getAbsolutePath()); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) .defaultDisplayImageOptions(categoryLoadOption) .memoryCacheExtraOptions(480, 800) .diskCacheExtraOptions(480, 800, null) .threadPoolSize(2) .threadPriority(Thread.NORM_PRIORITY - 2) .denyCacheImageMultipleSizesInMemory() .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) .memoryCacheSize(2 * 1024 * 1024) .diskCacheFileNameGenerator(new Md5FileNameGenerator()) .diskCacheSize(50 * 1024 * 1024) .diskCacheFileCount(100) .diskCache(new UnlimitedDiscCache(cacheDir)) .tasksProcessingOrder(QueueProcessingType.FIFO) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .writeDebugLogs() .build(); ImageLoader.getInstance().init(config); }