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);
}
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());
}
}
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();
}
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);
}
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);
}
Aggregations