Java 类android.support.v4.content.Loader 实例源码

项目:aos-Video    文件:VideoInfoActivityFragment.java   
@Override
public Loader onCreateLoader(int id, Bundle args) {
    // If we don't have the video object
    if(mCurrentVideo==null){
        if(mVideoIdFromPlayer!=-1){
            return new SingleVideoLoader(getActivity(),mVideoIdFromPlayer).getV4CursorLoader(true, false);
        }
        if(mPath!=null){
            return new SingleVideoLoader(getActivity(),mPath).getV4CursorLoader(true, false);
        }
    }
    else {
        if (mCurrentVideo.isIndexed()) {
            return new MultipleVideoLoader(getActivity(), mCurrentVideo.getId()).getV4CursorLoader(true, false);
        } else {
            return new MultipleVideoLoader(getActivity(), mCurrentVideo.getFilePath()).getV4CursorLoader(true, false);
        }
    }
    return null;
}
项目:orgzly-android    文件:SearchFragment.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, loader, cursor);

    if (mListAdapter == null) {
        if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "adapter is null, view is destroyed?");
        return;
    }

    /*
     * Swapping instead of changing Cursor here, to keep the old one open.
     * Loader should release the old Cursor - see note in
     * {@link LoaderManager.LoaderCallbacks#onLoadFinished).
     */
    mListAdapter.swapCursor(cursor);

    mActionModeListener.updateActionModeForSelection(mSelection.getCount(), new MyActionMode());

    if (mListAdapter.getCount() > 0) {
        mViewFlipper.setDisplayedChild(0);
    } else {
        mViewFlipper.setDisplayedChild(1);
    }
}
项目:boohee_v5.6    文件:LoaderManagerImpl.java   
public <D> Loader<D> initLoader(int id, Bundle args, LoaderCallbacks<D> callback) {
    if (this.mCreatingLoader) {
        throw new IllegalStateException("Called while creating a loader");
    }
    LoaderInfo info = (LoaderInfo) this.mLoaders.get(id);
    if (DEBUG) {
        Log.v(TAG, "initLoader in " + this + ": args=" + args);
    }
    if (info == null) {
        info = createAndInstallLoader(id, args, callback);
        if (DEBUG) {
            Log.v(TAG, "  Created new loader " + info);
        }
    } else {
        if (DEBUG) {
            Log.v(TAG, "  Re-using existing loader " + info);
        }
        info.mCallbacks = callback;
    }
    if (info.mHaveData && this.mStarted) {
        info.callOnLoadFinished(info.mLoader, info.mData);
    }
    return info.mLoader;
}
项目:letv    文件:LoaderManagerImpl.java   
void callOnLoadFinished(Loader<Object> loader, Object data) {
    if (this.mCallbacks != null) {
        String lastBecause = null;
        if (LoaderManagerImpl.this.mHost != null) {
            lastBecause = LoaderManagerImpl.this.mHost.mFragmentManager.mNoTransactionsBecause;
            LoaderManagerImpl.this.mHost.mFragmentManager.mNoTransactionsBecause = "onLoadFinished";
        }
        try {
            if (LoaderManagerImpl.DEBUG) {
                Log.v(LoaderManagerImpl.TAG, "  onLoadFinished in " + loader + ": " + loader.dataToString(data));
            }
            this.mCallbacks.onLoadFinished(loader, data);
            this.mDeliveredData = true;
        } finally {
            if (LoaderManagerImpl.this.mHost != null) {
                LoaderManagerImpl.this.mHost.mFragmentManager.mNoTransactionsBecause = lastBecause;
            }
        }
    }
}
项目:android-dev-challenge    文件:DetailActivity.java   
/**
 * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor.
 *
 * @param loaderId The loader ID for which we need to create a loader
 * @param loaderArgs Any arguments supplied by the caller
 *
 * @return A new Loader instance that is ready to start loading.
 */
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) {

    switch (loaderId) {

        case ID_DETAIL_LOADER:

            return new CursorLoader(this,
                    mUri,
                    WEATHER_DETAIL_PROJECTION,
                    null,
                    null,
                    null);

        default:
            throw new RuntimeException("Loader Not Implemented: " + loaderId);
    }
}
项目:TransLinkMe-App    文件:LocationFragment.java   
@Override
public Loader<List<BusStop>> onCreateLoader(int id, Bundle args) {
    Uri.Builder realTimeTransitInformationBuilder = new Uri.Builder();

    realTimeTransitInformationBuilder.scheme("https")
            .authority("api.translink.ca")
            .appendPath("rttiapi")
            .appendPath("v1")
            .appendPath("stops")
            .appendQueryParameter("apikey", TRANSLINK_OPEN_API_KEY)
            .appendQueryParameter("lat", String.format(Locale.CANADA, "%.4f", mLastLocation.getLatitude()))
            .appendQueryParameter("long", String.format(Locale.CANADA, "%.4f", mLastLocation.getLongitude()))
            .appendQueryParameter("radius", "200");

    Log.d(LOG_TAG, realTimeTransitInformationBuilder.build().toString());

    return new BusStopRadiusLoader(
            getActivity(),
            realTimeTransitInformationBuilder.build().toString());
}
项目:Android_Sunshine_Watch    文件:MainActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {

    switch (loaderId) {

        case ID_FORECAST_LOADER:
            Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI;
            String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
            String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards();

            return new CursorLoader(this,
                    forecastQueryUri,
                    MAIN_FORECAST_PROJECTION,
                    selection,
                    null,
                    sortOrder);

        default:
            throw new RuntimeException("Loader Not Implemented: " + loaderId);
    }
}
项目:GitJourney    文件:MainViewFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    int numberOfDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    Calendar newCalendar = (Calendar) calendar.clone();
    newCalendar.set(Calendar.DAY_OF_MONTH, 1);
    newCalendar.set(Calendar.HOUR_OF_DAY, 0);
    newCalendar.set(Calendar.MINUTE, 0);
    newCalendar.set(Calendar.SECOND, 0);
    Log.v(TAG, "numberOfDays = " + numberOfDays);
    long minDate = newCalendar.getTimeInMillis();
    newCalendar.set(Calendar.DAY_OF_MONTH, numberOfDays);
    newCalendar.set(Calendar.HOUR_OF_DAY, 23);
    newCalendar.set(Calendar.MINUTE, 59);
    newCalendar.set(Calendar.SECOND, 59);
    long maxDate = newCalendar.getTimeInMillis();
    return ContributionsDataLoader.newRangeLoader(getContext(), minDate, maxDate);
}
项目:android-dev-challenge    文件:DetailActivity.java   
/**
 * Creates and returns a CursorLoader that loads the data for our URI and stores it in a Cursor.
 *
 * @param loaderId The loader ID for which we need to create a loader
 * @param loaderArgs Any arguments supplied by the caller
 *
 * @return A new Loader instance that is ready to start loading.
 */
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle loaderArgs) {

    switch (loaderId) {

        case ID_DETAIL_LOADER:

            return new CursorLoader(this,
                    mUri,
                    WEATHER_DETAIL_PROJECTION,
                    null,
                    null,
                    null);

        default:
            throw new RuntimeException("Loader Not Implemented: " + loaderId);
    }
}
项目:CSipSimple    文件:AccountFiltersListFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
     return new CursorLoader(getActivity(), SipManager.FILTER_URI, new String[] {
        BaseColumns._ID,
        Filter.FIELD_ACCOUNT,
           Filter.FIELD_ACTION,
           Filter.FIELD_MATCHES,
        Filter.FIELD_PRIORITY,
        Filter.FIELD_REPLACE
     }, Filter.FIELD_ACCOUNT + "=?", new String[] {Long.toString(accountId)}, Filter.DEFAULT_ORDER);

}
项目:TVGuide    文件:ProgramsTabsFragment.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (loader.getId() == CONTENT_LOADER) {
        if (data != null && isAdded()) {
            viewPagerAdapter = new ChannelsViewPagerAdapter(getActivity(), getChildFragmentManager());
            viewPagerAdapter.swapCursor(data);
            if (viewPager != null) {
                viewPager.setAdapter(viewPagerAdapter);
                tabLayout.setupWithViewPager(viewPager);
                viewPager.setCurrentItem(selectedTabPosition);
            }
        }
    }
}
项目:face-landmark-android    文件:MediaLoaderCallback.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null) {
        if (data.getCount() > 0) {
            RealmList<ImageBean> realmList = new RealmList<>();
            data.moveToFirst();
            do {
                String path = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[0]));
                String name = data.getString(data.getColumnIndexOrThrow(IMAGE_PROJECTION[1]));
                long dateTime = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[2]));
                long id = data.getLong(data.getColumnIndexOrThrow(IMAGE_PROJECTION[5]));
                if (fileExist(path)) {
                    ImageBean bean = new ImageBean();
                    bean.setId(id);
                    bean.setPath(path);
                    bean.setName(name);
                    bean.setDate(dateTime);
                    realmList.add(bean);
                }

            } while (data.moveToNext());

            if (onLoadFinishedListener != null) {
                onLoadFinishedListener.onLoadFinished(realmList);
            }
        }
    }
}
项目:MyAnimeViewer    文件:FavoritesFragment.java   
@Override
public void onLoadFinished(Loader<List<Anime>> loader, List<Anime> data) {
    if (data != null && !data.isEmpty() && mAdapter.getItemCount() > 0) {
        mAdapter.clearData();
    }
    mList = (ArrayList) data;
    mAdapter.setSectionType(1);
    mAdapter.addAnimeList(data);
    sortFavorites();
    //mAdapter.getFilter().filter(null);
}
项目:Inflix    文件:NetworkLoader.java   
@Override
public Loader<String> onCreateLoader(int id, final Bundle args) {
    return new AsyncTaskLoader<String>(mContext) {

        private String mResponse;

        @Override
        protected void onStartLoading() {
            if (args == null) return;
            if (mResponse == null) {
                forceLoad();
            } else {
                deliverResult(mResponse);
            }
        }

        @Nullable
        @Override
        public String loadInBackground() {
            URL url = (java.net.URL) args.getSerializable(URL_EXTRA);
            if (url != null) {
                try {
                    Log.i(TAG, "Requesting Data From: " + url.toString());
                    return HTTPUtils.getHTTPResponse(url);
                } catch (IOException e) {
                    Log.e(TAG, e.getMessage());
                }
            }
            return null;
        }

        @Override
        public void deliverResult(@Nullable String data) {
            super.deliverResult(data);
            mResponse = data;
        }
    };
}
项目:Canvas-Vision    文件:CollectionActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    CursorLoader cursorLoader = new CursorLoader(CollectionActivity.this,
            CanvasDownloadTable.CONTENT_URI, // URI
            null, // projection fields
            null, // the selection criteria
            null, // the selection args
            null // the sort order
    );

    return cursorLoader;
}
项目:letv    文件:LoaderManagerImpl.java   
public <D> Loader<D> getLoader(int id) {
    if (this.mCreatingLoader) {
        throw new IllegalStateException("Called while creating a loader");
    }
    LoaderInfo loaderInfo = (LoaderInfo) this.mLoaders.get(id);
    if (loaderInfo == null) {
        return null;
    }
    if (loaderInfo.mPendingLoader != null) {
        return loaderInfo.mPendingLoader.mLoader;
    }
    return loaderInfo.mLoader;
}
项目:Matisse-Image-and-Video-Selector    文件:AlbumCollection.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    Context context = mContext.get();
    if (context == null) {
        return null;
    }
    return AlbumLoader.newInstance(context);
}
项目:PeSanKita-android    文件:MessageDetailsActivity.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
  MessageRecord messageRecord = getMessageRecord(this, cursor, getIntent().getStringExtra(TYPE_EXTRA));

  if (messageRecord == null) {
    finish();
  } else {
    new MessageRecipientAsyncTask(this, messageRecord).execute();
  }
}
项目:CSipSimple    文件:CSSListFragment.java   
/**
 * {@inheritDoc}
 */
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    changeCursor(data);
    if(isResumed()) {
        setListShown(true);
    }else {
        setListShownNoAnimation(true);
    }
}
项目:Farmacias    文件:FindPresenter.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {


    if(loader.getId() == LOADER_RESULT) {
        Utils.logD(LOG_TAG,"onLoadFinished_LOADER_RESULT");
        Utils.logD(LOG_TAG,data.toString());

        new Thread() {
            @Override
            public void run() {
                bindView(data);

            }
        }.start();
    }
    if(loader.getId() == LOADER_QUICK_SEARCH) {
        Utils.logD(LOG_TAG,"onLoadFinished_LOADER_QUICK_SEARCH");
        new Thread() {
            @Override
            public void run() {
                bindViewQuickSearch(data);

            }
        }.start();

    }
}
项目:yyox    文件:BaseChatActivity.java   
@Override
public Loader<IMPresenter> onCreateLoader(int id, Bundle args) {
    return new PresenterLoader<>(this, new PresenterFactory<IMPresenter>() {
        @Override
        public IMPresenter create() {
            return new IMPresenter(IMCaseManager.provideIMCase());
        }
    });
}
项目:face-landmark-android    文件:MediaLoaderCallback.java   
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    CursorLoader cursorLoader = new CursorLoader(mContext,
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, IMAGE_PROJECTION,
            IMAGE_PROJECTION[4]+">0 AND "+IMAGE_PROJECTION[3]+"=? OR "+IMAGE_PROJECTION[3]+"=? ",
            new String[]{"image/jpeg", "image/png"}, IMAGE_PROJECTION[2] + " ASC");  // DESC 降序
    return cursorLoader;
}
项目:android_nextgis_mobile    文件:LocalResourceSelectDialog.java   
@Override
public void onLoadFinished(
        Loader<List<LocalResourceListItem>> loader,
        List<LocalResourceListItem> resources)
{
    mAdapter.setResources(resources);

    if (null != mSavedPathList) {
        for (String path : mSavedPathList) {
            mAdapter.setSelection(path, true);
        }
    }
}
项目:FriendBook    文件:MvpLoaderFragment.java   
@Override
public final Loader<P> onCreateLoader(int i, Bundle bundle) {
    return new PresenterLoader<P>(this.getContext()) {
        @Override
        P create() {
            return createPresenter();
        }
    };
}
项目:Perfect-Day    文件:TodayTasksFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new AsyncTaskLoader<Cursor>(getActivity()) {

        Cursor mTaskDAta = null;

        @Override
        protected void onStartLoading() {
            if (mTaskDAta != null) {
                notifyLoaderChangeListener();
            } else {
                forceLoad();
            }
        }

        private void notifyLoaderChangeListener() {
        }

        @Override
        public Cursor loadInBackground() {
            try {
                Uri todayUri = TaskItemsContract.TaskItemsColumns.CONTENT_URI.buildUpon().appendPath(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_IS_TODAY).appendPath("1").build();
                return getActivity().getContentResolver().query(todayUri,
                        null,
                        null,
                        null,
                        null);

            } catch (Exception e) {
                Log.e(TAG, "Failed to asynchronously load data.");
                e.printStackTrace();
                return null;
            }
        }
    };
}
项目:aos-Video    文件:BrowserListOfSeasons.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if(id==0) {
        return new SeasonsLoader(getContext(), mShowId).getV4CursorLoader(true, false);
    }

    return super.onCreateLoader(id, args);
}
项目:MusicX-music-player    文件:PlaylistFragment.java   
@Override
public Loader<List<Song>> onCreateLoader(int id, Bundle args) {
    if (mPlaylist.getId() == 0) {
        return null;
    }
    PlaylistLoader playlistLoader = new PlaylistLoader(getContext(), mPlaylist.getId());
    if (id == trackloader) {
        return playlistLoader;
    }
    return null;
}
项目:aos-Video    文件:BrowserVideosInPlaylist.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args2) {
    if (getArguments() != null) {
        String listOfMoviesIds = getArguments().getString(BrowserByVideoSelection.LIST_OF_IDS);
        if (listOfMoviesIds != null)
            return new VideosSelectionInPlaylistLoader(getContext(), listOfMoviesIds).getV4CursorLoader(true, mPreferences.getBoolean(VideoPreferencesFragment.KEY_HIDE_WATCHED, false));
    }
    return null;
}
项目:yyox    文件:FeedBackActivity.java   
@Override
public Loader<TicketFeedBackPresenter> onCreateLoader(int id, Bundle args) {
    return new PresenterLoader<>(this, new PresenterFactory<TicketFeedBackPresenter>() {
        @Override
        public TicketFeedBackPresenter create() {
            return new TicketFeedBackPresenter(TicketUseCaseManager.provideTicketFeedBackCase());
        }
    });
}
项目:android-dev-challenge    文件:MainActivity.java   
/**
 * Called when a previously created loader has finished its load.
 *
 * @param loader The Loader that has finished.
 * @param data The data generated by the Loader.
 */
