add some animations

article: load webview contents in a runnable
This commit is contained in:
Andrew Dolgov 2015-02-11 14:59:15 +03:00
parent 2349845298
commit 0264b2d30f
6 changed files with 327 additions and 313 deletions

1
org.fox.ttrss/build.gradle Normal file → Executable file
View File

@ -34,4 +34,5 @@ dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.shamanland:fab:0.0.5'
compile 'ch.acra:acra:4.5.0'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.1.0@aar'
}

View File

@ -86,6 +86,7 @@
<orderEntry type="library" exported="" name="cardview-v7-21.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.6.1" level="project" />
<orderEntry type="library" exported="" name="view-pager-transforms-1.1.0" level="project" />
<orderEntry type="library" exported="" name="library-2.4.1" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />

2
org.fox.ttrss/src/main/AndroidManifest.xml Normal file → Executable file
View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
android:versionCode="299"
android:versionCode="300"
android:versionName="1.87" >
<uses-sdk

View File

@ -8,6 +8,7 @@ import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Html;
@ -149,22 +150,20 @@ public class ArticleFragment extends Fragment {
@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
if (savedInstanceState != null) {
m_article = savedInstanceState.getParcelable("article");
//m_fsviewShown = savedInstanceState.getBoolean("fsviewShown");
}
View view = inflater.inflate(R.layout.article_fragment, container, false);
final View view = inflater.inflate(R.layout.article_fragment, container, false);
/* if (m_fsviewShown) {
view.findViewById(R.id.article_fullscreen_video).setVisibility(View.VISIBLE);
view.findViewById(R.id.article_scrollview).setVisibility(View.INVISIBLE);
} */
if (m_article != null) {
m_contentView = view.findViewById(R.id.article_scrollview);
m_customViewContainer = (FrameLayout) view.findViewById(R.id.article_fullscreen_video);
@ -195,8 +194,8 @@ public class ArticleFragment extends Fragment {
}
}
int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2));
final int articleFontSize = Integer.parseInt(m_prefs.getString("article_font_size_sp", "16"));
final int articleSmallFontSize = Math.max(10, Math.min(18, articleFontSize - 2));
TextView title = (TextView)view.findViewById(R.id.title);
@ -288,6 +287,64 @@ public class ArticleFragment extends Fragment {
m_web = (WebView)view.findViewById(R.id.article_content);
TextView dv = (TextView)view.findViewById(R.id.date);
if (dv != null) {
dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
Date d = new Date(m_article.updated * 1000L);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
dv.setText(df.format(d));
}
TextView author = (TextView)view.findViewById(R.id.author);
boolean hasAuthor = false;
if (author != null) {
author.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
if (m_article.author != null && m_article.author.length() > 0) {
author.setText(getString(R.string.author_formatted, m_article.author));
} else {
author.setVisibility(View.GONE);
}
hasAuthor = true;
}
TextView tagv = (TextView)view.findViewById(R.id.tags);
if (tagv != null) {
tagv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
if (m_article.feed_title != null) {
String fTitle = m_article.feed_title;
if (!hasAuthor && m_article.author != null && m_article.author.length() > 0) {
fTitle += " (" + getString(R.string.author_formatted, m_article.author) + ")";
}
tagv.setText(fTitle);
} else if (m_article.tags != null) {
String tagsStr = "";
for (String tag : m_article.tags)
tagsStr += tag + ", ";
tagsStr = tagsStr.replaceAll(", $", "");
tagv.setText(tagsStr);
} else {
tagv.setVisibility(View.GONE);
}
}
if (m_article != null) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (m_web != null) {
m_web.setOnLongClickListener(new View.OnLongClickListener() {
@ -429,57 +486,8 @@ public class ArticleFragment extends Fragment {
m_web.setVisibility(View.VISIBLE);
}
TextView dv = (TextView)view.findViewById(R.id.date);
if (dv != null) {
dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
Date d = new Date(m_article.updated * 1000L);
DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
dv.setText(df.format(d));
}
TextView author = (TextView)view.findViewById(R.id.author);
boolean hasAuthor = false;
if (author != null) {
author.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
if (m_article.author != null && m_article.author.length() > 0) {
author.setText(getString(R.string.author_formatted, m_article.author));
} else {
author.setVisibility(View.GONE);
}
hasAuthor = true;
}
TextView tagv = (TextView)view.findViewById(R.id.tags);
if (tagv != null) {
tagv.setTextSize(TypedValue.COMPLEX_UNIT_SP, articleSmallFontSize);
if (m_article.feed_title != null) {
String fTitle = m_article.feed_title;
if (!hasAuthor && m_article.author != null && m_article.author.length() > 0) {
fTitle += " (" + getString(R.string.author_formatted, m_article.author) + ")";
}
tagv.setText(fTitle);
} else if (m_article.tags != null) {
String tagsStr = "";
for (String tag : m_article.tags)
tagsStr += tag + ", ";
tagsStr = tagsStr.replaceAll(", $", "");
tagv.setText(tagsStr);
} else {
tagv.setVisibility(View.GONE);
}
}
}, 100);
}

View File

@ -26,6 +26,7 @@ import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.ToxicBakery.viewpager.transforms.DepthPageTransformer;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
@ -295,6 +296,7 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
ViewPager pager = (ViewPager) findViewById(R.id.article_images_pager);
pager.setAdapter(m_adapter);
pager.setPageTransformer(true, new DepthPageTransformer());
UnderlinePageIndicator indicator = (UnderlinePageIndicator)findViewById(R.id.article_images_indicator);
indicator.setViewPager(pager);

View File

@ -16,6 +16,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.ToxicBakery.viewpager.transforms.StackTransformer;
import com.google.gson.JsonElement;
import com.viewpagerindicator.UnderlinePageIndicator;
@ -93,6 +94,7 @@ public class ArticlePager extends Fragment {
m_listener.onArticleSelected(m_article, false);
pager.setAdapter(m_adapter);
pager.setPageTransformer(true, new StackTransformer());
UnderlinePageIndicator indicator = (UnderlinePageIndicator)view.findViewById(R.id.article_titles);
indicator.setViewPager(pager);