标签:
转载自:Android应用框架 http://www.tuicool.com/articles/feqmQj
常用工具类总结 http://blog.csdn.net/krislight/article/details/11354119
一、 UML类图复习:
UML类图中有些标记很容易混淆,这里先复习下,请大家看下面这幅图:
注:这幅图来自《大话设计模式》这本书中的插图。
二、应用框架:
A、基本概念
抽象(抽出共同之现象)——在同领域的程序中,常含有许多类别,这些类别有其共同点,我们将类别之共同结构抽离出来,称为抽象类别。其抽象之步骤是: 1、观察几个相似的类别;2、分辨它们的异同点;3、把它们的共同点抽离出来。
衍生(与众不同之现象)——基于通用结构里的抽象类别,添加些特殊功能(扩展),使之成为具体类别,再诞生对象。
所以抽象类别的存在目的,是要用其衍生子类别,而不是由它本身来诞生对象。由于抽象类别本身不诞生对象,所以有些方法并不完整。反之,类别之内的方法,皆是完整的,而且要用来诞生对象,就称它为具体类别。所谓不完整就是方法的方法体从缺,只有方法的描述。
B、打造自己的专属应用框架之类图:
C、 打造自己的专属应用框架之编码实现:
BaseApplication类源码如下:
package com.lbt.hairdesigner;
import java.util.ArrayList;
import android.app.Activity;
import android.app.Application;
/**
* 功能描述:用于存放全局变量和公用的资源等
* @author android_ls
*/
public class BaseApplication extends Application {
/**
* Activity集合
*/
private static ArrayList<BaseActivity> activitys = new ArrayList<BaseActivity>();
@Override
public void onCreate() {
}
/**
* 添加Activity到ArrayList<Activity>管理集合
* @param activity
*/
public void addActivity(BaseActivity activity) {
String className = activity.getClass().getName();
for (Activity at : activitys) {
if (className.equals(at.getClass().getName())) {
activitys.remove(at);
break;
}
}
activitys.add(activity);
}
/**
* 退出应用程序的时候,手动调用
*/
@Override
public void onTerminate() {
for (BaseActivity activity : activitys) {
activity.defaultFinish();
}
}
}
BaseActivity类源码如下:
package com.lbt.hairdesigner;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.Toast;
import com.lbt.hairdesigner.utils.LogUtil;
/**
* 功能描述:对Activity类进行扩展
* @author android_ls
*/
public abstract class BaseActivity extends Activity {
/**
* LOG打印标签
*/
private static final String TAG = BaseActivity.class.getSimpleName();
/**
* 全局的Context {@link #mContext = this.getApplicationContext();}
*/
protected Context mContext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
int layoutId = getLayoutId();
if (layoutId != 0) {
setContentView(layoutId);
// 删除窗口背景
getWindow().setBackgroundDrawable(null);
}
mContext = this.getApplicationContext();
((BaseApplication) this.getApplication()).addActivity(this);
// 向用户展示信息前的准备工作在这个方法里处理
preliminary();
}
/**
* 向用户展示信息前的准备工作在这个方法里处理
*/
protected void preliminary() {
// 初始化组件
setupViews();
// 初始化数据
initialized();
}
/**
* 获取全局的Context
* @return {@link #mContext = this.getApplicationContext();}
*/
public Context getContext() {
return mContext;
}
/**
* 布局文件ID
* @return
*/
protected abstract int getLayoutId();
/**
* 初始化组件
*/
protected abstract void setupViews();
/**
* 初始化数据
*/
protected abstract void initialized();
/**
* Debug输出Log信息
* @param tag
* @param msg
*/
protected void debugLog(String msg) {
LogUtil.d(TAG, msg);
}
/**
* Error输出Log信息
* @param msg
*/
protected void errorLog(String msg) {
LogUtil.e(TAG, msg);
}
/**
* Info输出Log信息
* @param msg
*/
protected void showLog(String msg) {
LogUtil.i(TAG, msg);
}
/**
* 长时间显示Toast提示(来自String)
* @param message
*/
protected void showToast(String message) {
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
}
/**
* 长时间显示Toast提示(来自res)
* @param resId
*/
protected void showToast(int resId) {
Toast.makeText(mContext, getString(resId), Toast.LENGTH_LONG).show();
}
/**
* 短暂显示Toast提示(来自res)
* @param resId
*/
protected void showShortToast(int resId) {
Toast.makeText(mContext, getString(resId), Toast.LENGTH_SHORT).show();
}
/**
* 短暂显示Toast提示(来自String)
* @param text
*/
protected void showShortToast(String text) {
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}
/**
* 通过Class跳转界面
**/
public void startActivity(Class<?> cls) {
startActivity(cls, null);
}
/**
* 含有Bundle通过Class跳转界面
**/
public void startActivity(Class<?> cls, Bundle bundle) {
Intent intent = new Intent();
intent.setClass(this, cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
}
/**
* 通过Action跳转界面
**/
public void startActivity(String action) {
startActivity(action, null);
}
/**
* 含有Bundle通过Action跳转界面
**/
public void startActivity(String action, Bundle bundle) {
Intent intent = new Intent();
intent.setAction(action);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
}
/**
* 含有Bundle通过Class打开编辑界面
**/
public void startActivityForResult(Class<?> cls, Bundle bundle, int requestCode) {
Intent intent = new Intent();
intent.setClass(this, cls);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivityForResult(intent, requestCode);
overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
}
/**
* 带有右进右出动画的退出
*/
@Override
public void finish() {
super.finish();
overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
}
/**
* 默认退出
*/
public void defaultFinish() {
super.finish();
}
}
BaseNetworkActivity类源码如下:
package com.lbt.hairdesigner;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.os.Handler;
import com.lbt.hairdesigner.net.AsyncBaseRequest;
import com.lbt.hairdesigner.net.DefaultThreadPool;
/**
* 功能描述:应用中需要访问网络的Activity基类
* @author android_ls
*/
public abstract class BaseNetworkActivity extends BaseActivity {
/**
* 当前activity所持有的所有网络请求
*/
protected List<AsyncBaseRequest> mAsyncRequests;
/**
* 当前activity所持有的Handler
*/
protected Handler mHandler;
/**
* 当前activity所持有的线程池对象
*/
protected DefaultThreadPool mDefaultThreadPool;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
/**
* 向用户展示信息前的准备工作在这个方法里处理
*/
protected void preliminary() {
mHandler = new Handler();
mAsyncRequests = new ArrayList<AsyncBaseRequest>();
mDefaultThreadPool = DefaultThreadPool.getInstance();
// 初始化组件
setupViews();
// 初始化数据
initialized();
}
public List<AsyncBaseRequest> getAsyncRequests() {
return mAsyncRequests;
}
public Handler getHandler() {
return mHandler;
}
public DefaultThreadPool getDefaultThreadPool() {
return mDefaultThreadPool;
}
@Override
protected void onPause() {
/**
* 在activity暂停的时候,同时设置终止标识,终止异步线程
*/
cancelAllRequest();
super.onPause();
}
@Override
protected void onDestroy() {
/**
* 在activity销毁的时候,同时设置终止标识,终止异步线程
*/
cancelAllRequest();
super.onDestroy();
}
/**
* 取消当前Activity相关的网络请求
*/
private void cancelAllRequest() {
if (mAsyncRequests != null && mAsyncRequests.size() > 0) {
try {
int size = mAsyncRequests.size();
for (int i = 0; i < size; i++) {
AsyncBaseRequest request = mAsyncRequests.get(i);
request.setInterrupted(true);
mAsyncRequests.remove(request);
size = mAsyncRequests.size();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
PhotoNetworkActivity类源码如下:
package com.lbt.hairdesigner;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import com.lbt.hairdesigner.utils.Constant;
/**
* 功能描述:内置网络请求接口和照片处理的Activity基类
* @author android_ls
*/
public abstract class PhotoNetworkActivity extends BaseNetworkActivity {
/**
* 照片存储路径
* @return
*/
protected abstract String getPhotoPath();
/**
* 照片处理完成后的结果
* @param bitmap
*/
protected abstract void onPhotoResult(Bitmap bitmap);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (Constant.REQUEST_CAMERA_CODE == requestCode) {
if (resultCode == Activity.RESULT_OK) {
System.err.println("getPhotoPath() = " + getPhotoPath());
File file = new File(getPhotoPath());
if (file.exists()) {
showToast("拍摄的照片已存好");
cropPhoto(Uri.fromFile(file));
}
} else {
showToast("取消了拍照");
}
} else if (Constant.REQUEST_GALLERY_CODE == requestCode) {
if (resultCode == Activity.RESULT_OK) {
Uri uri = data.getData();
showToast("照片已选取");
cropPhoto(uri);
} else {
showToast("取消了选取照片");
}
} else if (Constant.REQUEST_CROP_PHOTO_CODE == requestCode) {
if (resultCode == Activity.RESULT_OK) {
photoCropResult(data);
} else {
showToast("取消了剪裁照片");
}
}
}
/**
* 调用系统裁剪照片应用
* @param uri Uri
*/
private void cropPhoto(Uri uri) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 200);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra("return-data", true);
startActivityForResult(intent, Constant.REQUEST_CROP_PHOTO_CODE);
}
/**
* 剪裁完成后返回的Bitmap
* @param data Intent
*/
private void photoCropResult(Intent intent) {
Bundle extras = intent.getExtras();
if (extras != null) {
Bitmap bitmap = extras.getParcelable("data");
if (bitmap != null) {
showToast("裁剪照片成功");
onPhotoResult(bitmap);
}
} else {
showToast("获取裁剪照片出错");
}
}
}
BaseFrameLayout类源码如下:
package com.lbt.hairdesigner;
import java.util.List;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.lbt.hairdesigner.net.AsyncBaseRequest;
import com.lbt.hairdesigner.net.DefaultThreadPool;
import com.lbt.hairdesigner.utils.LogUtil;
import com.lbt.hairdesigner.widget.TopNavbar;
/**
* 功能描述:主界面中各个视图的父类
* @author android_ls
*/
public abstract class BaseFrameLayout extends FrameLayout {
/**
* LOG打印标签
*/
protected static final String TAG = BaseFrameLayout.class.getSimpleName();
protected TopNavbar topMenuNavbar;
public TopNavbar getTopMenuNavbar() {
return topMenuNavbar;
}
/**
* 获取顶部左侧的menu组件
* @return
*/
public LinearLayout getMenuView() {
return topMenuNavbar.llShowMenu;
}
/**
* 应用主界面
*/
protected BaseNetworkActivity mActivity;
/**
* 当前activity所持有的所有网络请求
*/
protected List<AsyncBaseRequest> mAsyncRequests;
/**
* 当前activity所持有的Handler
*/
protected Handler mHandler;
/**
* 当前activity所持有的线程池对象
*/
protected DefaultThreadPool mDefaultThreadPool;
protected LayoutInflater mLayoutInflater;
/**
* 当前视图的父容器
*/
protected LinearLayout viewRoot;
public BaseFrameLayout(BaseNetworkActivity activity) {
super(activity);
mActivity = activity;
mLayoutInflater = LayoutInflater.from(getContext());
this.mAsyncRequests = activity.getAsyncRequests();
this.mDefaultThreadPool = activity.getDefaultThreadPool();
this.mHandler = activity.getHandler();
// 向用户展示信息前的准备工作在这个方法里处理
preliminary();
}
/**
* 向用户展示信息前的准备工作在这个方法里处理
*/
protected void preliminary() {
// 初始化组件
setupViews();
// 初始化数据
initialized();
}
/**
* 初始化组件
*/
protected void setupViews() {
int layoutId = getLayoutId();
if (layoutId != 0) {
viewRoot = (LinearLayout) mLayoutInflater.inflate(layoutId, null);
addView(viewRoot);
topMenuNavbar = (TopNavbar) viewRoot.findViewById(R.id.rl_top_menu_navbar);
topMenuNavbar.ivRefresh.setVisibility(View.GONE);
topMenuNavbar.ivRightLine.setVisibility(View.GONE);
topMenuNavbar.tvRightOperationName.setVisibility(View.GONE);
topMenuNavbar.ivDownListIcon.setVisibility(View.GONE);
}
}
/**
* 布局文件ID
* @return
*/
protected abstract int getLayoutId();
/**
* 初始化数据
*/
protected abstract void initialized();
/**
* Debug输出Log信息
* @param tag
* @param msg
*/
protected void debugLog(String msg) {
LogUtil.d(TAG, msg);
}
/**
* Error输出Log信息
* @param msg
*/
protected void errorLog(String msg) {
LogUtil.e(TAG, msg);
}
/**
* Info输出Log信息
* @param msg
*/
protected void showLog(String msg) {
LogUtil.i(TAG, msg);
}
/**
* 长时间显示Toast提示(来自String)
* @param message
*/
protected void showToast(String message) {
Toast.makeText(mActivity, message, Toast.LENGTH_LONG).show();
}
/**
* 长时间显示Toast提示(来自res)
* @param resId
*/
protected void showToast(int resId) {
Toast.makeText(mActivity, mActivity.getString(resId), Toast.LENGTH_LONG).show();
}
/**
* 短暂显示Toast提示(来自res)
* @param resId
*/
protected void showShortToast(int resId) {
Toast.makeText(mActivity, mActivity.getString(resId), Toast.LENGTH_SHORT).show();
}
/**
* 短暂显示Toast提示(来自String)
* @param text
*/
protected void showShortToast(String text) {
Toast.makeText(mActivity, text, Toast.LENGTH_SHORT).show();
}
}
PhotoFrameLayout类源码如下:
package com.lbt.hairdesigner;
import java.io.File;
import java.util.UUID;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.LinearLayout;
import com.lbt.hairdesigner.utils.Constant;
/**
* 功能描述:内置底部滑出拍照菜单的视图父类
* @author android_ls
*/
public abstract class PhotoFrameLayout extends BaseFrameLayout {
/**
* 底部弹出菜单
*/
protected LinearLayout llPopupMenu;
/**
* 底部弹出菜单照相机
*/
private Button btnPopupMenuCamera;
/**
* 底部弹出菜单我的相册
*/
private Button btnPopupMenuPhoto;
/**
* 底部弹出菜单取消按钮
*/
private Button btnPopupMenuCancel;
/**
* 存放拍照上传的照片路径
*/
public String mUploadPhotoPath;
public PhotoFrameLayout(BaseNetworkActivity activity) {
super(activity);
}
/**
* 初始化组件
*/
protected void setupViews() {
super.setupViews();
// 底部的弹出菜单
llPopupMenu = (LinearLayout) this.findViewById(R.id.ll_popup_menu);
btnPopupMenuCamera = (Button) this.findViewById(R.id.btn_popup_menu_camera);
btnPopupMenuPhoto = (Button) this.findViewById(R.id.btn_popup_menu_photo);
btnPopupMenuCancel = (Button) this.findViewById(R.id.btn_popup_menu_cancel);
popupMenu();
}
/**
* 底部的弹出菜单事件处理
*/
private void popupMenu() {
// 点击照相机按钮事件处理
btnPopupMenuCamera.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
llPopupMenu.setVisibility(View.GONE);
String rootDir = Constant.getRootDir(mActivity);
File dir = new File(rootDir + File.separator + Constant.IMAGE_CAMERA_UPLOAD_PATH);
if (!dir.exists()) {
dir.mkdirs();
}
mUploadPhotoPath = rootDir + "/" + Constant.IMAGE_CAMERA_UPLOAD_PATH + "/" + UUID.randomUUID().toString();
File file = new File(mUploadPhotoPath);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
mActivity.startActivityForResult(intent, Constant.REQUEST_CAMERA_CODE);
}
});
// 点击相册按钮事件处理
btnPopupMenuPhoto.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
llPopupMenu.setVisibility(View.GONE);
Intent getImage = new Intent(Intent.ACTION_GET_CONTENT);
getImage.addCategory(Intent.CATEGORY_OPENABLE);
getImage.setType("image/*");
mActivity.startActivityForResult(getImage, Constant.REQUEST_GALLERY_CODE);
}
});
// 点击取消按钮事件处理
btnPopupMenuCancel.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
TranslateAnimation animation = new TranslateAnimation(0f, 0f, 1f, 400.0f);
animation.setDuration(200);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
llPopupMenu.setVisibility(View.GONE);
}
});
llPopupMenu.startAnimation(animation);
}
});
}
}
三、基于应用框架的应用:
1、先看看效果图吧,如下:
2、具体实现层,个别类的源码
HairDesignerMainActivity类源码如下:
package com.lbt.hairdesigner.main;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import com.lbt.hairdesigner.BaseApplication;
import com.lbt.hairdesigner.PhotoNetworkActivity;
import com.lbt.hairdesigner.account.AccountManagerLayout;
import com.lbt.hairdesigner.friend.FriendsLayout;
import com.lbt.hairdesigner.leftpanel.LeftPanelLayout;
import com.lbt.hairdesigner.leftpanel.LeftPanelLayout.onChangeViewListener;
import com.lbt.hairdesigner.ma.MyAppointmentLayout;
import com.lbt.hairdesigner.message.MessageLayout;
import com.lbt.hairdesigner.personal.PersonalInformationLayout;
import com.lbt.hairdesigner.ph.PersonalHomepageLayout;
import com.lbt.hairdesigner.pm.PasswordManagerLayout;
import com.lbt.hairdesigner.site.MySiteLayout;
import com.lbt.hairdesigner.widget.ScrollerContainer;
import com.lbt.hairdesigner.widget.ScrollerContainer.OnUgcListener;
/**
* 功能描述:应用主界面
* @author android_ls
*
*/
public class HairDesignerMainActivity extends PhotoNetworkActivity implements View.OnClickListener, onChangeViewListener, OnUgcListener {
/**
* LOG打印标签
*/
private static final String TAG = HairDesignerMainActivity.class.getSimpleName();
/**
* 滚动(滑动)容器
*/
private ScrollerContainer mSlideContainer;
/**
* 菜单界面
*/
private LeftPanelLayout mDesktop;
/**
* 我的主页
*/
private PersonalHomepageLayout mPersonalHomepage;
/**
* 消息视图
*/
private MessageLayout mMessageLayout;
/**
* 好友
*/
private FriendsLayout mFriendsLayout;
/**
* 我的预约
*/
private MyAppointmentLayout mMyAppointmentLayout;
/**
* 我的日程
*/
private MyCalendarLayout mMyCalendarLayout;
/**
* 个人信息
*/
private PersonalInformationLayout mPersonalInformationLayout;
/**
* 密码管理
*/
private PasswordManagerLayout mPasswordManagerLayout;
/**
* 账户管理
*/
private AccountManagerLayout mAccountManagerLayout;
/**
* 我的场地
*/
private MySiteLayout mMySiteLayout;
/**
* 同步SNS
*/
private SynSNSLayout mSynSNSLayout;
/**
* 当前显示的View的编号
*/
private int mPosition;
/**
* 退出时间
*/
private long mExitTime;
/**
* 退出间隔
*/
private static final int EXIT_INTERVAL_TIME = 2000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected int getLayoutId() {
return 0;
}
@Override
protected void setupViews() {
mSlideContainer = new ScrollerContainer(mContext);
mSlideContainer.setOnUgcListener(this);
mDesktop = new LeftPanelLayout(this);
mDesktop.setOnChangeViewListener(this);
mPersonalHomepage = new PersonalHomepageLayout(this);
mPersonalHomepage.getMenuView().setOnClickListener(this);
mMessageLayout = new MessageLayout(this);
mMessageLayout.getMenuView().setOnClickListener(this);
mFriendsLayout = new FriendsLayout(this);
mFriendsLayout.getMenuView().setOnClickListener(this);
mMyAppointmentLayout = new MyAppointmentLayout(this);
mMyAppointmentLayout.getMenuView().setOnClickListener(this);
mMyCalendarLayout = new MyCalendarLayout(this);
mMyCalendarLayout.getMenuView().setOnClickListener(this);
mPersonalInformationLayout = new PersonalInformationLayout(this);
mPersonalInformationLayout.getMenuView().setOnClickListener(this);
mPasswordManagerLayout = new PasswordManagerLayout(this);
mPasswordManagerLayout.getMenuView().setOnClickListener(this);
mAccountManagerLayout = new AccountManagerLayout(this);
mAccountManagerLayout.getMenuView().setOnClickListener(this);
mMySiteLayout = new MySiteLayout(this);
mMySiteLayout.getMenuView().setOnClickListener(this);
mSynSNSLayout = new SynSNSLayout(this);
mSynSNSLayout.getMenuView().setOnClickListener(this);
LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
mSlideContainer.addView(mDesktop, 0, layoutParams);
mSlideContainer.addView(mPersonalHomepage, 1, layoutParams);
setContentView(mSlideContainer);
}
@Override
protected void initialized() {
}
@Override
protected String getPhotoPath() {
return mPersonalInformationLayout.mUploadPhotoPath;
}
@Override
protected void onPhotoResult(Bitmap bitmap) {
mPersonalInformationLayout.onActivityResult(bitmap);
}
@Override
public void onClick(View v) {
mSlideContainer.open();
}
@Override
public void onChangeView(int position) {
mPosition = position;
switch (position) {
case 0:
mSlideContainer.replace(mPersonalHomepage);
break;
case 1:
mSlideContainer.replace(mMessageLayout);
mMessageLayout.getFriendMessage();
break;
case 2:
mSlideContainer.replace(mFriendsLayout);
mFriendsLayout.getFriends();
break;
case 3:
mSlideContainer.replace(mMyAppointmentLayout);
break;
case 4:
mSlideContainer.replace(mMyCalendarLayout);
break;
case 5:
mSlideContainer.replace(mPersonalInformationLayout);
break;
case 6:
mSlideContainer.replace(mPasswordManagerLayout);
break;
case 7:
mSlideContainer.replace(mAccountManagerLayout);
break;
case 8:
mSlideContainer.replace(mMySiteLayout);
break;
case 9:
mSlideContainer.replace(mSynSNSLayout);
break;
default:
break;
}
}
@Override
public void dismissUGC() {
switch (mPosition) {
case 0:
mPersonalHomepage.dismissUgc();
break;
case 2:
mFriendsLayout.dismissUgc();
break;
case 3:
mMyAppointmentLayout.dismissUgc();
break;
case 5:
mPersonalInformationLayout.dismissUgc();
break;
case 6:
mPasswordManagerLayout.dismissUgc();
break;
case 7:
mAccountManagerLayout.dismissUgc();
break;
case 8:
mMySiteLayout.dismissUgc();
break;
case 9:
mSynSNSLayout.dismissUgc();
break;
default:
break;
}
}
@Override
public void showUGC() {
switch (mPosition) {
case 0:
mPersonalHomepage.showUgc();
break;
case 2:
mFriendsLayout.showUgc();
break;
case 3:
mMyAppointmentLayout.showUgc();
break;
case 5:
mPersonalInformationLayout.showUgc();
break;
case 6:
mPasswordManagerLayout.showUgc();
break;
case 7:
mAccountManagerLayout.showUgc();
break;
case 8:
mMySiteLayout.showUgc();
break;
case 9:
mSynSNSLayout.showUgc();
break;
default:
break;
}
}
/**
* 重写系统返回键事件的处理
*/
public void onBackPressed() {
if (mSlideContainer.isPanelInvisible()) {
// 如果界面的path菜单没有关闭时,关闭path菜单
if (mDesktop.getUgcIsShowing()) {
mDesktop.closeUgc();
return;
}
// 界面的path菜单处于关闭状态,关闭左侧面板
mSlideContainer.close();
} else {
switch (mPosition) {
case 0:
if (mPersonalHomepage.getUgcIsShowing()) {
mPersonalHomepage.closeUgc();
} else {
exit();
}
break;
case