免登录刷视频功能

master
FinalJcsp 2 years ago
parent 43f96491ae
commit 6ec43d1783

@ -0,0 +1 @@
AndroidTermWork

@ -2,9 +2,15 @@
<project version="4">
<component name="DBNavigator.Project.DataEditorManager">
<record-view-column-sorting-type value="BY_INDEX" />
<value-preview-text-wrapping value="true" />
<value-preview-text-wrapping value="false" />
<value-preview-pinned value="false" />
</component>
<component name="DBNavigator.Project.DatabaseBrowserManager">
<autoscroll-to-editor value="false" />
<autoscroll-from-editor value="true" />
<show-object-properties value="true" />
<loaded-nodes />
</component>
<component name="DBNavigator.Project.DatabaseEditorStateManager">
<last-used-providers />
</component>

@ -12,6 +12,6 @@
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-05-29T04:56:35.121693200Z" />
<timeTargetWasSelectedWithDropDown value="2023-06-07T08:15:29.077476100Z" />
</component>
</project>

@ -9,7 +9,7 @@
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="jbr-11" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="jbr-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/android_final" vcs="Git" />
</component>
</project>

@ -25,6 +25,12 @@ android {
}
dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
//noinspection GradleCompatible
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation "com.squareup.retrofit2:retrofit:2.8.1"
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
@ -33,6 +39,7 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.androidtermwork">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@ -9,11 +10,11 @@
android:allowBackup="true"
android:icon="@mipmap/appicon"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/iconcirred"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="n">
<activity
android:name=".ChatActivity"
@ -36,6 +37,15 @@
<activity
android:name=".Activity4"
android:exported="false" />
<activity
android:name="com.example.androidtermwork.video.MainActivityVideo"
android:exported="false" />
<activity
android:name="com.example.androidtermwork.video.ArticleActivity"
android:exported="false" />
<activity
android:name="com.example.androidtermwork.video.PersonActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:theme="@style/RedTheme" />

