Example usage for android.widget AdapterView getAdapter

List of usage examples for android.widget AdapterView getAdapter

Introduction

In this page you can find the example usage for android.widget AdapterView getAdapter.

Prototype

public abstract T getAdapter();

Source Link

Document

Returns the adapter currently associated with this widget.

Usage

From source file:com.esri.arcgisruntime.sample.transformsbysuitability.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the list of transformations
    final ListView tableList = findViewById(R.id.transforms_list);
    mTransformAdapter = new DatumTransformationAdapter(this, mTransformValues);
    tableList.setAdapter(mTransformAdapter);
    tableList.setOnItemClickListener((AdapterView<?> adapterView, View view, int i, long l) -> {

        view.setSelected(true);//  w  w  w  .  j  a  v  a 2s .c o  m

        // Get the datum transformation selected by the user
        DatumTransformation selectedTransform = (DatumTransformation) adapterView.getAdapter().getItem(i);

        Point projectedGeometry;
        try {
            // Use the selected transformation to reproject the Geometry
            projectedGeometry = (Point) GeometryEngine.project(mOriginalGeometry,
                    mMapView.getSpatialReference(), selectedTransform);

        } catch (ArcGISRuntimeException agsEx) {
            // Catch errors thrown from project method. If a transformation is missing grid files, then it cannot be
            // successfully used to project a geometry, and will throw an exception.
            Snackbar.make(tableList,
                    agsEx.getMessage() + "\n" + getResources().getString(R.string.transform_missing_files),
                    Snackbar.LENGTH_LONG).show();
            removeProjectedGeometryGraphic();
            return;
        }

        // Add projected geometry as a second graphic - use a cross symbol which ensures the default transformation
        // graphic remains visible beneath this graphic.
        if (mProjectedGraphic == null) {
            mProjectedGraphic = addGraphic(projectedGeometry, Color.argb(255, 255, 0, 0),
                    SimpleMarkerSymbol.Style.CROSS);

        } else {
            // If graphic already set, just update the geometry
            mProjectedGraphic.setGeometry(projectedGeometry);
        }
    });

    // If the CheckBox is not checked (default), transformations should be ordered by suitability for the whole
    // spatial reference. If checked, then transformations will be ordered by suitability for the map extent.
    CheckBox checkBox = findViewById(R.id.order_by_check_box);
    checkBox.setOnCheckedChangeListener((CompoundButton compoundButton, boolean newCheckState) -> {
        // Store the new check state in a member variable and update the list of transformations.
        mUseExtentForSuitability = newCheckState;
        setupTransformsList();
    });

    // Get MapView from layout and set a map into this view
    mMapView = findViewById(R.id.mapView);
    mArcGISMap = new ArcGISMap(Basemap.createLightGrayCanvas());
    mMapView.setMap(mArcGISMap);

    // Create a geometry located in the Greenwich observatory courtyard in London, UK, the location of the
    // Greenwich prime meridian. This will be projected using the selected transformation.
    mOriginalGeometry = new Point(538985.355, 177329.516, SpatialReference.create(27700));

    // Add a Graphic to show the original geometry location, projected using the default transformation
    addGraphic(mOriginalGeometry, Color.argb(255, 0, 0, 255), SimpleMarkerSymbol.Style.SQUARE);

    mArcGISMap.addDoneLoadingListener(() -> {
        if (mArcGISMap.getLoadStatus() == LoadStatus.LOADED) {
            if (mTransformValues.size() == 0) {
                // Zoom to the initial default geometry at a suitable scale
                Viewpoint vp = new Viewpoint(mOriginalGeometry, 5000);
                mMapView.setViewpointAsync(vp, 2);

                // Once the map has loaded (which means the 'from' spatial reference is set), trigger populating the list
                // of transformations. Start by checking app has permissions to access local file storage, where projection
                // engine files for grid-based transformations are stored.
                checkPermissions();
            }
        }
    });
}

From source file:com.example.android.apprestrictionenforcer.AppRestrictionEnforcerFragment.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.rank: {
        saveRank(getActivity(), (String) parent.getAdapter().getItem(position));
        break;/* w w  w  .  j  a v a  2s .  c o m*/
    }
    }
}

