I'm developing an app that has an HorizontalListview, currently I'm using TwoWayView lib, and everything works fine, but when it has an item changed, the listview try to reconstruct the view, but nothing changes, here is the code:
if (mHorizontalListViewUsersInChat.getAdapter() != null) {
usersInChatAdapter.notifyDataSetChanged();
mHorizontalListViewUsersInChat.invalidate();
} else {
mHorizontalListViewUsersInChat.setAdapter(usersInChatAdapter);
}
Inside the adapter there is an ImageView that loads the image with Picasso, but when the adapter is notified, the new URL is not loaded inside the ImageView, somebody could help me?
Thanks.
Related
We've been looking around for the implementation of the new material design swipe down to refresh on RecyclerViews with the loading circle coming down from bottom view same like new gmail app.i found so many things. But not getting new gmail app like example or demo .i already implement refreshlayout and recycleview.
But when scroll down to recycleview,how to put loading circle at the last of the record in recycleview. I want to get some idea to put in onscroll of recycleview.
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrollStateChanged(int arg0) {
}
#Override
public void onScrolled(int arg0, int arg1) {
//add some data but not to show loader.
getDataFromDB();
}
});
hi If you wan't to develop such a kind of Layout then please follow this url, i was used it it's an awesome.
https://github.com/stormzhang/SwipeRefreshLayoutDemo
You should wrap all your layouts with
pull to refresh component for that.
after swipeRefreshLayout.setOnRefreshListener and set swipeRefreshLayout.setRefreshing(true); when you send API call
hear is awesome demo for both Scroll down to load data using recycleview and Swipe to RefreshLayout.
I would like to implement the same technique as used in the stock android photos app to delete pictures. What I mean by that, is that I would like to be able to select the pictures / items when perform a long item click. Then the actionbar should also display how many pictures I have selected. If you know the app, you will also know what I mean.
Basically what I have so far, is the action bar itself (I am using the appcompat one) and the gridview. There I will have add this functionlity somewhere in here:
private void setGridViewClickListener() {
mGridView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {
File imgFile = new File(mImagePaths.get(position));
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
zoomImageFromThumb(new View(mContext), myBitmap);
}
}
});
You should set a ChoiceMode to CHOICE_MODE_MULTIPLE_MODAL to your gridview and a MultiChoiceMode listener:
gridview.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL);
gridview.setMultiChoiceModeListener(new MultiChoiceModeListener());
Then create an ActionMode (Reference) in this listener with these methods (I added a few example):
onPrepareActionMode: clear the menu, inflate the menu
onCreateActionMode: clear menu, inflate.. or whatever
onItemCheckedStateChanged: update the title in the ActionBar (like +1 item string), re/set a background to the clicked view..
onActionItemClicked: retreive the id clicked and perform actions (as notifyDataSetChanged method)
onDestroyActionMode: update the activity (like reset the background for views)
This tutorial: Multiple Selection GridView in Android might help you to do this. Also see the Guide Topic in Enabling batch contextual actions in a ListView or GridView section.
Hope this helps.
I am using volleys NetworkImageView to load imageĀ“s in an ArrayAdapter.
For some Items in my Adapter i want to use a Drawable resource instead.
Unfortunally setting the ImageResource doesnt seem to have an effect on NetworkImage.
networkImage.setImageResource(R.drawable.mydrawable); // no effect
I tryed working without NetworkImageView using an ImageLoaders get() method providing an interface. Unfortunally the view recycling didnt work out anymore and image downloads overrode already recycled and reused views.
ImageLoader.ImageListener listener =
ImageLoader.getImageListener(image, R.drawable.loading, R.drawable.error);
ImageCacheManager.getImageLoader().get(url,listener);
// OverrideĀ“s recycled views image
Any solutions?
If you only want to show drawable and not load any image at all for specific item, this is quite easy:
public void bind(Item item) {
if (item.shouldDisplayDrawable()) {
imageView.setDefaultImageResId(R.drawable.my_drawable); // show your drawable
imageView.setImageUrl(null, app.getImageLoader()); // and if url == null, Volley will not load any image to replace Default
} else {
imageView.setImageUrl(item.getImageUrl(), app.getImageLoader()); // load image from url
}
}
I tried this in my Adapter, recycling works without any issues. And you can continue using
imageView.setDefaultImageResId(R.drawable.icon_image_default);
imageView.setErrorImageResId(R.drawable.icon_image_error);
on imageView you download from url, it will display correct drawable while loading and on error.
I have a ListView that loads images to the ImageView asynchronously. To achieve this i am using Android-Universal-Image-Loader
But i would like to start loading this images only when they are visible in the listview. For example if the visible items of the listview are from 5 to 9, only those should be loaded. Also if the user scrolls very fast the ListView only when stopped those items should be loaded.
What is the best way to this?
If you use "view reusing" in your listview adapter then you shouldn't do anything. UIL do it for you. UIL won't load ALL scrolled images, only those which are got in task pool (you can set set pool size in configuration). If you use "view reusing" then images which were scrolled fast won't be loaded.
Look into example project on GitHub.
UPD: Since 1.7.0 version UIL have PauseOnScrollListener.
boolean pauseOnScroll = true;
boolean pauseOnFling = true;
listView.setOnScrollListener(new PauseOnScrollListener(pauseOnScroll, pauseOnFling));
Use an OnScrollListener, the onScrollStateChanged() method is called when the ListView switches between SCROLL_STATE_IDLE, SCROLL_STATE_TOUCH_SCROLL (slower scrolling), and SCROLL_STATE_FLING (faster scrolling). With this you can choose to load new images only when the states is "Idle" or "Touch".
Addition
In the first run the visible items of the ListView aren't shown. For example when the app starts if the ListView has 4 items visible those 4 images should be loaded.
I haven't used the Universal Image Loader myself, but from what you described below you need to know how many rows will be displayed before you start downloading. Try this:
Write a Runnable to start the asynchronous downloads.
Use your ListView's built-in Handler to call the Runnable after the rows have been drawn
For example:
private Runnable loadImages = new Runnable() {
#Override
public void run() {
// Start the asynchronous downloads
}
};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
mListView.post(loadImages);
}
The loadImages will be called after the ListView is drawn so you will know exactly how many rows are visible.
I have a Activity which has 2 components
Image view
Text view
Here the image in the image view is changed using a timer. This works fine. The text is scrolling text is marquee. Individually these works fine.
My problem is when the image gets changed it also reset the marquee string.
Is there any way to avoid this?
Is there any way to refresh the display partially in android.
Edit
File imgFolder = new File(config.AppDataDir+config.MainImagesDir);
if(imgFolder.isDirectory()) {
File[] imageList = imgFolder.listFiles();
if(imageList!=null) {
if(imageList.length>0) {
if(imageList[currentImageNum].exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imageList[currentImageNum++].getAbsolutePath());
ImageHolder.setImageBitmap(myBitmap);
}
if(currentImageNum>=imageList.length)
currentImageNum =0;
}
}
}
Thanks
Normally, changing the source of an ImageView should not have any implications on other views. Most probably when changing the image you are doing something that is reflected on the TextView too.