Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

We can See image of second page from first page? #32

Closed
sandeeptiwari opened this issue Dec 26, 2012 · 4 comments
Closed

We can See image of second page from first page? #32

sandeeptiwari opened this issue Dec 26, 2012 · 4 comments
Labels

Comments

@sandeeptiwari
Copy link

I am making application using this library ,And find two new issue please see it.
1- I am able to see second page image from first.I have tried to solve by commenting blending but its
not working.
2- I putting image this manner
11
22

loading image from sd card through AsynkTask and try to turn next page a blank page show nothing shows,but if I load image without AsynkTask take time but working fine.My need is after click progressbar is showing and load using AsynkTask.

3- How I face OOM exception because occurs every time when moving one page to other

thanks.

@VAdaihiep
Copy link

1, 2. You should use https://github.com/nostra13/Android-Universal-Image-Loader to load image, it's have call back onStart(), onSuccess(), etc.

@OverRide
onStart() {
progressBar.setVisible(View.VISIBLE);
}
@OverRide
onSuccess(){
flipView.refreshPage(int positionOfPage); // I think it will fix your issue 1
progressBar.setVisible(View.GONE);
}

Issue 3: You could try to follow my comment #25 (comment)
to fix this OOM.

@openaphid
Copy link
Owner

#33 fixes a memory leak issue, which could be relevant to your problem.

@sandeeptiwari
Copy link
Author

Hi,
where is onSuccessMethod in Activity.Here I am putting My code you can see logic After fetching image from sd-card and set Adapter and try to flip nothing shows screen become white and red.Why showing red I am not understand ,please see it thanks.
first when Load screen looks as:-
1
and
when try to flip shows screen as:-
2

I am using this code :-

public class FolderList extends BaseActivity
{
private int width;
private int height;
private ArrayList<List> objalbummodlelist;
private ArrayList objalbumlistall;
private Cursor imagecursor;
private String all_thumabnais_path;
private AlbumModle objalbummodle;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Display display = getWindowManager().getDefaultDisplay();
    width = display.getWidth();
    height = display.getHeight();
    Bundle objbundle = getIntent().getExtras();
    if(objbundle!=null)
    {
        String from = objbundle.getString("from");
        if(from.equalsIgnoreCase("folder"))
        {
            new FolderAsynkTask().execute();
        }
    }
}

private class FolderAsynkTask extends AsyncTask<Void, Void, ArrayList<List<AlbumModle>>>
{

    private final ProgressDialog objprogressdialog = new ProgressDialog(FolderList.this);
    @Override
    protected void onPreExecute()
    {
        objprogressdialog.setMessage("Please wait while loading...");
        objprogressdialog.show();
    }

    @Override
    protected ArrayList<List<AlbumModle>> doInBackground(Void... params)
    {
        ArrayList<AlbumModle> objalllist = fetchAllImages();
        ArrayList<AlbumModle> objallfolderlist = makeGroup(objalllist);
        Map<Album, List<AlbumModle>> objmap = groupTheList(objallfolderlist);
        ArrayList<List<AlbumModle>> objfinallist = makeList(objmap);
        return objfinallist;
    }

    @Override
    protected void onPostExecute(ArrayList<List<AlbumModle>> result)
    {
        if(objprogressdialog.isShowing())
        {
            objprogressdialog.dismiss();
        }

        if (height >= 320) {
            flipView.setAdapter(new FolderListAdapter(result,
                    FolderList.this, height,
                    width,imageLoader));
        }
        getMiddleView().removeAllViews();
        getMiddleView().addView(flipView);
    }
}

