Show image descriptions in gallery (#630)

* Add circleci

* Commit to maybe fix ci

* Suppress false positives in lint

* Disable linting for tests in ci

* Add image descriptions to gallery

* Fix test

* [CI] Attempt to fix OOM error

* [CI] Attempt to fix OOM error, 2

* Add option to open status from media

* fix theme issue

* increase linespacing on media description
This commit is contained in:
Ivan Kupalov 2018-05-10 21:13:25 +03:00 committed by Konrad Pozniak
commit 23d84dfa66
27 changed files with 313 additions and 193 deletions

View file

@ -4,24 +4,27 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.keylesspalace.tusky.entity.Attachment;
import com.keylesspalace.tusky.fragment.ViewMediaFragment;
import java.util.List;
import java.util.Locale;
public class ImagePagerAdapter extends FragmentPagerAdapter {
private String[] urls;
public final class ImagePagerAdapter extends FragmentPagerAdapter {
private List<Attachment> attachments;
private int initialPosition;
public ImagePagerAdapter(FragmentManager fragmentManager, String[] urls, int initialPosition) {
public ImagePagerAdapter(FragmentManager fragmentManager, List<Attachment> attachments, int initialPosition) {
super(fragmentManager);
this.urls = urls;
this.attachments = attachments;
this.initialPosition = initialPosition;
}
@Override
public Fragment getItem(int position) {
if (position >= 0 && position < urls.length) {
return ViewMediaFragment.newInstance(urls[position], position == initialPosition);
if (position >= 0 && position < attachments.size()) {
return ViewMediaFragment.newInstance(attachments.get(position), position == initialPosition);
} else {
return null;
}
@ -29,11 +32,11 @@ public class ImagePagerAdapter extends FragmentPagerAdapter {
@Override
public int getCount() {
return urls.length;
return attachments.size();
}
@Override
public CharSequence getPageTitle(int position) {
return String.format(Locale.getDefault(), "%d/%d", position + 1, urls.length);
return String.format(Locale.getDefault(), "%d/%d", position + 1, attachments.size());
}
}