Skip to content
Browse files

2012-9-20 V1.7.3

1.修复列表滑到底部后,自动加载“更多”数据时,出现重复加载;( by @kongnanlive )
2.修复用户在首页没法使用音量键的问题;
  • Loading branch information...
1 parent f85bec2 commit 05c6079e8309d3c349cd9f90aa707abede676014 @jxsmallmouse jxsmallmouse committed Oct 22, 2012
Showing with 245 additions and 76 deletions.
  1. +2 −2 AndroidManifest.xml
  2. +4 −0 res/values/messages.xml
  3. +7 −0 src/net/oschina/app/AppContext.java
  4. +75 −1 src/net/oschina/app/AppException.java
  5. +1 −4 src/net/oschina/app/AppManager.java
  6. +36 −0 src/net/oschina/app/common/UIHelper.java
  7. +2 −3 src/net/oschina/app/ui/About.java
  8. +31 −0 src/net/oschina/app/ui/BaseActivity.java
  9. +2 −5 src/net/oschina/app/ui/BlogDetail.java
  10. +1 −2 src/net/oschina/app/ui/CommentPub.java
  11. +1 −2 src/net/oschina/app/ui/FeedBack.java
  12. +1 −2 src/net/oschina/app/ui/ImageDialog.java
  13. +1 −2 src/net/oschina/app/ui/ImageZoomDialog.java
  14. +10 −2 src/net/oschina/app/ui/LoginDialog.java
  15. +11 −5 src/net/oschina/app/ui/Main.java
  16. +2 −2 src/net/oschina/app/ui/MessageDetail.java
  17. +1 −2 src/net/oschina/app/ui/MessageForward.java
  18. +1 −2 src/net/oschina/app/ui/MessagePub.java
  19. +2 −5 src/net/oschina/app/ui/NewsDetail.java
  20. +2 −5 src/net/oschina/app/ui/QuestionDetail.java
  21. +1 −2 src/net/oschina/app/ui/QuestionPub.java
  22. +2 −5 src/net/oschina/app/ui/QuestionTag.java
  23. +2 −2 src/net/oschina/app/ui/Search.java
  24. +11 −0 src/net/oschina/app/ui/Setting.java
  25. +23 −7 src/net/oschina/app/ui/SoftwareDetail.java
  26. +2 −2 src/net/oschina/app/ui/SoftwareLib.java
  27. +2 −2 src/net/oschina/app/ui/TweetDetail.java
  28. +1 −2 src/net/oschina/app/ui/TweetPub.java
  29. +3 −2 src/net/oschina/app/ui/UserCenter.java
  30. +2 −2 src/net/oschina/app/ui/UserFavorite.java
  31. +2 −2 src/net/oschina/app/ui/UserFriend.java
  32. +1 −2 src/net/oschina/app/ui/UserInfo.java
