Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#523 Add sorting option under Rearrange images #525

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import swati4star.createpdf.R;
import swati4star.createpdf.adapter.RearrangeImagesAdapter;
import swati4star.createpdf.util.Constants;
import swati4star.createpdf.util.ImageSortUtils;
import swati4star.createpdf.util.ThemeUtils;

import static swati4star.createpdf.util.Constants.CHOICE_REMOVE_IMAGE;
Expand Down Expand Up @@ -128,5 +130,24 @@ public static Intent getStartIntent(Context context, ArrayList<String> uris) {
intent.putExtra(PREVIEW_IMAGES, uris);
return intent;
}

private void sortImages() {
new MaterialDialog.Builder(this)
.title(R.string.sort_by_title)
.items(R.array.sort_options_images)
.itemsCallback((dialog, itemView, position, text) -> {
ImageSortUtils.performSortOperation(position, mImages);
mRearrangeImagesAdapter.positionChanged(mImages);
})
.negativeText(R.string.cancel)
.show();
}



@OnClick(R.id.sort)
void sortImg() {
sortImages();
}
}

19 changes: 19 additions & 0 deletions app/src/main/res/layout/activity_rearrange_images.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@

</android.support.design.widget.AppBarLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<Button
android:id="@+id/sort"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:background="@drawable/cornered_edges"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:text="@string/sort"
android:textAllCaps="false"
android:textColor="?attr/bottomSheetTextColor" />
</LinearLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
Expand Down