本文整理汇总了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));
}
示例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;
}
}
示例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);
}
示例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");
}
}
示例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);
}
}
示例6: onCreateLoader
import com.example.xyzreader.data.ArticleLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
return ArticleLoader.newAllArticlesInstance(this);
}
示例7: getItemId
import com.example.xyzreader.data.ArticleLoader; //导入依赖的package包/类
@Override
public long getItemId(int position) {
mCursor.moveToPosition(position);
return mCursor.getLong(ArticleLoader.Query._ID);
}
示例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");
}
}
示例9: onCreateLoader
import com.example.xyzreader.data.ArticleLoader; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
return ArticleLoader.newInstanceForItemId(getActivity(), mItemId);
}
示例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));
}
示例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");
}
});
}
});
}
示例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();
}
}
});
}
});
}