List of usage examples for android.support.v4.content Loader isReset
public boolean isReset()
From source file:de.aw.awlib.database.AWLoaderManagerEngine.java
/** * Initialisiert oder restartet einen Loader. * * @param loaderID/*w ww . j a va2s . c o m*/ * id des loaders, der (nach-) gestartet werden soll</br> * @param args * Argumente fuer Cursor */ public void startOrRestartLoader(int loaderID, Bundle args) { Loader<Cursor> loader = mLoaderManager.getLoader(loaderID); if (loader != null && !loader.isReset()) { mLoaderManager.restartLoader(loaderID, args, this); } else { mLoaderManager.initLoader(loaderID, args, this); } }
From source file:de.aw.monma.views.SpinnerAccount.java
private void startOrRestartLoader(int loaderID) { AWApplication.Log("SpinnerAccount: Loading Cursor"); if (mLoaderManager != null) { Loader<Cursor> loader = mLoaderManager.getLoader(loaderID); if (loader != null && !loader.isReset()) { mLoaderManager.initLoader(loaderID, null, this); } else {/*from ww w .j a v a2 s. c o m*/ mLoaderManager.restartLoader(loaderID, null, this); } } }
From source file:com.rsegismont.androlife.programlist.FragmentListProgrammes.java
public void onActivityCreated(Bundle paramBundle) { super.onActivityCreated(paramBundle); final Loader<Cursor> localLoader = getLoaderManager().getLoader(0); if ((localLoader != null) && (!localLoader.isReset())) { getLoaderManager().restartLoader(this.mType, null, this); } else {//ww w . ja v a 2 s . c om getLoaderManager().initLoader(this.mType, null, this); } }
From source file:com.ze.client.projecto.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Projecto.from(this).getComponent().inject(this); if (mPreferences.isKeepScreenOn()) getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar);// w w w. j a v a 2 s .c om if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); mList = new ArrayList<>(); Loader<Object> loader = getSupportLoaderManager().getLoader(LOADER); if (loader != null && !loader.isReset()) { restartLoader(LOADER, null, this); } else { initLoader(LOADER, null, this); } mPreferences.registerOnSharedPreferenceChangeListener(this); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout); mTextViewStatus = (TextView) findViewById(R.id.text_view_status); mInfoLayout = (ConstraintLayout) findViewById(R.id.info_layout); mPowerSwitch = (SwitchCompat) findViewById(R.id.projector_power); mButtonPictureMute = (Button) findViewById(R.id.button_picture_mute); mProjectorsSpinner = (Spinner) findViewById(R.id.spinner_projectors); mProjectorsSpinnerCaption = (TextView) findViewById(R.id.text_view_projector_spinner_caption); if (mProjectorsSpinner != null) mProjectorsSpinner.setOnItemSelectedListener(this); if (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.INTERNET)) { Snackbar.make(mCoordinatorLayout, R.string.message_network_permission, Snackbar.LENGTH_LONG).show(); } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.INTERNET }, PERMISSIONS_REQUEST_INTERNET); } } else { mPermission = true; } mProjectorStrategyContext = new ProjectorStrategyContext(); refresh(); refreshGui(mProjectorStrategyContext.getStrategy().getPowerStatus(), mProjectorStrategyContext.getStrategy().getPictureMuteStatus()); refreshState(); setPowerChangeListener(); if (mButtonPictureMute != null) { mButtonPictureMute.setOnClickListener(view -> { if (mPermission) mProjectorStrategyContext.togglePictureMute(); }); } }
From source file:org.bwgz.quotation.activity.QuotationActivity.java
private <T> void initLoader(LoaderManager loaderManager, int loaderId, Bundle args, LoaderCallbacks<T> callbacks) { final Loader<T> loader = loaderManager.getLoader(loaderId); if (loader == null || loader.isReset()) { Log.d(TAG, String.format("initLoader - initLoader: %d", loaderId)); loaderManager.initLoader(loaderId, args, callbacks); } else {/*ww w . j ava2 s. c om*/ Log.d(TAG, String.format("initLoader - restartLoader: %d", loaderId)); loaderManager.restartLoader(loaderId, args, callbacks); } }
From source file:de.grobox.transportr.departures.DeparturesActivity.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();/*from w w w .j a v a 2 s .com*/ location = (WrapLocation) intent.getSerializableExtra(WRAP_LOCATION); if (location == null || location.getLocation() == null) throw new IllegalArgumentException("No Location"); setContentView(R.layout.activity_departures); // Toolbar Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setSubtitle(location.getName()); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } // Swipe to Refresh swipe = findViewById(R.id.swipe); swipe.setColorSchemeResources(R.color.accent); swipe.setDirection(SwipyRefreshLayoutDirection.BOTH); swipe.setDistanceToTriggerSync(getDragDistance(this)); swipe.setOnRefreshListener(direction -> loadMoreDepartures(direction != TOP)); swipe.setEnabled(false); // Departures List adapter = new DepartureAdapter(); list = findViewById(R.id.list); list.setVisibility(INVISIBLE); list.setAdapter(adapter); list.setLayoutManager(new LinearLayoutManager(this)); // Loader Bundle args = getBundle(location.getId(), new Date(), MAX_DEPARTURES); Loader<QueryDeparturesResult> loader = getSupportLoaderManager().initLoader(LOADER_DEPARTURES, args, this); // Progress Bar and Error View progressBar = findViewById(R.id.progressBar); errorLayout = findViewById(R.id.errorLayout); errorText = errorLayout.findViewById(R.id.errorText); errorLayout.findViewById(R.id.errorButton).setOnClickListener(view -> { LceAnimator.showLoading(progressBar, list, errorLayout); getSupportLoaderManager().restartLoader(LOADER_DEPARTURES, args, this).forceLoad(); }); if (loader.isReset()) { LceAnimator.showLoading(progressBar, list, errorLayout); loader.forceLoad(); } if (savedInstanceState != null) { calendar = (Calendar) savedInstanceState.getSerializable(DATE); // re-attach fragment listener List<Fragment> fragments = getSupportFragmentManager().getFragments(); if (fragments != null && fragments.size() > 0 && fragments.get(0) instanceof TimeDateFragment) { ((TimeDateFragment) fragments.get(0)).setTimeDateListener(this); } } }