Java Code Examples for com.mob.tools.utils.ResHelper#forceCast()

The following examples show how to use com.mob.tools.utils.ResHelper#forceCast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryAPIActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_history);

    lvHistory = ResHelper.forceCast(findViewById(R.id.lvHistory));
    lvHistory.setSelector(new ColorDrawable(0));

    spMonth = ResHelper.forceCast(findViewById(R.id.spMonth));
    spMonth.setOnItemSelectedListener(this);
    ArrayList<String> monthList = new ArrayList<String>();
    for (int i = 1; i <= 12; i++) {
        monthList.add(IntegerToString(i));
    }
    spMonth.setAdapter(new ArrayAdapter<String>(this, R.layout.view_spinner, monthList));
    spDay = ResHelper.forceCast(findViewById(R.id.spDay));
    spDay.setOnItemSelectedListener(this);

    api = ResHelper.forceCast(MobAPI.getAPI(History.NAME));
    showToday();
}
 
Example 2
Source File: LotteryAPIActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = inflater.inflate(R.layout.view_lottery_item, null);
	}
	TextView tvAwards = ResHelper.forceCast(convertView.findViewById(R.id.tvAwards));
	TextView tvAwardNumber = ResHelper.forceCast(convertView.findViewById(R.id.tvAwardNumber));
	TextView tvAwardPrice = ResHelper.forceCast(convertView.findViewById(R.id.tvAwardPrice));
	TextView tvType = ResHelper.forceCast(convertView.findViewById(R.id.tvType));
	HashMap<String, Object> res = getItem(position);
	if (res != null) {
		tvAwards.setText(ResHelper.toString(res.get("awards")));
		tvAwardNumber.setText(getNumberString(res.get("awardNumber")));
		tvAwardPrice.setText(getNumberString(res.get("awardPrice")));
		String type = ResHelper.toString(res.get("type"));
		tvType.setText(type == null ? "" : type);
	}
	return convertView;
}
 
Example 3
Source File: OilPriceAPIActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	final ViewHolder viewHolder;
	if (convertView == null) {
		convertView = inflater.inflate(R.layout.view_oilprice_item, null);
		viewHolder = new ViewHolder();
		viewHolder.tvProvince = ResHelper.forceCast(convertView.findViewById(R.id.tvProvince));
		viewHolder.tvDieselOil0 = ResHelper.forceCast(convertView.findViewById(R.id.tvDieselOil0));
		viewHolder.tvGasoline90 = ResHelper.forceCast(convertView.findViewById(R.id.tvGasoline90));
		viewHolder.tvGasoline93 = ResHelper.forceCast(convertView.findViewById(R.id.tvGasoline93));
		viewHolder.tvGasoline97 = ResHelper.forceCast(convertView.findViewById(R.id.tvGasoline97));
		convertView.setTag(viewHolder);
	} else {
		viewHolder = ResHelper.forceCast(convertView.getTag());
	}
	HashMap<String, Object> res = getItem(position);
	if (res != null) {
		viewHolder.tvProvince.setText(com.mob.tools.utils.ResHelper.toString(res.get("province")));
		viewHolder.tvDieselOil0.setText(com.mob.tools.utils.ResHelper.toString(res.get("dieselOil0")));
		viewHolder.tvGasoline90.setText(com.mob.tools.utils.ResHelper.toString(res.get("gasoline90")));
		viewHolder.tvGasoline93.setText(com.mob.tools.utils.ResHelper.toString(res.get("gasoline93")));
		viewHolder.tvGasoline97.setText(com.mob.tools.utils.ResHelper.toString(res.get("gasoline97")));
	}
	return convertView;
}
 
Example 4
Source File: WxArticleAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_wxarticle);
	ListView lvResult = ResHelper.forceCast(findViewById(R.id.lvResult));
	lvResult.setOnItemClickListener(this);

	//init data
	categoryList = new ArrayList<HashMap<String, Object>>();
	categoryAdapter = new SimpleAdapter(this, categoryList, R.layout.view_wxarticle_category_item, new String[]{"cid", "name"},
			new int[]{R.id.tvCid, R.id.tvName});
	lvResult.setAdapter(categoryAdapter);

	//查询分类信息
	((WxArticle) ResHelper.forceCast(MobAPI.getAPI(WxArticle.NAME))).queryCategory(this);
}
 
