| 42 | import android.widget.Toast; |
| 43 | |
| 44 | public class GalleryActivity extends Activity |
| 45 | { |
| 46 | private static final String TAG = GalleryActivity.class.getSimpleName(); |
| 47 | |
| 48 | // An advice from @{link https://developer.android.com/guide/components/intents-filters.html} |
| 49 | // If you define your own actions, be sure to include your app's package name as a prefix. |
| 50 | private static final String EXTRA_PREFIX = App.PACKAGE_NAME; |
| 51 | /* package */ static final String ACTION_PICK_SINGLE = EXTRA_PREFIX + "action.PICK_SINGLE"; |
| 52 | /* package */ static final String ACTION_PICK_MULTIPLE = EXTRA_PREFIX + "action.PICK_MULTIPLE"; |
| 53 | |
| 54 | /* package */ static final String EXTRA_PICTURE_PATH = EXTRA_PREFIX + "extra.PICTURE_PATH"; |
| 55 | /* package */ static final String EXTRA_CLASS = EXTRA_PREFIX + "extra.CLASS"; |
| 56 | /* package */ static final String EXTRA_PICTURE_MAX = EXTRA_PREFIX + "extra.PICTURE_MAX"; |
| 57 | |
| 58 | private static final String TYPE_IMAGE = "image/*"; |
| 59 | |
| 60 | private int picture_max = 9; |
| 61 | |
| 62 | GridView gv_gallery; |
| 63 | GalleryAdapter adapter; |
| 64 | |
| 65 | private ImageView iv_picture_unavailable; |
| 66 | |
| 67 | private LinearLayout ll_thumbnails; |
| 68 | private TextView tv_picture_selection_info; |
| 69 | |
| 70 | private ImageLoader imageLoader; |
| 71 | |
| 72 | @Override |
| 73 | public void onCreate(Bundle savedInstanceState) |
| 74 | { |
| 75 | super.onCreate(savedInstanceState); |
| 76 | setContentView(R.layout.gallery_activity); |
| 77 | |
| 78 | ((TextView)findViewById(R.id.title)).setText(R.string.select_picture); |
| 79 | ll_thumbnails = (LinearLayout)findViewById(R.id.thumbnails); |
| 80 | |
| 81 | Intent intent = getIntent(); |
| 82 | picture_max = intent.getIntExtra(EXTRA_PICTURE_MAX, 9); |
| 83 | |
| 84 | final String action = intent.getAction(); |
| 85 | if(action == null) |
| 86 | finish(); |
| 87 | |
| 88 | initImageLoader(); |
| 89 | init(action); |
| 90 | } |
| 91 | |
| 92 | private void initImageLoader() |
| 93 | { |
| 94 | final String CACHE_DIR = App.getWorkingDirectory() + File.separator + ".temp"; |
| 95 | File file = new File(CACHE_DIR); |
| 96 | if(!file.exists()) |
| 97 | file.mkdirs(); |
| 98 | |
| 99 | try |
| 100 | { |
| 101 | File cacheDir = StorageUtils.getOwnCacheDirectory(getBaseContext(), CACHE_DIR); |
nothing calls this directly
no outgoing calls
no test coverage detected