From source file:com.gh4a.TimelineActivity.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    Event event = (Event) adapterView.getAdapter().getItem(position);
    Gh4Application context = getApplicationContext();

    //if payload is a base class, return void.  Think that it is an old event which not supported
    //by API v3.//from  w  w  w .j a v a2s . com
    if (event.getPayload().getClass().getSimpleName().equals("EventPayload")) {
        return;
    }

    String eventType = event.getType();
    EventRepository eventRepo = event.getRepo();
    String[] repoNamePart = eventRepo.getName().split("/");
    String repoOwner = "";
    String repoName = "";
    if (repoNamePart.length == 2) {
        repoOwner = repoNamePart[0];
        repoName = repoNamePart[1];
    }
    String repoUrl = eventRepo.getUrl();

    /** PushEvent */
    if (Event.TYPE_PUSH.equals(eventType)) {

        if (eventRepo != null) {
            PushPayload payload = (PushPayload) event.getPayload();

            List<Commit> commits = payload.getCommits();
            // if commit > 1, then show compare activity

            if (commits != null && commits.size() > 1) {
                Intent intent = new Intent().setClass(context, CompareActivity.class);
                for (Commit commit : commits) {
                    String[] commitInfo = new String[4];
                    commitInfo[0] = commit.getSha();
                    commitInfo[1] = CommitUtils.getAuthorEmail(commit);
                    commitInfo[2] = commit.getMessage();
                    commitInfo[3] = CommitUtils.getAuthorName(commit);
                    intent.putExtra("commit" + commit.getSha(), commitInfo);
                }

                intent.putExtra(Constants.Repository.REPO_OWNER, repoOwner);
                intent.putExtra(Constants.Repository.REPO_NAME, repoName);
                intent.putExtra(Constants.Repository.HEAD, payload.getHead());
                intent.putExtra(Constants.Repository.BASE, payload.getRef());
                startActivity(intent);
            }
            // only 1 commit, then show the commit details
            else {
                context.openCommitInfoActivity(this, repoOwner, repoName, payload.getCommits().get(0).getSha(),
                        0);
            }
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** IssueEvent */
    else if (Event.TYPE_ISSUES.equals(eventType)) {
        if (eventRepo != null) {
            IssuesPayload payload = (IssuesPayload) event.getPayload();
            context.openIssueActivity(this, repoOwner, repoName, payload.getIssue().getNumber());
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** WatchEvent */
    else if (Event.TYPE_WATCH.equals(eventType)) {
        if (eventRepo != null) {
            context.openRepositoryInfoActivity(this, repoOwner, repoName, 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** CreateEvent */
    else if (Event.TYPE_CREATE.equals(eventType)) {
        if (eventRepo != null) {
            context.openRepositoryInfoActivity(this, repoOwner, repoName, 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** PullRequestEvent */
    else if (Event.TYPE_PULL_REQUEST.equals(eventType)) {
        if (eventRepo != null) {
            PullRequestPayload payload = (PullRequestPayload) event.getPayload();
            int pullRequestNumber = payload.getNumber();
            context.openPullRequestActivity(this, repoOwner, repoName, pullRequestNumber);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** FollowEvent */
    else if (Event.TYPE_FOLLOW.equals(eventType)) {
        FollowPayload payload = (FollowPayload) event.getPayload();
        if (payload.getTarget() != null) {
            context.openUserInfoActivity(this, payload.getTarget().getLogin(), null);
        }
    }

    /** CommitCommentEvent */
    else if (Event.TYPE_COMMIT_COMMENT.equals(eventType)) {
        if (eventRepo != null) {
            CommitCommentPayload payload = (CommitCommentPayload) event.getPayload();
            context.openCommitInfoActivity(this, repoOwner, repoName, payload.getComment().getCommitId(), 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** DeleteEvent */
    else if (Event.TYPE_DELETE.equals(eventType)) {
        if (eventRepo != null) {
            context.openRepositoryInfoActivity(this, repoOwner, repoName, 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** DownloadEvent */
    else if (Event.TYPE_DOWNLOAD.equals(eventType)) {
        if (eventRepo != null) {
            DownloadPayload payload = (DownloadPayload) event.getPayload();
            context.openBrowser(this, payload.getDownload().getHtmlUrl());
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** ForkEvent */
    else if (Event.TYPE_FORK.equals(eventType)) {
        ForkPayload payload = (ForkPayload) event.getPayload();
        Repository forkee = payload.getForkee();
        if (forkee != null) {
            context.openRepositoryInfoActivity(this, forkee);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** ForkEvent */
    else if (Event.TYPE_FORK_APPLY.equals(eventType)) {
        if (eventRepo != null) {
            ForkApplyPayload payload = (ForkApplyPayload) event.getPayload();
            context.openRepositoryInfoActivity(this, repoOwner, repoName, 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** GollumEvent */
    else if (Event.TYPE_GOLLUM.equals(eventType)) {
        Intent intent = new Intent().setClass(this, WikiListActivity.class);
        intent.putExtra(Constants.Repository.REPO_OWNER, repoOwner);
        intent.putExtra(Constants.Repository.REPO_NAME, repoName);
        startActivity(intent);
    }

    /** PublicEvent */
    else if (Event.TYPE_PUBLIC.equals(eventType)) {
        if (eventRepo != null) {
            context.openRepositoryInfoActivity(this, repoOwner, repoName, 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** MemberEvent */
    else if (Event.TYPE_MEMBER.equals(eventType)) {
        if (eventRepo != null) {
            MemberPayload payload = (MemberPayload) event.getPayload();
            context.openRepositoryInfoActivity(this, repoOwner, repoName, 0);
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** Gist Event **/
    else if (Event.TYPE_GIST.equals(eventType)) {
        GistPayload payload = (GistPayload) event.getPayload();
        context.openGistActivity(this, payload.getGist().getUser().getLogin(), payload.getGist().getId(), 0);
    }

    /** IssueCommentEvent */
    else if (Event.TYPE_ISSUE_COMMENT.equals(eventType)) {
        if (eventRepo != null) {
            IssueCommentPayload payload = (IssueCommentPayload) event.getPayload();
            String type = payload.getIssue().getPullRequest().getDiffUrl() != null ? "pullrequest" : "issue";
            if ("pullrequest".equals(type)) {
                context.openPullRequestActivity(this, repoOwner, repoName, payload.getIssue().getNumber());
            } else {
                context.openIssueActivity(this, repoOwner, repoName, payload.getIssue().getNumber(),
                        payload.getIssue().getState());
            }
        } else {
            context.notFoundMessage(this, R.plurals.repository);
        }
    }

    /** PullRequestReviewComment */
    else if (Event.TYPE_PULL_REQUEST_REVIEW_COMMENT.equals(eventType)) {
        PullRequestReviewCommentPayload payload = (PullRequestReviewCommentPayload) event.getPayload();
        context.openCommitInfoActivity(this, repoOwner, repoName, payload.getComment().getCommitId(), 0);
    }
}

From source file:it.geosolutions.android.map.geostore.fragment.GeoStoreResourceListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);

    //init progress bar and loading text
    startLoadingGUI();/* w ww . j  a v a  2s .com*/

    //set the click listener for the items
    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(view.getContext(), GeoStoreResourceDetailActivity.class);
            i.putExtras(getActivity().getIntent().getExtras());
            Resource item = (Resource) parent.getAdapter().getItem(position);
            i.putExtra(GeoStoreResourceDetailActivity.PARAMS.RESOURCE, item);
            String action = getActivity().getIntent().getAction();
            i.setAction(action);
            getActivity().startActivityForResult(i, GeoStoreResourcesActivity.GET_MAP_CONFIG);

        }
    });
    //associate scroll listener to implement infinite scroll
    getListView().setOnScrollListener(this);

}

From source file:com.dycode.jepretstory.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);
            //int thumbnailColumnIndex    = imagecursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
            int idColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media._ID);
            //int idColumnIndex          = imagecursor.getColumnIndex(MediaStore.Images.Thumbnails.IMAGE_ID);
            int bucketColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID);
            int orientColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.ImageColumns.ORIENTATION);

            String imgUrl = imagecursor.getString(dataColumnIndex).toString();
            //            boolean selected = false;
            //            if (mSelectedModels != null && mSelectedModels.size() > 0) {
            //               for(String currImgUrl: mSelectedItems) {
            //                  if (currImgUrl.equalsIgnoreCase(imgUrl)) {
            //                     selected = true;
            //                     break;
            //                  }
            //               }
            //            }

            String id = imagecursor.getString(idColumnIndex);
            String thumbId = "";//imagecursor.getString(idColumnIndex);
            String bucketId = imagecursor.getString(bucketColumnIndex);
            String thumbUrl = "";//imagecursor.getString(thumbnailColumnIndex).toString();
            int orientation = imagecursor.getInt(orientColumnIndex);

            MediaModel galleryModel = new MediaModel(bucketId, id, imgUrl, thumbId, thumbUrl, false,
                    MediaType.IMAGE);/*from w  w  w. j  a v  a2 s . c  o m*/
            if (mSelectedModels != null && mSelectedModels.size() > 0) {
                galleryModel.status = mSelectedModels.contains(galleryModel);
            }
            galleryModel.orientation = orientation;

            //processThumbnailImage(id, galleryModel, getActivity());

            mGalleryModelList.add(galleryModel);
        }

        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 == 1) {
                    //remove all first
                    if (mSelectedModels.size() >= 1) {

                        MediaModel selModel = (MediaModel) mSelectedModels.get(0);
                        selModel.status = false;

                        mSelectedModels.clear();
                        MediaChooserConstants.SELECTED_MEDIA_COUNT--;
                    }
                }

                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());
                mSelectedModels.add(galleryModel);
                MediaChooserConstants.SELECTED_MEDIA_COUNT++;

            } else {
                //mSelectedItems.remove(galleryModel.url.toString().trim());
                mSelectedModels.remove(galleryModel);
                MediaChooserConstants.SELECTED_MEDIA_COUNT--;
            }

            if (mCallback != null) {

                mCallback.onImageSelectedCount(mSelectedModels.size());

                if (galleryModel.status) {
                    mCallback.onImageSelected(galleryModel);
                } else {
                    mCallback.onImageUnselected(galleryModel);
                }

                Intent intent = new Intent();
                //intent.putStringArrayListExtra("list", mSelectedItems);
                intent.putParcelableArrayListExtra("selectedImages", mSelectedModels);
                getActivity().setResult(Activity.RESULT_OK, intent);
            }

        }
    });
}

From source file:com.dycode.jepretstory.mediachooser.fragment.VideoFragment.java

private void setAdapter() {
    int count = mCursor.getCount();

    if (count > 0) {
        mDataColumnIndex = mCursor.getColumnIndex(MEDIA_DATA);
        int mIdColumnIndex = mCursor.getColumnIndex(MediaStore.Video.Media._ID);
        int mBucketColumnIndex = mCursor.getColumnIndex(MediaStore.Video.Media.BUCKET_ID);
        int resColumnIndex = mCursor.getColumnIndex(MediaStore.Video.Media.RESOLUTION);
        int durColumnIndex = mCursor.getColumnIndex(MediaStore.Video.Media.DURATION);

        //move position to first element
        mCursor.moveToFirst();//from  w  w  w .  j  a  v  a2s  .  c o m

        mGalleryModelList = new ArrayList<MediaModel>();
        for (int i = 0; i < count; i++) {
            mCursor.moveToPosition(i);
            String url = mCursor.getString(mDataColumnIndex);
            String id = mCursor.getString(mIdColumnIndex);
            String bucketId = mCursor.getString(mBucketColumnIndex);

            //mGalleryModelList.add(new MediaModel(url, false, MediaMode.VIDEO));

            //            boolean selected = false;
            //            if (mSelectedItems != null && mSelectedItems.size() > 0) {
            //               for(String currVidUrl: mSelectedItems) {
            //                  if (currVidUrl.equalsIgnoreCase(url)) {
            //                     selected = true;
            //                     break;
            //                  }
            //               }
            //            }

            MediaModel galleryModel = new MediaModel(bucketId, id, url, false, MediaType.VIDEO);
            if (mSelectedModels != null && mSelectedModels.size() > 0) {
                galleryModel.status = mSelectedModels.contains(galleryModel);
            }

            galleryModel.resolution = mCursor.getString(resColumnIndex);
            galleryModel.videoDuration = mCursor.getInt(durColumnIndex);

            mGalleryModelList.add(galleryModel);
        }

        mVideoAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, true);
        mVideoAdapter.videoFragment = this;
        mVideoGridView.setAdapter(mVideoAdapter);
        mVideoGridView.setOnScrollListener(this);

    } else {
        Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available),
                Toast.LENGTH_SHORT).show();

    }

    mVideoGridView.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), "video/*");
            startActivity(intent);
            return false;
        }
    });

    mVideoGridView.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()),
                        true);
                if (size != 0) {
                    Toast.makeText(getActivity(),
                            getActivity().getResources().getString(R.string.file_size_exeeded) + "  "
                                    + MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB + " "
                                    + getActivity().getResources().getString(R.string.mb),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                if (MediaChooserConstants.ENFORCE_VIDEO_DURATION_LIMIT && galleryModel
                        .getVideoDurationInSeconds() > MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND) {
                    String fmt = getActivity().getResources().getString(R.string.video_duration_limit_exeeded);
                    String msg = String.format(fmt, MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND);
                    Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show();
                    return;
                }

                if (MediaChooserConstants.MAX_MEDIA_LIMIT == 1) {
                    //remove all first
                    if (mSelectedModels.size() >= 1) {

                        MediaModel selModel = (MediaModel) mSelectedModels.get(0);
                        selModel.status = false;

                        mSelectedModels.clear();
                        MediaChooserConstants.SELECTED_MEDIA_COUNT--;
                    }
                }

                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) {
                mSelectedModels.add(galleryModel);

                MediaChooserConstants.SELECTED_MEDIA_COUNT++;

            } else {
                mSelectedModels.remove(galleryModel);

                MediaChooserConstants.SELECTED_MEDIA_COUNT--;
            }

            if (mCallback != null) {

                mCallback.onVideoSelectedCount(mSelectedModels.size());

                if (galleryModel.status) {
                    mCallback.onVideoSelected(galleryModel);
                } else {
                    mCallback.onVideoUnselected(galleryModel);
                }

                Intent intent = new Intent();
                intent.putParcelableArrayListExtra("selectedVideos", mSelectedModels);
                getActivity().setResult(Activity.RESULT_OK, intent);
            }

        }
    });

}