Example 5
Source File: TrainTicketsAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
	if (isQuerying) {
		return;
	}
	isQuerying = true;
	HashMap<String, Object> item = ResHelper.forceCast(adapterView.getAdapter().getItem(position));
	if (currentIsTrainNoResult) {
		String start = ResHelper.forceCast(item.get("startStationName"));
		String end = ResHelper.forceCast(item.get("endStationName"));
		if (TextUtils.isEmpty(start) || TextUtils.isEmpty(end)) {
			isQuerying = false;
			return;
		}
		etTrainNo.setText("");
		etStartStation.setText(start);
		etEndStation.setText(end);
		//站站查询
		((TrainTickets) MobAPI.getAPI(TrainTickets.NAME)).queryByStationToStation(start, end, TrainTicketsAPIActivity.this);
		return;
	}
	//车次查询
	etStartStation.setText("");
	etEndStation.setText("");
	String stationTrainCode = ResHelper.forceCast(item.get("stationTrainCode"));
	etTrainNo.setText(stationTrainCode);
	((TrainTickets) MobAPI.getAPI(TrainTickets.NAME)).queryByTrainNo(stationTrainCode, TrainTicketsAPIActivity.this);
}
 
Example 6
Source File: GoldAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_gold);
	btnFuture = ResHelper.forceCast(findViewById(R.id.btnFuture));
	btnSpot = ResHelper.forceCast(findViewById(R.id.btnSpot));
	tvTittle = ResHelper.forceCast(findViewById(R.id.tvTittle));
	lvResult = ResHelper.forceCast(findViewById(R.id.lvResult));

	btnFuture.setOnClickListener(this);
	btnSpot.setOnClickListener(this);
}
 
Example 7
Source File: LaoHuangLiAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_laohuangli);
	spYear  = ResHelper.forceCast(findViewById(R.id.spYear));
	spMonth = ResHelper.forceCast(findViewById(R.id.spManth));
	spDay   = ResHelper.forceCast(findViewById(R.id.spDay));

	spYear.setOnItemSelectedListener(this);
	spMonth.setOnItemSelectedListener(this);
	spDay.setOnItemSelectedListener(this);

	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	String[] dates = dateFormat.format(new java.util.Date()).split("-");
	int startyear = 1900;
	initSpinner(1900, 2099, spYear);
	initSpinner(1, 12, spMonth);
	initSpinner(1, 31, spDay);

	spYear.setSelection(Integer.parseInt(dates[0]) - startyear);
	spMonth.setSelection(Integer.parseInt(dates[1]) - 1);
	spDay.setSelection(Integer.parseInt(dates[2]) - 1);

	tvLhlAvoid     = ResHelper.forceCast(findViewById(R.id.tvLhlAvoid));
	tvLhlJiShen    = ResHelper.forceCast(findViewById(R.id.tvLhlJiShen));
	tvLhlSuit      = ResHelper.forceCast(findViewById(R.id.tvLhlSuit));
	tvLhlXiongShen = ResHelper.forceCast(findViewById(R.id.tvLhlXiongShen));
	tvLhlDate      = ResHelper.forceCast(findViewById(R.id.tvLhlDate));
	tvLhlLunar     = ResHelper.forceCast(findViewById(R.id.tvLhlLunar));

	api = (LaoHuangLi) MobAPI.getAPI(LaoHuangLi.NAME);
}
 
Example 8
Source File: PlatformPageAdapter.java    From POCenter with MIT License 5 votes vote down vote up
public void onClick(View v) {
	long time = System.currentTimeMillis();
	if (time - lastClickTime < MIN_CLICK_INTERVAL) {
		return;
	}
	lastClickTime = time;

	if (v.getTag() instanceof CustomerLogo) {
		CustomerLogo logo = ResHelper.forceCast(v.getTag());
		page.performCustomLogoClick(v, logo);
	} else {
		Platform plat = ResHelper.forceCast(v.getTag());
		page.showEditPage(plat);
	}
}
 
