基于Android的人事管理系统开发与设计源码(一)

该博客介绍了基于Android平台开发的人事管理系统,包括源码结构解析,涉及登录、管理、薪资、人员信息等多个功能模块,使用Java编程语言实现,提供了详细的项目说明链接。
摘要由CSDN通过智能技术生成

基于Android开发的人事管理系统

链接:https://blog.csdn.net/yql_617540298/article/details/108553842

上面的链接详细的介绍整个项目,是一份项目的说明报告。

整个项目是java开发的,整体的代码结构如下图所示:

 

在目录的src下面是详细的源码,整体结构如下:

PersonManage\src\com\example\adapter 

BaseFragmentAdapter.java

package com.example.adapter;

import java.util.List;

import com.example.fragment.LauncherBaseFragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

/**
 * Viewpager适配器
 * @author
 *
 */
public class BaseFragmentAdapter extends FragmentStatePagerAdapter {
	private List<LauncherBaseFragment>list;
	public BaseFragmentAdapter(FragmentManager fm, List<LauncherBaseFragment> list) {
		super(fm);
		this.list = list;
	}

	public BaseFragmentAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public int getCount() {
		return list.size();
	}
}

PersonManage\src\com\example\fragment

LastBegin.java

package com.example.fragment;

import com.example.kakalauncher.R;
import com.example.login.LoginActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

/**
 * 最后一个
 * @author 
 */
public class LastBegin extends LauncherBaseFragment implements OnClickListener{
	private static final float ZOOM_MAX = 1.3f;
	private static final  float ZOOM_MIN = 1.0f;
	
	private ImageView imgView_immediate_experience;
    
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		//匹配到.xml文件中的布局显示
		View rooView=inflater.inflate(R.layout.fragment_stereoscopic_launcher, null);
		
		//与xml中的图片绑定,创建一个监听,实现页面的跳转,回调函数
		imgView_immediate_experience=(ImageView) rooView.findViewById(R.id.imgView_immediate_experience);
		imgView_immediate_experience.setOnClickListener(this);
		return rooView;
	}
	
    public void playHeartbeatAnimation(){
    		/**
    		 * 放大动画
    		 */
        AnimationSet animationSet = new AnimationSet(true);
		animationSet.addAnimation(new ScaleAnimation(ZOOM_MIN, ZOOM_MAX, ZOOM_MIN, ZOOM_MAX, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f));
        animationSet.addAnimation(new AlphaAnimation(1.0f, 0.8f));
 
        animationSet.setDuration(500);
        animationSet.setInterpolator(new AccelerateInterpolator());
        animationSet.setFillAfter(true);
 
        animationSet.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }
 
            @Override
            public void onAnimationRepeat(Animation animation) {
            }
 
            @Override
            public void onAnimationEnd(Animation animation) {
	        		/**
	        		 * 缩小动画
	        		 */
                AnimationSet animationSet = new AnimationSet(true);
                animationSet.addAnimation(new ScaleAnimation(ZOOM_MAX, ZOOM_MIN, ZOOM_MAX,ZOOM_MIN, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f));
                animationSet.addAnimation(new AlphaAnimation(0.8f, 1.0f));
                animationSet.setDuration(600);
                animationSet.setInterpolator(new DecelerateInterpolator());
                animationSet.setFillAfter(false);
                 // 实现心跳的View
                imgView_immediate_experience.startAnimation(animationSet);
            }
        });
         // 实现心跳的View
        imgView_immediate_experience.startAnimation(animationSet);
    } 
    //实现Fragment的回调函数,onclick方法
    @Override
	public void onClick(View v) {
		Intent intent = new Intent();
		intent.setClass(getActivity(),LoginActivity.class);
		startActivity(intent);
		getActivity().finish();
	}
   
	
	@Override
	public void startAnimation() {
		playHeartbeatAnimation();
	}

	@Override
	public void stopAnimation() {
		
	}	
	
}

LauncherBaseFragment.java

package com.example.fragment;

import android.support.v4.app.Fragment;

/**
 * Fragment抽象类
 * @author 
 * 
 */
public abstract class LauncherBaseFragment extends Fragment{
	public abstract void  startAnimation();
	public abstract void  stopAnimation();
}

MoneyFragment.java

package com.example.fragment;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

import com.example.kakalauncher.R;
import com.example.login.LoginActivity;
public class MoneyFragment extends LauncherBaseFragment implements OnClickListener{
	private ImageView ivReward;
	private ImageView ivGold;
	//私有化跳过的图片
	private ImageView goon;
	
