Search in sources :

Example 26 with MultiObjectAdapter

use of com.abewy.android.apps.klyph.adapter.MultiObjectAdapter in project Klyph by jonathangerbaud.

the class GalleryFragment method setCursor.

public void setCursor(Cursor cursor) {
    if (cursorLoaded == false) {
        MultiObjectAdapter adapter = new MultiObjectAdapter(getListView()) {

            @Override
            protected TypeAdapter<GraphObject> getAdapter(GraphObject object, int layoutType) {
                TypeAdapter<GraphObject> adapter = BaseAdapterSelector.getAdapter(object, layoutType);
                if (adapter != null)
                    return adapter;
                if (object instanceof Picture)
                    return new GalleryAdapter();
                if (object instanceof CameraObject)
                    return new CameraObjectAdapter();
                return null;
            }
        };
        if (cursor != null && cursor.isClosed() == false) {
            int n = cursor.getCount();
            int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            for (int i = 0; i < n; i++) {
                cursor.moveToPosition(i);
                imageUris.add(cursor.getString(columnIndex));
                adapter.add(new Picture(cursor.getString(columnIndex)));
            }
            if (showCamera && hasCamera) {
                adapter.insert(new CameraObject(), 0);
            }
            getGridView().setAdapter(adapter);
            getGridView().setVisibility(View.VISIBLE);
            n = adapter.getCount();
            int nSelected = 0;
            for (int i = 0; i < n; i++) {
                if (adapter.getItem(i) instanceof Picture) {
                    Picture image = (Picture) adapter.getItem(i);
                    // Log.d("GalleryFragment", "uri = " + image.getUri());
                    for (String uri : initUris) {
                        if (image.getUri().equals(uri)) {
                            getGridView().setItemChecked(i, true);
                            nSelected++;
                            break;
                        }
                    }
                }
            }
            adapter.notifyDataSetChanged();
            if (nSelected > 0) {
                if (actionMode == null)
                    actionMode = getActivity().startActionMode(mActionModeCallback);
                refreshActionModeTitle();
            }
            cursor.close();
        } else {
            if (showCamera && hasCamera) {
                adapter.insert(new CameraObject(), 0);
            }
            getGridView().setAdapter(adapter);
        }
        cursorLoaded = true;
    }
    loadingView.setVisibility(View.GONE);
    getGridView().setVisibility(View.VISIBLE);
    ((View) getGridView().getParent()).setVisibility(View.VISIBLE);
}
Also used : MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 27 with MultiObjectAdapter

use of com.abewy.android.apps.klyph.adapter.MultiObjectAdapter in project Klyph by jonathangerbaud.

the class KlyphFragment2 method populate.

protected void populate(List<GraphObject> data) {
    if (getView() != null && getAdapter() != null) {
        MultiObjectAdapter adapter = getAdapter();
        for (GraphObject graphObject : data) {
            adapter.add(graphObject);
        }
        // adapter.addAll(data); is only available in api 11
        endLoading();
        boolean requestHasMoreData = request != null && request.hasMoreData();
        if (data.size() == 0 || !requestHasMoreData)
            noMoreData = true;
        else
            offset = String.valueOf(adapter.getCount());
    }
}
Also used : MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject)

Example 28 with MultiObjectAdapter

use of com.abewy.android.apps.klyph.adapter.MultiObjectAdapter in project Klyph by jonathangerbaud.

