Compare commits

...

1 Commits
master ... main

Author SHA1 Message Date
manxyr fceeeb23c5 补充 2024-06-18 00:27:13 +08:00
8 changed files with 21 additions and 21 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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)

View File

@ -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().

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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();
}