Closed sandeeptiwari closed 11 years ago
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 https://github.com/openaphid/android-flip/issues/25#issuecomment-11700764 to fix this OOM.
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:- and when try to flip shows screen as:-
I am using this code :-
public class FolderList extends BaseActivity
{
private int width;
private int height;
private ArrayList<List
@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
I think commit c187a822e557c15de943da8bb955d6584f09058f may have fix it.
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
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.