From source file:com.ymt.demo1.plates.exportConsult.ExportConsultMainActivity.java

/**
 * ?//www.  j  av a  2 s. c  o  m
 */
protected void initOnDutyExpertView() {
    GridView amDutyView = (GridView) findViewById(R.id.am_expert_gridView);
    GridView pmDutyView = (GridView) findViewById(R.id.pm_expert_gridView);
    amAdapter = new DutyExpertAdapter(this);
    pmAdapter = new DutyExpertAdapter(this);
    amAdapter.setExpertList(onDutyAmExperts);
    pmAdapter.setExpertList(onDutyPmExperts);
    amDutyView.setAdapter(amAdapter);
    pmDutyView.setAdapter(pmAdapter);

    AdapterView.OnItemClickListener itemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            OnDutyExpert expert = (OnDutyExpert) parent.getAdapter().getItem(position);
            Intent intent1 = new Intent(ExportConsultMainActivity.this, ExpertInfoActivity.class);
            intent1.putExtra("id", Integer.valueOf(expert.getFkUserId()));
            startActivity(intent1);
        }
    };
    amDutyView.setOnItemClickListener(itemClickListener);
    pmDutyView.setOnItemClickListener(itemClickListener);
}

From source file:org.onebusaway.android.ui.TripPlanFragment.java