	private Bitmap goldBitmap;
	private boolean started;//是否开启动画(ViewPage滑动时候给这个变量赋值)
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		View rooView=inflater.inflate(R.layout.fragment_reward_launcher, null);
		ivGold=(ImageView) rooView.findViewById(R.id.iv_gold);
		ivReward=(ImageView) rooView.findViewById(R.id.iv_reward);
		//获取跳过图片
		goon=(ImageView) rooView.findViewById(R.id.goon);
		goon.setOnClickListener(this);
		
		//获取硬币的高度
		goldBitmap=BitmapFactory.decodeResource(getActivity().getResources(),R.drawable.icon_gold);
		startAnimation();
		return rooView;
		
	}
	//为跳转图片注册监听
	 @Override
		public void onClick(View v) {
			Intent intent = new Intent();
			intent.setClass(getActivity(),LoginActivity.class);
			startActivity(intent);
			//结束当前页面,返回到上一个页面
			getActivity().finish();
		}
	@Override
	public void startAnimation(){
		started=true;
		
		//向下移动动画 硬币的高度*2+80   
		TranslateAnimation translateAnimation=new TranslateAnimation(0,0,0,goldBitmap.getHeight()*2+80);
		translateAnimation.setDuration(500);
		translateAnimation.setFillAfter(true);
		
		ivGold.startAnimation(translateAnimation);
		translateAnimation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {}
			@Override
			public void onAnimationEnd(Animation animation){
				if(started){
					ivReward.setVisibility(View.VISIBLE);
					//硬币移动动画结束开启缩放动画
		            Animation anim=AnimationUtils.loadAnimation(getActivity(),R.anim.reward_launcher);  
		            ivReward.startAnimation(anim);
		            anim.setAnimationListener(new AnimationListener(){
		                @Override  
		                public void onAnimationStart(Animation animation) {}  
		                @Override  
		                public void onAnimationRepeat(Animation animation) {}  
		                @Override  
		                public void onAnimationEnd(Animation animation) {
		                		//缩放动画结束 开启改变透明度动画
		                		AlphaAnimation alphaAnimation=new AlphaAnimation(1,0);
		                		alphaAnimation.setDuration(1000);
		                		ivReward.startAnimation(alphaAnimation);
		                		alphaAnimation.setAnimationListener(new AnimationListener() {
									@Override
									public void onAnimationStart(Animation animation) {}
									@Override
									public void onAnimationRepeat(Animation animation) {}
									@Override
									public void onAnimationEnd(Animation animation) {
										//透明度动画结束隐藏图片
										ivReward.setVisibility(View.GONE);
									}
							});
		                }
		            });
				}
			}
			@Override
			public void onAnimationRepeat(Animation animation) {}
		});
	}
	
	@Override
	public void stopAnimation(){
		started=false;//结束动画时标示符设置为false
		ivGold.clearAnimation();//清空view上的动画
	}
}

PersonBegin.java

package com.example.fragment;

import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.example.kakalauncher.R;

/**
 * 人事
 * @author
 */
public class PersonBegin extends LauncherBaseFragment{
	private ImageView ivLikeVideo,ivThinkReward,ivThisWeek,ivWatchMovie;
	
	private Animation likeAnimation,thinkAnimation,watchAnimation,thisWeekAnimation;
	
	private boolean started;//是否开启动画
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		View rooView=inflater.inflate(R.layout.fragment_private_message_launcher, null);
		