Example 9
Source File: DomesticMetalAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_domestic_metal);
	btnTianjin = ResHelper.forceCast(findViewById(R.id.btnTianjin));
	btnGuangdong = ResHelper.forceCast(findViewById(R.id.btnGuangdong));
	btnNanfang = ResHelper.forceCast(findViewById(R.id.btnNanfang));
	tvTittle = ResHelper.forceCast(findViewById(R.id.tvTittle));
	lvResult = ResHelper.forceCast(findViewById(R.id.lvResult));

	btnTianjin.setOnClickListener(this);
	btnGuangdong.setOnClickListener(this);
	btnNanfang.setOnClickListener(this);

	onClick(btnTianjin);
}
 
Example 10
Source File: LaoHuangLiAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
public void onSuccess(API api, int action, Map<String, Object> result) {
	HashMap<String, Object> res = ResHelper.forceCast(result.get("result"));
	tvLhlAvoid.setText(com.mob.tools.utils.ResHelper.toString(res.get("avoid")));
	tvLhlJiShen.setText(com.mob.tools.utils.ResHelper.toString(res.get("jishen")));
	tvLhlSuit.setText(com.mob.tools.utils.ResHelper.toString(res.get("suit")));
	tvLhlXiongShen.setText(com.mob.tools.utils.ResHelper.toString(res.get("xiongshen")));
	tvLhlDate.setText(com.mob.tools.utils.ResHelper.toString(res.get("date")));
	tvLhlLunar.setText(com.mob.tools.utils.ResHelper.toString(res.get("lunar")));
}
 
Example 11
Source File: OnekeyShare.java    From POCenter with MIT License 5 votes vote down vote up
/** 设置自己图标和点击事件,可以重复调用添加多次 */
public void setCustomerLogo(Bitmap logo, String label, OnClickListener ocl) {
	CustomerLogo cl = new CustomerLogo();
	cl.logo = logo;
	cl.label = label;
	cl.listener = ocl;
	ArrayList<CustomerLogo> customers = ResHelper.forceCast(params.get("customers"));
	customers.add(cl);
}
 
Example 12
Source File: GlobalStockListAPIActivity.java    From styT with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
	final ViewHolder viewHolder;
	HashMap<String, Object> itemData = getItem(position);
	if (itemData != null && !itemData.isEmpty()) {
		if (convertView == null) {
			if (((Integer) itemData.get("type")) == TYPE_CONTINENT) {
				convertView = LayoutInflater.from(GlobalStockListAPIActivity.this).inflate(R.layout.view_globalstock_item_continent,
						viewGroup, false);
			} else if (((Integer) itemData.get("type")) == TYPE_COUNTRY) {
				convertView = LayoutInflater.from(GlobalStockListAPIActivity.this).inflate(R.layout.view_globalstock_item_country,
						viewGroup, false);
			} else if (((Integer) itemData.get("type")) == TYPE_CODES) {
				convertView = LayoutInflater.from(GlobalStockListAPIActivity.this).inflate(R.layout.view_globalstock_item_code,
						viewGroup, false);
			}
			viewHolder = new ViewHolder();
			viewHolder.tvContinent = ResHelper.forceCast(convertView.findViewById(R.id.tvContinent));
			viewHolder.tvCountry = ResHelper.forceCast(convertView.findViewById(R.id.tvCountry));
			viewHolder.tvName = ResHelper.forceCast(convertView.findViewById(R.id.tvName));
			viewHolder.tvCode = ResHelper.forceCast(convertView.findViewById(R.id.tvCode));
			convertView.setTag(viewHolder);
		} else {
			viewHolder = ResHelper.forceCast(convertView.getTag());
		}
		if (viewHolder.tvContinent != null) {
			viewHolder.tvContinent.setText(itemData.get("continent").toString());
		}
		if (viewHolder.tvCountry != null) {
			viewHolder.tvCountry.setText(itemData.get("country").toString());
		}
		if (viewHolder.tvName != null) {
			viewHolder.tvName.setText(itemData.get("name").toString());
		}
		if (viewHolder.tvCode != null) {
			viewHolder.tvCode.setText(itemData.get("code").toString());
		}
	}
	return convertView;
}
 
