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

The following examples show how to use com.mob.tools.utils.R#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: OnekeyShareThemeImpl.java    From fingerpoetry-android with Apache License 2.0 6 votes vote down vote up
final ShareParams shareDataToShareParams(Platform plat) {
	if (plat == null || shareParamsMap == null) {
		toast("ssdk_oks_share_failed");
		return null;
	}

	try {
		String imagePath = R.forceCast(shareParamsMap.get("imagePath"));
		Bitmap viewToShare = R.forceCast(shareParamsMap.get("viewToShare"));
		if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) {
			String path = R.getCachePath(plat.getContext(), "screenshot");
			File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
			FileOutputStream fos = new FileOutputStream(ss);
			viewToShare.compress(CompressFormat.JPEG, 100, fos);
			fos.flush();
			fos.close();
			shareParamsMap.put("imagePath", ss.getAbsolutePath());
		}
	} catch (Throwable t) {
		t.printStackTrace();
		toast("ssdk_oks_share_failed");
		return null;
	}

	return new ShareParams(shareParamsMap);
}
 
Example 2
Source File: OnekeyShareThemeImpl.java    From HHComicViewer with Apache License 2.0 6 votes vote down vote up
final ShareParams shareDataToShareParams(Platform plat) {
	if (plat == null || shareParamsMap == null) {
		toast("ssdk_oks_share_failed");
		return null;
	}

	try {
		String imagePath = R.forceCast(shareParamsMap.get("imagePath"));
		Bitmap viewToShare = R.forceCast(shareParamsMap.get("viewToShare"));
		if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) {
			String path = R.getCachePath(plat.getContext(), "screenshot");
			File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
			FileOutputStream fos = new FileOutputStream(ss);
			viewToShare.compress(CompressFormat.JPEG, 100, fos);
			fos.flush();
			fos.close();
			shareParamsMap.put("imagePath", ss.getAbsolutePath());
		}
	} catch (Throwable t) {
		t.printStackTrace();
		toast("ssdk_oks_share_failed");
		return null;
	}

	return new ShareParams(shareParamsMap);
}
 
Example 3
Source File: OnekeyShareThemeImpl.java    From Social with Apache License 2.0 6 votes vote down vote up
final ShareParams shareDataToShareParams(Platform plat) {
	if (plat == null || shareParamsMap == null) {
		toast("ssdk_oks_share_failed");
		return null;
	}

	try {
		String imagePath = R.forceCast(shareParamsMap.get("imagePath"));
		Bitmap viewToShare = R.forceCast(shareParamsMap.get("viewToShare"));
		if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) {
			String path = R.getCachePath(plat.getContext(), "screenshot");
			File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
			FileOutputStream fos = new FileOutputStream(ss);
			viewToShare.compress(CompressFormat.JPEG, 100, fos);
			fos.flush();
			fos.close();
			shareParamsMap.put("imagePath", ss.getAbsolutePath());
		}
	} catch (Throwable t) {
		t.printStackTrace();
		toast("ssdk_oks_share_failed");
		return null;
	}

	return new ShareParams(shareParamsMap);
}
 
Example 4
Source File: PlatformPageAdapter.java    From Mobike with Apache License 2.0 5 votes vote down vote up
public View getView(int index, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = createPanel(parent.getContext());
	}

	LinearLayout llPanel = R.forceCast(convertView);
	LinearLayout[] llCells = R.forceCast(llPanel.getTag());
	refreshPanel(llCells, cells[index]);
	return convertView;
}
 
Example 5
Source File: EditPage.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
/** 动态适配编辑界面的高度 */
public void run() {
	int height = svContent.getChildAt(0).getHeight();
	RelativeLayout.LayoutParams lp = R.forceCast(svContent.getLayoutParams());
	if (height > maxBodyHeight && lp.height != maxBodyHeight) {
		lp.height = maxBodyHeight;
		svContent.setLayoutParams(lp);
	} else if (height < maxBodyHeight && lp.height == maxBodyHeight) {
		lp.height = LayoutParams.WRAP_CONTENT;
		svContent.setLayoutParams(lp);
	}
}
 
Example 6
Source File: EditPage.java    From GithubApp with Apache License 2.0 5 votes vote down vote up
/** 动态适配编辑界面的高度 */
public void run() {
	int height = svContent.getChildAt(0).getHeight();
	RelativeLayout.LayoutParams lp = R.forceCast(svContent.getLayoutParams());
	if (height > maxBodyHeight && lp.height != maxBodyHeight) {
		lp.height = maxBodyHeight;
		svContent.setLayoutParams(lp);
	} else if (height < maxBodyHeight && lp.height == maxBodyHeight) {
		lp.height = LayoutParams.WRAP_CONTENT;
		svContent.setLayoutParams(lp);
	}
}
 
