diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 97507d1..75a512d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -4,6 +4,9 @@ + + + - \ No newline at end of file + diff --git a/app/src/main/java/com/example/myapplication/FindFragment.java b/app/src/main/java/com/example/myapplication/FindFragment.java new file mode 100644 index 0000000..e49ec91 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/FindFragment.java @@ -0,0 +1,64 @@ +package com.example.myapplication; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link FindFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class FindFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public FindFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment FindFragment. + */ + // TODO: Rename and change types and number of parameters + public static FindFragment newInstance(String param1, String param2) { + FindFragment fragment = new FindFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_find, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/HomeFragment.java b/app/src/main/java/com/example/myapplication/HomeFragment.java new file mode 100644 index 0000000..260fa4d --- /dev/null +++ b/app/src/main/java/com/example/myapplication/HomeFragment.java @@ -0,0 +1,19 @@ +package com.example.myapplication; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class HomeFragment extends Fragment { + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_home, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/MainActivity.java b/app/src/main/java/com/example/myapplication/MainActivity.java index c35c7e4..5ed0f83 100644 --- a/app/src/main/java/com/example/myapplication/MainActivity.java +++ b/app/src/main/java/com/example/myapplication/MainActivity.java @@ -3,13 +3,14 @@ package com.example.myapplication; import androidx.appcompat.app.AppCompatActivity; -import com.example.myapplication.RetrofitUtils; +import com.example.myapplication.Utils.RetrofitUtils; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.View; +import android.widget.EditText; import android.widget.Toast; import com.example.myapplication.dao.LoginResult; @@ -27,12 +28,25 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + + //初始化 EditText + EditText editText = findViewById(R.id.editTextText); + EditText editText1 = findViewById(R.id.editTextTextPassword); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + String username = editText.getText().toString().trim(); + String password = editText1.getText().toString().trim(); + + if (username.isEmpty() || password.isEmpty()){ + Toast.makeText(MainActivity.this, "用户名密码不能为空!", Toast.LENGTH_SHORT).show(); + return; + } + Map map = new HashMap<>(); - map.put("username", "admin"); - map.put("password", "admin123"); + map.put("username", username); + map.put("password", password); + Call loginResultCall = RetrofitUtils.getRetrofit("http://10.138.77.128:8080/").create(Api.class).login(map); loginResultCall.enqueue(new Callback() { @Override @@ -42,7 +56,7 @@ public class MainActivity extends AppCompatActivity { SharedPreferences.Editor editor = getSharedPreferences("data", MODE_PRIVATE).edit(); editor.putString("token", loginResult.token); editor.apply(); - Intent intent = new Intent(MainActivity.this, HomeActivity.class); + Intent intent = new Intent(MainActivity.this, yindaoActivity.class); startActivity(intent); }else { Toast.makeText(MainActivity.this,loginResult.msg, Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/java/com/example/myapplication/MineFragment.java b/app/src/main/java/com/example/myapplication/MineFragment.java new file mode 100644 index 0000000..7abdbb1 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/MineFragment.java @@ -0,0 +1,64 @@ +package com.example.myapplication; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link MineFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class MineFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public MineFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment MineFragment. + */ + // TODO: Rename and change types and number of parameters + public static MineFragment newInstance(String param1, String param2) { + MineFragment fragment = new MineFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_mine, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java b/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java new file mode 100644 index 0000000..945b963 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/ShoppingTrolleyFragment.java @@ -0,0 +1,64 @@ +package com.example.myapplication; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link ShoppingTrolleyFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class ShoppingTrolleyFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public ShoppingTrolleyFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment ShoppingTrolleyFragment. + */ + // TODO: Rename and change types and number of parameters + public static ShoppingTrolleyFragment newInstance(String param1, String param2) { + ShoppingTrolleyFragment fragment = new ShoppingTrolleyFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_shopping_trolley, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/RetrofitUtils.java b/app/src/main/java/com/example/myapplication/Utils/RetrofitUtils.java similarity index 98% rename from app/src/main/java/com/example/myapplication/RetrofitUtils.java rename to app/src/main/java/com/example/myapplication/Utils/RetrofitUtils.java index 014d7bd..1e07167 100644 --- a/app/src/main/java/com/example/myapplication/RetrofitUtils.java +++ b/app/src/main/java/com/example/myapplication/Utils/RetrofitUtils.java @@ -1,4 +1,4 @@ -package com.example.myapplication; +package com.example.myapplication.Utils; import android.util.Log; diff --git a/app/src/main/java/com/example/myapplication/VipFragment.java b/app/src/main/java/com/example/myapplication/VipFragment.java new file mode 100644 index 0000000..13aabc5 --- /dev/null +++ b/app/src/main/java/com/example/myapplication/VipFragment.java @@ -0,0 +1,64 @@ +package com.example.myapplication; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link VipFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class VipFragment extends Fragment { + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public VipFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment VipFragment. + */ + // TODO: Rename and change types and number of parameters + public static VipFragment newInstance(String param1, String param2) { + VipFragment fragment = new VipFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_vip, container, false); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/HomeActivity.java b/app/src/main/java/com/example/myapplication/yindaoActivity.java similarity index 68% rename from app/src/main/java/com/example/myapplication/HomeActivity.java rename to app/src/main/java/com/example/myapplication/yindaoActivity.java index 3a78a0b..aa9280b 100644 --- a/app/src/main/java/com/example/myapplication/HomeActivity.java +++ b/app/src/main/java/com/example/myapplication/yindaoActivity.java @@ -4,11 +4,11 @@ import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -public class HomeActivity extends AppCompatActivity { +public class yindaoActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_home); + setContentView(R.layout.activity_yindao); } } \ No newline at end of file diff --git a/app/src/main/res/drawable/shuiguoshop.png b/app/src/main/res/drawable/shuiguoshop.png new file mode 100644 index 0000000..1646563 Binary files /dev/null and b/app/src/main/res/drawable/shuiguoshop.png differ diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml deleted file mode 100644 index 43ae9ba..0000000 --- a/app/src/main/res/layout/activity_home.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index a1880f9..4eaf538 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -38,7 +38,7 @@ android:id="@+id/textView" android:layout_width="119dp" android:layout_height="37dp" - android:layout_marginStart="36dp" + android:layout_marginStart="24dp" android:layout_marginTop="300dp" android:gravity="center" android:text="用户名" @@ -51,7 +51,7 @@ android:id="@+id/textView2" android:layout_width="119dp" android:layout_height="37dp" - android:layout_marginStart="36dp" + android:layout_marginStart="24dp" android:layout_marginTop="39dp" android:gravity="center" android:text="密码" diff --git a/app/src/main/res/layout/activity_yindao.xml b/app/src/main/res/layout/activity_yindao.xml new file mode 100644 index 0000000..878c605 --- /dev/null +++ b/app/src/main/res/layout/activity_yindao.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_find.xml b/app/src/main/res/layout/fragment_find.xml new file mode 100644 index 0000000..d960b58 --- /dev/null +++ b/app/src/main/res/layout/fragment_find.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml new file mode 100644 index 0000000..adacaa4 --- /dev/null +++ b/app/src/main/res/layout/fragment_home.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_mine.xml b/app/src/main/res/layout/fragment_mine.xml new file mode 100644 index 0000000..7291d63 --- /dev/null +++ b/app/src/main/res/layout/fragment_mine.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_shopping_trolley.xml b/app/src/main/res/layout/fragment_shopping_trolley.xml new file mode 100644 index 0000000..ff9d659 --- /dev/null +++ b/app/src/main/res/layout/fragment_shopping_trolley.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_vip.xml b/app/src/main/res/layout/fragment_vip.xml new file mode 100644 index 0000000..c512611 --- /dev/null +++ b/app/src/main/res/layout/fragment_vip.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3de1a39..4cacd0f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,5 @@ My Application + + Hello blank fragment \ No newline at end of file