@Override
public void onLoadFinished(Loader<String[]> loader, String[] data) {
    mLoadingIndicator.setVisibility(View.INVISIBLE);
    mForecastAdapter.setWeatherData(data);
    if (null == data) {
        showErrorMessage();
    } else {
        showWeatherDataView();
    }
}
项目:FuelUp    文件:StatisticsChartConsumptionPerTimeFragment.java   
@Override
public void onLoadFinished(Loader<Map<String, Object>> loader, Map<String, Object> data) {
    binding.setHasData(data != null);
    if (data != null) {
        chart.setColumnChartData((ColumnChartData) data.get(ConsumptionPerMonthChartDataLoader.CHART_DATA));
        setViewport((Number) data.get(ConsumptionPerMonthChartDataLoader.MIN_CONSUMPTION));
    }
}
项目:android-dev-challenge    文件:MainActivity.java   
/**
 * Called by the {@link android.support.v4.app.LoaderManagerImpl} when a new Loader needs to be
 * created. This Activity only uses one loader, so we don't necessarily NEED to check the
 * loaderId, but this is certainly best practice.
 *
 * @param loaderId The loader ID for which we need to create a loader
 * @param bundle   Any arguments supplied by the caller
 * @return A new Loader instance that is ready to start loading.
 */
@Override
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {


    switch (loaderId) {

        case ID_FORECAST_LOADER:
            /* URI for all rows of weather data in our weather table */
            Uri forecastQueryUri = WeatherContract.WeatherEntry.CONTENT_URI;
            /* Sort order: Ascending by date */
            String sortOrder = WeatherContract.WeatherEntry.COLUMN_DATE + " ASC";
            /*
             * A SELECTION in SQL declares which rows you'd like to return. In our case, we
             * want all weather data from today onwards that is stored in our weather table.
             * We created a handy method to do that in our WeatherEntry class.
             */
            String selection = WeatherContract.WeatherEntry.getSqlSelectForTodayOnwards();

            return new CursorLoader(this,
                    forecastQueryUri,
                    MAIN_FORECAST_PROJECTION,
                    selection,
                    null,
                    sortOrder);

        default:
            throw new RuntimeException("Loader Not Implemented: " + loaderId);
    }
}
项目:Todule-android    文件:ToduleListFragment.java   
@Override
public void onLoaderReset(Loader<Cursor> loader) {
    // This is called when the last Cursor provided to onLoadFinished()
    // above is about to be closed.  We need to make sure we are no
    // longer using it.
    mAdapter.swapCursor(null);
}
项目:android_firebase_green_thumb    文件:ShoppingCartActivity.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    mCartAdapter.swapCursor(data);

    int mTotalPrice = calculateTotal(data);
    mTextViewTotalPrice.setText(getString(R.string.shopping_cart_total, mTotalPrice));

    boolean emptyCart = data.getCount() == 0;
    mTextViewEmptyCart.setVisibility(emptyCart ? View.VISIBLE : View.GONE);
    mButtonCheckout.setEnabled(!emptyCart);

}
项目:android-dev-challenge    文件:MainActivity.java   
/**
 * Called when a previously created loader is being reset, and thus
 * making its data unavailable.  The application should at this point
 * remove any references it has to the Loader's data.
 *
 * @param loader The Loader that is being reset.
 */