		ivLikeVideo=(ImageView) rooView.findViewById(R.id.iv_private_message_like_video);
		ivThinkReward=(ImageView) rooView.findViewById(R.id.iv_private_message_think_reward);
		ivWatchMovie=(ImageView) rooView.findViewById(R.id.iv_private_message_watch_movie);
		ivThisWeek=(ImageView) rooView.findViewById(R.id.private_message_this_week);
		return rooView;
	}
	
	@Override
	public void stopAnimation(){
		//动画开启标示符设置成false   
		started=false;
		/**
		 * 清空所有控件上的动画
		 */
		ivLikeVideo.clearAnimation();
		ivThinkReward.clearAnimation();
		ivWatchMovie.clearAnimation();
		ivThisWeek.clearAnimation();
	}
	
	
	@Override
	public void startAnimation(){
		started=true;
		
		/**
		 * 每次开启动画前先隐藏控件
		 */
		ivLikeVideo.setVisibility(View.GONE);
		ivThinkReward.setVisibility(View.GONE);
		ivWatchMovie.setVisibility(View.GONE);
		ivThisWeek.setVisibility(View.GONE);
		
		new Handler().postDelayed(new Runnable() {//延时0.5秒之后开启
			@Override
			public void run(){
				if(started)
					likeVideoAnimation();
			}
		},500);
	}
	
	//第一个动画
	private void likeVideoAnimation(){
		ivLikeVideo.setVisibility(View.VISIBLE);
		
		likeAnimation = AnimationUtils.loadAnimation(getActivity(),R.anim.private_message_launcher);
		ivLikeVideo.startAnimation(likeAnimation);//开启动画
		likeAnimation.setAnimationListener(new AnimationListener(){  
            @Override  
            public void onAnimationStart(Animation animation) {}  
            @Override  
            public void onAnimationRepeat(Animation animation) {}  
            @Override  
            public void onAnimationEnd(Animation animation) {//监听动画结束
	            	if(started)
	            		thinkReward();
            }  
        }); 
	}
	
	//第二个动画
	private void thinkReward(){
		//动画效果弹出
		ivThinkReward.setVisibility(View.VISIBLE);
		thinkAnimation = AnimationUtils.loadAnimation(getActivity(),R.anim.private_message_launcher);
		ivThinkReward.startAnimation(thinkAnimation);
		thinkAnimation.setAnimationListener(new AnimationListener(){  
            @Override  
            public void onAnimationStart(Animation animation) {}  
            @Override  
            public void onAnimationRepeat(Animation animation) {}  
            @Override  
            public void onAnimationEnd(Animation animation) {
            	if(started)
            		watchMovie();
            }  
        }); 
	}
	
	//第三个动画
	private void watchMovie(){
		ivWatchMovie.setVisibility(View.VISIBLE);
		watchAnimation = AnimationUtils.loadAnimation(getActivity(),R.anim.private_message_launcher);
		ivWatchMovie.startAnimation(watchAnimation);
		watchAnimation.setAnimationListener(new AnimationListener(){  
            @Override  
            public void onAnimationStart(Animation animation) {}  
            @Override  
            public void onAnimationRepeat(Animation animation) {}  
            @Override  
            public void onAnimationEnd(Animation animation) {
            	if(started)
            		thisWeek();
            }  
        }); 
	}
	
	//第四个动画(弹出)
	private void thisWeek(){
		ivThisWeek.setVisibility(View.VISIBLE);
		thisWeekAnimation = AnimationUtils.loadAnimation(getActivity(),R.anim.private_message_launcher);  
		ivThisWeek.startAnimation(thisWeekAnimation);
	}
}

PersonManage\src\com\example\line

ContentView.java

package com.example.line;

import java.util.ArrayList;
import java.util.List;

import com.example.kakalauncher.R;
import com.example.line.Drawl.GestureCallBack;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
 * 
 * @author
 *
 */
public class ContentView extends ViewGroup {

	private int baseNum = 6;

	private int[] screenDispaly;
	
	private int d;
	/**
	 * 声明一个集合用来封装坐标集合
	 */
	private List<Point> list;
	private Context context;
	private Drawl drawl;
	
	/**
	 * 包含9个ImageView的容器,初始化
	 * @param context
	 * @param passWord 用户传入密码
	 * @param callBack 手势绘制完毕的回调
	 */
	public ContentView(Context context,String passWord,GestureCallBack callBack) {
		super(context);
		screenDispaly = ScreenUtils.getScreenDispaly(context);
		d = screenDispaly[0]/3;
		this.list = new ArrayList<Point>();
		this.context = context;
		// 添加9个图标
		addChild();
		// 初始化一个可以画线的view
		drawl = new Drawl(context, list,passWord,callBack);
	}
	
	private void addChild(){
		for (int i = 0; i < 9; i++) {
			ImageView image = new ImageView(context);
			image.setBackgroundResource(R.drawable.gesture_node_normal);
			this.addView(image);

			// 第几行
			int row = i / 3;
			// 第几列
			int col = i % 3;

			// 定义点的每个属性
			int leftX = col*d+d/baseNum;
			int topY = row*d+d/baseNum; 
			int rightX = col*d+d-d/baseNum;
			int bottomY = row*d+d-d/baseNum;
			
			Point p = new Point(leftX, rightX, topY, bottomY, image,i+1);

			this.list.add(p);
		}
	}

	
	public void setParentView(ViewGroup parent){
		// 得到屏幕的宽度
		int width = screenDispaly[0];
		LayoutParams layoutParams = new LayoutParams(width, width);
		
		this.setLayoutParams(layoutParams);
		drawl.setLayoutParams(layoutParams);

		parent.addView(drawl);
		parent.addView(this);
		
	}
	
	
	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		for (int i = 0; i < getChildCount(); i++) {
			//第几行
			int row = i/3;
			//第几列
			int col = i%3;
			View v = getChildAt(i);
			v.layout(col*d+d/baseNum, row*d+d/baseNum, col*d+d-d/baseNum, row*d+d-d/baseNum);
		}
	}
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		for (int i = 0; i < getChildCount(); i++) {
			View v = getChildAt(i);
			v.measure(widthMeasureSpec, heightMeasureSpec);
		}
	}

}

