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