Skip to content

Commit

Permalink
better image ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Oct 29, 2017
1 parent 747d4a3 commit 40fbe87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

public class ImageProvider {
private static final Comparator<File> modifiedComparator = new Comparator<File>() {
@Override
public int compare(File o1, File o2) {
if(o1.lastModified() > o2.lastModified()) {
return -1;
}
return 1;
}
};

public static List<File> getFilePaths(Context context) {
List<File> resultIAV = new ArrayList<>();

Expand Down Expand Up @@ -69,6 +82,9 @@ public static List<File> getFilePaths(Context context) {
}
}


Collections.sort(resultIAV, modifiedComparator);

return resultIAV;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void onBindViewHolder(final GalleryAdapter.GalleryHolder viewHolder, fina
viewHolder.title.setText(getItem(i).getTitle());
viewHolder.img.setScaleType(ImageView.ScaleType.CENTER_CROP);

Picasso.with(context).load(getItem(i).getImageFile()).resize(240, 120).into(viewHolder.img);
Picasso.with(context).load(getItem(i).getImageFile()).centerCrop().resize(240, 120).into(viewHolder.img);

viewHolder.img.setOnClickListener(new OnClickListener() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/gallery_cell.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#000"
Expand Down

0 comments on commit 40fbe87

Please sign in to comment.