Drawl.java

package com.example.line;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;


/**
 * 
 * @author
 * 
 */
public class Drawl extends View {
	private int mov_x;// 声明起点坐标
	private int mov_y;
	private Paint paint;// 声明画笔
	private Canvas canvas;// 画布
	private Bitmap bitmap;// 位图

	private List<Point> list;// 装有各个view坐标的集合
	private List<Pair<Point, Point>> lineList;// 记录画过的线

	/**
	 * 手指当前在哪个Point内
	 */
	private Point currentPoint;
	/**
	 * 用户绘图的回调
	 */
	private GestureCallBack callBack;
	
	/**
	 * 用户当前绘制的图形密码
	 */
	private StringBuilder passWordSb;
	
	/**
	 * 用户传入的passWord
	 */
	private String passWord;

	public Drawl(Context context, List<Point> list,String passWord,GestureCallBack callBack) {
		super(context);
		paint = new Paint(Paint.DITHER_FLAG);// 创建一个画笔
		bitmap = Bitmap.createBitmap(480, 854, Bitmap.Config.ARGB_8888); // 设置位图的宽高
		canvas = new Canvas();
		canvas.setBitmap(bitmap);

		paint.setStyle(Style.STROKE);// 设置非填充
		paint.setStrokeWidth(10);// 笔宽5像素
		paint.setColor(Color.rgb(4, 115, 157));// 设置颜色
		paint.setAntiAlias(true);// 不显示锯齿

		this.list = list;
		this.lineList = new ArrayList<Pair<Point, Point>>();
		this.callBack = callBack;
		
		//初始化密码缓存
		this.passWordSb = new StringBuilder();
		this.passWord = passWord;
	}

	// 画位图
	@Override
	protected void onDraw(Canvas canvas) {
		// super.onDraw(canvas);
		canvas.drawBitmap(bitmap, 0, 0, null);
	}

	// 触摸事件
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:

			mov_x = (int) event.getX();
			mov_y = (int) event.getY();

			// 判断当前点击的位置是处于哪个点之内
			currentPoint = getPointAt(mov_x, mov_y);
			if (currentPoint != null) {
				currentPoint.setHighLighted(true);
				passWordSb.append(currentPoint.getNum());
			}
			// canvas.drawPoint(mov_x, mov_y, paint);// 画点
			invalidate();
			break;
		case MotionEvent.ACTION_MOVE:
			clearScreenAndDrawList();

			// 得到当前移动位置是处于哪个点内
			Point pointAt = getPointAt((int) event.getX(), (int) event.getY());
			//代表当前用户手指处于点与点之前
			if(currentPoint==null && pointAt == null){
				return true;
			}else{//代表用户的手指移动到了点上
				if(currentPoint == null){//先判断当前的point是不是为null
					//如果为空,那么把手指移动到的点赋值给currentPoint
					currentPoint = pointAt;
					//把currentPoint这个点设置选中为true;
					currentPoint.setHighLighted(true);
					passWordSb.append(currentPoint.getNum());
				}
			}
			
