SimpleDraweeView black filckering on replacement image with Fresco - android

I am trying to replace mutiples images (from local storage) using the same
After a while the black flickering disappear and works well.
See the video: http://sendvid.com/q92ry52l
I am only doing: mSimpleDraweeView.setImageURI("file://" + imagesList.get(index));
The xml code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="#+id/fresco_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
I am using 'com.facebook.fresco:fresco:0.13.0'
SimpleDraweeView. How avoid the black flickering?
Thanks

(full discussion here)
Unfortunately this is a known issue. If you set a new URI, you'll see the placeholder image until the new image is ready. This is especially noticeable when you have large images and you switch them a lot (like in your example).
We are going to fix this at some point in the future (see this pull request).
For now, you can manually copy the RetainingDataSourceSupplier implementation from said pull request to your project and use it similar to the MainActivity.java example:
PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()...
builder.setDataSourceSupplier(retainingDataSourceSupplier);
draweeView.setController(builder.build());

Related

Android XML Image Background (Vector Drawable Or Png) Issues With Long Loading

Good Day.Lately i have noticed an horrible delay between activity load which has an image attached to it's background.
Basically here is my simple layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_vip"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ink.va.activities.VIPActivity">
<ImageView
android:id="#+id/rootImageView"
android:src="#drawable/vip_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</RelativeLayout>
Meanwhile the issue is that i am very much confused the fact that activity takes a long way to load,if i remove the image,activity goes good,otherwise it takes a while to load,and i have tried to do the same with a PNG file of same image within different dimensions,scaled down with size of image and pixels so it shall be light,meanwhile my device still loads long the activity.The device is Huawei p8 Lite and i reckon it is not issue of device,anyone has any best practice for such situation?Thank you very much.

How to run an Pinch-Zoom example on android?

To run an example on android to use PinchZoom I found the following example. I was able to write a working example code which shows the View from the example - but it is all white! How can I use an actual image in this example?
I tried the following in the activity-xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<com.example.alexander.capycoding_pinchzoom.CanvasView
android:id="#+id/signature_canvas"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/image"
android:textColor="#FFFFFF" />
</FrameLayout>
to use an actual non-white image, but it does not work. (I also renamed the class from ZoomableImageView to CanvasView).
Maybe there is another/better example on how to make PinchZoom workable on a Canvas/Bitmap in android?
you are using a default image in the xml.use your image and by the way simply putting xml cannot alone perform the action.i suggest to use library files for the pinch zoom and then create a class for the zoom specification

How to design a grid layout as shown in the screenshot in android?

I am able to query all the images from my device and display them in a linearlayout with a recyclerview but actually i want to display image thumbnails like its shown in android gallery app where the image size is different but they somehow adjust to fit and cover all space
gallery
plz check the image link as i can't post it in my question because of low reputation
For creating a grid with like your requirement you can get concept from link there are lot of custom grid available on github but this is most common find it here
This is example for how to define in xml
<com.etsy.android.grid.StaggeredGridView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:item_margin="8dp"
app:column_count="#integer/column_count" />

Getting black ImageView using Picasso and Glide

