當前位置: 首頁>>代碼示例>>Java>>正文


Java ArticleLoader類代碼示例

本文整理匯總了Java中com.example.xyzreader.data.ArticleLoader的典型用法代碼示例。如果您正苦於以下問題:Java ArticleLoader類的具體用法?Java ArticleLoader怎麽用?Java ArticleLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ArticleLoader類屬於com.example.xyzreader.data包,在下文中一共展示了ArticleLoader類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBindViewHolder

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    mCursor.moveToPosition(position);
    holder.titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
    holder.subtitleView.setText(
            DateUtils.getRelativeTimeSpanString(
                    mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
                    DateUtils.FORMAT_ABBREV_ALL).toString()
                    + " by "
                    + mCursor.getString(ArticleLoader.Query.AUTHOR));
    holder.thumbnailView.setImageUrl(
            mCursor.getString(ArticleLoader.Query.THUMB_URL),
            ImageLoaderHelper.getInstance(ArticleListActivity.this).getImageLoader());
    holder.thumbnailView.setAspectRatio(mCursor.getFloat(ArticleLoader.Query.ASPECT_RATIO));
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:17,代碼來源:ArticleListActivity.java

示例2: onLoadFinished

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    mCursor = cursor;
    mPagerAdapter.notifyDataSetChanged();

    // Select the start ID
    if (mStartId > 0) {
        mCursor.moveToFirst();
        // TODO: optimize
        while (!mCursor.isAfterLast()) {
            if (mCursor.getLong(ArticleLoader.Query._ID) == mStartId) {
                final int position = mCursor.getPosition();
                mPager.setCurrentItem(position, false);
                break;
            }
            mCursor.moveToNext();
        }
        mStartId = 0;
    }
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:21,代碼來源:ArticleDetailActivity.java

示例3: onBindViewHolder

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
    mCursor.moveToPosition(position);
    holder.titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
    holder.subtitleView.setText(
            DateUtils.getRelativeTimeSpanString(
                    mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
                    DateUtils.FORMAT_ABBREV_ALL).toString()
                    + " by "
                    + mCursor.getString(ArticleLoader.Query.AUTHOR));

    Glide.with(getBaseContext()).load(mCursor.getString(ArticleLoader.Query.THUMB_URL)).asBitmap().into(holder.thumbnailView);



}
 
開發者ID:josemontiel,項目名稱:MaterialZebra,代碼行數:18,代碼來源:ArticleListActivity.java

示例4: bindViews

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
private void bindViews() {
    if (mRootView == null) {
        return;
    }

    TextView titleView = (TextView) mRootView.findViewById(R.id.article_title);
    TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline);
    bylineView.setMovementMethod(new LinkMovementMethod());
    TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (mCursor != null) {

        Log.i(TAG,"bindViews1: "+mCursor.getString(ArticleLoader.Query.TITLE));
        Log.i(TAG, "bindViews2: " + mCursor.getString(ArticleLoader.Query.PHOTO_URL));

        mRootView.setAlpha(0);
        mRootView.setVisibility(View.VISIBLE);
        mRootView.animate().alpha(1);
        titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
        bylineView.setText(Html.fromHtml(
                DateUtils.getRelativeTimeSpanString(
                        mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                        System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
                        DateUtils.FORMAT_ABBREV_ALL).toString()
                        + " by <font color='#ffffff'>"
                        + mCursor.getString(ArticleLoader.Query.AUTHOR)
                        + "</font>"));
        bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));

    } else {
        mRootView.setVisibility(View.GONE);
        titleView.setText("N/A");
        bylineView.setText("N/A" );
        bodyView.setText("N/A");
    }
}
 
開發者ID:frank-tan,項目名稱:XYZReader,代碼行數:37,代碼來源:ArticleDetailFragment.java

示例5: setToolbarImage

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
public void setToolbarImage() {
    if (mCursor != null) {
        // load low resolution thumb nail picture first
        // It is a lot faster, so the shared element transition works well
        // High resolution image will be load later
        setImageWithUrl(mCursor.getString(ArticleLoader.Query.THUMB_URL), THUMBNAIL);
    }
}
 
開發者ID:frank-tan,項目名稱:XYZReader,代碼行數:9,代碼來源:ArticleDetailFragment.java

示例6: onCreateLoader

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return ArticleLoader.newAllArticlesInstance(this);
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:5,代碼來源:ArticleListActivity.java

