Search in sources :

Example 41 with AbsListView

use of android.widget.AbsListView in project android_frameworks_base by crdroidandroid.

the class RenderSessionImpl method postInflateProcess.

/**
     * Post process on a view hierarchy that was just inflated.
     * <p/>
     * At the moment this only supports TabHost: If {@link TabHost} is detected, look for the
     * {@link TabWidget}, and the corresponding {@link FrameLayout} and make new tabs automatically
     * based on the content of the {@link FrameLayout}.
     * @param view the root view to process.
     * @param layoutlibCallback callback to the project.
     * @param skip the view and it's children are not processed.
     */
// For the use of Pair
@SuppressWarnings("deprecation")
private void postInflateProcess(View view, LayoutlibCallback layoutlibCallback, View skip) throws PostInflateException {
    if (view == skip) {
        return;
    }
    if (view instanceof TabHost) {
        setupTabHost((TabHost) view, layoutlibCallback);
    } else if (view instanceof QuickContactBadge) {
        QuickContactBadge badge = (QuickContactBadge) view;
        badge.setImageToDefault();
    } else if (view instanceof AdapterView<?>) {
        // get the view ID.
        int id = view.getId();
        BridgeContext context = getContext();
        // get a ResourceReference from the integer ID.
        ResourceReference listRef = context.resolveId(id);
        if (listRef != null) {
            SessionParams params = getParams();
            AdapterBinding binding = params.getAdapterBindings().get(listRef);
            // if there was no adapter binding, trying to get it from the call back.
            if (binding == null) {
                binding = layoutlibCallback.getAdapterBinding(listRef, context.getViewKey(view), view);
            }
            if (binding != null) {
                if (view instanceof AbsListView) {
                    if ((binding.getFooterCount() > 0 || binding.getHeaderCount() > 0) && view instanceof ListView) {
                        ListView list = (ListView) view;
                        boolean skipCallbackParser = false;
                        int count = binding.getHeaderCount();
                        for (int i = 0; i < count; i++) {
                            Pair<View, Boolean> pair = context.inflateView(binding.getHeaderAt(i), list, false, skipCallbackParser);
                            if (pair.getFirst() != null) {
                                list.addHeaderView(pair.getFirst());
                            }
                            skipCallbackParser |= pair.getSecond();
                        }
                        count = binding.getFooterCount();
                        for (int i = 0; i < count; i++) {
                            Pair<View, Boolean> pair = context.inflateView(binding.getFooterAt(i), list, false, skipCallbackParser);
                            if (pair.getFirst() != null) {
                                list.addFooterView(pair.getFirst());
                            }
                            skipCallbackParser |= pair.getSecond();
                        }
                    }
                    if (view instanceof ExpandableListView) {
                        ((ExpandableListView) view).setAdapter(new FakeExpandableAdapter(listRef, binding, layoutlibCallback));
                    } else {
                        ((AbsListView) view).setAdapter(new FakeAdapter(listRef, binding, layoutlibCallback));
                    }
                } else if (view instanceof AbsSpinner) {
                    ((AbsSpinner) view).setAdapter(new FakeAdapter(listRef, binding, layoutlibCallback));
                }
            }
        }
    } else if (view instanceof ViewGroup) {
        mInflater.postInflateProcess(view);
        ViewGroup group = (ViewGroup) view;
        final int count = group.getChildCount();
        for (int c = 0; c < count; c++) {
            View child = group.getChildAt(c);
            postInflateProcess(child, layoutlibCallback, skip);
        }
    }
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) TabHost(android.widget.TabHost) ViewGroup(android.view.ViewGroup) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) AbsListView(android.widget.AbsListView) FakeAdapter(com.android.layoutlib.bridge.impl.binding.FakeAdapter) FakeExpandableAdapter(com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListView(android.widget.ListView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) AbsListView(android.widget.AbsListView) ActionMenuView(android.widget.ActionMenuView) ExpandableListView(android.widget.ExpandableListView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView) QuickContactBadge(android.widget.QuickContactBadge) AdapterBinding(com.android.ide.common.rendering.api.AdapterBinding) AbsSpinner(android.widget.AbsSpinner) AdapterView(android.widget.AdapterView) ResourceReference(com.android.ide.common.rendering.api.ResourceReference) ExpandableListView(android.widget.ExpandableListView)

Example 42 with AbsListView

use of android.widget.AbsListView in project android_frameworks_base by AOSPA.

the class ResolverActivity method onPrepareAdapterView.

public void onPrepareAdapterView(AbsListView adapterView, ResolveListAdapter adapter, boolean alwaysUseOption) {
    final boolean useHeader = adapter.hasFilteredItem();
    final ListView listView = adapterView instanceof ListView ? (ListView) adapterView : null;
    adapterView.setAdapter(mAdapter);
    final ItemClickListener listener = new ItemClickListener();
    adapterView.setOnItemClickListener(listener);
    adapterView.setOnItemLongClickListener(listener);
    if (alwaysUseOption) {
        listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    }
    if (useHeader && listView != null) {
        listView.addHeaderView(LayoutInflater.from(this).inflate(R.layout.resolver_different_item_header, listView, false));
    }
}
Also used : ListView(android.widget.ListView) AbsListView(android.widget.AbsListView)

Example 43 with AbsListView

use of android.widget.AbsListView in project boilerplate by koush.

the class ScrollingToolbarLayout method enableToolbarScrollOff.

public void enableToolbarScrollOff(final IHeaderRecyclerView headerRecyclerView, final Fragment fragment) {
    scrollOffEnabled = true;
    int extra;
    View paddingView;
    if (getChildCount() == 3)
        paddingView = getChildAt(0);
    else
        paddingView = getChildAt(getChildCount() - 1);
    if (paddingView.getLayoutParams().height > 0) {
        extra = paddingView.getLayoutParams().height;
    } else {
        // apparently this is the max size allowed
        final int SIZE_MAX = 1073741823;
        paddingView.measure(MeasureSpec.makeMeasureSpec(SIZE_MAX, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(SIZE_MAX, MeasureSpec.AT_MOST));
        extra = paddingView.getMeasuredHeight();
    }
    AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, extra);
    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setLayoutParams(lp);
    headerRecyclerView.addHeaderView(0, frameLayout);
    headerRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView absListView, int scrollState) {
            // when scrolling stops, and the toolbar is only partially scrolled off, force to scroll bar in completely
            if (scrollState != RecyclerView.SCROLL_STATE_IDLE)
                return;
            if (absListView.getChildCount() < 1)
                return;
            int firstVisibleItem = headerRecyclerView.findFirstVisibleItemPosition();
            if (firstVisibleItem != 0)
                return;
            final View toolbarContainer = getChildAt(getChildCount() - 1);
            if (toolbarContainer.getTranslationY() <= -toolbarContainer.getHeight() || (existingToolbarYAnimation != null && existingToolbarYEnd <= toolbarContainer.getHeight()))
                return;
            toolbarScrollIn();
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (recyclerView.getChildCount() < 1)
                return;
            if (fragment != null && !fragment.getUserVisibleHint())
                return;
            // cancelToolbarScroll();
            final View firstView = recyclerView.getChildAt(0);
            final View toolbarContainer = getChildAt(getChildCount() - 1);
            final View backdrop;
            if (getChildCount() == 3)
                backdrop = getChildAt(0);
            else
                backdrop = null;
            final int toolbarHeight = toolbarContainer.getHeight();
            int firstVisibleItem = headerRecyclerView.findFirstVisibleItemPosition();
            if (backdrop != null) {
                int newBackdropHeight;
                int backdropHeight = getResources().getDimensionPixelSize(R.dimen.icon_list_drawer_activity_backdrop_height);
                if (firstVisibleItem >= 1) {
                    newBackdropHeight = toolbarHeight;
                } else {
                    newBackdropHeight = firstView.getTop() + backdropHeight;
                }
                newBackdropHeight = Math.max(newBackdropHeight, toolbarHeight);
                FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) backdrop.getLayoutParams();
                lp.height = newBackdropHeight;
                // another option is to use y translation to not do parallax
                backdrop.setLayoutParams(lp);
                if (newBackdropHeight / (float) backdropHeight < .5f) {
                    toolbarFadeToPrimary();
                } else {
                    toolbarFadeToTranslucent();
                }
            }
            if (firstVisibleItem == 0) {
                int remainder = firstView.getHeight() + firstView.getTop();
                // if there's less than toolbar height left, start scrolling off.
                if (remainder < toolbarHeight) {
                    remainder = toolbarHeight - remainder;
                    if (existingToolbarYAnimation == null) {
                        float diff = -remainder - toolbarContainer.getTranslationY();
                        if (false && Math.abs(diff) > toolbarHeight / 4) {
                            if (toolbarContainer.getTranslationY() < -remainder) {
                                // scrolling down
                                toolbarScrollIn();
                            } else {
                                // scrolling up
                                toolbarScrollOut();
                            }
                        } else {
                            toolbarContainer.setTranslationY(-remainder);
                        }
                    }
                    if (backdrop != null)
                        backdrop.setTranslationY(-remainder);
                } else {
                    cancelToolbarScroll();
                    toolbarContainer.setTranslationY(0);
                    // toolbarScrollIn();
                    if (backdrop != null)
                        backdrop.setTranslationY(0);
                }
                return;
            }
            if (firstVisibleItem == 1) {
                cancelToolbarScroll();
                toolbarContainer.setTranslationY(-toolbarHeight);
            } else {
                toolbarScrollOut();
            }
            if (backdrop != null)
                backdrop.setTranslationY(-toolbarHeight);
        }
    });
    if (getChildCount() == 3)
        toolbarFadeToTranslucent();
}
Also used : FrameLayout(android.widget.FrameLayout) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) IHeaderRecyclerView(com.koushikdutta.boilerplate.recyclerview.IHeaderRecyclerView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) IHeaderRecyclerView(com.koushikdutta.boilerplate.recyclerview.IHeaderRecyclerView)

