+
\ No newline at end of file
diff --git a/chapter04_sqlite/.idea/misc.xml b/chapter06_net/.idea/misc.xml
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/.idea/misc.xml
rename to chapter06_net/.idea/misc.xml
index 9e1d7ba..1671a39
--- a/chapter04_sqlite/.idea/misc.xml
+++ b/chapter06_net/.idea/misc.xml
@@ -1,75 +1,75 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/chapter04_sqlite/.idea/runConfigurations.xml b/chapter06_net/.idea/runConfigurations.xml
old mode 100755
new mode 100644
similarity index 96%
rename from chapter04_sqlite/.idea/runConfigurations.xml
rename to chapter06_net/.idea/runConfigurations.xml
index 9b770a6..7f68460
--- a/chapter04_sqlite/.idea/runConfigurations.xml
+++ b/chapter06_net/.idea/runConfigurations.xml
@@ -1,12 +1,12 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter03_fragment/app/.gitignore b/chapter06_net/app/.gitignore
similarity index 100%
rename from chapter03_fragment/app/.gitignore
rename to chapter06_net/app/.gitignore
diff --git a/chapter04_sqlite/app/build.gradle b/chapter06_net/app/build.gradle
old mode 100755
new mode 100644
similarity index 82%
rename from chapter04_sqlite/app/build.gradle
rename to chapter06_net/app/build.gradle
index 9217ea0..1b8c071
--- a/chapter04_sqlite/app/build.gradle
+++ b/chapter06_net/app/build.gradle
@@ -1,34 +1,37 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 29
- buildToolsVersion "29.0.2"
- defaultConfig {
- applicationId "com.orangesale.cn"
- minSdkVersion 26
- targetSdkVersion 29
- versionCode 1
- versionName "1.0"
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
- compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test.ext:junit:1.1.0'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
- implementation 'liji.library.dev:citypickerview:1.1.0'
-}
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+ defaultConfig {
+ applicationId "com.orangesale.cn"
+ minSdkVersion 26
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ /*引入OkHTTP*/
+ implementation "com.squareup.okhttp3:okhttp:4.2.2"
+ implementation 'org.conscrypt:conscrypt-android:2.2.1'
+ implementation 'androidx.appcompat:appcompat:1.0.2'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ implementation 'liji.library.dev:citypickerview:1.1.0'
+}
diff --git a/chapter03_fragment/app/proguard-rules.pro b/chapter06_net/app/proguard-rules.pro
similarity index 100%
rename from chapter03_fragment/app/proguard-rules.pro
rename to chapter06_net/app/proguard-rules.pro
diff --git a/chapter03_fragment/app/src/androidTest/java/com/orangesale/cn/ExampleInstrumentedTest.java b/chapter06_net/app/src/androidTest/java/com/orangesale/cn/ExampleInstrumentedTest.java
similarity index 100%
rename from chapter03_fragment/app/src/androidTest/java/com/orangesale/cn/ExampleInstrumentedTest.java
rename to chapter06_net/app/src/androidTest/java/com/orangesale/cn/ExampleInstrumentedTest.java
diff --git a/chapter04_sqlite/app/src/main/AndroidManifest.xml b/chapter06_net/app/src/main/AndroidManifest.xml
old mode 100755
new mode 100644
similarity index 81%
rename from chapter04_sqlite/app/src/main/AndroidManifest.xml
rename to chapter06_net/app/src/main/AndroidManifest.xml
index 31f5b92..9bc5ef0
--- a/chapter04_sqlite/app/src/main/AndroidManifest.xml
+++ b/chapter06_net/app/src/main/AndroidManifest.xml
@@ -1,24 +1,30 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/MainActivity.java b/chapter06_net/app/src/main/java/com/orangesale/cn/MainActivity.java
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/MainActivity.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/MainActivity.java
index 5575870..25ed3e8
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/MainActivity.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/MainActivity.java
@@ -1,79 +1,79 @@
-package com.orangesale.cn;
-
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.Toast;
-
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.orangesale.cn.activity.IndexActivity;
-import com.orangesale.cn.activity.RegisterActivity;
-import com.orangesale.cn.dataoperation.OrangeDatabase;
-
-public class MainActivity extends AppCompatActivity implements View.OnClickListener {
- private Button registerButton, loginButton;
- private EditText usernameText, paswdEdit;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.user_login);
- init();
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.register:
- Intent intent = new Intent(MainActivity.this, RegisterActivity.class);
- startActivity(intent);
- break;
- case R.id.login:
- //注册时,我们引入了数据库,登录这里可以通过数据库进行验证,验证跳转到首页,不通过进行提示
- if (validateLogin()) {
- Intent intent1 = new Intent(MainActivity.this, IndexActivity.class);
- Bundle bundle = new Bundle();
- OrangeDatabase orangeDatabase = new OrangeDatabase(MainActivity.this);
- bundle.putString("username", usernameText.getText().toString());
- bundle = orangeDatabase.queryUserInfo(orangeDatabase.getReadableDatabase(), bundle);
- intent1.putExtras(bundle);
- startActivity(intent1);
- } else {
- Toast.makeText(MainActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show();
- }
- break;
- }
- }
-
- //界面组件初始化
- private void init() {
- usernameText = findViewById(R.id.username);
- paswdEdit = findViewById(R.id.password);
- loginButton = findViewById(R.id.login);
- loginButton.setOnClickListener(this);
- registerButton = findViewById(R.id.register);
- registerButton.setOnClickListener(this);
- }
-
- /**
- * 登录验证
- *
- * @return
- */
- private boolean validateLogin() {
- String username = usernameText.getText().toString();
- String password = paswdEdit.getText().toString();
- OrangeDatabase orangeDatabase = new OrangeDatabase(MainActivity.this);
- SQLiteDatabase sqLiteDatabase = orangeDatabase.getReadableDatabase();
- Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=? and password=?", new String[]{username, password});
- if (cursor.getCount() > 0) {
- return true;
- }
- return false;
- }
-}
+package com.orangesale.cn;
+
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.orangesale.cn.activity.IndexActivity;
+import com.orangesale.cn.activity.RegisterActivity;
+import com.orangesale.cn.dataoperation.OrangeDatabase;
+
+public class MainActivity extends AppCompatActivity implements View.OnClickListener {
+ private Button registerButton, loginButton;
+ private EditText usernameText, paswdEdit;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.user_login);
+ init();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.register:
+ Intent intent = new Intent(MainActivity.this, RegisterActivity.class);
+ startActivity(intent);
+ break;
+ case R.id.login:
+ //注册时,我们引入了数据库,登录这里可以通过数据库进行验证,验证跳转到首页,不通过进行提示
+ if (validateLogin()) {
+ Intent intent1 = new Intent(MainActivity.this, IndexActivity.class);
+ Bundle bundle = new Bundle();
+ OrangeDatabase orangeDatabase = new OrangeDatabase(MainActivity.this);
+ bundle.putString("username", usernameText.getText().toString());
+ bundle = orangeDatabase.queryUserInfo(orangeDatabase.getReadableDatabase(), bundle);
+ intent1.putExtras(bundle);
+ startActivity(intent1);
+ } else {
+ Toast.makeText(MainActivity.this, "账号或者密码错误", Toast.LENGTH_SHORT).show();
+ }
+ break;
+ }
+ }
+
+ //界面组件初始化
+ private void init() {
+ usernameText = findViewById(R.id.username);
+ paswdEdit = findViewById(R.id.password);
+ loginButton = findViewById(R.id.login);
+ loginButton.setOnClickListener(this);
+ registerButton = findViewById(R.id.register);
+ registerButton.setOnClickListener(this);
+ }
+
+ /**
+ * 登录验证
+ *
+ * @return
+ */
+ private boolean validateLogin() {
+ String username = usernameText.getText().toString();
+ String password = paswdEdit.getText().toString();
+ OrangeDatabase orangeDatabase = new OrangeDatabase(MainActivity.this);
+ SQLiteDatabase sqLiteDatabase = orangeDatabase.getReadableDatabase();
+ Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=? and password=?", new String[]{username, password});
+ if (cursor.getCount() > 0) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/CategoryActivity.java b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/CategoryActivity.java
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/CategoryActivity.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/activity/CategoryActivity.java
index 963b7cb..af5b6bc
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/CategoryActivity.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/CategoryActivity.java
@@ -1,90 +1,90 @@
-package com.orangesale.cn.activity;
-
-import android.app.Activity;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-import android.os.Bundle;
-import android.widget.ListView;
-
-import androidx.annotation.Nullable;
-
-import com.orangesale.cn.R;
-import com.orangesale.cn.adapter.Adapter;
-import com.orangesale.cn.entity.Product;
-import com.orangesale.cn.fragment.SetDetailFragment;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-
-
-public class CategoryActivity extends Activity {
- public OnChangeListener onchangedListener;
- private List productList;
- private List productCategory = new ArrayList<>();
- private ListView titleList;
- private Adapter adapter;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.content_category);
- initData();
- init();
- SetDetailFragment fragment = new SetDetailFragment();
- FragmentManager fragmentManager = getFragmentManager();
- FragmentTransaction transaction = fragmentManager.beginTransaction();
- transaction.replace(R.id.category_detail, fragment);
- transaction.commit();
- titleList.setOnItemClickListener((parent, view, position, id) -> {
- adapter.setSelectedPosition(position);
- adapter.notifyDataSetInvalidated();
- if (onchangedListener != null) {
- onchangedListener.changeText(productList.get(position));
- }
- });
-
- }
-
- public void setOnChangeListener(OnChangeListener onChangeListener) {
- this.onchangedListener = onChangeListener;
- }
-
- public interface OnChangeListener {
- void changeText(Product product);
- }
-
- /**
- * 初始化数据
- */
- private void initData() {
- productList = new ArrayList<>();
- productCategory.add("橘子");
- productCategory.add("橙子");
- productCategory.add("柚子");
- Product product = new Product();
- product.setImageUrlId(R.drawable.arrow_down);
- product.setProductName("橘子");
- product.setProductPrice(new BigDecimal("9.9"));
- Product product1 = new Product();
- product1.setImageUrlId(R.drawable.orange);
- product1.setProductName("橙子");
- product1.setProductPrice(new BigDecimal("29.9"));
- Product product2 = new Product();
- product2.setImageUrlId(R.drawable.arrow_left);
- product2.setProductName("柚子");
- product2.setProductPrice(new BigDecimal("19.9"));
- productList.add(product);
- productList.add(product1);
- productList.add(product2);
- }
-
- /**
- * 初始化组件
- */
- private void init() {
- titleList = findViewById(R.id.category_title_list);
- adapter = new Adapter(productCategory, CategoryActivity.this);
- titleList.setAdapter(adapter);
- }
+package com.orangesale.cn.activity;
+
+import android.app.Activity;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.widget.ListView;
+
+import androidx.annotation.Nullable;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.adapter.Adapter;
+import com.orangesale.cn.entity.Product;
+import com.orangesale.cn.fragment.SetDetailFragment;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class CategoryActivity extends Activity {
+ public OnChangeListener onchangedListener;
+ private List productList;
+ private List productCategory = new ArrayList<>();
+ private ListView titleList;
+ private Adapter adapter;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.content_category);
+ initData();
+ init();
+ SetDetailFragment fragment = new SetDetailFragment();
+ FragmentManager fragmentManager = getFragmentManager();
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+ transaction.replace(R.id.category_detail, fragment);
+ transaction.commit();
+ titleList.setOnItemClickListener((parent, view, position, id) -> {
+ adapter.setSelectedPosition(position);
+ adapter.notifyDataSetInvalidated();
+ if (onchangedListener != null) {
+ onchangedListener.changeText(productList.get(position));
+ }
+ });
+
+ }
+
+ public void setOnChangeListener(OnChangeListener onChangeListener) {
+ this.onchangedListener = onChangeListener;
+ }
+
+ public interface OnChangeListener {
+ void changeText(Product product);
+ }
+
+ /**
+ * 初始化数据
+ */
+ private void initData() {
+ productList = new ArrayList<>();
+ productCategory.add("橘子");
+ productCategory.add("橙子");
+ productCategory.add("柚子");
+ Product product = new Product();
+ product.setImageUrlId(R.drawable.arrow_down);
+ product.setProductName("橘子");
+ product.setProductPrice(new BigDecimal("9.9"));
+ Product product1 = new Product();
+ product1.setImageUrlId(R.drawable.orange);
+ product1.setProductName("橙子");
+ product1.setProductPrice(new BigDecimal("29.9"));
+ Product product2 = new Product();
+ product2.setImageUrlId(R.drawable.arrow_left);
+ product2.setProductName("柚子");
+ product2.setProductPrice(new BigDecimal("19.9"));
+ productList.add(product);
+ productList.add(product1);
+ productList.add(product2);
+ }
+
+ /**
+ * 初始化组件
+ */
+ private void init() {
+ titleList = findViewById(R.id.category_title_list);
+ adapter = new Adapter(productCategory, CategoryActivity.this);
+ titleList.setAdapter(adapter);
+ }
}
\ No newline at end of file
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
old mode 100755
new mode 100644
similarity index 93%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
index 07152fc..3d8ae47
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/IndexActivity.java
@@ -1,120 +1,128 @@
-package com.orangesale.cn.activity;
-
-import android.app.Activity;
-import android.app.FragmentTransaction;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import androidx.annotation.Nullable;
-
-import com.orangesale.cn.R;
-import com.orangesale.cn.fragment.IndexFragment;
-import com.orangesale.cn.fragment.PearsonFragment;
-import com.orangesale.cn.fragment.ProductFragment;
-import com.orangesale.cn.fragment.ShoppingCartFragment;
-
-public class IndexActivity extends Activity implements View.OnClickListener {
- private IndexFragment indexFragment;
- private ProductFragment productFragment;
- private ShoppingCartFragment shoppingCartFragment;
- private PearsonFragment pearsonFragment;
- private LinearLayout indexLine, productLine, shoppingCartLine, pearsonLine;
-
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- init();
- initIndexFragment();
- }
-
- /**
- * 组件初始化
- */
- private void init() {
- indexLine = findViewById(R.id.content_index);
- indexLine.setOnClickListener(this);
- productLine = findViewById(R.id.content_product);
- productLine.setOnClickListener(this);
- shoppingCartLine = findViewById(R.id.content_cart);
- shoppingCartLine.setOnClickListener(this);
- pearsonLine = findViewById(R.id.content_pearson);
- pearsonLine.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.content_index:
- initIndexFragment();
- break;
- case R.id.content_product:
- initproductFragment();
- break;
- case R.id.content_cart:
- initshoppingCartFragment();
- break;
- case R.id.content_pearson:
- initpearsonFragment();
- break;
- }
- }
-
- /**
- * 初始化首页Fragment
- */
- private void initIndexFragment() {
- //开启事务,fragment的控制是由事务来实现的
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- if (indexFragment == null) {
- indexFragment = new IndexFragment();
- }
- transaction.replace(R.id.main_content, indexFragment);
- transaction.commit();
- }
-
- /**
- * 初始化产品Fragment
- */
- private void initproductFragment() {
- //开启事务,fragment的控制是由事务来实现的
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- if (productFragment == null) {
- productFragment = new ProductFragment();
- }
- transaction.replace(R.id.main_content, productFragment);
- transaction.commit();
- }
-
- /**
- * 初始化购物车Fragment
- */
- private void initshoppingCartFragment() {
- //开启事务,fragment的控制是由事务来实现的
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- if (shoppingCartFragment == null) {
- shoppingCartFragment = new ShoppingCartFragment();
- }
- transaction.replace(R.id.main_content, shoppingCartFragment);
- transaction.commit();
- }
-
- /**
- * 初始化个人Fragment
- */
- private void initpearsonFragment() {
- //开启事务,fragment的控制是由事务来实现的
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- if (pearsonFragment == null) {
- Intent intent = IndexActivity.this.getIntent();
- Bundle bundle = intent.getExtras();
- pearsonFragment = new PearsonFragment();
- pearsonFragment.setArguments(bundle);
- }
- transaction.replace(R.id.main_content, pearsonFragment);
- transaction.commit();
- }
-
-}
+package com.orangesale.cn.activity;
+
+import android.app.Activity;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import androidx.annotation.Nullable;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.fragment.IndexFragment;
+import com.orangesale.cn.fragment.PearsonFragment;
+import com.orangesale.cn.fragment.ProductFragment;
+import com.orangesale.cn.fragment.ShoppingCartFragment;
+import com.orangesale.cn.service.TimeService;
+
+public class IndexActivity extends Activity implements View.OnClickListener {
+ private IndexFragment indexFragment;
+ private ProductFragment productFragment;
+ private ShoppingCartFragment shoppingCartFragment;
+ private PearsonFragment pearsonFragment;
+ private LinearLayout indexLine, productLine, shoppingCartLine, pearsonLine;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ init();
+ initIndexFragment();
+ Thread thread = new Thread(runnable);
+ thread.start();
+ }
+
+ /**
+ * 组件初始化
+ */
+ private void init() {
+ indexLine = findViewById(R.id.content_index);
+ indexLine.setOnClickListener(this);
+ productLine = findViewById(R.id.content_product);
+ productLine.setOnClickListener(this);
+ shoppingCartLine = findViewById(R.id.content_cart);
+ shoppingCartLine.setOnClickListener(this);
+ pearsonLine = findViewById(R.id.content_pearson);
+ pearsonLine.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.content_index:
+ initIndexFragment();
+ break;
+ case R.id.content_product:
+ initproductFragment();
+ break;
+ case R.id.content_cart:
+ initshoppingCartFragment();
+ break;
+ case R.id.content_pearson:
+ initpearsonFragment();
+ break;
+ }
+ }
+
+ /**
+ * 初始化首页Fragment
+ */
+ private void initIndexFragment() {
+ //开启事务,fragment的控制是由事务来实现的
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (indexFragment == null) {
+ indexFragment = new IndexFragment();
+ }
+ transaction.replace(R.id.main_content, indexFragment);
+ transaction.commit();
+ }
+
+ /**
+ * 初始化产品Fragment
+ */
+ private void initproductFragment() {
+ //开启事务,fragment的控制是由事务来实现的
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (productFragment == null) {
+ productFragment = new ProductFragment();
+ }
+ transaction.replace(R.id.main_content, productFragment);
+ transaction.commit();
+ }
+
+ /**
+ * 初始化购物车Fragment
+ */
+ private void initshoppingCartFragment() {
+ //开启事务,fragment的控制是由事务来实现的
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (shoppingCartFragment == null) {
+ shoppingCartFragment = new ShoppingCartFragment();
+ }
+ transaction.replace(R.id.main_content, shoppingCartFragment);
+ transaction.commit();
+ }
+
+ /**
+ * 初始化个人Fragment
+ */
+ private void initpearsonFragment() {
+ //开启事务,fragment的控制是由事务来实现的
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (pearsonFragment == null) {
+ Intent intent = IndexActivity.this.getIntent();
+ Bundle bundle = intent.getExtras();
+ pearsonFragment = new PearsonFragment();
+ pearsonFragment.setArguments(bundle);
+ }
+ transaction.replace(R.id.main_content, pearsonFragment);
+ transaction.commit();
+ }
+
+ Runnable runnable = () -> {
+ Intent intent = new Intent(IndexActivity.this, TimeService.class);
+ startService(intent);
+ };
+
+}
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/RegisterActivity.java b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/RegisterActivity.java
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/RegisterActivity.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/activity/RegisterActivity.java
index 5f41097..3edcd0c
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/activity/RegisterActivity.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/RegisterActivity.java
@@ -1,168 +1,168 @@
-package com.orangesale.cn.activity;
-
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.sqlite.SQLiteDatabase;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.RadioGroup;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.lljjcoder.citypickerview.widget.CityPicker;
-import com.orangesale.cn.R;
-import com.orangesale.cn.dataoperation.OrangeDatabase;
-
-public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
- private EditText usernameEdit, passwordEdit, surePasswordEdit;
- private TextView cityText;
- private CityPicker cityPicker;
- private Button regButton;
- private RadioGroup sexGroup;
- private String sexStr = "男";
-
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.user_register);
- init();
- }
-
- /**
- * 界面组件初始化
- */
- private void init() {
- cityText = findViewById(R.id.reg_province);
- cityText.setOnClickListener(this);
- usernameEdit = findViewById(R.id.reg_username);
- passwordEdit = findViewById(R.id.reg_password);
- surePasswordEdit = findViewById(R.id.reg_sure_password);
- regButton = findViewById(R.id.reg_register);
- regButton.setOnClickListener(this);
- sexGroup = findViewById(R.id.sex);
- sexGroup.setOnCheckedChangeListener(this);
-
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.reg_province:
- initCityPicker();
- cityPicker.show();
- break;
- case R.id.reg_register:
- //注册验证方法
- validateRegister();
- break;
-
- }
- }
-
- /**
- * 初始化城市选择器
- */
- public void initCityPicker() {
- cityPicker = new CityPicker.Builder(RegisterActivity.this)
- .textSize(16)
- .title("地址选择")
- .backgroundPop(0xa0000000)
- .titleBackgroundColor("#EFB81C")
- .titleTextColor("#000000")
- .backgroundPop(0xa0000000)
- .confirTextColor("#000000")
- .cancelTextColor("#000000")
- .province("江西省")
- .city("赣州市")
- .district("章贡区")
- .textColor(Color.parseColor("#000000"))
- .provinceCyclic(true)
- .cityCyclic(false)
- .districtCyclic(false)
- .visibleItemsCount(7)
- .itemPadding(10)
- .onlyShowProvinceAndCity(false)
- .build();
- cityPicker.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener() {
- @Override
- public void onSelected(String... strings) {
- String province = strings[0];
- String city = strings[1];
- String district = strings[2];
- cityText.setText(String.format("%s %s %s", province, city, district));
- }
-
- @Override
- public void onCancel() {
- }
- });
-
- }
-
- /**
- * 注册验证
- */
- public void validateRegister() {
- String username = usernameEdit.getText().toString();
- String password = passwordEdit.getText().toString();
- String surePassword = surePasswordEdit.getText().toString();
- String city = cityText.getText().toString();
- //判断两次密码是否输入一致
- if (password.equals(surePassword)) {
- //这里也可以再进行其它的验证,如是否符合要求等,符合就进行插入数据库操作
- if (!username.equals("") || !password.equals("")) {
- if (!city.equals("")) {
- Bundle bundle = new Bundle();
- bundle.putString("username", username);
- bundle.putString("password", password);
- bundle.putString("sex", sexStr);
- bundle.putString("city", city);
- //本节将使用安卓自身带的SQLite数据库的方式存储注册的信息(之前直接传输显示在界面是的方式)
- OrangeDatabase orangeDatabase = new OrangeDatabase(RegisterActivity.this);
- SQLiteDatabase sqLiteDatabase = orangeDatabase.getWritableDatabase();
- insertData(sqLiteDatabase, bundle);
- Intent intent = new Intent(RegisterActivity.this, IndexActivity.class);
- intent.putExtras(bundle);
- startActivity(intent);
- } else {
- Toast.makeText(RegisterActivity.this, "请选择地址", Toast.LENGTH_SHORT).show();
- }
- } else {
- Toast.makeText(RegisterActivity.this, "账号或密码未填写", Toast.LENGTH_SHORT).show();
- }
- } else {
- Toast.makeText(RegisterActivity.this, "两次密码输入不一致", Toast.LENGTH_SHORT).show();
- }
-
-
- }
-
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- //根据用户选择来改变sex的值
- sexStr = checkedId == R.id.reg_man ? "男" : "女";
- }
-
- /**
- * 插入数据库的值
- *
- * @param sqLiteDatabase
- * @param bundle
- */
- private void insertData(SQLiteDatabase sqLiteDatabase, Bundle bundle) {
- ContentValues contentValues = new ContentValues();
- contentValues.put("username", bundle.getString("username"));
- contentValues.put("password", bundle.getString("password"));
- contentValues.put("sex", bundle.getString("sex"));
- contentValues.put("city", bundle.getString("city"));
- sqLiteDatabase.insert("orange_user", null, contentValues);
- sqLiteDatabase.close();
- }
-}
+package com.orangesale.cn.activity;
+
+import android.content.ContentValues;
+import android.content.Intent;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.lljjcoder.citypickerview.widget.CityPicker;
+import com.orangesale.cn.R;
+import com.orangesale.cn.dataoperation.OrangeDatabase;
+
+public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
+ private EditText usernameEdit, passwordEdit, surePasswordEdit;
+ private TextView cityText;
+ private CityPicker cityPicker;
+ private Button regButton;
+ private RadioGroup sexGroup;
+ private String sexStr = "男";
+
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.user_register);
+ init();
+ }
+
+ /**
+ * 界面组件初始化
+ */
+ private void init() {
+ cityText = findViewById(R.id.reg_province);
+ cityText.setOnClickListener(this);
+ usernameEdit = findViewById(R.id.reg_username);
+ passwordEdit = findViewById(R.id.reg_password);
+ surePasswordEdit = findViewById(R.id.reg_sure_password);
+ regButton = findViewById(R.id.reg_register);
+ regButton.setOnClickListener(this);
+ sexGroup = findViewById(R.id.sex);
+ sexGroup.setOnCheckedChangeListener(this);
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.reg_province:
+ initCityPicker();
+ cityPicker.show();
+ break;
+ case R.id.reg_register:
+ //注册验证方法
+ validateRegister();
+ break;
+
+ }
+ }
+
+ /**
+ * 初始化城市选择器
+ */
+ public void initCityPicker() {
+ cityPicker = new CityPicker.Builder(RegisterActivity.this)
+ .textSize(16)
+ .title("地址选择")
+ .backgroundPop(0xa0000000)
+ .titleBackgroundColor("#EFB81C")
+ .titleTextColor("#000000")
+ .backgroundPop(0xa0000000)
+ .confirTextColor("#000000")
+ .cancelTextColor("#000000")
+ .province("江西省")
+ .city("赣州市")
+ .district("章贡区")
+ .textColor(Color.parseColor("#000000"))
+ .provinceCyclic(true)
+ .cityCyclic(false)
+ .districtCyclic(false)
+ .visibleItemsCount(7)
+ .itemPadding(10)
+ .onlyShowProvinceAndCity(false)
+ .build();
+ cityPicker.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener() {
+ @Override
+ public void onSelected(String... strings) {
+ String province = strings[0];
+ String city = strings[1];
+ String district = strings[2];
+ cityText.setText(String.format("%s %s %s", province, city, district));
+ }
+
+ @Override
+ public void onCancel() {
+ }
+ });
+
+ }
+
+ /**
+ * 注册验证
+ */
+ public void validateRegister() {
+ String username = usernameEdit.getText().toString();
+ String password = passwordEdit.getText().toString();
+ String surePassword = surePasswordEdit.getText().toString();
+ String city = cityText.getText().toString();
+ //判断两次密码是否输入一致
+ if (password.equals(surePassword)) {
+ //这里也可以再进行其它的验证,如是否符合要求等,符合就进行插入数据库操作
+ if (!username.equals("") || !password.equals("")) {
+ if (!city.equals("")) {
+ Bundle bundle = new Bundle();
+ bundle.putString("username", username);
+ bundle.putString("password", password);
+ bundle.putString("sex", sexStr);
+ bundle.putString("city", city);
+ //本节将使用安卓自身带的SQLite数据库的方式存储注册的信息(之前直接传输显示在界面是的方式)
+ OrangeDatabase orangeDatabase = new OrangeDatabase(RegisterActivity.this);
+ SQLiteDatabase sqLiteDatabase = orangeDatabase.getWritableDatabase();
+ insertData(sqLiteDatabase, bundle);
+ Intent intent = new Intent(RegisterActivity.this, IndexActivity.class);
+ intent.putExtras(bundle);
+ startActivity(intent);
+ } else {
+ Toast.makeText(RegisterActivity.this, "请选择地址", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(RegisterActivity.this, "账号或密码未填写", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(RegisterActivity.this, "两次密码输入不一致", Toast.LENGTH_SHORT).show();
+ }
+
+
+ }
+
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ //根据用户选择来改变sex的值
+ sexStr = checkedId == R.id.reg_man ? "男" : "女";
+ }
+
+ /**
+ * 插入数据库的值
+ *
+ * @param sqLiteDatabase
+ * @param bundle
+ */
+ private void insertData(SQLiteDatabase sqLiteDatabase, Bundle bundle) {
+ ContentValues contentValues = new ContentValues();
+ contentValues.put("username", bundle.getString("username"));
+ contentValues.put("password", bundle.getString("password"));
+ contentValues.put("sex", bundle.getString("sex"));
+ contentValues.put("city", bundle.getString("city"));
+ sqLiteDatabase.insert("orange_user", null, contentValues);
+ sqLiteDatabase.close();
+ }
+}
diff --git a/chapter03_fragment/app/src/main/java/com/orangesale/cn/activity/UserActivity.java b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/UserActivity.java
similarity index 92%
rename from chapter03_fragment/app/src/main/java/com/orangesale/cn/activity/UserActivity.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/activity/UserActivity.java
index 8160243..21e5ea6 100644
--- a/chapter03_fragment/app/src/main/java/com/orangesale/cn/activity/UserActivity.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/activity/UserActivity.java
@@ -10,7 +10,6 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
-import com.orangesale.cn.MainActivity;
import com.orangesale.cn.R;
public class UserActivity extends Activity implements View.OnClickListener {
@@ -39,7 +38,7 @@ public class UserActivity extends Activity implements View.OnClickListener {
userPayLine = findViewById(R.id.user_pay);
userSettingLine = findViewById(R.id.user_setting);
userGeneralLine = findViewById(R.id.user_general);
- userSearchProductLine = findViewById(R.id.user_searchProduct);
+// userSearchProductLine = findViewById(R.id.user_searchProduct);
userSearchProductLine.setOnClickListener(this);
setData();
}
@@ -58,10 +57,10 @@ public class UserActivity extends Activity implements View.OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()) {
- case R.id.user_searchProduct:
+ /*case R.id.user_searchProduct:
Intent intent1 = new Intent(UserActivity.this, CategoryActivity.class);
startActivity(intent1);
- break;
+ break;*/
}
}
}
diff --git a/chapter03_fragment/app/src/main/java/com/orangesale/cn/adapter/Adapter.java b/chapter06_net/app/src/main/java/com/orangesale/cn/adapter/Adapter.java
similarity index 100%
rename from chapter03_fragment/app/src/main/java/com/orangesale/cn/adapter/Adapter.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/adapter/Adapter.java
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/adapter/ListViewAdapter.java b/chapter06_net/app/src/main/java/com/orangesale/cn/adapter/ListViewAdapter.java
new file mode 100644
index 0000000..8eb7172
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/adapter/ListViewAdapter.java
@@ -0,0 +1,78 @@
+package com.orangesale.cn.adapter;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.entity.Condition;
+
+import java.util.List;
+
+public class ListViewAdapter extends BaseAdapter {
+ private List conditionList;
+ private LayoutInflater layoutInflater;
+ private int selectedPosition = -1;
+ private int selectColor = Color.GRAY;
+
+ public ListViewAdapter(Context context, List conditionList) {
+ this.conditionList = conditionList;
+ this.layoutInflater = LayoutInflater.from(context);
+ }
+
+ @Override
+ public int getCount() {
+ return conditionList.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return conditionList.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder;
+ if (convertView == null) {
+ convertView = layoutInflater.inflate(R.layout.product_condition_item, null);
+ viewHolder = new ViewHolder();
+ viewHolder.imageView = convertView.findViewById(R.id.condition_icon);
+ viewHolder.jiange = convertView.findViewById(R.id.image_jiange);
+ viewHolder.textView = convertView.findViewById(R.id.condition_name);
+ viewHolder.linearLayout = convertView.findViewById(R.id.item_bg);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+ Condition condition = conditionList.get(position);
+ if (condition != null) {
+ viewHolder.imageView.setBackgroundResource(condition.getConditionIcon());
+ viewHolder.textView.setText(condition.getConditionName());
+ viewHolder.jiange.setBackgroundColor(Color.rgb(207, 207, 207));
+ if (selectedPosition == position) {
+ viewHolder.linearLayout.setBackgroundColor(selectColor);
+ }
+
+ }
+ return convertView;
+ }
+
+ class ViewHolder {
+ ImageView imageView, jiange;
+ TextView textView;
+ LinearLayout linearLayout;
+ }
+
+
+}
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/adapter/ProductAdapter.java b/chapter06_net/app/src/main/java/com/orangesale/cn/adapter/ProductAdapter.java
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/adapter/ProductAdapter.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/adapter/ProductAdapter.java
index d459f94..b3f61ce
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/adapter/ProductAdapter.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/adapter/ProductAdapter.java
@@ -1,69 +1,69 @@
-package com.orangesale.cn.adapter;
-
-import android.content.Context;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.orangesale.cn.R;
-import com.orangesale.cn.entity.Product;
-
-import java.util.List;
-
-public class ProductAdapter extends BaseAdapter {
- private List productList;
- private LayoutInflater layoutInflater;
-
- public ProductAdapter(Context context, List productList) {
- this.productList = productList;
- this.layoutInflater = LayoutInflater.from(context);
- }
-
- @Override
- public int getCount() {
- return productList.size();
- }
-
- @Override
- public Object getItem(int position) {
- return productList.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return position;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder viewHolder;
- if (convertView == null) {
- Log.i("aa", "getView: "+"aa");
- convertView = layoutInflater.inflate(R.layout.categoty_detail_content, null);
- viewHolder = new ViewHolder();
- viewHolder.productImage = convertView.findViewById(R.id.category_product_image);
- viewHolder.productName = convertView.findViewById(R.id.category_product_name);
- viewHolder.productPrice = convertView.findViewById(R.id.category_product_price);
- convertView.setTag(viewHolder);
- } else {
- viewHolder = (ViewHolder) convertView.getTag();
- }
- Product product = productList.get(position);
- Log.i("product", "getView: "+product.toString());
- if (product != null) {
- viewHolder.productImage.setBackgroundResource(product.getImageUrlId());
- viewHolder.productName.setText(product.getProductName());
- viewHolder.productPrice.setText(String.valueOf(product.getProductPrice()));
- }
- return convertView;
- }
-
- class ViewHolder {
- ImageView productImage;
- TextView productName, productPrice;
- }
-}
+package com.orangesale.cn.adapter;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.entity.Product;
+
+import java.util.List;
+
+public class ProductAdapter extends BaseAdapter {
+ private List productList;
+ private LayoutInflater layoutInflater;
+
+ public ProductAdapter(Context context, List productList) {
+ this.productList = productList;
+ this.layoutInflater = LayoutInflater.from(context);
+ }
+
+ @Override
+ public int getCount() {
+ return productList.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return productList.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder;
+ if (convertView == null) {
+ Log.i("aa", "getView: "+"aa");
+ convertView = layoutInflater.inflate(R.layout.categoty_detail_content, null);
+ viewHolder = new ViewHolder();
+ viewHolder.productImage = convertView.findViewById(R.id.category_product_image);
+ viewHolder.productName = convertView.findViewById(R.id.category_product_name);
+ viewHolder.productPrice = convertView.findViewById(R.id.category_product_price);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+ Product product = productList.get(position);
+ Log.i("product", "getView: "+product.toString());
+ if (product != null) {
+ viewHolder.productImage.setBackgroundResource(product.getImageUrlId());
+ viewHolder.productName.setText(product.getProductName());
+ viewHolder.productPrice.setText(String.valueOf(product.getProductPrice()));
+ }
+ return convertView;
+ }
+
+ class ViewHolder {
+ ImageView productImage;
+ TextView productName, productPrice;
+ }
+}
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/dataoperation/OrangeDatabase.java b/chapter06_net/app/src/main/java/com/orangesale/cn/dataoperation/OrangeDatabase.java
old mode 100755
new mode 100644
similarity index 96%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/dataoperation/OrangeDatabase.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/dataoperation/OrangeDatabase.java
index 1437bf9..75992f3
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/dataoperation/OrangeDatabase.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/dataoperation/OrangeDatabase.java
@@ -1,68 +1,68 @@
-package com.orangesale.cn.dataoperation;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.os.Bundle;
-
-import androidx.annotation.Nullable;
-
-public class OrangeDatabase extends SQLiteOpenHelper {
- public OrangeDatabase(@Nullable Context context) {
- super(context, "orange", null, 1);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- //创建用户表
- String sql = "create table orange_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50))";
- db.execSQL(sql);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-
- }
-
- /**
- * 插入数据
- *
- * @param sqLiteDatabase
- * @param username
- * @param password
- * @param sex
- * @param city
- */
- public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city) {
- ContentValues contentValues = new ContentValues();
- contentValues.put("username", username);
- contentValues.put("password", password);
- contentValues.put("sex", sex);
- contentValues.put("city", city);
- sqLiteDatabase.insert("orange_user", null, contentValues);
- sqLiteDatabase.close();
- }
-
- /**
- * 查询数据
- *
- * @param sqLiteDatabase
- * @param bundle
- * @return
- */
- public Bundle queryUserInfo(SQLiteDatabase sqLiteDatabase, Bundle bundle) {
- String username = bundle.getString("username");
- Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=?", new String[]{username});
- if (cursor != null) {
- while (cursor.moveToNext()) {
- bundle.putString("sex", cursor.getString(3));
- bundle.putString("city", cursor.getString(4));
- }
- }
- cursor.close();
- sqLiteDatabase.close();
- return bundle;
- }
-}
+package com.orangesale.cn.dataoperation;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+
+public class OrangeDatabase extends SQLiteOpenHelper {
+ public OrangeDatabase(@Nullable Context context) {
+ super(context, "orange", null, 1);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ //创建用户表
+ String sql = "create table orange_user(id integer primary key autoincrement, username varchar(50), password varchar(50),sex varchar(10),city carchar(50))";
+ db.execSQL(sql);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+
+ }
+
+ /**
+ * 插入数据
+ *
+ * @param sqLiteDatabase
+ * @param username
+ * @param password
+ * @param sex
+ * @param city
+ */
+ public void insertUser(SQLiteDatabase sqLiteDatabase, String username, String password, String sex, String city) {
+ ContentValues contentValues = new ContentValues();
+ contentValues.put("username", username);
+ contentValues.put("password", password);
+ contentValues.put("sex", sex);
+ contentValues.put("city", city);
+ sqLiteDatabase.insert("orange_user", null, contentValues);
+ sqLiteDatabase.close();
+ }
+
+ /**
+ * 查询数据
+ *
+ * @param sqLiteDatabase
+ * @param bundle
+ * @return
+ */
+ public Bundle queryUserInfo(SQLiteDatabase sqLiteDatabase, Bundle bundle) {
+ String username = bundle.getString("username");
+ Cursor cursor = sqLiteDatabase.rawQuery("select * from orange_user where username=?", new String[]{username});
+ if (cursor != null) {
+ while (cursor.moveToNext()) {
+ bundle.putString("sex", cursor.getString(3));
+ bundle.putString("city", cursor.getString(4));
+ }
+ }
+ cursor.close();
+ sqLiteDatabase.close();
+ return bundle;
+ }
+}
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/entity/Condition.java b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/Condition.java
new file mode 100644
index 0000000..de78bb9
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/Condition.java
@@ -0,0 +1,30 @@
+package com.orangesale.cn.entity;
+
+public class Condition {
+ private Integer conditionIcon;
+ private String conditionName;
+
+ public Integer getConditionIcon() {
+ return conditionIcon;
+ }
+
+ public void setConditionIcon(Integer conditionIcon) {
+ this.conditionIcon = conditionIcon;
+ }
+
+ public String getConditionName() {
+ return conditionName;
+ }
+
+ public void setConditionName(String conditionName) {
+ this.conditionName = conditionName;
+ }
+
+ @Override
+ public String toString() {
+ return "Condition{" +
+ "conditionIcon=" + conditionIcon +
+ ", conditionName='" + conditionName + '\'' +
+ '}';
+ }
+}
diff --git a/chapter03_fragment/app/src/main/java/com/orangesale/cn/entity/OrangeUser.java b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/OrangeUser.java
similarity index 100%
rename from chapter03_fragment/app/src/main/java/com/orangesale/cn/entity/OrangeUser.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/entity/OrangeUser.java
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/entity/Product.java b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/Product.java
old mode 100755
new mode 100644
similarity index 95%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/entity/Product.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/entity/Product.java
index e640ee8..2cab742
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/entity/Product.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/Product.java
@@ -1,43 +1,43 @@
-package com.orangesale.cn.entity;
-
-import java.math.BigDecimal;
-
-public class Product {
-
- public String getProductName() {
- return productName;
- }
-
- public void setProductName(String productName) {
- this.productName = productName;
- }
-
- public BigDecimal getProductPrice() {
- return productPrice;
- }
-
- public void setProductPrice(BigDecimal productPrice) {
- this.productPrice = productPrice;
- }
-
- public Integer getImageUrlId() {
- return imageUrlId;
- }
-
- public void setImageUrlId(Integer imageUrlId) {
- this.imageUrlId = imageUrlId;
- }
-
- private Integer imageUrlId;
- private String productName;
- private BigDecimal productPrice;
-
- @Override
- public String toString() {
- return "Product{" +
- "imageUrlId=" + imageUrlId +
- ", productName='" + productName + '\'' +
- ", productPrice=" + productPrice +
- '}';
- }
-}
+package com.orangesale.cn.entity;
+
+import java.math.BigDecimal;
+
+public class Product {
+
+ public String getProductName() {
+ return productName;
+ }
+
+ public void setProductName(String productName) {
+ this.productName = productName;
+ }
+
+ public BigDecimal getProductPrice() {
+ return productPrice;
+ }
+
+ public void setProductPrice(BigDecimal productPrice) {
+ this.productPrice = productPrice;
+ }
+
+ public Integer getImageUrlId() {
+ return imageUrlId;
+ }
+
+ public void setImageUrlId(Integer imageUrlId) {
+ this.imageUrlId = imageUrlId;
+ }
+
+ private Integer imageUrlId;
+ private String productName;
+ private BigDecimal productPrice;
+
+ @Override
+ public String toString() {
+ return "Product{" +
+ "imageUrlId=" + imageUrlId +
+ ", productName='" + productName + '\'' +
+ ", productPrice=" + productPrice +
+ '}';
+ }
+}
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/entity/ShoppingCart.java b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/ShoppingCart.java
new file mode 100644
index 0000000..b6600c8
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/entity/ShoppingCart.java
@@ -0,0 +1,44 @@
+package com.orangesale.cn.entity;
+
+public class ShoppingCart {
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+
+ public Integer getProductId() {
+ return ProductId;
+ }
+
+ public void setProductId(Integer productId) {
+ ProductId = productId;
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ private Integer id;
+ private Integer userId;
+ private Integer ProductId;
+ /**
+ * 购买数量
+ */
+ private Integer number;
+}
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
index a2b9d65..c79cb93
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/IndexFragment.java
@@ -1,109 +1,110 @@
-package com.orangesale.cn.fragment;
-
-import android.app.Fragment;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.GridView;
-import android.widget.LinearLayout;
-import android.widget.SearchView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.orangesale.cn.R;
-import com.orangesale.cn.adapter.ProductAdapter;
-import com.orangesale.cn.entity.Product;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-
-public class IndexFragment extends Fragment implements View.OnClickListener {
- private SearchView searchView;
- private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine;
- private GridView gridView;
- private List productList;
- private ProductAdapter productAdapter;
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index, container, false);
- init(view);
- return view;
- }
-
- /**
- * 初始化组件
- */
- private void init(View view) {
- searchView = view.findViewById(R.id.searchView);
- searchView.setOnClickListener(this);
- orangeLine = view.findViewById(R.id.chengzi);
- orangeLine.setOnClickListener(this);
- youziLine = view.findViewById(R.id.youzi);
- youziLine.setOnClickListener(this);
- juziLine = view.findViewById(R.id.juzi);
- juziLine.setOnClickListener(this);
- xiguaLine = view.findViewById(R.id.xigua);
- xiguaLine.setOnClickListener(this);
- liLine = view.findViewById(R.id.li);
- liLine.setOnClickListener(this);
- lemonLine = view.findViewById(R.id.lemon);
- lemonLine.setOnClickListener(this);
- mangguoLine = view.findViewById(R.id.mangguo);
- mangguoLine.setOnClickListener(this);
- appleLine = view.findViewById(R.id.apple);
- appleLine.setOnClickListener(this);
- gridView = view.findViewById(R.id.index_famous_gridview);
- initData();
- productAdapter = new ProductAdapter(getActivity(), productList);
- gridView.setAdapter(productAdapter);
- }
-
-
- @Override
- public void onClick(View v) {
-
- }
-
- /**
- * 初始化商品数据
- */
- private void initData() {
- productList = new ArrayList<>();
- Product product = new Product();
- product.setImageUrlId(R.drawable.juzip);
- product.setProductName("橘子");
- product.setProductPrice(new BigDecimal("9.9"));
- Product product1 = new Product();
- product1.setImageUrlId(R.drawable.orange);
- product1.setProductName("橙子");
- product1.setProductPrice(new BigDecimal("29.9"));
- Product product2 = new Product();
- product2.setImageUrlId(R.drawable.youzip);
- product2.setProductName("柚子");
- product2.setProductPrice(new BigDecimal("19.9"));
- Product product3 = new Product();
- product3.setImageUrlId(R.drawable.xiguap);
- product3.setProductName("西瓜");
- product3.setProductPrice(new BigDecimal("19.9"));
- Product product4 = new Product();
- product4.setImageUrlId(R.drawable.applep);
- product4.setProductName("苹果");
- product4.setProductPrice(new BigDecimal("49.9"));
- Product product5 = new Product();
- product5.setImageUrlId(R.drawable.lemonp);
- product5.setProductName("柠檬");
- product5.setProductPrice(new BigDecimal("9.9"));
- productList.add(product);
- productList.add(product1);
- productList.add(product2);
- productList.add(product3);
- productList.add(product4);
- productList.add(product5);
-
- }
-}
+package com.orangesale.cn.fragment;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.GridView;
+import android.widget.LinearLayout;
+import android.widget.SearchView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.adapter.ProductAdapter;
+import com.orangesale.cn.entity.Product;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class IndexFragment extends Fragment implements View.OnClickListener {
+ private SearchView searchView;
+ private LinearLayout orangeLine, youziLine, juziLine, xiguaLine, liLine, appleLine, lemonLine, mangguoLine;
+ private GridView gridView;
+ private ProductAdapter productAdapter;
+ private List productList;
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index, container, false);
+ init(view);
+ return view;
+ }
+
+ /**
+ * 初始化组件
+ */
+ private void init(View view) {
+ searchView = view.findViewById(R.id.searchView);
+ searchView.setOnClickListener(this);
+ orangeLine = view.findViewById(R.id.chengzi);
+ orangeLine.setOnClickListener(this);
+ youziLine = view.findViewById(R.id.youzi);
+ youziLine.setOnClickListener(this);
+ juziLine = view.findViewById(R.id.juzi);
+ juziLine.setOnClickListener(this);
+ xiguaLine = view.findViewById(R.id.xigua);
+ xiguaLine.setOnClickListener(this);
+ liLine = view.findViewById(R.id.li);
+ liLine.setOnClickListener(this);
+ lemonLine = view.findViewById(R.id.lemon);
+ lemonLine.setOnClickListener(this);
+ mangguoLine = view.findViewById(R.id.mangguo);
+ mangguoLine.setOnClickListener(this);
+ appleLine = view.findViewById(R.id.apple);
+ appleLine.setOnClickListener(this);
+ gridView = view.findViewById(R.id.index_famous_gridview);
+ initData();
+ productAdapter = new ProductAdapter(getActivity(), productList);
+ gridView.setAdapter(productAdapter);
+ }
+
+
+ @Override
+ public void onClick(View v) {
+
+ }
+
+ /**
+ * 初始化商品数据
+ */
+ private void initData() {
+ productList = new ArrayList<>();
+ Product product = new Product();
+ product.setImageUrlId(R.drawable.juzip);
+ product.setProductName("橘子");
+ product.setProductPrice(new BigDecimal("9.9"));
+ Product product1 = new Product();
+ product1.setImageUrlId(R.drawable.orange);
+ product1.setProductName("橙子");
+ product1.setProductPrice(new BigDecimal("29.9"));
+ Product product2 = new Product();
+ product2.setImageUrlId(R.drawable.youzip);
+ product2.setProductName("柚子");
+ product2.setProductPrice(new BigDecimal("19.9"));
+ Product product3 = new Product();
+ product3.setImageUrlId(R.drawable.xiguap);
+ product3.setProductName("西瓜");
+ product3.setProductPrice(new BigDecimal("19.9"));
+ Product product4 = new Product();
+ product4.setImageUrlId(R.drawable.applep);
+ product4.setProductName("苹果");
+ product4.setProductPrice(new BigDecimal("49.9"));
+ Product product5 = new Product();
+ product5.setImageUrlId(R.drawable.lemonp);
+ product5.setProductName("柠檬");
+ product5.setProductPrice(new BigDecimal("9.9"));
+ productList.add(product);
+ productList.add(product1);
+ productList.add(product2);
+ productList.add(product3);
+ productList.add(product4);
+ productList.add(product5);
+
+ }
+}
diff --git a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/fragment/PearsonFragment.java b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/PearsonFragment.java
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/java/com/orangesale/cn/fragment/PearsonFragment.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/fragment/PearsonFragment.java
index 10ec6dc..cc6f5ca
--- a/chapter04_sqlite/app/src/main/java/com/orangesale/cn/fragment/PearsonFragment.java
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/PearsonFragment.java
@@ -1,64 +1,64 @@
-package com.orangesale.cn.fragment;
-
-import android.app.Fragment;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.orangesale.cn.R;
-
-public class PearsonFragment extends Fragment implements View.OnClickListener {
- private ImageView userIconImage;
- private TextView usernameText, userSexText, userCityText;
- private LinearLayout usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine;
-
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_user, container, false);
- init(view);
- return view;
- }
-
- /**
- * 组件初始化
- */
- private void init(View view) {
- userIconImage = view.findViewById(R.id.user_icon);
- usernameText = view.findViewById(R.id.user_username);
- userSexText = view.findViewById(R.id.user_sex);
- userCityText = view.findViewById(R.id.user_city);
- usernameLine = view.findViewById(R.id.user_username_line);
- userSexline = view.findViewById(R.id.user_sex_line);
- userCityLine = view.findViewById(R.id.user_city_line);
- userPayLine = view.findViewById(R.id.user_pay);
- userSettingLine = view.findViewById(R.id.user_setting);
- userGeneralLine = view.findViewById(R.id.user_general);
- setData();
- }
-
- /**
- * 组件赋值
- */
- private void setData() {
- Bundle bundle = getArguments();
- usernameText.setText(String.format("用户名:%s", bundle.getString("username")));
- userSexText.setText(String.format("性别:%s", bundle.getString("sex")));
- userCityText.setText(String.format("城市:%s", bundle.getString("city")));
- }
-
- @Override
- public void onClick(View v) {
-
- }
-
-
-}
+package com.orangesale.cn.fragment;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.orangesale.cn.R;
+
+public class PearsonFragment extends Fragment implements View.OnClickListener {
+ private ImageView userIconImage;
+ private TextView usernameText, userSexText, userCityText;
+ private LinearLayout usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine;
+
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_user, container, false);
+ init(view);
+ return view;
+ }
+
+ /**
+ * 组件初始化
+ */
+ private void init(View view) {
+ userIconImage = view.findViewById(R.id.user_icon);
+ usernameText = view.findViewById(R.id.user_username);
+ userSexText = view.findViewById(R.id.user_sex);
+ userCityText = view.findViewById(R.id.user_city);
+ usernameLine = view.findViewById(R.id.user_username_line);
+ userSexline = view.findViewById(R.id.user_sex_line);
+ userCityLine = view.findViewById(R.id.user_city_line);
+ userPayLine = view.findViewById(R.id.user_pay);
+ userSettingLine = view.findViewById(R.id.user_setting);
+ userGeneralLine = view.findViewById(R.id.user_general);
+ setData();
+ }
+
+ /**
+ * 组件赋值
+ */
+ private void setData() {
+ Bundle bundle = getArguments();
+ usernameText.setText(String.format("用户名:%s", bundle.getString("username")));
+ userSexText.setText(String.format("性别:%s", bundle.getString("sex")));
+ userCityText.setText(String.format("城市:%s", bundle.getString("city")));
+ }
+
+ @Override
+ public void onClick(View v) {
+
+ }
+
+
+}
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/ProductFragment.java b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/ProductFragment.java
new file mode 100644
index 0000000..807dcac
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/ProductFragment.java
@@ -0,0 +1,117 @@
+package com.orangesale.cn.fragment;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.GridView;
+import android.widget.Spinner;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.adapter.ListViewAdapter;
+import com.orangesale.cn.adapter.ProductAdapter;
+import com.orangesale.cn.entity.Condition;
+import com.orangesale.cn.entity.Product;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ProductFragment extends Fragment {
+ private Spinner conditonListSpinner;
+ private ListViewAdapter listViewAdapter;
+ private List conditionList;
+ private GridView productGridView;
+ private List productList;
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_product, container, false);
+ init(view);
+ return view;
+ }
+
+ /**
+ * 组件初始化方法
+ *
+ * @param view
+ */
+ private void init(View view) {
+ conditonListSpinner = view.findViewById(R.id.product_select_condition);
+ initCondList();
+ listViewAdapter = new ListViewAdapter(getActivity(), conditionList);
+ conditonListSpinner.setAdapter(listViewAdapter);
+ productGridView = view.findViewById(R.id.product_list);
+ initData();
+ ProductAdapter productAdapter = new ProductAdapter(getActivity(), productList);
+ productGridView.setAdapter(productAdapter);
+ }
+
+ /**
+ * 初始化conditionList
+ */
+ private void initCondList() {
+ conditionList = new ArrayList<>();
+ Condition allCondition = new Condition();
+ allCondition.setConditionIcon(R.drawable.all);
+ allCondition.setConditionName("全部");
+ Condition saleCondition = new Condition();
+ saleCondition.setConditionIcon(R.drawable.salenum);
+ saleCondition.setConditionName("按销量高低排序");
+ Condition timeCondition = new Condition();
+ timeCondition.setConditionIcon(R.drawable.time);
+ timeCondition.setConditionName("按上市时间排序");
+ Condition priceCondition = new Condition();
+ priceCondition.setConditionIcon(R.drawable.price);
+ priceCondition.setConditionName("按商品价格排序");
+ conditionList.add(allCondition);
+ conditionList.add(saleCondition);
+ conditionList.add(timeCondition);
+ conditionList.add(priceCondition);
+ }
+
+ /**
+ * 初始化商品数据
+ */
+ private void initData() {
+ productList = new ArrayList<>();
+ Product product = new Product();
+ product.setImageUrlId(R.drawable.juzip);
+ product.setProductName("橘子");
+ product.setProductPrice(new BigDecimal("9.9"));
+ Product product1 = new Product();
+ product1.setImageUrlId(R.drawable.orange);
+ product1.setProductName("橙子");
+ product1.setProductPrice(new BigDecimal("29.9"));
+ Product product2 = new Product();
+ product2.setImageUrlId(R.drawable.youzip);
+ product2.setProductName("柚子");
+ product2.setProductPrice(new BigDecimal("19.9"));
+ Product product3 = new Product();
+ product3.setImageUrlId(R.drawable.xiguap);
+ product3.setProductName("西瓜");
+ product3.setProductPrice(new BigDecimal("19.9"));
+ Product product4 = new Product();
+ product4.setImageUrlId(R.drawable.applep);
+ product4.setProductName("苹果");
+ product4.setProductPrice(new BigDecimal("49.9"));
+ Product product5 = new Product();
+ product5.setImageUrlId(R.drawable.lemonp);
+ product5.setProductName("柠檬");
+ product5.setProductPrice(new BigDecimal("9.9"));
+ productList.add(product);
+ productList.add(product1);
+ productList.add(product2);
+ productList.add(product3);
+ productList.add(product4);
+ productList.add(product5);
+
+ }
+
+
+}
diff --git a/chapter03_fragment/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java
similarity index 100%
rename from chapter03_fragment/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java
rename to chapter06_net/app/src/main/java/com/orangesale/cn/fragment/SetDetailFragment.java
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/ShoppingCartFragment.java b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/ShoppingCartFragment.java
new file mode 100644
index 0000000..680bbe3
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/fragment/ShoppingCartFragment.java
@@ -0,0 +1,61 @@
+package com.orangesale.cn.fragment;
+
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.orangesale.cn.R;
+import com.orangesale.cn.entity.ShoppingCart;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ShoppingCartFragment extends Fragment implements View.OnClickListener {
+ private Button walkButton;
+ private List cartList = new ArrayList<>();
+ private ProductFragment productFragment;
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view;
+ if (cartList.size() > 0) {
+ //有商品
+ view = LayoutInflater.from(getActivity()).inflate(R.layout.cart_have_product, container, false);
+ } else {
+ view = LayoutInflater.from(getActivity()).inflate(R.layout.cart_no_product, container, false);
+ }
+ init(view);
+ return view;
+ }
+
+ /**
+ * 组件初始化
+ */
+ private void init(View view) {
+ walkButton = view.findViewById(R.id.random_search);
+ walkButton.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.random_search:
+ //开启事务,fragment的控制是由事务来实现的
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ if (productFragment == null) {
+ productFragment = new ProductFragment();
+ }
+ transaction.replace(R.id.main_content, productFragment);
+ transaction.commit();
+ break;
+ }
+ }
+}
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/netrequest/ImageOkHttp.java b/chapter06_net/app/src/main/java/com/orangesale/cn/netrequest/ImageOkHttp.java
new file mode 100644
index 0000000..0dc2537
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/netrequest/ImageOkHttp.java
@@ -0,0 +1,4 @@
+package com.orangesale.cn.netrequest;
+
+public class ImageOkHttp {
+}
diff --git a/chapter06_net/app/src/main/java/com/orangesale/cn/service/TimeService.java b/chapter06_net/app/src/main/java/com/orangesale/cn/service/TimeService.java
new file mode 100644
index 0000000..c062d3f
--- /dev/null
+++ b/chapter06_net/app/src/main/java/com/orangesale/cn/service/TimeService.java
@@ -0,0 +1,82 @@
+package com.orangesale.cn.service;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.os.IBinder;
+
+import androidx.annotation.Nullable;
+import androidx.core.app.NotificationCompat;
+
+import com.orangesale.cn.R;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class TimeService extends Service {
+ private static Timer timer = null;
+ private NotificationManager manager;
+ private NotificationCompat.Builder builder;
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ /**
+ * 清除通知
+ */
+ private void cleanAllNotification() {
+ manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ manager.cancelAll();
+ if (timer != null) {
+ timer.cancel();
+ timer = null;
+ }
+
+ }
+
+ /**
+ * 添加通知
+ */
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ long period = 60 * 1000; //1分钟一个周期
+ if (timer == null) {
+ timer = new Timer();
+ }
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ /**
+ * NotificationChannel是android8.0新增的特性,如果App的targetSDKVersion>=26,
+ * 没有设置channel通知渠道的话,就会导致通知无法展示。
+ * 报错内容:Failed to post notification on channel “null”
+ */
+ NotificationChannel channel = new NotificationChannel("channel", "通知", NotificationManager.IMPORTANCE_DEFAULT);
+ manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ manager.createNotificationChannel(channel);
+ builder = new NotificationCompat.Builder(TimeService.this);
+ builder.setContentTitle("提醒系统当前时间");
+ builder.setSmallIcon(R.drawable.chengzi);
+ builder.setChannelId("channel");
+ Date date = new Date();
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ builder.setContentText("系统当前时间为:" + formatter.format(date));
+ builder.setAutoCancel(true);
+ builder.setDefaults(Notification.DEFAULT_ALL);
+ Notification notification = builder.build();
+ manager.notify(1, notification);
+
+ }
+ }, 0, period);
+
+ return super.onStartCommand(intent, flags, startId);
+ }
+}
diff --git a/chapter03_fragment/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/chapter06_net/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
rename to chapter06_net/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
diff --git a/chapter03_fragment/app/src/main/res/drawable/address.png b/chapter06_net/app/src/main/res/drawable/address.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/address.png
rename to chapter06_net/app/src/main/res/drawable/address.png
diff --git a/chapter06_net/app/src/main/res/drawable/all.png b/chapter06_net/app/src/main/res/drawable/all.png
new file mode 100644
index 0000000..131c4fd
Binary files /dev/null and b/chapter06_net/app/src/main/res/drawable/all.png differ
diff --git a/chapter04_sqlite/app/src/main/res/drawable/apple.png b/chapter06_net/app/src/main/res/drawable/apple.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/apple.png
rename to chapter06_net/app/src/main/res/drawable/apple.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/applep.png b/chapter06_net/app/src/main/res/drawable/applep.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/applep.png
rename to chapter06_net/app/src/main/res/drawable/applep.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/arrow_down.png b/chapter06_net/app/src/main/res/drawable/arrow_down.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/arrow_down.png
rename to chapter06_net/app/src/main/res/drawable/arrow_down.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/arrow_left.png b/chapter06_net/app/src/main/res/drawable/arrow_left.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/arrow_left.png
rename to chapter06_net/app/src/main/res/drawable/arrow_left.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/arrow_right.png b/chapter06_net/app/src/main/res/drawable/arrow_right.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/arrow_right.png
rename to chapter06_net/app/src/main/res/drawable/arrow_right.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/button_login.xml b/chapter06_net/app/src/main/res/drawable/button_login.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/button_login.xml
rename to chapter06_net/app/src/main/res/drawable/button_login.xml
diff --git a/chapter03_fragment/app/src/main/res/drawable/button_register.xml b/chapter06_net/app/src/main/res/drawable/button_register.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/button_register.xml
rename to chapter06_net/app/src/main/res/drawable/button_register.xml
diff --git a/chapter06_net/app/src/main/res/drawable/cart.png b/chapter06_net/app/src/main/res/drawable/cart.png
new file mode 100644
index 0000000..f2e1190
Binary files /dev/null and b/chapter06_net/app/src/main/res/drawable/cart.png differ
diff --git a/chapter03_fragment/app/src/main/res/drawable/chengzi.png b/chapter06_net/app/src/main/res/drawable/chengzi.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/chengzi.png
rename to chapter06_net/app/src/main/res/drawable/chengzi.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/city.png b/chapter06_net/app/src/main/res/drawable/city.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/city.png
rename to chapter06_net/app/src/main/res/drawable/city.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/ic_launcher_background.xml b/chapter06_net/app/src/main/res/drawable/ic_launcher_background.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/ic_launcher_background.xml
rename to chapter06_net/app/src/main/res/drawable/ic_launcher_background.xml
diff --git a/chapter04_sqlite/app/src/main/res/drawable/index.png b/chapter06_net/app/src/main/res/drawable/index.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/index.png
rename to chapter06_net/app/src/main/res/drawable/index.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/index_menu.xml b/chapter06_net/app/src/main/res/drawable/index_menu.xml
old mode 100755
new mode 100644
similarity index 94%
rename from chapter04_sqlite/app/src/main/res/drawable/index_menu.xml
rename to chapter06_net/app/src/main/res/drawable/index_menu.xml
index f56bc61..14636dd
--- a/chapter04_sqlite/app/src/main/res/drawable/index_menu.xml
+++ b/chapter06_net/app/src/main/res/drawable/index_menu.xml
@@ -1,16 +1,16 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter03_fragment/app/src/main/res/drawable/juzi.png b/chapter06_net/app/src/main/res/drawable/juzi.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/juzi.png
rename to chapter06_net/app/src/main/res/drawable/juzi.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/juzip.png b/chapter06_net/app/src/main/res/drawable/juzip.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/juzip.png
rename to chapter06_net/app/src/main/res/drawable/juzip.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/lemon.png b/chapter06_net/app/src/main/res/drawable/lemon.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/lemon.png
rename to chapter06_net/app/src/main/res/drawable/lemon.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/lemonp.png b/chapter06_net/app/src/main/res/drawable/lemonp.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/lemonp.png
rename to chapter06_net/app/src/main/res/drawable/lemonp.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/li.png b/chapter06_net/app/src/main/res/drawable/li.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/li.png
rename to chapter06_net/app/src/main/res/drawable/li.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/mangguo.png b/chapter06_net/app/src/main/res/drawable/mangguo.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/mangguo.png
rename to chapter06_net/app/src/main/res/drawable/mangguo.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/orange.png b/chapter06_net/app/src/main/res/drawable/orange.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/orange.png
rename to chapter06_net/app/src/main/res/drawable/orange.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/password.png b/chapter06_net/app/src/main/res/drawable/password.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/password.png
rename to chapter06_net/app/src/main/res/drawable/password.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/pearson.png b/chapter06_net/app/src/main/res/drawable/pearson.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/pearson.png
rename to chapter06_net/app/src/main/res/drawable/pearson.png
diff --git a/chapter06_net/app/src/main/res/drawable/price.png b/chapter06_net/app/src/main/res/drawable/price.png
new file mode 100644
index 0000000..c7a125c
Binary files /dev/null and b/chapter06_net/app/src/main/res/drawable/price.png differ
diff --git a/chapter04_sqlite/app/src/main/res/drawable/product.png b/chapter06_net/app/src/main/res/drawable/product.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/product.png
rename to chapter06_net/app/src/main/res/drawable/product.png
diff --git a/chapter06_net/app/src/main/res/drawable/salenum.png b/chapter06_net/app/src/main/res/drawable/salenum.png
new file mode 100644
index 0000000..87ed2c9
Binary files /dev/null and b/chapter06_net/app/src/main/res/drawable/salenum.png differ
diff --git a/chapter03_fragment/app/src/main/res/drawable/search.png b/chapter06_net/app/src/main/res/drawable/search.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/search.png
rename to chapter06_net/app/src/main/res/drawable/search.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/setting.png b/chapter06_net/app/src/main/res/drawable/setting.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/setting.png
rename to chapter06_net/app/src/main/res/drawable/setting.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/sex.png b/chapter06_net/app/src/main/res/drawable/sex.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/sex.png
rename to chapter06_net/app/src/main/res/drawable/sex.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/shoppingcart.png b/chapter06_net/app/src/main/res/drawable/shoppingcart.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/shoppingcart.png
rename to chapter06_net/app/src/main/res/drawable/shoppingcart.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/shuiguo.png b/chapter06_net/app/src/main/res/drawable/shuiguo.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/shuiguo.png
rename to chapter06_net/app/src/main/res/drawable/shuiguo.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/spinner_drop_down_shape.xml b/chapter06_net/app/src/main/res/drawable/spinner_drop_down_shape.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/spinner_drop_down_shape.xml
rename to chapter06_net/app/src/main/res/drawable/spinner_drop_down_shape.xml
diff --git a/chapter03_fragment/app/src/main/res/drawable/sure_apssword.png b/chapter06_net/app/src/main/res/drawable/sure_apssword.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/sure_apssword.png
rename to chapter06_net/app/src/main/res/drawable/sure_apssword.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/tab_menu_text.xml b/chapter06_net/app/src/main/res/drawable/tab_menu_text.xml
old mode 100755
new mode 100644
similarity index 93%
rename from chapter04_sqlite/app/src/main/res/drawable/tab_menu_text.xml
rename to chapter06_net/app/src/main/res/drawable/tab_menu_text.xml
index ff3a059..fb06945
--- a/chapter04_sqlite/app/src/main/res/drawable/tab_menu_text.xml
+++ b/chapter06_net/app/src/main/res/drawable/tab_menu_text.xml
@@ -1,5 +1,5 @@
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/chapter06_net/app/src/main/res/drawable/time.png b/chapter06_net/app/src/main/res/drawable/time.png
new file mode 100644
index 0000000..8a672eb
Binary files /dev/null and b/chapter06_net/app/src/main/res/drawable/time.png differ
diff --git a/chapter03_fragment/app/src/main/res/drawable/user.png b/chapter06_net/app/src/main/res/drawable/user.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/user.png
rename to chapter06_net/app/src/main/res/drawable/user.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/user_account.png b/chapter06_net/app/src/main/res/drawable/user_account.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/user_account.png
rename to chapter06_net/app/src/main/res/drawable/user_account.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/user_general.png b/chapter06_net/app/src/main/res/drawable/user_general.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/user_general.png
rename to chapter06_net/app/src/main/res/drawable/user_general.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/user_icon.png b/chapter06_net/app/src/main/res/drawable/user_icon.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/user_icon.png
rename to chapter06_net/app/src/main/res/drawable/user_icon.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/user_pay.png b/chapter06_net/app/src/main/res/drawable/user_pay.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/user_pay.png
rename to chapter06_net/app/src/main/res/drawable/user_pay.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/user_sex.png b/chapter06_net/app/src/main/res/drawable/user_sex.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/user_sex.png
rename to chapter06_net/app/src/main/res/drawable/user_sex.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/xigua.png b/chapter06_net/app/src/main/res/drawable/xigua.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/xigua.png
rename to chapter06_net/app/src/main/res/drawable/xigua.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/xiguap.png b/chapter06_net/app/src/main/res/drawable/xiguap.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/xiguap.png
rename to chapter06_net/app/src/main/res/drawable/xiguap.png
diff --git a/chapter03_fragment/app/src/main/res/drawable/youzi.png b/chapter06_net/app/src/main/res/drawable/youzi.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/drawable/youzi.png
rename to chapter06_net/app/src/main/res/drawable/youzi.png
diff --git a/chapter04_sqlite/app/src/main/res/drawable/youzip.png b/chapter06_net/app/src/main/res/drawable/youzip.png
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/app/src/main/res/drawable/youzip.png
rename to chapter06_net/app/src/main/res/drawable/youzip.png
diff --git a/chapter04_sqlite/app/src/main/res/layout/activity_main.xml b/chapter06_net/app/src/main/res/layout/activity_main.xml
old mode 100755
new mode 100644
similarity index 95%
rename from chapter04_sqlite/app/src/main/res/layout/activity_main.xml
rename to chapter06_net/app/src/main/res/layout/activity_main.xml
index 8efbc79..dfe67c8
--- a/chapter04_sqlite/app/src/main/res/layout/activity_main.xml
+++ b/chapter06_net/app/src/main/res/layout/activity_main.xml
@@ -1,29 +1,29 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter04_sqlite/app/src/main/res/layout/category_list_item.xml b/chapter06_net/app/src/main/res/layout/cart_have_product.xml
old mode 100755
new mode 100644
similarity index 62%
rename from chapter04_sqlite/app/src/main/res/layout/category_list_item.xml
rename to chapter06_net/app/src/main/res/layout/cart_have_product.xml
index 09e87d8..b7362e4
--- a/chapter04_sqlite/app/src/main/res/layout/category_list_item.xml
+++ b/chapter06_net/app/src/main/res/layout/cart_have_product.xml
@@ -1,14 +1,15 @@
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter06_net/app/src/main/res/layout/cart_no_product.xml b/chapter06_net/app/src/main/res/layout/cart_no_product.xml
new file mode 100644
index 0000000..ff8c14c
--- /dev/null
+++ b/chapter06_net/app/src/main/res/layout/cart_no_product.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter03_fragment/app/src/main/res/layout/category_detail.xml b/chapter06_net/app/src/main/res/layout/category_detail.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/layout/category_detail.xml
rename to chapter06_net/app/src/main/res/layout/category_detail.xml
diff --git a/chapter03_fragment/app/src/main/res/layout/category_list_item.xml b/chapter06_net/app/src/main/res/layout/category_list_item.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/layout/category_list_item.xml
rename to chapter06_net/app/src/main/res/layout/category_list_item.xml
diff --git a/chapter04_sqlite/app/src/main/res/layout/categoty_detail_content.xml b/chapter06_net/app/src/main/res/layout/categoty_detail_content.xml
old mode 100755
new mode 100644
similarity index 96%
rename from chapter04_sqlite/app/src/main/res/layout/categoty_detail_content.xml
rename to chapter06_net/app/src/main/res/layout/categoty_detail_content.xml
index b3972c2..2b3a24f
--- a/chapter04_sqlite/app/src/main/res/layout/categoty_detail_content.xml
+++ b/chapter06_net/app/src/main/res/layout/categoty_detail_content.xml
@@ -1,32 +1,32 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter06_net/app/src/main/res/layout/content_category.xml b/chapter06_net/app/src/main/res/layout/content_category.xml
new file mode 100644
index 0000000..8c5aee2
--- /dev/null
+++ b/chapter06_net/app/src/main/res/layout/content_category.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter04_sqlite/app/src/main/res/layout/content_index.xml b/chapter06_net/app/src/main/res/layout/content_index.xml
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/app/src/main/res/layout/content_index.xml
rename to chapter06_net/app/src/main/res/layout/content_index.xml
index d935945..7fa926d
--- a/chapter04_sqlite/app/src/main/res/layout/content_index.xml
+++ b/chapter06_net/app/src/main/res/layout/content_index.xml
@@ -1,221 +1,221 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter04_sqlite/app/src/main/res/layout/content_nav.xml b/chapter06_net/app/src/main/res/layout/content_nav.xml
old mode 100755
new mode 100644
similarity index 96%
rename from chapter04_sqlite/app/src/main/res/layout/content_nav.xml
rename to chapter06_net/app/src/main/res/layout/content_nav.xml
index 4c54af1..d406b9a
--- a/chapter04_sqlite/app/src/main/res/layout/content_nav.xml
+++ b/chapter06_net/app/src/main/res/layout/content_nav.xml
@@ -1,118 +1,119 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter06_net/app/src/main/res/layout/content_product.xml b/chapter06_net/app/src/main/res/layout/content_product.xml
new file mode 100644
index 0000000..35c06c7
--- /dev/null
+++ b/chapter06_net/app/src/main/res/layout/content_product.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter03_fragment/app/src/main/res/layout/content_category.xml b/chapter06_net/app/src/main/res/layout/content_product_title.xml
similarity index 55%
rename from chapter03_fragment/app/src/main/res/layout/content_category.xml
rename to chapter06_net/app/src/main/res/layout/content_product_title.xml
index 440633f..d9f5a7c 100644
--- a/chapter03_fragment/app/src/main/res/layout/content_category.xml
+++ b/chapter06_net/app/src/main/res/layout/content_product_title.xml
@@ -1,15 +1,14 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/chapter03_fragment/app/src/main/res/layout/content_user.xml b/chapter06_net/app/src/main/res/layout/content_user.xml
similarity index 90%
rename from chapter03_fragment/app/src/main/res/layout/content_user.xml
rename to chapter06_net/app/src/main/res/layout/content_user.xml
index fa429d8..3266d28 100644
--- a/chapter03_fragment/app/src/main/res/layout/content_user.xml
+++ b/chapter06_net/app/src/main/res/layout/content_user.xml
@@ -23,14 +23,14 @@
android:orientation="horizontal">
@@ -52,14 +52,14 @@
@@ -82,15 +82,15 @@
@@ -141,14 +141,14 @@
android:orientation="horizontal">
@@ -160,7 +160,7 @@
-
+
@@ -224,7 +224,7 @@
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="18sp"
- android:layout_marginTop="150dp"
+ android:layout_marginTop="90dp"
android:text="退出登录"
android:textColor="#FFFFFF"
android:layout_gravity="center"
diff --git a/chapter04_sqlite/app/src/main/res/layout/index_famous.xml b/chapter06_net/app/src/main/res/layout/index_famous.xml
old mode 100755
new mode 100644
similarity index 96%
rename from chapter04_sqlite/app/src/main/res/layout/index_famous.xml
rename to chapter06_net/app/src/main/res/layout/index_famous.xml
index e0ab56b..b884b44
--- a/chapter04_sqlite/app/src/main/res/layout/index_famous.xml
+++ b/chapter06_net/app/src/main/res/layout/index_famous.xml
@@ -1,55 +1,55 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter06_net/app/src/main/res/layout/product_condition_item.xml b/chapter06_net/app/src/main/res/layout/product_condition_item.xml
new file mode 100644
index 0000000..27dd56d
--- /dev/null
+++ b/chapter06_net/app/src/main/res/layout/product_condition_item.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter06_net/app/src/main/res/layout/shopping_cart_product.xml b/chapter06_net/app/src/main/res/layout/shopping_cart_product.xml
new file mode 100644
index 0000000..55543e4
--- /dev/null
+++ b/chapter06_net/app/src/main/res/layout/shopping_cart_product.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter04_sqlite/app/src/main/res/layout/content_category.xml b/chapter06_net/app/src/main/res/layout/shoppingcart_title.xml
old mode 100755
new mode 100644
similarity index 51%
rename from chapter04_sqlite/app/src/main/res/layout/content_category.xml
rename to chapter06_net/app/src/main/res/layout/shoppingcart_title.xml
index 7c73e75..f23f741
--- a/chapter04_sqlite/app/src/main/res/layout/content_category.xml
+++ b/chapter06_net/app/src/main/res/layout/shoppingcart_title.xml
@@ -1,52 +1,32 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chapter03_fragment/app/src/main/res/layout/user_login.xml b/chapter06_net/app/src/main/res/layout/user_login.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/layout/user_login.xml
rename to chapter06_net/app/src/main/res/layout/user_login.xml
diff --git a/chapter03_fragment/app/src/main/res/layout/user_register.xml b/chapter06_net/app/src/main/res/layout/user_register.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/layout/user_register.xml
rename to chapter06_net/app/src/main/res/layout/user_register.xml
diff --git a/chapter03_fragment/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/chapter06_net/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
rename to chapter06_net/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
diff --git a/chapter03_fragment/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/chapter06_net/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
rename to chapter06_net/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
diff --git a/chapter03_fragment/app/src/main/res/mipmap-hdpi/ic_launcher.png b/chapter06_net/app/src/main/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-hdpi/ic_launcher.png
rename to chapter06_net/app/src/main/res/mipmap-hdpi/ic_launcher.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/chapter06_net/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
rename to chapter06_net/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-mdpi/ic_launcher.png b/chapter06_net/app/src/main/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-mdpi/ic_launcher.png
rename to chapter06_net/app/src/main/res/mipmap-mdpi/ic_launcher.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/chapter06_net/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
rename to chapter06_net/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/chapter06_net/app/src/main/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-xhdpi/ic_launcher.png
rename to chapter06_net/app/src/main/res/mipmap-xhdpi/ic_launcher.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/chapter06_net/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
rename to chapter06_net/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/chapter06_net/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
rename to chapter06_net/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/chapter06_net/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
rename to chapter06_net/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/chapter06_net/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
rename to chapter06_net/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
diff --git a/chapter03_fragment/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/chapter06_net/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
similarity index 100%
rename from chapter03_fragment/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
rename to chapter06_net/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
diff --git a/chapter03_fragment/app/src/main/res/values/colors.xml b/chapter06_net/app/src/main/res/values/colors.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/values/colors.xml
rename to chapter06_net/app/src/main/res/values/colors.xml
diff --git a/chapter03_fragment/app/src/main/res/values/strings.xml b/chapter06_net/app/src/main/res/values/strings.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/values/strings.xml
rename to chapter06_net/app/src/main/res/values/strings.xml
diff --git a/chapter03_fragment/app/src/main/res/values/styles.xml b/chapter06_net/app/src/main/res/values/styles.xml
similarity index 100%
rename from chapter03_fragment/app/src/main/res/values/styles.xml
rename to chapter06_net/app/src/main/res/values/styles.xml
diff --git a/chapter03_fragment/app/src/test/java/com/orangesale/cn/ExampleUnitTest.java b/chapter06_net/app/src/test/java/com/orangesale/cn/ExampleUnitTest.java
similarity index 100%
rename from chapter03_fragment/app/src/test/java/com/orangesale/cn/ExampleUnitTest.java
rename to chapter06_net/app/src/test/java/com/orangesale/cn/ExampleUnitTest.java
diff --git a/chapter04_sqlite/build.gradle b/chapter06_net/build.gradle
old mode 100755
new mode 100644
similarity index 95%
rename from chapter04_sqlite/build.gradle
rename to chapter06_net/build.gradle
index 69cab14..fb516be
--- a/chapter04_sqlite/build.gradle
+++ b/chapter06_net/build.gradle
@@ -1,27 +1,27 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- repositories {
- google()
- jcenter()
-
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.5.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- google()
- jcenter()
-
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ google()
+ jcenter()
+
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.5.2'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/chapter04_sqlite/gradle.properties b/chapter06_net/gradle.properties
old mode 100755
new mode 100644
similarity index 98%
rename from chapter04_sqlite/gradle.properties
rename to chapter06_net/gradle.properties
index 55f37b3..199d16e
--- a/chapter04_sqlite/gradle.properties
+++ b/chapter06_net/gradle.properties
@@ -1,20 +1,20 @@
-# Project-wide Gradle settings.
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx1536m
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-# AndroidX package structure to make it clearer which packages are bundled with the
-# Android operating system, and which are packaged with your app's APK
-# https://developer.android.com/topic/libraries/support-library/androidx-rn
-android.useAndroidX=true
-# Automatically convert third-party libraries to use AndroidX
-android.enableJetifier=true
-
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true
+
diff --git a/chapter04_sqlite/gradle/wrapper/gradle-wrapper.jar b/chapter06_net/gradle/wrapper/gradle-wrapper.jar
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/gradle/wrapper/gradle-wrapper.jar
rename to chapter06_net/gradle/wrapper/gradle-wrapper.jar
diff --git a/chapter04_sqlite/gradle/wrapper/gradle-wrapper.properties b/chapter06_net/gradle/wrapper/gradle-wrapper.properties
old mode 100755
new mode 100644
similarity index 97%
rename from chapter04_sqlite/gradle/wrapper/gradle-wrapper.properties
rename to chapter06_net/gradle/wrapper/gradle-wrapper.properties
index 60decb6..7aeb00b
--- a/chapter04_sqlite/gradle/wrapper/gradle-wrapper.properties
+++ b/chapter06_net/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Dec 06 17:33:43 CST 2019
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+#Fri Dec 06 17:33:43 CST 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/chapter04_sqlite/gradlew b/chapter06_net/gradlew
old mode 100755
new mode 100644
similarity index 100%
rename from chapter04_sqlite/gradlew
rename to chapter06_net/gradlew
diff --git a/chapter04_sqlite/gradlew.bat b/chapter06_net/gradlew.bat
old mode 100755
new mode 100644
similarity index 96%
rename from chapter04_sqlite/gradlew.bat
rename to chapter06_net/gradlew.bat
index e95643d..f955316
--- a/chapter04_sqlite/gradlew.bat
+++ b/chapter06_net/gradlew.bat
@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/chapter04_sqlite/settings.gradle b/chapter06_net/settings.gradle
old mode 100755
new mode 100644
similarity index 95%
rename from chapter04_sqlite/settings.gradle
rename to chapter06_net/settings.gradle
index 3effc47..96b534d
--- a/chapter04_sqlite/settings.gradle
+++ b/chapter06_net/settings.gradle
@@ -1,2 +1,2 @@
-include ':app'
-rootProject.name='orangesale'
+include ':app'
+rootProject.name='orangesale'