use of com.newsrob.widget.SwipeRelativeLayout in project newsrob by marianokamp.
the class ArticleViewHelper method populateEntryView.
static void populateEntryView(final View view, final Entry entry, final EntryManager entryManager, final UIHelper uiHelper) {
final Resources resources = entryManager.getContext().getResources();
// swipe
final SwipeRelativeLayout swipeContainer = (SwipeRelativeLayout) view.findViewById(R.id.swipe_container);
final View outterContainer = view.findViewById(R.id.outter_container);
outterContainer.setPadding(0, 0, 0, 0);
swipeContainer.setSwipeListener(new SwipeRelativeLayout.ISwipeListener() {
private final int selectionFeedbackColor = resources.getColor(R.color.selection_feedback);
public boolean swipeTopToBottom(final View v) {
return false;
}
public boolean swipeRightToLeft(final View v) {
view.setBackgroundColor(selectionFeedbackColor);
entryManager.increaseUnreadLevel(entry);
return true;
}
public boolean swipeLeftToRight(final View v) {
view.setBackgroundColor(selectionFeedbackColor);
entryManager.increaseReadLevel(entry);
return true;
}
public boolean swipeBottomToTop(final View v) {
return false;
}
public boolean onLongClick(final View v, final MotionEvent e) {
return view.performLongClick();
}
public boolean onClick(final View v, final MotionEvent e) {
return view.performClick();
}
});
swipeContainer.setSwipeEnabeld(entryManager.isSwipeOnArticleDetailViewEnabled());
swipeContainer.setBackgroundResource(R.drawable.article_header_background_thin);
final TextView entryTitleView = (TextView) view.findViewById(R.id.entry_title);
final TextView feedTitleView = (TextView) view.findViewById(R.id.feed_title);
if (feedTitleView == null || entryTitleView == null) {
Log.e(TAG, "feedTitleView or entryTitleView were null.");
return;
}
if (entry == null) {
Log.d(TAG, "entry was null");
return;
}
if (entry.getFeedTitle() == null) {
Log.e(TAG, "entry.getFeedTitle() was null.");
return;
}
feedTitleView.setText(entry.getFeedTitle());
entryTitleView.setText(entry.getTitle());
if (entryManager.shouldTitlesBeEllipsized()) {
entryTitleView.setEllipsize(TruncateAt.MIDDLE);
entryTitleView.setLines(2);
}
// final int backgroundColor = resources.getColor(entry.isRead() ?
// R.color.article_read_background
// : R.color.article_unread_background);
// final int textColor = resources.getColor(entry.isRead() ?
// R.color.article_read_text
// : R.color.article_unread_text);
final TextView readIndicator = (TextView) view.findViewById(R.id.read_status_indicator);
final int readIndicatorBackground = entryManager.isLightColorSchemeSelected() ? R.drawable.read_indicator : R.drawable.read_indicator_dark;
final int pinnedIndicatorBackground = entryManager.isLightColorSchemeSelected() ? R.drawable.pinned_indicator : R.drawable.pinned_indicator_dark;
int bgReadIndicator = -1;
switch(entry.getReadState()) {
case READ:
bgReadIndicator = R.drawable.read_indicator_invisible;
break;
case UNREAD:
bgReadIndicator = readIndicatorBackground;
break;
default:
bgReadIndicator = pinnedIndicatorBackground;
}
readIndicator.setBackgroundResource(bgReadIndicator);
// view.setBackgroundColor(backgroundColor);
View container = view.findViewById(R.id.outter_container);
if (entryManager.isLightColorSchemeSelected())
container.setBackgroundColor(resources.getColor(R.color.article_read_background));
else
container.setBackgroundDrawable(resources.getDrawable(R.drawable.article_header_background_dark));
// entryTitleView.setTextColor(textColor);
// feedTitleView.setTextColor(textColor);
//
feedTitleView.setCompoundDrawablePadding(3);
feedTitleView.setCompoundDrawablesWithIntrinsicBounds(resources.getDrawable(uiHelper.getArticleDownloadIndicatorDrawable(entry.getDownloaded(), entry.getDownloadPref(), resources)), null, null, null);
// star check box
final CheckBox starCheckBox = (CheckBox) view.findViewById(R.id.star_checkbox);
starCheckBox.setVisibility(View.VISIBLE);
starCheckBox.setChecked(entry.isStarred());
starCheckBox.setOnClickListener(new View.OnClickListener() {
public void onClick(final View v) {
entryManager.updateStarredState(entry, starCheckBox.isChecked());
}
});
starCheckBox.requestFocus();
if (false) {
// changed
final TextView changedView = (TextView) view.findViewById(R.id.article_changed);
final boolean stateChanged = entry.isReadStatePending() || entry.isStarredStatePending();
changedView.setText(stateChanged ? "*" : "");
}
}
Aggregations