@ -34,6 +34,8 @@ import android.widget.TextView;
import android.widget.Toast;
import com.example.androidtermwork.util.StatusBarUtil;
import com.example.androidtermwork.video.MainActivityVideo;
@RequiresApi(api = Build.VERSION_CODES.M)
public class LoginPage extends AppCompatActivity {
private AlertDialog.Builder builder;
@ -76,6 +78,8 @@ public class LoginPage extends AppCompatActivity {
OnButtonToLogin();
//注册
OnButtonToRegister();
//视频
OnButtonToVideo();
//初始化页面底部可点击文本
initView();
//密码显示或隐藏
@ -215,6 +219,17 @@ public class LoginPage extends AppCompatActivity {
});
}
public void OnButtonToVideo() {
Button regis = findViewById(R.id.video);
regis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginPage.this, MainActivityVideo.class);
startActivity(intent);
}
});
}
//初始化页面底部可点击文本
public void initView() {

@ -0,0 +1,140 @@
package com.example.androidtermwork.ui.dashboard;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.example.androidtermwork.R;
import com.example.androidtermwork.webView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class VideoNews {
public String title;
public String resource;
public String title2;
public String time;
public String article;
public String editor;
public VideoNews(String title, String resource, String title2, String time, String article, String editor) {
this.title = title;
this.resource = resource;
this.title2 = title2;
this.time = time;
this.article = article;
this.editor = editor;
}
}
public class VideoArticlesFragment extends Fragment {
public static List<News> newLists = Arrays.asList(
new News("中国共产党第十九届中央委员会第六次全体会议公报",
"“学习强国”学习平台",
"中国共产党第十九届中央委员会第六次全体会议公报2021年11月11日中国共产党第十九届中央委员会第六次全体会议通过",
"2021-11-12",
"中国共产党第十九届中央委员会第六次全体会议于2021年11月8日至11日在北京举行。\\n' +\n" +
" '出席这次全会的有中央委员197人候补中央委员151人。中央纪律检查委员会常务委员会委员和有关方面负责同志列席会议。\\n' +\n" +
" '全会由中央政治局主持。中央委员会总书记习近平作了重要讲话。\\n' +\n" +
" '全会听取和讨论了习近平受中央政治局委托作的工作报告,审议通过了《中共中央关于党的百年奋斗重大成就和历史经验的决议》,审议通过了《关于召开党的第二十次全国代表大会的决议》。习近平就《中共中央关于党的百年奋斗重大成就和历史经验的决议(讨论稿)》向全会作了说明。\\n' +\n" +
" '全会认为,总结党的百年奋斗重大成就和历史经验,是在建党百年历史条件下开启全面建设社会主义现代化国家新征程、在新时代坚持和发展中国特色社会主义的需要;是增强政治意识、大局意识、核心意识、看齐意识,坚定道路自信、理论自信、制度自信、文化自信,做到坚决维护习近平同志党中央的核心、全党的核心地位,坚决维护党中央权威和集中统一领导,确保全党步调一致向前进的需要;是推进党的自我革命、提高全党斗争本领和应对风险挑战能力、永葆党的生机活力、团结带领全国各族人民为实现中华民族伟大复兴的中国梦而继续奋斗的需要。全党要坚持唯物史观和正确党史观,从党的百年奋斗中看清楚过去我们为什么能够成功、弄明白未来我们怎样才能继续成功,从而更加坚定、更加自觉地践行初心使命,在新时代更好坚持和发展中国特色社会主义。",
"秦辰宇"),
new News("习近平主持召开中央政治局会议 分析研究2022年经济工作", "“学习强国”学习平台",
"征求对经济工作的意见和建议\n" +
"\n" +
"中共中央召开党外人士座谈会\n" +
"\n" +
"习近平主持并发表重要讲话\n" +
"\n" +
"李克强通报有关情况 汪洋王沪宁韩正出席",
"2021-12-06",
"新华社北京12月6日电 12月2日中共中央在中南海召开党外人士座谈会就今年经济形势和明年经济工作听取各民主党派中央、全国工商联负责人和无党派人士代表的意见和建议。中共中央总书记习近平主持座谈会并发表重要讲话强调要全面贯彻落实中共十九届六中全会精神重温多党合作的历程和作用发扬光荣传统坚守合作初心围绕宏观政策要稳健有效、微观政策要激发市场主体活力、改革开放政策要增强发展动力、社会政策要兜住民生底线积极履行职能加强自身建设引导广大成员和所联系群众把会议精神转化为共同奋斗的政治共识在全面建设社会主义现代化国家新征程中继续团结奋斗。\n" +
"\n" +
"座谈会上,民革中央主席万鄂湘、民盟中央主席丁仲礼、民建中央主席郝明金、民进中央主席蔡达峰、农工党中央主席陈竺、致公党中央常务副主席蒋作君、九三学社中央主席武维华、台盟中央主席苏辉、全国工商联主席高云龙、无党派人士代表宇如聪先后发言。他们完全赞同中共中央对当前我国经济形势的分析判断和明年经济工作的谋划考虑,并就加强宏观调控、提升政策效能,改善进出口结构、促进内外贸一体化,提高生产制造装备水平、加快我国高端制造业发展,健全人口服务体系、激发内需增长潜力,完善我国疫情防控策略、为稳增长打牢扎实基础,强化法治保障和政策引领、科学有序推进“双碳”目标,转变涉企财税支持方式、提高财政收入质量,加强农村生态环境治理、夯实乡村振兴基础,加大改革力度、助力推进共同富裕,强化中小企业发展政策导向和可持续发展能力,发挥民企在促进共同富裕中积极作用,完善科技领域“揭榜挂帅”工作机制,加快推动省际交界地区协同发展等提出意见建议。",
"张秋兰"),
new News("习近平主持党外人士座谈会并发表重要讲话", "“学习强国”学习平台",
"",
"2021-12-06",
"", "张玙蕗"),
new News("国家主席习近平任免驻外大使", "“学习强国”学习平台",
"",
"2021-12-03",
"", "齐翼"),
new News("习近平向“2021从都国际论坛”开幕式发表视频致辞",
"“学习强国”学习平台",
"",
"2021-12-05",
"", "秦辰宇"),
new News("习近平同老挝人民革命党中央总书记、国家主席通伦共同出席中老铁路通车仪式",
"“学习强国”学习平台",
"",
"2021-12-03",
"", "胡佳"),
new News("习近平向中国-拉共体论坛第三届部长会议发表视频致辞",
"“学习强国”学习平台",
"",
"2021-12-03",
"", "齐翼"),
new News("习近平出席全国宗教工作会议并发表重要讲话",
"“学习强国”学习平台",
"",
"2021-12-04",
"", "秦辰宇"));
private DashboardViewModel dashboardViewModel;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// dashboardViewModel =
// ViewModelProviders.of(this).get(DashboardViewModel.class);
View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
final ListView listView = root.findViewById(R.id.newsList);
// dashboardViewModel.getText().observe(this, new Observer<String>() {
// @Override
// public void onChanged(@Nullable String s) {
// }
// });
updateListView(listView);
return root;
}
public void updateListView(ListView listView) {
final List<Map<String, Object>> listItem = new ArrayList<>();
for (int i = 0; i < newLists.size(); i++) {
Map<String, Object> tempMap = new HashMap<>();
tempMap.put("title", newLists.get(i).title);
tempMap.put("resource", newLists.get(i).resource + newLists.get(i).time);
listItem.add(tempMap);
}
SimpleAdapter mAdapter = new SimpleAdapter(getActivity(), listItem, R.layout.news_list_item, new String[]{"title", "resource"}, new int[]{R.id.title, R.id.resource});
listView.setAdapter(mAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
//跳转页面,显示详细信息
Intent intent = new Intent(getActivity(), webView.class);
Bundle bundle = new Bundle();
bundle.putString("title", newLists.get(i).title);
bundle.putString("resource", newLists.get(i).resource);
bundle.putString("title2", newLists.get(i).title2);
bundle.putString("time", newLists.get(i).time);
bundle.putString("article", newLists.get(i).article);
bundle.putString("editor", newLists.get(i).editor);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}

@ -0,0 +1,165 @@
package com.example.androidtermwork.video;
import static android.content.pm.PackageManager.PERMISSION_DENIED;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.example.androidtermwork.R;
import java.io.File;
import java.util.Locale;
public class AddFragment extends Fragment {
private View main_view;
private static String TAG = "XXL";
private String[] permissionsArray = new String[]{
Manifest.permission.CAMERA, //相机权限
Manifest.permission.WRITE_EXTERNAL_STORAGE, //写外部文件
Manifest.permission.READ_EXTERNAL_STORAGE, //读外部文件
Manifest.permission.RECORD_AUDIO //音频录制
};
private int REQUEST_CODE = 277;
private int REQUEST_CAMERA = 305;
private File videoPath;
private Boolean permissionOK = false;
private LinearLayout camera;
private LinearLayout upload;
private TextView regis;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// main_view = inflater.inflate(R.layout.article, container, false);
main_view = inflater.inflate(R.layout.video_articles, container, false);
regis = main_view.findViewById(R.id.article_title_1);
// OnButtonToVideo();
// camera = main_view.findViewById(R.id.shoot_layout);
// upload = main_view.findViewById(R.id.local_layout);
//
// //1、第一件事获取或者验证用户本地文件读写权限和摄像头权限
// if(!checkPermissionAllGranted(permissionsArray)){
// requestPermissions(permissionsArray, REQUEST_CODE);
// }else{
// permissionOK = true;
// }
//
// camera.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if(permissionOK)
// openSystemCamera();
// else {
// Toast.makeText(getActivity(), "请您先授权",Toast.LENGTH_SHORT).show();
// requestPermissions(permissionsArray, REQUEST_CODE);
// if(permissionOK)
// openSystemCamera();
// }
// }
// });
// upload.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Toast.makeText(getActivity(), "系统正在维护,敬请期待",Toast.LENGTH_SHORT).show();
// }
// });
return main_view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
System.out.println("ddddd" + isAdded());
if (isAdded()) {
regis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//
System.out.println("dddddddddddddddddddddddddddd");
startActivity(new Intent(getActivity(), ArticleActivity.class));
}
});
}
}
// 设置点击事件监听器
public void OnButtonToVideo() {
// regis.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
//// inflater.inflate(R.layout.video_articles, container, false);
// }
// });
}
/*
*/
private void openSystemCamera() {
Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
String videoName = String.format(Locale.getDefault(), "video_%d.mp4", System.currentTimeMillis());
videoPath = new File(getActivity().getExternalCacheDir(), videoName);
Uri outUri = FileProvider.getUriForFile(getActivity(), getActivity().getPackageName() + ".fileprovider", videoPath);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outUri);
startActivityForResult(cameraIntent, REQUEST_CAMERA); //跳转相机拍摄activity
}
private boolean checkPermissionAllGranted(String[] permissions) {
for (String permission : permissions) {
if (getActivity().checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
// 只要有一个权限没有被授予, 则直接返回 false
return false;
}
}
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CODE) {
Log.d(TAG, "权限申请回调");
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] == PERMISSION_DENIED)
return;
}
permissionOK = true;
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "拍摄完毕返回AddFragment");
}
}

@ -0,0 +1,19 @@
package com.example.androidtermwork.video;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import com.example.androidtermwork.R;
public class ArticleActivity extends AppCompatActivity {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.article);
}
}

@ -0,0 +1,220 @@
package com.example.androidtermwork.video;
import android.app.Person;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.example.androidtermwork.LoginPage;
import com.example.androidtermwork.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import java.util.ArrayList;
import java.util.List;
/*
ViewPager2
*/
public class MainActivityVideo extends AppCompatActivity {
private ViewPager2 pager2;
private BottomNavigationView bottomNavigationView;
private List<Fragment> fragments;
private MyFragmentAdapter adapter;
// private List<VideoBean> videos; //消息列表
// private String baseUrl = "https://beiyou.bytedance.com/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
OnButtonToVideo();
OnImageToVideo();
bottomNavigationView = findViewById(R.id.bnv);
//监听事件底部按钮和pager同步
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.item_home:
pager2.setCurrentItem(0);
break;
case R.id.item_add:
pager2.setCurrentItem(1);
break;
case R.id.item_my:
pager2.setCurrentItem(2);
break;
}
return true; //返回值决定是否被选中
}
});
fragments = new ArrayList<Fragment>();
fragments.add(new ViewPagerFragment());
fragments.add(new AddFragment());
fragments.add(new MyInfoFragment());
pager2 = findViewById(R.id.vp2);
adapter = new MyFragmentAdapter(this);
pager2.setAdapter(adapter);
//监听事件底部按钮和pager同步
pager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
bottomNavigationView.getMenu().getItem(position).setChecked(true);
Log.d("XXL", "onPageSelected " + position);
}
@Override
public void onPageScrollStateChanged(int state) {
super.onPageScrollStateChanged(state);
}
});
// pager2.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
// @Override
// public void onViewAttachedToWindow(View v) {
// if(v.getId() == R.id.me)
// bottomNavigationView.getMenu().getItem(1).setChecked(true);
// else if(v.getId() == R.id.pager2)
// bottomNavigationView.getMenu().getItem(2).setChecked(true);
// }
// @Override
// public void onViewDetachedFromWindow(View v) {
//
// }
// });
/*
*/
// Log.d("XXL", "retrofit in");
// Retrofit retrofit = new Retrofit.Builder()
// .baseUrl(baseUrl)
// .addConverterFactory(GsonConverterFactory.create())
// .build();
// Log.d("XXL", "retrofit out");
// ApiService apiService = retrofit.create(ApiService.class);
// apiService.getArticles().enqueue(new Callback<List<VideoBean>>() {
// @Override
// public void onResponse(Call<List<VideoBean>> call, Response<List<VideoBean>> response) {
// if(response.body()!=null){
// videos = response.body(); //设置数据
// Log.d("XXL", "success "+videos.size());
// //网络请求是异步的,通知信息实现同步
// notifyDataReceive();
// }
// }
//
// @Override
// public void onFailure(Call<List<VideoBean>> call, Throwable t) {
// Log.d("retrofit", "response error"+t.getMessage());
// }
// });
}
// private void notifyDataReceive() {
// pager2 = findViewById(R.id.vp2);
// //设置pager2的滑动方向未垂直方向
// pager2.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
// adapter = new MyFragmentAdapter(this);
// pager2.setAdapter(adapter);
// }
// private class MyFragmentAdapter extends FragmentStateAdapter{
//
// public MyFragmentAdapter(@NonNull FragmentActivity fragmentActivity) {
// super(fragmentActivity);
// }
//
// @NonNull
// @Override
// public Fragment createFragment(int position) {
// return VideoFragment.newInstance(videos.get(position), position);
// }
//
//
// @Override
// public int getItemCount() {
// return videos.size();
// }
//
// }
public void OnButtonToVideo() {
Button regis = findViewById(R.id.personButton);
regis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivityVideo.this, PersonActivity.class);
startActivity(intent);
}
});
}
public void OnImageToVideo() {
ImageView regis = findViewById(R.id.support_image);
TextView supportNumber = findViewById(R.id.support_number);
regis.setOnClickListener(new View.OnClickListener() {
boolean isSupport = false;
@Override
public void onClick(View view) {
isSupport=!isSupport;
if(isSupport){
regis.setBackground(getDrawable(R.drawable.icon_support));
supportNumber.setText("1");
}else {
regis.setBackground(getDrawable(R.drawable.icon_un_support1));
supportNumber.setText("0");
}
}
});
}
/*
=========================================================
*/
private class MyFragmentAdapter extends FragmentStateAdapter {
public MyFragmentAdapter(@NonNull FragmentActivity fragmentActivity) {
super(fragmentActivity);
}
@NonNull
@Override
public Fragment createFragment(int position) {
return fragments.get(position);
}
@Override
public int getItemCount() {
return fragments.size();
}
}
}

