Search in sources :

Example 11 with DragSortListView

use of com.mobeta.android.dslv.DragSortListView in project SeriesGuide by UweTrottmann.

the class ListsReorderDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.dialog_lists_reorder, container, false);
    unbinder = ButterKnife.bind(this, v);
    DragSortController controller = new DragSortController(dragSortListView, R.id.dragGripViewItemList, DragSortController.ON_DOWN, DragSortController.CLICK_REMOVE);
    controller.setRemoveEnabled(false);
    dragSortListView.setFloatViewManager(controller);
    dragSortListView.setOnTouchListener(controller);
    dragSortListView.setDropListener(new DragSortListView.DropListener() {

        @Override
        public void drop(int from, int to) {
            reorderList(from, to);
        }
    });
    buttonNegative.setText(R.string.discard);
    buttonNegative.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    buttonPositive.setText(android.R.string.ok);
    buttonPositive.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            saveListsOrder();
            dismiss();
        }
    });
    return v;
}
Also used : DragSortController(com.mobeta.android.dslv.DragSortController) DragSortListView(com.mobeta.android.dslv.DragSortListView) BindView(butterknife.BindView) DragSortListView(com.mobeta.android.dslv.DragSortListView) View(android.view.View)

Example 12 with DragSortListView

use of com.mobeta.android.dslv.DragSortListView in project ultrasonic by ultrasonic.