private ArrayList<AlbumModle> fetchAllImages()
 {
    final int newcount = 0;
    objalbumlistall = new ArrayList<AlbumModle>();
    ContentResolver objcr=getContentResolver();
    String[] columns = { MediaStore.Images.Media.DATA,
            MediaStore.Images.Media._ID };
    String orderBy = MediaStore.Images.Media._ID;
    //imagecursor = managedQuery(
            //MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
        //  null, orderBy);
    imagecursor = objcr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            null, null, null, null);

    while(imagecursor.moveToNext())
    {
        objalbummodle = new AlbumModle();
        String imagename = "";
        String placevalue="";

        int image_column_index = imagecursor
                .getColumnIndex(MediaStore.Images.Media._ID);

        int dataColumnIndex = imagecursor
                .getColumnIndex(MediaStore.Images.Media.DATA);

        String findpath = imagecursor.getString(dataColumnIndex);

        String date1 = imagecursor.getString(imagecursor
                .getColumnIndex(MediaStore.Images.Media.DATE_TAKEN));

        Long d = Long.parseLong(date1);
        Date date = new Date(d);
        DateFormat dataformat = DateFormat
                .getDateInstance(DateFormat.LONG);
        String dateandmonth = dataformat.format(date);

        all_thumabnais_path = "/" + getPath(findpath);

        if ((findpath.contains("jpeg")
                || findpath.contains("jpg")
                || findpath.contains("JPG") || findpath
                    .contains("JPEG"))) {
            String test_name = new File(findpath).getName();
            if (test_name.contains("jpeg") || test_name.contains("JPEG")) {
                imagename = test_name.substring(0, test_name.length() - 5);
            } else if (test_name.contains("jpg")
                    || test_name.contains("JPG")) {
                imagename = test_name.substring(0, test_name.length() - 4);
            }
        }

        String lat = imagecursor.getString(imagecursor
                .getColumnIndex(MediaStore.Images.Media.LATITUDE));
        String longi = imagecursor.getString(imagecursor
                .getColumnIndex(MediaStore.Images.Media.LONGITUDE));

        if(lat!=null && !lat.equalsIgnoreCase("") && longi!=null && !longi.equalsIgnoreCase(""))
        {
            double latti = Double.parseDouble(lat);
            double longiti = Double.parseDouble(longi);
            GetLocationFromLatLong objGetLocationFromLatLong = new GetLocationFromLatLong();  
            placevalue = objGetLocationFromLatLong.getFromLocation(latti,longiti,1);    
            Log.e("check======",placevalue);
        }

        objalbummodle.setPath(all_thumabnais_path);
        objalbummodle.setImgplace(placevalue);
        objalbummodle.setImgdate(dateandmonth);
        objalbummodle.setPath(all_thumabnais_path);
        objalbummodle.setImagepath(findpath);
        objalbummodle.setFoldername(getFolder(findpath));
        objalbumlistall.add(objalbummodle);
    }
    return objalbumlistall;
}

private String getPath(String path) {
    String finalpath = "";
    if (path != null) {
        String str[] = path.split("/");
        for (int index = 0; index < str.length - 1; index++) {
            if (finalpath.equals("")) {
                finalpath = str[index];
            } else {
                finalpath = finalpath + "/" + str[index];
            }
        }

    }
    return finalpath;
}

private String getFolder(String path) {
    String finalpath = "";
    if (path != null) {
        String str[] = path.split("/");
        finalpath = finalpath + "/" + str[str.length - 2];

    }
    return finalpath;
}

private  ArrayList<AlbumModle> makeGroup(ArrayList<AlbumModle> objalllist)
{
     ArrayList<AlbumModle> objalbumfolder= new ArrayList<AlbumModle>();

    for (int index = 0; index < objalllist.size(); index++)
    {
        if(objalllist!=null && objalllist.size()>index)
        {

            if(objalllist.get(index).getFoldername()!=null && !objalllist.get(index).getFoldername().equals(""))
            {
                objalbumfolder.add(objalllist.get(index));
            }
        }
    }

    return objalbumfolder;
}

private Map<Album, List<AlbumModle>> groupTheList(
        List<AlbumModle> arrayList) {
    Map<Album, List<AlbumModle>> map = new HashMap<Album, List<AlbumModle>>();
    for (AlbumModle appSet : arrayList) {
        Album objalbum = new Album(appSet.getPath());
        List<AlbumModle> list = map.get(objalbum);
        if (list == null) {
            list = new ArrayList<AlbumModle>();
            map.put(objalbum, list);
        }
        list.add(appSet);
    }
    return map;
}

private ArrayList<List<AlbumModle>> makeList(Map<Album, List<AlbumModle>> objmap)
{
    ArrayList<List<AlbumModle>> objlist=new ArrayList<List<AlbumModle>>();
    for (Map.Entry<Album, List<AlbumModle>> entry : objmap.entrySet()) {

        List<AlbumModle> objlist1 = entry.getValue();
        objlist.add(objlist1);
    }
    return objlist;

}

}

/////////////////////////////////////////////////////////////
load image by passing sd card path as:-
objimgloader.displayImage(objmaplist.get(index).get(0).getImagepath(), objrow1img1,options);

see this issue I think this one of bug

@openaphid
Copy link
Owner

I think commit c187a82 may have fix it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants