Skip to content

Commit 0126e59

Browse files
committed
merger
1 parent 421a9bf commit 0126e59

File tree

37 files changed

+781
-41
lines changed

37 files changed

+781
-41
lines changed

.idea/gradle.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glinlibrary/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

glinlibrary/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apply plugin: 'java'
2+
3+
dependencies {
4+
targetCompatibility = '1.7'
5+
sourceCompatibility = '1.7'
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.example.glinlibrary;
2+
3+
/**
4+
* Created by Pengliang on 2016/9/2.
5+
*/
6+
public class TestCode {
7+
public static void main(String[] args) {
8+
9+
/* int freezeByte = 0x01;
10+
int coolByte = 0x02;
11+
int smartByte = 0x04;
12+
int cleanByte = 0x08;
13+
14+
byte a = (byte) (freezeByte | cleanByte);
15+
16+
System.out.println(String.format("%02x",a));*/
17+
18+
printbyte(getHexByteFrom10(38));
19+
20+
}
21+
22+
23+
public static byte getHexByteFrom10(int i) {
24+
return (byte) Integer.parseInt(Integer.toHexString(i), 16);
25+
}
26+
27+
public static void printbyte(byte a){
28+
System.out.println(String.format("%02x",a));
29+
}
30+
}

p010_recycleviewall/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ dependencies {
308308

309309

310310
compile project(':glin')
311+
compile project(':glinlibrary')
311312
compile 'com.github.bumptech.glide:glide:3.7.0'
312313
compile 'com.alibaba:fastjson:1.2.17'
313314
compile 'com.squareup.okio:okio:1.9.0'

p034_greendao_sqlite/src/main/java/com/example/p034_greendao_sqlite/MainActivity.java

+26-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.support.v7.app.AppCompatActivity;
55
import android.view.View;
66
import android.widget.TextView;
7+
import android.widget.Toast;
78

89
import com.example.p034_greendao_sqlite.application.DemoApplication;
910
import com.example.p034_greendao_sqlite.domain.User;
@@ -96,20 +97,41 @@ private void queryData() {
9697

9798
//增
9899
private void insertData(int i) {
99-
User insertData = new User((long)i, "geek", "100", "男", "100");
100+
User insertData = new User(null, i + "", "geek", "100", "男", "100");
100101
mUserDao.insert(insertData);
101102
}
102103

103104
//改
104105
private void updateData(int i) {
105-
User updateData = new User((long) i, "geek1", "101", "女", "101");
106-
mUserDao.update(updateData);
106+
// User updateData = new User(null, i + "", "geek1", "101", "女", "101");
107+
// User updateData = new User((long) i, "geek1", "101", "女", "101");
108+
// mUserDao.update(updateData);
109+
110+
User user = mUserDao.queryBuilder()
111+
.where(UserDao.Properties.Userid.eq(i + "")/*, UserDao.Properties.Name.like("%90%")*/).build().unique();
112+
if (user == null) {
113+
Toast.makeText(MainActivity.this, "用户不存在!", Toast.LENGTH_SHORT).show();
114+
} else {
115+
user.setUserid(i + "");
116+
user.setName("geek1");
117+
user.setAge("101");
118+
user.setSex("女");
119+
user.setSalary("101");
120+
mUserDao.update(user);
121+
}
107122
}
108123

109124
//删
110125

111126
private void deleteData(int id) {
112-
mUserDao.deleteByKey((long) id);
127+
User user = mUserDao.queryBuilder().where(UserDao.Properties.Userid.eq(id + "")).build().unique();
128+
if (user == null) {
129+
Toast.makeText(MainActivity.this, "用户不存在", Toast.LENGTH_SHORT).show();
130+
} else {
131+
mUserDao.deleteByKey(user.getId());
132+
}
133+
// User updateData = new User((long) i, "geek1", "101", "女", "101");
134+
// mUserDao.deleteByKey((long) id);
113135
}
114136

115137
//删全部

p034_greendao_sqlite/src/main/java/com/example/p034_greendao_sqlite/domain/User.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
public class User {
1313
@Id
1414
private Long id;
15+
private String userid;
1516
private String name;
1617
private String age;
1718
private String sex;
@@ -46,9 +47,17 @@ public Long getId() {
4647
public void setId(Long id) {
4748
this.id = id;
4849
}
49-
@Generated(hash = 1281958717)
50-
public User(Long id, String name, String age, String sex, String salary) {
50+
public String getUserid() {
51+
return this.userid;
52+
}
53+
public void setUserid(String userid) {
54+
this.userid = userid;
55+
}
56+
@Generated(hash = 364037205)
57+
public User(Long id, String userid, String name, String age, String sex,
58+
String salary) {
5159
this.id = id;
60+
this.userid = userid;
5261
this.name = name;
5362
this.age = age;
5463
this.sex = sex;

p034_greendao_sqlite/src/main/java/com/example/p034_greendao_sqlite/greendao/UserDao.java

+38-24
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ public class UserDao extends AbstractDao<User, Long> {
2525
*/
2626
public static class Properties {
2727
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
28-
public final static Property Name = new Property(1, String.class, "name", false, "NAME");
29-
public final static Property Age = new Property(2, String.class, "age", false, "AGE");
30-
public final static Property Sex = new Property(3, String.class, "sex", false, "SEX");
31-
public final static Property Salary = new Property(4, String.class, "salary", false, "SALARY");
28+
public final static Property Userid = new Property(1, String.class, "userid", false, "USERID");
29+
public final static Property Name = new Property(2, String.class, "name", false, "NAME");
30+
public final static Property Age = new Property(3, String.class, "age", false, "AGE");
31+
public final static Property Sex = new Property(4, String.class, "sex", false, "SEX");
32+
public final static Property Salary = new Property(5, String.class, "salary", false, "SALARY");
3233
};
3334

3435

@@ -45,10 +46,11 @@ public static void createTable(Database db, boolean ifNotExists) {
4546
String constraint = ifNotExists? "IF NOT EXISTS ": "";
4647
db.execSQL("CREATE TABLE " + constraint + "\"USER\" (" + //
4748
"\"_id\" INTEGER PRIMARY KEY ," + // 0: id
48-
"\"NAME\" TEXT," + // 1: name
49-
"\"AGE\" TEXT," + // 2: age
50-
"\"SEX\" TEXT," + // 3: sex
51-
"\"SALARY\" TEXT);"); // 4: salary
49+
"\"USERID\" TEXT," + // 1: userid
50+
"\"NAME\" TEXT," + // 2: name
51+
"\"AGE\" TEXT," + // 3: age
52+
"\"SEX\" TEXT," + // 4: sex
53+
"\"SALARY\" TEXT);"); // 5: salary
5254
}
5355

5456
/** Drops the underlying database table. */
@@ -66,24 +68,29 @@ protected final void bindValues(DatabaseStatement stmt, User entity) {
6668
stmt.bindLong(1, id);
6769
}
6870

71+
String userid = entity.getUserid();
72+
if (userid != null) {
73+
stmt.bindString(2, userid);
74+
}
75+
6976
String name = entity.getName();
7077
if (name != null) {
71-
stmt.bindString(2, name);
78+
stmt.bindString(3, name);
7279
}
7380

7481
String age = entity.getAge();
7582
if (age != null) {
76-
stmt.bindString(3, age);
83+
stmt.bindString(4, age);
7784
}
7885

7986
String sex = entity.getSex();
8087
if (sex != null) {
81-
stmt.bindString(4, sex);
88+
stmt.bindString(5, sex);
8289
}
8390

8491
String salary = entity.getSalary();
8592
if (salary != null) {
86-
stmt.bindString(5, salary);
93+
stmt.bindString(6, salary);
8794
}
8895
}
8996

@@ -96,24 +103,29 @@ protected final void bindValues(SQLiteStatement stmt, User entity) {
96103
stmt.bindLong(1, id);
97104
}
98105

106+
String userid = entity.getUserid();
107+
if (userid != null) {
108+
stmt.bindString(2, userid);
109+
}
110+
99111
String name = entity.getName();
100112
if (name != null) {
101-
stmt.bindString(2, name);
113+
stmt.bindString(3, name);
102114
}
103115

104116
String age = entity.getAge();
105117
if (age != null) {
106-
stmt.bindString(3, age);
118+
stmt.bindString(4, age);
107119
}
108120

109121
String sex = entity.getSex();
110122
if (sex != null) {
111-
stmt.bindString(4, sex);
123+
stmt.bindString(5, sex);
112124
}
113125

114126
String salary = entity.getSalary();
115127
if (salary != null) {
116-
stmt.bindString(5, salary);
128+
stmt.bindString(6, salary);
117129
}
118130
}
119131

@@ -126,21 +138,23 @@ public Long readKey(Cursor cursor, int offset) {
126138
public User readEntity(Cursor cursor, int offset) {
127139
User entity = new User( //
128140
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
129-
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
130-
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // age
131-
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // sex
132-
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // salary
141+
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userid
142+
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // name
143+
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // age
144+
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // sex
145+
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // salary
133146
);
134147
return entity;
135148
}
136149

137150
@Override
138151
public void readEntity(Cursor cursor, User entity, int offset) {
139152
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
140-
entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
141-
entity.setAge(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
142-
entity.setSex(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
143-
entity.setSalary(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
153+
entity.setUserid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
154+
entity.setName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
155+
entity.setAge(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
156+
entity.setSex(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
157+
entity.setSalary(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
144158
}
145159

146160
@Override

p036_tablayoutdemo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

p036_tablayoutdemo/build.gradle

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.3"
6+
7+
defaultConfig {
8+
applicationId "com.example.shining.p036_tablayoutdemo"
9+
minSdkVersion 21
10+
targetSdkVersion 25
11+
versionCode 1
12+
versionName "1.0"
13+
14+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
compile fileTree(dir: 'libs', include: ['*.jar'])
27+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28+
exclude group: 'com.android.support', module: 'support-annotations'
29+
})
30+
compile 'com.android.support:appcompat-v7:25.3.1'
31+
compile 'com.android.support:recyclerview-v7:25.3.1'
32+
compile 'com.android.support:design:25.3.1'
33+
compile 'com.android.support:cardview-v7:25.3.1'
34+
compile 'com.android.support.constraint:constraint-layout:1.0.2'
35+
36+
testCompile 'junit:junit:4.12'
37+
}

p036_tablayoutdemo/proguard-rules.pro

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in E:\Andriod\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.shining.p036_tablayoutdemo;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.example.shining.p036_tablayoutdemo", appContext.getPackageName());
25+
}
26+
}

0 commit comments

Comments
 (0)