the class DownloadActivity method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.download);
    final WindowManager windowManager = getWindowManager();
    final Display display = windowManager.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
    swipeDistance = (width + height) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100;
    swipeVelocity = swipeDistance;
    gestureScanner = new GestureDetector(this, this);
    playlistFlipper = (ViewFlipper) findViewById(R.id.download_playlist_flipper);
    emptyTextView = (TextView) findViewById(R.id.download_empty);
    songTitleTextView = (TextView) findViewById(R.id.download_song_title);
    albumTextView = (TextView) findViewById(R.id.download_album);
    artistTextView = (TextView) findViewById(R.id.download_artist);
    albumArtImageView = (ImageView) findViewById(R.id.download_album_art_image);
    positionTextView = (TextView) findViewById(R.id.download_position);
    downloadTrackTextView = (TextView) findViewById(R.id.download_track);
    downloadTotalDurationTextView = (TextView) findViewById(R.id.download_total_duration);
    durationTextView = (TextView) findViewById(R.id.download_duration);
    progressBar = (SeekBar) findViewById(R.id.download_progress_bar);
    playlistView = (DragSortListView) findViewById(R.id.download_list);
    final AutoRepeatButton previousButton = (AutoRepeatButton) findViewById(R.id.download_previous);
    final AutoRepeatButton nextButton = (AutoRepeatButton) findViewById(R.id.download_next);
    pauseButton = findViewById(R.id.download_pause);
    stopButton = findViewById(R.id.download_stop);
    startButton = findViewById(R.id.download_start);
    final View shuffleButton = findViewById(R.id.download_shuffle);
    repeatButton = (ImageView) findViewById(R.id.download_repeat);
    visualizerViewLayout = (LinearLayout) findViewById(R.id.download_visualizer_view_layout);
    View.OnTouchListener touchListener = new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent me) {
            return gestureScanner.onTouchEvent(me);
        }
    };
    albumArtImageView.setOnTouchListener(touchListener);
    albumArtImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            toggleFullScreenAlbumArt();
        }
    });
    previousButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            warnIfNetworkOrStorageUnavailable();
            new SilentBackgroundTask<Void>(DownloadActivity.this) {

                @Override
                protected Void doInBackground() throws Throwable {
                    getDownloadService().previous();
                    return null;
                }

                @Override
                protected void done(final Void result) {
                    onCurrentChanged();
                    onSliderProgressChanged();
                }
            }.execute();
        }
    });
    previousButton.setOnRepeatListener(new Runnable() {

        @Override
        public void run() {
            int incrementTime = Util.getIncrementTime(DownloadActivity.this);
            changeProgress(-incrementTime);
        }
    });
    nextButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            warnIfNetworkOrStorageUnavailable();
            new SilentBackgroundTask<Boolean>(DownloadActivity.this) {

                @Override
                protected Boolean doInBackground() throws Throwable {
                    if (getDownloadService().getCurrentPlayingIndex() < getDownloadService().size() - 1) {
                        getDownloadService().next();
                        return true;
                    } else {
                        return false;
                    }
                }

                @Override
                protected void done(final Boolean result) {
                    if (result) {
                        onCurrentChanged();
                        onSliderProgressChanged();
                    }
                }
            }.execute();
        }
    });
    nextButton.setOnRepeatListener(new Runnable() {

        @Override
        public void run() {
            int incrementTime = Util.getIncrementTime(DownloadActivity.this);
            changeProgress(incrementTime);
        }
    });
    pauseButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            new SilentBackgroundTask<Void>(DownloadActivity.this) {

                @Override
                protected Void doInBackground() throws Throwable {
                    getDownloadService().pause();
                    return null;
                }

                @Override
                protected void done(final Void result) {
                    onCurrentChanged();
                    onSliderProgressChanged();
                }
            }.execute();
        }
    });
    stopButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            new SilentBackgroundTask<Void>(DownloadActivity.this) {

                @Override
                protected Void doInBackground() throws Throwable {
                    getDownloadService().reset();
                    return null;
                }

                @Override
                protected void done(final Void result) {
                    onCurrentChanged();
                    onSliderProgressChanged();
                }
            }.execute();
        }
    });
    startButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            warnIfNetworkOrStorageUnavailable();
            new SilentBackgroundTask<Void>(DownloadActivity.this) {

                @Override
                protected Void doInBackground() throws Throwable {
                    start();
                    return null;
                }

                @Override
                protected void done(final Void result) {
                    onCurrentChanged();
                    onSliderProgressChanged();
                }
            }.execute();
        }
    });
    shuffleButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            getDownloadService().shuffle();
            Util.toast(DownloadActivity.this, R.string.download_menu_shuffle_notification);
        }
    });
    repeatButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View view) {
            final RepeatMode repeatMode = getDownloadService().getRepeatMode().next();
            getDownloadService().setRepeatMode(repeatMode);
            onDownloadListChanged();
            switch(repeatMode) {
                case OFF:
                    Util.toast(DownloadActivity.this, R.string.download_repeat_off);
                    break;
                case ALL:
                    Util.toast(DownloadActivity.this, R.string.download_repeat_all);
                    break;
                case SINGLE:
                    Util.toast(DownloadActivity.this, R.string.download_repeat_single);
                    break;
                default:
                    break;
            }
        }
    });
    progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(final SeekBar seekBar) {
            new SilentBackgroundTask<Void>(DownloadActivity.this) {

                @Override
                protected Void doInBackground() throws Throwable {
                    getDownloadService().seekTo(getProgressBar().getProgress());
                    return null;
                }

                @Override
                protected void done(final Void result) {
                    onSliderProgressChanged();
                }
            }.execute();
        }

        @Override
        public void onStartTrackingTouch(final SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
        }
    });
    playlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
            warnIfNetworkOrStorageUnavailable();
            new SilentBackgroundTask<Void>(DownloadActivity.this) {

                @Override
                protected Void doInBackground() throws Throwable {
                    getDownloadService().play(position);
                    return null;
                }

                @Override
                protected void done(final Void result) {
                    onCurrentChanged();
                    onSliderProgressChanged();
                }
            }.execute();
        }
    });
    registerForContextMenu(playlistView);
    final DownloadService downloadService = getDownloadService();
    if (downloadService != null && getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, false)) {
        warnIfNetworkOrStorageUnavailable();
        downloadService.setShufflePlayEnabled(true);
    }
    visualizerAvailable = (downloadService != null) && (downloadService.getVisualizerController() != null);
    equalizerAvailable = (downloadService != null) && (downloadService.getEqualizerController() != null);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                DownloadService downloadService = getDownloadService();
                jukeboxAvailable = (downloadService != null) && (downloadService.isJukeboxAvailable());
            } catch (Exception e) {
                Log.e(TAG, e.getMessage(), e);
            }
        }
    }).start();
    final View nowPlayingMenuItem = findViewById(R.id.menu_now_playing);
    menuDrawer.setActiveView(nowPlayingMenuItem);
    if (visualizerAvailable) {
        visualizerView = new VisualizerView(this);
        visualizerViewLayout.addView(visualizerView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
        if (!visualizerView.isActive()) {
            visualizerViewLayout.setVisibility(View.GONE);
        } else {
            visualizerViewLayout.setVisibility(View.VISIBLE);
        }
        visualizerView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(final View view, final MotionEvent motionEvent) {
                visualizerView.setActive(!visualizerView.isActive());
                getDownloadService().setShowVisualization(visualizerView.isActive());
                return true;
            }
        });
    } else {
        visualizerViewLayout.setVisibility(View.GONE);
    }
}
Also used : SilentBackgroundTask(org.moire.ultrasonic.util.SilentBackgroundTask) GestureDetector(android.view.GestureDetector) DownloadService(org.moire.ultrasonic.service.DownloadService) WindowManager(android.view.WindowManager) AutoRepeatButton(org.moire.ultrasonic.view.AutoRepeatButton) RepeatMode(org.moire.ultrasonic.domain.RepeatMode) VisualizerView(org.moire.ultrasonic.view.VisualizerView) SeekBar(android.widget.SeekBar) Point(android.graphics.Point) ImageView(android.widget.ImageView) VisualizerView(org.moire.ultrasonic.view.VisualizerView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) DragSortListView(com.mobeta.android.dslv.DragSortListView) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout) Display(android.view.Display)

