Search in sources :

Example 76 with ListView

use of android.widget.ListView in project FBReaderJ by geometer.

the class ViewFilesContextMenuUtils method doShowHistoryContents.

/**
     * Shows history contents to the user. He can clear all items.
     * 
     * @param context
     *            {@link Context}
     * @param fileProvider
     *            {@link IFileProvider}
     * @param history
     *            {@link History} of {@link IFile}.
     * @param currentLocation
     *            current location, will not be shown.
     * @param listener
     *            will be notified after the user closed the dialog, or when the
     *            user selects an item.
     */
public static void doShowHistoryContents(final Context context, final IFileProvider fileProvider, final History<IFile> history, IFile currentLocation, final TaskListener listener) {
    if (history.isEmpty())
        return;
    final AlertDialog _dialog = Dlg.newDlg(context);
    // don't use Cancel button
    _dialog.setButton(DialogInterface.BUTTON_NEGATIVE, null, (DialogInterface.OnClickListener) null);
    _dialog.setIcon(android.R.drawable.ic_dialog_info);
    _dialog.setTitle(R.string.afc_title_history);
    List<IFileDataModel> data = new ArrayList<IFileDataModel>();
    ArrayList<IFile> items = history.items();
    for (int i = items.size() - 1; i >= 0; i--) {
        IFile f = items.get(i);
        if (f == currentLocation)
            continue;
        // check for duplicates
        boolean duplicated = false;
        for (int j = 0; j < data.size(); j++) {
            if (f.equalsToPath(data.get(j).getFile())) {
                duplicated = true;
                break;
            }
        }
        if (!duplicated)
            data.add(new IFileDataModel(f));
    }
    final IFileAdapter _adapter = new IFileAdapter(context, data, FilterMode.DirectoriesOnly, null, false);
    ListView listView = (ListView) LayoutInflater.from(context).inflate(R.layout.afc_listview_files, null);
    listView.setBackgroundResource(0);
    listView.setFastScrollEnabled(true);
    listView.setAdapter(_adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (listener != null) {
                _dialog.dismiss();
                listener.onFinish(true, _adapter.getItem(position).getFile());
            }
        }
    });
    // OnItemClickListener
    _dialog.setView(listView);
    _dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.afc_cmd_clear), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            history.clear();
        }
    });
    _dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (listener != null)
                listener.onFinish(true, null);
        }
    });
    _dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) IFileAdapter(group.pals.android.lib.ui.filechooser.IFileAdapter) IFile(group.pals.android.lib.ui.filechooser.io.IFile) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) IFileDataModel(group.pals.android.lib.ui.filechooser.IFileDataModel) AdapterView(android.widget.AdapterView)

Example 77 with ListView

use of android.widget.ListView in project FBReaderJ by geometer.

the class DragSortListView method startDrag.

/**
     * Start a drag of item at <code>position</code> without using
     * a FloatViewManager.
     *
     * @param position Item to drag.
     * @param floatView Floating View.
     * @param dragFlags Flags that restrict some movements of the
     * floating View. For example, set <code>dragFlags |= 
     * ~{@link #DRAG_NEG_X}</code> to allow dragging the floating
     * View in all directions except off the screen to the left.
     * @param deltaX Offset in x of the touch coordinate from the
     * left edge of the floating View (i.e. touch-x minus float View
     * left).
     * @param deltaY Offset in y of the touch coordinate from the
     * top edge of the floating View (i.e. touch-y minus float View
     * top).
     *
     * @return True if the drag was started, false otherwise. This
     * <code>startDrag</code> will fail if we are not currently in
     * a touch event, <code>floatView</code> is null, or there is
     * a drag in progress.
     */
public boolean startDrag(int position, View floatView, int dragFlags, int deltaX, int deltaY) {
    if (mDragState != IDLE || !mInTouchEvent || mFloatView != null || floatView == null || !mDragEnabled) {
        return false;
    }
    if (getParent() != null) {
        getParent().requestDisallowInterceptTouchEvent(true);
    }
    int pos = position + getHeaderViewsCount();
    mFirstExpPos = pos;
    mSecondExpPos = pos;
    mSrcPos = pos;
    mFloatPos = pos;
    // mDragState = dragType;
    mDragState = DRAGGING;
    mDragFlags = 0;
    mDragFlags |= dragFlags;
    mFloatView = floatView;
    // sets mFloatViewHeight
    measureFloatView();
    mDragDeltaX = deltaX;
    mDragDeltaY = deltaY;
    mDragStartY = mY;
    // updateFloatView(mX - mDragDeltaX, mY - mDragDeltaY);
    mFloatLoc.x = mX - mDragDeltaX;
    mFloatLoc.y = mY - mDragDeltaY;
    // set src item invisible
    final View srcItem = getChildAt(mSrcPos - getFirstVisiblePosition());
    if (srcItem != null) {
        srcItem.setVisibility(View.INVISIBLE);
    }
    if (mTrackDragSort) {
        mDragSortTracker.startTracking();
    }
    // to ListView
    switch(mCancelMethod) {
        case ON_TOUCH_EVENT:
            super.onTouchEvent(mCancelEvent);
            break;
        case ON_INTERCEPT_TOUCH_EVENT:
            super.onInterceptTouchEvent(mCancelEvent);
            break;
    }
    requestLayout();
    if (mLiftAnimator != null) {
        mLiftAnimator.start();
    }
    return true;
}
Also used : View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) Point(android.graphics.Point)