			if (pointAt == null || currentPoint.equals(pointAt)
					|| pointAt.isHighLighted()) {
				// 点击移动区域不在圆的区域 或者
				// 如果当前点击的点与当前移动到的点的位置相同
				// 那么以当前的点中心为起点,以手指移动位置为终点画线
				canvas.drawLine(currentPoint.getCenterX(),
						currentPoint.getCenterY(), event.getX(), event.getY(),
						paint);// 画线
				
				

			} else {
				// 如果当前点击的点与当前移动到的点的位置不同
				// 那么以前前点的中心为起点,以手移动到的点的位置画线
				canvas.drawLine(currentPoint.getCenterX(),
						currentPoint.getCenterY(), pointAt.getCenterX(),
						pointAt.getCenterY(), paint);// 画线

				pointAt.setHighLighted(true);
				
				Pair<Point, Point> pair = new Pair<Point, Point>(currentPoint,
						pointAt);
				lineList.add(pair);

				// 赋值当前的point;
				currentPoint = pointAt;
				passWordSb.append(currentPoint.getNum());
			}
			invalidate();
			break;
		case MotionEvent.ACTION_UP:// 当手指抬起的时候
			// 清掉屏幕上所有的线,只画上集合里面保存的线
			if(passWord.equals(passWordSb.toString())){
				//代表用户绘制的密码手势与传入的密码相同
				callBack.checkedSuccess();
			}else{
				//用户绘制的密码与传入的密码不同。
				callBack.checkedFail();
			}
			//重置passWordSb
			passWordSb = new StringBuilder();
			//清空保存点的集合
			lineList.clear();
			//重新绘制界面
			clearScreenAndDrawList();
			for (Point p : list) {
				p.setHighLighted(false);
			}
			invalidate();
			break;
		default:
			break;
		}
		return true;
	}

	/**
	 * 通过点的位置去集合里面查找这个点是包含在哪个Point里面的
	 * 
	 * @param x
	 * @param y
	 * @return 如果没有找到,则返回null,代表用户当前移动的地方属于点与点之间
	 */
	private Point getPointAt(int x, int y) {

		for (Point point : list) {
			// 先判断x
			int leftX = point.getLeftX();
			int rightX = point.getRightX();
			if (!(x >= leftX && x < rightX)) {
				// 如果为假,则跳到下一个对比
				continue;
			}

			int topY = point.getTopY();
			int bottomY = point.getBottomY();
			if (!(y >= topY && y < bottomY)) {
				// 如果为假,则跳到下一个对比
				continue;
			}

			// 如果执行到这,那么说明当前点击的点的位置在遍历到点的位置这个地方
			return point;
		}

		return null;
	}

	/**
	 * 清掉屏幕上所有的线,然后画出集合里面的线
	 */
	private void clearScreenAndDrawList() {
		canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
		for (Pair<Point, Point> pair : lineList) {
			canvas.drawLine(pair.first.getCenterX(), pair.first.getCenterY(),
					pair.second.getCenterX(), pair.second.getCenterY(), paint);// 画线
		}
	}
	
	public interface GestureCallBack{
		
		/**
		 * 代表用户绘制的密码与传入的密码相同
		 */
		public abstract void checkedSuccess();
		/**
		 * 代表用户绘制的密码与传入的密码不相同
		 */
		public abstract void checkedFail();
	}

}

LineActivity.java

package com.example.line;

import com.example.kakalauncher.R;
import com.example.line.Drawl.GestureCallBack;
import com.example.user.MainframeActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.Toast;
/**
 * 
 * @author
 * 
 */
public class LineActivity extends Activity {

	private FrameLayout body_layout;
	private ContentView content;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		//隐藏标题栏,运营商图标和电量等
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
				
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_line);
		body_layout = (FrameLayout) findViewById(R.id.body_layout);


		// 初始化一个显示各个点的viewGroup
		content = new ContentView(this, "159",new GestureCallBack() {

			@Override
			public void checkedSuccess() {
				Toast.makeText(LineActivity.this,"校验成功", Toast.LENGTH_SHORT).show();
				Intent intent = new Intent();
				intent.setClass(LineActivity.this, MainframeActivity.class);
//				intent.setClass(LineActivity.this, MainActivity.class);
				Toast.makeText(LineActivity.this, "欢迎回来!", Toast.LENGTH_LONG).show();
				startActivity(intent);
			}

			@Override
			public void checkedFail() {
				Toast.makeText(LineActivity.this,"校验失败", Toast.LENGTH_SHORT).show();
			}
		});
		//设置手势解锁显示到哪个布局里面
		content.setParentView(body_layout);
	}

}

Point.java

package com.example.line;

import com.example.kakalauncher.R;

import android.widget.ImageView;


/**
 * 
 * @author 
 *
 */
public class Point {
	
	private int leftX;
	
	private int rightX;
	
	private int topY;
	
	private int bottomY;
	
	private ImageView image;

	private int centerX;

	private int centerY;

	private boolean highLighted;

	private int num;

	public Point(int leftX, int rightX, int topY, int bottomY, ImageView image,int num) {
		super();
		this.leftX = leftX;
		this.rightX = rightX;
		this.topY = topY;
		this.bottomY = bottomY;
		this.image = image;

		this.centerX = (leftX + rightX) / 2;
		this.centerY = (topY + bottomY) / 2;
		
		this.num = num;
	}

	public int getLeftX() {
		return leftX;
	}