Example 44 with AbsListView

use of android.widget.AbsListView in project android_packages_apps_Settings by LineageOS.

the class ListDialogPreference method onPrepareDialogBuilder.

@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder, DialogInterface.OnClickListener listener) {
    super.onPrepareDialogBuilder(builder, listener);
    final Context context = getContext();
    final int dialogLayout = getDialogLayoutResource();
    final View picker = LayoutInflater.from(context).inflate(dialogLayout, null);
    final ListPreferenceAdapter adapter = new ListPreferenceAdapter();
    final AbsListView list = (AbsListView) picker.findViewById(android.R.id.list);
    list.setAdapter(adapter);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
            if (callChangeListener((int) id)) {
                setValue((int) id);
            }
            final Dialog dialog = getDialog();
            if (dialog != null) {
                dialog.dismiss();
            }
        }
    });
    // Set initial selection.
    final int selectedPosition = getIndexForValue(mValue);
    if (selectedPosition != AbsListView.INVALID_POSITION) {
        list.setSelection(selectedPosition);
    }
    builder.setView(picker);
    builder.setPositiveButton(null, null);
}
Also used : Context(android.content.Context) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) AbsListView(android.widget.AbsListView) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 45 with AbsListView

use of android.widget.AbsListView in project Applozic-Android-SDK by AppLozic.

