Skip to content

Commit

Permalink
ArticleActivity title & up down page
Browse files Browse the repository at this point in the history
  • Loading branch information
HumbleLivelyBear2 committed Mar 21, 2013
1 parent c8af3de commit b040382
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 43 deletions.
25 changes: 25 additions & 0 deletions res/layout/item_title.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:textSize="20dp"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:text=""
android:layout_marginTop="10dp"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
/>

</RelativeLayout>
15 changes: 13 additions & 2 deletions res/layout/layout_article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >


<LinearLayout android:id="@+id/layout_progress"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

<com.kosbrother.tool.DetectScrollView android:id="@+id/article_scrollview"
android:layout_width="fill_parent"
android:layout_height="0dp"
Expand All @@ -14,7 +25,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
/>
</com.kosbrother.tool.DetectScrollView>
Expand Down
11 changes: 9 additions & 2 deletions res/layout/layout_bookmark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<com.ifixit.android.sectionheaders.SectionListView
android:id="@+id/bookmark_listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

android:layout_height="0dp"
android:layout_weight="1"
/>
<LinearLayout
android:id="@+id/adonView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
/>
</LinearLayout>
3 changes: 1 addition & 2 deletions res/layout/loadmore_grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

/>
</LinearLayout>

<com.taiwan.imageload.LoadMoreGridView
Expand Down
2 changes: 2 additions & 0 deletions res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<string name="article_up">上一篇</string>
<string name="article_down">下一篇</string>
<string name="article_no_up">無上一篇</string>
<string name="article_no_down">無下一篇</string>

<string name="setting_text">文字大小:</string>
<string name="setting_text_preview">文字預覽:小說王</string>
Expand Down
2 changes: 2 additions & 0 deletions res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<string name="article_up">上一篇</string>
<string name="article_down">下一篇</string>
<string name="article_no_up">无上一篇</string>
<string name="article_no_down">无下一篇</string>

<string name="setting_text">文字大小:</string>
<string name="setting_text_preview">文字预览:小说王</string>
Expand Down
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<string name="article_up">上一篇</string>
<string name="article_down">下一篇</string>
<string name="article_no_up">無上一篇</string>
<string name="article_no_down">無下一篇</string>

