show top changed message in articlepager
This commit is contained in:
parent
32c0691d5d
commit
4083904781
@ -183,6 +183,17 @@ public class ArticleFragment extends Fragment {
|
|||||||
m_contentView = view.findViewById(R.id.article_scrollview);
|
m_contentView = view.findViewById(R.id.article_scrollview);
|
||||||
m_customViewContainer = (FrameLayout) view.findViewById(R.id.article_fullscreen_video);
|
m_customViewContainer = (FrameLayout) view.findViewById(R.id.article_fullscreen_video);
|
||||||
|
|
||||||
|
if (m_article.id == HeadlinesFragment.ARTICLE_SPECIAL_TOP_CHANGED) {
|
||||||
|
TextView statusMessage = (TextView) view.findViewById(R.id.article_status_message);
|
||||||
|
statusMessage.setText(R.string.headlines_row_top_changed);
|
||||||
|
statusMessage.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
view.findViewById(R.id.article_scrollview).setVisibility(View.GONE);
|
||||||
|
view.findViewById(R.id.article_fab).setVisibility(View.GONE);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
NotifyingScrollView scrollView = (NotifyingScrollView) view.findViewById(R.id.article_scrollview);
|
NotifyingScrollView scrollView = (NotifyingScrollView) view.findViewById(R.id.article_scrollview);
|
||||||
m_fab = view.findViewById(R.id.article_fab);
|
m_fab = view.findViewById(R.id.article_fab);
|
||||||
|
|
||||||
@ -422,7 +433,7 @@ public class ArticleFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void renderContent(Bundle savedInstanceState) {
|
protected void renderContent(Bundle savedInstanceState) {
|
||||||
if (!isAdded()) return;
|
if (!isAdded() || m_web == null) return;
|
||||||
|
|
||||||
Log.d(TAG, "renderContent: " + m_article.title);
|
Log.d(TAG, "renderContent: " + m_article.title);
|
||||||
|
|
||||||
@ -545,14 +556,14 @@ public class ArticleFragment extends Fragment {
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
m_web.onPause();
|
if (m_web != null) m_web.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
m_web.onResume();
|
if (m_web != null) m_web.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inCustomView() {
|
public boolean inCustomView() {
|
||||||
|
@ -155,6 +155,11 @@ public class ArticlePager extends Fragment {
|
|||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
||||||
|
if (m_topIdChanged) {
|
||||||
|
m_articles.add(new Article(HeadlinesFragment.ARTICLE_SPECIAL_TOP_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
} catch (BadParcelableException e) {
|
} catch (BadParcelableException e) {
|
||||||
@ -172,7 +177,7 @@ public class ArticlePager extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login(true);
|
m_activity.login(true);
|
||||||
@ -254,6 +259,11 @@ public class ArticlePager extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (checkTopId > 0) put("check_top_id", String.valueOf(checkTopId));
|
if (checkTopId > 0) put("check_top_id", String.valueOf(checkTopId));
|
||||||
|
|
||||||
|
if (m_activity.getApiLevel() >= 12) {
|
||||||
|
put("include_header", "true");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
public static final int ARTICLE_SPECIAL_LOADMORE = -1;
|
public static final int ARTICLE_SPECIAL_LOADMORE = -1;
|
||||||
public static final int ARTICLE_SPECIAL_SPACER = -2;
|
public static final int ARTICLE_SPECIAL_SPACER = -2;
|
||||||
|
public static final int ARTICLE_SPECIAL_TOP_CHANGED = -3;
|
||||||
|
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
@ -390,7 +391,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
View layout = inflater.inflate(R.layout.headlines_footer, container, false);
|
View layout = inflater.inflate(R.layout.headlines_footer, container, false);
|
||||||
|
|
||||||
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, screenHeight));
|
layout.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, screenHeight));
|
||||||
|
|
||||||
m_list.addFooterView(layout, null, false);
|
m_list.addFooterView(layout, null, false);
|
||||||
}
|
}
|
||||||
@ -539,11 +540,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
m_refreshInProgress = false;
|
m_refreshInProgress = false;
|
||||||
m_articles.add(0, new Article(-2));
|
m_articles.add(0, new Article(ARTICLE_SPECIAL_SPACER));
|
||||||
|
|
||||||
if (m_articles.indexOf(m_activeArticle) == -1)
|
if (m_articles.indexOf(m_activeArticle) == -1)
|
||||||
m_activeArticle = null;
|
m_activeArticle = null;
|
||||||
|
|
||||||
|
if (m_topIdChanged) {
|
||||||
|
m_articles.add(new Article(ARTICLE_SPECIAL_TOP_CHANGED));
|
||||||
|
}
|
||||||
|
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
m_listener.onHeadlinesLoaded(fappend);
|
m_listener.onHeadlinesLoaded(fappend);
|
||||||
|
|
||||||
@ -551,7 +556,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
// top headline content becomes partially obscured by the toolbar on phones
|
// top headline content becomes partially obscured by the toolbar on phones
|
||||||
// (not reproducible on avd)
|
// (not reproducible on avd)
|
||||||
if (!fappend) m_list.smoothScrollToPosition(0);
|
if (!fappend) m_list.smoothScrollToPosition(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (m_lastError == ApiError.LOGIN_FAILED) {
|
if (m_lastError == ApiError.LOGIN_FAILED) {
|
||||||
m_activity.login(true);
|
m_activity.login(true);
|
||||||
@ -643,6 +648,10 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (checkTopId > 0) put("check_top_id", String.valueOf(checkTopId));
|
if (checkTopId > 0) put("check_top_id", String.valueOf(checkTopId));
|
||||||
|
|
||||||
|
if (m_activity.getApiLevel() >= 12) {
|
||||||
|
put("include_header", "true");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -695,8 +704,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
public static final int VIEW_SELECTED_UNREAD = 3;
|
public static final int VIEW_SELECTED_UNREAD = 3;
|
||||||
public static final int VIEW_LOADMORE = 4;
|
public static final int VIEW_LOADMORE = 4;
|
||||||
public static final int VIEW_SPACER = 5;
|
public static final int VIEW_SPACER = 5;
|
||||||
|
public static final int VIEW_TOP_CHANGED = 6;
|
||||||
|
|
||||||
public static final int VIEW_COUNT = VIEW_SPACER+1;
|
public static final int VIEW_COUNT = VIEW_TOP_CHANGED+1;
|
||||||
|
|
||||||
private final Integer[] origTitleColors = new Integer[VIEW_COUNT];
|
private final Integer[] origTitleColors = new Integer[VIEW_COUNT];
|
||||||
private final int titleHighScoreUnreadColor;
|
private final int titleHighScoreUnreadColor;
|
||||||
@ -754,6 +764,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
if (a.id == ARTICLE_SPECIAL_LOADMORE) {
|
if (a.id == ARTICLE_SPECIAL_LOADMORE) {
|
||||||
return VIEW_LOADMORE;
|
return VIEW_LOADMORE;
|
||||||
|
} else if (a.id == ARTICLE_SPECIAL_TOP_CHANGED) {
|
||||||
|
return VIEW_TOP_CHANGED;
|
||||||
} else if (a.id == ARTICLE_SPECIAL_SPACER) {
|
} else if (a.id == ARTICLE_SPECIAL_SPACER) {
|
||||||
return VIEW_SPACER;
|
return VIEW_SPACER;
|
||||||
} else if (m_activeArticle != null && a.id == m_activeArticle.id && a.unread) {
|
} else if (m_activeArticle != null && a.id == m_activeArticle.id && a.unread) {
|
||||||
@ -858,6 +870,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
case VIEW_SPACER:
|
case VIEW_SPACER:
|
||||||
layoutId = R.layout.fragment_dummy;
|
layoutId = R.layout.fragment_dummy;
|
||||||
break;
|
break;
|
||||||
|
case VIEW_TOP_CHANGED:
|
||||||
|
layoutId = R.layout.headlines_row_top_changed;
|
||||||
|
break;
|
||||||
case VIEW_UNREAD:
|
case VIEW_UNREAD:
|
||||||
layoutId = m_compactLayoutMode ? R.layout.headlines_row_unread_compact : R.layout.headlines_row_unread;
|
layoutId = m_compactLayoutMode ? R.layout.headlines_row_unread_compact : R.layout.headlines_row_unread;
|
||||||
break;
|
break;
|
||||||
@ -1705,7 +1720,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
public void setArticles(ArticleList articles) {
|
public void setArticles(ArticleList articles) {
|
||||||
m_articles.clear();
|
m_articles.clear();
|
||||||
m_articles.add(0, new Article(-2));
|
m_articles.add(0, new Article(ARTICLE_SPECIAL_SPACER));
|
||||||
m_articles.addAll(articles);
|
m_articles.addAll(articles);
|
||||||
m_adapter.notifyDataSetChanged();
|
m_adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -1246,7 +1246,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getApiLevel() {
|
public int getApiLevel() {
|
||||||
return Application.getInstance().m_apiLevel;
|
return Application.getInstance().m_apiLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package org.fox.ttrss.util;
|
package org.fox.ttrss.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import org.fox.ttrss.ApiRequest;
|
import org.fox.ttrss.ApiRequest;
|
||||||
@ -13,6 +15,7 @@ import org.fox.ttrss.OnlineActivity;
|
|||||||
import org.fox.ttrss.types.Article;
|
import org.fox.ttrss.types.Article;
|
||||||
import org.fox.ttrss.types.ArticleList;
|
import org.fox.ttrss.types.ArticleList;
|
||||||
import org.fox.ttrss.types.Feed;
|
import org.fox.ttrss.types.Feed;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -27,7 +30,9 @@ public class HeadlinesRequest extends ApiRequest {
|
|||||||
private OnlineActivity m_activity;
|
private OnlineActivity m_activity;
|
||||||
private ArticleList m_articles; // = new ArticleList(); //Application.getInstance().m_loadedArticles;
|
private ArticleList m_articles; // = new ArticleList(); //Application.getInstance().m_loadedArticles;
|
||||||
private Feed m_feed;
|
private Feed m_feed;
|
||||||
|
|
||||||
|
protected boolean m_topIdChanged = false;
|
||||||
|
|
||||||
public HeadlinesRequest(Context context, OnlineActivity activity, final Feed feed, ArticleList articles) {
|
public HeadlinesRequest(Context context, OnlineActivity activity, final Feed feed, ArticleList articles) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
@ -48,9 +53,25 @@ public class HeadlinesRequest extends ApiRequest {
|
|||||||
|
|
||||||
JsonArray content = result.getAsJsonArray();
|
JsonArray content = result.getAsJsonArray();
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
Type listType = new TypeToken<List<Article>>() {}.getType();
|
final List<Article> articles;
|
||||||
final List<Article> articles = new Gson().fromJson(content, listType);
|
final JsonObject header;
|
||||||
|
|
||||||
|
if (m_activity.getApiLevel() >= 12) {
|
||||||
|
header = content.get(0).getAsJsonObject();
|
||||||
|
|
||||||
|
//Log.d(TAG, "headerID:" + header.get("top_id_changed"));
|
||||||
|
|
||||||
|
m_topIdChanged = header.get("top_id_changed") != null;
|
||||||
|
|
||||||
|
Type listType = new TypeToken<List<Article>>() {}.getType();
|
||||||
|
articles = new Gson().fromJson(content.get(1), listType);
|
||||||
|
} else {
|
||||||
|
header = null;
|
||||||
|
|
||||||
|
Type listType = new TypeToken<List<Article>>() {}.getType();
|
||||||
|
articles = new Gson().fromJson(content, listType);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_offset == 0) {
|
if (m_offset == 0) {
|
||||||
m_articles.clear();
|
m_articles.clear();
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,4 +154,12 @@
|
|||||||
android:src="@drawable/ic_action_web_site"
|
android:src="@drawable/ic_action_web_site"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="[status message]"
|
||||||
|
android:id="@+id/article_status_message"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/headlines_row_top_changed"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/top_changed_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?headlineExcerptTextColor"
|
||||||
|
android:text="@string/headlines_row_top_changed" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -232,4 +232,5 @@
|
|||||||
<string name="video_player_open">Open video</string>
|
<string name="video_player_open">Open video</string>
|
||||||
|
|
||||||
<string name="flavor_image_prompt">(more images...)</string>
|
<string name="flavor_image_prompt">(more images...)</string>
|
||||||
|
<string name="headlines_row_top_changed">New articles found, reload feed to continue.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user