@ -0,0 +1,23 @@
package com.example.androidtermwork.video;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.androidtermwork.R;
public class MyInfoFragment extends Fragment {
private View main_view;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
main_view = inflater.inflate(R.layout.fragment_me, container, false);
return main_view;
}
}

@ -0,0 +1,22 @@
package com.example.androidtermwork.video;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import com.example.androidtermwork.R;
import com.example.androidtermwork.util.StatusBarUtil;
public class PersonActivity extends AppCompatActivity {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.person);
}
}

@ -0,0 +1,241 @@
package com.example.androidtermwork.video;
import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.androidtermwork.R;
import com.example.androidtermwork.video.tool.VideoBean;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
public class VideoFragment extends Fragment implements View.OnClickListener{
private static String key = "XXL";
private static String POS = "POS";
private static String TAG = "XXL";
private VideoBean video;
private MediaPlayer player;
private SurfaceView view;
private ImageButton pause_btn;
private SeekBar bar;
private int curr_pos;
private Timer timer;
private TimerTask task;
private boolean isPrepared = false; //视频资源是否加载完成
private boolean flag = false; //设置flag当前主页
public static VideoFragment newInstance(VideoBean videoBean, int pos){
System.out.println("dddddd" + videoBean);
VideoFragment videoFragment = new VideoFragment();
Bundle args = new Bundle();
args.putSerializable(key, videoBean);
args.putInt(POS, pos);
videoFragment.setArguments(args);
return videoFragment;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_video, container, false);
Bundle args = getArguments();
System.out.println("ddddddddddddddddddddddddddddddd");
if (args != null) {
System.out.println(args);
video = (VideoBean) args.getSerializable(key);
System.out.println(video.getVideoUrl());
curr_pos = (int) args.get(POS);
TextView tv = v.findViewById(R.id.video_name);
tv.setText(video.getNickName());
TextView des = v.findViewById(R.id.description);
des.setText(video.getDescription());
// TextView like = v.findViewById(R.id.like_num);
// like.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Toast.makeText(getActivity(), "点赞维护中", Toast.LENGTH_SHORT).show();
// }
// });
// Log.d(TAG, "glide in");
// ImageView image = v.findViewById(R.id.Glide_image);
// Glide.with(getActivity())
// .load(Uri.parse(video.getVideoUrl().replace("http://","https://")))
// .into(image);
// image.setVisibility(View.INVISIBLE);
pause_btn = v.findViewById(R.id.video_pause);
pause_btn.setVisibility(View.INVISIBLE);
pause_btn.setOnClickListener(this);
playVideo(v);
addTimer(v);
}
return v;
}
/*
* */
private void addTimer(View v) {
bar = v.findViewById(R.id.percent);
bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
player.seekTo(seekBar.getProgress());
}
});
timer = new Timer();
task = new TimerTask() {
@Override
public void run() {
if(isPrepared && player.isPlaying())
bar.setProgress(player.getCurrentPosition());
// Log.d(TAG, "task "+ curr_pos + " " + player.getCurrentPosition());
}
};
timer.schedule(task, 0,500);
}
private void playVideo(View v) {
player = new MediaPlayer();
view = v.findViewById(R.id.media_view);
view.setOnClickListener(this);
SurfaceHolder h = view.getHolder();
h.addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
player.setDisplay(h); //设置播放的画布
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// holder.removeCallback(this);
}
});
Context context = getActivity();
try {
assert context != null;
// player.setDataSource(context, Uri.parse(video.getVideoUrl().replace("http://","https://")));
// TODO 设置数据源
player.setDataSource(context, Uri.parse(video.getVideoUrl()));
player.prepareAsync(); //异步prepare资源
} catch (IOException e) {
e.printStackTrace();
}
player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.d(TAG, "prepared " + curr_pos);
bar.setMax(mp.getDuration());
mp.setLooping(true);
isPrepared = true; //资源加载完毕
if(flag)
mp.start();
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
if(isPrepared) {
if (player.isPlaying())
player.stop();
player.release();
player = null;
}
if(timer!=null){
timer.cancel();
timer = null;
}
Log.d("XXL", curr_pos + " onDestroy");
}
@Override
public void onStart() {
super.onStart();
Log.d(TAG, curr_pos + " onStart");
// player.pause();
}
@Override
public void onStop() {
super.onStop();
Log.d(TAG, curr_pos + " onStop");
}
@Override
public void onResume() {
super.onResume();
flag = true;
if(isPrepared && !player.isPlaying()){
player.start();
pause_btn.setVisibility(View.INVISIBLE);
}
Log.d(TAG, curr_pos + " onResume");
}
@Override
public void onPause() {
super.onPause();
if(isPrepared && player.isPlaying()){
player.pause();
pause_btn.setVisibility(View.VISIBLE);
}
Log.d(TAG, curr_pos + " onPause");
}
/*
* */
@Override
public void onClick(View v) {
if(v.getId() == R.id.video_pause || v.getId() == R.id.media_view) {
if (player.isPlaying()) {
pause_btn.setVisibility(View.VISIBLE);
player.pause();
} else {
pause_btn.setVisibility(View.INVISIBLE);
player.start();
}
}
}
}