	public void setLeftX(int leftX) {
		this.leftX = leftX;
	}

	public int getRightX() {
		return rightX;
	}

	public void setRightX(int rightX) {
		this.rightX = rightX;
	}

	public int getTopY() {
		return topY;
	}

	public void setTopY(int topY) {
		this.topY = topY;
	}

	public int getBottomY() {
		return bottomY;
	}

	public void setBottomY(int bottomY) {
		this.bottomY = bottomY;
	}

	public ImageView getImage() {
		return image;
	}

	public void setImage(ImageView image) {
		this.image = image;
	}

	public int getCenterX() {
		return centerX;
	}

	public void setCenterX(int centerX) {
		this.centerX = centerX;
	}

	public int getCenterY() {
		return centerY;
	}

	public void setCenterY(int centerY) {
		this.centerY = centerY;
	}

	public boolean isHighLighted() {
		return highLighted;
	}

	public void setHighLighted(boolean highLighted) {
		this.highLighted = highLighted;
		if (highLighted) {
			this.image
					.setBackgroundResource(R.drawable.gesture_node_highlighted);
		} else {
			this.image.setBackgroundResource(R.drawable.gesture_node_normal);
		}
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + bottomY;
		result = prime * result + ((image == null) ? 0 : image.hashCode());
		result = prime * result + leftX;
		result = prime * result + rightX;
		result = prime * result + topY;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Point other = (Point) obj;
		if (bottomY != other.bottomY)
			return false;
		if (image == null) {
			if (other.image != null)
				return false;
		} else if (!image.equals(other.image))
			return false;
		if (leftX != other.leftX)
			return false;
		if (rightX != other.rightX)
			return false;
		if (topY != other.topY)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Point [leftX=" + leftX + ", rightX=" + rightX + ", topY="
				+ topY + ", bottomY=" + bottomY + "]";
	}
}

ScreenUtils.java

package com.example.line;

import android.content.Context;
import android.view.WindowManager;

public class ScreenUtils {

	@SuppressWarnings("deprecation")
	public static int[] getScreenDispaly(Context context){
		WindowManager wm=(WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
		//设置手势解锁的长和宽
		int width=wm.getDefaultDisplay().getWidth();
		int height=wm.getDefaultDisplay().getHeight();
		int result[] = {width,height};
		//返回一个结果
		return result;
	}
}

PersonManage\src\com\example\login

BeforeLoginActivity.java

package com.example.login;

import java.util.ArrayList;
import java.util.List;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.adapter.BaseFragmentAdapter;
import com.example.fragment.LauncherBaseFragment;
import com.example.fragment.LastBegin;
import com.example.fragment.PersonBegin;
import com.example.fragment.MoneyFragment;
import com.example.kakalauncher.R;
import com.example.view.GuideViewPager;
//设置启动界面的三个动画
public class BeforeLoginActivity extends FragmentActivity {
	private GuideViewPager vPager;
	private List<LauncherBaseFragment> list = new ArrayList<LauncherBaseFragment>();
	private BaseFragmentAdapter adapter;
	//私有化图片
	private ImageView[] tips;
	private int currentSelect; 
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_luancher_main);
		
		//初始化点点点控件
		ViewGroup group = (ViewGroup)findViewById(R.id.viewGroup);
		tips = new ImageView[3];
		for (int i = 0; i < tips.length; i++) {
			//定义图片视图
			ImageView imageView = new ImageView(this);
			imageView.setLayoutParams(new LayoutParams(10, 10));
			if (i == 0) {
				imageView.setBackgroundResource(R.drawable.page_indicator_focused);
			} else {
				imageView.setBackgroundResource(R.drawable.page_indicator_unfocused);
			}
			tips[i]=imageView;

			LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
			layoutParams.leftMargin = 20;//设置点点点view的左边距
			layoutParams.rightMargin = 20;//设置点点点view的右边距
			group.addView(imageView,layoutParams);
		}
		
		//获取自定义viewpager 然后设置背景图片
		vPager = (GuideViewPager) findViewById(R.id.viewpager_launcher);
		vPager.setBackGroud(BitmapFactory.decodeResource(getResources(),R.drawable.bg_kaka_launcher));

		/**
		 * 初始化三个fragment  并且添加到list中
		 */
		MoneyFragment rewardFragment = new MoneyFragment();
		LastBegin privateFragment = new LastBegin();
		PersonBegin personbegin=new PersonBegin();
		//将三个动画界面添加到主界面中显示动画
		list.add(rewardFragment);//抛硬币
		//添加中间页面
		list.add(personbegin);
		//启动界面,跳转到登录
		list.add(privateFragment);