the class NewAlbumDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.dialog_new_album, null);
    name = (TextView) view.findViewById(R.id.name);
    location = (TextView) view.findViewById(R.id.location);
    description = (TextView) view.findViewById(R.id.description);
    privacy = (Spinner) view.findViewById(R.id.privacy);
    /*ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.privacy,
				android.R.layout.simple_spinner_item);
		// Specify the layout to use when the list of choices appears
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);*/
    MultiObjectAdapter adapter = new MultiObjectAdapter(null, SpecialLayout.DROP_DOWN_ITEM);
    FriendList publicFL = new FriendList();
    publicFL.setName(getActivity().getString(R.string.menu_privacy_public));
    FriendList friendsFL = new FriendList();
    friendsFL.setName(getActivity().getString(R.string.menu_privacy_friends));
    FriendList selfFL = new FriendList();
    selfFL.setName(getActivity().getString(R.string.menu_privacy_self));
    adapter.add(publicFL);
    adapter.add(friendsFL);
    adapter.add(selfFL);
    List<GraphObject> friendLists = KlyphData.getFriendLists();
    if (friendLists != null) {
        for (GraphObject graphObject : friendLists) {
            adapter.add(graphObject);
        }
    }
    privacy.setAdapter(adapter);
    privacy.setSelection(KlyphPreferences.getPrivacy());
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(view);
    builder.setTitle(R.string.new_album).setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            createAlbum();
        }
    }).setNegativeButton(R.string.cancel, null);
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) FriendList(com.abewy.android.apps.klyph.core.fql.FriendList) DialogInterface(android.content.DialogInterface) MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) LayoutInflater(android.view.LayoutInflater) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) TextView(android.widget.TextView) View(android.view.View)

Example 29 with MultiObjectAdapter

use of com.abewy.android.apps.klyph.adapter.MultiObjectAdapter in project Klyph by jonathangerbaud.

the class Search method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    searchText = (EditText) view.findViewById(R.id.search_text);
    spinner = (Spinner) view.findViewById(R.id.search_type);
    button = (ImageButton) view.findViewById(R.id.button);
    progress = (ProgressBar) view.findViewById(android.R.id.progress);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            search();
        }
    });
    searchText.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
                search();
                return true;
            }
            return false;
        }
    });
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.search_labels, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);
    setListAdapter(new MultiObjectAdapter(getGridView()));
    defineEmptyText(R.string.empty_list_no_data);
    setListVisible(false);
    setAutoLoad(false);
    super.onViewCreated(view, savedInstanceState);
    progress.setVisibility(View.GONE);
}
Also used : KeyEvent(android.view.KeyEvent) MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) KlyphGridView(com.abewy.android.apps.klyph.widget.KlyphGridView) View(android.view.View)

Example 30 with MultiObjectAdapter

use of com.abewy.android.apps.klyph.adapter.MultiObjectAdapter in project Klyph by jonathangerbaud.

the class Groups method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    MultiObjectAdapter moa = new MultiObjectAdapter(getListView());
    moa.setFilter(new Filter() {

        @SuppressWarnings("unchecked")
        @Override
        protected void publishResults(CharSequence constraint, FilterResults results) {
            setFilteredResults((List<GraphObject>) results.values);
        }

        @Override
        protected FilterResults performFiltering(CharSequence constraint) {
            FilterResults results = new FilterResults();
            List<Group> filteredGroups = new ArrayList<Group>();
            // perform your search here using the searchConstraint String.
            constraint = constraint.toString().toLowerCase();
            for (int i = 0; i < groups.size(); i++) {
                Group group = (Group) groups.get(i);
                if (group.getName().toLowerCase().startsWith(constraint.toString())) {
                    filteredGroups.add(group);
                }
            }
            results.count = filteredGroups.size();
            results.values = filteredGroups;
            return results;
        }
    });
    setListAdapter(moa);
    defineEmptyText(R.string.empty_list_no_group);
    setRequestType(Query.GROUPS);
    setListVisible(false);
    super.onViewCreated(view, savedInstanceState);
}
Also used : Group(com.abewy.android.apps.klyph.core.fql.Group) Filter(android.widget.Filter) MultiObjectAdapter(com.abewy.android.apps.klyph.adapter.MultiObjectAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MultiObjectAdapter (com.abewy.android.apps.klyph.adapter.MultiObjectAdapter)32 View (android.view.View)7 GraphObject (com.abewy.android.apps.klyph.core.graph.GraphObject)7 ArrayList (java.util.ArrayList)5 List (java.util.List)4 Filter (android.widget.Filter)3 GoogleCardStyleAdapter (com.abewy.android.apps.klyph.adapter.animation.GoogleCardStyleAdapter)3 KlyphGridView (com.abewy.android.apps.klyph.widget.KlyphGridView)3 ImageView (android.widget.ImageView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 Friend (com.abewy.android.apps.klyph.core.fql.Friend)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 SparseBooleanArray (android.util.SparseBooleanArray)1 KeyEvent (android.view.KeyEvent)1