当前位置: 首页>>代码示例>>Java>>正文


Java Loader类代码示例

本文整理汇总了Java中android.support.v4.content.Loader的典型用法代码示例。如果您正苦于以下问题:Java Loader类的具体用法?Java Loader怎么用?Java Loader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Loader类属于android.support.v4.content包,在下文中一共展示了Loader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:21,代码来源:VideoInfoActivityFragment.java

示例2: onLoadFinished

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:25,代码来源:SearchFragment.java

示例3: initLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:LoaderManagerImpl.java

示例4: callOnLoadFinished

import android.support.v4.content.Loader; //导入依赖的package包/类
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;
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:21,代码来源:LoaderManagerImpl.java

示例5: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:27,代码来源:DetailActivity.java

示例6: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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());
}
 
开发者ID:joshvocal,项目名称:TransLinkMe-App,代码行数:21,代码来源:LocationFragment.java

示例7: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:changja88,项目名称:Android_Sunshine_Watch,代码行数:22,代码来源:MainActivity.java

示例8: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
}
 
开发者ID:OlgaKuklina,项目名称:GitJourney,代码行数:18,代码来源:MainViewFragment.java

示例9: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
	 
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:13,代码来源:AccountFiltersListFragment.java

示例10: onLoadFinished

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:15,代码来源:ProgramsTabsFragment.java

示例11: onLoadFinished

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:SimonCherryGZ,项目名称:face-landmark-android,代码行数:29,代码来源:MediaLoaderCallback.java

示例12: onLoadFinished

import android.support.v4.content.Loader; //导入依赖的package包/类
@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);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:12,代码来源:FavoritesFragment.java

示例13: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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;
        }
    };
}
 
开发者ID:scaffeinate,项目名称:Inflix,代码行数:39,代码来源:NetworkLoader.java

示例14: onCreateLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
@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;
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:14,代码来源:CollectionActivity.java

示例15: getLoader

import android.support.v4.content.Loader; //导入依赖的package包/类
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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:14,代码来源:LoaderManagerImpl.java


注:本文中的android.support.v4.content.Loader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。