How download all pictures at the start of mediaManager? - android

I have been working with DJI Mobile SDK for Android, making my own application by following this tutorial: https://developer.dji.com/mobile-sdk/documentation/android-tutorials/MediaManagerDemo.html
But i have to download all pictures at once at the start of my gallery, and i coudn't manage how to do it.
Is there any example showing how to do it?
I think it should happen at MainActivity.java from the MediaManagerDemo tutorial. Should i create getFiles() and put it alongside getThumbnails and getPreviews (on line 317)?
scheduler.resume(new CommonCallbacks.CompletionCallback() {
#Override
public void onResult(DJIError error) {
if (error == null) {
getThumbnails();
getPreviews();
}
}
});
Should i create a Callback for this? What else should i look out?
Thank you all in advance!
EDIT: I stopped and thinked calmly about this, and managed to solve this by creating a downloadAllFiles() method after getPreviews(), where it checks if the connection was succeed and calls downloadFileByIndex for each one of the items. I also implemented a way to check if there is already a file with the exact size on internal storage, to avoid unnecessary downloads.
If anyone is interested, heres my code on Github

Have you looked at the section in the tutorial on Downloading and Editing the Media files?

Related

WebRTC for Android : VideoRendererGUI take a screenshot in the video call

The demand is that saving a video frame in the video call. I have made a demo that take a screenshot through the GLSurfaceView's method "onDrawFrame". But when I use the webrtc, it have its own renderer "VideoRendererGUI" .And then when I want to override it, I find it can't be overrided. the main part code :
vsv = (GLSurfaceView) findViewById(R.id.glviewchild_call);
vsv.setPreserveEGLContextOnPause(true);
vsv.setKeepScreenOn(true);
VideoRendererGui.setView(vsv, new Runnable() {
#Override
public void run() {
init();
}
});
And If you have another way to take a screenshot, you can also share with me.
Thanks a lot!
If you use a SurfaceViewRenderer to display the stream, you can use the solution in this answer to capture a frame on the call.
Basically, using surfaceViewRenderer.AddFrameListener with a class that implements EGLRenderer.FrameListener
I will assume that the SurfaceViewRenderer of the peer you want to take a screenshot of is called remotePeerSurfaceViewRenderer, also I will asume that the button that you will use to take a screenshot is called btnScreenshot
So all what you need to do is as "Webo80" said in the answer above use the FrameListener, the issue is the FrameListener implementation of the webrtc takes only the first frame available once the Listener is attached to the SurfaceViewRenderer, so my approach to do that is by attaching the webrtc implementation of the FrameListsner at the second I need to take a screenshot and remove it once it is taken:
btnScreenshot.setOnClickListener((view)-> {
remotePeerSurfaceViewRenderer.addFrameListsner(new EglRenderer.FrameListener() {
#Override
public void onFrame(Bitmap bitmap) {
runOnUiThread(() -> {
/*
do what ever you want with the bitmap for example
imgView.setImageBitmap(bitmap);
*/
localVideoView.removeFrameListener(this);
});
}
}, 1);
})
Important note:
1. Please don't forget to runOnUiThread as Iam doing
2. Please don't forget to remove the listener inside the button onClick() method
I have tried this solution and it is working more than fine, if you want to make your custom solution you have to completely implement the interface "EglRenderer.FrameListener"
I am sorry to say due to unavailability of canvas and other facilities in Android It's not possible to capture screenshot programatically using WebRTC. One can dodge this situation by animating the app's UI and capturing the screenshot manually , store it at configured location and exchange it with other party.

play-games-plugin-for-unity - show specific Leaderboard

I'm trying to integrate the google play Leaderboard with help of the play-games-plugin-for-unity plugin into my game.
It works fine, committing to Leaderboard an all, only one thing is not working. When I call the Leaderboard
//LEADERBOARD
if (GUI.Button(leaderboardButton, "Leaderboard"))
{
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(Constants.LEADERBOARDID);
// Social.ShowLeaderboardUI();
}
it opens the window where I see all leaderboards. But I'm giving a specific id. This would be the behaviour I expect from the line Social.ShowLeaderboardUI(); which is commented out. The overload with a given Id (hid behind Constants.LEADERBOARDID) should start the specific Leaderboard UI according to the doc. Someone knows if this is an issue (haven't seen any report on GitHub) and how to solve it? It isn't that that big of an issue, but one click is better than two.
I tried something interesting. I changed the Id to some wrong value. Still the same behavior (opening the window with all leaderboards). Of course committing the score doesn't work anymore.
Okay, i found the error in the sourcecode of the Plugin, fixed it and resolved the problem. So here I present the fix if someone needs it. It's in the LeaderboardManager class.
This is how ShowUI is called:
internal void ShowUI(string leaderboardId, Action callback) {
Misc.CheckNotNull(callback);
C.LeaderboardManager_ShowAllUI(mServices.AsHandle(), Callbacks.InternalShowUICallback,
Callbacks.ToIntPtr(callback));
}
This should be the correct version
internal void ShowUI(string leaderboardId, Action callback) {
Misc.CheckNotNull(callback);
C.LeaderboardManager_ShowUI(mServices.AsHandle(),leaderboardId, Callbacks.InternalShowUICallback,
Callbacks.ToIntPtr(callback));
}
}
See the difference? C.LeaderboardManager_ShowAllUI instead of C.LeaderboardManager_ShowUI is called.

Picasso Library Not Loading Images in Android 5.0

I have a ListView extending ArrayAdapter. I am using a view holder patter for the getView and here is a part of my getView method which loads images using picasso. The following code is expected to load images into my image view inside every list item.
Picasso.with(mContext).load(imageURL).fit().into(holder.myImageView,
new Callback(){
#Override
public void onError() {
holder.myImageView.setVisibility(View.INVISIBLE);}
#Override
public void onSuccess() {}});
So here is the problem: this works fine for OS < Android 5.0, but in the case of Android 5.0 (Lollipop), it looks like Picasso is fetching these images when my app is installed and run for the very first time, but when I launch the app again, the images don't load. Not at all sure what the problem is. I am not loading huge images, you can assume all the images that I am loading are only of the size of a small icon/thumbnail (around 120X120). I am using Picasso 2.4.0 for my application and the phone that I am using for testing is the Nexus 4.
Open Issue as of this edit: https://github.com/square/picasso/issues/633
Alternative:
I struggled to find an answer for very long time yesterday night. I explored Picasso really intimately trying several stuff. None did work. So right now what I am doing is:
if(api>=21) //Keeping in mind about any updates beyond 21
Use Android-Universal-Image-Loader
else
Use Picasso
For more information on Andorid Universal Image Loader.
Please visit https://github.com/nostra13/Android-Universal-Image-Loader
Its awesome with its cusotmization.
Agian, dont get me wrong, I am 100% +ve there is a solution with Picasso, I am sure I will find it someday, I will post it here then, but for anyone who have problems like me, I think the above is the way to go. Please suggest if you have anuy other better way.
************************ ISSUE FIXED **************************
https://github.com/square/picasso/issues/632
https://github.com/square/picasso/pull/860
************************** ISSUE FIXED ****************************

Google Tag Manager Not Showing Values

I just started working on Google Tag Manager. I got it worked. But I faced one issue. That is, each time I edit or add some new macros, I need to create new version and publish it. Unless I am not downloading the new version and saving inside assets/tagmanager and also unless I refer with the new version name of the downloaded file, I am not able to see my updates.
Is it so? If so, I didn't understand why this is useful. Is anything done by me went wrong?
I got it worked.The issue was when we keep the json or binary inside assets folder, then on openContainer() call, Google Tag Manager will check for the saved file first. Then only it will goto the network and search. This caused issue to me. So I removed the file kept inside assets/tagmanager folder.
Also I called container.refresh() before we set value inside the singleton class.
Sample code:
ContainerOpener.openContainer(tagManager, CONTAINER_ID, OpenType.PREFER_NON_DEFAULT,
TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS, new ContainerOpener.Notifier() {
#Override
public void containerAvailable(Container container) {
container.refresh();
// Save container for use by any other activities in the app.
WPContainerHolder.setContainer(container);
//perform your other functionalities
}
});

Android - Best way to query device for all folders containing images

Im trying to figure out the best way to get all the directories on a device that contain image files. I know how to use all the api's but my application calls for using an in app image gallery rather than just using an intent to launch the gallery. Ive thought of going through the entire device and looking in the directories and check for extensions but that would take a couple seconds to long. Does any one have a better solution? I already have a very solid custom gallery built but my only problem is coming up with a nice solution to get all the images in other places that my app wont know about.
apache commons-io DirectoryWalker
public class ImagesFinder extends DirectoryWalker{
protected boolean handleDirectory(File directory, int depth, Collection results) {
return true;
}
protected void handleFile(File file, int depth, Collection results) {
//
}
}

Categories

Resources