@ -0,0 +1,108 @@
package com.example.androidtermwork.video;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.example.androidtermwork.R;
import com.example.androidtermwork.video.tool.ApiService;
import com.example.androidtermwork.video.tool.VideoBean;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ViewPagerFragment extends Fragment {
private View main_view;
private List<VideoBean> videos; //消息列表
// private String baseUrl = "https://beiyou.bytedance.com/";
// TODO 更改BASE_URL
private String baseUrl = "https://www.finalc.cn/exam/";
private ViewPager2 pager2;
private MyFragmentAdapter adapter;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
main_view = inflater.inflate(R.layout.fragment_viewpager, container, false);
getDataFromNet();
return main_view;
}
private void getDataFromNet() {
/*
*/
Log.d("XXL", "retrofit in");
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.build();
Log.d("XXL", "retrofit out");
ApiService apiService = retrofit.create(ApiService.class);
apiService.getArticles().enqueue(new Callback<List<VideoBean>>() {
@Override
public void onResponse(Call<List<VideoBean>> call, Response<List<VideoBean>> response) {
if(response.body()!=null){
videos = response.body(); //设置数据
Log.d("XXL", "success "+videos.size());
//网络请求是异步的,通知信息实现同步
notifyDataReceive();
} else {
Log.d("XXL", call.toString());
Log.d("XXL", response.toString());
Log.d("XXL", "没有收到数据");
}
}
@Override
public void onFailure(Call<List<VideoBean>> call, Throwable t) {
Log.d("retrofit", "response error "+t.getMessage());
}
});
}
private void notifyDataReceive() {
pager2 = main_view.findViewById(R.id.pager2);
//设置pager2的滑动方向未垂直方向
pager2.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
// TODO 设置视频缓存
pager2.setOffscreenPageLimit(1);
adapter = new MyFragmentAdapter(this);
pager2.setAdapter(adapter);
}
private class MyFragmentAdapter extends FragmentStateAdapter {
public MyFragmentAdapter(@NonNull ViewPagerFragment fragmentActivity) {
super(fragmentActivity);
}
@NonNull
@Override
public Fragment createFragment(int position) {
return VideoFragment.newInstance(videos.get(position), position);
}
@Override
public int getItemCount() {
return videos.size();
}
}
}

@ -0,0 +1,14 @@
package com.example.androidtermwork.video.tool;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
public interface ApiService {
// https://beiyou.bytedance.com/api/invoke/video/invoke/video
// @GET("api/invoke/video/invoke/video")
@GET("1")
public Call<List<VideoBean>> getArticles();
}