<string name="setting_text">文字大小:</string>
<string name="setting_text_preview">文字預覽:小說王</string>
Expand Down
95 changes: 67 additions & 28 deletions src/com/android/novel/reader/ArticleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
Expand Down Expand Up @@ -67,6 +70,8 @@ public class ArticleActivity extends SherlockFragmentActivity implements DetectS
// private ProgressDialog progressDialog= null;
private AlertDialog.Builder aboutUsDialog;
private String adWhirlKey = "215f895eb71748e7ba4cb3a5f20b061e";
private ActionBar ab;
private LinearLayout layoutProgress;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -75,7 +80,7 @@ protected void onCreate(Bundle savedInstanceState) {
restorePreValues();
setViews();

final ActionBar ab = getSupportActionBar();
ab = getSupportActionBar();
mBundle = this.getIntent().getExtras();
novelName = mBundle.getString("NovelName");
articleTitle = mBundle.getString("ArticleTitle");
Expand All @@ -85,7 +90,13 @@ protected void onCreate(Bundle savedInstanceState) {
novelId = mBundle.getInt("NovelId");
yRate = mBundle.getInt("ReadingRate",0);

ab.setTitle(novelName);
ab.setDisplayShowCustomEnabled(true);
ab.setDisplayShowTitleEnabled(false);

setActionBarTitle(articleTitle);


// ab.setTitle(novelName);
ab.setDisplayHomeAsUpEnabled(true);

if(downloadBoolean){
Expand All @@ -112,6 +123,14 @@ protected void onCreate(Bundle savedInstanceState) {

}

private void setActionBarTitle(String articleTitle) {
LayoutInflater inflator = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflator.inflate(R.layout.item_title, null);
TextView titleText = ((TextView)v.findViewById(R.id.title));
titleText.setText(novelName+":"+ articleTitle);
ab.setCustomView(v);
}

private void restorePreValues() {
textSize = Setting.getSetting(Setting.keyTextSize, ArticleActivity.this);
textLanguage = Setting.getSetting(Setting.keyTextLanguage, ArticleActivity.this);
Expand All @@ -132,6 +151,7 @@ private void restorePreValues() {

private void setViews() {

layoutProgress = (LinearLayout) findViewById (R.id.layout_progress);
articleTextView = (TextView) findViewById (R.id.article_text);
articleScrollView = (DetectScrollView) findViewById (R.id.article_scrollview);
articleButtonUp = (Button) findViewById (R.id.article_button_up);
Expand Down Expand Up @@ -267,16 +287,17 @@ protected Object doInBackground(Object... params) {
protected void onPostExecute(Object result) {
super.onPostExecute(result);

layoutProgress.setVisibility(View.GONE);
if(textLanguage ==1){
String text ="";
try {
text = taobe.tec.jcc.JChineseConvertor.getInstance().t2s(myAricle.getTitle() + "\n\n" + myAricle.getText());
text = taobe.tec.jcc.JChineseConvertor.getInstance().t2s(myAricle.getText());
} catch (IOException e) {
e.printStackTrace();
}
articleTextView.setText(text);
}else{
articleTextView.setText(articleTitle + "\n\n" + myAricle.getText());
articleTextView.setText(myAricle.getText());
}

new GetLastPositionTask().execute();
Expand All @@ -290,7 +311,7 @@ private class GetPreviousArticleTask extends AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();

layoutProgress.setVisibility(View.VISIBLE);
}

@Override
Expand All @@ -304,19 +325,29 @@ protected Object doInBackground(Object... params) {
protected void onPostExecute(Object result) {

super.onPostExecute(result);

if(textLanguage ==1){
String text ="";
try {
text = taobe.tec.jcc.JChineseConvertor.getInstance().t2s(myAricle.getTitle() + "\n\n" + myAricle.getText());
} catch (IOException e) {
e.printStackTrace();
}
articleTextView.setText(text);
}else{
articleTextView.setText(articleTitle + "\n\n" + myAricle.getText());
layoutProgress.setVisibility(View.GONE);
if (myAricle != null){
if(textLanguage ==1){
String text ="";
try {
text = taobe.tec.jcc.JChineseConvertor.getInstance().t2s( myAricle.getText());
} catch (IOException e) {
e.printStackTrace();
}
articleTextView.setText(text);
}else{
articleTextView.setText(myAricle.getText());
}

articleScrollView.fullScroll(ScrollView.FOCUS_UP);
setActionBarTitle(myAricle.getTitle());
articlePercent.setText("0%");

}else{
Toast.makeText( ArticleActivity.this, getResources().getString(R.string.article_no_up), Toast.LENGTH_SHORT).show();
}


new GetLastPositionTask().execute();


Expand All @@ -327,7 +358,7 @@ private class GetNextArticleTask extends AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();

layoutProgress.setVisibility(View.VISIBLE);
}

@Override
Expand All @@ -340,17 +371,25 @@ protected Object doInBackground(Object... params) {
@Override
protected void onPostExecute(Object result) {
super.onPostExecute(result);

if(textLanguage ==1){
String text ="";
try {
text = taobe.tec.jcc.JChineseConvertor.getInstance().t2s(myAricle.getTitle() + "\n\n" + myAricle.getText());
} catch (IOException e) {
e.printStackTrace();
}
articleTextView.setText(text);
}else{
articleTextView.setText(articleTitle + "\n\n" + myAricle.getText());
layoutProgress.setVisibility(View.GONE);
if (myAricle != null){
if(textLanguage ==1){
String text ="";
try {
text = taobe.tec.jcc.JChineseConvertor.getInstance().t2s( myAricle.getText());
} catch (IOException e) {
e.printStackTrace();
}
articleTextView.setText(text);
}else{
articleTextView.setText(myAricle.getText());
}

articleScrollView.fullScroll(ScrollView.FOCUS_UP);
setActionBarTitle(myAricle.getTitle());
articlePercent.setText("0%");
}else{
Toast.makeText( ArticleActivity.this, getResources().getString(R.string.article_no_down), Toast.LENGTH_SHORT).show();
}

new GetLastPositionTask().execute();
Expand Down
Loading

0 comments on commit b040382

Please sign in to comment.