removed unused Holder and listener
This commit is contained in:
parent
24f6ed2015
commit
6ea8554ef7
2 changed files with 1 additions and 96 deletions
|
@ -1,30 +1,15 @@
|
|||
package net.osmand.plus.wikivoyage.explore;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestCreator;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.widgets.tools.CropCircleTransformation;
|
||||
import net.osmand.plus.widgets.tools.CropRectTransformation;
|
||||
import net.osmand.plus.wikivoyage.WikivoyageUtils;
|
||||
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard;
|
||||
import net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard;
|
||||
|
@ -41,24 +26,11 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
|
||||
private final List<Object> items = new ArrayList<>();
|
||||
|
||||
private ExploreRvAdapter.Listener listener;
|
||||
OsmandApplication app;
|
||||
private final Drawable readIcon;
|
||||
private final Drawable deleteIcon;
|
||||
|
||||
public void setListener(ExploreRvAdapter.Listener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
private OsmandApplication app;
|
||||
|
||||
ExploreRvAdapter(OsmandApplication app) {
|
||||
this.app = app;
|
||||
this.settings = app.getSettings();
|
||||
|
||||
int colorId = settings.isLightContent()
|
||||
? R.color.wikivoyage_active_light : R.color.wikivoyage_active_dark;
|
||||
IconsCache ic = app.getIconsCache();
|
||||
readIcon = ic.getIcon(R.drawable.ic_action_read_article, colorId);
|
||||
deleteIcon = ic.getIcon(R.drawable.ic_action_read_later_fill, colorId);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -163,62 +135,4 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
description = (TextView) itemView.findViewById(R.id.description);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemVH extends RecyclerView.ViewHolder {
|
||||
|
||||
final TextView title;
|
||||
final TextView content;
|
||||
final TextView partOf;
|
||||
final ImageView icon;
|
||||
final TextView leftButton;
|
||||
final TextView rightButton;
|
||||
final View divider;
|
||||
final View shadow;
|
||||
|
||||
ItemVH(final View itemView) {
|
||||
super(itemView);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
content = (TextView) itemView.findViewById(R.id.content);
|
||||
partOf = (TextView) itemView.findViewById(R.id.part_of);
|
||||
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
leftButton = (TextView) itemView.findViewById(R.id.left_button);
|
||||
rightButton = (TextView) itemView.findViewById(R.id.right_button);
|
||||
divider = itemView.findViewById(R.id.divider);
|
||||
shadow = itemView.findViewById(R.id.shadow);
|
||||
|
||||
View.OnClickListener readClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Object item = getItemByPosition();
|
||||
if (item != null && item instanceof TravelArticle) {
|
||||
if (listener != null) {
|
||||
listener.openArticle((TravelArticle) item);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
itemView.setOnClickListener(readClickListener);
|
||||
leftButton.setOnClickListener(readClickListener);
|
||||
|
||||
rightButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Object getItemByPosition() {
|
||||
int pos = getAdapterPosition();
|
||||
if (pos != RecyclerView.NO_POSITION) {
|
||||
return getItem(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
void openArticle(TravelArticle article);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,15 +37,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment {
|
|||
|
||||
|
||||
ExploreRvAdapter adapter = new ExploreRvAdapter(app);
|
||||
adapter.setListener(new ExploreRvAdapter.Listener() {
|
||||
@Override
|
||||
public void openArticle(TravelArticle article) {
|
||||
FragmentManager fm = getFragmentManager();
|
||||
if (fm != null) {
|
||||
WikivoyageArticleDialogFragment.showInstance(app, fm, article.getCityId(), article.getLang());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
|
||||
rv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
|
Loading…
Reference in a new issue