Search in sources :

Example 26 with DataSetObserver

use of android.database.DataSetObserver in project facebook-android-sdk by facebook.

the class SelectionFragment method init.

/**
     * Resets the view to the initial defaults.
     */
private void init(Bundle savedInstanceState) {
    disableButtons();
    listElements = new ArrayList<BaseListElement>();
    listElements.add(new EatListElement(0));
    listElements.add(new LocationListElement(1));
    listElements.add(new PeopleListElement(2));
    listElements.add(new PhotoListElement(3));
    if (savedInstanceState != null) {
        for (BaseListElement listElement : listElements) {
            listElement.restoreState(savedInstanceState);
        }
        pendingAnnounce = savedInstanceState.getBoolean(PENDING_ANNOUNCE_KEY, false);
    }
    ActionListAdapter listAdapter = new ActionListAdapter(getActivity(), R.id.selection_list, listElements);
    listAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            updateShareContent();
        }
    });
    listView.setAdapter(listAdapter);
    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    if (accessToken != null) {
        profilePictureView.setProfileId(accessToken.getUserId());
    }
    updateShareContent();
}
Also used : DataSetObserver(android.database.DataSetObserver)

Example 27 with DataSetObserver

use of android.database.DataSetObserver in project ADWLauncher2 by boombuler.

the class LauncherActions method getSelectActionAdapter.

public ListAdapter getSelectActionAdapter() {
    final List<Action> mActions = getList();
    return new ListAdapter() {

        @Override
        public void unregisterDataSetObserver(DataSetObserver observer) {
        }

        @Override
        public void registerDataSetObserver(DataSetObserver observer) {
        }

        @Override
        public boolean isEmpty() {
            return mActions.isEmpty();
        }

        @Override
        public boolean hasStableIds() {
            return false;
        }

        @Override
        public int getViewTypeCount() {
            return 1;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                LayoutInflater li = mLauncher.getLayoutInflater();
                convertView = li.inflate(R.layout.add_list_item, parent, false);
            }
            Action act = mActions.get(position);
            TextView textView = (TextView) convertView;
            textView.setText(act.getName());
            textView.setCompoundDrawablesWithIntrinsicBounds(mLauncher.getResources().getDrawable(act.getIconResourceId()), null, null, null);
            return convertView;
        }

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

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

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

        @Override
        public int getCount() {
            return mActions.size();
        }

        @Override
        public boolean isEnabled(int position) {
            return true;
        }

        @Override
        public boolean areAllItemsEnabled() {
            return true;
        }
    };
}
Also used : ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) DataSetObserver(android.database.DataSetObserver) TextView(android.widget.TextView) View(android.view.View) ListAdapter(android.widget.ListAdapter)

Example 28 with DataSetObserver

use of android.database.DataSetObserver in project platform_frameworks_base by android.

the class CalendarViewLegacyDelegate method setUpAdapter.

/**
     * Creates a new adapter if necessary and sets up its parameters.
     */
private void setUpAdapter() {
    if (mAdapter == null) {
        mAdapter = new WeeksAdapter(mContext);
        mAdapter.registerDataSetObserver(new DataSetObserver() {

            @Override
            public void onChanged() {
                if (mOnDateChangeListener != null) {
                    Calendar selectedDay = mAdapter.getSelectedDay();
                    mOnDateChangeListener.onSelectedDayChange(mDelegator, selectedDay.get(Calendar.YEAR), selectedDay.get(Calendar.MONTH), selectedDay.get(Calendar.DAY_OF_MONTH));
                }
            }
        });
        mListView.setAdapter(mAdapter);
    }
    // refresh the view with the new parameters
    mAdapter.notifyDataSetChanged();
}
Also used : Calendar(android.icu.util.Calendar) DataSetObserver(android.database.DataSetObserver)

Example 29 with DataSetObserver

use of android.database.DataSetObserver in project plaid by nickbutcher.

the class InkPageIndicator method setViewPager.

public void setViewPager(ViewPager viewPager) {
    this.viewPager = viewPager;
    viewPager.addOnPageChangeListener(this);
    setPageCount(viewPager.getAdapter().getCount());
    viewPager.getAdapter().registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            setPageCount(InkPageIndicator.this.viewPager.getAdapter().getCount());
        }
    });
    setCurrentPageImmediate();
}
Also used : DataSetObserver(android.database.DataSetObserver)

Example 30 with DataSetObserver

use of android.database.DataSetObserver in project android_frameworks_base by ParanoidAndroid.

the class RecentsHorizontalScrollView method setAdapter.

public void setAdapter(TaskDescriptionAdapter adapter) {
    mAdapter = adapter;
    mAdapter.registerDataSetObserver(new DataSetObserver() {

        public void onChanged() {
            update();
        }

        public void onInvalidated() {
            update();
        }
    });
    DisplayMetrics dm = getResources().getDisplayMetrics();
    int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(dm.widthPixels, MeasureSpec.AT_MOST);
    int childheightMeasureSpec = MeasureSpec.makeMeasureSpec(dm.heightPixels, MeasureSpec.AT_MOST);
    View child = mAdapter.createView(mLinearLayout);
    child.measure(childWidthMeasureSpec, childheightMeasureSpec);
    mNumItemsInOneScreenful = (int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth());
    addToRecycledViews(child);
    for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) {
        addToRecycledViews(mAdapter.createView(mLinearLayout));
    }
}
Also used : DataSetObserver(android.database.DataSetObserver) DisplayMetrics(android.util.DisplayMetrics) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View)

Aggregations

DataSetObserver (android.database.DataSetObserver)36 View (android.view.View)14 AdapterView (android.widget.AdapterView)9 ImageView (android.widget.ImageView)9 TextView (android.widget.TextView)9 OnClickListener (android.view.View.OnClickListener)8 ListView (android.widget.ListView)8 Calendar (android.icu.util.Calendar)5 PrintManager (android.print.PrintManager)5 PrinterInfo (android.print.PrinterInfo)5 PrintServiceInfo (android.printservice.PrintServiceInfo)5 SearchView (android.widget.SearchView)5 Intent (android.content.Intent)3 Calendar (java.util.Calendar)3 Bitmap (android.graphics.Bitmap)2 DisplayMetrics (android.util.DisplayMetrics)2 ViewGroup (android.view.ViewGroup)2 ScrollView (android.widget.ScrollView)2 HowaboutApplication (io.recom.howabout.HowaboutApplication)2 ArrayList (java.util.ArrayList)2