Example 13
Source File: PlatformPageAdapter.java    From YiZhi with Apache License 2.0 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0));
		TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1));
		if (logos[i] == null) {
			ivLogo.setVisibility(View.INVISIBLE);
			tvName.setVisibility(View.INVISIBLE);
			llCells[i].setBackgroundResource(disableBack);
			llCells[i].setOnClickListener(null);
		} else {
			ivLogo.setVisibility(View.VISIBLE);
			tvName.setVisibility(View.VISIBLE);
			ivLogo.requestLayout();
			tvName.requestLayout();
			llCells[i].setBackgroundResource(cellBack);
			llCells[i].setOnClickListener(this);
			llCells[i].setTag(logos[i]);

			if (logos[i] instanceof CustomerLogo) {
				CustomerLogo logo = ResHelper.forceCast(logos[i]);
				if (logo.logo != null) {
					ivLogo.setImageBitmap(logo.logo);
				} else {
					ivLogo.setImageBitmap(null);
				}
				if (logo.label != null) {
					tvName.setText(logo.label);
				} else {
					tvName.setText("");
				}
			} else {
				Platform plat = ResHelper.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}
 
Example 14
Source File: OnekeyShare.java    From LQRWeChat with MIT License 4 votes vote down vote up
/** 添加一个隐藏的platform */
public void addHiddenPlatform(String platform) {
	HashMap<String, String> hiddenPlatforms = ResHelper.forceCast(params.get("hiddenPlatforms"));
	hiddenPlatforms.put(platform, platform);
}
 
Example 15
Source File: OnekeyShare.java    From enjoyshop with Apache License 2.0 4 votes vote down vote up
/** 添加一个隐藏的platform */
public void addHiddenPlatform(String platform) {
	HashMap<String, String> hiddenPlatforms = ResHelper.forceCast(params.get("hiddenPlatforms"));
	hiddenPlatforms.put(platform, platform);
}
 
Example 16
Source File: PlatformPageAdapter.java    From LiuAGeAndroid with MIT License 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0));
		TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1));
		if (logos[i] == null) {
			ivLogo.setVisibility(View.INVISIBLE);
			tvName.setVisibility(View.INVISIBLE);
			llCells[i].setBackgroundResource(disableBack);
			llCells[i].setOnClickListener(null);
		} else {
			ivLogo.setVisibility(View.VISIBLE);
			tvName.setVisibility(View.VISIBLE);
			llCells[i].setBackgroundResource(cellBack);
			llCells[i].setOnClickListener(this);
			llCells[i].setTag(logos[i]);

			if (logos[i] instanceof CustomerLogo) {
				CustomerLogo logo = ResHelper.forceCast(logos[i]);
				if (logo.logo != null) {
					ivLogo.setImageBitmap(logo.logo);
				} else {
					ivLogo.setImageBitmap(null);
				}
				if (logo.label != null) {
					tvName.setText(logo.label);
				} else {
					tvName.setText("");
				}
			} else {
				Platform plat = ResHelper.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}
 
Example 17
Source File: PlatformPage.java    From enjoyshop with Apache License 2.0 4 votes vote down vote up
public PlatformPage(OnekeyShareThemeImpl impl) {
    super(impl);
    this.impl = ResHelper.forceCast(impl);
}
 
Example 18
Source File: UserCenterAPIActivity.java    From styT with Apache License 2.0 4 votes vote down vote up
public void onSuccess(API api, int action, Map<String, Object> result) {
	switch (action) {
		case UserCenter.ACTION_REGISTER: {
			uid = ResHelper.forceCast(result.get("result"));
			tvUserInfo.setText(getString(R.string.usercenter_api_toast_register_suc) + "\n"
					+ "uid = " + uid + "\n"
					+ getString(R.string.usercenter_api_user_not_login));
		} break;
		case UserCenter.ACTION_LOGIN: {
			HashMap<String, String> res = ResHelper.forceCast(result.get("result"));
			if (res != null) {
				token = res.get("token");
				uid = res.get("uid");
			}
			tvUserInfo.setText(getString(R.string.usercenter_api_toast_login_suc) + "\n"
					+ "uid = " + uid + "\n"
					+ "token =  " + token);
		} break;
		case UserCenter.ACTION_CHANGE_PASSWORD: {
			tvUserInfo.setText(getString(R.string.usercenter_api_toast_change_suc) + "\n"
					+ "uid = " + uid + "\n"
					+ "token =  " + token);
		} break;
		case UserCenter.ACTION_FORGOT_PASSWORD: {
			tvUserInfo.setText(String.valueOf(result.get("msg")));
		} break;
		case UserCenter.ACTION_PROFILE_PUT:
		case UserCenter.ACTION_DATA_PUT: {
			tvUserInfo.setText(getString(R.string.usercenter_api_toast_put_suc) + "\n"
					+ "uid = " + uid + "\n"
					+ "token =  " + token);
		} break;
		case UserCenter.ACTION_DATA_DEL:
		case UserCenter.ACTION_PROFILE_DEL: {
			tvUserInfo.setText(getString(R.string.usercenter_api_toast_del_suc) + "\n"
					+ "uid = " + uid + "\n"
					+ "token =  " + token);
		} break;
		case UserCenter.ACTION_DATA_QUERY:
		case UserCenter.ACTION_PROFILE_QUERY: {
			try {
				if (TextUtils.isEmpty(inputItemStr) || inputItemStr.contains(",")) {
					//如果输入的为空或者是输入了多项,则查询到的是用户所有或者多项的资料项或者数据
					HashMap<String, String> response = ResHelper.forceCast(result.get("result"));
					StringBuffer sb = new StringBuffer();
					for (Map.Entry<String, String> entry : response.entrySet()) {
						sb.append(decodeData(entry.getKey()));
						sb.append(":");
						sb.append(decodeData(entry.getValue()));
						sb.append("\n");
					}
					tvUserInfo.setText(getString(R.string.usercenter_api_toast_query_suc) + "\n"
							+ sb.toString());
					break;
				}
				String value = decodeData((String) result.get("result"));
				tvUserInfo.setText(getString(R.string.usercenter_api_toast_query_suc) + "\n"
						+ "value = " + value + "\n");
			} catch (Exception e) {
				e.printStackTrace();
			}
		} break;
	}
	setBtnEnable(true);
}
 
Example 19
Source File: PlatformPage.java    From YiZhi with Apache License 2.0 4 votes vote down vote up
public PlatformPage(OnekeyShareThemeImpl impl) {
	super(impl);
	this.impl = ResHelper.forceCast(impl);
}
 
Example 20
Source File: PlatformPageAdapter.java    From BaoKanAndroid with MIT License 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = ResHelper.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = ResHelper.forceCast(llCells[i].getChildAt(0));
		TextView tvName = ResHelper.forceCast(llCells[i].getChildAt(1));
		if (logos[i] == null) {
			ivLogo.setVisibility(View.INVISIBLE);
			tvName.setVisibility(View.INVISIBLE);
			llCells[i].setBackgroundResource(disableBack);
			llCells[i].setOnClickListener(null);
		} else {
			ivLogo.setVisibility(View.VISIBLE);
			tvName.setVisibility(View.VISIBLE);
			llCells[i].setBackgroundResource(cellBack);
			llCells[i].setOnClickListener(this);
			llCells[i].setTag(logos[i]);

			if (logos[i] instanceof CustomerLogo) {
				CustomerLogo logo = ResHelper.forceCast(logos[i]);
				if (logo.logo != null) {
					ivLogo.setImageBitmap(logo.logo);
				} else {
					ivLogo.setImageBitmap(null);
				}
				if (logo.label != null) {
					tvName.setText(logo.label);
				} else {
					tvName.setText("");
				}
			} else {
				Platform plat = ResHelper.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = ResHelper.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = ResHelper.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}