private void setUpAutocomplete(AutoCompleteTextView tv, final int use) {
    ObaRegion region = Application.get().getCurrentRegion();

    // Use Google widget if available
    if (GoogleApiAvailability.getInstance()
            .isGooglePlayServicesAvailable(getContext()) == ConnectionResult.SUCCESS) {
        tv.setFocusable(false);/*from  w w w  .j a v  a2  s .c  om*/
        tv.setOnClickListener(new ProprietaryMapHelpV2.StartPlacesAutocompleteOnClick(use, this, region));
        return;
    }

    // else, set up autocomplete with Android geocoder

    tv.setAdapter(new PlacesAutoCompleteAdapter(getContext(), android.R.layout.simple_list_item_1, region));
    tv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CustomAddress addr = (CustomAddress) parent.getAdapter().getItem(position);

            if (use == USE_FROM_ADDRESS) {
                mFromAddress = addr;
                mBuilder.setFrom(mFromAddress);
            } else if (use == USE_TO_ADDRESS) {
                mToAddress = addr;
                mBuilder.setTo(mToAddress);
            }

            checkRequestAndSubmit();
        }
    });
}

From source file:com.easemob.chatuidemo.activity.GroupPickContactsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_pick_contacts);
    setActionbarTitle(R.string.title_name_emchat_contact);

    listView = (StickyListHeadersListView) findViewById(R.id.list);
    ((Sidebar) findViewById(R.id.sidebar)).setListView(listView);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override//from w ww.j av a2 s. c o m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            User user = (User) parent.getAdapter().getItem(position);
            if (!exitingMembers.contains(user.getUsername())) {
                CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
                checkBox.toggle();
            }

        }
    });

    initSearch();
    initHeader();

    setRightText(R.string.emchat_contact_title_right, new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final List<String> members = contactAdapter.getToBeAddMembers();
            if (exitingMembers.size() > 0) {
                save(members.toArray(new String[members.size()]));
            } else if (members.size() > 0) {
                createGroup(members);
            } else {
                ToastUtil.showToast(mContext, R.string.group_member_empty);
            }
        }
    });

    departments = EMChatResManager.getDepartments();
    roles = EMChatResManager.getRoles();
    contacts = EMChatResManager.getContacts();
    Map<Long, Department> departmentMap = new HashMap<>(departments.size());
    for (Department department : departments) {
        departmentMap.put(department.getId(), department);
    }
    Map<Integer, Role> roleMap = new HashMap<>(roles.size());
    for (Role role : roles) {
        roleMap.put(role.getId(), role);
    }

    String groupId = getIntent().getStringExtra("groupId");
    if (groupId == null) {// 
        isCreatingNewGroup = true;
    } else {
        // ??
        EMGroup group = EMGroupManager.getInstance().getGroup(groupId);
        exitingMembers = group.getMembers();
    }
    if (exitingMembers == null)
        exitingMembers = new ArrayList<>();
    for (int ii = 0; ii < contacts.size(); ii++) {
        if (contacts.get(ii).getUsername().equals(EMChatManager.getInstance().getCurrentUser())
                || exitingMembers.contains(contacts.get(ii).getUsername())) {
            contacts.remove(ii);
            ii--;
        } else {
            contacts.get(ii).setTag(departmentMap, roleMap);
        }
    }

    initContactList(contacts);

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout);

    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            MainActivity.initContactsFromServer(mContext, new MainActivity.OnUpdatingListener() {
                @Override
                public void onStart() {

                }

                @Override
                public void onComplete() {
                    SPHelper.setContactLastUpdateTime(mContext, Calendar.getInstance().getTimeInMillis());
                    swipeRefreshLayout.setRefreshing(false);
                }
            });
        }
    });
}

From source file:com.audiokernel.euphonyrmt.SearchActivity.java

@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
    final Object selectedItem = parent.getAdapter().getItem(position);
    if (selectedItem instanceof Music) {
        add((Music) selectedItem, false, false);
    } else if (selectedItem instanceof Artist) {
        final Intent intent = new Intent(this, SimpleLibraryActivity.class);
        intent.putExtra("artist", (Parcelable) selectedItem);
        startActivityForResult(intent, -1);
    } else if (selectedItem instanceof Album) {
        final Intent intent = new Intent(this, SimpleLibraryActivity.class);
        intent.putExtra("album", (Parcelable) selectedItem);
        startActivityForResult(intent, -1);
    }/*w w w.j a  v  a2 s.c o  m*/
}