List of usage examples for android.widget AdapterView getAdapter
public abstract T getAdapter();
From source file:csms19.inapp.msg.customgallery.ImageFragment.java
private void setAdapter(Cursor imagecursor) { if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); mGalleryModelList.add(galleryModel); }//from w w w . j a v a 2 s .c o m mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false); mImageGridView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), "no media file available", Toast.LENGTH_SHORT).show(); } mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "image/*"); startActivity(intent); return true; } }); mImageGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false); if (size != 0) { Toast.makeText( getActivity(), "File size greater then" + " " + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " " + "mb", Toast.LENGTH_SHORT).show(); return; } if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) { if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText( getActivity(), "Max selected file " + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + "file", Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText( getActivity(), "Max selected file " + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + "file", Toast.LENGTH_SHORT).show(); return; } } } // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); MediaChooserConstants.SELECTED_MEDIA_COUNT++; } else { mSelectedItems.remove(galleryModel.url.toString().trim()); MediaChooserConstants.SELECTED_MEDIA_COUNT--; } if (mCallback != null) { mCallback.onImageSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:com.gh4a.fragment.RepositoryListFragment.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Gh4Application context = ((BaseSherlockFragmentActivity) getActivity()).getApplicationContext(); Repository repository = (Repository) adapterView.getAdapter().getItem(position); Intent intent = new Intent().setClass(getActivity(), RepositoryActivity.class); Bundle data = context.populateRepository(repository); intent.putExtra(Constants.DATA_BUNDLE, data); startActivity(intent);//www. j a v a2 s.c o m }
From source file:com.dazone.crewchat.libGallery.fragment.ImageFragment.java
private void setAdapter(Cursor imagecursor) { if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); mGalleryModelList.add(galleryModel); }/*from www . jav a 2s. com*/ mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false); mImageGridView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "image/*"); startActivity(intent); return true; } }); mImageGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false); if (size != 0) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.file_size_exeeded) + " " + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " " + getActivity().getResources().getString(R.string.mb), Toast.LENGTH_SHORT).show(); return; } if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) { if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.file), Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.files), Toast.LENGTH_SHORT).show(); return; } } } // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); MediaChooserConstants.SELECTED_MEDIA_COUNT++; } else { mSelectedItems.remove(galleryModel.url.toString().trim()); MediaChooserConstants.SELECTED_MEDIA_COUNT--; } if (mCallback != null) { mCallback.onImageSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:com.media.LuYinFragment.java
private void setAdapter(Cursor imagecursor) { if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Audio.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); mGalleryModelList.add(galleryModel); }/*from w w w. java2s . c o m*/ mImageAdapter = new AudioListViewAdapter(getActivity(), 0, mGalleryModelList, false); audioListView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } audioListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { AudioListViewAdapter adapter = (AudioListViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "audio/*"); startActivity(intent); return true; } }); audioListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter AudioListViewAdapter adapter = (AudioListViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false); if (size != 0) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.file_size_exeeded) + " " + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " " + getActivity().getResources().getString(R.string.mb), Toast.LENGTH_SHORT).show(); return; } if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) { if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.file), Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.files), Toast.LENGTH_SHORT).show(); return; } } } // inverse the status galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); MediaChooserConstants.SELECTED_MEDIA_COUNT++; } else { mSelectedItems.remove(galleryModel.url.toString().trim()); MediaChooserConstants.SELECTED_MEDIA_COUNT--; } if (mCallback != null) { mCallback.onLuYinSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:de.damdi.fitness.activity.create_workout.DialogWorkoutOverviewFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); final View v = inflater.inflate(R.layout.fragment_dialog_workout_overview, null); mEditTextWorkoutName = (EditText) v.findViewById(R.id.edittext_workout_name); mEditTextWorkoutName.setText(mWorkout.getName()); mListView = (ListView) v.findViewById(R.id.listview); mListView.setAdapter(new ArrayAdapter<FitnessExercise>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, mWorkout.getFitnessExercises())); mListView.setOnItemClickListener(new OnItemClickListener() { @Override/* w w w.j a v a 2 s.com*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final FitnessExercise fEx = (FitnessExercise) parent.getAdapter().getItem(position); new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.are_you_sure)) .setMessage( getString(R.string.really_remove_exercise).replace("EXERCISE_NAME", fEx.toString())) .setPositiveButton(getString(android.R.string.ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { removeExerciseFromWorkout(fEx); dialog.dismiss(); } }).setNegativeButton(getString(R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } }); return new AlertDialog.Builder(getActivity()).setTitle(mWorkout.getName()).setView(v).setCancelable(true) .setPositiveButton(getString(R.string.save_workout), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // check if name is empty final String workoutName = mEditTextWorkoutName.getText().toString(); if (workoutName.equals("") || workoutName.replaceAll(" ", "").equals("")) { Toast.makeText(getActivity(), getString(R.string.workout_name_cannot_be_empty), Toast.LENGTH_LONG).show(); return; } // check if file already exists if (fileAlreadyExists(workoutName)) { showOverrideDialog(); return; } saveWorkout(getActivity()); } }).setNeutralButton(getString(R.string.add_more_exercises), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { continueAddingExercises(); } }).setNegativeButton(getString(R.string.discard), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finishActivities(getActivity()); } }).create(); }
From source file:at.alladin.rmbt.android.map.RMBTMapFilterFragment.java
/** * *//*w ww .ja va2 s.c o m*/ @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { final SectionListAdapter sectionListAdapter = (SectionListAdapter) parent.getAdapter(); final Object item = sectionListAdapter.getItem(position); if (options.select((ServerOption) item) != null) { final List<ServerOption> newOptionList = new ArrayList<ServerOption>(); newOptionList.add((ServerOption) item); populateList(newOptionList, false); } else if (((ServerOption) item).getParent() != null) { populateList(options.getRootOptions(), true); } ((SectionListAdapter) parent.getAdapter()).notifyDataSetChanged(); ((RMBTMainActivity) getActivity()).updateMapFilter(null); }
From source file:com.achep.acdisplay.ui.fragments.dialogs.SetupPermissionsDialog.java
@NonNull @Override/*from ww w . jav a2s.c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); assert context != null; View view = new DialogBuilder(context).setTitle(R.string.permissions_dialog_title) .setView(R.layout.dialog_permissions).createSkeletonView(); // Make title more red TextView title = (TextView) view.findViewById(R.id.title); title.setTextColor(title.getCurrentTextColor() & 0xFFFF3333 | 0xFF << 16); ListView listView = (ListView) view.findViewById(R.id.list); mAdapter = new Adapter(context, new ArrayList<Item>()); listView.setAdapter(mAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = (Adapter) parent.getAdapter(); Item item = adapter.getItem(position); item.run(); } }); return new AlertDialog.Builder(context).setView(view).setNeutralButton(R.string.later, null).create(); }
From source file:com.example.de.taomi2.mediachooser.fragment.ImageFragment.java
private void setAdapter(Cursor imagecursor) { if (imagecursor.getCount() > 0) { mGalleryModelList = new ArrayList<MediaModel>(); for (int i = 0; i < imagecursor.getCount(); i++) { imagecursor.moveToPosition(i); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false); mGalleryModelList.add(galleryModel); }/*ww w .j a v a2s .com*/ mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false); mImageGridView.setAdapter(mImageAdapter); } else { Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available), Toast.LENGTH_SHORT).show(); } mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); File file = new File(galleryModel.url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "image/*"); startActivity(intent); return true; } }); mImageGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // update the mStatus of each category in the adapter GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter(); MediaModel galleryModel = (MediaModel) adapter.getItem(position); if (!galleryModel.status) { long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()), false); if (size != 0) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.file_size_exeeded) + " " + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " " + getActivity().getResources().getString(R.string.mb), Toast.LENGTH_SHORT).show(); return; } /* if((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)){ if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.file), Toast.LENGTH_SHORT).show(); return; } else { Toast.makeText(getActivity(), getActivity().getResources().getString(R.string.max_limit_file) + " " + MediaChooserConstants.SELECTED_MEDIA_COUNT + " " + getActivity().getResources().getString(R.string.files), Toast.LENGTH_SHORT).show(); return; } } */ } /* // inverse the status galleryModel.status = ! galleryModel.status; adapter.notifyDataSetChanged(); */ int i = 0; for (; i < adapter.getCount(); i++) { if (i != position) { adapter.getItem(i).status = false; } } galleryModel.status = !galleryModel.status; adapter.notifyDataSetChanged(); mSelectedItems.clear(); if (galleryModel.status) { mSelectedItems.add(galleryModel.url.toString()); //MediaChooserConstants.SELECTED_MEDIA_COUNT ++; } else { //mSelectedItems.remove(galleryModel.url.toString().trim()); //MediaChooserConstants.SELECTED_MEDIA_COUNT --; } if (mCallback != null) { mCallback.onImageSelected(mSelectedItems.size()); Intent intent = new Intent(); intent.putStringArrayListExtra("list", mSelectedItems); getActivity().setResult(Activity.RESULT_OK, intent); } } }); }
From source file:liqui.droid.activity.ContactListCached.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Cursor c = (Cursor) adapterView.getAdapter().getItem(position); Intent intent = new Intent().setClass(ContactListCached.this, MemberDetails.class); Uri uri = dbUri(DBProvider.MEMBER_CONTENT_URI.toString()).buildUpon() .appendPath(String.valueOf(c.getInt(c.getColumnIndex(DB.Member.COLUMN_ID)))).build(); intent.putExtra("sortOrder", mSortOrder); intent.putExtra("sortDir", mSortDir); intent.putExtra("filter", mFfilter); intent.putExtra(DBProvider.MEMBER_CONTENT_ITEM_TYPE, uri); Bundle extras = new Bundle(); extras.putString(Constants.Account.API_NAME, getAPIName()); extras.putString(Constants.Account.API_URL, getAPIUrl()); extras.putString(Constants.Account.MEMBER_ID, getMemberId()); extras.putString(Constants.Account.SESSION_KEY, getSessionKey()); intent.putExtras(extras);/*from w w w. j a v a 2s .co m*/ startActivity(intent); }
From source file:liqui.droid.activity.MemberListCached.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Cursor c = (Cursor) adapterView.getAdapter().getItem(position); Intent intent = new Intent().setClass(MemberListCached.this, MemberDetails.class); Uri uri = dbUri(DBProvider.MEMBER_CONTENT_URI.toString()).buildUpon() .appendPath(String.valueOf(c.getInt(c.getColumnIndex(DB.Member.COLUMN_ID)))).build(); intent.putExtra("sortOrder", mSortOrder); intent.putExtra("sortDir", mSortDir); intent.putExtra("filter", mFfilter); intent.putExtra(DBProvider.MEMBER_CONTENT_ITEM_TYPE, uri); Bundle extras = new Bundle(); extras.putString(Constants.Account.API_NAME, getAPIName()); extras.putString(Constants.Account.API_URL, getAPIUrl()); extras.putString(Constants.Account.MEMBER_ID, getMemberId()); extras.putString(Constants.Account.SESSION_KEY, getSessionKey()); intent.putExtras(extras);//from ww w . j a va2s . c o m startActivity(intent); }