offline: various positioning fixes
This commit is contained in:
parent
972588b485
commit
6e4ab99134
@ -10,6 +10,7 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
@ -22,12 +23,14 @@ import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebView.HitTestResult;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.shamanland.fab.ShowHideOnScroll;
|
||||
|
||||
import org.fox.ttrss.R;
|
||||
import org.fox.ttrss.util.ImageCacheService;
|
||||
import org.fox.ttrss.util.NotifyingScrollView;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@ -130,9 +133,27 @@ public class OfflineArticleFragment extends Fragment {
|
||||
if (m_cursor.isFirst()) {
|
||||
final String link = m_cursor.getString(m_cursor.getColumnIndex("link"));
|
||||
|
||||
View scrollView = view.findViewById(R.id.article_scrollview);
|
||||
NotifyingScrollView scrollView = (NotifyingScrollView) view.findViewById(R.id.article_scrollview);
|
||||
View fab = view.findViewById(R.id.article_fab);
|
||||
|
||||
if (scrollView != null && m_activity.isSmallScreen()) {
|
||||
view.findViewById(R.id.article_heading_spacer).setVisibility(View.VISIBLE);
|
||||
|
||||
scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
|
||||
@Override
|
||||
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
|
||||
ActionBar ab = m_activity.getSupportActionBar();
|
||||
|
||||
if (t >= oldt && t >= ab.getHeight()) {
|
||||
ab.hide();
|
||||
} else if (t <= ab.getHeight() | oldt - t >= 10) {
|
||||
ab.show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (scrollView != null && fab != null) {
|
||||
if (m_prefs.getBoolean("enable_article_fab", true)) {
|
||||
scrollView.setOnTouchListener(new ShowHideOnScroll(fab));
|
||||
|
@ -239,7 +239,7 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
|
||||
public int getItemViewType(int position) {
|
||||
Cursor cursor = (Cursor) this.getItem(position);
|
||||
|
||||
if (cursor.getLong(0) == m_selectedCatId) {
|
||||
if (!m_activity.isSmallScreen() && cursor.getLong(0) == m_selectedCatId) {
|
||||
return VIEW_SELECTED;
|
||||
} else {
|
||||
return VIEW_NORMAL;
|
||||
|
@ -277,7 +277,7 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
|
||||
public int getItemViewType(int position) {
|
||||
Cursor cursor = (Cursor) this.getItem(position);
|
||||
|
||||
if (cursor.getLong(0) == m_selectedFeedId) {
|
||||
if (!m_activity.isSmallScreen() && cursor.getLong(0) == m_selectedFeedId) {
|
||||
return VIEW_SELECTED;
|
||||
} else {
|
||||
return VIEW_NORMAL;
|
||||
|
@ -48,6 +48,8 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
|
||||
getSupportActionBar().show();
|
||||
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
|
||||
private boolean m_compactLayoutMode = false;
|
||||
private ListView m_list;
|
||||
private int m_listPreviousVisibleItem;
|
||||
|
||||
public void initialize(int feedId, boolean isCat, boolean compactMode) {
|
||||
m_feedId = feedId;
|
||||
@ -811,18 +812,20 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
}
|
||||
|
||||
public Cursor getArticleAtPosition(int position) {
|
||||
return (Cursor) m_adapter.getItem(position);
|
||||
return (Cursor) m_list.getItemAtPosition(position);
|
||||
}
|
||||
|
||||
public int getArticleIdAtPosition(int position) {
|
||||
/*Cursor c = getArticleAtPosition(position);
|
||||
Cursor c = getArticleAtPosition(position);
|
||||
|
||||
if (c != null) {
|
||||
int id = c.getInt(0);
|
||||
return id;
|
||||
} */
|
||||
}
|
||||
|
||||
return (int) m_adapter.getItemId(position);
|
||||
return 0;
|
||||
|
||||
//return (int) m_adapter.getItemId(position + m_list.getHeaderViewsCount());
|
||||
}
|
||||
|
||||
public int getActiveArticleId() {
|
||||
@ -832,7 +835,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
public int getArticleIdPosition(int articleId) {
|
||||
for (int i = 0; i < m_adapter.getCount(); i++) {
|
||||
if (articleId == m_adapter.getItemId(i))
|
||||
return i;
|
||||
return i + m_list.getHeaderViewsCount();
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -862,7 +865,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
if (m_prefs.getBoolean("headlines_mark_read_scroll", false) && firstVisibleItem > 0) {
|
||||
if (m_prefs.getBoolean("headlines_mark_read_scroll", false) && firstVisibleItem > (m_activity.isSmallScreen() ? 1 : 0)) {
|
||||
//Article a = m_articles.get(firstVisibleItem - 1);
|
||||
|
||||
Cursor article = getArticleAtPosition(firstVisibleItem - 1);
|
||||
@ -876,6 +879,20 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_activity.isTablet()) {
|
||||
if (m_adapter.getCount() > 0) {
|
||||
if (firstVisibleItem > m_listPreviousVisibleItem) {
|
||||
m_activity.getSupportActionBar().hide();
|
||||
} else if (firstVisibleItem < m_listPreviousVisibleItem) {
|
||||
m_activity.getSupportActionBar().show();
|
||||
}
|
||||
} else {
|
||||
m_activity.getSupportActionBar().show();
|
||||
}
|
||||
|
||||
m_listPreviousVisibleItem = firstVisibleItem;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user