View
4 AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.oschina.app"
- android:versionCode="15"
- android:versionName="1.7.1 Beta2">
+ android:versionCode="17"
+ android:versionName="1.7.3">
<uses-sdk android:minSdkVersion="4" />
<application android:name=".AppContext" android:icon="@drawable/icon" android:label="@string/app_name" >
View
4 res/values/messages.xml
@@ -12,6 +12,10 @@
<string name="sure">确定</string>
<string name="cancle">取消</string>
+ <string name="app_error">应用程序错误</string>
+ <string name="app_error_message">很抱歉,应用程序出现错误,即将退出。\n请提交错误报告,我们会尽快修复这个问题!</string>
+ <string name="submit_report">提交报告</string>
+
<string name="load_more">更多</string>
<string name="load_ing">加载中···</string>
<string name="load_full">已加载全部</string>
View
7 src/net/oschina/app/AppContext.java
@@ -84,6 +84,13 @@ public void handleMessage(Message msg) {
}
}
};
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ //注册App异常崩溃处理器
+ Thread.setDefaultUncaughtExceptionHandler(AppException.getAppExceptionHandler());
+ }
/**
* 检测当前系统声音是否为正常模式
View
76 src/net/oschina/app/AppException.java
@@ -4,15 +4,20 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
+import java.lang.Thread.UncaughtExceptionHandler;
import java.net.ConnectException;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Date;
+import net.oschina.app.common.UIHelper;
+
import org.apache.commons.httpclient.HttpException;
import android.content.Context;
+import android.content.pm.PackageInfo;
import android.os.Environment;
+import android.os.Looper;
import android.widget.Toast;
/**
@@ -21,7 +26,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class AppException extends Exception {
+public class AppException extends Exception implements UncaughtExceptionHandler{
private final static boolean Debug = false;//是否保存错误日志
@@ -37,6 +42,13 @@
private byte type;
private int code;
+ /** 系统默认的UncaughtException处理类 */
+ private Thread.UncaughtExceptionHandler mDefaultHandler;
+
+ private AppException(){
+ this.mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
+ }
+
private AppException(byte type, int code, Exception excp) {
super(excp);
this.type = type;
@@ -169,5 +181,67 @@ else if(e instanceof SocketException){
public static AppException run(Exception e) {
return new AppException(TYPE_RUN, 0, e);
}
+
+ /**
+ * 获取APP异常崩溃处理对象
+ * @param context
+ * @return
+ */
+ public static AppException getAppExceptionHandler(){
+ return new AppException();
+ }
+ @Override
+ public void uncaughtException(Thread thread, Throwable ex) {
+
+ if(!handleException(ex) && mDefaultHandler != null) {
+ mDefaultHandler.uncaughtException(thread, ex);
+ }
+
+ }
+ /**
+ * 自定义异常处理:收集错误信息&发送错误报告
+ * @param ex
+ * @return true:处理了该异常信息;否则返回false
+ */
+ private boolean handleException(Throwable ex) {
+ if(ex == null) {
+ return false;
+ }
+
+ final Context context = AppManager.getAppManager().currentActivity();
+
+ if(context == null) {
+ return false;
+ }
+
+ final String crashReport = getCrashReport(context, ex);
+ //显示异常信息&发送报告
+ new Thread() {
+ public void run() {
+ Looper.prepare();
+ UIHelper.sendAppCrashReport(context, crashReport);
+ Looper.loop();
+ }
+
+ }.start();
+ return true;
+ }
+ /**
+ * 获取APP崩溃异常报告
+ * @param ex
+ * @return
+ */
+ private String getCrashReport(Context context, Throwable ex) {
+ PackageInfo pinfo = ((AppContext)context.getApplicationContext()).getPackageInfo();
+ StringBuffer exceptionStr = new StringBuffer();
+ exceptionStr.append("Version: "+pinfo.versionName+"("+pinfo.versionCode+")\n");
+ exceptionStr.append("Android: "+android.os.Build.VERSION.RELEASE+"("+android.os.Build.MODEL+")\n");
+ exceptionStr.append("Exception: "+ex.getMessage()+"\n");
+ StackTraceElement[] elements = ex.getStackTrace();
+ for (int i = 0; i < elements.length; i++) {
+ exceptionStr.append(elements[i].toString()+"\n");
+ }
+ return exceptionStr.toString();
+ }
}
View
5 src/net/oschina/app/AppManager.java
@@ -48,10 +48,7 @@ public Activity currentActivity(){
*/
public void finishActivity(){
Activity activity=activityStack.lastElement();
- if(activity!=null){
- activity.finish();
- activity=null;
- }
+ finishActivity(activity);
}
/**
* 结束指定的Activity
View
36 src/net/oschina/app/common/UIHelper.java
@@ -1330,6 +1330,42 @@ public void run() {
}
/**
+ * 发送App异常崩溃报告
+ * @param cont
+ * @param crashReport
+ */
+ public static void sendAppCrashReport(final Context cont, final String crashReport)
+ {
+ AlertDialog.Builder builder = new AlertDialog.Builder(cont);
+ builder.setIcon(android.R.drawable.ic_dialog_info);
+ builder.setTitle(R.string.app_error);
+ builder.setMessage(R.string.app_error_message);
+ builder.setPositiveButton(R.string.submit_report, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ //发送异常报告
+ Intent i = new Intent(Intent.ACTION_SEND);
+ //i.setType("text/plain"); //模拟器
+ i.setType("message/rfc822") ; //真机
+ i.putExtra(Intent.EXTRA_EMAIL, new String[]{"jxsmallmouse@163.com"});
+ i.putExtra(Intent.EXTRA_SUBJECT,"开源中国Android客户端 - 错误报告");
+ i.putExtra(Intent.EXTRA_TEXT,crashReport);
+ cont.startActivity(Intent.createChooser(i, "发送错误报告"));
+ //退出
+ AppManager.getAppManager().AppExit(cont);
+ }
+ });
+ builder.setNegativeButton(R.string.sure, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ //退出
+ AppManager.getAppManager().AppExit(cont);
+ }
+ });
+ builder.show();
+ }
+
+ /**
* 退出程序
* @param cont
*/
View
5 src/net/oschina/app/ui/About.java
@@ -2,7 +2,6 @@
import net.oschina.app.R;
import net.oschina.app.common.UpdateManager;
-import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
@@ -16,7 +15,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class About extends Activity{
+public class About extends BaseActivity{
private TextView mVersion;
private Button mUpdate;
@@ -40,6 +39,6 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View v) {
UpdateManager.getUpdateManager().checkAppUpdate(About.this, true);
}
- });
+ });
}
}
View
31 src/net/oschina/app/ui/BaseActivity.java
@@ -0,0 +1,31 @@
+package net.oschina.app.ui;
+
+import net.oschina.app.AppManager;
+import android.app.Activity;
+import android.os.Bundle;
+
+/**
+ * 应用程序Activity的基类
+ * @author liux (http://my.oschina.net/liux)
+ * @version 1.0
+ * @created 2012-9-18
+ */
+public class BaseActivity extends Activity{
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ //添加Activity到堆栈
+ AppManager.getAppManager().addActivity(this);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+
+ //结束Activity&从堆栈中移除
+ AppManager.getAppManager().finishActivity(this);
+ }
+
+}
View
7 src/net/oschina/app/ui/BlogDetail.java
@@ -7,7 +7,6 @@
import net.oschina.app.AppConfig;
import net.oschina.app.AppContext;
import net.oschina.app.AppException;
-import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.adapter.ListViewCommentAdapter;
import net.oschina.app.bean.Blog;
@@ -20,7 +19,6 @@
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.BadgeView;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
@@ -53,7 +51,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class BlogDetail extends Activity {
+public class BlogDetail extends BaseActivity {
private FrameLayout mHeader;
private LinearLayout mFooter;
@@ -122,8 +120,6 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.blog_detail);
- AppManager.getAppManager().addActivity(this);
-
this.initView();
this.initData();
@@ -526,6 +522,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvComment.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvComment_foot_more.setText(R.string.load_ing);
lvComment_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
3 src/net/oschina/app/ui/CommentPub.java
@@ -8,7 +8,6 @@
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.LinkView;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@@ -26,7 +25,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class CommentPub extends Activity{
+public class CommentPub extends BaseActivity{
public final static int CATALOG_NEWS = 1;
public final static int CATALOG_POST = 2;
View
3 src/net/oschina/app/ui/FeedBack.java
@@ -3,7 +3,6 @@
import net.oschina.app.R;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -17,7 +16,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class FeedBack extends Activity{
+public class FeedBack extends BaseActivity{
private ImageButton mClose;
private EditText mEditer;
View
3 src/net/oschina/app/ui/ImageDialog.java
@@ -10,7 +10,6 @@
import net.oschina.app.common.ImageUtils;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
@@ -26,7 +25,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class ImageDialog extends Activity{
+public class ImageDialog extends BaseActivity{
private ViewSwitcher mViewSwitcher;
private ImageButton btn_close;
View
3 src/net/oschina/app/ui/ImageZoomDialog.java
@@ -10,7 +10,6 @@
import net.oschina.app.common.ImageUtils;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
@@ -35,7 +34,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class ImageZoomDialog extends Activity implements OnTouchListener, OnClickListener {
+public class ImageZoomDialog extends BaseActivity implements OnTouchListener, OnClickListener {
// These matrices will be used to move and zoom image
Matrix matrix = new Matrix();
View
12 src/net/oschina/app/ui/LoginDialog.java
@@ -8,12 +8,12 @@
import net.oschina.app.bean.User;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AutoCompleteTextView;
@@ -29,7 +29,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class LoginDialog extends Activity{
+public class LoginDialog extends BaseActivity{
private ViewSwitcher mViewSwitcher;
private ImageButton btn_close;
@@ -171,4 +171,12 @@ public void run() {
}
}.start();
}
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if(keyCode == KeyEvent.KEYCODE_BACK) {
+ this.onDestroy();
+ }
+ return super.onKeyDown(keyCode, event);
+ }
}
View
16 src/net/oschina/app/ui/Main.java
@@ -12,7 +12,6 @@
import net.oschina.app.AppConfig;
import net.oschina.app.AppContext;
import net.oschina.app.AppException;
-import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.adapter.ListViewActiveAdapter;
import net.oschina.app.adapter.ListViewBlogAdapter;
@@ -72,7 +71,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class Main extends Activity {
+public class Main extends BaseActivity {
public static final int QUICKACTION_LOGIN_OR_LOGOUT = 0;
public static final int QUICKACTION_USERINFO = 1;
@@ -196,8 +195,6 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- AppManager.getAppManager().addActivity(this);
-
//注册广播接收器
tweetReceiver = new TweetReceiver();
IntentFilter filter = new IntentFilter();
@@ -471,6 +468,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvNews.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvNews.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvNews_foot_more.setText(R.string.load_ing);
lvNews_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
@@ -538,6 +536,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvBlog.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvBlog.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvBlog_foot_more.setText(R.string.load_ing);
lvBlog_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
@@ -605,6 +604,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvQuestion.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvQuestion.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvQuestion_foot_more.setText(R.string.load_ing);
lvQuestion_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
@@ -672,6 +672,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvTweet.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvTweet.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvTweet_foot_more.setText(R.string.load_ing);
lvTweet_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
@@ -794,6 +795,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvActive.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvActive.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvActive_foot_more.setText(R.string.load_ing);
lvActive_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
@@ -870,6 +872,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvMsg.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvMsg.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvMsg_foot_more.setText(R.string.load_ing);
lvMsg_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
@@ -2055,6 +2058,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
* 监听返回--是否退出程序
*/
public boolean onKeyDown(int keyCode, KeyEvent event) {
+ boolean flag = true;
if(keyCode == KeyEvent.KEYCODE_BACK) {
//是否退出应用
UIHelper.Exit(this);
@@ -2065,7 +2069,9 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
}else if(keyCode == KeyEvent.KEYCODE_SEARCH){
//展示搜索页
UIHelper.showSearch(Main.this);
+ }else{
+ flag = super.onKeyDown(keyCode, event);
}
- return true;
+ return flag;
}
}
View
4 src/net/oschina/app/ui/MessageDetail.java
@@ -16,7 +16,6 @@
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@@ -40,7 +39,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class MessageDetail extends Activity{
+public class MessageDetail extends BaseActivity{
private ImageView mBack;
private ImageView mRefresh;
@@ -191,6 +190,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvComment.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvComment_foot_more.setText(R.string.load_ing);
lvComment_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
3 src/net/oschina/app/ui/MessageForward.java
@@ -6,7 +6,6 @@
import net.oschina.app.bean.Result;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
@@ -23,7 +22,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class MessageForward extends Activity{
+public class MessageForward extends BaseActivity{
private ImageView mBack;
private EditText mReceiver;
View
3 src/net/oschina/app/ui/MessagePub.java
@@ -7,7 +7,6 @@
import net.oschina.app.bean.Result;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@@ -26,7 +25,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class MessagePub extends Activity{
+public class MessagePub extends BaseActivity{
private ImageView mBack;
private TextView mReceiver;
View
7 src/net/oschina/app/ui/NewsDetail.java
@@ -7,7 +7,6 @@
import net.oschina.app.AppConfig;
import net.oschina.app.AppContext;
import net.oschina.app.AppException;
-import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.adapter.ListViewCommentAdapter;
import net.oschina.app.bean.Comment;
@@ -21,7 +20,6 @@
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.BadgeView;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
@@ -54,7 +52,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class NewsDetail extends Activity {
+public class NewsDetail extends BaseActivity {
private FrameLayout mHeader;
private LinearLayout mFooter;
@@ -124,8 +122,6 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.news_detail);
- AppManager.getAppManager().addActivity(this);
-
this.initView();
this.initData();
@@ -546,6 +542,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvComment.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvComment_foot_more.setText(R.string.load_ing);
lvComment_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
7 src/net/oschina/app/ui/QuestionDetail.java
@@ -8,7 +8,6 @@
import net.oschina.app.AppConfig;
import net.oschina.app.AppContext;
import net.oschina.app.AppException;
-import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.adapter.ListViewCommentAdapter;
import net.oschina.app.bean.Comment;
@@ -21,7 +20,6 @@
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.BadgeView;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Color;
@@ -54,7 +52,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class QuestionDetail extends Activity {
+public class QuestionDetail extends BaseActivity {
private FrameLayout mHeader;
private LinearLayout mFooter;
@@ -124,8 +122,6 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.question_detail);
- AppManager.getAppManager().addActivity(this);
-
this.initView();
this.initData();
@@ -532,6 +528,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvComment.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvComment_foot_more.setText(R.string.load_ing);
lvComment_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
3 src/net/oschina/app/ui/QuestionPub.java
@@ -8,7 +8,6 @@
import net.oschina.app.bean.Result;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
@@ -28,7 +27,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class QuestionPub extends Activity{
+public class QuestionPub extends BaseActivity{
private ImageView mBack;
private EditText mTitle;
View
7 src/net/oschina/app/ui/QuestionTag.java
@@ -6,7 +6,6 @@
import net.oschina.app.AppContext;
import net.oschina.app.AppException;
-import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.adapter.ListViewQuestionAdapter;
import net.oschina.app.bean.Notice;
@@ -15,7 +14,6 @@
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -32,7 +30,7 @@
* @version 1.0
* @created 2012-8-27
*/
-public class QuestionTag extends Activity{
+public class QuestionTag extends BaseActivity{
private ImageView mHome;
private TextView mHeadTitle;
@@ -58,8 +56,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.question_tag);
- AppManager.getAppManager().addActivity(this);
-
//初始化视图控件
initView();
@@ -123,6 +119,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
int lvDataState = StringUtils.toInt(lvQuestion.getTag());
if(scrollEnd && lvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ lvQuestion.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvQuestion_foot_more.setText(R.string.load_ing);
lvQuestion_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
4 src/net/oschina/app/ui/Search.java
@@ -12,7 +12,6 @@
import net.oschina.app.bean.SearchList.Result;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -33,7 +32,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class Search extends Activity{
+public class Search extends BaseActivity{
private Button mSearchBtn;
private EditText mSearchEditer;
private ProgressBar mProgressbar;
@@ -190,6 +189,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mlvSearch.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvSearch_foot_more.setText(R.string.load_ing);
lvSearch_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
11 src/net/oschina/app/ui/Setting.java
@@ -3,6 +3,7 @@
import java.io.File;
import net.oschina.app.AppContext;
+import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.common.FileUtils;
import net.oschina.app.common.MethodsCompat;
@@ -37,6 +38,9 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ //添加Activity到堆栈
+ AppManager.getAppManager().addActivity(this);
+
//设置显示Preferences
addPreferencesFromResource(R.xml.preferences);
//获得SharedPreferences
@@ -225,4 +229,11 @@ protected void onNewIntent(Intent intent) {
account.setTitle(R.string.main_menu_logout);
}
}
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ //结束Activity&从堆栈中移除
+ AppManager.getAppManager().finishActivity(this);
+ }
}
View
30 src/net/oschina/app/ui/SoftwareDetail.java
@@ -2,7 +2,6 @@
import net.oschina.app.AppContext;
import net.oschina.app.AppException;
-import net.oschina.app.AppManager;
import net.oschina.app.R;
import net.oschina.app.api.ApiClient;
import net.oschina.app.bean.FavoriteList;
@@ -11,7 +10,6 @@
import net.oschina.app.bean.Software;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
@@ -35,7 +33,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class SoftwareDetail extends Activity {
+public class SoftwareDetail extends BaseActivity {
private FrameLayout mHeader;
private ImageView mBack;
@@ -79,8 +77,6 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.software_detail);
- AppManager.getAppManager().addActivity(this);
-
this.initView();
this.initData();
@@ -234,8 +230,28 @@ public void run() {
Message msg = new Message();
try {
softwareDetail = ((AppContext)getApplication()).getSoftware(ident, isRefresh);
- if(softwareDetail != null){
- logo = ApiClient.getNetBitmap(softwareDetail.getLogo());
+ if(softwareDetail != null && !StringUtils.isEmpty(softwareDetail.getLogo())){
+ /* 软件logo格式为gif,保存后再读取图片透明效果消失
+ //先加载SD卡中的图片缓存
+ String filename = FileUtils.getFileName(softwareDetail.getLogo());
+ String filepath = getFilesDir() + File.separator + filename;
+ File file = new File(filepath);
+ if(file.exists()){
+ logo = ImageUtils.getBitmap(SoftwareDetail.this, filename);
+ }else{
+ //加载网络图片
+ logo = ApiClient.getNetBitmap(softwareDetail.getLogo());
+ if(logo != null){
+ //向SD卡中写入图片缓存
+ try{
+ ImageUtils.saveImage(SoftwareDetail.this, filename, logo);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }*/
+ //加载网络图片
+ logo = ApiClient.getNetBitmap(softwareDetail.getLogo());
}
msg.what = (softwareDetail!=null && softwareDetail.getId()>0) ? 1 : 0;
msg.obj = (softwareDetail!=null) ? softwareDetail.getNotice() : null;
View
4 src/net/oschina/app/ui/SoftwareLib.java
@@ -18,7 +18,6 @@
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
import net.oschina.app.widget.ScrollLayout;
-import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -38,7 +37,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class SoftwareLib extends Activity{
+public class SoftwareLib extends BaseActivity{
private ImageView mBack;
private TextView mTitle;
@@ -295,6 +294,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvSoftwareDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mlvSoftware.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvSoftware_foot_more.setText(R.string.load_ing);
lvSoftware_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
4 src/net/oschina/app/ui/TweetDetail.java
@@ -18,7 +18,6 @@
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.drawable.Drawable;
@@ -49,7 +48,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class TweetDetail extends Activity {
+public class TweetDetail extends BaseActivity {
private ImageView mBack;
private ImageView mRefresh;
@@ -253,6 +252,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvComment.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvComment_foot_more.setText(R.string.load_ing);
lvComment_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
3 src/net/oschina/app/ui/TweetPub.java
@@ -17,7 +17,6 @@
import net.oschina.app.common.MediaUtils;
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -55,7 +54,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class TweetPub extends Activity{
+public class TweetPub extends BaseActivity{
private FrameLayout mForm;
private ImageView mBack;
View
5 src/net/oschina/app/ui/UserCenter.java
@@ -20,7 +20,6 @@
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
import net.oschina.app.widget.UserInfoDialog;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -41,7 +40,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class UserCenter extends Activity{
+public class UserCenter extends BaseActivity{
private ImageView mBack;
private ImageView mRefresh;
@@ -192,6 +191,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvActiveDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvActive.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvActive_foot_more.setText(R.string.load_ing);
lvActive_foot_progress.setVisibility(View.VISIBLE);
//当前页数
@@ -250,6 +250,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvBlogDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mLvBlog.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvBlog_foot_more.setText(R.string.load_ing);
lvBlog_foot_progress.setVisibility(View.VISIBLE);
//当前页数
View
4 src/net/oschina/app/ui/UserFavorite.java
@@ -14,7 +14,6 @@
import net.oschina.app.bean.FavoriteList.Favorite;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -32,7 +31,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class UserFavorite extends Activity {
+public class UserFavorite extends BaseActivity {
private ImageView mBack;
private ProgressBar mProgressbar;
@@ -150,6 +149,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mlvFavorite.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvFavorite_foot_more.setText(R.string.load_ing);
lvFavorite_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
4 src/net/oschina/app/ui/UserFriend.java
@@ -13,7 +13,6 @@
import net.oschina.app.bean.Notice;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.PullToRefreshListView;
-import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -31,7 +30,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class UserFriend extends Activity {
+public class UserFriend extends BaseActivity {
private ImageView mBack;
private ProgressBar mProgressbar;
@@ -147,6 +146,7 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollEnd && curLvDataState==UIHelper.LISTVIEW_DATA_MORE)
{
+ mlvFriend.setTag(UIHelper.LISTVIEW_DATA_LOADING);
lvFriend_foot_more.setText(R.string.load_ing);
lvFriend_foot_progress.setVisibility(View.VISIBLE);
//当前pageIndex
View
3 src/net/oschina/app/ui/UserInfo.java
@@ -16,7 +16,6 @@
import net.oschina.app.common.StringUtils;
import net.oschina.app.common.UIHelper;
import net.oschina.app.widget.LoadingDialog;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
@@ -39,7 +38,7 @@
* @version 1.0
* @created 2012-3-21
*/
-public class UserInfo extends Activity{
+public class UserInfo extends BaseActivity{
private ImageView back;
private ImageView refresh;

0 comments on commit 05c6079

Please sign in to comment.
Something went wrong with that request. Please try again.