Example usage for android.widget GridView getAdapter

List of usage examples for android.widget GridView getAdapter

Introduction

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

Prototype

@Override
    public ListAdapter getAdapter() 

Source Link

Usage

From source file:com.activiti.android.app.fragments.content.ContentsFragment.java

@Override
public void onListItemClick(GridView l, View v, int position, long id) {
    RelatedContentRepresentation rep = (RelatedContentRepresentation) l.getAdapter().getItem(position);

    ContentTransferManager.downloadTransfer(getActivity(), rep.getName(), rep.getMimeType(),
            Long.toString(rep.getId()));

    waitingDialog = new MaterialDialog.Builder(getActivity()).title(R.string.please_wait)
            .cancelListener(new DialogInterface.OnCancelListener() {
                @Override/*from   w  w w  .  j ava2  s .  c o m*/
                public void onCancel(DialogInterface dialog) {
                    dismiss();
                }
            }).content(R.string.content_message_content_pending).progress(true, 0).show();
}

From source file:org.bwgz.quotation.fragment.AuthorFragment.java

private void updateQuotations(Cursor cursor) {
    Log.d(TAG, String.format("updateQuotations - cursor: %s (%d)", cursor, cursor.getCount()));

    if (cursor.getCount() != 0) {
        GridView gridView = viewHolder.quotation_grid;
        if (gridView.getAdapter() instanceof QuotationPicksCursorAdapter) {
            QuotationPicksCursorAdapter adapter = (QuotationPicksCursorAdapter) gridView.getAdapter();
            adapter.swapCursor(cursor);/*from ww w.  ja  va 2s  .co  m*/
        } else {
            QuotationPicksCursorAdapter adapter = new QuotationPicksCursorAdapter(getView().getContext(),
                    cursor, R.layout.author_quotation_pick_view, getImageLoader());
            gridView.setAdapter(adapter);
        }
    }
}

From source file:org.libreoffice.impressremote.fragment.slides.SlidesGridFragment.java

private void refreshSlidePreview(int aSlideIndex) {
    GridView aSlidesGrid = getSlidesGrid();
    View aSlideView = (null == aSlidesGrid) ? null : aSlidesGrid.getChildAt(aSlideIndex);

    if (aSlideView == null) {
        return;//from   www. jav  a 2 s  .c  om
    }

    aSlidesGrid.getAdapter().getView(aSlideIndex, aSlideView, aSlidesGrid);
}

From source file:it.geosolutions.geocollect.android.core.form.FormPageFragment.java

/**
 * Handle the results of the CameraAction
 *//*  w  ww .j a va2 s  .c  om*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "onActivityResult(): " + requestCode);
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == CameraAction.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == Activity.RESULT_OK) {

        String originIDString = MissionUtils.getMissionGCID(this.mission);
        if (this.page.fields != null && originIDString != null && !originIDString.isEmpty()) {

            for (Field f : page.fields) {
                if (f == null || f.xtype != XType.photo)
                    continue;

                // TODO: use a non-string tag
                GridView grid = (GridView) this.mFormView.findViewWithTag("__photo__");

                if (grid != null && ImageLoader.getInstance().isInited()) {

                    //((UILImageAdapter)grid.getAdapter()).setImageUrls(FormUtils.getPhotoUriStrings(this.mission.getOrigin().id));
                    ((UILImageAdapter) grid.getAdapter()).notifyDataSetChanged();
                }
                break;
            }

        }
    }

}

From source file:cx.ring.fragments.CallListFragment.java

public void setGridViewHeight(GridView gridView, LinearLayout llMain) {
    ListAdapter listAdapter = gridView.getAdapter();
    if (listAdapter == null) {
        return;/* w  w  w.  j a v  a2 s .c o m*/
    }

    int totalHeight = 0;
    int firstHeight = 0;
    int desiredWidth = View.MeasureSpec.makeMeasureSpec(gridView.getWidth(), View.MeasureSpec.AT_MOST);

    int rows = (listAdapter.getCount() + gridView.getNumColumns() - 1) / gridView.getNumColumns();

    for (int i = 0; i < rows; i++) {
        if (i == 0) {
            View listItem = listAdapter.getView(i, null, gridView);
            listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
            firstHeight = listItem.getMeasuredHeight();
        }
        totalHeight += firstHeight;
    }

    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llMain.getLayoutParams();

    params.height = (int) (totalHeight
            + (getResources().getDimension(R.dimen.contact_vertical_spacing) * (rows - 1)
                    + llMain.getPaddingBottom() + llMain.getPaddingTop()));
    llMain.setLayoutParams(params);
    mHeader.requestLayout();
}