示例7: getItemId

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public long getItemId(int position) {
    mCursor.moveToPosition(position);
    return mCursor.getLong(ArticleLoader.Query._ID);
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:6,代碼來源:ArticleListActivity.java

示例8: bindViews

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
private void bindViews() {
    if (mRootView == null) {
        return;
    }

    TextView bylineView = (TextView) mRootView.findViewById(R.id.article_byline);
    bylineView.setMovementMethod(new LinkMovementMethod());
    TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);
    bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));

    if (mCursor != null) {
        mRootView.setAlpha(0);
        mRootView.setVisibility(View.VISIBLE);
        mRootView.animate().alpha(1);
        collapsingToolbarLayout.setTitle(mCursor.getString(ArticleLoader.Query.TITLE));
        bylineView.setText(Html.fromHtml(
                DateUtils.getRelativeTimeSpanString(
                        mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                        System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
                        DateUtils.FORMAT_ABBREV_ALL).toString()
                        + " by <font color='#ffffff'>"
                        + mCursor.getString(ArticleLoader.Query.AUTHOR)
                        + "</font>"));
        bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));
        ImageLoaderHelper.getInstance(getActivity()).getImageLoader()
                .get(mCursor.getString(ArticleLoader.Query.PHOTO_URL), new ImageLoader.ImageListener() {
                    @Override
                    public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) {
                        Bitmap bitmap = imageContainer.getBitmap();
                        if (bitmap != null) {
                            Palette p = Palette.generate(bitmap, 12);
                            mMutedColor = p.getDarkMutedColor(0xFF333333);
                            mPhotoView.setImageBitmap(imageContainer.getBitmap());
                            mRootView.findViewById(R.id.meta_bar)
                                    .setBackgroundColor(mMutedColor);
                            updateStatusBar();
                        }
                    }

                    @Override
                    public void onErrorResponse(VolleyError volleyError) {

                    }
                });
    } else {
        mRootView.setVisibility(View.GONE);
        collapsingToolbarLayout.setTitle("N/A");
        bylineView.setText("N/A" );
        bodyView.setText("N/A");
    }
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:52,代碼來源:ArticleDetailFragment.java

示例9: onCreateLoader

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
    return ArticleLoader.newInstanceForItemId(getActivity(), mItemId);
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:5,代碼來源:ArticleDetailFragment.java

示例10: getItem

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public Fragment getItem(int position) {
    mCursor.moveToPosition(position);
    return ArticleDetailFragment.newInstance(mCursor.getLong(ArticleLoader.Query._ID));
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:6,代碼來源:ArticleDetailActivity.java

示例11: onBindViewHolder

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    mCursor.moveToPosition(position);
    holder.titleView.setText(mCursor.getString(ArticleLoader.Query.TITLE));
    String subTitleText = DateUtils.getRelativeTimeSpanString(
            mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
            System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS,
            DateUtils.FORMAT_ABBREV_ALL).toString()
            + " by "
            + mCursor.getString(ArticleLoader.Query.AUTHOR);

    holder.subtitleView.setText(subTitleText);

    final DynamicHeightNetworkImageView thumbnailView = holder.thumbnailView;
    final String thumbnailUrl = mCursor.getString(ArticleLoader.Query.THUMB_URL);
    final float aspectRatio = mCursor.getFloat(ArticleLoader.Query.ASPECT_RATIO);

    Picasso.with(getApplicationContext())
            .load(thumbnailUrl)
            .networkPolicy(NetworkPolicy.OFFLINE)
            .into(thumbnailView, new Callback() {
                @Override
                public void onSuccess() {
                    Log.i(TAG, "Picasso loaded thumbnail image successfully");
                    thumbnailView.setAspectRatio(aspectRatio);
                }

                @Override
                public void onError() {
                    Picasso.with(getApplicationContext())
                            .load(thumbnailUrl)
                            .into(thumbnailView, new Callback() {
                                @Override
                                public void onSuccess() {
                                    Log.i(TAG, "Picasso loaded thumbnail image successfully");
                                    thumbnailView.setAspectRatio(aspectRatio);
                                }

                                @Override
                                public void onError() {
                                    Log.e(TAG, "Picasso failed to load thumbnail image");
                                }
                            });
                }
            });
}
 
開發者ID:frank-tan,項目名稱:XYZReader,代碼行數:47,代碼來源:ArticleListActivity.java

示例12: setImageWithUrl

import com.example.xyzreader.data.ArticleLoader; //導入依賴的package包/類
private void setImageWithUrl (final String url, final String type) {
    final Context appContext = getActivity().getApplicationContext();
    Picasso.with(appContext)
            .load(url)
            .networkPolicy(NetworkPolicy.OFFLINE)
            .noPlaceholder()
            .fit()
            .centerCrop()
            .into(mPhotoView, new Callback() {
                @Override
                public void onSuccess() {
                    Log.i(TAG, "Picasso loaded backdrop image successfully from local cache");
                    // load high resolution picture afterwards
                    if(type.equals(THUMBNAIL)) {
                        setTitleBackgroundDarkMutedColour();
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                            getActivity().startPostponedEnterTransition();
                        }
                        setImageWithUrl(mCursor.getString(ArticleLoader.Query.PHOTO_URL),FULL_SIZE);
                    }
                }

                @Override
                public void onError() {
                    Picasso.with(appContext)
                            .load(url)
                            .noPlaceholder()
                            .fit()
                            .centerCrop()
                            .into(mPhotoView, new Callback() {
                                @Override
                                public void onSuccess() {
                                    Log.i(TAG, "Picasso loaded backdrop image successfully from Network");
                                    // load high resolution picture afterwards
                                    if(type.equals(THUMBNAIL)) {
                                        setTitleBackgroundDarkMutedColour();
                                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                            getActivity().startPostponedEnterTransition();
                                        }
                                        setImageWithUrl(mCursor.getString(ArticleLoader.Query.PHOTO_URL),FULL_SIZE);
                                    }
                                }

                                @Override
                                public void onError() {
                                    Log.e(TAG, "Picasso failed to load backdrop image");
                                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                        getActivity().startPostponedEnterTransition();
                                    }
                                }
                            });
                }
            });
}
 
開發者ID:frank-tan,項目名稱:XYZReader,代碼行數:55,代碼來源:ArticleDetailFragment.java


注:本文中的com.example.xyzreader.data.ArticleLoader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。