Example 13 with DragSortListView

use of com.mobeta.android.dslv.DragSortListView in project drag-sort-listview by bauerca.

the class WarpDSLV method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.warp_main);
    DragSortListView lv = (DragSortListView) getListView();
    lv.setDropListener(onDrop);
    lv.setRemoveListener(onRemove);
    lv.setDragScrollProfile(ssProfile);
    array = getResources().getStringArray(R.array.countries);
    list = new ArrayList<String>(Arrays.asList(array));
    adapter = new ArrayAdapter<String>(this, R.layout.list_item_handle_right, R.id.text, list);
    setListAdapter(adapter);
}
Also used : DragSortListView(com.mobeta.android.dslv.DragSortListView)

Example 14 with DragSortListView

use of com.mobeta.android.dslv.DragSortListView in project drag-sort-listview by bauerca.

the class Sections method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sections_main);
    DragSortListView dslv = (DragSortListView) getListView();
    // get jazz artist names and make adapter
    String[] array = getResources().getStringArray(R.array.jazz_artist_names);
    List<String> list = new ArrayList<String>(Arrays.asList(array));
    SectionAdapter adapter = new SectionAdapter(this, list);
    dslv.setDropListener(adapter);
    // make and set controller on dslv
    SectionController c = new SectionController(dslv, adapter);
    dslv.setFloatViewManager(c);
    dslv.setOnTouchListener(c);
    // pass it to the ListActivity
    setListAdapter(adapter);
}
Also used : ArrayList(java.util.ArrayList) DragSortListView(com.mobeta.android.dslv.DragSortListView)

Example 15 with DragSortListView

use of com.mobeta.android.dslv.DragSortListView in project drag-sort-listview by bauerca.

the class TestBedDSLV method onEnabledOkClick.

@Override
public void onEnabledOkClick(boolean drag, boolean sort, boolean remove) {
    mSortEnabled = sort;
    mRemoveEnabled = remove;
    mDragEnabled = drag;
    DSLVFragment f = (DSLVFragment) getSupportFragmentManager().findFragmentByTag(mTag);
    DragSortListView dslv = (DragSortListView) f.getListView();
    f.getController().setRemoveEnabled(remove);
    f.getController().setSortEnabled(sort);
    dslv.setDragEnabled(drag);
}
Also used : DragSortListView(com.mobeta.android.dslv.DragSortListView)

Aggregations

DragSortListView (com.mobeta.android.dslv.DragSortListView)16 View (android.view.View)7 AdapterView (android.widget.AdapterView)5 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 ArrayList (java.util.ArrayList)4 Paint (android.graphics.Paint)3 DragSortController (com.mobeta.android.dslv.DragSortController)3 MotionEvent (android.view.MotionEvent)2 ViewGroup (android.view.ViewGroup)2 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)2 SuppressLint (android.annotation.SuppressLint)1 AlertDialog (android.app.AlertDialog)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 MatrixCursor (android.database.MatrixCursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 Bitmap (android.graphics.Bitmap)1