Fork me
BeyondAR
Augmented Reality Framework for Android
 All Classes Functions Variables
com.beyondar.android.view.BeyondarViewAdapter Class Referenceabstract

Adapter to attach views to the BeyondarObject. More...

Collaboration diagram for com.beyondar.android.view.BeyondarViewAdapter:

Public Member Functions

 BeyondarViewAdapter (Context context)
 
abstract View getView (BeyondarObject beyondarObject, View recycledView, ViewGroup parent)
 Override this method to create your own views from the BeyondarObject. More...
 

Protected Member Functions

Context getContext ()
 Get Context. More...
 
void setPosition (Point2 position)
 Set the screen position of the view. More...
 

Detailed Description

Adapter to attach views to the BeyondarObject.

This is an example of how to use the adapter:


private class CustomBeyondarViewAdapter extends BeyondarViewAdapter {
        LayoutInflater inflater;
        public CustomBeyondarViewAdapter(Context context) {
            super(context);
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
        
        public View getView(BeyondarObject beyondarObject, View recycledView, ViewGroup parent) {
            if (!showViewOn.contains(beyondarObject)) {
                return null;
            }
            if (recycledView == null) {
                recycledView = inflater.inflate(R.layout.beyondar_object_view, null);
            }
            TextView textView = (TextView) recycledView.findViewById(R.id.titleTextView);
            textView.setText(beyondarObject.getName());
            Button button = (Button) recycledView.findViewById(R.id.button);
            button.setOnClickListener(AttachViewToGeoObjectActivity.this);
         // Once the view is ready we specify the position
            setPosition(beyondarObject.getScreenPositionTopRight());
            return recycledView;
        }
    }

Then when the adapter is ready we can set it in the BeyondarFragment:

CustomBeyondarViewAdapter customBeyondarViewAdapter = new CustomBeyondarViewAdapter(this); 
mBeyondarFragment.setBeyondarViewAdapter(customBeyondarViewAdapter);
 

Member Function Documentation

Context com.beyondar.android.view.BeyondarViewAdapter.getContext ( )
protected

Get Context.

Returns
abstract View com.beyondar.android.view.BeyondarViewAdapter.getView ( BeyondarObject  beyondarObject,
View  recycledView,
ViewGroup  parent 
)
abstract

Override this method to create your own views from the BeyondarObject.

The usage of this adapter is very similar to the ListAdapter.


private class CustomBeyondarViewAdapter extends BeyondarViewAdapter {
        LayoutInflater inflater;
        public CustomBeyondarViewAdapter(Context context) {
            super(context);
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
        
        public View getView(BeyondarObject beyondarObject, View recycledView, ViewGroup parent) {
            if (!showViewOn.contains(beyondarObject)) {
                return null;
            }
            if (recycledView == null) {
                recycledView = inflater.inflate(R.layout.beyondar_object_view, null);
            }
            TextView textView = (TextView) recycledView.findViewById(R.id.titleTextView);
            textView.setText(beyondarObject.getName());
            Button button = (Button) recycledView.findViewById(R.id.button);
            button.setOnClickListener(AttachViewToGeoObjectActivity.this);
         // Once the view is ready we specify the position
            setPosition(beyondarObject.getScreenPositionTopRight());
            return recycledView;
        }
    }

Parameters
beyondarObject
recycledView
parent
Returns
void com.beyondar.android.view.BeyondarViewAdapter.setPosition ( Point2  position)
protected

Set the screen position of the view.

When the view is created use this method to specify the position on the screen.

Parameters
position

The documentation for this class was generated from the following file: