Search in sources :

Example 56 with BaseAdapter

use of android.widget.BaseAdapter in project ListViewAnimations by nhaarman.

the class DynamicListView method setAdapter.

/**
 * Sets the {@link ListAdapter} for this {@code DynamicListView}.
 * If the drag and drop functionality is or will be enabled, the adapter should have stable ids,
 * and should implement {@link com.nhaarman.listviewanimations.util.Swappable}.
 *
 * @param adapter the adapter.
 *
 * @throws java.lang.IllegalStateException    if the drag and drop functionality is enabled
 *                                            and the adapter does not have stable ids.
 * @throws java.lang.IllegalArgumentException if the drag and drop functionality is enabled
 *                                            and the adapter does not implement {@link com.nhaarman.listviewanimations.util.Swappable}.
 */
@Override
public void setAdapter(final ListAdapter adapter) {
    ListAdapter wrappedAdapter = adapter;
    mSwipeUndoAdapter = null;
    if (adapter instanceof BaseAdapter) {
        BaseAdapter rootAdapter = (BaseAdapter) wrappedAdapter;
        while (rootAdapter instanceof BaseAdapterDecorator) {
            if (rootAdapter instanceof SwipeUndoAdapter) {
                mSwipeUndoAdapter = (SwipeUndoAdapter) rootAdapter;
            }
            rootAdapter = ((BaseAdapterDecorator) rootAdapter).getDecoratedBaseAdapter();
        }
        if (rootAdapter instanceof Insertable) {
            mAnimateAdditionAdapter = new AnimateAdditionAdapter((BaseAdapter) wrappedAdapter);
            mAnimateAdditionAdapter.setListView(this);
            wrappedAdapter = mAnimateAdditionAdapter;
        }
    }
    super.setAdapter(wrappedAdapter);
    if (mDragAndDropHandler != null) {
        mDragAndDropHandler.setAdapter(adapter);
    }
}
Also used : BaseAdapterDecorator(com.nhaarman.listviewanimations.BaseAdapterDecorator) SwipeUndoAdapter(com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.SwipeUndoAdapter) BaseAdapter(android.widget.BaseAdapter) Insertable(com.nhaarman.listviewanimations.util.Insertable) ListAdapter(android.widget.ListAdapter) AnimateAdditionAdapter(com.nhaarman.listviewanimations.itemmanipulation.animateaddition.AnimateAdditionAdapter)

Example 57 with BaseAdapter

use of android.widget.BaseAdapter in project PhotoView by bm-x.

the class PhotoBrowse method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_photo_browse);
    in.setDuration(300);
    out.setDuration(300);
    out.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mBg.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    mParent = findViewById(R.id.parent);
    mBg = findViewById(R.id.bg);
    mPhotoView = (PhotoView) findViewById(R.id.img);
    mPhotoView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    gv = (GridView) findViewById(R.id.gv);
    gv.setAdapter(new BaseAdapter() {

        @Override
        public int getCount() {
            return imgs.length;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return 0;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            PhotoView p = new PhotoView(PhotoBrowse.this);
            p.setLayoutParams(new AbsListView.LayoutParams((int) (getResources().getDisplayMetrics().density * 100), (int) (getResources().getDisplayMetrics().density * 100)));
            p.setScaleType(ImageView.ScaleType.CENTER_CROP);
            p.setImageResource(imgs[position]);
            // 把PhotoView当普通的控件把触摸功能关掉
            p.disenable();
            return p;
        }
    });
    gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            PhotoView p = (PhotoView) view;
            mInfo = p.getInfo();
            mPhotoView.setImageResource(imgs[position]);
            mBg.startAnimation(in);
            mBg.setVisibility(View.VISIBLE);
            mParent.setVisibility(View.VISIBLE);
            ;
            mPhotoView.animaFrom(mInfo);
        }
    });
    mPhotoView.enable();
    mPhotoView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mBg.startAnimation(out);
            mPhotoView.animaTo(mInfo, new Runnable() {

                @Override
                public void run() {
                    mParent.setVisibility(View.GONE);
                }
            });
        }
    });
}
Also used : ViewGroup(android.view.ViewGroup) GridView(android.widget.GridView) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) PhotoView(com.bm.library.PhotoView) PhotoView(com.bm.library.PhotoView) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AdapterView(android.widget.AdapterView) BaseAdapter(android.widget.BaseAdapter)

Example 58 with BaseAdapter

use of android.widget.BaseAdapter in project robolectric by robolectric.

the class ShadowBaseAdapterTest method canResetNotifyDataSetChangedFlag.

@Test
public void canResetNotifyDataSetChangedFlag() {
    BaseAdapter adapter = new TestBaseAdapter();
    adapter.notifyDataSetChanged();
    shadowOf(adapter).clearWasDataSetChangedCalledFlag();
    assertFalse(shadowOf(adapter).wasNotifyDataSetChangedCalled());
}
Also used : BaseAdapter(android.widget.BaseAdapter) Test(org.junit.Test)

Example 59 with BaseAdapter

use of android.widget.BaseAdapter in project android-flip by openaphid.

the class FlipButtonActivity method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.activity_title);
    flipView = new FlipViewController(this);
    flipView.setAdapter(new BaseAdapter() {

        @Override
        public int getCount() {
            return 10;
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            NumberButton button;
            if (convertView == null) {
                final Context context = parent.getContext();
                button = new NumberButton(context, position);
                button.setTextSize(context.getResources().getDimension(R.dimen.textSize));
            } else {
                button = (NumberButton) convertView;
                button.setNumber(position);
            }
            return button;
        }
    });
    setContentView(flipView);
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) FlipViewController(com.aphidmobile.flip.FlipViewController) NumberButton(com.aphidmobile.flip.demo.views.NumberButton) BaseAdapter(android.widget.BaseAdapter) View(android.view.View)

Example 60 with BaseAdapter

use of android.widget.BaseAdapter in project android-flip by openaphid.

the class FlipTextViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    flipView = new FlipViewController(inflater.getContext());
    flipView.setAdapter(new BaseAdapter() {

        @Override
        public int getCount() {
            return 10;
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            NumberTextView view;
            if (convertView == null) {
                final Context context = parent.getContext();
                view = new NumberTextView(context, position);
                view.setTextSize(context.getResources().getDimension(R.dimen.textSize));
            } else {
                view = (NumberTextView) convertView;
                view.setNumber(position);
            }
            return view;
        }
    });
    return flipView;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) FlipViewController(com.aphidmobile.flip.FlipViewController) NumberTextView(com.aphidmobile.flip.demo.views.NumberTextView) BaseAdapter(android.widget.BaseAdapter) NumberTextView(com.aphidmobile.flip.demo.views.NumberTextView) View(android.view.View)

Aggregations

BaseAdapter (android.widget.BaseAdapter)63 View (android.view.View)30 AdapterView (android.widget.AdapterView)26 ViewGroup (android.view.ViewGroup)22 TextView (android.widget.TextView)21 ListAdapter (android.widget.ListAdapter)16 Adapter (android.widget.Adapter)15 ListView (android.widget.ListView)11 PackageInfoData (dev.ukanth.ufirewall.Api.PackageInfoData)8 RemoteAdapterConnectionCallback (android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback)7 Intent (android.content.Intent)5 LayoutInflater (android.view.LayoutInflater)5 SuppressLint (android.annotation.SuppressLint)4 Context (android.content.Context)4 AbsListView (android.widget.AbsListView)4 GridView (android.widget.GridView)4 ImageView (android.widget.ImageView)4 RecyclerView (android.support.v7.widget.RecyclerView)3 MenuItem (android.view.MenuItem)3 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)3