0

Hello to all i have some questions...

I am making new app with imageviews and loading images from web, and i wrote the code and first time the images are downloaded but next time when i open app it load the same images as first time and on my server i replaced this images with other one ( with same name and extension ). I need your help

here is my fragment code:

package layout;



 import android.os.Bundle;
   import android.os.CountDownTimer;
   import android.support.v4.app.Fragment;
   import android.support.v4.view.ViewPager;
   import android.view.LayoutInflater;
   import android.view.View;
   import android.view.ViewGroup;
   import android.webkit.WebSettings;
   import android.webkit.WebView;
   import android.webkit.WebViewClient;
   import android.widget.FrameLayout;
   import android.widget.LinearLayout;
   import android.widget.ProgressBar;

   import com.example.pecurka.clubdraganm.R;
   import com.loopj.android.image.SmartImageView;


   public class second_frag extends Fragment {
private ProgressBar progress;
private String url;



@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.second_frag, container, false);
    url = getArguments().getString("msg");

    SmartImageView myImage2 = (SmartImageView) v.findViewById(R.id.my_image2);
    myImage2.setImageResource(R.drawable.logo);
    myImage2.setImageUrl(url);



    FrameLayout r_frag2 = (FrameLayout) v.findViewById(R.id.reservieren_frag2);
    r_frag2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ViewPager pager = (ViewPager) getActivity().findViewById(R.id.viewPager);
            pager.setVisibility(View.GONE);

            LinearLayout indicator = (LinearLayout) getActivity().findViewById(R.id.indicator);
            indicator.setVisibility(View.GONE);

            progress = (ProgressBar) getActivity().findViewById(R.id.progressBar1);
            progress.setVisibility(View.VISIBLE);

            WebView web = (WebView) getActivity().findViewById(R.id.webView);
            web.loadUrl("http://plastifikacija-bogdanic.com/dm/reservierung");
            web.setWebViewClient(new MyWebViewClient());

            WebSettings webSettings = web.getSettings();
            webSettings.setJavaScriptEnabled(true);
            getActivity().setTitle("Reservierung");


        }
    });



    return v;





}

public static second_frag newInstance(String text) {

    second_frag f = new second_frag();
    Bundle b = new Bundle();
    b.putString("msg", text);

    f.setArguments(b);

    return f;
}


private class MyWebViewClient extends WebViewClient {


    @Override
    public void onPageFinished(WebView view, String url) {
        progress.setProgress(100);
        progress.setVisibility(View.GONE);
        WebView web = (WebView) getActivity().findViewById(R.id.webView);
        web.setVisibility(View.VISIBLE);

        FrameLayout reservieren = (FrameLayout) getActivity().findViewById(R.id.submitbtn);
        reservieren.setVisibility(View.VISIBLE);

        super.onPageFinished(view, url);

    }


}

}

I have three fragments the same as this one and this fragments are showing in viewpager, and i will whn i replace images on server that the images load automaticali at next startup in my app.

Thanks

  • it seems SmartImageView expects unique url to refresh images. similar question is discussed [here](http://stackoverflow.com/questions/29194496/smartimageview-i-would-like-to-force-refresh-and-not-caching) – ugur Mar 31 '16 at 00:31

1 Answers1

0

You are using the SmartImageView library which caches the image on disk for future loading. As stated here: http://loopj.com/android-smart-image-view/

If you have updated the images on the server and want to clear the cache, you can do so using:

WebImageCache cache = new WebImageCache(context);
cache.clear();

Or you can manually delete the cached files from the disk on this path: "/web_image_cache/"

Arshad Mehmood
  • 409
  • 3
  • 14