The problem
I'm writing an Android app that's supposed to have a "Slideshow" feature on it. I've found this nice library, based on Picasso, that does exactly what I wanted, and it worked just fine most of the times.
Problem is, sometimes my images are not loaded into the slide ImageView... It only shows a "black canvas" as you can see on the screenshot below.
I am loading the image from a local resource from my drawables. Sometimes it happens on Portrait mode, sometimes on Landscape mode. It doesn't matter which image I use, sometimes that "blackness" happens.
EDIT:
I'm using Android 5.0.2 and 4.4.2 - It doesn't seem to happen on 4.4.2. Only on 5.0.2.
It happened on a Moto X 2014 with android 5.1.
The images I'm trying to load have 45KB on disk with a resolution of 900x445.
I've turned on the layout rects as suggested, and these were the results:
And it keep like that on scroll.
And sometimes, it gets white instead of black (Or white, then black).
Something else I tried: My drawables were located on the res/drawable folder, when I've changed the files from that folder to the res/drawable-xxxhdpi the slider worked on the 5.0.2 device. wtf???
What have I tried so far
I've tried different images, to load multiple images on the slide, and even this pull request that changes Picasso to Glide on the lib. Nothing seems to work and the error seems random.
Once I've tried to use URLs from the web instead of the actual drawables on the local storage, it worked. With the exact same images.
Here's how I'm loading the images:
Fragment.java
private SliderLayout slider;
private PagerIndicator indicator;
// ...
private void setupSlider() {
HashMap<String,Integer> file_maps = new HashMap<>();
file_maps.put("Blah",R.drawable.banner_1);
file_maps.put("Bleh",R.drawable.banner_2);
file_maps.put("Blih",R.drawable.banner_3);
file_maps.put("Bloh",R.drawable.banner_4);
for (String name : file_maps.keySet()) {
DefaultSliderView dsv = new DefaultSliderView(getActivity());
dsv.description(name)
.image(file_maps.get(name))
.error(R.drawable.banner_error)
.empty(R.drawable.empty)
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);
//add your extra information
dsv.bundle(new Bundle());
dsv.getBundle()
.putString("extra",name);
slider.addSlider(dsv);
}
slider.setPresetTransformer(SliderLayout.Transformer.Default);
slider.setCustomIndicator(indicator);
slider.setCustomAnimation(new DescriptionAnimation());
slider.setDuration(4000);
slider.addOnPageChangeListener(this);
}
fragment.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:custom="http://schemas.android.com/apk/res-auto"
tools:context="com.example.fragments.Fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/sv_main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/rl_main">
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="200dp"
/>
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="#+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/slider"
custom:shape="oval"
custom:selected_color="#00BFA5"
custom:unselected_color="#55333333"
custom:selected_padding_left="#dimen/spacing_medium"
custom:selected_padding_right="#dimen/spacing_medium"
custom:selected_padding_top="3dp"
custom:selected_padding_bottom="#dimen/spacing_small"
custom:unselected_padding_left="#dimen/spacing_medium"
custom:unselected_padding_right="#dimen/spacing_medium"
custom:unselected_padding_top="#dimen/spacing_small"
custom:unselected_padding_bottom="4dp"
custom:selected_width="#dimen/spacing_medium"
custom:selected_height="#dimen/spacing_medium"
custom:unselected_width="6dp"
custom:unselected_height="6dp"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/custom_indicator"
android:id="#+id/ll_main_body">
</LinearLayout>
</RelativeLayout>
</ScrollView>
<!-- Other stuff -->
</RelativeLayout>
I'm following the tutorial from the libs wiki page. And no errors are being thrown on the LogCat, which is making this a lot harder to solve.
Any ideas?
Create A Resource Folder Named drawable-nodpi in that folder put your images instead of different folders or drawable folder.
Have you tried using a ViewPager with an ImageView and passing an array of image URIs to the adapter? I think you would be able to avoid/debug much better if you implement it yourself.
This library works fine for me, the very first time I used it. It's a really nice library.
First
SliderLayout is not being referenced by anything. That's where the magic happens. Make a xml layout and refer to it by SliderLayout. After that don't forget to call startAutoScroll() and in onPause() stopAutoScroll().
https://github.com/daimajia/AndroidImageSlider/wiki/Start-Using
The link above is basically all you need.
Second
The problem could also be that it's inside a scrollView. The scroll callbacks may be misbehaving.
Make a simple layout, start with a simple slider and work your way up with customizations.
Good luck.

Using bluejamesbond DocumentView

I'm trying to use the bluejamesbond DocumentView to display a bit of justified text. I'm unable to get text to display even in the simplest of cases;
<com.bluejamesbond.text.DocumentView xmlns:ext="http://schemas.android.com/apk/res-auto"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
ext:documentView_text="test"
android:background="#android:color/background_light" />
I've tried both a light and a dark background in case the default colour is one of them and hence invisible.
I've obtained the library by adding the following to the module's build.gradle;
compile 'com.github.bluejamesbond:textjustify-android:2.1.1'
The only indication of any problem is a fidelity warning from the Android Studio preview, but running on the real device (4.4.2) gives the same lack of text in each case.
I'd initially tried the more complicated example, removing the progress bar and changing the text to just some simple inline text to get rid of other dependencies. That didn't work either, again with different backgrounds.
To rule out the possibility of something else in the layout affecting it, I've also created a new layout as follows. Again, with either a light or dark background the expected text "test" is not to be seen.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.bluejamesbond.text.DocumentView xmlns:ext="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
ext:documentView_text="test"
android:background="#android:color/background_dark" />
</LinearLayout>
There is a (working) demo of the library on Play Store which gives an indication that this library is of decent quality and well maintained, so how can I move on from here?

Categories

Resources