From source file:com.activiti.android.app.fragments.app.AppInstancesFragment.java

@Override
public void onListItemClick(GridView l, View v, int position, long id) {
    Cursor cursor = (Cursor) l.getItemAtPosition(position);
    adapter.notifyDataSetChanged();//w  ww .  ja  va2 s.  c  o m

    RuntimeAppInstance item = RuntimeAppInstanceManager.getInstance(getActivity()).getByProviderId(id);
    boolean back = true;
    if (drawerId != null) {
        // Analytics
        AnalyticsHelper.reportOperationEvent(getActivity(), AnalyticsManager.CATEGORY_SESSION,
                AnalyticsManager.ACTION_SWITCH, AnalyticsManager.LABEL_APPS, 1, false);

        ((AppInstanceCursorAdapter) l.getAdapter()).setSelected(item.getId());
        ((AppInstanceCursorAdapter) l.getAdapter()).notifyDataSetInvalidated();

        // Flag last used Application
        InternalAppPreferences.savePref(getActivity(), getAccount().getId(),
                InternalAppPreferences.PREF_LAST_APP_USED, item.getId());
        InternalAppPreferences.savePref(getActivity(), getAccount().getId(),
                InternalAppPreferences.PREF_LAST_APP_NAME, item.getName());

        // Clean Right Menu.
        resetRightMenu();

        ((MainActivity) getActivity()).hideSlideMenu();
        back = false;
        getActivity().getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    }

    TasksFragment.with((MainActivity) v.getContext()).appName(item.getName()).appId(item.getId()).back(back)
            .display();
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Display a grid of all installed apps + virtual apps. Allow user to launch
 * apps.//  www.  j a v  a  2 s. c o m
 * 
 * @param context
 * @param applications
 */
public static void displayAllApps(final Launcher context, final ArrayList<ApplicationInfo> applications) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.apps_grid);

    final GridView gridView = (GridView) dialog.findViewById(R.id.grid);
    gridView.setAdapter(new AllItemAdapter(context, getApplications(context, applications, false)));
    gridView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ItemInfo itemInfo = (ItemInfo) parent.getAdapter().getItem(position);
            itemInfo.invoke(context);
            context.showCover(false);
            dialog.dismiss();
            if (itemInfo instanceof ApplicationInfo) {
                ApplicationInfo applicationInfo = (ApplicationInfo) itemInfo;
                RecentAppsTable.persistRecentApp(context, applicationInfo);
            }
        }

    });
    gridView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> gridView, View view, int pos, long arg3) {
            ItemInfo itemInfo = (ItemInfo) gridView.getAdapter().getItem(pos);
            if (itemInfo instanceof ApplicationInfo) {
                Uri packageURI = Uri.parse("package:" + itemInfo.getIntent().getComponent().getPackageName());
                Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
                context.startActivity(uninstallIntent);
                context.showCover(false);
                dialog.dismiss();
                Analytics.logEvent(Analytics.UNINSTALL_APP);
            }

            return false;
        }

    });
    gridView.setDrawingCacheEnabled(true);
    gridView.setOnKeyListener(onKeyListener);
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
    Analytics.logEvent(Analytics.DIALOG_ALL_APPS);
}