diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 25835731c..9add12392 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -20,5 +20,9 @@ + + diff --git a/app/src/main/java/gallery/simplemobiletools/com/Constants.java b/app/src/main/java/gallery/simplemobiletools/com/Constants.java new file mode 100644 index 000000000..7fb01ae80 --- /dev/null +++ b/app/src/main/java/gallery/simplemobiletools/com/Constants.java @@ -0,0 +1,5 @@ +package gallery.simplemobiletools.com; + +public class Constants { + public static final String DIRECTORY = "directory"; +} diff --git a/app/src/main/java/gallery/simplemobiletools/com/Directory.java b/app/src/main/java/gallery/simplemobiletools/com/Directory.java index 136d1ee5a..10dd30abd 100644 --- a/app/src/main/java/gallery/simplemobiletools/com/Directory.java +++ b/app/src/main/java/gallery/simplemobiletools/com/Directory.java @@ -1,16 +1,22 @@ package gallery.simplemobiletools.com; public class Directory { + private final String path; private final String thumbnail; private final String name; private int photoCnt; - public Directory(String thumbnail, String name, int photoCnt) { + public Directory(String path, String thumbnail, String name, int photoCnt) { + this.path = path; this.thumbnail = thumbnail; this.name = name; this.photoCnt = photoCnt; } + public String getPath() { + return path; + } + public String getThumbnail() { return thumbnail; } diff --git a/app/src/main/java/gallery/simplemobiletools/com/MainActivity.java b/app/src/main/java/gallery/simplemobiletools/com/MainActivity.java index 4ebc950a7..6690bfc83 100644 --- a/app/src/main/java/gallery/simplemobiletools/com/MainActivity.java +++ b/app/src/main/java/gallery/simplemobiletools/com/MainActivity.java @@ -1,10 +1,14 @@ package gallery.simplemobiletools.com; +import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.GridView; import java.io.File; @@ -13,7 +17,8 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -public class MainActivity extends AppCompatActivity { +public class MainActivity extends AppCompatActivity implements OnItemClickListener { + private List dirs; @Override protected void onCreate(Bundle savedInstanceState) { @@ -21,9 +26,10 @@ public class MainActivity extends AppCompatActivity { setContentView(R.layout.activity_main); final GridView gridView = (GridView) findViewById(R.id.photo_grid); - final List dirs = new ArrayList<>(getDirectories().values()); + dirs = new ArrayList<>(getDirectories().values()); final DirectoryAdapter adapter = new DirectoryAdapter(this, dirs); gridView.setAdapter(adapter); + gridView.setOnItemClickListener(this); } private Map getDirectories() { @@ -44,7 +50,7 @@ public class MainActivity extends AppCompatActivity { } else { final String thumbnail = file.getAbsolutePath(); final String dirName = fileDir.substring(fileDir.lastIndexOf("/") + 1); - directories.put(fileDir, new Directory(thumbnail, dirName, 1)); + directories.put(fileDir, new Directory(fileDir, thumbnail, dirName, 1)); } } while (cursor.moveToNext()); cursor.close(); @@ -52,4 +58,11 @@ public class MainActivity extends AppCompatActivity { return directories; } + + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + final Intent intent = new Intent(this, PhotosActivity.class); + intent.putExtra(Constants.DIRECTORY, dirs.get(position).getPath()); + startActivity(intent); + } } diff --git a/app/src/main/java/gallery/simplemobiletools/com/PhotosActivity.java b/app/src/main/java/gallery/simplemobiletools/com/PhotosActivity.java new file mode 100644 index 000000000..3444c2781 --- /dev/null +++ b/app/src/main/java/gallery/simplemobiletools/com/PhotosActivity.java @@ -0,0 +1,15 @@ +package gallery.simplemobiletools.com; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +public class PhotosActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_photos); + + final String path = getIntent().getStringExtra(Constants.DIRECTORY); + } +} diff --git a/app/src/main/res/layout/activity_photos.xml b/app/src/main/res/layout/activity_photos.xml new file mode 100644 index 000000000..c881b43c0 --- /dev/null +++ b/app/src/main/res/layout/activity_photos.xml @@ -0,0 +1,8 @@ + + + +