@Override
public void onLoaderReset(Loader<String[]> loader) {
    /*
     * We aren't using this method in our example application, but we are required to Override
     * it to implement the LoaderCallbacks<String> interface
     */
}
项目:mobile-store    文件:WhatsNewViewBinder.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (id != LOADER_ID) {
        return null;
    }

    return new CursorLoader(
            activity,
            AppProvider.getRecentlyUpdatedUri(),
            Schema.AppMetadataTable.Cols.ALL,
            null,
            null,
            null
    );
}
项目:BlackList    文件:SMSConversationsListFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (showProgress) {
        progress.show(context, R.string.Loading_);
    }
    return new ConversationsLoader(context);
}
项目:chips-input-layout    文件:ContactLoadingActivity.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    return new CursorLoader(this,
            ContactsContract.CommonDataKinds.Phone.CONTENT_URI,// Content provider
            null, null, null,
            ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY + " ASC"); // OrderBy clause
}
项目:mobile-store    文件:InstalledAppsActivity.java   
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    adapter.setApps(cursor);

    if (adapter.getItemCount() == 0) {
        appList.setVisibility(View.GONE);
        emptyState.setVisibility(View.VISIBLE);
    } else {
        appList.setVisibility(View.VISIBLE);
        emptyState.setVisibility(View.GONE);
    }
}
项目:CSipSimple    文件:AccountsEditListFragment.java   
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
     return new CursorLoader(getActivity(), SipProfile.ACCOUNT_URI, new String[] {
        SipProfile.FIELD_ID + " AS " + BaseColumns._ID,
        SipProfile.FIELD_ID,
        SipProfile.FIELD_DISPLAY_NAME,
        SipProfile.FIELD_WIZARD,
        SipProfile.FIELD_ACTIVE
     }, null, null, null);

}