mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2024-12-24 15:30:46 +01:00
media tweets is clickable
This commit is contained in:
parent
c25e6e5e07
commit
167e143f95
@ -57,10 +57,14 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
|
||||
@Override
|
||||
protected IStatusViewHolder onCreateStatusViewHolder(ViewGroup parent, boolean compact) {
|
||||
final View view = getInflater().inflate(R.layout.adapter_item_media_status, parent, false);
|
||||
return new MediaTimelineViewHolder(this, view);
|
||||
final MediaStatusViewHolder holder = new MediaStatusViewHolder(this, view);
|
||||
holder.setOnClickListeners();
|
||||
holder.setupViewOptions();
|
||||
return holder;
|
||||
}
|
||||
|
||||
public static class MediaTimelineViewHolder extends RecyclerView.ViewHolder implements IStatusViewHolder {
|
||||
public static class MediaStatusViewHolder extends RecyclerView.ViewHolder
|
||||
implements IStatusViewHolder, View.OnClickListener, View.OnLongClickListener {
|
||||
private final SimpleAspectRatioSource aspectRatioSource = new SimpleAspectRatioSource();
|
||||
|
||||
private final AspectLockedFrameLayout mediaImageContainer;
|
||||
@ -68,8 +72,9 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
|
||||
private final ImageView mediaProfileImageView;
|
||||
private final TextView mediaTextView;
|
||||
private final IStatusesAdapter<?> adapter;
|
||||
private StatusClickListener listener;
|
||||
|
||||
public MediaTimelineViewHolder(IStatusesAdapter<?> adapter, View itemView) {
|
||||
public MediaStatusViewHolder(IStatusesAdapter<?> adapter, View itemView) {
|
||||
super(itemView);
|
||||
this.adapter = adapter;
|
||||
mediaImageContainer = (AspectLockedFrameLayout) itemView.findViewById(R.id.media_image_container);
|
||||
@ -117,22 +122,27 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (listener == null) return;
|
||||
switch (v.getId()) {
|
||||
case R.id.item_content: {
|
||||
listener.onStatusClick(this, getLayoutPosition());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatusClickListener(StatusClickListener listener) {
|
||||
|
||||
this.listener = listener;
|
||||
itemView.findViewById(R.id.item_content).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -140,6 +150,14 @@ public class StaggeredGridParcelableStatusesAdapter extends AbsParcelableStatuse
|
||||
|
||||
}
|
||||
|
||||
public void setOnClickListeners() {
|
||||
setStatusClickListener(adapter);
|
||||
}
|
||||
|
||||
public void setupViewOptions() {
|
||||
setTextSize(adapter.getTextSize());
|
||||
}
|
||||
|
||||
|
||||
private static class SimpleAspectRatioSource implements AspectLockedFrameLayout.AspectRatioSource {
|
||||
private int width, height;
|
||||
|
@ -12,12 +12,17 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.AbsStatusesAdapter;
|
||||
import org.mariotaku.twidere.adapter.StaggeredGridParcelableStatusesAdapter;
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
import org.mariotaku.twidere.loader.iface.IExtendedLoader;
|
||||
import org.mariotaku.twidere.loader.support.MediaTimelineLoader;
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.view.HeaderDrawerLayout.DrawerCallback;
|
||||
import org.mariotaku.twidere.view.holder.GapViewHolder;
|
||||
import org.mariotaku.twidere.view.holder.iface.IStatusViewHolder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -25,7 +30,7 @@ import java.util.List;
|
||||
* Created by mariotaku on 14/11/5.
|
||||
*/
|
||||
public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<StaggeredGridParcelableStatusesAdapter, StaggeredGridLayoutManager>
|
||||
implements LoaderCallbacks<List<ParcelableStatus>>, DrawerCallback {
|
||||
implements LoaderCallbacks<List<ParcelableStatus>>, DrawerCallback, AbsStatusesAdapter.StatusAdapterListener {
|
||||
|
||||
|
||||
@Override
|
||||
@ -36,14 +41,16 @@ public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<St
|
||||
|
||||
@Override
|
||||
public boolean isRefreshing() {
|
||||
//TODO detect loader refreshing
|
||||
return false;
|
||||
final Loader<Object> loader = getLoaderManager().getLoader(0);
|
||||
return loader != null && loader.isStarted();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
final AbsStatusesAdapter<List<ParcelableStatus>> adapter = getAdapter();
|
||||
adapter.setListener(this);
|
||||
final Bundle loaderArgs = new Bundle(getArguments());
|
||||
loaderArgs.putBoolean(EXTRA_FROM_USER, true);
|
||||
getLoaderManager().initLoader(0, loaderArgs, this);
|
||||
@ -145,4 +152,39 @@ public class UserMediaTimelineFragment extends AbsContentRecyclerViewFragment<St
|
||||
final long maxId = adapter.getStatusId(adapter.getStatusesCount() - 1);
|
||||
getStatuses(maxId, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGapClick(GapViewHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMediaClick(IStatusViewHolder holder, View view, ParcelableMedia media, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusActionClick(IStatusViewHolder holder, int id, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusClick(IStatusViewHolder holder, int position) {
|
||||
Utils.openStatus(getContext(), getAdapter().getStatus(position), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStatusLongClick(IStatusViewHolder holder, int position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusMenuClick(IStatusViewHolder holder, View menuView, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserProfileClick(IStatusViewHolder holder, ParcelableStatus status, int position) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -45,10 +45,6 @@ public interface IStatusViewHolder extends CardMediaContainer.OnMediaClickListen
|
||||
@Nullable
|
||||
ImageView getProfileTypeView();
|
||||
|
||||
void onClick(View v);
|
||||
|
||||
boolean onLongClick(View v);
|
||||
|
||||
@Override
|
||||
void onMediaClick(View view, ParcelableMedia media, long accountId);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/item_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/element_spacing_small"
|
||||
|
Loading…
Reference in New Issue
Block a user