I have a webview and i have next previous buttons to get to the next or previous picture.
What i want to do if possible is : Can i display the first picture but the webview loads (in the background the other pictures(other URLS) so that are available in the cache when a new picture is needed. Thank you
This is possible if you use two Webviews and a ViewFlipper to change between them.
This way while the user looks at one, the other is loading the content. And when flips(you need to implement) it will bring up instantly the loaded image.
Related
I have a long list of images that i need to show in to recyclerView. I am using glide to show the images from my adapter.
Glide.with(context).load(feed.getImgLink()).diskCacheStrategy(DiskCacheStrategy.NONE).into(holder.myImgView);
The above is the code am using i set the DiskCacheStrategy to none because I'm trying to show Instagram like Feed and i didn't want to permanently cache the img on disk.
The first time i see the image there is no problem it is displayed normal but after i scroll down and back up the image reload again. I get that i haven't cache the image in to disk but there is still momery cache.
Is there any way i can solve i could use diskcache to ALL but it is taking space for just one time viewing.
Try this.
Glide.with(context).load(imageUrl).into(holder.myImgView);
I have realised an NFC reader application
So i have 3 activities :
MainActivity, which is an activity who contains a Button. If button is clicked, the scan is activated and the user can put his NFC tag against the device to detect it.
WebActivity, who is launched if the NFC tag contains and URL (and open a WebView) or if the user want to launch WebActivity by himself
HistoryActivity, who gonna contains a list of every scans.
Now, I would like to swipe activity with a finger gesture. according to my research on Internet. I need fragments and ViewPager.
But every example that I saw is bases on ONE activity and multiple fragments.
But in my case, I have to create 3 fragments (one per activity), right ?
And I really don't know how to manage my fragment. I mean, what to put inside ?
All I want to do is create a transition/animation while changing activity... That's crazy
This is too broad of a question but hopefully my answer will steer you in right direction.
You should definitely go with single activity/multiple fragments model. Aside of recommendations by Google, you could use navigation components, deep linking much easier then without single activity.
Yes you should be using ViewPager for the purpose (and likely your implementation of FragmentPagerAdapter as well) however I do not understand what kind of swiping will you be doing
Reading your setup, I would suggest to use bottom view with 2 items (good example is here https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample/app/src/main/java/com/example/android/navigationadvancedsample). 2nd one would show history, first one would offer a button that activates your action, and then displays fragment with your WebView.
As a side effect of such implementation, you'd be able to go back from 2nd bottom view item to whatever first one holds - by pressing system back button - which I think is nice touch.
UPDATE to "swiping takes place anytime. " comment:
You could have single activity, ViewPager with 2 fragments. First fragment would display a button, 2nd fragment would display a history. You could freely swipe between them, as you want to. However to me it does not make sense to put WebView screen into this. WebView screen is result of action (NFC detection) and it should probably display as full screen, without any chance of swiping between main/history and itself. Hope it helps or I'm missing some important piece of info you did not share.
In my app i have button when it clicked the app goes to another activity with webView to show HTML table
The issue here is when i press back and return to the same activity the webView load agin and it take while how can i prevent it from loading over and over agin and will turnning the HTML table to listview will make it loade faster if yes . How ?
You can Preserving the state of an Android WebView on screen orientation change or activity is paused.
If you’ve tried to use a WebView inside your app, you know that the standard behavior on screen orientation change is not satisfactory in most cases because the full state of the WebView is not preserved or similarly when your activity is pause same situation WebView will change their sate.
possible implementation to keep the full state of the WebView
here complete tutorial and code is given you can get idea from this code&tutorial
I'm fairly new to Android programming and I've got this project I need to finish and I'm currently stuck.
I've got a standard listview in a Menu class with an array containing around 20 different elements. So what I want to do is load images in an imageview depending on which item in the listview I click, and since I'm a beginner the only idea I had was to make a new activity for each imageview which seems like a pretty bad way to do it since I'd need about 20-30 new activities..
To sum things up what I want is:
Code for making ONE activity that will display a different image depending on which item in the listview I click, probably pretty basic coding I want as simple solution as possible.
If possible I'm also looking for a solution that includes an SQLite database that stores the URL of an image and then display it in a single activity, also depending on which item I press in my current listview.
(I hope you understand my needs, and if you need I can also post my current code for the Menu class if it helps you help me) Or you can just show me a different way to make this work, I appreciate every answer! Thanks in advance!
NOTE
And please keep in mind, I'm a noob at Java and Android so keep it rather simple or at least explain what you do.
When you click on a list item, display the image in another view in the same layout, unless you want the image to take up the entire screen real estate. If you want it in the entire screen, go to a new Activity by sending the activity an Intent.
Activities are the "controller" of your application. They interact with the visible UI and the input from the user. You don't need a separate activity for each image, just an activity that's associated with a "place" in the UI (an ImageView) where you'll display the image.
I'd start by adding the images as resources under res/drawable before going on to databases.
You are going to have to do most of this yourself. There really isn't any substitute for taking the time to learn Java and Android. There are several tutorials and Android University classes under the Resources tab in the Developers Guide; I suggest you do all of them.
What I am looking to do is to capture an image on a button click, without requesting any other input from the user.
At the moment I'm using a MediaStore.ACTION_IMAGE_CAPTURE intent inside my activity, which is called when pressing a button on a widget. At the moment this opens the camera preview allowing me to take a picture.
That's all working great, however what I'm looking to do is when the user presses the button on the widget, take the picture straight away and display a preview of the captured image. So it essentially snaps the picture automatically, without the need for the user to press anything else.
I tried using the Camera API directly, using a SurfaceView class to capture the image and call the PictureCallback etc, this worked how I want it to, however the quality of the images was very low and I couldn't figure out how to change it.
So I guess I'm looking for an answer to either of those two problems, or both if anyone knows them.
Firstly, is there anyway, using something similar to a MediaStore.ACTION_IMAGE_CAPTURE intent to snap the image automatically without requesting the user to take the picture.
Or secondly, how can I increase the quality and resolution of an image captured using the Camera API directly (camera.takePicture(shutterCallback, rawCallback, jpegCallback); and all that business).
Any help would be much appreciated.
Did you try autoFocus?