lawloretienne / imagegallery Goto Github PK
View Code? Open in Web Editor NEWA gallery used to host an array of images
License: Apache License 2.0
A gallery used to host an array of images
License: Apache License 2.0
In fullscreen view where the image shows in viewpager, add option like click listener, long click listener , page change listener.
So from there i can share or do something by the image / url and also handle page change listener..
I tried using the sample code provided & couple of images weren't loading at all. I experienced the same issue when I tried running the ImageGallery-master.
Also the images failed to load when I provided the the path of local storage. Example the path was given in this pattern :-
/storage/sdcard1/DCIM/Camera/IMG_20160303_174756.jpg
I have different albums. when i select an album i want to show the title on grid Screen. Is there any way to set title.
I was wondering if it's at all possible to hide the toolbar of the fragment activity in code. I could write my own implementation of the xml layout of the fragment, but that requires a lot of work.
This is how I'm currently starting the fragment:
private fun imageGalleryInitializer(): ImageGalleryFragment {
val fragment = ImageGalleryFragment()
val images =
val bundle = Bundle().apply {
putStringArrayList(ImageGalleryFragment.KEY_IMAGES, ArrayList(images))
putString(ImageGalleryFragment.KEY_TITLE, "Unsplash Images")
}
fragment.arguments = bundle
return fragment
}
If I could give as parameter in putString() some sort of value to hide the toolbar, that would be the ideal situation. Let me know if this is at all possible!
You pass reference to activity (context) to static variable
activity
static variable
Error:(30, 29) error: package org.apache.commons.io does not exist
FullScreenImageGalleryActivity.java
actionBar.setTitle(String.format("%d of %d", (position + 1), totalPages));
for translation in other language.
Is it possible?
I have followed the description in the Readme, declaring the activity in the manifest, putting the required extras (with ArrayList og string urls) and implementing ImageGalleryAdapter.ImageThumbnailLoader and FullScreenImageGalleryAdapter.FullScreenImageLoader in my calling activity.
But I get a NPE from com.etiennelawlor.imagegallery.library.activities.ImageGalleryActivity.loadImageThumbnail(ImageGalleryActivity.java:101) where the imageThumbnailLoader is NULL.
Am I doing something wrong?
StackTrace: https://gist.github.com/olavbg/e19fdc38700d83b3d90e9e1ddf7340d6
@lawloretienne: how can I access gallery items from app internal resource? I try add several ways to add internal resource to the "unsplash_images" array, but no success. Please help!
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/picasso/Picasso;
at com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter.setUpImage(ImageGalleryAdapter.java:105)
at
com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter.onBindViewHolder(ImageGalleryAdapter.java:55)
@lawloretienne Hi,
I have used the following code to open the ImageGalleryActivity:
Intent intent = new Intent(BaseActivity.this, ImageGalleryActivity.class);
String[] images = getResources().getStringArray(R.array.unsplash_images);
Bundle bundle = new Bundle();
bundle.putStringArrayList(ImageGalleryActivity.KEY_IMAGES, new ArrayList<>(Arrays.asList(images)));
bundle.putString(ImageGalleryActivity.KEY_TITLE, "Unsplash Images");
intent.putExtras(bundle);
startActivity(intent);
(Also added image urls in strings file)
But, i see the app is crashing with the following log:
04-02 23:12:53.080 29349-29349/nikhil.reddy.MNB E/AndroidRuntime: FATAL EXCEPTION: main
Process: nikhil.reddy.MNB, PID: 29349
java.lang.NullPointerException: Attempt to invoke interface method 'void com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter$ImageThumbnailLoader.loadImageThumbnail(android.widget.ImageView, java.lang.String, int)' on a null object reference
at com.etiennelawlor.imagegallery.library.activities.ImageGalleryActivity.loadImageThumbnail(ImageGalleryActivity.java:98)
at com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter.onBindViewHolder(ImageGalleryAdapter.java:69)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6482)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6515)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5458)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5724)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:608)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:759)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2515)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2224)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1410)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6834)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:778)
at android.view.Choreographer.doFrame(Choreographer.java:713)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
04-02 23:12:53.082 29349-29349/nikhil.reddy.MNB E/AndroidRuntime: FATAL EXCEPTION: main
Process: nikhil.reddy.MNB, PID: 29349
java.lang.NullPointerException: Attempt to invoke interface method 'void com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter$ImageThumbnailLoader.loadImageThumbnail(android.widget.ImageView, java.lang.String, int)' on a null object reference
at com.etiennelawlor.imagegallery.library.activities.ImageGalleryActivity.loadImageThumbnail(ImageGalleryActivity.java:98)
at com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter.onBindViewHolder(ImageGalleryAdapter.java:69)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6482)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6515)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5458)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5724)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5563)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5559)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2229)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1516)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:608)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3693)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3410)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3962)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1791)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1635)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1544)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:759)
at android.view.View.layout(View.java:19692)
at android.view.ViewGroup.layout(ViewGroup.java:6057)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2515)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2224)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1410)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6834)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:778)
at android.view.Choreographer.doFrame(Choreographer.java:713)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6809)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I have also seen another guy has posted similar error log, and mentioned it was cleared on using Pallete, but i am even more confused with it. Please help me in resolving it.
Images in the same row of grid don't seem to have a margin separation between them.. it does exist between the rows.. just not between the columns.
I downloaded your code from github, ran it.. and the UI came out just right.
I copied the same code to a new project (including your images xml file) and images in the same row don't have a margin anymore!
Here's a screenshot: http://imgur.com/a/U6Bde
Feature Required: Allow activity customization specially for the FullScreenImageGalleryActivity has a toolbar so allow to auto hide that like standard gallery apps
It would be nice the possibility to enter in inmersive mode on image touch when is in fullscreen, just like Google Photos app does.
I've tried to implement it but TouchImageView consumes the ontouch event.
When i am trying to put ArrayList as generated from manually image stored in primary storage, it displays blank image placeholders, and on click it displays the selected image no of total but image is not showing,
How to put Image ArrayList in the bundle.putStringArrayList() section?
not from static , i want it dynamic
Access level of private final List images; could be protected so anyone could extend Adapter and add or remove items in Image list.
Would be nice to be able to hide the toolbar when in FullScreenImageGalleryActivity.
Single tap will hide the toolbar, tapping again would show it.
Will help on images where there are text at the upper part.
Thanks!
Hi Team.
For some reason, I want to use Glide library to load image instead of Picasso as your example.
When I used Glide, The image not able to load Image.
My code like that:
public void loadFullScreenImage(final ImageView iv, final String imageUrl, int width, final LinearLayout bgLinearLayout) { Log.d(TAG, "loadFullScreenImage: " + imageUrl); Glide.with(iv.getContext()).load(imageUrl).into(iv); } else { iv.setImageDrawable(null); } }
Please help me to do it.
Thank you very much.
Feature required: Use App Theme or change theme of the activities. Although theme for FullScreenImageGalleryActivity can be replaced using tools:replace="android:theme".
Hello LawLoretienne,
Thank you for this great image gallery ! while i was implement the gallery i face a null object reference exception
My Code:
Intent intent = new Intent(MainActivity.this, ImageGalleryActivity.class);
String path = Environment.getExternalStorageDirectory().toString() + "/req_images/photos";
Log.d("Files", "Path: " + path);
File directory = new File(path);
File[] files = directory.listFiles();
Log.d("Files", "Size: "+ files.length);
String[] images = new String[files.length];
for (int i = 0; i < files.length; i++)
{
images[i] = path+"/"+files[i].getName();
Log.d("Files", "FileName:" + path+"/"+files[i].getName());
}
Log.d("Files",images.length+"~~");
Bundle bundle = new Bundle();
bundle.putStringArrayList(ImageGalleryActivity.KEY_IMAGES, new ArrayList<>(Arrays.asList(images)));
bundle.putString(ImageGalleryActivity.KEY_TITLE, "Gallery");
intent.putExtras(bundle);
startActivity(intent);
The Error i'm getting:
java.lang.NullPointerException: Attempt to invoke interface method 'void com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter$ImageThumbnailLoader.loadImageThumbnail(android.widget.ImageView, java.lang.String, int)' on a null object reference
at com.etiennelawlor.imagegallery.library.activities.ImageGalleryActivity.loadImageThumbnail(ImageGalleryActivity.java:101)
at com.etiennelawlor.imagegallery.library.adapters.ImageGalleryAdapter.onBindViewHolder(ImageGalleryAdapter.java:58)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5471)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5504)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4741)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:528)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
at android.view.View.layout(View.java:16653)
at android.view.ViewGroup.layout(ViewGroup.java:5438)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2198)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1958)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
at android.view.Choreographer.doCallbacks(Choreographer.java:672)
at android.view.Choreographer.doFrame(Choreographer.java:608)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.jav
if you can point me at the error i would be grateful i added the activity you requested to the manifest file, and i'm attempting to launch the intent from a actionbar button click, thank you!
hello how can i change the actionbar background colour and the whole activity background colour?
after using this library and material dialog library gradle will show error that drwable resource not found related to alpha_close.
gradle file
compile('com.github.afollestad.material-dialogs:core:0.8.5.1@aar') {
transitive = true
}
compile 'com.github.lawloretienne:imagegallery:0.0.13'
Error:
/Users/apple/Desktop/androidApp/app/build/intermediates/exploded-aar/com.github.afollestad.material-dialogs/core/0.8.5.1/res/values-v11/values-v11.xml
Error:(3, 5) No resource found that matches the given name (at 'android:actionModeCloseDrawable' with value '@drawable/abc_ic_ab_back_mtrl_am_alpha').
I want to set the background color to com.etiennelawlor.imagegallery.library.enums.PaletteColorType.LIGHT_VIBRANT
Currently, I am trying
intent.putExtra("palette_color_type", com.etiennelawlor.imagegallery.library.enums.PaletteColorType.LIGHT_VIBRANT);
It doesn't work
Also, I am noticed that gridItemWidth is being passed to the height in two area of layout param and images.
Is it possible to enter the full view of the image without having the small preview layer?
Thanks
Right now the library works fine, but the developer should implement a new activity. Would be great if the library give the option to implement its "magic" in a fragment instead of an Activity.
can u add in this app download and share full screen iamge ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.