use of com.squareup.picasso.Picasso in project Klyph by jonathangerbaud.
the class ImageLoader method displayNoScaling.
public static void displayNoScaling(ImageView imageView, String uri, boolean fadeIn, int stubImage, ImageLoaderListener listener) {
if (uri == null || uri.length() == 0)
uri = FAKE_URI;
Picasso picasso = Picasso.with(imageView.getContext());
RequestCreator requestCreator = picasso.load(uri);
if (stubImage != 0) {
requestCreator.placeholder(stubImage);
requestCreator.error(stubImage);
}
if (!(fadeIn && FADE_ENABLED))
requestCreator.noFade();
requestCreator.into(imageView, listener);
}
use of com.squareup.picasso.Picasso in project UltimateAndroid by cymcsg.
the class MultiImageSelectorFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// 选择图片数量
mDesireImageCount = getArguments().getInt(EXTRA_SELECT_COUNT);
// 图片选择模式
final int mode = getArguments().getInt(EXTRA_SELECT_MODE);
// 默认选择
if (mode == MODE_MULTI) {
ArrayList<String> tmp = getArguments().getStringArrayList(EXTRA_DEFAULT_SELECTED_LIST);
if (tmp != null && tmp.size() > 0) {
resultList = tmp;
}
}
// 是否显示照相机
final boolean showCamera = getArguments().getBoolean(EXTRA_SHOW_CAMERA, true);
mImageAdapter = new ImageGridAdapter(getActivity(), showCamera);
// 是否显示选择指示器
mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
// 如果显示了照相机,则创建临时文件
if (showCamera) {
mTmpFile = FileUtils.createTmpFile(getActivity());
}
mPopupAnchorView = view.findViewById(R.id.footer);
mTimeLineText = (TextView) view.findViewById(R.id.timeline_area);
// 初始化,先隐藏当前timeline
mTimeLineText.setVisibility(View.GONE);
mCategoryText = (TextView) view.findViewById(R.id.category_btn);
// 初始化,加载所有图片
mCategoryText.setText("folder_all");
mCategoryText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mFolderPopupWindow.isShowing()) {
mFolderPopupWindow.dismiss();
} else {
mFolderPopupWindow.show();
int index = mFolderAdapter.getSelectIndex();
index = index == 0 ? index : index - 1;
mFolderPopupWindow.getListView().setSelection(index);
}
}
});
mPreviewBtn = (Button) view.findViewById(R.id.preview);
// 初始化,按钮状态初始化
if (resultList == null || resultList.size() <= 0) {
mPreviewBtn.setText("preview");
mPreviewBtn.setEnabled(false);
}
mPreviewBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// TODO 预览
}
});
mGridView = (GridView) view.findViewById(R.id.grid);
mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView absListView, int state) {
final Picasso picasso = Picasso.with(getActivity());
if (state == SCROLL_STATE_IDLE || state == SCROLL_STATE_TOUCH_SCROLL) {
picasso.resumeTag(getActivity());
} else {
picasso.pauseTag(getActivity());
}
if (state == SCROLL_STATE_IDLE) {
// 停止滑动,日期指示器消失
mTimeLineText.setVisibility(View.GONE);
} else if (state == SCROLL_STATE_FLING) {
mTimeLineText.setVisibility(View.VISIBLE);
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (mTimeLineText.getVisibility() == View.VISIBLE) {
int index = firstVisibleItem + 1 == view.getAdapter().getCount() ? view.getAdapter().getCount() - 1 : firstVisibleItem + 1;
Image image = (Image) view.getAdapter().getItem(index);
if (image != null) {
mTimeLineText.setText(TimeUtils.formatPhotoDate(image.path));
}
}
}
});
mGridView.setAdapter(mImageAdapter);
mGridView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void onGlobalLayout() {
final int width = mGridView.getWidth();
final int height = mGridView.getHeight();
final int desireSize = getResources().getDimensionPixelOffset(R.dimen.multi_image_select_image_size);
final int numCount = width / desireSize;
final int columnSpace = getResources().getDimensionPixelOffset(R.dimen.multi_image_select_space_size);
int columnWidth = (width - columnSpace * (numCount - 1)) / numCount;
mImageAdapter.setItemSize(columnWidth);
if (mFolderPopupWindow == null) {
createPopupFolderList(width, height);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
mGridView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (mImageAdapter.isShowCamera()) {
// 如果显示照相机,则第一个Grid显示为照相机,处理特殊逻辑
if (i == 0) {
showCameraAction();
} else {
// 正常操作
Image image = (Image) adapterView.getAdapter().getItem(i);
selectImageFromGrid(image, mode);
}
} else {
// 正常操作
Image image = (Image) adapterView.getAdapter().getItem(i);
selectImageFromGrid(image, mode);
}
}
});
mFolderAdapter = new FolderAdapter(getActivity());
}
use of com.squareup.picasso.Picasso in project u2020 by JakeWharton.
the class DebugDataModule method providePicasso.
@Provides
@Singleton
Picasso providePicasso(OkHttpClient client, NetworkBehavior behavior, @IsMockMode boolean isMockMode, Application app) {
Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttp3Downloader(client));
if (isMockMode) {
builder.addRequestHandler(new MockRequestHandler(behavior, app.getAssets()));
}
builder.listener((picasso, uri, exception) -> {
Timber.e(exception, "Error while loading image %s", uri);
});
return builder.build();
}
use of com.squareup.picasso.Picasso in project picasso by square.
the class SampleWidgetProvider method onUpdate.
@Override
public void onUpdate(final Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.sample_widget);
// Load image for all appWidgetIds.
Picasso picasso = Picasso.with(context);
//
picasso.load(Data.URLS[new Random().nextInt(Data.URLS.length)]).placeholder(//
R.drawable.placeholder).error(//
R.drawable.error).transform(//
new GrayscaleTransformation(picasso)).into(updateViews, R.id.image, appWidgetIds);
}
use of com.squareup.picasso.Picasso in project UltimateAndroid by cymcsg.
the class SampleBubbleFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.shape_image_fragment_chat_sample, container, false);
final Picasso picasso = Picasso.with(getActivity());
picasso.setLoggingEnabled(true);
picasso.setIndicatorsEnabled(false);
int listLayout1 = getArguments().getInt(ARG_LAYOUT_1);
int listLayout2 = getArguments().getInt(ARG_LAYOUT_2);
final ListView listView = (ListView) view.findViewById(R.id.list);
Adapter adapter = new Adapter(getActivity(), picasso, listLayout1, listLayout2);
listView.setAdapter(adapter);
return view;
}
Aggregations