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