當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。