		adapter = new BaseFragmentAdapter(getSupportFragmentManager(),list);
		vPager.setAdapter(adapter);
		vPager.setOffscreenPageLimit(2);
		vPager.setCurrentItem(0);
		vPager.setOnPageChangeListener(changeListener);
	}
	
	/**
	 * 监听viewpager的移动
	 */
	OnPageChangeListener changeListener=new OnPageChangeListener() {
		@Override
		public void onPageSelected(int index) {
			setImageBackground(index);//改变点点点的切换效果
			LauncherBaseFragment fragment=list.get(index);
			
			list.get(currentSelect).stopAnimation();//停止前一个页面的动画
			fragment.startAnimation();//开启当前页面的动画
			
			currentSelect=index;
		}
		
		@Override
		public void onPageScrolled(int arg0, float arg1, int arg2) {}
		@Override
		public void onPageScrollStateChanged(int arg0) {}
	};
	
	/**
	 * 改变点点点的切换效果
	 * @param selectItems
	 */
	private void setImageBackground(int selectItems) {
		for (int i = 0; i < tips.length; i++) {
			if (i == selectItems) {
				tips[i].setBackgroundResource(R.drawable.page_indicator_focused);
			} else {
				tips[i].setBackgroundResource(R.drawable.page_indicator_unfocused);
			}
		}
	}
}

LoginActivity.java

package com.example.login;

import com.example.kakalauncher.R;
import com.example.line.LineActivity;
import com.example.manage.ManagerActivity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends Activity {
	public static String USER=null;
	// 帐号和密码
	private EditText edname;
	private EditText edpassword;

	private Button btregister;
	private Button btlogin;
	private CheckBox cb;
	// 创建SQLite数据库
	public static SQLiteDatabase db;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		//隐藏标题栏,运营商图标和电量等
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		edname = (EditText) findViewById(R.id.edname);
		edpassword = (EditText) findViewById(R.id.edpassword);
		btregister = (Button) findViewById(R.id.btregister);
		btlogin = (Button) findViewById(R.id.btlogin);
		cb=(CheckBox)findViewById(R.id.xianshifou);
		
		//为隐藏密码注册监听
	       cb.setOnCheckedChangeListener(new OnCheckedChangeListener(){

				@Override
				public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
					// TODO Auto-generated method stub
					if(cb.isChecked()){
			               //设置EditText的密码为可见的
			            	edpassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
			            }else{
			               //设置密码为隐藏的
			            	edpassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
			            }
				}
	         
	       });
	      
		db = SQLiteDatabase.openOrCreateDatabase(LoginActivity.this.getFilesDir().toString()+ "/test.dbs", null);
		// 跳转到注册界面
		btregister.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(LoginActivity.this, RegistersActivity.class);
				startActivity(intent);
			}
		});
		
		btlogin.setOnClickListener(new LoginListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				try{
					Toast.makeText(LoginActivity.this, "正在登录,请稍等.....", Toast.LENGTH_LONG).show();
					Thread.sleep(3000);
				} 
				catch (InterruptedException e) {
					e.printStackTrace();
				}
				Intent intent = new Intent();
				intent.setClass(LoginActivity.this, LineActivity.class);
				//Toast.makeText(LoginActivity.this, "欢迎回来!", Toast.LENGTH_LONG).show();
				startActivity(intent);
			}
		});
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		db.close();
	}
	//为进入到管理员界面的图片创建监听,实现页面的跳转
	public void manager(View view){
		Intent intent=new Intent();
		intent.setClass(LoginActivity.this, ManagerActivity.class);
		startActivity(intent);
	}

	class LoginListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String name = edname.getText().toString();
			String password = edpassword.getText().toString();
			if (name.equals("") || password.equals("")) {
				// 弹出消息框
				new AlertDialog.Builder(LoginActivity.this).setTitle("错误").setMessage("帐号或密码不能空").setPositiveButton("确定", null).show();
			} else {
				isUserinfo(name, password);
			}
		}

		// 判断输入的用户是否正确
		public Boolean isUserinfo(String name, String pwd) {
			try{
				String str="select * from tb_user where name=? and password=?";
				Cursor cursor = db.rawQuery(str, new String []{name,pwd});
				if(cursor.getCount()<=0){
					new AlertDialog.Builder(LoginActivity.this).setTitle("错误").setMessage("帐号或密码错误!").setPositiveButton("确定", null).show();
					return false;
				}else{
					new AlertDialog.Builder(LoginActivity.this).setTitle("正确").setMessage("成功登录").setPositiveButton("确定", null).show();
					return true;
				}
				
			}catch(SQLiteException e){
				createDb();
			}
			return false;
		}
	
	}
	// 创建数据库和用户表
	public void createDb() {
		db.execSQL("create table tb_user( name varchar(30) primary key,password varchar(30))");
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}

