List of usage examples for android.database DataSetObserver DataSetObserver
DataSetObserver
From source file:droidninja.filepicker.utils.TabLayoutHelper.java
/** * Constructor./*from w w w. j a va2s . co m*/ * * @param tabLayout TabLayout instance * @param viewPager ViewPager instance */ public TabLayoutHelper(@NonNull TabLayout tabLayout, @NonNull ViewPager viewPager) { PagerAdapter adapter = viewPager.getAdapter(); if (adapter == null) { throw new IllegalArgumentException("ViewPager does not have a PagerAdapter set"); } mTabLayout = tabLayout; mViewPager = viewPager; mInternalDataSetObserver = new DataSetObserver() { @Override public void onChanged() { // * This method is called when the entire data set has changed handleOnDataSetChanged(); } }; mInternalOnTabSelectedListener = new TabLayout.OnTabSelectedListener() { // ?? @Override public void onTabSelected(TabLayout.Tab tab) { handleOnTabSelected(tab); } // ? ?? @Override public void onTabUnselected(TabLayout.Tab tab) { handleOnTabUnselected(tab); } @Override public void onTabReselected(TabLayout.Tab tab) { handleOnTabReselected(tab); } }; mInternalTabLayoutOnPageChangeListener = new FixedTabLayoutOnPageChangeListener(mTabLayout); mInternalOnAdapterChangeListener = new ViewPager.OnAdapterChangeListener() { @Override public void onAdapterChanged(@NonNull ViewPager viewPager, @Nullable PagerAdapter oldAdapter, @Nullable PagerAdapter newAdapter) { handleOnAdapterChanged(viewPager, oldAdapter, newAdapter); } }; setupWithViewPager(mTabLayout, mViewPager); }
From source file:com.measuredsoftware.passvault.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w . j ava 2 s .c o m*/ passwordList = (PasswordList) findViewById(R.id.password_list); passwordList.setOnScrollListener(this); final PasswordListAdapter adapter = new PasswordListAdapter(this, passwordList); passwordList.setAdapter(adapter); passwordList.getAdapter().registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { if (dataModel.isEmpty()) { if (dataModel.getMode() == PasswordListAdapter.Mode.EDIT) { toggleEditMode(); } } dataModel.storePasswords(); updateEditButtonState(); } }); adapter.setEditItemListener(this); final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.sliding_drawer); dataModel = passwordList.getPasswordListAdapter(); addButton = findViewById(R.id.add_button); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { goToPasswordCreator(); } }); passwordList.setPasswordPopup((PasswordPopup) findViewById(R.id.password_popup)); final MenuScreen menuScreen = (MenuScreen) findViewById(R.id.menu_screen); menuScreen.setListener(this); for (UserPreferences.Options option : UserPreferences.Options.values()) { menuScreen.setOption(option.getViewId(), getUserPrefs().isOptionChecked(option)); } actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.openDrawer, R.string.closeDrawer); // Set the actionbarToggle to drawer layout drawerLayout.setDrawerListener(actionBarDrawerToggle); actionBarDrawerToggle.syncState(); navigationClickHandler = new NavigationClickHandler(dataModel, drawerLayout); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (navigationClickHandler.toggleEditModeOnClick(scrolling)) { toggleEditMode(); if (!scrolling) { actionBarDrawerToggle.syncState(); } } } }); getSupportActionBar().setDisplayShowHomeEnabled(true); }
From source file:com.qiscus.sdk.filepicker.util.TabLayoutHelper.java
/** * Constructor.//ww w. ja va2s .c o m * * @param tabLayout TabLayout instance * @param viewPager ViewPager instance */ public TabLayoutHelper(@NonNull TabLayout tabLayout, @NonNull ViewPager viewPager) { PagerAdapter adapter = viewPager.getAdapter(); if (adapter == null) { throw new IllegalArgumentException("ViewPager does not have a PagerAdapter set"); } this.tabLayout = tabLayout; this.viewPager = viewPager; internalDataSetObserver = new DataSetObserver() { @Override public void onChanged() { handleOnDataSetChanged(); } }; internalOnTabSelectedListener = new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { handleOnTabSelected(tab); } @Override public void onTabUnselected(TabLayout.Tab tab) { handleOnTabUnselected(tab); } @Override public void onTabReselected(TabLayout.Tab tab) { handleOnTabReselected(tab); } }; internalTabLayoutOnPageChangeListener = new FixedTabLayoutOnPageChangeListener(this.tabLayout); internalOnAdapterChangeListener = this::handleOnAdapterChanged; setupWithViewPager(this.tabLayout, this.viewPager); }
From source file:com.conferenceengineer.android.iosched.ui.ExploreFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); view.setBackgroundColor(Color.WHITE); final ListView listView = getListView(); listView.setSelector(android.R.color.transparent); listView.setCacheColorHint(Color.WHITE); mAdapter = new TracksAdapter(getActivity(), false); setListAdapter(mAdapter);/*from w w w . j a v a2 s . co m*/ // Override default ListView empty-view handling listView.setEmptyView(null); mEmptyView.setVisibility(View.VISIBLE); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { if (mAdapter.getCount() > 0) { mEmptyView.setVisibility(View.GONE); mAdapter.unregisterDataSetObserver(this); } } }); }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.ExploreFragment.java
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); view.setBackgroundColor(Color.WHITE); final ListView listView = getListView(); listView.setSelector(android.R.color.transparent); listView.setCacheColorHint(Color.WHITE); addMapHeaderView();/*from w ww . ja v a2 s . c om*/ mAdapter = new TracksAdapter(getActivity(), false); setListAdapter(mAdapter); // Override default ListView empty-view handling listView.setEmptyView(null); mEmptyView.setVisibility(View.VISIBLE); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { if (mAdapter.getCount() > 0) { mEmptyView.setVisibility(View.GONE); mAdapter.unregisterDataSetObserver(this); } } }); }
From source file:org.fedorahosted.freeotp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); onNewIntent(getIntent());// w w w. ja v a 2s. c o m setContentView(R.layout.main); mTokenAdapter = new TokenAdapter(this); ((GridView) findViewById(R.id.grid)).setAdapter(mTokenAdapter); // Don't permit screenshots since these might contain OTP codes. getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); mDataSetObserver = new DataSetObserver() { @Override public void onChanged() { super.onChanged(); if (mTokenAdapter.getCount() == 0) findViewById(android.R.id.empty).setVisibility(View.VISIBLE); else findViewById(android.R.id.empty).setVisibility(View.GONE); } }; mTokenAdapter.registerDataSetObserver(mDataSetObserver); tokenPersistence = new TokenPersistence(this); }
From source file:com.github.prdobby.gamekeeper.utils.views.SlidingTabLayout.java
public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);//from w w w.j a v a 2 s . com mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new SlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); this.mObserver = new DataSetObserver() { @Override public void onChanged() { super.onChanged(); populateTabStrip(); } @Override public void onInvalidated() { super.onInvalidated(); } }; }
From source file:com.example.nitish.welcomapp.activitypt.ElementListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.registerOnSharedPreferenceChangeListener(this); if (savedInstanceState != null) { mSort = savedInstanceState.getInt(KEY_SORT, mSort); mSortReverse = savedInstanceState.getBoolean(KEY_SORT_REVERSE, mSortReverse); mFilter = savedInstanceState.getString(KEY_FILTER); mActivatedItem = savedInstanceState.getLong(KEY_ACTIVATED_ITEM, mActivatedItem); }//ww w . j a va2s . c o m mAdapter = new ElementListAdapter(getContext()); mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); setActivatedPosition(mAdapter.getItemPosition(mActivatedItem)); } }); mAdapter.getFilter().filter(mFilter); mAdapter.setSort(mSort, mSortReverse); setListAdapter(mAdapter); setupFilter(); setupSort(); }
From source file:de.k3b.android.androFotoFinder.imagedetail.ImageDetailActivityViewPager.java
@Override public void onCreate(Bundle savedInstanceState) { debugPrefix = "ImageDetailActivityViewPager#" + (id++) + " "; Global.debugMemory(debugPrefix, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_view_pager); mViewPager = (LockableViewPager) findViewById(R.id.view_pager); setContentView(mViewPager);// w ww . ja va2 s. com // extra parameter this.mGalleryContentQuery = getIntent().getParcelableExtra(EXTRA_QUERY); if (mGalleryContentQuery == null) { Log.e(Global.LOG_CONTEXT, debugPrefix + " onCreate() : intent.extras[" + EXTRA_QUERY + "] not found. Using default."); mGalleryContentQuery = FotoSql.getQuery(FotoSql.QUERY_TYPE_DEFAULT); } else if (Global.debugEnabled) { Log.e(Global.LOG_CONTEXT, debugPrefix + " onCreate() : query = " + mGalleryContentQuery); } mAdapter = new ImagePagerAdapterFromCursor(this, mGalleryContentQuery, debugPrefix); loadCompleteHandler = new DataSetObserver() { @Override public void onChanged() { super.onChanged(); onLoadCompleted(); } }; mAdapter.registerDataSetObserver(loadCompleteHandler); mViewPager.setAdapter(mAdapter); this.mInitialPosition = getIntent().getIntExtra(EXTRA_POSITION, this.mInitialPosition); if (savedInstanceState != null) { mInitialPosition = savedInstanceState.getInt(INSTANCE_STATE_LAST_SCROLL_POSITION, this.mInitialPosition); } }
From source file:jp.co.rediscovery.firstflight.PhotoFragment.java
private void initView(final View rootView) { mViewPager = rootView.findViewById(R.id.viewpager); mViewPager.setKeepScreenOn(true);//w w w .j av a 2 s .c o m mAdapter = new MediaStoreImageAdapter(getActivity(), R.layout.grid_item_media, false); // MediaStoreImageAdapter?Cursor??????? // ???0?????ViewPager#setAdapter? mAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { super.onChanged(); mViewPager.setAdapter(mAdapter); mViewPager.setCurrentItem(mAdapter.getItemPositionFromID(mId)); mAdapter.unregisterDataSetObserver(this); // ????OK???? } @Override public void onInvalidated() { super.onInvalidated(); } }); mAdapter.startQuery(); // ?? }