Re: [android-developers] Re: Image loading from remote problem

2010-11-17 Thread Kumar Bibek
Well, I cannot write up the whole code for this, but I am sure it's quite
possible to do what you are saying.

On Wed, Nov 17, 2010 at 7:31 PM, umakantpatil wrote:

> Kumar,
> I have already checked your pages. Its shows example for drawable
> which you have on mobile.
> I want to load remote image. As remote image loading takes long time.
> UI hangs up till the time.
>
> I have also seen that you have written saying that we can pass null
> and open new thread which downloads image to local.
> Replace's the path to local file in html and then reset the text in
> TextView.
>
> This works fine when textview has one image but when our text has 2/3
> img tags. Each time getter is called and 2/3 new threads get open and
> 2/3 times text is reset.
> Lets imagine case where means while image downloads in new thread then
> user goes to other activity and the one which we opened is destroyed.
> Also the case where in same acitivty i have 2/3 pages like which has
> next and prev button. So the image comes bit late and then the thread
> will take other text and replace it somewhere else
>
> I dont know but Im going it in big confusion. Is there some direct
> widget for this ?
>
> I dont want to use webview as I have some other things which gets
> disturb because of webview. Need to it in textview only.
>
>
> On Nov 17, 6:26 pm, Kumar Bibek  wrote:
> > http://techdroid.kbeanie.com/2010/06/textview-with-html-content.html
> >
> > On Nov 17, 6:17 pm, umakantpatil  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > No one in the form knows the answer ?
> > > weired :(
> >
> > > On Nov 14, 10:38 pm, umakantpatil  wrote:
> >
> > > > Thanks Kumar,
> > > > I said it previous that i know i can load it async or in new thread.
> > > > But after getting the image I don't know how to replace that image
> > > > back in textview.
> >
> > > > Can you help me with small piece of code that how can i do it ?
> >
> > > > On Oct 27, 4:05 pm, Kumar Bibek  wrote:
> >
> > > > > Do the fetching image part in a thread. That will solve your
> problem.
> >
> > > > > On Wed, Oct 27, 2010 at 4:25 PM, umakantpatil <
> umakantpat...@gmail.com>wrote:
> >
> > > > > > I have HTML text, I need to show it in textview. I did it. There
> are
> > > > > > some images in it. I also made ImageGetter
> > > > > > which loads image from remote server and displays it. But the
> issue is
> > > > > > now its very slow.
> > > > > > I know i can load it async. But i haven't got a single example or
> help
> > > > > > for this.
> >
> > > > > > Below is the code to get the image
> >
> > > > > >  @Override
> > > > > >public Drawable getDrawable(String source) {
> > > > > >Drawable drawable = null;
> > > > > >Bitmap bitmap = null;
> > > > > >InputStream in = null;
> > > > > >BufferedOutputStream out = null;
> > > > > >try {
> > > > > >in = new BufferedInputStream(new
> > > > > > URL(source).openStream(),4096);
> > > > > >final ByteArrayOutputStream dataStream =
> new
> > > > > > ByteArrayOutputStream();
> > > > > >out = new BufferedOutputStream(dataStream,
> 4096);
> > > > > >copy(in, out);
> > > > > >out.flush();
> > > > > >final byte[] data =
> dataStream.toByteArray();
> > > > > >bitmap =
> BitmapFactory.decodeByteArray(data, 0,
> > > > > > data.length);
> > > > > >drawable = new BitmapDrawable(bitmap);
> >
> > > > > >int width = getScreen();
> > > > > >int fin = width - 120;
> >
> > > > > >drawable.setBounds(0, 0, fin, 200);
> > > > > >return drawable;
> > > > > >}catch (Throwable e) {
> > > > > >return null;
> > > > > >}
> > > > > > }
> >
> > > > > > Can any one tell my how can get it async without stopping UI?
> >
> > > > > > --
> > > > > > You received this message because you are subscribed to the
> Google
> > > > > > Groups "Android Developers" group.
> > > > > > To post to this group, send email to
> android-developers@googlegroups.com
> > > > > > To unsubscribe from this group, send email to
> > > > > > android-developers+unsubscr...@googlegroups.com cr...@googlegroups.com>
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/android-developers?hl=en
> >
> > > > > --
> > > > > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
>

[android-developers] Re: Image loading from remote problem

2010-11-17 Thread umakantpatil
Kumar,
I have already checked your pages. Its shows example for drawable
which you have on mobile.
I want to load remote image. As remote image loading takes long time.
UI hangs up till the time.

I have also seen that you have written saying that we can pass null
and open new thread which downloads image to local.
Replace's the path to local file in html and then reset the text in
TextView.

This works fine when textview has one image but when our text has 2/3
img tags. Each time getter is called and 2/3 new threads get open and
2/3 times text is reset.
Lets imagine case where means while image downloads in new thread then
user goes to other activity and the one which we opened is destroyed.
Also the case where in same acitivty i have 2/3 pages like which has
next and prev button. So the image comes bit late and then the thread
will take other text and replace it somewhere else

I dont know but Im going it in big confusion. Is there some direct
widget for this ?

I dont want to use webview as I have some other things which gets
disturb because of webview. Need to it in textview only.


On Nov 17, 6:26 pm, Kumar Bibek  wrote:
> http://techdroid.kbeanie.com/2010/06/textview-with-html-content.html
>
> On Nov 17, 6:17 pm, umakantpatil  wrote:
>
>
>
>
>
>
>
> > No one in the form knows the answer ?
> > weired :(
>
> > On Nov 14, 10:38 pm, umakantpatil  wrote:
>
> > > Thanks Kumar,
> > > I said it previous that i know i can load it async or in new thread.
> > > But after getting the image I don't know how to replace that image
> > > back in textview.
>
> > > Can you help me with small piece of code that how can i do it ?
>
> > > On Oct 27, 4:05 pm, Kumar Bibek  wrote:
>
> > > > Do the fetching image part in a thread. That will solve your problem.
>
> > > > On Wed, Oct 27, 2010 at 4:25 PM, umakantpatil 
> > > > wrote:
>
> > > > > I have HTML text, I need to show it in textview. I did it. There are
> > > > > some images in it. I also made ImageGetter
> > > > > which loads image from remote server and displays it. But the issue is
> > > > > now its very slow.
> > > > > I know i can load it async. But i haven't got a single example or help
> > > > > for this.
>
> > > > > Below is the code to get the image
>
> > > > > �...@override
> > > > >                public Drawable getDrawable(String source) {
> > > > >                        Drawable drawable = null;
> > > > >                        Bitmap bitmap = null;
> > > > >                    InputStream in = null;
> > > > >                    BufferedOutputStream out = null;
> > > > >                    try {
> > > > >                            in = new BufferedInputStream(new
> > > > > URL(source).openStream(),4096);
> > > > >                        final ByteArrayOutputStream dataStream = new
> > > > > ByteArrayOutputStream();
> > > > >                        out = new BufferedOutputStream(dataStream, 
> > > > > 4096);
> > > > >                        copy(in, out);
> > > > >                        out.flush();
> > > > >                        final byte[] data = dataStream.toByteArray();
> > > > >                        bitmap = BitmapFactory.decodeByteArray(data, 0,
> > > > > data.length);
> > > > >                        drawable = new BitmapDrawable(bitmap);
>
> > > > >                            int width = getScreen();
> > > > >                            int fin = width - 120;
>
> > > > >                        drawable.setBounds(0, 0, fin, 200);
> > > > >                        return drawable;
> > > > >                    }catch (Throwable e) {
> > > > >                        return null;
> > > > >                }
> > > > > }
>
> > > > > Can any one tell my how can get it async without stopping UI?
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to 
> > > > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com > > > >  cr...@googlegroups.com>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Image loading from remote problem

2010-11-17 Thread Kumar Bibek
http://techdroid.kbeanie.com/2010/06/textview-with-html-content.html

On Nov 17, 6:17 pm, umakantpatil  wrote:
> No one in the form knows the answer ?
> weired :(
>
> On Nov 14, 10:38 pm, umakantpatil  wrote:
>
> > Thanks Kumar,
> > I said it previous that i know i can load it async or in new thread.
> > But after getting the image I don't know how to replace that image
> > back in textview.
>
> > Can you help me with small piece of code that how can i do it ?
>
> > On Oct 27, 4:05 pm, Kumar Bibek  wrote:
>
> > > Do the fetching image part in a thread. That will solve your problem.
>
> > > On Wed, Oct 27, 2010 at 4:25 PM, umakantpatil 
> > > wrote:
>
> > > > I have HTML text, I need to show it in textview. I did it. There are
> > > > some images in it. I also made ImageGetter
> > > > which loads image from remote server and displays it. But the issue is
> > > > now its very slow.
> > > > I know i can load it async. But i haven't got a single example or help
> > > > for this.
>
> > > > Below is the code to get the image
>
> > > > �...@override
> > > >                public Drawable getDrawable(String source) {
> > > >                        Drawable drawable = null;
> > > >                        Bitmap bitmap = null;
> > > >                    InputStream in = null;
> > > >                    BufferedOutputStream out = null;
> > > >                    try {
> > > >                            in = new BufferedInputStream(new
> > > > URL(source).openStream(),4096);
> > > >                        final ByteArrayOutputStream dataStream = new
> > > > ByteArrayOutputStream();
> > > >                        out = new BufferedOutputStream(dataStream, 4096);
> > > >                        copy(in, out);
> > > >                        out.flush();
> > > >                        final byte[] data = dataStream.toByteArray();
> > > >                        bitmap = BitmapFactory.decodeByteArray(data, 0,
> > > > data.length);
> > > >                        drawable = new BitmapDrawable(bitmap);
>
> > > >                            int width = getScreen();
> > > >                            int fin = width - 120;
>
> > > >                        drawable.setBounds(0, 0, fin, 200);
> > > >                        return drawable;
> > > >                    }catch (Throwable e) {
> > > >                        return null;
> > > >                }
> > > > }
>
> > > > Can any one tell my how can get it async without stopping UI?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com > > >  cr...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Image loading from remote problem

2010-11-17 Thread umakantpatil
No one in the form knows the answer ?
weired :(

On Nov 14, 10:38 pm, umakantpatil  wrote:
> Thanks Kumar,
> I said it previous that i know i can load it async or in new thread.
> But after getting the image I don't know how to replace that image
> back in textview.
>
> Can you help me with small piece of code that how can i do it ?
>
> On Oct 27, 4:05 pm, Kumar Bibek  wrote:
>
>
>
>
>
>
>
> > Do the fetching image part in a thread. That will solve your problem.
>
> > On Wed, Oct 27, 2010 at 4:25 PM, umakantpatil 
> > wrote:
>
> > > I have HTML text, I need to show it in textview. I did it. There are
> > > some images in it. I also made ImageGetter
> > > which loads image from remote server and displays it. But the issue is
> > > now its very slow.
> > > I know i can load it async. But i haven't got a single example or help
> > > for this.
>
> > > Below is the code to get the image
>
> > > �...@override
> > >                public Drawable getDrawable(String source) {
> > >                        Drawable drawable = null;
> > >                        Bitmap bitmap = null;
> > >                    InputStream in = null;
> > >                    BufferedOutputStream out = null;
> > >                    try {
> > >                            in = new BufferedInputStream(new
> > > URL(source).openStream(),4096);
> > >                        final ByteArrayOutputStream dataStream = new
> > > ByteArrayOutputStream();
> > >                        out = new BufferedOutputStream(dataStream, 4096);
> > >                        copy(in, out);
> > >                        out.flush();
> > >                        final byte[] data = dataStream.toByteArray();
> > >                        bitmap = BitmapFactory.decodeByteArray(data, 0,
> > > data.length);
> > >                        drawable = new BitmapDrawable(bitmap);
>
> > >                            int width = getScreen();
> > >                            int fin = width - 120;
>
> > >                        drawable.setBounds(0, 0, fin, 200);
> > >                        return drawable;
> > >                    }catch (Throwable e) {
> > >                        return null;
> > >                }
> > > }
>
> > > Can any one tell my how can get it async without stopping UI?
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com > >  cr...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Image loading from remote problem

2010-11-14 Thread umakantpatil
Thanks Kumar,
I said it previous that i know i can load it async or in new thread.
But after getting the image I don't know how to replace that image
back in textview.

Can you help me with small piece of code that how can i do it ?

On Oct 27, 4:05 pm, Kumar Bibek  wrote:
> Do the fetching image part in a thread. That will solve your problem.
>
> On Wed, Oct 27, 2010 at 4:25 PM, umakantpatil wrote:
>
>
>
>
>
>
>
>
>
>
>
> > I have HTML text, I need to show it in textview. I did it. There are
> > some images in it. I also made ImageGetter
> > which loads image from remote server and displays it. But the issue is
> > now its very slow.
> > I know i can load it async. But i haven't got a single example or help
> > for this.
>
> > Below is the code to get the image
>
> > �...@override
> >                public Drawable getDrawable(String source) {
> >                        Drawable drawable = null;
> >                        Bitmap bitmap = null;
> >                    InputStream in = null;
> >                    BufferedOutputStream out = null;
> >                    try {
> >                            in = new BufferedInputStream(new
> > URL(source).openStream(),4096);
> >                        final ByteArrayOutputStream dataStream = new
> > ByteArrayOutputStream();
> >                        out = new BufferedOutputStream(dataStream, 4096);
> >                        copy(in, out);
> >                        out.flush();
> >                        final byte[] data = dataStream.toByteArray();
> >                        bitmap = BitmapFactory.decodeByteArray(data, 0,
> > data.length);
> >                        drawable = new BitmapDrawable(bitmap);
>
> >                            int width = getScreen();
> >                            int fin = width - 120;
>
> >                        drawable.setBounds(0, 0, fin, 200);
> >                        return drawable;
> >                    }catch (Throwable e) {
> >                        return null;
> >                }
> > }
>
> > Can any one tell my how can get it async without stopping UI?
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscr...@googlegroups.com > cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en