Example 78 with ListView

use of android.widget.ListView in project cardslib by gabrielemariotti.

the class CardArrayAdapter method getView.

// -------------------------------------------------------------
// Views
// -------------------------------------------------------------
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;
    CardViewWrapper mCardView;
    Card mCard;
    LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //Retrieve card from items
    mCard = (Card) getItem(position);
    if (mCard != null) {
        int layout = mRowLayoutId;
        boolean recycle = false;
        //Inflate layout
        if (view == null) {
            recycle = false;
            view = mInflater.inflate(layout, parent, false);
        } else {
            recycle = true;
        }
        //Setup card
        mCardView = (CardViewWrapper) view.findViewById(R.id.list_cardId);
        if (mCardView != null) {
            //It is important to set recycle value for inner layout elements
            mCardView.setForceReplaceInnerLayout(Card.equalsInnerLayout(mCardView.getCard(), mCard));
            //It is important to set recycle value for performance issue
            mCardView.setRecycle(recycle);
            //Save original swipeable to prevent cardSwipeListener (listView requires another cardSwipeListener)
            boolean origianlSwipeable = mCard.isSwipeable();
            mCard.setSwipeable(false);
            mCardView.setCard(mCard);
            //Set originalValue
            mCard.setSwipeable(origianlSwipeable);
            //If card has an expandable button override animation
            if ((mCard.getCardHeader() != null && mCard.getCardHeader().isButtonExpandVisible()) || mCard.getViewToClickToExpand() != null) {
                setupExpandCollapseListAnimation(mCardView);
            }
            //Setup swipeable animation
            setupSwipeableAnimation(mCard, mCardView);
            //setupMultiChoice
            setupMultichoice(view, mCard, mCardView, position);
        }
    }
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) CardViewWrapper(it.gmariotti.cardslib.library.view.base.CardViewWrapper) View(android.view.View) CardView(it.gmariotti.cardslib.library.view.CardView) AbsListView(android.widget.AbsListView) CardListView(it.gmariotti.cardslib.library.view.CardListView) ListView(android.widget.ListView) UndoCard(it.gmariotti.cardslib.library.view.listener.UndoCard)

Example 79 with ListView

use of android.widget.ListView in project facebook-android-sdk by facebook.

the class PlacePickerFragment method setupViews.

@Override
void setupViews(ViewGroup view) {
    if (showSearchBox) {
        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
        View searchHeaderView = getActivity().getLayoutInflater().inflate(R.layout.picker_search_box, listView, false);
        listView.addHeaderView(searchHeaderView, null, false);
        searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text);
        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
            searchBox.setText(searchText);
        }
    }
}
Also used : ListView(android.widget.ListView) View(android.view.View) ListView(android.widget.ListView)

Example 80 with ListView

use of android.widget.ListView in project Android-AccountChooser by frakbot.

the class ChooseAccountActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mAccounts = getIntent().getParcelableArrayExtra(AccountManager.KEY_ACCOUNTS);
    mAccountManagerResponse = getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE);
    // KEY_ACCOUNTS is a required parameter
    if (mAccounts == null) {
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    getAuthDescriptions();
    AccountInfo[] mAccountInfos = new AccountInfo[mAccounts.length];
    for (int i = 0; i < mAccounts.length; i++) {
        mAccountInfos[i] = new AccountInfo(((Account) mAccounts[i]).name, getDrawableForType(((Account) mAccounts[i]).type));
    }
    setContentView(R.layout.choose_account);
    // Setup the list
    ListView list = (ListView) findViewById(android.R.id.list);
    // Use an existing ListAdapter that will map an array of strings to TextViews
    list.setAdapter(new AccountArrayAdapter(this, android.R.layout.simple_list_item_1, mAccountInfos));
    list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    list.setTextFilterEnabled(true);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            onListItemClick((ListView) parent, v, position, id);
        }
    });
}
Also used : Account(android.accounts.Account) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

ListView (android.widget.ListView)1139 View (android.view.View)739 AdapterView (android.widget.AdapterView)444 TextView (android.widget.TextView)389 ImageView (android.widget.ImageView)167 Intent (android.content.Intent)148 AbsListView (android.widget.AbsListView)135 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)97 ArrayAdapter (android.widget.ArrayAdapter)97 ArrayList (java.util.ArrayList)81 ViewGroup (android.view.ViewGroup)75 ListAdapter (android.widget.ListAdapter)71 OnClickListener (android.view.View.OnClickListener)65 LayoutInflater (android.view.LayoutInflater)63 Bundle (android.os.Bundle)57 Button (android.widget.Button)55 LinearLayout (android.widget.LinearLayout)50 SuppressLint (android.annotation.SuppressLint)34 DialogInterface (android.content.DialogInterface)34 ScrollView (android.widget.ScrollView)31