Java Code Examples for android.database.DataSetObserver

The following are top voted examples for showing how to use android.database.DataSetObserver. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: iosched-reader   File: MyScheduleView.java   View source code 6 votes vote down vote up
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);
            }
        });
    }
}
 
Example 2
Project: TextEmoji   File: AdaptableRadioGroup.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: youkes_browser   File: SwipeListView.java   View source code 6 votes vote down vote up
/**
 * @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();
        }
    });
}
 
Example 4
Project: browser   File: SwipeListView.java   View source code 6 votes vote down vote up
/**
 * @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();
        }
    });
}
 
Example 5
Project: PictureShow   File: AlbumPage.java   View source code 6 votes vote down vote up
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);
}
 
Example 6
Project: mupdf-android-viewer-nui   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example 7
Project: Note   File: AddListActivity.java   View source code 5 votes vote down vote up
@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();
}
 
Example 8
Project: decoy   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example 9
Project: boohee_v5.6   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
protected void notifyDataInvalidatedEvent() {
    if (this.datasetObservers != null) {
        for (DataSetObserver observer : this.datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example 10
Project: GitHub   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onChanged();
        }
    }
}
 
Example 11
Project: PictureShow   File: MyMergeSortCursor.java   View source code 5 votes vote down vote up
@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);
        }
    }
}
 
Example 12
Project: mupdf-android-viewer-nui   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example 13
Project: TripBuyer   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example 14
Project: ultrasonic   File: DragSortListView.java   View source code 5 votes vote down vote up
public AdapterWrapper(ListAdapter adapter) {
    super();
    mAdapter = adapter;
    
    mAdapter.registerDataSetObserver(new DataSetObserver() {
        public void onChanged() {
            notifyDataSetChanged();
        }

        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
}
 
Example 15
Project: AssistantBySDK   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example 16
Project: AssistantBySDK   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onChanged();
        }
    }
}
 
Example 17
Project: AssistantBySDK   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example 18
Project: SmartRefresh   File: RefreshContentWrapper.java   View source code 5 votes vote down vote up
@Override
public void setViewPagerObserver(DataSetObserver observer) {
    super.setViewPagerObserver(observer);
    if (observer == null) {
        wrapperViewPager(mViewPager, this);
    }
}
 
Example 19
Project: SlotNSlot_Android   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example 20
Project: Hotspot-master-devp   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example 21
Project: SlotNSlot_Android   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onChanged();
        }
    }
}
 
Example 22
Project: Mybilibili   File: CBLoopPagerAdapterWrapper.java   View source code 5 votes vote down vote up
CBLoopPagerAdapterWrapper(PagerAdapter adapter) {
    this.mAdapter = adapter;
    adapter.registerDataSetObserver(new DataSetObserver(){
        public void onChanged(){
            notifyDataSetChanged();
        }
    });
}
 
Example 23
Project: Hotspot-master-devp   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
	if (datasetObservers == null) {
		datasetObservers = new LinkedList<DataSetObserver>();
	}
	datasetObservers.add(observer);
}
 
Example 24
Project: Hotspot-master-devp   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
	if (datasetObservers != null) {
		for (DataSetObserver observer : datasetObservers) {
			observer.onChanged();
		}
	}
}
 
Example 25
Project: Hotspot-master-devp   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
	if (datasetObservers != null) {
		for (DataSetObserver observer : datasetObservers) {
			observer.onInvalidated();
		}
	}
}
 
Example 26
Project: SlotNSlot_Android   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example 27
Project: NoticeDog   File: DragSortListView.java   View source code 5 votes vote down vote up
public AdapterWrapper(ListAdapter adapter) {
    super();
    mAdapter = adapter;

    mAdapter.registerDataSetObserver(new DataSetObserver() {
        public void onChanged() {
            notifyDataSetChanged();
        }

        public void onInvalidated() {
            notifyDataSetInvalidated();
        }
    });
}
 
Example 28
Project: CoolClock   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
    if (datasetObservers == null) {
        datasetObservers = new LinkedList<DataSetObserver>();
    }
    datasetObservers.add(observer);
}
 
Example 29
Project: CoolClock   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about data changing
 */
protected void notifyDataChangedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onChanged();
        }
    }
}
 
Example 30
Project: CoolClock   File: AbstractWheelAdapter.java   View source code 5 votes vote down vote up
/**
 * Notifies observers about invalidating data
 */
protected void notifyDataInvalidatedEvent() {
    if (datasetObservers != null) {
        for (DataSetObserver observer : datasetObservers) {
            observer.onInvalidated();
        }
    }
}
 
Example 31
Project: PagerTabIndicator   File: PagerTabsIndicator.java   View source code 4 votes vote down vote up
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();
        }
    };
}
 
Example 32
Project: GongXianSheng   File: SwipeMenuAdapter.java   View source code 4 votes vote down vote up
@Override
public void registerDataSetObserver(DataSetObserver observer) {
	mAdapter.registerDataSetObserver(observer);
}
 
Example 33
Project: KrGallery   File: BaseFragmentAdapter.java   View source code 4 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    if (observer != null) {
        super.unregisterDataSetObserver(observer);
    }
}
 
Example 34
Project: boohee_v5.6   File: PagerAdapter.java   View source code 4 votes vote down vote up
public void registerDataSetObserver(DataSetObserver observer) {
    this.mObservable.registerObserver(observer);
}
 
Example 35
Project: GitHub   File: AbstractWheelAdapter.java   View source code 4 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    if (datasetObservers != null) {
        datasetObservers.remove(observer);
    }
}
 
Example 36
Project: Note   File: AddListActivity.java   View source code 4 votes vote down vote up
@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);
        }
    };
}
 
Example 37
Project: boohee_v5.6   File: PLA_HeaderViewListAdapter.java   View source code 4 votes vote down vote up
public void unregisterDataSetObserver(DataSetObserver observer) {
    if (this.mAdapter != null) {
        this.mAdapter.unregisterDataSetObserver(observer);
    }
}
 
Example 38
Project: GitHub   File: CommonAdapter.java   View source code 4 votes vote down vote up
public void unregisterDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.unregisterObserver(observer);
}
 
Example 39
Project: PlusGram   File: BaseFragmentAdapter.java   View source code 4 votes vote down vote up
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
    if (observer != null) {
        super.unregisterDataSetObserver(observer);
    }
}
 
Example 40
Project: GitHub   File: BaseRecyclerAdapter.java   View source code 4 votes vote down vote up
public void unregisterDataSetObserver(DataSetObserver observer) {
    mDataSetObservable.unregisterObserver(observer);
}