public void setAdapter(MyScheduleAdapter adapter) { if (mAdapter != null && mObserver != null) { mAdapter.unregisterDataSetObserver(mObserver); mObserver = null; } mAdapter = adapter; rebuild(); if (mAdapter != null) { mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { rebuild(); } @Override public void onInvalidated() { setAdapter(null); } }); } }
private void init() { mDataSetObserver = new DataSetObserver() { @Override public void onChanged() { removeAllViews(); for (int i = 0; i < mRadioAdapter.getCount(); i++) { RadioButton radioButton = mRadioAdapter.getRadioButton(i); addView(radioButton); } setCurrentItem(0); } @Override public void onInvalidated() { super.onInvalidated(); } }; mRadioAdapter = new MyRadioAdapter(null); mRadioAdapter.setViewPagerObserver(mDataSetObserver); }
/** * @see ListView#setAdapter(ListAdapter) */ @Override public void setAdapter(ListAdapter adapter) { super.setAdapter(adapter); if (isDropDownStyle) { setSecondPositionVisible(); } touchListener.resetItems(); adapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); onListChanged(); touchListener.resetItems(); } }); }
private void initView() { gridView = findViewById(R.id.grid); mToolbar = findViewById(R.id.topbar); setSupportActionBar(mToolbar); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); setTitle(getIntent().getStringExtra(MediaSetUtils.SET_NAME)); mAdapter = new TimeLineAdapter(this); mAdapter.setDecodeSize(decodeBitmapWidth); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); } }); gridView.setAdapter(mAdapter); gridView.setOnItemClickListener(this); }
@Override public void registerDataSetObserver(DataSetObserver observer) { if (datasetObservers == null) { datasetObservers = new LinkedList<DataSetObserver>(); } datasetObservers.add(observer); }
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); myCalendar = (Calendar) savedInstanceState.getSerializable("calendar"); hasReminder = savedInstanceState.getBoolean("hasReminder"); items = (ArrayList<ListItem>) savedInstanceState.getSerializable("items"); adapter = new ListItemArrayAdapter(this, items); add_list_values.setAdapter(adapter); adapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); int totalHeight = 0; for (int i = 0; i < adapter.getCount(); i++) { View listItem = adapter.getView(i, null, add_list_values); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = add_list_values.getLayoutParams(); params.height = totalHeight + (add_list_values.getDividerHeight() * (adapter.getCount() - 1)); add_list_values.setLayoutParams(params); add_list_values.requestLayout(); } }); adapter.notifyDataSetChanged(); }
/** * Notifies observers about invalidating data */ protected void notifyDataInvalidatedEvent() { if (datasetObservers != null) { for (DataSetObserver observer : datasetObservers) { observer.onInvalidated(); } } }
protected void notifyDataInvalidatedEvent() { if (this.datasetObservers != null) { for (DataSetObserver observer : this.datasetObservers) { observer.onInvalidated(); } } }
/** * Notifies observers about data changing */ protected void notifyDataChangedEvent() { if (datasetObservers != null) { for (DataSetObserver observer : datasetObservers) { observer.onChanged(); } } }
@Override public void unregisterDataSetObserver(DataSetObserver observer) { int length = mCursors.length; for (int i = 0 ; i < length ; i++) { if (mCursors[i] != null) { mCursors[i].unregisterDataSetObserver(observer); } } }
public AdapterWrapper(ListAdapter adapter) { super(); mAdapter = adapter; mAdapter.registerDataSetObserver(new DataSetObserver() { public void onChanged() { notifyDataSetChanged(); } public void onInvalidated() { notifyDataSetInvalidated(); } }); }
@Override public void setViewPagerObserver(DataSetObserver observer) { super.setViewPagerObserver(observer); if (observer == null) { wrapperViewPager(mViewPager, this); } }
CBLoopPagerAdapterWrapper(PagerAdapter adapter) { this.mAdapter = adapter; adapter.registerDataSetObserver(new DataSetObserver(){ public void onChanged(){ notifyDataSetChanged(); } }); }
public PagerTabsIndicator(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setHorizontalScrollBarEnabled(false); tabsContainer = new LinearLayout(getContext()); addView(tabsContainer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); //Load default dimens textSize = getContext().getResources().getDimensionPixelSize(R.dimen.tab_default_text_size); indicatorHeight = getContext().getResources().getDimensionPixelSize(R.dimen.tab_default_indicator_height); indicatorBgHeight = getContext().getResources().getDimensionPixelSize(R.dimen.tab_default_indicator_bg_height); dividerWidth = getContext().getResources().getDimensionPixelSize(R.dimen.tab_default_divider_width); dividerMargin = getContext().getResources().getDimensionPixelSize(R.dimen.tab_default_divider_margin); //Load default colors textColor = getResources().getColor(R.color.tab_default_text_color); indicatorColor = getResources().getColor(R.color.tab_indicator_color); highlightTextColor = indicatorColor; indicatorBgColor = getResources().getColor(R.color.tab_indicator_bg_color); dividerColor = getResources().getColor(R.color.tab_default_divider_color); tabPadding = getResources().getDimensionPixelSize(R.dimen.tab_default_padding); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PagerTabsIndicator); tabPadding = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_padding, tabPadding); textSize = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_text_size, textSize); textColor = typedArray.getColor(R.styleable.PagerTabsIndicator_tab_text_color, textColor); highlightTextColor = typedArray.getColor(R.styleable.PagerTabsIndicator_tab_highlight_text_color, highlightTextColor); highlightText = typedArray.getBoolean(R.styleable.PagerTabsIndicator_tab_highlight_text_color, highlightText); showDivider = typedArray.getBoolean(R.styleable.PagerTabsIndicator_tab_show_divider, showDivider); lockExpanded = typedArray.getBoolean(R.styleable.PagerTabsIndicator_tab_lock_expanded, lockExpanded); indicatorType = typedArray.getInt(R.styleable.PagerTabsIndicator_tab_indicator, indicatorType); indicatorResource = typedArray.getResourceId(R.styleable.PagerTabsIndicator_tab_indicator_resource, indicatorResource); indicatorHeight = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_indicator_height, indicatorHeight); indicatorBgHeight = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_indicator_bg_height, indicatorBgHeight); indicatorMargin = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_indicator_margin, indicatorMargin); indicatorColor = typedArray.getColor(R.styleable.PagerTabsIndicator_tab_indicator_color, indicatorColor); indicatorBgColor = typedArray.getColor(R.styleable.PagerTabsIndicator_tab_indicator_bg_color, indicatorBgColor); dividerWidth = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_divider_width, dividerWidth); dividerMargin = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_divider_margin, dividerMargin); dividerColor = typedArray.getColor(R.styleable.PagerTabsIndicator_tab_divider_color, dividerColor); dividerResource = typedArray.getResourceId(R.styleable.PagerTabsIndicator_tab_divider_resource, dividerResource); showBarIndicator = typedArray.getBoolean(R.styleable.PagerTabsIndicator_tab_show_bar_indicator, showBarIndicator); tabElevation = typedArray.getDimensionPixelSize(R.styleable.PagerTabsIndicator_tab_elevation, tabElevation); indicatorScaleType = typedArray.getInt(R.styleable.PagerTabsIndicator_tab_indicator_scale_type, indicatorScaleType); disableTabAnimation = typedArray.getBoolean(R.styleable.PagerTabsIndicator_tab_disable_animation, disableTabAnimation); typedArray.recycle(); prepareResources(); adapterObserver = new DataSetObserver() { @Override public void onChanged() { notifyDatasetChanged(); } @Override public void onInvalidated() { super.onInvalidated(); } }; }
@Override public void registerDataSetObserver(DataSetObserver observer) { mAdapter.registerDataSetObserver(observer); }
@Override public void unregisterDataSetObserver(DataSetObserver observer) { if (observer != null) { super.unregisterDataSetObserver(observer); } }
public void registerDataSetObserver(DataSetObserver observer) { this.mObservable.registerObserver(observer); }
@Override public void unregisterDataSetObserver(DataSetObserver observer) { if (datasetObservers != null) { datasetObservers.remove(observer); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_list); ButterKnife.bind(this); setTitle(getString(R.string.add_list_title)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); myCalendar = Calendar.getInstance(); items = new ArrayList<>(); adapter = new ListItemArrayAdapter(this, items); add_list_values.setAdapter(adapter); add_list_content.setImeOptions(EditorInfo.IME_ACTION_DONE); adapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); int totalHeight = 0; for (int i = 0; i < adapter.getCount(); i++) { View listItem = adapter.getView(i, null, add_list_values); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = add_list_values.getLayoutParams(); params.height = totalHeight + (add_list_values.getDividerHeight() * (adapter.getCount() - 1)); add_list_values.setLayoutParams(params); add_list_values.requestLayout(); } }); date = new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { myCalendar.set(Calendar.YEAR, year); myCalendar.set(Calendar.MONTH, monthOfYear); myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); new TimePickerDialog(AddListActivity.this, time, myCalendar.get(Calendar.HOUR_OF_DAY), myCalendar.get(Calendar.MINUTE), true).show(); } }; time = new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int hour, int minute) { myCalendar.set(Calendar.HOUR_OF_DAY, hour); myCalendar.set(Calendar.MINUTE, minute); if (myCalendar.getTime().before(Calendar.getInstance().getTime())) Toast.makeText(AddListActivity.this, getString(R.string.provide_valid_date_time), Toast.LENGTH_LONG).show(); else updateRemind(true); } }; }
public void unregisterDataSetObserver(DataSetObserver observer) { if (this.mAdapter != null) { this.mAdapter.unregisterDataSetObserver(observer); } }
public void unregisterDataSetObserver(DataSetObserver observer) { mDataSetObservable.unregisterObserver(observer); }