@ -0,0 +1,57 @@
package com.example.androidtermwork.video.tool;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class VideoBean implements Serializable {
@SerializedName("feedurl")
private String videoUrl; //mp4的url
@SerializedName("nickname")
private String nickName; //视频名称
@SerializedName("description")
private String description; //描述
@SerializedName("likecount")
private int likeCount; //点赞数
@SerializedName("avatar")
private String avatar; //封面图片url
public VideoBean(String videoUrl, String nickName, String description, int likeCount, String avatar) {
this.videoUrl = videoUrl;
this.nickName = nickName;
this.description = description;
this.likeCount = likeCount;
this.avatar = avatar;
}
public String getNickName() {
return nickName;
}
public String getDescription() {
return description;
}
public int getLikeCount() {
return likeCount;
}
public String getAvatar() {
return avatar;
}
public String getVideoUrl() {
return videoUrl;
}
@Override
public String toString() {
return "VideoItem{" +
"videoUrl='" + videoUrl + '\'' +
", nickName='" + nickName + '\'' +
", description='" + description + '\'' +
", likeCount=" + likeCount +
", avatar='" + avatar + '\'' +
'}';
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#CCCCCC" />
<size android:width="12dp" android:height="12dp" />
</shape>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

@ -29,7 +29,7 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="475dp"
android:layout_marginTop="25dp"
android:padding="30dp">
@ -42,18 +42,18 @@
android:id="@+id/userPhone"
style="@style/login_input"
android:layout_below="@id/text1"
android:inputType="phone"
android:maxLength="11"
android:layout_marginTop="3dp"
android:hint="请输入手机号码" />
android:hint="请输入手机号码"
android:inputType="phone"
android:maxLength="11" />
<ImageView
android:id="@+id/del"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_margin="20dp"
android:layout_below="@id/text1"
android:layout_alignParentRight="true"
android:layout_margin="20dp"
android:src="@mipmap/clear"
android:visibility="gone" />
@ -67,17 +67,17 @@
android:id="@+id/userPassword"
style="@style/login_input"
android:layout_below="@id/text2"
android:hint="请输入密码"
android:inputType="textPassword"
android:maxLength="20"
android:hint="请输入密码" />
android:maxLength="20" />
<ImageView
android:id="@+id/imageView"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_margin="20dp"
android:layout_below="@id/text2"
android:layout_alignParentRight="true"/>
android:layout_alignParentRight="true"
android:layout_margin="20dp" />
<Button
android:id="@+id/submit"
@ -91,14 +91,20 @@
android:layout_below="@id/submit"
android:text="新用户注册" />
<Button
android:id="@+id/video"
style="@style/button_submit"
android:layout_below="@id/register"
android:text="免登录学习" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="20dp"
android:orientation="horizontal"
android:layout_gravity="center"
android:layout_marginTop="212dp"
android:layout_gravity="center">
android:orientation="horizontal">
<TextView
android:id="@+id/retrieve"
@ -119,12 +125,11 @@
android:id="@+id/loss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="20dp"
android:textSize="15sp"
android:text="账号挂失"/>
android:layout_weight="1"
android:text="账号挂失"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp2"
android:layout_width="match_parent"
android:layout_height="680dp"
android:background="@color/viewPager_background"></androidx.viewpager2.widget.ViewPager2>
<!-- <ListView-->
<!-- android:id="@+id/info"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="680dp"-->
<!-- />-->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv"
android:layout_width="match_parent"
android:layout_height="0dp"
app:itemBackground="@color/bottomNavigationView"
app:menu="@menu/menu" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="10dp"
android:layout_marginBottom="300dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="50dp"
android:layout_height="65dp"
android:layout_marginBottom="30dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/video_author_head_portrait"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerVertical="true"
android:src="@drawable/default_user_avatar" />
<Button
android:id="@+id/personButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
</Button>
</RelativeLayout>
<LinearLayout
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/support_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/icon_un_support1"
android:contentDescription="支持" />
<TextView
android:id="@+id/support_number"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:gravity="center"
android:text="0"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F5F5F5"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<!-- 文章标题 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="写在中国共产党成立100周年之际"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#333333"/>
<!-- 作者和时间 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="作者:"
android:textColor="#666666"
android:textSize="16sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任仲平"
android:textColor="#333333"
android:textSize="16sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 发布时间:"
android:textColor="#666666"
android:textSize="16sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-06-28"
android:textColor="#333333"
android:textSize="16sp"/>
</LinearLayout>
<!-- 文章内容 -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="一百年来我们党为民族谋复兴。中华民族以五千年传承不绝之文化卓然于世界。自1840年起却一路沉沦被迫签订了一系列不平等条约一幅列强争食的《时局图》就是写照“多屈辱啊多耻辱啊那时的中国是待宰的肥羊。”中国共产党带领亿万人民救国、兴国、富国、强国创造了世所罕见的经济快速发展奇迹和社会长期稳定奇迹书写下震撼世界的巨变。"
android:textColor="#333333"
android:textSize="18sp"
android:lineSpacingExtra="8dp"
android:paddingTop="16dp"/>
<!-- 图片1 -->
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/gcd"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_marginTop="16dp"/>
<!-- 图片2 -->
<!-- <ImageView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@drawable/bj"-->
<!-- android:scaleType="centerCrop"-->
<!-- android:adjustViewBounds="true"-->
<!-- android:layout_marginTop="16dp"/>-->
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/camera_background">
<!-- <ImageView-->
<!-- android:id="@+id/backImage"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="500dp"-->
<!-- android:text="@string/top_view"-->
<!-- android:src="@mipmap/zhou"-->
<!-- tools:ignore="MissingConstraints" />-->
<!-- <LinearLayout-->
<!-- android:id="@+id/shoot_layout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="60dp"-->
<!-- app:layout_constraintTop_toBottomOf="@id/backImage"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:layout_marginStart="20dp"-->
<!-- android:layout_marginEnd="20dp"-->
<!-- android:orientation="horizontal"-->
<!-- android:background="@color/camera_view"-->
<!-- tools:ignore="MissingConstraints">-->
<!-- <ImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_marginTop="12dp"-->
<!-- android:layout_marginStart="30dp"-->
<!-- android:src="@mipmap/camera"-->
<!-- android:layout_height="wrap_content"/>-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="10dp"-->
<!-- android:layout_marginTop="12dp"-->
<!-- android:text="拍摄"-->
<!-- android:textColor="@color/shoot"-->
<!-- android:textSize="30dp" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:id="@+id/local_layout"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="60dp"-->
<!-- app:layout_constraintTop_toBottomOf="@id/shoot_layout"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:layout_marginStart="20dp"-->
<!-- android:layout_marginEnd="20dp"-->
<!-- android:orientation="horizontal"-->
<!-- android:background="@color/camera_view"-->
<!-- tools:ignore="MissingConstraints">-->
<!-- <ImageView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_marginTop="12dp"-->
<!-- android:layout_marginStart="30dp"-->
<!-- android:src="@mipmap/upload"-->
<!-- android:layout_height="wrap_content"/>-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginStart="10dp"-->
<!-- android:layout_marginTop="12dp"-->
<!-- android:text="本地上传"-->
<!-- android:textColor="@color/shoot"-->
<!-- android:textSize="30dp" />-->
<!-- </LinearLayout>-->
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#8E8E8D">
<LinearLayout
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="MissingConstraints"
android:orientation="horizontal"
android:background="#DDDDDC">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/coffee"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:textSize="30dp"
android:text="广告位招租"
android:textColor="#000000"
tools:ignore="MissingConstraints" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toBottomOf="@id/item"
android:src="@mipmap/hanhan"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SurfaceView
android:id="@+id/media_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<ImageView
android:id="@+id/Glide_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/top_view"
android:visibility="invisible"
android:src="@mipmap/zhou"
tools:layout_editor_absoluteX="-115dp"
tools:layout_editor_absoluteY="35dp" />
<TextView
android:id="@+id/video_name"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/video_pause"
android:layout_width="63dp"
android:layout_height="54dp"
android:contentDescription="@string/pause"
android:src="@mipmap/pause"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/percent"
android:layout_marginBottom="20dp"
android:text="@string/app_name"
tools:ignore="MissingConstraints" />
<SeekBar
android:id="@+id/percent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
app:layout_constraintBottom_toBottomOf="parent"
tools:ignore="MissingConstraints" />
<!-- <GridLayout-->
<!-- android:id="@+id/grid_like"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintBottom_toTopOf="@id/percent"-->
<!-- android:layout_marginBottom="20dp"-->
<!-- app:layout_constraintRight_toLeftOf="@id/comments"-->
<!-- android:layout_marginStart="100dp"-->
<!-- android:orientation="vertical">-->
<!-- <ImageView-->
<!-- android:id="@+id/like"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:contentDescription="@string/like"-->
<!-- android:src="@mipmap/nice_2" />-->
<!-- <TextView-->
<!-- android:id="@+id/like_num"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:paddingStart="5dp"-->
<!-- android:text="520"-->
<!-- android:textAlignment="center"-->
<!-- tools:ignore="RtlSymmetry" />-->
<!-- </GridLayout>-->
<!-- <GridLayout-->
<!-- android:id="@+id/comments"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:layout_constraintBottom_toTopOf="@id/percent"-->
<!-- android:layout_marginBottom="20dp"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- android:layout_marginStart="10dp"-->
<!-- tools:ignore="MissingConstraints"-->
<!-- android:orientation="vertical">-->
<!-- <ImageView-->
<!-- android:id="@+id/comment"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:contentDescription="@string/comment"-->
<!-- android:src="@mipmap/comment"-->
<!-- tools:layout_editor_absoluteX="269dp"-->
<!-- tools:layout_editor_absoluteY="629dp" />-->
<!-- <TextView-->
<!-- android:id="@+id/comment_num"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="1314"-->
<!-- android:paddingStart="5dp"-->
<!-- android:textAlignment="center"-->
<!-- tools:ignore="RtlSymmetry" />-->
<!-- </GridLayout>-->
<!-- <ImageView-->
<!-- android:id="@+id/comment"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@mipmap/comment"-->
<!-- app:layout_constraintBottom_toBottomOf="@id/percent"-->
<!-- app:layout_constraintStart_toEndOf="@id/like"-->
<!-- android:layout_marginStart="20dp"-->
<!-- tools:ignore="MissingConstraints"-->
<!-- android:contentDescription="@string/comment" />-->
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/design_default_color_primary_dark">
</androidx.viewpager2.widget.ViewPager2>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,229 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0C0C0"
android:orientation="vertical"
android:paddingTop="100px">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginBottom="20dp"
android:background="#FFFFFF"
android:orientation="horizontal"
tools:ignore="MissingConstraints">
<ImageView
android:id="@+id/touxiang"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:src="@mipmap/avatar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/nickName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="学习强国小助手"
android:textColor="@color/black"
android:textSize="25sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/bt4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0.1dp"
android:layout_weight="0.3"
android:background="#FFFFFF"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="联系方式:"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="@+id/bt5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:background="#FFFFFF"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="1234567890"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/bt6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0.1dp"
android:layout_weight="0.3"
android:background="#FFFFFF"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="性别:"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="@+id/bt61"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="0.1dp"
android:layout_weight="0.8"
android:background="#FFFFFF"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="未知"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginBottom="0.1dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.3"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="地区:"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.8"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="湖南省"
android:textSize="18dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/bt10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="爱好:"
android:textSize="18dp"
android:textStyle="bold"
tools:ignore="DuplicateIds,RtlHardcoded" />
<TextView
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.8"
android:gravity="left"
android:paddingLeft="10px"
android:paddingTop="12dp"
android:text="湖南省"
android:textSize="18dp" />
</LinearLayout>
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2"
android:rowCount="1"
android:orientation="horizontal"
tools:ignore="MissingConstraints">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:src="@drawable/qg1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:src="@drawable/qg2" />
</GridLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content">-->
<!-- <ImageView-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:src="@drawable/qg1"></ImageView>-->
<!-- <ImageView-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:src="@drawable/qg2"></ImageView>-->
<!-- </LinearLayout>-->
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -9,6 +9,7 @@
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:background="#efefef" />
<TextView
android:id="@+id/taskName"
android:layout_width="wrap_content"

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
<androidx.cardview.widget.CardView
android:id="@+id/article_card_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardMaxElevation="8dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:contentPadding="8dp"
tools:ignore="ExtraText">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/article_title_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="写在中国共产党成立100周年之际"
android:textColor="@color/title_text"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/article_content_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2021-06-28"
android:textColor="@color/content_text" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/article_card_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardMaxElevation="8dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:contentPadding="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/article_title_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="传承红色精神"
android:textColor="@color/title_text"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/article_content_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2022-06-28"
android:textColor="@color/content_text" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -5,19 +5,25 @@
<item
android:id="@+id/navigation_home"
android:icon="@mipmap/message"
app:showAsAction="always"
android:title="@string/title_home" />
android:title="@string/title_home"
app:showAsAction="always" />
<item
android:id="@+id/navigation_dashboard"
android:icon="@mipmap/iconcir"
app:showAsAction="always"
android:title="" />
android:title=""
app:showAsAction="always" />
<item
android:id="@+id/navigation_notifications"
android:icon="@mipmap/broadcast"
app:showAsAction="always"
android:title="@string/title_notifications" />
android:title="@string/title_notifications"
app:showAsAction="always" />
<!-- <item-->
<!-- android:id="@+id/navigation_video"-->
<!-- android:icon="@mipmap/broadcast"-->
<!-- android:title="@string/title_notifications"-->
<!-- app:showAsAction="always" />-->
</menu>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/item_home"
android:icon="@mipmap/home_focus"
android:title="首页" />
<item
android:id="@+id/item_add"
android:icon="@mipmap/add"
android:title="拍摄" />
<item
android:id="@+id/item_my"
android:icon="@mipmap/my_unfocus"
android:title="我的" />
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

@ -22,4 +22,11 @@
android:name="com.example.androidtermwork.ui.notifications.NotificationsFragment"
android:label="@string/title_notifications"
tools:layout="@layout/fragment_notifications" />
<!-- <fragment-->
<!-- android:id="@+id/navigation_video"-->
<!-- android:name="com.example.androidtermwork.video."-->
<!-- android:label="@string/title_notifications"-->
<!-- tools:layout="@layout/fragment_notifications" />-->
</navigation>

@ -5,4 +5,16 @@
<color name="colorAccent">#D81B60</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="colorPrimary_video">#6200EE</color>
<color name="colorPrimaryDark_video">#3700B3</color>
<color name="colorAccent_video">#03DAC5</color>
<color name="viewPager_background">#F7F7FA</color>
<color name="bottomNavigationView">#CBCBD1</color>
<color name="camera_background">#353434</color>
<color name="camera_view">#4E4C4C</color>
<color name="shoot">#F7F7FA</color>
<color name="card_background">#FFCDD2</color>
<color name="title_text">#FF5252</color>
<color name="content_text">#212121</color>
<color name="divider">#BDBDBD</color>
</resources>

@ -2,4 +2,5 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="card_stroke_width">2dp</dimen>
</resources>

@ -4,4 +4,8 @@
<string name="title_home">强国通</string>
<string name="title_dashboard">学习</string>
<string name="title_notifications">电视台</string>
<string name="pause">pause_image_button</string>
<string name="top_view">加载封面图</string>
<string name="like">点赞</string>
<string name="comment">评论</string>
</resources>

@ -85,4 +85,5 @@
<style name="shadow">
<item name="android:background">@drawable/layer</item>
</style>
</resources>

Loading…
Cancel
Save