Search in sources :

Example 31 with BaseAdapter

use of android.widget.BaseAdapter in project remusic by aa112901.

the class ThemeUtils method refreshView.

private static void refreshView(View view, ExtraRefreshable extraRefreshable) {
    if (view == null)
        return;
    view.destroyDrawingCache();
    if (view instanceof Tintable) {
        ((Tintable) view).tint();
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                refreshView(((ViewGroup) view).getChildAt(i), extraRefreshable);
            }
        }
    } else {
        if (extraRefreshable != null) {
            extraRefreshable.refreshSpecificView(view);
        }
        if (view instanceof AbsListView) {
            ListAdapter adapter = ((AbsListView) view).getAdapter();
            while (adapter instanceof WrapperListAdapter) {
                adapter = ((WrapperListAdapter) adapter).getWrappedAdapter();
            }
            if (adapter instanceof BaseAdapter) {
                ((BaseAdapter) adapter).notifyDataSetChanged();
            }
        }
        if (view instanceof RecyclerView) {
            try {
                if (mRecycler == null) {
                    mRecycler = RecyclerView.class.getDeclaredField("mRecycler");
                    mRecycler.setAccessible(true);
                }
                if (mClearMethod == null) {
                    mClearMethod = Class.forName("android.support.v7.widget.RecyclerView$Recycler").getDeclaredMethod("clear");
                    mClearMethod.setAccessible(true);
                }
                mClearMethod.invoke(mRecycler.get(view));
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            ((RecyclerView) view).getRecycledViewPool().clear();
            ((RecyclerView) view).invalidateItemDecorations();
        }
        if (view instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
                refreshView(((ViewGroup) view).getChildAt(i), extraRefreshable);
            }
        }
    }
}
Also used : Tintable(com.bilibili.magicasakura.widgets.Tintable) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) InvocationTargetException(java.lang.reflect.InvocationTargetException) RecyclerView(android.support.v7.widget.RecyclerView) BaseAdapter(android.widget.BaseAdapter) ListAdapter(android.widget.ListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter) WrapperListAdapter(android.widget.WrapperListAdapter)

Example 32 with BaseAdapter

use of android.widget.BaseAdapter in project PreLollipopTransition by takahirom.

the class ListViewFragment method onCreateView.

@Nullable
@Override
public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View inflate = inflater.inflate(R.layout.fragment_list_view, container, false);
    final ListView listView = (ListView) inflate.findViewById(R.id.list);
    listView.setAdapter(new BaseAdapter() {

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

        @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) {
            return inflater.inflate(R.layout.list_row, parent, false);
        }
    });
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Intent intent = new Intent(getContext(), SubActivity.class);
            ActivityTransitionLauncher.with(getActivity()).from(view.findViewById(R.id.image)).launch(intent);
        }
    });
    return inflate;
}
Also used : SubActivity(com.kogitune.prelollipoptransition.SubActivity) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) BaseAdapter(android.widget.BaseAdapter) Nullable(android.support.annotation.Nullable)

Example 33 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 34 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 35 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)43 View (android.view.View)22 AdapterView (android.widget.AdapterView)21 ViewGroup (android.view.ViewGroup)16 Adapter (android.widget.Adapter)15 TextView (android.widget.TextView)15 ListAdapter (android.widget.ListAdapter)8 ListView (android.widget.ListView)7 RemoteAdapterConnectionCallback (android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback)7 LayoutInflater (android.view.LayoutInflater)5 Context (android.content.Context)4 AbsListView (android.widget.AbsListView)4 RecipeInformation (com.se491.chef_ly.model.RecipeInformation)4 SuppressLint (android.annotation.SuppressLint)3 Intent (android.content.Intent)3 GridView (android.widget.GridView)3 HeaderViewListAdapter (android.widget.HeaderViewListAdapter)3 ImageView (android.widget.ImageView)3 FlipViewController (com.aphidmobile.flip.FlipViewController)3 NumberTextView (com.aphidmobile.flip.demo.views.NumberTextView)3