Commits

Michael Ma committed e91619e

修复销毁过程

  • Participants
  • Parent commits 446d789

Comments (0)

Files changed (2)

File Project/src/com/noodle/note/activity/MainActivity.java

 import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
+
 import com.noodle.note.R;
 import com.noodle.note.persistent.unitofwork.Session;
 
 	private int activeBackgroundWidth;
 	private int activeBackgroundHeight;
 	private boolean isReplaced = false;
-	
+
 	private int defaultPosition;
 	private int startPosition;
 	private int endPosition = 0;
 	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
-		setContentView(R.layout.main);
 		initViews();
 		setListeners();
 		Session session = Session.getInstance(this);
 	 * 初始化视图
 	 */
 	private void initViews() {
-
+		setContentView(R.layout.main);
 		// 获得视图对象
 		tabContentLayout = (RelativeLayout) findViewById(R.id.tabContent);
 		listContentLayout = (RelativeLayout) findViewById(R.id.listContent);
 		tab1 = (ImageView) findViewById(R.id.tab1);
 		tab2 = (ImageView) findViewById(R.id.tab2);
 		tab3 = (ImageView) findViewById(R.id.tab3);
-		
+
 		// 初始化滚动背景
 		RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
 		rl.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
 		activeBackground.setImageResource(R.drawable.icon); // TODO 修改图片
 		addButton = (ImageButton) findViewById(R.id.mainAdd);
 		searchButton = (ImageButton) findViewById(R.id.mainSearch);
-		
+
 		// 默认滚动背景位置
 		switch (defaultActiveBackgroundId) {
 		case 1:
 
 		}
 	};
-	
+
 	/**
 	 * 运行动画
 	 */
 		}
 
 	}
-	
+
 	/**
 	 * 设置动画
 	 */
-	private void setAnimation(){
+	private void setAnimation() {
 		ImageView currentActiveBackground = (ImageView) tabContentLayout.findViewWithTag("currentActiveBackground");
 		TranslateAnimation animation = new TranslateAnimation(startPosition, endPosition - defaultPosition, 0, 0);
 		startPosition = endPosition - defaultPosition; // 重新设定起始位置
 		currentActiveBackground.bringToFront();
 		currentActiveBackground.startAnimation(animation);
 	}
-	
+
 	/**
 	 * 替换原视图
 	 */
 		relativeLayout.removeView(old);
 		ImageView iv = new ImageView(this);
 		iv.setTag("currentActiveBackground");
-		iv.setImageResource(R.drawable.icon);	// TODO 修改图片
+		iv.setImageResource(R.drawable.icon); // TODO 修改图片
 		tabContentLayout.addView(iv, rl);
 	}
+
 	/**
 	 * 替换原视图
 	 */
 			break;
 		}
 	}
-	
+
 	/**
 	 * 顶部按钮监听器
 	 */
-	
+
 	OnClickListener addButtonListener = new OnClickListener() {
 		@Override
 		public void onClick(View v) {
 	OnClickListener searchButtonListener = new OnClickListener() {
 		@Override
 		public void onClick(View v) {
-			//TODO 搜索页面
+			// TODO 搜索页面
 		}
 	};
+
 	/**
 	 * 初始化Menu
 	 */
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
-	    MenuInflater inflater = getMenuInflater();
-	    inflater.inflate(R.menu.main_menu, menu);
-	    return true;
+		MenuInflater inflater = getMenuInflater();
+		inflater.inflate(R.menu.main_menu, menu);
+		return true;
 	}
+
 	/**
 	 * Menu点击事件
 	 */
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item) {
-	    switch (item.getItemId()) {
-	    case R.id.mainTab1:
-	    	//TODO 登录功能尚未实现
-	        return true;
-	    case R.id.mainTab2:
-	    	startActivity(new Intent().setClass(this, NotebookManageActivity.class));
-	        return true;
-	    case R.id.mainTab3:
-	    	//TODO 设置功能尚未实现
-	    	return true;
-	    default:
-	        return super.onOptionsItemSelected(item);
-	    }
+		switch (item.getItemId()) {
+		case R.id.mainTab1:
+			// TODO 登录功能尚未实现
+			return true;
+		case R.id.mainTab2:
+			startActivity(new Intent().setClass(this, NotebookManageActivity.class));
+			return true;
+		case R.id.mainTab3:
+			// TODO 设置功能尚未实现
+			return true;
+		default:
+			return super.onOptionsItemSelected(item);
+		}
 	}
-	
+
+	@Override
+	protected void onRestart() {
+		super.onRestart();
+	}
+
 }

File Project/src/com/noodle/note/activity/NotebookManageActivity.java

 			bundle.putString("notebookName", notebookName);
 			intent.putExtras(bundle);
 			startActivity(intent);
+			NotebookManageActivity.this.finish();
 			break;
 		/** 长按菜单的“删除”操作 */
 		case 1: