diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/AfterLoginMyFragment.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/AfterLoginMyFragment.java index 84f1dbb..6e86cbd 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/AfterLoginMyFragment.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/AfterLoginMyFragment.java @@ -1,7 +1,9 @@ package com.hnucm.c202201020207; +import android.content.Intent; import android.os.Bundle; +import androidx.constraintlayout.widget.ConstraintLayout; import androidx.fragment.app.Fragment; import android.provider.ContactsContract; @@ -27,6 +29,15 @@ public class AfterLoginMyFragment extends Fragment { .load(url) .apply(RequestOptions.bitmapTransform(new CircleCrop())) .into(headimg); + + ConstraintLayout settingLayout=view.findViewById(R.id.settingLayout); + settingLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent=new Intent(getActivity(), SettingActivity.class); + startActivity(intent); + } + }); return view; } } \ No newline at end of file diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/CommunityFragment.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/CommunityFragment.java index 89671fb..fd47268 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/CommunityFragment.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/CommunityFragment.java @@ -47,13 +47,12 @@ public class CommunityFragment extends Fragment { recyclerView2=view.findViewById(R.id.recyclerView13); recyclerView3=view.findViewById(R.id.recyclerView14); -// SmartRefreshLayout smartRefreshLayout=view.findViewById(R.id.smartLayout1); -// smartRefreshLayout.setRefreshFooter(new ClassicsFooter(getActivity())); - + //垂直滚动 MyAdapter1 myAdapter1=new MyAdapter1(); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setAdapter(myAdapter1); + //水平滚动 MyAdapter2 myAdapter2=new MyAdapter2(); LinearLayoutManager layoutManager2 = new LinearLayoutManager(getActivity()); layoutManager2.setOrientation(RecyclerView.HORIZONTAL); diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/HomePageActivity.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/HomePageActivity.java index dfac058..618c83a 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/HomePageActivity.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/HomePageActivity.java @@ -147,12 +147,9 @@ public class HomePageActivity extends AppCompatActivity { textView4.setTextColor(Color.parseColor("#8a8a8a")); textView2.setTextColor(Color.parseColor("#8a8a8a")); -// getSupportFragmentManager().beginTransaction() -// .show(myFragment).hide(homePageFragment).hide(communityFragment).hide(consultationFragment).hide(mallFragment) -// .commit(); - Intent intent=getIntent(); Boolean islogin=intent.getBooleanExtra("islogin",false); + //登录后切换MyFragment为AfterLoginMyFragment if (islogin){ getSupportFragmentManager().beginTransaction() .show(afterLoginMyFragment) diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MallFragment.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MallFragment.java index d91074c..fa2c379 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MallFragment.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MallFragment.java @@ -18,6 +18,7 @@ import com.bumptech.glide.load.resource.bitmap.CircleCrop; import com.bumptech.glide.request.RequestOptions; public class MallFragment extends Fragment { + //Fragment嵌套 TopPicksFragment topPicksFragment=new TopPicksFragment(); GlucometerFragment glucometerFragment=new GlucometerFragment(); RelatedDrugFragment relatedDrugFragment=new RelatedDrugFragment(); @@ -81,6 +82,7 @@ public class MallFragment extends Fragment { .apply(RequestOptions.bitmapTransform(new CircleCrop())) .into(imageView4); + //嵌套Fragment,管理ChildFragment事务 getChildFragmentManager().beginTransaction(). add(R.id.LayoutReplace,topPicksFragment).commit(); getChildFragmentManager().beginTransaction(). diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MyFragment.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MyFragment.java index 196f81a..9acdeec 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MyFragment.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/MyFragment.java @@ -26,14 +26,8 @@ public class MyFragment extends Fragment { Bundle savedInstanceState) { View view=inflater.inflate(R.layout.fragment_my, container, false); - ConstraintLayout layout=view.findViewById(R.id.headLayout); - ImageView imageView=view.findViewById(R.id.imageView10); TextView loginView=view.findViewById(R.id.textView14); ConstraintLayout settingLayout=view.findViewById(R.id.settingLayout); -// Glide.with(this) -// .load(getResources().getDrawable(R.drawable.ic_launcher_foreground)) -// .apply(RequestOptions.bitmapTransform(new CircleCrop())) -// .into(imageView); loginView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/PopularSciencePopularizationFragment.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/PopularSciencePopularizationFragment.java index 31aa17d..26f160c 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/PopularSciencePopularizationFragment.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/PopularSciencePopularizationFragment.java @@ -50,6 +50,7 @@ public class PopularSciencePopularizationFragment extends Fragment { recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView2.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView3.setLayoutManager(new LinearLayoutManager(getActivity())); + //多个MyAdapter,丰富界面item样式 recyclerView.setAdapter(myAdapter1); recyclerView2.setAdapter(myAdapter2); recyclerView3.setAdapter(myAdapter3); diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/TopPicksFragment.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/TopPicksFragment.java index a7cb345..a2b77be 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/TopPicksFragment.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/TopPicksFragment.java @@ -46,6 +46,7 @@ public class TopPicksFragment extends Fragment { Bundle savedInstanceState) { View view=inflater.inflate(R.layout.fragment_top_picks,container, false); + //设置头尾刷新 SmartRefreshLayout smartRefreshLayout=view.findViewById(R.id.smartRefreshLayout1); smartRefreshLayout.setRefreshHeader(new ClassicsHeader(getActivity())); smartRefreshLayout.setRefreshFooter(new ClassicsFooter(getActivity())); @@ -54,7 +55,6 @@ public class TopPicksFragment extends Fragment { myAdapter=new MyAdapter(); recyclerView.setAdapter(myAdapter); GridLayoutManager layoutManager = new GridLayoutManager(getActivity(),2); -// layoutManager.setOrientation(RecyclerView.HORIZONTAL); 也能设置横向滚动 recyclerView.setLayoutManager(layoutManager); Api api=RetrofitUtils.getRetrofit("https://dev.usemock.com/66544d5fe80629674af4c3d9/").create(Api.class); @@ -119,6 +119,7 @@ public class TopPicksFragment extends Fragment { holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + //RecyclerView中Item的传值,跳转到商品详情界面 Intent intent=new Intent(getActivity(), GoodDetailsActivity.class); intent.putExtra("imgurl",selected.image); intent.putExtra("title",selected.title); diff --git a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/VideoActivity.java b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/VideoActivity.java index 52b58e9..4bbb030 100644 --- a/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/VideoActivity.java +++ b/Diabetes_Health_Management/app/src/main/java/com/hnucm/c202201020207/VideoActivity.java @@ -45,7 +45,6 @@ public class VideoActivity extends AppCompatActivity { // 设置视频源 videoView.setVideoPath(url); - // 设置SeekBar的监听器 seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override @@ -55,7 +54,6 @@ public class VideoActivity extends AppCompatActivity { videoView.seekTo(progress); } } - @Override public void onStartTrackingTouch(SeekBar seekBar) { // 用户开始拖动SeekBar @@ -66,14 +64,13 @@ public class VideoActivity extends AppCompatActivity { // 用户停止拖动SeekBar } }); - + //视频进度条 // 设置视频播放准备完成的监听器 videoView.setOnPreparedListener(mediaPlayer -> { // 获取视频总时长,并设置SeekBar的最大值 int duration = mediaPlayer.getDuration(); seekBar.setMax(duration); - - // 设置周期性更新SeekBar的进度 + // 设置周期性更新SeekBar的进度, new Handler().post(new Runnable() { @Override public void run() { @@ -85,8 +82,6 @@ public class VideoActivity extends AppCompatActivity { } }); }); - - // 开始播放视频 videoView.start(); }