android - Application not running properly on Samsung Galaxy Ace -
i have made application not running on samsung galaxy ace.my problem when trying call particular activity dialog box on activity not work.although able call remaining activities same activity. can not understand problem behind it.
please me. thanks.
my calling activity code is:
public void onclick(view v) { if(iscollageframeselected) { editimageactivity.this.progress = progressdialog.show(editimageactivity.this, "", "loading collage frames...", true); editimageactivity.this.framedialog.dismiss(); new thread(new runnable() { public void run() { intent localintent = new intent(editimageactivity.this, photocollageactivity.class); localintent.putextra(constants.layout_id , layoutid); localintent.putextra(constants.image_count, imgcount); localintent.putextra(constants.mybitmap, selectedbitmap); startactivity(localintent); editimageactivity.this.progress.dismiss(); } }).start(); }
my called activity code is:
public class photocollageactivity extends fragmentactivity implements view.ontouchlistener, view.onlongclicklistener { private colorfilter filter; private int imgcount = 3; private int imgid; private list<integer> imgids; private int lastaction = 0; private map<integer, matrix> matrix = new hashmap<integer, matrix>(); private int mode = 0; private int moveactions = 0; private map<integer, float> olddist = new hashmap<integer, float>(); private map<integer, integer> patterns; private progressdialog pd; private bitmap photo; private map<string, pointf> points = new hashmap<string, pointf>(); private map<integer, matrix> savedmatrix = new hashmap<integer, matrix>(); private map<integer, border> bordersmap = new hashmap<integer, border>(); private dialogfragment df; dialog dialog; private handler handler = new handler() { public void handlemessage(message paramanonymousmessage) { photocollageactivity.this.setimage(); photocollageactivity.this.pd.dismiss(); } }; private handler handlerdialog = new handler() { public void handlemessage(message paramanonymousmessage) { try { photocollageactivity.this.df.dismiss(); return; } catch (exception localexception) { localexception.printstacktrace(); } } }; private void dumpevent(motionevent parammotionevent) { string[] arrayofstring = { "down", "up", "move", "cancel", "outside", "pointer_down", "pointer_up", "7?", "8?", "9?" }; stringbuilder localstringbuilder = new stringbuilder(); int = parammotionevent.getaction(); int j = & 0xff; localstringbuilder.append("event action_").append(arrayofstring[j]); if ((j == 5) || (j == 6)) { localstringbuilder.append("(pid ").append(i >> 8); localstringbuilder.append(")"); } localstringbuilder.append("["); (int k = 0; ; k++) { if (k >= parammotionevent.getpointercount()) { localstringbuilder.append("]"); return; } localstringbuilder.append("#").append(k); localstringbuilder.append("(pid ").append(parammotionevent.getpointerid(k)); localstringbuilder.append(")=").append((int)parammotionevent.getx(k)); localstringbuilder.append(",").append((int)parammotionevent.gety(k)); if (k + 1 < parammotionevent.getpointercount()) localstringbuilder.append(";"); } } private map<integer, border> getbordersmap() { hashmap<integer, border> localhashmap = new hashmap<integer, border>(); localhashmap.put(integer.valueof(r.id._1_img ), new border(r.id._1_border)); localhashmap.put(integer.valueof(r.id._2_img), new border(r.id._2_border)); localhashmap.put(integer.valueof(r.id._3_img), new border(r.id._3_border)); localhashmap.put(integer.valueof(r.id._4_img), new border(r.id._4_border)); return localhashmap; } private list<integer> getimageviewids() { arraylist<integer> localarraylist = new arraylist<integer>(); localarraylist.add(integer.valueof(r.id._1_img)); localarraylist.add(integer.valueof(r.id._2_img)); localarraylist.add(integer.valueof(r.id._3_img)); localarraylist.add(integer.valueof(r.id._4_img)); return localarraylist; } public static map<integer, integer> getpatterns() { hashmap<integer, integer> localhashmap = new hashmap<integer, integer>(); localhashmap.put(integer.valueof(r.id. pattern_01 ),integer.valueof(r.drawable.tile_christ_1)); localhashmap.put(integer.valueof(r.id.pattern_02), integer.valueof(r.drawable.tile_christ_2)); localhashmap.put(integer.valueof(r.id.pattern_03), integer.valueof(r.drawable.tile_christ_3 )); localhashmap.put(integer.valueof(r.id.pattern_04), integer.valueof(r.drawable.tile_christ_4)); localhashmap.put(integer.valueof(r.id.pattern_05), integer.valueof(r.drawable.tile_christ_5)); localhashmap.put(integer.valueof(r.id.pattern_06), integer.valueof(r.drawable.tile_christ_6)); localhashmap.put(integer.valueof(r.id.pattern_07), integer.valueof(r.drawable.tile_christ_7)); localhashmap.put(integer.valueof(r.id.pattern_08), integer.valueof(r.drawable.tile_christ_8)); localhashmap.put(integer.valueof(r.id.pattern_09), integer.valueof(r.drawable.tile_christ_9)); localhashmap.put(integer.valueof(r.id.pattern_1), integer.valueof(r.drawable.p1)); localhashmap.put(integer.valueof(r.id.pattern_2), integer.valueof(r.drawable.p2)); localhashmap.put(integer.valueof(r.id.pattern_3), integer.valueof(r.drawable.p3)); localhashmap.put(integer.valueof(r.id.pattern_4), integer.valueof(r.drawable.p4)); localhashmap.put(integer.valueof(r.id.pattern_5), integer.valueof(r.drawable.p5)); localhashmap.put(integer.valueof(r.id.pattern_6), integer.valueof(r.drawable.p6)); localhashmap.put(integer.valueof(r.id.pattern_7), integer.valueof(r.drawable.p7)); localhashmap.put(integer.valueof(r.id.pattern_8), integer.valueof(r.drawable.p8)); localhashmap.put(integer.valueof(r.id.pattern_9), integer.valueof(r.drawable.p9)); localhashmap.put(integer.valueof(r.id.pattern_10), integer.valueof(r.drawable.p10)); localhashmap.put(integer.valueof(r.id.pattern_11), integer.valueof(r.drawable.p11)); localhashmap.put(integer.valueof(r.id.pattern_12), integer.valueof(r.drawable.p12)); localhashmap.put(integer.valueof(r.id.pattern_13), integer.valueof(r.drawable.p13)); localhashmap.put(integer.valueof(r.id.pattern_14), integer.valueof(r.drawable.p14)); localhashmap.put(integer.valueof(r.id.pattern_15), integer.valueof(r.drawable.p15)); localhashmap.put(integer.valueof(r.id.pattern_16), integer.valueof(r.drawable.p16)); localhashmap.put(integer.valueof(r.id.pattern_17), integer.valueof(r.drawable.p17)); localhashmap.put(integer.valueof(r.id.pattern_18), integer.valueof(r.drawable.p18)); localhashmap.put(integer.valueof(r.id.pattern_19), integer.valueof(r.drawable.p19)); localhashmap.put(integer.valueof(r.id.pattern_20), integer.valueof(r.drawable.p20)); localhashmap.put(integer.valueof(r.id.pattern_21), integer.valueof(r.drawable.p21)); localhashmap.put(integer.valueof(r.id.pattern_22), integer.valueof(r.drawable.p22)); localhashmap.put(integer.valueof(r.id.pattern_23), integer.valueof(r.drawable.p23)); localhashmap.put(integer.valueof(r.id.pattern_24), integer.valueof(r.drawable.p24)); localhashmap.put(integer.valueof(r.id.pattern_25), integer.valueof(r.drawable.p25)); return localhashmap; } private void getphotobitmap(string paramstring) { bitmapfactory.options localoptions = new bitmapfactory.options(); localoptions.injustdecodebounds = false; localoptions.insamplesize = bitmaputils.calculateinsamplesize(paramstring); try { this.photo = bitmapfactory.decodefile(paramstring, localoptions); return; } catch (outofmemoryerror localoutofmemoryerror) { this.photo.recycle(); localoptions.insamplesize = (1 + localoptions.insamplesize); } } private void midpoint(pointf parampointf, motionevent parammotionevent) { float f1 = parammotionevent.getx(0) + parammotionevent.getx(1); float f2 = parammotionevent.gety(0) + parammotionevent.gety(1); parampointf.set(f1 / 2.0f, f2 / 2.0f); } private void setimage() { ((imageview)findviewbyid(this.imgid)) .setimagebitmap(imagehelper.getroundedcornerbitmap(this.photo, 10)); } private float spacing(motionevent parammotionevent) { float f1 = parammotionevent.getx(0) - parammotionevent.getx(1); float f2 = parammotionevent.gety(0) - parammotionevent.gety(1); return (float) java.lang.math.sqrt(f1 * f1 + f2 * f2); } protected void oncreate(bundle parambundle) { super.oncreate(parambundle); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); this.imgids = getimageviewids(); this.bordersmap = getbordersmap(); this.patterns = getpatterns(); bundle localbundle = getintent().getextras(); this.filter = new colorfilter(); int = 0; iterator<integer> localiterator; if ((localbundle != null) && (localbundle.getint(constants.layout_id) != 0) && (localbundle.getint(constants.image_count) != 0)) { setcontentview(localbundle.getint(constants.layout_id)); this.imgcount = localbundle.getint(constants.image_count); while (i < this.imgcount) { imageview localimageview = (imageview)findviewbyid(((integer)this.imgids.get(i)).intvalue()); this.matrix.put(integer.valueof(localimageview.getid()), new matrix()); this.savedmatrix.put(integer.valueof(localimageview.getid()), new matrix()); this.olddist.put(integer.valueof(localimageview.getid()), float.valueof(1.0f)); this.points.put("start" + localimageview.getid(), new pointf()); this.points.put("mid" + localimageview.getid(), new pointf()); localimageview.setontouchlistener(this); localimageview.setonlongclicklistener(this); i++; } } if((bitmap)this.getintent().getparcelableextra(constants.mybitmap) != null) { ((imageview)findviewbyid(((integer)this.imgids.get(new random().nextint(2))))) .setimagebitmap(imagehelper.getroundedcornerbitmap((bitmap)this.getintent() .getparcelableextra(constants.mybitmap), 10)); } ((imageview)findviewbyid(r.id.sharebtn)).setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { bitmap localbitmap = bitmaputils.loadbitmapfromview(photocollageactivity.this .findviewbyid(r.id.mashup_container)); string str = bitmaputils.savebitmap(localbitmap, "loveframes_" + new simpledateformat("yyyymmdd_hhmmss",locale.us) .format(new date()).tostring(), getcontentresolver()); toast.maketext(photocollageactivity.this, "image has been saved in gallery at" +str, toast.length_long).show(); localbitmap.recycle(); intent localintent = new intent("android.intent.action.send"); localintent.settype("image/jpeg"); localintent.putextra("android.intent.extra.stream", uri.fromfile(new file(str))); localintent.addflags(1); localintent.putextra("android.intent.extra.subject", "check out photo collage"); localintent.putextra("android.intent.extra.text", "from photocollage"); photocollageactivity.this.startactivity(localintent); } }); ////////////////// set tiles background of layout /////////////////////////////// localiterator = this.patterns.keyset().iterator(); while (localiterator.hasnext()) { findviewbyid(((integer)localiterator.next()).intvalue()) .setonclicklistener(new view.onclicklistener() { @suppresswarnings("deprecation") public void onclick(view paramanonymousview) { bitmap localbitmap = bitmapfactory.decoderesource(photocollageactivity.this.getresources(), (integer)photocollageactivity.this.patterns. get(integer.valueof(paramanonymousview.getid()))).intvalue()); bitmapdrawable localbitmapdrawable = new bitmapdrawable(photocollageactivity.this.getresources(), localbitmap); localbitmapdrawable.settilemodexy(shader.tilemode.repeat, shader.tilemode.repeat); photocollageactivity.this.findviewbyid(r.id.mashup_container) .setbackgrounddrawable(localbitmapdrawable); } }); } } ///////////////////////////////////////////////////////////////////////////////////////////////// public boolean onlongclick(view paramview) { fragmentmanager localfragmentmanager = getsupportfragmentmanager(); new dialogkolaz().show(localfragmentmanager, "fragment_edit_name"); return true; } ///////////////////////////////////////////////////////////////////////////////////////////////// public boolean ontouch(view paramview, motionevent parammotionevent) { imageview localimageview = (imageview)paramview; dumpevent(parammotionevent); switch (motionevent.action_mask & parammotionevent.getaction()) { case 3: case 4: case motionevent.action_down: ((matrix)this.savedmatrix.get(integer.valueof(paramview.getid()))) .set((matrix)this.matrix.get(integer.valueof(paramview.getid()))); ((pointf)this.points.get("start" + paramview.getid())) .set(parammotionevent.getx(), parammotionevent.gety()); this.mode = constants.drag; this.lastaction = 0; break; case motionevent.action_pointer_down: this.lastaction = -1; this.olddist.put(integer.valueof(paramview.getid()), float.valueof(spacing(parammotionevent))); if (((float)this.olddist.get(integer.valueof(paramview.getid()))).floatvalue() > 10.0f) { ((matrix)this.savedmatrix.get(integer.valueof(paramview.getid()))) .set((matrix)this.matrix.get(integer.valueof(paramview.getid()))); midpoint((pointf)this.points.get("mid" + paramview.getid()), parammotionevent); this.mode = constants.zoom; } break; case motionevent.action_up: case motionevent.action_pointer_up: if (this.lastaction < 4) { fragmentmanager localfragmentmanager = getsupportfragmentmanager(); this.df = new dialogkolaz(); this.df.setstyle(2, 0); this.df.show(localfragmentmanager, "fragment_edit_name"); this.lastaction = -1; this.imgid = paramview.getid(); } this.mode = constants.none; break; case motionevent.action_move: this.lastaction = (1 + this.lastaction); this.moveactions = (1 + this.moveactions); if (this.mode == constants.drag) { ((matrix)this.matrix.get(integer.valueof(paramview.getid()))) .set((matrix)this.savedmatrix.get(integer.valueof(paramview.getid()))); ((matrix)this.matrix.get(integer.valueof(paramview.getid()))) .posttranslate(parammotionevent.getx() - ((pointf)this.points .get("start" + paramview.getid())).x, parammotionevent.gety() - ((pointf)this.points.get("start" + paramview.getid())).y); } else if (this.mode == constants.zoom ) { float f1 = spacing(parammotionevent); if (f1 > 10.0f) { ((matrix)this.matrix.get(integer.valueof(paramview.getid()))) .set((matrix)this.savedmatrix.get(integer.valueof(paramview.getid()))); float f2 = f1 / ((float)this.olddist.get(integer.valueof(paramview.getid()))).floatvalue(); ((matrix)this.matrix.get(integer.valueof(paramview.getid()))) .postscale(f2, f2, ((pointf)this.points.get("mid" + paramview.getid())).x, ((pointf)this.points.get("mid" + paramview.getid())).y); } } break; } localimageview.setimagematrix((matrix)this.matrix.get(integer.valueof(paramview.getid()))); return true; } ////////////////////////////////////////////////////////////////////////////////// @suppresslint("validfragment") private class dialogkolaz extends dialogfragment { public dialogkolaz() { } public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode,data); if (resultcode != result_ok){ photocollageactivity.this.handlerdialog.sendemptymessage(0); return; } try { if ((requestcode == constants.app_kolaz_gallery) && (resultcode == result_ok )) { uri localuri = data.getdata(); photocollageactivity.this.handlerdialog.sendemptymessage(0); string[] arrayofstring = { "_data" }; cursor localcursor = photocollageactivity.this.getcontentresolver() .query(localuri, arrayofstring, null, null, null); localcursor.movetofirst(); string str = localcursor.getstring(localcursor.getcolumnindex(arrayofstring[0])); localcursor.close(); photocollageactivity.this.getphotobitmap(str); } else if ((requestcode == constants.app_kolaz_camera) && (resultcode == result_ok)) { photocollageactivity.this.pd = progressdialog.show(photocollageactivity.this, "working", "please wait...", true, false); new photocollageactivity.photothread().start(); } photocollageactivity.this.setimage(); } catch (exception localexception) { localexception.printstacktrace(); } } ///////////////////////////////////////////////////////////////////////////////////////// public view oncreateview(layoutinflater paramlayoutinflater, viewgroup paramviewgroup, bundle parambundle) { view localview = paramlayoutinflater.inflate(r.layout.choose_dialog, paramviewgroup,false); imageview localimageview1 = (imageview)localview.findviewbyid(r.id.gallery); imageview localimageview2 = (imageview)localview.findviewbyid(r.id.camera); imageview localimageview3 = (imageview)localview.findviewbyid(r.id.rotate); imageview localimageview4 = (imageview)localview.findviewbyid(r.id.borders); imageview localimageview5 = (imageview)localview.findviewbyid(r.id.imgeffect); localimageview1.setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { intent localintent = new intent("android.intent.action.pick", mediastore.images.media.external_content_uri); photocollageactivity.dialogkolaz.this.startactivityforresult(localintent, constants.app_kolaz_gallery); } }); localimageview2.setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { intent localintent = new intent("android.media.action.image_capture"); localintent.putextra("output", uri.fromfile(new file("/sdcard/tmp.file"))); photocollageactivity.dialogkolaz.this.startactivityforresult(localintent, constants.app_kolaz_camera); } }); localimageview3.setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { matrix localmatrix = new matrix(); localmatrix.postrotate(90.0f); imageview localimageview = (imageview)photocollageactivity.this. findviewbyid(photocollageactivity.this.imgid); photocollageactivity.this.photo = ( (bitmapdrawable)localimageview.getdrawable() ).getbitmap(); photocollageactivity.this.photo = bitmap.createbitmap(photocollageactivity.this.photo, 0, 0, photocollageactivity.this.photo.getwidth(), photocollageactivity.this.photo.getheight(), localmatrix, true); localimageview.setimagebitmap(photocollageactivity.this.photo); photocollageactivity.this.handlerdialog.sendemptymessage(0); } }); localimageview4.setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { border localborder = (border)photocollageactivity.this.bordersmap .get(integer.valueof(photocollageactivity.this.imgid)); view localview = photocollageactivity.this.findviewbyid(localborder.id); if (localborder.visible) { localview.setbackgroundresource(r.drawable.rounded_transparent); localborder.visible = false; } else { photocollageactivity.this.handlerdialog.sendemptymessage(0); localview.setbackgroundresource(r.drawable.rounded); localborder.visible = true; } photocollageactivity.this.handlerdialog.sendemptymessage(0); } }); localimageview5.setonclicklistener(new view.onclicklistener() { public void onclick(view paramanonymousview) { imageview localimageview = (imageview)photocollageactivity.this. findviewbyid(photocollageactivity.this.imgid); int choose = new random().nextint(10); if(choose == 0) { photocollageactivity.this.filter = effectutils.adjusthue(350 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 1) { photocollageactivity.this.filter = effectutils.adjusthue(400 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 2) { photocollageactivity.this.filter = effectutils.adjusthue(500 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 3) { photocollageactivity.this.filter = effectutils.adjusthue(300 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 4) { photocollageactivity.this.filter = effectutils.adjusthue(150 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 5) { photocollageactivity.this.filter = effectutils.adjusthue(175 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 6) { photocollageactivity.this.filter = effectutils.adjusthue(125 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 7) { photocollageactivity.this.filter = effectutils.adjusthue(100 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 8) { photocollageactivity.this.filter = effectutils.adjusthue(75 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } if(choose == 9) { photocollageactivity.this.filter = effectutils.adjusthue(50 - 255); localimageview.setcolorfilter(photocollageactivity.this.filter); } } }); return localview; } } ////////////////////////////////////////////////////////////////////////////////////// private class photothread extends thread { private photothread() { } public void run() { photocollageactivity.this.getphotobitmap("/sdcard/tmp.file"); photocollageactivity.this.handler.sendemptymessage(0); } } }
Comments
Post a Comment