Java Code Examples for android.widget.Gallery.setTag()

The following are Jave code examples for showing how to use setTag() of the android.widget.Gallery class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: lr_dialer   File: Common.java   Source Code and License Vote up 5 votes
private static boolean shouldDelayGallery(int position, View convertView, ViewGroup parent, String url)
{
	if (url == null || BitmapAjaxCallback.isMemoryCached(url))
	{
		return false;
	}
	Gallery gallery = (Gallery) parent;
	Integer selected = (Integer) gallery.getTag(AQuery.TAG_NUM);
	if (selected == null)
	{
		selected = 0;
		gallery.setTag(AQuery.TAG_NUM, 0);
		gallery.setCallbackDuringFling(false);
		Common common = new Common();
		common.listen(gallery);
	}
	int first = gallery.getFirstVisiblePosition();
	int last = gallery.getLastVisiblePosition();
	int diff = last - first;
	int delta = (diff / 2) + 1;
	int from = selected - delta;
	int to = selected + delta;
	if (from < 0)
	{
		//shift window back to positive region
		to = to - from;
		from = 0;
	}
	if ((position >= from && position <= to))
	{
		//AQUtility.debug("yes", position + ":" + from + "." + to);
		convertView.setTag(AQuery.TAG_NUM, position);
		return false;
	}
	//AQUtility.debug("no", position + ":" + from + "." + to);
	convertView.setTag(AQuery.TAG_NUM, null);
	return true;
}
 
Example 2
Project: ExoPlayerDemo   File: Common.java   Source Code and License Vote up 2 votes
private static boolean shouldDelayGallery(int position, View convertView, ViewGroup parent, String url){
	

	if(url == null || BitmapAjaxCallback.isMemoryCached(url)){
		return false;
	}
	
	Gallery gallery = (Gallery) parent;
	
	Integer selected = (Integer) gallery.getTag(AQuery.TAG_NUM);
	
	if(selected == null){
		
		selected = 0;
		gallery.setTag(AQuery.TAG_NUM, 0);
		
		gallery.setCallbackDuringFling(false);
		
		Common common = new Common();
		common.listen(gallery);
		
	}
	
	int first = gallery.getFirstVisiblePosition();
	int last = gallery.getLastVisiblePosition();
	
	int diff = last - first;
	int delta = (diff / 2) + 1;
	
	int from = selected - delta;
	int to = selected + delta;
	
	if(from < 0){
		//shift window back to positive region
		to = to - from;
		from = 0;
	}
	
	if((position >= from && position <= to)){
		
		//AQUtility.debug("yes", position + ":" + from + "." + to);
		convertView.setTag(AQuery.TAG_NUM, position);
		
		return false;
	}
	
	//AQUtility.debug("no", position + ":" + from + "." + to);
	convertView.setTag(AQuery.TAG_NUM, null);
	return true;
	
}
 
Example 3
Project: NeXT_pyp   File: Common.java   Source Code and License Vote up 2 votes
private static boolean shouldDelayGallery(int position, View convertView,
		ViewGroup parent, String url) {

	if (url == null || BitmapAjaxCallback.isMemoryCached(url)) {
		return false;
	}

	Gallery gallery = (Gallery) parent;

	Integer selected = (Integer) gallery.getTag(Constants.TAG_NUM);

	if (selected == null) {

		selected = 0;
		gallery.setTag(Constants.TAG_NUM, 0);

		gallery.setCallbackDuringFling(false);

		Common common = new Common();
		common.listen(gallery);

	}

	int first = gallery.getFirstVisiblePosition();
	int last = gallery.getLastVisiblePosition();

	int diff = last - first;
	int delta = (diff / 2) + 1;

	int from = selected - delta;
	int to = selected + delta;

	if (from < 0) {
		// shift window back to positive region
		to = to - from;
		from = 0;
	}

	if ((position >= from && position <= to)) {

		// AQUtility.debug("yes", position + ":" + from + "." + to);
		convertView.setTag(Constants.TAG_NUM, position);

		return false;
	}

	// AQUtility.debug("no", position + ":" + from + "." + to);
	convertView.setTag(Constants.TAG_NUM, null);
	return true;

}
 
Example 4
Project: NeXT_pyp   File: Common.java   Source Code and License Vote up 2 votes
private static boolean shouldDelayGallery(int position, View convertView,
		ViewGroup parent, String url) {

	if (url == null || BitmapAjaxCallback.isMemoryCached(url)) {
		return false;
	}

	Gallery gallery = (Gallery) parent;

	Integer selected = (Integer) gallery.getTag(Constants.TAG_NUM);

	if (selected == null) {

		selected = 0;
		gallery.setTag(Constants.TAG_NUM, 0);

		gallery.setCallbackDuringFling(false);

		Common common = new Common();
		common.listen(gallery);

	}

	int first = gallery.getFirstVisiblePosition();
	int last = gallery.getLastVisiblePosition();

	int diff = last - first;
	int delta = (diff / 2) + 1;

	int from = selected - delta;
	int to = selected + delta;

	if (from < 0) {
		// shift window back to positive region
		to = to - from;
		from = 0;
	}

	if ((position >= from && position <= to)) {

		// AQUtility.debug("yes", position + ":" + from + "." + to);
		convertView.setTag(Constants.TAG_NUM, position);

		return false;
	}

	// AQUtility.debug("no", position + ":" + from + "." + to);
	convertView.setTag(Constants.TAG_NUM, null);
	return true;

}