Improve art timeline
This commit is contained in:
parent
539acd053b
commit
209d698223
|
@ -48,6 +48,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.GridView;
|
||||
|
@ -62,6 +63,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
@ -2113,6 +2115,35 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
StatusViewHolder holder = (StatusViewHolder) viewHolder;
|
||||
MastodonHelper.loadPPMastodon(holder.bindingArt.artPp, status.account);
|
||||
if (status.art_attachment != null) {
|
||||
|
||||
holder.bindingArt.artMedia.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
holder.bindingArt.artMedia.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
float viewWidth = holder.bindingArt.artMedia.getWidth();
|
||||
ConstraintLayout.LayoutParams lp;
|
||||
float mediaH = status.art_attachment.meta.small.height;
|
||||
float mediaW = status.art_attachment.meta.small.width;
|
||||
float ratio = 1.0f;
|
||||
if (mediaW != 0) {
|
||||
ratio = viewWidth / mediaW;
|
||||
}
|
||||
lp = new ConstraintLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
||||
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
holder.bindingArt.artMedia.setLayoutParams(lp);
|
||||
}
|
||||
});
|
||||
float viewWidth = holder.bindingArt.artMedia.getWidth();
|
||||
ConstraintLayout.LayoutParams lp;
|
||||
float mediaH = status.art_attachment.meta.small.height;
|
||||
float mediaW = status.art_attachment.meta.small.width;
|
||||
float ratio = 1.0f;
|
||||
if (mediaW != 0) {
|
||||
ratio = viewWidth / mediaW;
|
||||
}
|
||||
lp = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio));
|
||||
holder.bindingArt.artMedia.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
holder.bindingArt.artMedia.setLayoutParams(lp);
|
||||
Glide.with(holder.bindingArt.artMedia.getContext())
|
||||
.load(status.art_attachment.preview_url)
|
||||
.apply(new RequestOptions().transform(new RoundedCorners((int) Helper.convertDpToPixel(3, context))))
|
||||
|
|
|
@ -342,19 +342,28 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
flagLoading = fetched_statuses.pagination.max_id == null;
|
||||
binding.noAction.setVisibility(View.GONE);
|
||||
|
||||
|
||||
if (timelineType == Timeline.TimeLineEnum.ART) {
|
||||
//We have to split media in different statuses
|
||||
List<Status> mediaStatuses = new ArrayList<>();
|
||||
for (Status status : fetched_statuses.statuses) {
|
||||
if (status.media_attachments.size() > 1) {
|
||||
for (Attachment attachment : status.media_attachments) {
|
||||
status.media_attachments = new ArrayList<>();
|
||||
status.media_attachments.add(0, attachment);
|
||||
mediaStatuses.add(status);
|
||||
if (!tagTimeline.isNSFW && status.sensitive) {
|
||||
continue;
|
||||
}
|
||||
for (Attachment attachment : status.media_attachments) {
|
||||
try {
|
||||
Status statusTmp = (Status) status.clone();
|
||||
statusTmp.art_attachment = attachment;
|
||||
mediaStatuses.add(statusTmp);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
fetched_statuses.statuses = mediaStatuses;
|
||||
if (mediaStatuses.size() > 0) {
|
||||
fetched_statuses.statuses = mediaStatuses;
|
||||
}
|
||||
}
|
||||
//Update the timeline with new statuses
|
||||
int insertedStatus = updateStatusListWith(fetched_statuses.statuses);
|
||||
|
@ -622,14 +631,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
||||
/*Handler handler = new Handler();
|
||||
handler.postDelayed(() -> {
|
||||
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
||||
getCachedStatus(direction, fetchingMissing, timelineParams);
|
||||
} else {
|
||||
getLiveStatus(direction, fetchingMissing, timelineParams, status);
|
||||
}
|
||||
}, slug.compareTo(Helper.getSlugOfFirstFragment(requireActivity(), currentUserID, currentInstance)) == 0 ? 0 : 1000);*/
|
||||
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
||||
getCachedStatus(direction, fetchingMissing, timelineParams);
|
||||
} else {
|
||||
|
|
|
@ -14,47 +14,32 @@
|
|||
You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/art_container"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/art_media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/art_media"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerInside" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/status_show_more"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@color/mastodonC1"
|
||||
android:visibility="gone">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/show_more_button_art"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/ic_outline_remove_red_eye_24" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/bottom_banner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/art_media"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:background="#44000000"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
@ -88,4 +73,4 @@
|
|||
android:textColor="@color/white" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue