Java Code Examples for android.widget.BaseAdapter#getItem()

The following examples show how to use android.widget.BaseAdapter#getItem() . 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: EditMicroBlogAccountSelectorItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
	if (!(adapter instanceof AccountSelectorListAdapter)) {
		return;
	}
	
	LocalAccount account = (LocalAccount)adapter.getItem(position);
       if (selectorWindow.isSelected(account)) {
       	selectorWindow.removeSelectedAccount(account);
       } else {
       	selectorWindow.addSelectedAccount(account);
       }
       
       EditMicroBlogActivity context = (EditMicroBlogActivity)parent.getContext();
       context.setListUpdateAccount(selectorWindow.getSelectedAccounts());
       context.updateSelectorText();
}
 
Example 2
Source File: EditMicroBlogEmotionItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = (BaseAdapter)parent.getAdapter();
	String emotion = (String)adapter.getItem(position);
       if (StringUtil.isEmpty(emotion)) {
       	return;
       }
       
	EditText etText = (EditText)((Activity)context).findViewById(R.id.etText);
	int currentPos = 0;
	if (etText != null) {
		currentPos = etText.getSelectionStart();
		etText.getText().insert(currentPos, emotion);
	}

}
 
Example 3
Source File: MicroBlogItemLongClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
		int position, long id) {
       BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
       Status status = (Status)adapter.getItem(position);
	if (status == null 
		|| (status instanceof LocalStatus
			&& ((LocalStatus)status).isDivider())) {
		return false;
	}
	
	Intent intent = new Intent();
	Bundle bundle = new Bundle();

	bundle.putSerializable("STATUS", status);
	intent.putExtras(bundle);

	intent.setClass(parent.getContext(), MicroBlogActivity.class);

	((Activity)context).startActivityForResult(intent, Constants.REQUEST_CODE_MY_HOME);
	
	return true;
}
 
Example 4
Source File: HomePageSwitchAccountItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
       BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
       LocalAccount account = (LocalAccount)adapter.getItem(position);        
       if (selectorWindow.isSelected(account)) {
       	selectorWindow.removeSelectedAccount(account);
       } else {
       	selectorWindow.addSelectedAccount(account);
       }
       
       Context context = view.getContext();
       SheJiaoMaoApplication sheJiaoMao = (SheJiaoMaoApplication)context.getApplicationContext();
       sheJiaoMao.setCurrentAccount(account);
       
       HomePageActivity activity = (HomePageActivity)context;
       Skeleton skeleton = activity.getSkeleton();
       if (skeleton != null) {
       	skeleton.setCurrentAccount(account, true);
       	skeleton.setContentType(skeleton.getContentType());
       }
       
       selectorWindow.dismiss();
}
 
Example 5
Source File: SocialGraphItemClickListener.java    From YiBo with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
		long id) {
	BaseAdapter adapter = AdapterUtil.getAdapter(parent.getAdapter());
	if (adapter == null || position >= adapter.getCount()) {
		return;
	}
	
	User user = (User)adapter.getItem(position);
	if (user == null) {
           return;
       }

	Intent intent = new Intent();
	intent.putExtra("USER", user);
	intent.setClass(parent.getContext(), ProfileActivity.class);
	context.startActivity(intent);
}
 
Example 6
Source File: WallpaperPickerActivity.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@Thunk void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 7
Source File: WallpaperPickerActivity.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 8
Source File: WallpaperPickerActivity.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
private void populateWallpapersFromAdapter(ViewGroup parent, BaseAdapter adapter,
        boolean addLongPressHandler) {
    for (int i = 0; i < adapter.getCount(); i++) {
        FrameLayout thumbnail = (FrameLayout) adapter.getView(i, null, parent);
        parent.addView(thumbnail, i);
        WallpaperTileInfo info = (WallpaperTileInfo) adapter.getItem(i);
        thumbnail.setTag(info);
        info.setView(thumbnail);
        if (addLongPressHandler) {
            addLongPressHandler(thumbnail);
        }
        thumbnail.setOnClickListener(mThumbnailOnClickListener);
    }
}
 
Example 9
Source File: WriteilySingleton.java    From writeily-pro with MIT License 5 votes vote down vote up
public void copySelectedNotes(SparseBooleanArray checkedIndices, BaseAdapter notesAdapter, String destination) {
    for (int i = 0; i < checkedIndices.size(); i++) {
        if (checkedIndices.valueAt(i)) {
            File file = (File) notesAdapter.getItem(checkedIndices.keyAt(i));
            copyFile(file, destination);
        }
    }
}