Example 7
Source File: EditPage.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
/** 动态适配编辑界面的高度 */
public void run() {
	int height = svContent.getChildAt(0).getHeight();
	RelativeLayout.LayoutParams lp = R.forceCast(svContent.getLayoutParams());
	if (height > maxBodyHeight && lp.height != maxBodyHeight) {
		lp.height = maxBodyHeight;
		svContent.setLayoutParams(lp);
	} else if (height < maxBodyHeight && lp.height == maxBodyHeight) {
		lp.height = LayoutParams.WRAP_CONTENT;
		svContent.setLayoutParams(lp);
	}
}
 
Example 8
Source File: PlatformPageAdapter.java    From GithubApp with Apache License 2.0 5 votes vote down vote up
public View getView(int index, View convertView, ViewGroup parent) {
	if (convertView == null) {
		convertView = createPanel(parent.getContext());
	}

	LinearLayout llPanel = R.forceCast(convertView);
	LinearLayout[] llCells = R.forceCast(llPanel.getTag());
	refreshPanel(llCells, cells[index]);
	return convertView;
}
 
Example 9
Source File: PlatformPageAdapter.java    From HHComicViewer with Apache License 2.0 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = R.forceCast(llCells[i].getChildAt(0));
		TextView tvName = R.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 = R.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 = R.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = R.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = R.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}
 
Example 10
Source File: OnekeyShare.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
/** 自定义不同平台分享不同内容的回调 */
public ShareContentCustomizeCallback getShareContentCustomizeCallback() {
	return R.forceCast(params.get("customizeCallback"));
}
 
Example 11
Source File: OnekeyShare.java    From Social with Apache License 2.0 4 votes vote down vote up
/** 自定义不同平台分享不同内容的回调 */
public ShareContentCustomizeCallback getShareContentCustomizeCallback() {
	return R.forceCast(params.get("customizeCallback"));
}
 
Example 12
Source File: PlatformPageAdapter.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = R.forceCast(llCells[i].getChildAt(0));
		TextView tvName = R.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 = R.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 = R.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = R.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = R.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}
 
Example 13
Source File: OnekeyShare.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
/** 添加一个隐藏的platform */
public void addHiddenPlatform(String platform) {
	HashMap<String, String> hiddenPlatforms = R.forceCast(params.get("hiddenPlatforms"));
	hiddenPlatforms.put(platform, platform);
}
 
Example 14
Source File: OnekeyShare.java    From Social with Apache License 2.0 4 votes vote down vote up
/** 返回操作回调 */
public PlatformActionListener getCallback() {
	return R.forceCast(params.get("callback"));
}
 
Example 15
Source File: OnekeyShare.java    From HHComicViewer with Apache License 2.0 4 votes vote down vote up
/**
 * 返回操作回调
 */
public PlatformActionListener getCallback() {
    return R.forceCast(params.get("callback"));
}
 
Example 16
Source File: PlatformPageAdapter.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = R.forceCast(llCells[i].getChildAt(0));
		TextView tvName = R.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 = R.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 = R.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = R.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = R.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}
 
Example 17
Source File: PlatformPage.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
public PlatformPage(OnekeyShareThemeImpl impl) {
	super(impl);
	this.impl = R.forceCast(impl);
}
 
Example 18
Source File: PlatformPage.java    From GithubApp with Apache License 2.0 4 votes vote down vote up
public PlatformPage(OnekeyShareThemeImpl impl) {
	super(impl);
	this.impl = R.forceCast(impl);
}
 
Example 19
Source File: OnekeyShare.java    From MyHearts with Apache License 2.0 4 votes vote down vote up
/** 添加一个隐藏的platform */
public void addHiddenPlatform(String platform) {
	HashMap<String, String> hiddenPlatforms = R.forceCast(params.get("hiddenPlatforms"));
	hiddenPlatforms.put(platform, platform);
}
 
Example 20
Source File: PlatformPageAdapter.java    From Social with Apache License 2.0 4 votes vote down vote up
private void refreshPanel(LinearLayout[] llCells, Object[] logos) {
	int cellBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platform_cell_back");
	int disableBack = R.getBitmapRes(page.getContext(), "ssdk_oks_classic_platfrom_cell_back_nor");
	for (int i = 0; i < logos.length; i++) {
		ImageView ivLogo = R.forceCast(llCells[i].getChildAt(0));
		TextView tvName = R.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 = R.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 = R.forceCast(logos[i]);
				String name = plat.getName().toLowerCase();
				int resId = R.getBitmapRes(ivLogo.getContext(),"ssdk_oks_classic_" + name);
				if (resId > 0) {
					ivLogo.setImageResource(resId);
				} else {
					ivLogo.setImageBitmap(null);
				}
				resId = R.getStringRes(tvName.getContext(), "ssdk_" + name);
				if (resId > 0) {
					tvName.setText(resId);
				} else {
					tvName.setText("");
				}
			}
		}
	}
}