RegistersActivity.java

package com.example.login;

import com.example.kakalauncher.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class RegistersActivity extends Activity {

	private EditText edname1;
	private EditText edpassword1;
	private Button btregister1;
	SQLiteDatabase db;

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		db.close();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		//隐藏标题栏,运营商图标和电量等
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
				
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_register);
		edname1 = (EditText) findViewById(R.id.edname1);
		edpassword1 = (EditText) findViewById(R.id.edpassword1);
		btregister1 = (Button) findViewById(R.id.btregister1);
		btregister1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				final String name = edname1.getText().toString();
				final String password = edpassword1.getText().toString();
				if (!(name.equals("") && password.equals(""))) {
					if (addUser(name, password)) {
						DialogInterface.OnClickListener ss = new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog,
									int which) {
								// TODO Auto-generated method stub
								if(edname1.getText().equals(name)||edpassword1.getText().equals(password)){
									// 跳转到登录界面
									Intent in = new Intent();
									in.setClass(RegistersActivity.this,LoginActivity.class);
									startActivity(in);
									// 销毁当前activity
									RegistersActivity.this.onDestroy();
								}
								
								
							}
						};
						new AlertDialog.Builder(RegistersActivity.this)
								.setTitle("注册成功").setMessage("注册成功")
								.setPositiveButton("确定", ss).show();

					} else {
						new AlertDialog.Builder(RegistersActivity.this).setTitle("注册失败").setMessage("注册失败").setPositiveButton("确定", null);
					}
				} else {
					new AlertDialog.Builder(RegistersActivity.this).setTitle("帐号密码不能为空").setMessage("帐号密码不能为空").setPositiveButton("确定", null);
				}

			}
		});

	}

	// 添加用户
	public Boolean addUser(String name, String password) {
		String str = "insert into tb_user values(?,?) ";
		LoginActivity main = new LoginActivity();
		db = SQLiteDatabase.openOrCreateDatabase(this.getFilesDir().toString()+ "/test.dbs", null);
		LoginActivity.db = db;
		try {
			db.execSQL(str, new String[] { name, password });
			return true;
		} catch (Exception e) {
			main.createDb();
		}
		return false;
	}

}

PersonManage\src\com\example\manage

ManagerActivity.java

package com.example.manage;

import com.example.kakalauncher.R;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ManagerActivity extends Activity {


	// 帐号和密码
	private EditText edname;
	private EditText edpassword;
	private Button btlogin;
	private Button btregister;
	// 创建SQLite数据库
	public static SQLiteDatabase db1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		//隐藏标题栏,运营商图标和电量等
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
				
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_manager);
		edname = (EditText) findViewById(R.id.userName);
		edpassword = (EditText) findViewById(R.id.passwd);
		btlogin = (Button) findViewById(R.id.bnLogin);
		btregister = (Button) findViewById(R.id.bnregister);
		db1 = SQLiteDatabase.openOrCreateDatabase(ManagerActivity.this.getFilesDir().toString()+ "/manager.dbs", null);
		
		// 跳转到注册界面
		btregister.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(ManagerActivity.this, ManageregisterActivity.class);
				startActivity(intent);
			}
		});
		btlogin.setOnClickListener(new LoginListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(ManagerActivity.this, ManagermainActivity.class);
				startActivity(intent);
			}
		});
		
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		db1.close();
	}
	
	class LoginListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			String name = edname.getText().toString();
			String password = edpassword.getText().toString();
			if (name.equals("") || password.equals("")) {
				// 弹出消息框
				new AlertDialog.Builder(ManagerActivity.this).setTitle("错误").setMessage("帐号或密码不能空").setPositiveButton("确定", null).show();
			} else {
				isUserinfo(name, password);
			}
		}

		// 判断输入的管理员是否正确
		public Boolean isUserinfo(String name, String pwd) {
			try{
				String str="select * from tb_manager where name=? and password=?";
				Cursor cursor = db1.rawQuery(str, new String []{name,pwd});
				if(cursor.getCount()<=0){
					new AlertDialog.Builder(ManagerActivity.this).setTitle(
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蹦跶的小羊羔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值