Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.13 KB | None | 0 0
  1. Logcat
  2.  
  3. 08-27 15:57:10.434: E/ActivityManager(80): ANR in com.example.positivityapp (com.example.positivityapp/.CreateSlideActivity)
  4. 08-27 15:57:10.434: E/ActivityManager(80): Reason: keyDispatchingTimedOut
  5.  
  6. package com.example.positivityapp;
  7. import android.app.Activity;
  8. import android.content.Intent;
  9. import android.net.Uri;
  10. import android.os.Bundle;
  11. import android.view.Menu;
  12. import android.view.View;
  13. import android.widget.AdapterView;
  14. import android.widget.Button;
  15. import android.widget.ImageView;
  16. import android.widget.TextView;
  17. import android.widget.Toast;
  18. import java.util.ArrayList;
  19. import com.example.positivityapp.db.DBAdapter;
  20. import com.example.positivityapp.views.DraggableGridView;
  21.  
  22.  
  23.  
  24. public class CreateSlideActivity extends Activity {
  25.  
  26. private ArrayList<String> arl;
  27. Boolean arrsize;
  28. DraggableGridView dgv;
  29. ArrayList localArrayList;
  30. DBAdapter localDBAdapter;
  31. private FullImageLoader mLoder;
  32. private Uri musicUrl;
  33. private TextView textViewMessagetitle;
  34. boolean url = true;
  35.  
  36. private void SaveVideo()
  37. {
  38. if (this.musicUrl != null)
  39. {
  40. String str = this.musicUrl.toString();
  41. this.localDBAdapter.addSlideShow(str, this.arl);
  42. Toast.makeText(getBaseContext(), "Saved!", 0).show();
  43. this.url = false;
  44. finish();
  45. return;
  46. }
  47. if (this.url) {}
  48. this.localDBAdapter.addSlideShow(null, this.arl);
  49. Toast.makeText(getBaseContext(), "Saved!", 0).show();
  50. this.url = true;
  51. finish();
  52. }
  53. private void setListeners()
  54. {
  55. this.dgv.setOnRearrangeListener(new com.animoto.android.views.OnRearrangeListener()
  56. {
  57. public void onRearrange(int paramAnonymousInt1, int paramAnonymousInt2)
  58. {
  59. String str = (String)CreateSlideActivity.this.arl.remove(paramAnonymousInt1);
  60. if (paramAnonymousInt1 < paramAnonymousInt2)
  61. {
  62. CreateSlideActivity.this.arl.add(paramAnonymousInt2, str);
  63. return;
  64. }
  65. CreateSlideActivity.this.arl.add(paramAnonymousInt2, str);
  66. }
  67. });
  68. this.dgv.setOnItemClickListener(new AdapterView.OnItemClickListener()
  69. {
  70. public void onItemClick(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
  71. {
  72. CreateSlideActivity.this.dgv.removeViewAt(paramAnonymousInt);
  73. CreateSlideActivity.this.arl.remove(paramAnonymousInt);
  74. }
  75. });
  76. }
  77.  
  78. protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  79. {
  80. super.onActivityResult(paramInt1, paramInt2, paramIntent);
  81. if ((paramInt2 == -1) && (paramIntent != null))
  82. {
  83. if (paramInt1 != 1) {
  84. for (;;)
  85. {
  86.  
  87. if (paramInt1 == 0)
  88. {
  89. this.localArrayList = ((ArrayList)paramIntent.getSerializableExtra("list"));
  90. if (this.arl == null)
  91. {
  92. this.arl = this.localArrayList;
  93. this.arrsize = Boolean.valueOf(true);
  94. }
  95. if (this.arrsize.booleanValue())
  96. {
  97. int k = 0;
  98. if (this.localArrayList != null)
  99. {
  100. this.textViewMessagetitle.setVisibility(0);
  101. this.dgv.setVisibility(0);
  102. this.arl.addAll(this.localArrayList);
  103. k = this.localArrayList.size();
  104. }
  105. for (int m = 0;; m++)
  106. {
  107. if (m >= k / 2)
  108. {
  109. this.arrsize = Boolean.valueOf(false);
  110. return;
  111. }
  112. this.localArrayList.remove(m);
  113. ImageView localImageView2 = new ImageView(this);
  114. localImageView2.setScaleType(ImageView.ScaleType.CENTER_CROP);
  115. localImageView2.setImageBitmap(this.mLoder.getBitmap((String)this.localArrayList.get(m), 300, 300));
  116. this.dgv.addView(localImageView2);
  117. }
  118. }
  119. if (this.localArrayList == null) {
  120. break;
  121. }
  122. this.textViewMessagetitle.setVisibility(0);
  123. this.dgv.setVisibility(0);
  124. this.arl.addAll(this.localArrayList);
  125. int i = this.localArrayList.size();
  126. for (int j = 0; j < i; j++)
  127. {
  128. ImageView localImageView1 = new ImageView(this);
  129. localImageView1.setScaleType(ImageView.ScaleType.CENTER_CROP);
  130. localImageView1.setImageBitmap(this.mLoder.getBitmap((String)this.localArrayList.get(j), 300, 300));
  131. this.dgv.addView(localImageView1);
  132. }
  133. }
  134. }
  135. }
  136. this.musicUrl = paramIntent.getData();
  137. }
  138.  
  139. }
  140. public void onBackPressed()
  141. {
  142. super.onBackPressed();
  143.  
  144. }
  145.  
  146. @Override
  147. protected void onCreate(Bundle savedInstanceState) {
  148. super.onCreate(savedInstanceState);
  149. setContentView(R.layout.activity_create_slide);
  150. Button button1 = (Button)findViewById(R.id.buttonChoosePictures);
  151. Button button2 = (Button)findViewById(R.id.buttonMusic);
  152. Button button3 = (Button)findViewById(R.id.buttonPreview);
  153. Button button4 = (Button)findViewById(R.id.buttonSave);
  154. button1.setOnClickListener(new View.OnClickListener()
  155. {
  156. public void onClick(View view)
  157. {
  158. startActivityForResult(new Intent().setClass(CreateSlideActivity.this, MultiPhotoSelectActivity.class), 0);
  159. }
  160. });
  161. button2.setOnClickListener(new View.OnClickListener()
  162. {
  163. public void onClick(View view)
  164. {
  165. Intent localIntent = new Intent();
  166. localIntent.setType("audio/*");
  167. localIntent.setAction("android.intent.action.GET_CONTENT");
  168. CreateSlideActivity.this.startActivityForResult(Intent.createChooser(localIntent, "Complete action using"), 1);
  169. }
  170. });
  171. button3.setOnClickListener(new View.OnClickListener()
  172. {
  173. public void onClick(View view)
  174. {
  175. if (CreateSlideActivity.this.arl == null)
  176. {
  177. Toast.makeText(CreateSlideActivity.this.getBaseContext(), "Choose photos from gallery!", 0).show();
  178. return;
  179. }
  180. Intent localIntent = new Intent();
  181. localIntent.putExtra("list", CreateSlideActivity.this.arl);
  182. localIntent.setData(CreateSlideActivity.this.musicUrl);
  183. localIntent.putExtra("preview", true);
  184. localIntent.putExtra("oldslide", false);
  185. localIntent.setClass(CreateSlideActivity.this, SlideShow.class);
  186. CreateSlideActivity.this.startActivity(localIntent);
  187. }
  188. });
  189. button4.setOnClickListener(new View.OnClickListener()
  190. {
  191. public void onClick(View paramAnonymousView)
  192. {
  193. if (CreateSlideActivity.this.arl == null)
  194. {
  195. Toast.makeText(CreateSlideActivity.this.getBaseContext(), "Choose photos from gallery!", 0).show();
  196. return;
  197. }
  198. CreateSlideActivity.this.localDBAdapter = new DBAdapter(CreateSlideActivity.this);
  199. CreateSlideActivity.this.SaveVideo();
  200. }
  201. });
  202. this.dgv = ((DraggableGridView)findViewById(R.id.vgv));
  203. this.textViewMessagetitle = ((TextView)findViewById(R.id.textViewMessagetitle));
  204. this.mLoder = new FullImageLoader(getBaseContext(), (short)200);
  205. setListeners();
  206. }
  207.  
  208. @Override
  209. public boolean onCreateOptionsMenu(Menu menu) {
  210. // Inflate the menu; this adds items to the action bar if it is present.
  211. getMenuInflater().inflate(R.menu.create_slide, menu);
  212. return true;
  213. }
  214.  
  215. }
  216.  
  217. <?xml version="1.0" encoding="utf-8"?>
  218. <RelativeLayout
  219.  
  220. android:padding="2.0dip"
  221. android:layout_width="fill_parent"
  222. android:layout_height="fill_parent"
  223. android:keepScreenOn="true"
  224. xmlns:android="http://schemas.android.com/apk/res/android"
  225.  
  226. >
  227. <LinearLayout
  228. android:gravity="center"
  229. android:orientation="vertical"
  230. android:id="@+id/layout_button"
  231. android:layout_width="fill_parent"
  232. android:layout_height="fill_parent"
  233. android:layout_above="@+id/ad1">
  234. <LinearLayout
  235. android:gravity="center"
  236. android:orientation="horizontal"
  237. android:layout_width="fill_parent"
  238. android:layout_height="wrap_content"
  239. android:layout_marginBottom="10.0dip">
  240. <Button
  241. android:id="@+id/buttonChoosePictures"
  242. android:background="@drawable/ingallery"
  243. android:layout_width="100.0dip"
  244. android:layout_height="100.0dip" />
  245. <Button
  246. android:id="@+id/buttonMusic"
  247. android:background="@drawable/inmusic"
  248. android:layout_width="100.0dip"
  249. android:layout_height="100.0dip" />
  250. </LinearLayout>
  251. <LinearLayout android:gravity="center"
  252. android:orientation="horizontal"
  253. android:layout_width="fill_parent"
  254. android:layout_height="wrap_content"
  255. android:layout_marginTop="10.0dip">
  256. <Button
  257. android:id="@+id/buttonPreview"
  258. android:background="@drawable/inpreview"
  259. android:layout_width="100.0dip"
  260. android:layout_height="100.0dip" />
  261. <Button
  262. android:id="@+id/buttonSave"
  263. android:background="@drawable/insave"
  264. android:layout_width="100.0dip"
  265. android:layout_height="100.0dip" />
  266. </LinearLayout>
  267. <LinearLayout
  268. android:gravity="center"
  269. android:orientation="vertical"
  270. android:layout_width="fill_parent"
  271. android:layout_height="wrap_content">
  272. <TextView
  273. android:textAppearance="?android:textAppearanceMedium"
  274. android:textColor="@android:color/white"
  275. android:id="@+id/textViewMessagetitle"
  276. android:visibility="gone"
  277. android:layout_width="wrap_content"
  278. android:layout_height="wrap_content"
  279. android:layout_marginTop="3.0dip"
  280. android:layout_marginBottom="2.0dip"
  281. android:text="Drag slide to arrange slide" />
  282. <com.example.positivityapp.views.DraggableGridView
  283. android:scrollbarStyle="insideOverlay"
  284. android:id="@+id/vgv"
  285. android:background="@drawable/bg_grid"
  286. android:visibility="gone"
  287. android:scrollbars="vertical"
  288. android:layout_width="fill_parent"
  289. android:layout_height="wrap_content"
  290. android:layout_marginTop="5.0dip" />
  291. </LinearLayout>
  292. </LinearLayout>
  293.  
  294. </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement