@Override protected void onDestroy() { super.onDestroy(); if (_adapter != null) { _adapter.free(); } }
@Override protected void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.tile_picker); ListView list = (ListView) findViewById(R.id.tile_picker_tile_list); if (state != null && state.containsKey(TILE_ARRAY_BUNDLE_KEY)) { _tile_array = state.getStringArray(TILE_ARRAY_BUNDLE_KEY); if (_tile_array.length == 0) { _tile_array = Assets.apkListTiles(this); } } else { _tile_array = Assets.apkListTiles(this); } list.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = getIntent(); i.putExtra( StyleEditorActivity.TILE_EXTRA, StyleData.DEFAULT_TILE_LOCATION_PREFIX + view.getTag().toString()); setResult(Activity.RESULT_OK, i); finish(); } }); Button open_gallery = new Button(this); open_gallery.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult( Intent.createChooser(intent, getString(R.string.tile_picker_open_gallery)), TILE_GALLERY_RESULT); } }); open_gallery.setText(R.string.tile_picker_open_gallery); list.addFooterView(open_gallery); _adapter = new TilePickerAdapter(this); // Don't use array in the constructor to avoid caching problems list.setAdapter(_adapter); for (String tile : _tile_array) { _adapter.add(tile); } }