use of com.mobeta.android.dslv.DragSortListView in project Klyph by jonathangerbaud.
the class MultiSelectDragListPreference method onPrepareDialogBuilder.
@Override
protected void onPrepareDialogBuilder(Builder builder) {
super.onPrepareDialogBuilder(builder);
if (mEntries == null || mEntryValues == null) {
throw new IllegalStateException("MultiSelectListPreference requires an entries array and " + "an entryValues array.");
}
String[] entries = new String[mEntries.length];
for (int i = 0; i < mEntries.length; i++) {
entries[i] = mEntries[i].toString();
}
boolean[] selectedItems = getSelectedItems();
ArrayList<String> orderedList = new ArrayList<String>();
int n = selectedItems.length;
for (String value : mValues) {
int index = ArrayUtils.indexOf(mEntryValues, value);
orderedList.add(mEntries[index].toString());
}
for (int i = 0; i < mEntries.length; i++) {
if (!mValues.contains(mEntryValues[i]))
orderedList.add(mEntries[i].toString());
}
adapter = new ArrayAdapter<String>(getContext(), R.layout.item_list_preference_multi_drag, R.id.text, orderedList);
listView = new DragSortListView(getContext(), null);
listView.setAdapter(adapter);
listView.setDropListener(onDrop);
listView.setDragEnabled(true);
listView.setFloatAlpha(0.8f);
DragSortController controller = new DragSortController(listView);
controller.setDragHandleId(R.id.drag_handle);
controller.setRemoveEnabled(false);
controller.setSortEnabled(true);
controller.setBackgroundColor(0xFFFFFF);
controller.setDragInitMode(DragSortController.ON_DOWN);
listView.setFloatViewManager(controller);
listView.setOnTouchListener(controller);
builder.setView(listView);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
mPreferenceChanged = true;
refreshNewValues();
}
});
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
for (int i = 0; i < n; i++) {
listView.setItemChecked(i, i < mValues.size());
}
/*
* boolean [] checkedItems = getSelectedItems();
* builder.setMultiChoiceItems(mEntries, checkedItems,
* new DialogInterface.OnMultiChoiceClickListener() {
* public void onClick(DialogInterface dialog, int which, boolean
* isChecked) {
* if (isChecked) {
* mPreferenceChanged |= mNewValues.add(mEntryValues[which].toString());
* } else {
* mPreferenceChanged |=
* mNewValues.remove(mEntryValues[which].toString());
* }
* }
* });
*/
mNewValues.clear();
mNewValues.addAll(mValues);
}
use of com.mobeta.android.dslv.DragSortListView in project WordPress-Android by wordpress-mobile.
the class MediaGalleryEditFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mIds = new ArrayList<>();
if (savedInstanceState != null) {
mIds = ListUtils.fromLongArray(savedInstanceState.getLongArray(SAVED_MEDIA_IDS));
}
mGridAdapter = new MediaGalleryAdapter(getActivity(), R.layout.media_gallery_item, null, true, mImageLoader);
View view = inflater.inflate(R.layout.media_gallery_edit_fragment, container, false);
DragSortListView gridView = (DragSortListView) view.findViewById(R.id.edit_media_gallery_gridview);
gridView.setAdapter(mGridAdapter);
gridView.setOnCreateContextMenuListener(this);
gridView.setDropListener(this);
gridView.setRemoveListener(this);
refreshGridView();
return view;
}
use of com.mobeta.android.dslv.DragSortListView in project JamsMusicPlayer by psaravan.
the class BlacklistManagerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mApp = (Common) getActivity().getApplicationContext();
View rootView = (ViewGroup) inflater.inflate(R.layout.fragment_blacklist_manager, container, false);
mContext = getActivity().getApplicationContext();
ImageView blacklistImage = (ImageView) rootView.findViewById(R.id.blacklist_image);
blacklistImage.setImageResource(UIElementsHelper.getIcon(mContext, "manage_blacklists"));
MANAGER_TYPE = getArguments().getString("MANAGER_TYPE");
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//Get a cursor with a list of blacklisted elements.
if (MANAGER_TYPE.equals("ARTISTS")) {
builder.setTitle(R.string.blacklisted_artists);
cursor = mApp.getDBAccessHelper().getBlacklistedArtists();
//Finish the activity if there are no blacklisted elements.
if (cursor.getCount() == 0) {
Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show();
getActivity().finish();
} else {
//Load the cursor data into temporary ArrayLists.
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)));
}
}
} else if (MANAGER_TYPE.equals("ALBUMS")) {
builder.setTitle(R.string.blacklisted_albums);
cursor = mApp.getDBAccessHelper().getBlacklistedAlbums();
//Finish the activity if there are no blacklisted elements.
if (cursor.getCount() == 0) {
Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show();
getActivity().finish();
} else {
//Load the cursor data into temporary ArrayLists.
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM)));
artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)));
}
}
} else if (MANAGER_TYPE.equals("SONGS")) {
builder.setTitle(R.string.blacklisted_songs);
cursor = mApp.getDBAccessHelper().getAllBlacklistedSongs();
//Finish the activity if there are no blacklisted elements.
if (cursor.getCount() == 0) {
Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show();
getActivity().finish();
} else {
//Load the cursor data into temporary ArrayLists.
for (int i = 0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_TITLE)));
artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ARTIST)));
filePathList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_FILE_PATH)));
songIdsList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ID)));
}
}
} else if (MANAGER_TYPE.equals("PLAYLISTS")) {
/*builder.setTitle(R.string.blacklisted_playlists);
DBAccessHelper playlistsDBHelper = new DBAccessHelper(getActivity());
cursor = playlistsDBHelper.getAllBlacklistedPlaylists();
//Finish the activity if there are no blacklisted elements.
if (cursor.getCount()==0) {
Toast.makeText(getActivity(), R.string.no_blacklisted_items_found, Toast.LENGTH_LONG).show();
getActivity().finish();
} else {
//Load the cursor data into temporary ArrayLists.
for (int i=0; i < cursor.getCount(); i++) {
cursor.moveToPosition(i);
elementNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_NAME)));
artistNameList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.NUMBER_OF_SONGS)));
filePathList.add(cursor.getString(cursor.getColumnIndex(DBAccessHelper.PLAYLIST_FILE_PATH)));
}
}*/
} else {
Toast.makeText(getActivity(), R.string.error_occurred, Toast.LENGTH_LONG).show();
getActivity().finish();
}
TextView blacklistManagerInfoText = (TextView) rootView.findViewById(R.id.blacklist_manager_info_text);
DragSortListView blacklistManagerListView = (DragSortListView) rootView.findViewById(R.id.blacklist_manager_list);
blacklistManagerListView.setRemoveListener(onRemove);
blacklistManagerInfoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
blacklistManagerInfoText.setPaintFlags(blacklistManagerInfoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
blacklistManagerListView.setFastScrollEnabled(true);
adapter = new BlacklistedElementsAdapter(getActivity(), elementNameList, artistNameList, MANAGER_TYPE);
blacklistManagerListView.setAdapter(adapter);
return rootView;
}
use of com.mobeta.android.dslv.DragSortListView in project little-bear-dictionary by daimajia.
the class DictionaryManageFragment method onDestroyView.
@Override
public void onDestroyView() {
super.onDestroyView();
QueryProcessor.updateCacheDictionaryList(getActivity().getApplicationContext());
if (mDictionaryManageFragment.mOfflineDictionaryManageView == null) {
return;
}
DragSortListView dragSortListView = (DragSortListView) mDictionaryManageFragment.mOfflineDictionaryManageView.findViewById(android.R.id.list);
OfflineListCursorAdapter dragSortCursorAdapter = (OfflineListCursorAdapter) dragSortListView.getInputAdapter();
ArrayList<Integer> SortedResult = dragSortCursorAdapter.getCursorPositions();
if (SortedResult == null || SortedResult.size() == 0) {
return;
}
Cursor cursor = dragSortCursorAdapter.getCursor();
cursor.moveToPosition(-1);
int i = 0;
DictionaryDB dictionaryDB = new DictionaryDB(getActivity(), DictionaryDB.DB_NAME, null, DictionaryDB.DB_VERSION);
SQLiteDatabase sqLiteDatabase = dictionaryDB.getWritableDatabase();
while (cursor.moveToNext()) {
String[] args = { SortedResult.get(i).toString(), cursor.getString(cursor.getColumnIndex("_id")) };
sqLiteDatabase.execSQL("update `dictionary_list` set `dictionary_order`= ? where `_id`= ?", args);
i++;
}
}
use of com.mobeta.android.dslv.DragSortListView in project drag-sort-listview by bauerca.
the class MultipleChoiceListView method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.checkable_main);
String[] array = getResources().getStringArray(R.array.jazz_artist_names);
ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(array));
adapter = new ArrayAdapter<String>(this, R.layout.list_item_checkable, R.id.text, arrayList);
setListAdapter(adapter);
DragSortListView list = getListView();
list.setDropListener(onDrop);
list.setRemoveListener(onRemove);
}
Aggregations