diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/AndroidManifest.xml b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/AndroidManifest.xml new file mode 100644 index 00000000..66e39744 --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/Net1314080903115LoginActivity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/Net1314080903115LoginActivity.java new file mode 100644 index 00000000..cfc163aa --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/Net1314080903115LoginActivity.java @@ -0,0 +1,132 @@ +package edu.hzuapps.androidworks.homeworks.net1314080903115; + + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.view.View; +import android.view.Window; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import com.google.android.gms.appindexing.Action; +import com.google.android.gms.appindexing.AppIndex; +import com.google.android.gms.common.api.GoogleApiClient; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.util.EntityUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import edu.hzuapps.androidworks.R; + + +public class Net1314080903115LoginActivity extends Activity implements View.OnClickListener { + + private EditText login_Phone, login_PassWord; + private Button login_Login, login_SignUp; + /** + * ATTENTION: This was auto-generated to implement the App Indexing API. + * See https://g.co/AppIndexing/AndroidStudio for more information. + */ + private GoogleApiClient client; + + @Override + protected void onCreate(Bundle savedInstanceState) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + super.onCreate(savedInstanceState); + setContentView(R.layout.net1314080903115login); + + login_Phone = (EditText) findViewById(R.id.login_Phone); + login_PassWord = (EditText) findViewById(R.id.login_PassWord); + login_Login = (Button) findViewById(R.id.login_Login); + login_Login.setOnClickListener(this); + login_SignUp = (Button) findViewById(R.id.login_SignUp); + login_SignUp.setOnClickListener(this); + // ATTENTION: This was auto-generated to implement the App Indexing API. + // See https://g.co/AppIndexing/AndroidStudio for more information. + client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); + } + + public void onClick(View v) { + + if (v.getId() == R.id.login_Login) { + + final String phont = login_Phone.getText().toString(); + final String password = login_PassWord.getText().toString(); + + new Thread(new Runnable() { + @Override + public void run() { + try { + HttpGet httpGet = new HttpGet("http://lyongsb.cn:81/CloudNotes.asmx/Login?Phone=" + phont + "&PassWord=" + password);//编者按:与HttpPost区别所在,这里是将参数在地址中传递 + HttpResponse response = new DefaultHttpClient().execute(httpGet); + if (response.getStatusLine().getStatusCode() == 200) { + HttpEntity entity = response.getEntity(); + String json3 = EntityUtils.toString(entity);//这里取得的是带xml头的字符串 + String json2 = json3.substring(json3.indexOf("{"), json3.indexOf("}") + 1);//去掉头和尾取得中间的json字符串 + Message msg = Message.obtain(); + msg.obj = json2; + handler.sendMessage(msg); + } + } catch (IOException e) { + } + } + }).start(); + + } + + if (v.getId() == R.id.login_Login) { + + } + + } + + public JSONObject getJSON(String json) { + JSONObject jsonObject=null; + try { + jsonObject = new JSONObject(json); + }catch (JSONException e){ + + } + return jsonObject; + } + + public Handler handler = new Handler() { + @Override + public void handleMessage(Message msg) { + String json = (String) msg.obj; + JSONObject jsonObject = getJSON(json); + + String state = "0"; + String NoteTable=""; + try { + state = jsonObject.getString("state"); + NoteTable = jsonObject.getString("content"); + if (state.equals("1")) { + Net1314080903115MainActivity.Account.State = 2; + Net1314080903115MainActivity.Account.UserName = "黎振锋"; + Intent intent = new Intent(Net1314080903115LoginActivity.this, Net1314080903115MainActivity.class); + startActivity(intent); + } else { + Toast.makeText(Net1314080903115LoginActivity.this, NoteTable, Toast.LENGTH_LONG).show(); + } + } catch (JSONException e) { + e.printStackTrace(); + } + + } + }; +} \ No newline at end of file diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/Net1314080903115MainActivity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/Net1314080903115MainActivity.java new file mode 100644 index 00000000..3f69f69f --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/Net1314080903115MainActivity.java @@ -0,0 +1,235 @@ +package edu.hzuapps.androidworks.homeworks.net1314080903115; + +import android.app.Activity; +import android.content.Intent; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Message; +import android.provider.MediaStore; +import android.view.View; +import android.view.Window; +import android.widget.Button; +import android.widget.ImageButton; +import android.widget.ImageSwitcher; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.util.EntityUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import edu.hzuapps.androidworks.R; +import edu.hzuapps.androidworks.homeworks.net1314080903115.db.Net1314080903115_Account; +import edu.hzuapps.androidworks.homeworks.net1314080903115.db.Net1314080903115_Constant; +import edu.hzuapps.androidworks.homeworks.net1314080903115.db.Net1314080903115_MySQLiteOpenHelper; +import edu.hzuapps.androidworks.homeworks.net1314080903115.view.Net1314080903115_MySlidingMenuView; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.util.EntityUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +public class Net1314080903115MainActivity extends Activity implements View.OnClickListener { + + private Net1314080903115_MySlidingMenuView slidingMenu; + private ImageButton main_portrait; + private Net1314080903115_MySQLiteOpenHelper helper; + public static Net1314080903115_Account Account=new Net1314080903115_Account(); + private ImageView imageview; + private Button zhaoxiang; + + private Uri OutImageUri = Uri.parse("file://" + + Environment.getExternalStorageDirectory() + "/lzf.jpg"); + //public static Activity THIS2; + private TextView name_text1, name_text2; + + public Handler handler = new Handler(){ + @Override + public void handleMessage(Message msg) { + String json=(String)msg.obj; + List listjsonObject = getJSON(json); + JSONObject j = listjsonObject.get(0); + String state = null; + String NoteTable; + try { + state = j.getString("state"); + NoteTable = j.getString("content"); + } catch (JSONException e) { + e.printStackTrace(); + } + if(state.equals("1")) + {//登录成功 + Account.State=2; + name_text1.setText(Account.UserName); + name_text2.setText(Account.UserName); + }else{//登录失败 + Account.State=0; + name_text1.setText("请登录"); + name_text2.setText("请登录"); + } + + } + }; + + @Override + protected void onCreate(Bundle savedInstanceState) { + requestWindowFeature(Window.FEATURE_NO_TITLE); + super.onCreate(savedInstanceState); + //requestWindowFeature(Window.FEATURE_NO_TITLE); + setContentView(R.layout.net1314080903115main); + + + slidingMenu = (Net1314080903115_MySlidingMenuView) findViewById(R.id.sliding_menu); + slidingMenu.setlSlidingMenuState(Net1314080903115_MySlidingMenuView.SLIDING_MENU_COVER); + + main_portrait = (ImageButton) findViewById(R.id.main_portrait); + main_portrait.setOnClickListener(this); + + //http = new Net1314080903115_HTTP(); + + name_text1 = (TextView) findViewById(R.id.name_text1); + name_text2 = (TextView) findViewById(R.id.name_text2); + imageview = (ImageView) findViewById(R.id.imageview); + zhaoxiang = (Button)findViewById(R.id.zhaoxiang); + zhaoxiang.setOnClickListener(this); + + helper = new Net1314080903115_MySQLiteOpenHelper(this); + Login(); + if (Account.State == 0) { + name_text1.setText("请登录"); + name_text2.setText("请登录"); + } else if (Account.State == 1) { + new Thread(new Runnable() { + @Override + public void run() { + try { + HttpGet httpGet = new HttpGet("http://lyongsb.cn:81/CloudNotes.asmx/Login?Phone=" + Account.Phone + "&PassWord=" + Account.PassWord);//编者按:与HttpPost区别所在,这里是将参数在地址中传递 + HttpResponse response = new DefaultHttpClient().execute(httpGet); + if (response.getStatusLine().getStatusCode() == 200) { + HttpEntity entity = response.getEntity(); + String json3 = EntityUtils.toString(entity);//这里取得的是带xml头的字符串 + String json2 = json3.substring(json3.indexOf("{"), json3.indexOf("}") + 1);//去掉头和尾取得中间的json字符串 + Message msg = Message.obtain(); + msg.obj = json2; + handler.sendMessage(msg); + } + } catch (IOException e) { + } + } + }).start(); + } else if (Account.State == 2) { + name_text1.setText(Account.UserName); + name_text2.setText(Account.UserName); + } + } + + public void onClick(View v) { + + + if (v.getId() == R.id.zhaoxiang) { + + Uri OutImageUri = Uri.parse("file://" + + Environment.getExternalStorageDirectory() +"/lzf.jpg"); + Intent intent; + intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + intent.putExtra("return-data", false);// 是否返回数据 + // 部分手机,不返回数据才能直接输出文件 + intent.putExtra(MediaStore.EXTRA_OUTPUT, OutImageUri);// 直接输出文件 + startActivityForResult(intent, 0); + + } + + + if (v.getId() == R.id.main_portrait) { + if(Account.State == 2) + { + //跳转登录 + }else{ + Intent intent = new Intent(Net1314080903115MainActivity.this, Net1314080903115LoginActivity.class); + startActivity(intent); + } + + } + } + + private void Login() { + SQLiteDatabase db = helper.getReadableDatabase(); + Cursor cursor = db.rawQuery("select * from " + Net1314080903115_Constant.TABLE_Account + + " where ID=?", new String[]{"1"}); + if (cursor != null) { + if (cursor.moveToFirst()) { + Account.ID = cursor.getInt(cursor + .getColumnIndex(Net1314080903115_Constant.Account_ID)); + Account.Phone = cursor.getString(cursor + .getColumnIndex(Net1314080903115_Constant.Account_Phone)); + Account.PassWord = cursor.getString(cursor + .getColumnIndex(Net1314080903115_Constant.Account_PassWord)); + Account.UserName = cursor.getString(cursor + .getColumnIndex(Net1314080903115_Constant.Account_UserName)); + Account.HeadPortrait = cursor.getString(cursor + .getColumnIndex(Net1314080903115_Constant.Account_HeadPortrait)); + Account.NoteTable = cursor.getString(cursor + .getColumnIndex(Net1314080903115_Constant.Account_NoteTable)); + } else { + //Toast.makeText(this, "没有用户数据", Toast.LENGTH_LONG).show(); + } + cursor.close(); + } + db.close(); + } + + public List getJSON(String json) { + List listjsonObject = new ArrayList(); + try { + JSONArray jsonArray = new JSONArray(json); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = (JSONObject) jsonArray.opt(i); + listjsonObject.add(jsonObject); + } + } catch (JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return listjsonObject; + } + + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (resultCode != Activity.RESULT_OK) { + return; + } else { + switch (requestCode) { + case 0:// 拍照完回调这里 + + String fileName = + Environment.getExternalStorageDirectory() + "/temp.jpg"; + Bitmap bm = BitmapFactory.decodeFile(fileName); + imageview.setImageBitmap(bm); + break; + default: + break; + } + } + } +} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Account.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Account.java new file mode 100644 index 00000000..462457f1 --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Account.java @@ -0,0 +1,15 @@ +package edu.hzuapps.androidworks.homeworks.net1314080903115.db; + +/** + * Created by lzf on 2016/6/14. + */ +public class Net1314080903115_Account { + + public int State=0;//0数据库里没数据,1有数据,还没通过网络验证,2通过网络验证 + public int ID; + public String Phone; + public String PassWord; + public String UserName; + public String HeadPortrait; + public String NoteTable; +} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Constant.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Constant.java new file mode 100644 index 00000000..b0674767 --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_Constant.java @@ -0,0 +1,24 @@ +package edu.hzuapps.androidworks.homeworks.net1314080903115.db; + +public class Net1314080903115_Constant { + // 数据库名称 + public static final String DATABASE_NAME = "CloudNotes.db"; + + // 数据库中各表名 + public static final String TABLE_Account = "Account"; + + // Account表 + public static final String Account_ID = "ID"; + public static final String Account_Phone = "Phone"; + public static final String Account_PassWord = "PassWord"; + public static final String Account_UserName = "UserName"; + public static final String Account_HeadPortrait = "HeadPortrait"; + public static final String Account_NoteTable = "NoteTable"; + + // 笔记表 + public static final String NoteTable_ID = "ID"; + public static final String NoteTable_Title = "Title"; + public static final String NoteTable_Text = "Text"; + public static final String NoteTable_Edition = "Edition"; + public static final String NoteTable_Date = "Date"; +} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_MySQLiteOpenHelper.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_MySQLiteOpenHelper.java new file mode 100644 index 00000000..450680d8 --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/Net1314080903115_MySQLiteOpenHelper.java @@ -0,0 +1,33 @@ +package edu.hzuapps.androidworks.homeworks.net1314080903115.db; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +public class Net1314080903115_MySQLiteOpenHelper extends SQLiteOpenHelper { + /* + * 创建数据库 + */ + public Net1314080903115_MySQLiteOpenHelper(Context context) { + super(context, Net1314080903115_Constant.DATABASE_NAME, null, 1); + } + + // 初始化表 + @Override + public void onCreate(SQLiteDatabase db) { + // 创建用户表 + db.execSQL("create table " + Net1314080903115_Constant.TABLE_Account + "(" + + Net1314080903115_Constant.Account_ID + " integer primary key not null," + + Net1314080903115_Constant.Account_Phone+ " text not null," + + Net1314080903115_Constant.Account_PassWord+ " text not null," + + Net1314080903115_Constant.Account_UserName + " text not null," + + Net1314080903115_Constant.Account_HeadPortrait + " text, " + + Net1314080903115_Constant.Account_NoteTable + " text not null);"); + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + + } + +} diff --git "a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/\346\225\260\346\215\256\345\272\223\346\226\207\344\273\266.txt" "b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/\346\225\260\346\215\256\345\272\223\346\226\207\344\273\266.txt" new file mode 100644 index 00000000..9e1ba446 --- /dev/null +++ "b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/db/\346\225\260\346\215\256\345\272\223\346\226\207\344\273\266.txt" @@ -0,0 +1 @@ +数据库相关的文件保存在这里 diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/view/Net1314080903115_MySlidingMenuView.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/view/Net1314080903115_MySlidingMenuView.java new file mode 100644 index 00000000..b2002c07 --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/view/Net1314080903115_MySlidingMenuView.java @@ -0,0 +1,250 @@ +package edu.hzuapps.androidworks.homeworks.net1314080903115.view; + + +import edu.hzuapps.androidworks.homeworks.net1314080903115.Net1314080903115MainActivity; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.Toast; + +/** + * @author LDM + * @fileName MySlidingMenuView.java + * @date 2012-12-20 下午1:51:49 + * 侧滑分类菜单 + */ +public class Net1314080903115_MySlidingMenuView extends ViewGroup { + + private float lTouchX;// touch操作被触发时记录当前X坐标 + private float lLastDownX;//最后一次按下的坐标值 + private float lTouchSlop = 25;//滑动时产生粘性效果 + private int LEFT_VIEW_WIDTH = 0;//菜单宽度 + private boolean LEFT_VIEW_STATE;//菜单状态 true显示 + + private int lSlidingMenuState;//菜单状态,平铺式出或覆盖式 + + private boolean PULL_DIRECTION;// true向右拉动 false向左拉动 + // 拉动比率 :当view已经被拉过边缘时,操作没有停止,VIEW的跟随减慢的比率 + private double PULL_RATIO = 0.5; + + private boolean enter = true;// 是否可以进入验证,手指离开屏幕时使用 + + /** + * 默认平铺样式 + */ + public static final int SLIDING_MENU_TILE = 0; + + /** + * 覆盖式样式 + */ + public static final int SLIDING_MENU_COVER = 1; + + public Net1314080903115_MySlidingMenuView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(context); + } + + public Net1314080903115_MySlidingMenuView(Context context, AttributeSet attrs) { + super(context, attrs); + init(context); + } + + public Net1314080903115_MySlidingMenuView(Context context) { + super(context); + init(context); + } + + void init(Context context) + { + postDelayed(new Runnable() { + @Override + public void run() { + LEFT_VIEW_WIDTH = getChildAt(0).getWidth(); + scrollTo(LEFT_VIEW_WIDTH, 0); + if(lSlidingMenuState == SLIDING_MENU_COVER){ + /*隐藏并保留菜单空间,如果不隐藏则会执行平滑拉出操作 */ + getChildAt(0).setVisibility(View.INVISIBLE); + } + } + }, 50); + } + + @Override + public void scrollTo(int x, int y) + { + super.scrollTo(x, y); + postInvalidate(); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) + { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + final View child1 = getChildAt(0); + child1.measure(child1.getLayoutParams().width + child1.getLeft() + child1.getRight(), heightMeasureSpec); + + final View child2 = getChildAt(1); + child2.measure(widthMeasureSpec, heightMeasureSpec); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) + { + int childLeft = 0; + + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View child = getChildAt(i); + if (child.getVisibility() != View.GONE) { + final int childWidth = child.getMeasuredWidth(); + child.layout(childLeft, 0, childLeft + childWidth, child.getMeasuredHeight()); + childLeft += childWidth; + } + } + } + + /* + * 当屏幕被按下时会调用方法 + * 参数MotionEvent封装了触屏事件的所有信息 + * */ + @Override + public boolean onTouchEvent(MotionEvent event) { + switch (event.getAction()) + {//触摸的状态 + case MotionEvent.ACTION_UP://屏幕被抬起 + + + int offux = getScrollX();// 默认不移动 + + // 向左拉动超过边缘 + if (getScrollX() < 0) { + offux = 0; + } + // 向右拉动超过边缘 + if (enter && getScrollX() > LEFT_VIEW_WIDTH) { + offux = LEFT_VIEW_WIDTH; + enter = !enter; + } + + // 边缘内左右拉动 + if (enter && PULL_DIRECTION) { + if ((LEFT_VIEW_WIDTH - getScrollX()) >= LEFT_VIEW_WIDTH / 3) {// 可以展开第一页面 + offux = 0; + } else {// 拉动距离不够,回到第二界面 + offux = LEFT_VIEW_WIDTH; + } + enter = !enter; + } + + // 边缘内向左拉动 + if (enter && !PULL_DIRECTION) { + if (getScrollX() >= LEFT_VIEW_WIDTH / 3) { + offux = LEFT_VIEW_WIDTH; + } else { + offux = 0; + } + } + scrollTo(offux, 0);// 根据上面的计算执行得出的最终结果 + if(lSlidingMenuState == SLIDING_MENU_COVER){ + if(offux == 0){ + LEFT_VIEW_STATE = true; + getChildAt(0).setVisibility(View.VISIBLE); + } + if(offux == LEFT_VIEW_WIDTH){ + LEFT_VIEW_STATE = false; + getChildAt(0).setVisibility(View.INVISIBLE); + } + } + enter = true;// 每次使用完还原状态 + + + break; + case MotionEvent.ACTION_DOWN://屏幕被按下 + lTouchX = event.getX();//记录touch操作被触发时记录当前X坐标 + lLastDownX = event.getX();//记录最后一次按下的x坐标值 + break; + case MotionEvent.ACTION_MOVE://在屏幕中拖动 + if (lLastDownX > lTouchSlop) + { + //如果滑动时菜单项为显示状态,将其隐藏 + if(LEFT_VIEW_STATE) + { + getChildAt(0).setVisibility(View.INVISIBLE);//可见性设为不可见 + } + int offx = 0;// 此次移动的偏移量 + // 计算拉动是否超出边缘 + if ((getScrollX() + (int) (lTouchX - event.getX()) < 0)//getScrollX() 就是当前view的左上角相对于母视图的左上角的X轴偏移量 + || (getScrollX() + (int) (lTouchX - event.getX()) > LEFT_VIEW_WIDTH)) + {// VIEW已经被拉过边缘 + offx = (int) ((lTouchX - event.getX()) * PULL_RATIO); + } + else + {// VIEW处于边缘内 + offx = (int) (lTouchX - event.getX()); + scrollBy(offx, 0); + } + + // 根据本次的移动距离计算用户的方向,PULL_DIRECTION 取值true向右拉动 false向左拉动 + PULL_DIRECTION = lTouchX == event.getX() ? PULL_DIRECTION : lTouchX < event.getX(); + + + + lTouchX = event.getX(); + } + break; + default: + break; + } + return true; + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return super.onInterceptTouchEvent(ev); + } + + void enableChildrenCache() { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View layout = (View) getChildAt(i); + layout.setDrawingCacheEnabled(true); + } + } + + void clearChildrenCache() { + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + final View layout = (View) getChildAt(i); + layout.setDrawingCacheEnabled(false); + } + } + + + + /** + * 获取当前菜单使用的样式CODE + * @return + */ + public int getlSlidingMenuState() { + return lSlidingMenuState; + } + + /** + * 设置菜单的出现样式。取值范围:MySlidingMenuView.SLIDING_MENU_TILE(default) or MySlidingMenuView.SLIDING_MENU_COVER + * @param lSlidingMenuState + */ + public void setlSlidingMenuState(int lSlidingMenuState) { + this.lSlidingMenuState = lSlidingMenuState; + } + + public void MenuButton() + { + + } + +} diff --git "a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/view/\350\207\252\345\256\232\344\271\211view" "b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/view/\350\207\252\345\256\232\344\271\211view" new file mode 100644 index 00000000..0f28354e --- /dev/null +++ "b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903115/view/\350\207\252\345\256\232\344\271\211view" @@ -0,0 +1 @@ +这个文件夹放自定义view diff --git a/app/src/main/res/drawable/net1314080903115logo.png b/app/src/main/res/drawable/net1314080903115logo.png new file mode 100644 index 00000000..62f67af3 Binary files /dev/null and b/app/src/main/res/drawable/net1314080903115logo.png differ diff --git a/app/src/main/res/drawable/net1314080903115portrait.xml b/app/src/main/res/drawable/net1314080903115portrait.xml new file mode 100644 index 00000000..60df9bec --- /dev/null +++ b/app/src/main/res/drawable/net1314080903115portrait.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/net1314080903115portrait_lift.png b/app/src/main/res/drawable/net1314080903115portrait_lift.png new file mode 100644 index 00000000..6719ab42 Binary files /dev/null and b/app/src/main/res/drawable/net1314080903115portrait_lift.png differ diff --git a/app/src/main/res/drawable/net1314080903115portrait_press.png b/app/src/main/res/drawable/net1314080903115portrait_press.png new file mode 100644 index 00000000..16d2c281 Binary files /dev/null and b/app/src/main/res/drawable/net1314080903115portrait_press.png differ diff --git a/app/src/main/res/layout/net1314080903115login.xml b/app/src/main/res/layout/net1314080903115login.xml new file mode 100644 index 00000000..1aa64b28 --- /dev/null +++ b/app/src/main/res/layout/net1314080903115login.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + +