-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,454 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/src/main/java/de/timonback/android/whatisthatplace/activity/GalleryFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package de.timonback.android.whatisthatplace.activity; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
|
||
import de.timonback.android.whatisthatplace.Constants; | ||
import de.timonback.android.whatisthatplace.R; | ||
import de.timonback.android.whatisthatplace.activity.provider.DBProvider; | ||
import de.timonback.android.whatisthatplace.activity.provider.ImageProvider; | ||
import de.timonback.android.whatisthatplace.component.MyCallable; | ||
import de.timonback.android.whatisthatplace.component.database.VisionResultDbHelper; | ||
import de.timonback.android.whatisthatplace.component.gallery.GalleryAdapter; | ||
import de.timonback.android.whatisthatplace.component.gallery.GalleryItem; | ||
|
||
public class GalleryFragment extends Fragment { | ||
public static final String LOG_NAME = GalleryFragment.class.getName(); | ||
|
||
private DBProvider dbProvider; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
View view = inflater.inflate(R.layout.fragment_gallery, container, false); | ||
|
||
RecyclerView recyclerView = (RecyclerView)view.findViewById(R.id.imagegallery); | ||
recyclerView.setHasFixedSize(true); | ||
|
||
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(),3); | ||
recyclerView.setLayoutManager(layoutManager); | ||
|
||
ArrayList<GalleryItem> createLists = prepareData(); | ||
GalleryAdapter adapter = new GalleryAdapter(getActivity(), createLists, new MyCallable<GalleryItem>() { | ||
@Override | ||
public void call(GalleryItem item) { | ||
Log.i(LOG_NAME, "Gallery Click"); | ||
String filePath = item.getImageFile().getPath(); | ||
|
||
//gVisionComponent.analyze(filePath, GVisionComponent.FEATURE.LANDMARK); | ||
} | ||
}); | ||
recyclerView.setAdapter(adapter); | ||
|
||
return view; | ||
} | ||
|
||
private ArrayList<GalleryItem> prepareData() { | ||
ArrayList<GalleryItem> items = new ArrayList<>(); | ||
|
||
for(File image: ImageProvider.getFilePaths(getActivity())) { | ||
items.add(new GalleryItem(image.getName(), image)); | ||
} | ||
|
||
return items; | ||
} | ||
|
||
/** | ||
* Use this factory method to create a new instance of | ||
* this fragment using the provided parameters. | ||
* | ||
* @return A new instance of fragment GalleryFragment. | ||
*/ | ||
public static GalleryFragment newInstance(DBProvider dbProvider) { | ||
GalleryFragment fragment = new GalleryFragment(); | ||
fragment.dbProvider = dbProvider; | ||
|
||
Bundle args = new Bundle(); | ||
fragment.setArguments(args); | ||
return fragment; | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
if (getArguments() != null) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/de/timonback/android/whatisthatplace/activity/provider/DBProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package de.timonback.android.whatisthatplace.activity.provider; | ||
|
||
import de.timonback.android.whatisthatplace.component.database.VisionResultDbHelper; | ||
|
||
public interface DBProvider { | ||
VisionResultDbHelper getDB(); | ||
} |
74 changes: 74 additions & 0 deletions
74
app/src/main/java/de/timonback/android/whatisthatplace/activity/provider/ImageProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package de.timonback.android.whatisthatplace.activity.provider; | ||
|
||
import android.content.ContentValues; | ||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.provider.MediaStore; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
public class ImageProvider { | ||
public static List<File> getFilePaths(Context context) { | ||
List<File> resultIAV = new ArrayList<>(); | ||
|
||
String[] projection = { MediaStore.Images.Media.DATA }; | ||
Cursor c = null; | ||
Uri u = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; | ||
if (u != null) | ||
{ | ||
c = context.getContentResolver().query(u, projection, null, null, null); | ||
} | ||
|
||
Set<String> directories = new TreeSet<>(); | ||
if ((c != null) && (c.moveToFirst())) { | ||
do { | ||
String tempDir = c.getString(0); | ||
tempDir = tempDir.substring(0, tempDir.lastIndexOf("/")); | ||
try { | ||
directories.add(tempDir); | ||
} catch (Exception e) { | ||
|
||
} | ||
} | ||
while (c.moveToNext()); | ||
|
||
c.close(); | ||
} | ||
|
||
for (String directory: directories) { | ||
File imageDir = new File(directory); | ||
File[] imageList = imageDir.listFiles(); | ||
if (imageList == null) | ||
continue; | ||
for (File imagePath : imageList) { | ||
try { | ||
|
||
if (imagePath.isDirectory()) { | ||
imageList = imagePath.listFiles(); | ||
} | ||
if (imagePath.getName().contains(".jpg") || imagePath.getName().contains(".JPG") | ||
|| imagePath.getName().contains(".jpeg") || imagePath.getName().contains(".JPEG") | ||
|| imagePath.getName().contains(".png") || imagePath.getName().contains(".PNG") | ||
|| imagePath.getName().contains(".gif") || imagePath.getName().contains(".GIF") | ||
|| imagePath.getName().contains(".bmp") || imagePath.getName().contains(".BMP") | ||
) { | ||
|
||
resultIAV.add(imagePath); | ||
|
||
} | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
return resultIAV; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/de/timonback/android/whatisthatplace/component/MyCallable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package de.timonback.android.whatisthatplace.component; | ||
|
||
|
||
public interface MyCallable<T> { | ||
void call(T param); | ||
} |
Oops, something went wrong.