Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3342334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:49:35+00:00 2026-05-18T00:49:35+00:00

friends, i am using following global variables in my activity private String Session_ID; private

  • 0

friends,

i am using following global variables in my activity

private  String Session_ID;
  private  String uid;

  // menu item starts
  private final int Trash = 0x003;
  private final int More = 0x005;
  private final int SignOut = 0x006;
  private final int SignIn = 0x007;
  //menu item ends

   private  EfficientAdapter adap;

  private  String[] Msg_id; 
  private  String[] Msg_body;
  private  String[] Sent_by;
  private  String[] Sent_on;
  private  String[] Is_my_message;
  private  String[] Photo_thumbnail;
  private  String[] Photo_full_path;


  private  String Conversation_id;
   ProgressBar progressBar;
   Button getMoreButton;


   boolean callComplete = false;
   private Handler mHandler = new Handler();
   private int PageSize = Constants.pageSizeForMessages;
   Object serviceData = null; 


   private String ConversationName;
   private Uri selectedImage;





 public  class EfficientAdapter extends BaseAdapter implements Filterable {
                    private LayoutInflater mInflater;
                    private Context context;

                    public EfficientAdapter(Context context) {
                      mInflater = LayoutInflater.from(context);
                      this.context = context;
                    }


                    public View getView(final int position, View convertView, ViewGroup parent) {
                      ViewHolder holder;
                        convertView = mInflater.inflate(R.layout.adaptor_contentmessagedetail, null);
                        holder = new ViewHolder();

                        holder.ImgPhoto = (ImageView)convertView.findViewById(R.id.ImgPhoto);
                        holder.lblMsgSentBy = (TextView) convertView.findViewById(R.id.lblSentBy);
                        holder.lblMsgBody = (TextView) convertView.findViewById(R.id.lblMessageBody);
                        holder.lblMsgSentOn = (TextView) convertView.findViewById(R.id.lblSentOn);


                        convertView.setOnClickListener(new OnClickListener() {
                              @Override
                              public void onClick(View v) {

                                  if (!((MessageDetail)v.getContext()).isConnected()) {
                                        Constants.DisplayMessage(v.getContext(),
                                                Constants.CONNECTION_ERROR_MESSAGE);
                                        return;
                                    }


                                  if(!Photo_full_path[position].equals(""))
                                  {

                                      String str= Photo_full_path[position].substring(Photo_full_path[position].length() - 3);
                                      if(str.equals("pdf"))
                                      {


                                      }else
                                      {

                                  Intent myIntent = new Intent(v.getContext(), ViewSingleImage.class);
                                    Bundle b = new Bundle();
                                    b.putString("single_image_path", Photo_full_path[position] );
                                    myIntent.putExtras(b);
                                    v.getContext().startActivity(myIntent);
                                      }

                                  }

                              }
                            });





                        convertView.setTag(holder);


                      // Bind the data efficiently with the holder.

                      if(Is_my_message[position].equals("1"))
                          holder.lblMsgSentBy.setTextColor(Color.BLACK);
                          else
                          holder.lblMsgSentBy.setTextColor(Color.rgb(255, 107, 1));



                    SimpleDateFormat fromUser = new SimpleDateFormat(Constants.SERVICE_DATE_FORMAT); 
                    java.text.DateFormat df=new SimpleDateFormat(Constants.DATE_FORMAT);                          
                    Date dt=new Date();
                    try
                    {
                        dt = fromUser.parse(Sent_on[position]);

                    } catch (java.text.ParseException e) {
                        e.printStackTrace();
                    }





                    // display photo
                    if(!Photo_thumbnail[position].equals(""))
                    {

                    // resize it
                        holder.ImgPhoto.setImageBitmap(DisplayLiveImage(Photo_thumbnail[position]));

                    }else
                    {
                        holder.ImgPhoto.setVisibility(View.GONE);

                    }
                    // display photo



                      holder.lblMsgSentBy.setText(Constants.GetSpecialCharacters(Sent_by[position]));
                      holder.lblMsgBody.setText(Constants.GetSpecialCharacters(Msg_body[position]));
                      holder.lblMsgSentOn.setText(df.format(dt));


                      return convertView;
                    }

                     class ViewHolder {

                      ImageView ImgPhoto;
                      TextView lblMsgSentBy;
                      TextView lblMsgBody;
                      TextView lblMsgSentOn;

                    }

                    @Override
                    public Filter getFilter() {
                      // TODO Auto-generated method stub
                      return null;
                    }

                    @Override
                    public long getItemId(int position) {
                      // TODO Auto-generated method stub
                      return 0;
                    }

                    @Override
                    public int getCount() {
                      // TODO Auto-generated method stub
                      return Msg_id.length;
                    }

                    @Override
                    public Object getItem(int position) {
                      // TODO Auto-generated method stub
                      return Msg_id[position];
                    }

                  } 

 public Bitmap DisplayLiveImage(String ImageSrc)
        {
            Bitmap bm;
                         try {  

                                 URL aURL = new URL(ImageSrc);  
                                 URLConnection conn = aURL.openConnection(); 

                                 conn.connect();  
                                 InputStream is = null;
                                 try
                                 {
                                     is= conn.getInputStream();  
                                 }catch(IOException e)
                                 {
                                     return null;
                                 }

                                 BufferedInputStream bis = new BufferedInputStream(is);  

                                 bm = BitmapFactory.decodeStream(bis);  
                                 bis.close();  
                                 is.close();  

                            } catch (IOException e) {  
                                return null;
                            }  

                            return  bm;

        }

i have made them global in activity because i need them all in more than 1 functions
now my question is how to improve performance of my activity it is too slow
should i make them static or what?

any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:49:35+00:00Added an answer on May 18, 2026 at 12:49 am

    it is recommended to cache images and dont bring them all again and again from internet.

    so my case while using custom adapter and scrolling it was again and again loading images from internet
    which was causing poor performance.

    and memory leakage problem too.

    so what i did i followed following tutorial to load live images and my problem resolved

    Answer: LazyList

    http://mobilebitworks.wordpress.com/2010/11/05/android-listview-and-dynamically-loading-images-from-the-web

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

friends, i am using following code to resizeImage private Bitmap resizeImage( final Bitmap image)
friends, i am trying to check internetconnectivity in android and using following code final
I'm using the following code to retrieve a user's friends: $fql_query_url = 'https://graph.facebook.com/fql?q=SELECT+uid,+name,+pic_square+FROM+user+WHERE+uid+IN+(SELECT+uid2+FROM+friend+WHERE+uid1+=+me())+order+by+name&access_token=' .
The following batch request for retrieve friends using the same app is not working:
friends, i have created custom title bar using following titlebar.xml file with code <?xml
Friends, I'm populating a GridView in my asp.net application using following code. GridView grdExport
friends, i am using following onDraw method to display bitmap on screen. @Override public
friends, i am using following code to display bitmap on screen and having next
friends, i am trying to upload file to php server using following tutorial http://getablogger.blogspot.com/2008/01/android-how-to-post-file-to-php-server.html
Using the following code to display a list of friends from my twitter profile.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.