use of me.ccrama.redditslide.Views.SubsamplingScaleImageView in project Slide by ccrama.
the class MediaFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = (ViewGroup) inflater.inflate(R.layout.submission_mediacard, container, false);
if (savedInstanceState != null && savedInstanceState.containsKey("position")) {
stopPosition = savedInstanceState.getLong("position");
}
PopulateShadowboxInfo.doActionbar(s, rootView, getActivity(), true);
(rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);
ImageView typeImage = (ImageView) rootView.findViewById(R.id.type);
typeImage.setVisibility(View.VISIBLE);
SubsamplingScaleImageView img = rootView.findViewById(R.id.submission_image);
final SlidingUpPanelLayout slideLayout = ((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout));
ContentType.Type type = ContentType.getContentType(s);
img.setAlpha(1f);
if (s.getThumbnail() == null || s.getThumbnail().isEmpty() || firstUrl == null || firstUrl.isEmpty() || (s.isNsfw() && SettingValues.getIsNSFWEnabled())) {
(rootView.findViewById(R.id.thumbimage2)).setVisibility(View.VISIBLE);
((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource(R.drawable.web);
addClickFunctions((rootView.findViewById(R.id.thumbimage2)), slideLayout, rootView, type, getActivity(), s);
(rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
if ((s.isNsfw() && SettingValues.getIsNSFWEnabled())) {
((ImageView) rootView.findViewById(R.id.thumbimage2)).setImageResource(R.drawable.nsfw);
} else {
if (firstUrl.isEmpty() && !s.getThumbnail().isEmpty()) {
((Reddit) getContext().getApplicationContext()).getImageLoader().displayImage(s.getThumbnail(), ((ImageView) rootView.findViewById(R.id.thumbimage2)));
}
}
} else {
(rootView.findViewById(R.id.thumbimage2)).setVisibility(View.GONE);
addClickFunctions(img, slideLayout, rootView, type, getActivity(), s);
}
if (!s.isNsfw() || !SettingValues.getIsNSFWEnabled()) {
if (type == ContentType.Type.EXTERNAL || type == ContentType.Type.LINK || type == ContentType.Type.VIDEO) {
doLoad(firstUrl, type);
} else {
doLoad(contentUrl, type);
}
}
switch(type) {
case ALBUM:
typeImage.setImageResource(R.drawable.album);
break;
case EXTERNAL:
case LINK:
case REDDIT:
typeImage.setImageResource(R.drawable.world);
rootView.findViewById(R.id.submission_image).setAlpha(0.5f);
break;
case SELF:
typeImage.setImageResource(R.drawable.fontsizedarker);
break;
case EMBEDDED:
case VIDEO:
typeImage.setImageResource(R.drawable.play);
rootView.findViewById(R.id.submission_image).setAlpha(0.5f);
break;
default:
typeImage.setVisibility(View.GONE);
break;
}
rootView.findViewById(R.id.base).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i2 = new Intent(getActivity(), CommentsScreen.class);
i2.putExtra(CommentsScreen.EXTRA_PAGE, i);
i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, sub);
getActivity().startActivity(i2);
}
});
final View.OnClickListener openClick = new View.OnClickListener() {
@Override
public void onClick(View v) {
((SlidingUpPanelLayout) rootView.findViewById(R.id.sliding_layout)).setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
}
};
rootView.findViewById(R.id.base).setOnClickListener(openClick);
final View title = rootView.findViewById(R.id.title);
title.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
slideLayout.setPanelHeight(title.getMeasuredHeight());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
title.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
}
});
slideLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
}
@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) {
rootView.findViewById(R.id.base).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i2 = new Intent(getActivity(), CommentsScreen.class);
i2.putExtra(CommentsScreen.EXTRA_PAGE, i);
i2.putExtra(CommentsScreen.EXTRA_SUBREDDIT, sub);
getActivity().startActivity(i2);
}
});
} else {
rootView.findViewById(R.id.base).setOnClickListener(openClick);
}
}
});
return rootView;
}
use of me.ccrama.redditslide.Views.SubsamplingScaleImageView in project Slide by ccrama.
the class AlbumPager method loadImage.
private static void loadImage(final View rootView, Fragment f, String url, boolean single) {
final SubsamplingScaleImageView image = (SubsamplingScaleImageView) rootView.findViewById(R.id.image);
image.setMinimumDpi(70);
image.setMinimumTileDpi(240);
ImageView fakeImage = new ImageView(f.getActivity());
final TextView size = (TextView) rootView.findViewById(R.id.size);
fakeImage.setLayoutParams(new LinearLayout.LayoutParams(image.getWidth(), image.getHeight()));
fakeImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
((Reddit) f.getActivity().getApplication()).getImageLoader().displayImage(url, new ImageViewAware(fakeImage), new DisplayImageOptions.Builder().resetViewBeforeLoading(true).cacheOnDisk(true).imageScaleType(single ? ImageScaleType.NONE : ImageScaleType.NONE_SAFE).cacheInMemory(false).build(), new ImageLoadingListener() {
private View mView;
@Override
public void onLoadingStarted(String imageUri, View view) {
mView = view;
size.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Log.v("Slide", "LOADING FAILED");
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
size.setVisibility(View.GONE);
image.setImage(ImageSource.bitmap(loadedImage));
(rootView.findViewById(R.id.progress)).setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
Log.v("Slide", "LOADING CANCELLED");
}
}, new ImageLoadingProgressListener() {
@Override
public void onProgressUpdate(String imageUri, View view, int current, int total) {
size.setText(readableFileSize(total));
((ProgressBar) rootView.findViewById(R.id.progress)).setProgress(Math.round(100.0f * current / total));
}
});
}
Aggregations