the class ChannelFragment method onActivityCreated.

@SuppressLint("NewApi")
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    shareButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, inviteMessage);
            List<Intent> targetedShareIntents = new ArrayList<Intent>();
            List<ResolveInfo> resInfo = getActivity().getPackageManager().queryIntentActivities(intent, 0);
            if (!resInfo.isEmpty()) {
                for (ResolveInfo resolveInfo : resInfo) {
                    String packageName = resolveInfo.activityInfo.packageName;
                    Intent targetedShareIntent = new Intent(Intent.ACTION_SEND);
                    targetedShareIntent.setType("text/plain").setAction(Intent.ACTION_SEND).putExtra(Intent.EXTRA_TEXT, inviteMessage).setPackage(packageName);
                    targetedShareIntents.add(targetedShareIntent);
                }
                Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Share Via");
                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {}));
                startActivity(chooserIntent);
            }
        }
    });
    setListAdapter(mAdapter);
    getListView().setOnItemClickListener(this);
    getListView().setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            mChannelImageLoader.setPauseWork(scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING);
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i1, int i2) {
        }
    });
    // the action bar search view (see onQueryTextChange() in onCreateOptionsMenu()).
    if (mPreviouslySelectedSearchItem == 0) {
        // Initialize the loader, and create a loader identified by ContactsQuery.QUERY_ID
        getLoaderManager().initLoader(QUERY_ID, null, this);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) ArrayList(java.util.ArrayList) List(java.util.List) SpannableString(android.text.SpannableString) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Aggregations

AbsListView (android.widget.AbsListView)218 View (android.view.View)126 ListView (android.widget.ListView)80 AdapterView (android.widget.AdapterView)54 TextView (android.widget.TextView)46 ViewGroup (android.view.ViewGroup)33 ImageView (android.widget.ImageView)29 RecyclerView (android.support.v7.widget.RecyclerView)21 GridView (android.widget.GridView)21 SuppressLint (android.annotation.SuppressLint)20 ScrollView (android.widget.ScrollView)20 OnScrollListener (android.widget.AbsListView.OnScrollListener)19 Intent (android.content.Intent)17 ArrayList (java.util.ArrayList)16 Context (android.content.Context)12 Point (android.graphics.Point)12 Handler (android.os.Handler)12 ExpandableListView (android.widget.ExpandableListView)12 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)10 ItemManager (org.lucasr.smoothie.ItemManager)10