期末作页提交.3

master
xsl 2 years ago
parent 53fc6e92c8
commit 8e3d229048

13
.gitignore vendored

@ -0,0 +1,13 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,116 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetsSelectedWithDialog>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="emulator-5554" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetsSelectedWithDialog>
</component>
</project>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="corretto-11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

1
app/.gitignore vendored

@ -0,0 +1 @@
/build

@ -0,0 +1,39 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.myapplication10"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//noinspection GradleCompatible
implementation 'com.android.support:support-compat:25.1.1'
implementation 'com.daimajia.easing:library:2.0@aar'
implementation 'com.daimajia.androidanimations:library:2.3@aar'
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
implementation files('libs/xutils-2.6.14.jar')
//noinspection GradleCompatible
implementation 'com.android.support:design:28.0.0'
}

Binary file not shown.

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

@ -0,0 +1,27 @@
package com.example.myapplication10;
import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.myapplication10", appContext.getPackageName());
}
}

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.musicPlayer">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="听之"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service
android:name=".MusicService"
android:enabled="true"
android:exported="true"></service>
<activity android:name=".zuceActivity">
</activity>
<activity android:name=".login"></activity>
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:theme="@style/AppTheme">
</activity>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -0,0 +1,250 @@
package com.example.musicPlayer;
import android.content.ClipData;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.IBinder;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.view.menu.MenuView;
import androidx.core.view.GravityCompat;
import androidx.appcompat.app.ActionBarDrawerToggle;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.google.android.material.navigation.NavigationView;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener{
private com.example.musicPlayer.MusicService musicService;
private ListView news_list;
private List<Map<String,Object>>mData;
private ViewPager mViewPager;
private FragmentPagerAdapter mAdapter;
private List<Fragment> mFragment;
private LinearLayout mTabWechat;
private LinearLayout mTabFriend;
private LinearLayout mTabContact;
private TextView a;
private TextView b;
private ImageButton mImgWechat;
private ImageButton mImgFriend;
private ImageButton mImgContact;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.abc);
NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
initViews();
initEvents();
initDatas();
View headerView=navigationView.getHeaderView(0);//设置抽屉的用户名
TextView b=(TextView)headerView.findViewById(R.id.b);
SharedPreferences sp=getSharedPreferences("loginInfo", MODE_PRIVATE);
String userName=sp.getString("loginUserName",null);
b.setText(userName);
Intent mintent=new Intent(this,MusicService.class);
this.startService(mintent);
this.bindService(mintent,mSerConn, Context.BIND_AUTO_CREATE);
}
private void initViews(){ //初始化控件
mViewPager=(ViewPager)findViewById(R.id.id_viewpager);
mTabWechat=(LinearLayout)findViewById(R.id.id_tab_wechat);
mTabFriend=(LinearLayout)findViewById(R.id.id_tab_friend);
mTabContact=(LinearLayout)findViewById(R.id.id_tab_contact);
mImgWechat=(ImageButton)findViewById(R.id.id_tab_wechat_img);
mImgFriend=(ImageButton)findViewById(R.id.id_tab_friend_img);
mImgContact=(ImageButton)findViewById(R.id.id_tab_contact_img);
}
private void initEvents(){
mTabWechat.setOnClickListener(onClickListener);
mTabFriend.setOnClickListener(onClickListener);
mTabContact.setOnClickListener(onClickListener);
}
private void initDatas(){
mFragment=new ArrayList<>();
mFragment.add(new findFragment());
mFragment.add(new playingFragment());
mFragment.add(new loveFragment());
mAdapter=new FragmentPagerAdapter(getSupportFragmentManager()){ //viewPager的适配器
@Override
public Fragment getItem(int position) {
return mFragment.get(position);
}
@Override
public int getCount() {
return mFragment.size();
}
};
mViewPager.setAdapter(mAdapter);
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mViewPager.setCurrentItem(position);
resetImgs();
selectTab(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void selectTab(int i){
switch (i){
case 0:
mImgWechat.setImageResource(R.drawable.findon);
break;
case 1:
mImgFriend.setImageResource(R.drawable.playing);
break;
case 2:
mImgContact.setImageResource(R.drawable.into);
break;
}
mViewPager.setCurrentItem(i);
}
private void resetImgs(){
mImgWechat.setImageResource(R.drawable.findoff);
mImgFriend.setImageResource(R.drawable.pause);
mImgContact.setImageResource(R.drawable.leave);
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
View.OnClickListener onClickListener=new View.OnClickListener(){
@Override
public void onClick(View v) {
resetImgs();
switch(v.getId()){
case R.id.id_tab_wechat:
selectTab(0);
break;
case R.id.id_tab_friend:
selectTab(1);
break;
case R.id.id_tab_contact:
selectTab(2);
break;
}
}
};
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
final AlertDialog.Builder builder=new AlertDialog.Builder(this);
if (id == R.id.nav_zhuxiao) {
Intent intent1=new Intent(MainActivity.this,login.class);
finish();
startActivity(intent1);
// Handle the camera action
} else if (id == R.id.nav_tuichu) {
finish();
}else if (id == R.id.nav_find) {
selectTab(0);
}
else if (id == R.id.nav_playing) {
selectTab(1);
}else if (id == R.id.nav_mygedan) {
selectTab(2);
}
else if (id == R.id.nav_qiandao) {
builder.setTitle("消息提示").setMessage("您签到成功").setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
}
}).show();
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}

@ -0,0 +1,139 @@
package com.example.musicPlayer;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Binder;
import android.os.Environment;
import android.os.IBinder;
import android.util.Log;
import com.example.musicPlayer.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;
public class MusicService extends Service {
private MyBinder iBinder;
public MediaPlayer musicPlayer=new MediaPlayer();
public static int musicPosition;
public Uri uri;
private Timer timer;
public MusicService() {
}
public class MyBinder extends Binder {
MusicService getService(){
return MusicService.this;
}
}
@Override
public void onCreate() {
super.onCreate();
timer = new Timer();
}
//更新进度条
public void refreshSeekBar() {
timer.cancel();//timer定时给播放界面发送当前播放时间和进度
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (musicPlayer != null && musicPlayer.isPlaying()) {
int playedTime = musicPlayer.getCurrentPosition();
int duration = musicPlayer.getDuration();
Intent updateIntent = new Intent();
updateIntent.putExtra("playedTime", playedTime);
updateIntent.putExtra("duration", duration);
updateIntent.putExtra("progress", playedTime/duration);
updateIntent.setAction("action.updateplayedtime");
MusicService.this.sendBroadcast(updateIntent);
}
}
}, 0, 1000);
}
//从头开始播放一首歌
public void play(int uri) {
try {
if(musicPlayer.isPlaying()){
musicPlayer.stop();
}
else{
musicPosition = 0;
musicPlayer.reset();
musicPlayer=MediaPlayer.create(getApplicationContext(),uri);
musicPlayer.start();//开启音乐
musicPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
//播放完成发送播放下一首的广播请求
public void onCompletion(MediaPlayer arg0) {
Intent completeIntent = new Intent();
completeIntent.setAction("action.nextsong");
sendBroadcast(completeIntent);
Log.d("MusicService", "sendBroadcast");
}
});
}
}catch (NullPointerException e){
e.printStackTrace();
}
}
//暂停播放
public void pause() {
Log.d("MusicService", "pause");
musicPlayer.pause();
musicPosition = musicPlayer.getCurrentPosition();
timer.cancel();
}
// 获取当前进度
public int getCurrentProgress() {
if (musicPlayer != null & musicPlayer.isPlaying()) {
return musicPlayer.getCurrentPosition();
} else if (musicPlayer != null & (!musicPlayer.isPlaying())) {
return musicPlayer.getCurrentPosition();
}
return 0;
}
public void setPosition (int position) {
musicPlayer.seekTo(position);//重新设定播放进度
}
//继续播放
public void goPlay(){
int position = getCurrentProgress();
musicPlayer.seekTo(position);//设置当前MediaPlayer的播放位置单位是毫秒。
musicPlayer.start();
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
MyBinder ibinder=new MyBinder();
return ibinder;
}
@Override
public boolean onUnbind(Intent intent) {
return super.onUnbind(intent);
}
@Override
public void onDestroy() {
super.onDestroy();
if (musicPlayer != null) {
if (musicPlayer.isPlaying()) timer.cancel();
musicPlayer.stop();
musicPlayer.release();
}
}
}

@ -0,0 +1,24 @@
package com.example.musicPlayer;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent mainIntent=new Intent(SplashScreen.this,login.class);
startActivity(mainIntent);
finish();
}
},3000);
}
}

@ -0,0 +1,282 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.musicPlayer.R;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class SubFragment1 extends Fragment {
private ListView news_list;
private List<Map<String, Object>> mData;
private TextView sname, info;
private MusicService musicService;
private List<musicInfo> results;
private int id = 0;
DbUtils db;
public SubFragment1() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
private List<Map<String,Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("news_title", "在希望的田野上");
map.put("news_info", "中国广播合唱团、杨淑清 - 中华人民共和国国歌 珍藏版");
map.put("news_thumb", R.drawable.zaixiwangdetianyeshang);
map.put("url",R.raw.zaixiwangdetianyeshang);
list.add(map);
map = new HashMap<String,Object>();
map.put("news_title", "天耀中华");
map.put("news_info", "姚贝娜 - 2014年中央电视台春节联欢晚会");
map.put("news_thumb", R.drawable.tianyaozhonghua);
map.put("url",R.raw.tianyaozhonghua);
list.add(map);
map = new HashMap<String,Object>();
map.put("news_title", "我的战鹰绕着宝岛飞");
map.put("news_info", "韩召 - 我的战鹰绕着宝岛飞");
map.put("news_thumb", R.drawable.wodezhanyingraozhebaodaofei);
map.put("url",R.raw.wodezhanyingraozhebaodaofei);
list.add(map);
map = new HashMap<String, Object>();
map.put("news_title", "Die Internationale");
map.put("news_info", "Arbeit - Marx");
map.put("news_thumb", R.drawable.dieinternationale);
map.put("url",R.raw.dieinternationale);
list.add(map);
map = new HashMap<String, Object>();
map.put("news_title", "Песня о тревожной молодости");
map.put("news_info", "Стас Пьеха、Хор \"Пересвет\" - Песня о тревожной молодости");
map.put("news_thumb", R.drawable.gechangdongdangdeqingchun);
map.put("url",R.raw.gechangdongdangdeqingchun);
list.add(map);
return list;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_sub_fragment1, container, false);
news_list = (ListView) view.findViewById(R.id.news_list);
mData = getData();
DbUtils.DaoConfig config = new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db = DbUtils.create(config);
MyAdapter adapter = new MyAdapter(getActivity(), mData,results,db);
news_list.setAdapter(adapter);
try {
db.createTableIfNotExist(musicList.class);
}catch (Exception e){}
Intent mintent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(mintent,mSerConn,Context.BIND_AUTO_CREATE);
return view;
}
@Override
public void onResume() {
try {
List<musicInfo> results = db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter = new MyAdapter(getActivity(), mData, results, db);
news_list.setAdapter(adapter);
}catch (DbException e){
}
super.onResume();
}
public final class ViewHolder {
public ImageView news_thumb;
public TextView news_title;
public TextView news_info;
public ImageButton news_btn;
public ImageButton like;
}
public class MyAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context context;
private List<Map<String, Object>> data;
private List<musicInfo> results;
private Fragment fragment;//用于接收传递过来的Context对象
DbUtils db;
public MyAdapter(Context contaxt, List<Map<String, Object>> data,List<musicInfo> results,DbUtils db ){
this.context = contaxt;
this.data = data;
this.results=results;
this.db=db;
this.mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.listview1, null);
holder.news_thumb = (ImageView) convertView.findViewById(R.id.news_thumb);
holder.news_title = (TextView) convertView.findViewById(R.id.news_title);
holder.news_info = (TextView) convertView.findViewById(R.id.news_info);
holder.news_btn = (ImageButton) convertView.findViewById(R.id.news_btn);
holder.like = (ImageButton) convertView.findViewById(R.id.like);
convertView.setTag(holder);
} else {
holder = (SubFragment1.ViewHolder) convertView.getTag();
}
holder.news_thumb.setBackgroundResource((Integer) mData.get(position).get("news_thumb"));
holder.news_title.setText((String) mData.get(position).get("news_title"));
holder.news_info.setText((String) mData.get(position).get("news_info"));
holder.news_btn.setTag(position);
holder.like.setTag(position);
final ImageButton storeMusic = holder.like;
final TextView sname = holder.news_title;
final TextView info = holder.news_info;
//将歌曲列表存入表musicList
String gm=sname.getText().toString();
String gs=info.getText().toString();
Integer songuri=(Integer)mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
try {
if(db.findAll(Selector.from(musicList.class).where("songname", "=", gm)).isEmpty()) {
musicList l = new musicList(gm, gs, songuri, imguri);
db.save(l);
}
}catch (Exception e){}
try {
List<musicInfo> musicstored = db.findAll(Selector.from(musicInfo.class).where("songname", "=", sname.getText().toString()));
if(musicstored.isEmpty()){
holder.like.setImageResource(R.drawable.unlike);
}else {
holder.like.setImageResource(R.drawable.like);
}
}catch (Exception e){
}
holder.news_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchToPlay((Integer) mData.get(position).get("url"));
playMusic(position);
}
});
holder.like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
storeMusic.setImageResource(R.drawable.like);
try{
String songname=sname.getText().toString();
String singer=info.getText().toString();
Integer uri=(Integer) mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
Log.e("======",songname);
Log.e("======",singer);
if(db.findAll(Selector.from(musicInfo.class).where("songname", "=", songname)).isEmpty()){
musicInfo m=new musicInfo(songname,singer,uri,imguri);
db.save(m);
Log.e("======",songname);
Log.e("======",singer);
Toast.makeText(getActivity(),"收藏成功!",Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
}
}
});
return convertView;
}
public void playMusic(int position) {
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
musicService.play((Integer) mData.get(position).get("url"));
Log.e("________",mData.get(position).get("url").toString());
}
public void switchToPlay(Integer uri) {
Log.e("puturi",uri.toString());
Intent intent = new Intent();
intent.putExtra("uri", uri);
intent.setAction("updateSong");
getActivity().sendBroadcast(intent);
}
}
}

@ -0,0 +1,260 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.musicPlayer.R;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class SubFragment2 extends Fragment {
private ListView news_list;
private List<Map<String,Object>> mData;
private MusicService musicService;
private List<musicInfo> results;
private int id = 0;
DbUtils db;
public SubFragment2() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
private List<Map<String,Object>>getData(){
List<Map<String,Object>>list=new ArrayList<Map<String, Object>>();
Map<String,Object>map=new HashMap<String, Object>();
map.put("news_title","夏恋Ver2");
map.put("news_info","Delos - 夏恋Ver");
map.put("news_thumb", R.drawable.xialianver2);
map.put("url",R.raw.xialianver2);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","Ringtone (MetroGnome Remix)");
map.put("news_info","MetroGnome - Ringtone (MetroGnome Remix)");
map.put("news_thumb",R.drawable.ringtone);
map.put("url",R.raw.ringtone);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","Takeoff");
map.put("news_info","Adam Young - The Spirit of St. Louis");
map.put("news_thumb",R.drawable.takeoff);
map.put("url",R.raw.takeoff);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","武侯祠");
map.put("news_info","闫东炜、陸二胡 - 【现代民乐】天朝元素project-2016");
map.put("news_thumb",R.drawable.wuhouci);
map.put("url",R.raw.wuhouci);
list.add(map);
return list;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_sub_fragment2,container,false);
news_list=(ListView)view.findViewById(R.id.news_list);
mData=getData();
DbUtils.DaoConfig config = new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db = DbUtils.create(config);
MyAdapter adapter = new MyAdapter(getActivity(), mData,results,db);
news_list.setAdapter(adapter);
try {
db.createTableIfNotExist(musicList.class);
}catch (Exception e){}
Intent mintent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(mintent,mSerConn,Context.BIND_AUTO_CREATE);
return view;
}
@Override
public void onResume() {
try {
List<musicInfo> results = db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter = new MyAdapter(getActivity(), mData, results, db);
news_list.setAdapter(adapter);
}catch (DbException e){
}
super.onResume();
}
public final class ViewHolder{
public ImageView news_thumb;
public TextView news_title;
public TextView news_info;
public ImageButton news_btn;
public ImageButton like;
}
public class MyAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context context;
private List<Map<String,Object>> data;
private List<musicInfo> results;
DbUtils db;
private Fragment fragment;//用于接收传递过来的Context对象
public MyAdapter(Context contaxt, List<Map<String, Object>> data,List<musicInfo> results,DbUtils db ){
this.context = contaxt;
this.data = data;
this.results=results;
this.db=db;
this.mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
SubFragment2.ViewHolder holder=null;
if(convertView==null){
holder=new SubFragment2.ViewHolder();
convertView=mInflater.inflate(R.layout.listview1,null);
holder.news_thumb=(ImageView)convertView.findViewById(R.id.news_thumb);
holder.news_title=(TextView)convertView.findViewById(R.id.news_title);
holder.news_info=(TextView)convertView.findViewById(R.id.news_info);
holder.news_btn=(ImageButton)convertView.findViewById(R.id.news_btn);
holder.like=(ImageButton)convertView.findViewById(R.id.like);
convertView.setTag(holder);
}
else {
holder=(SubFragment2.ViewHolder)convertView.getTag();
}
holder.news_thumb.setBackgroundResource((Integer)mData.get(position).get("news_thumb"));
holder.news_title.setText((String)mData.get(position).get("news_title"));
holder.news_info.setText((String)mData.get(position).get("news_info"));
holder.news_btn.setTag(position);
holder.like.setTag(position);
final ImageButton storeMusic = holder.like;
final TextView sname = holder.news_title;
final TextView info = holder.news_info;
//将歌曲列表存入表musicList
String gm=sname.getText().toString();
String gs=info.getText().toString();
Integer songuri=(Integer)mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
try {
if(db.findAll(Selector.from(musicList.class).where("songname", "=", gm)).isEmpty()) {
musicList l = new musicList(gm, gs, songuri, imguri);
db.save(l);
}
}catch (Exception e){}
try {
List<musicInfo> musicstored = db.findAll(Selector.from(musicInfo.class).where("songname", "=", sname.getText().toString()));
if(musicstored.isEmpty()){
holder.like.setImageResource(R.drawable.unlike);
}else {
holder.like.setImageResource(R.drawable.like);
}
}catch (Exception e){
}
holder.news_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
playMusic(position);
switchToPlayActivity((Integer) mData.get(position).get("url"));
}
});
holder.like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
storeMusic.setImageResource(R.drawable.like);
Intent intent=new Intent(getActivity(),loveFragment.class);
try{
String songname=sname.getText().toString();
String singer=info.getText().toString();
Integer uri=(Integer) mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
Log.e("======",songname);
Log.e("======",singer);
if(db.findAll(Selector.from(musicInfo.class).where("songname", "=", songname)).isEmpty()){
musicInfo m=new musicInfo(songname,singer,uri,imguri);
db.save(m);
Log.e("======",songname);
Log.e("======",singer);
Toast.makeText(getActivity(),"收藏成功!",Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
}
}
});
return convertView;
}
}
public void playMusic(int position) {
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
musicService.play((Integer) mData.get(position).get("url"));
Log.e("________",mData.get(position).get("url").toString());
}
public void switchToPlayActivity(Integer uri) {
Log.e("puturi",uri.toString());
playingFragment fragment=new playingFragment();
Intent intent = new Intent();
intent.putExtra("uri", uri);
intent.setAction("updateSong");
getActivity().sendBroadcast(intent);
}
}

@ -0,0 +1,244 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.musicPlayer.R;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class SubFragment3 extends Fragment {
private ListView news_list;
private List<Map<String,Object>> mData;
private List<musicInfo> results;
private MusicService musicService;
private int id = 0;
DbUtils db;
public SubFragment3() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
private List<Map<String,Object>>getData(){
List<Map<String,Object>>list=new ArrayList<Map<String, Object>>();
Map<String,Object>map=new HashMap<String, Object>();
map.put("news_title","白鸟朝凤");
map.put("news_info","复州鼓乐团 - 国乐大典 第二季第九期");
map.put("news_thumb",R.drawable.bainiaochaofeng);
map.put("url",R.raw.bainiaochaofeng);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","敦煌");
map.put("news_info","女子十二乐坊 - 敦煌");
map.put("news_thumb",R.drawable.dunhuang);
map.put("url",R.raw.dunhuang);
list.add(map);
return list;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_sub_fragment3,container,false);
news_list=(ListView)view.findViewById(R.id.news_list);
mData = getData();
DbUtils.DaoConfig config = new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db = DbUtils.create(config);
MyAdapter adapter = new MyAdapter(getActivity(), mData,results,db);
news_list.setAdapter(adapter);
try {
db.createTableIfNotExist(musicList.class);
}catch (Exception e){}
Intent mintent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(mintent,mSerConn,Context.BIND_AUTO_CREATE);
return view;
}
@Override
public void onResume() {
try {
List<musicInfo> results = db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter = new MyAdapter(getActivity(), mData, results, db);
news_list.setAdapter(adapter);
}catch (DbException e){
}
super.onResume();
}
public final class ViewHolder{
public ImageView news_thumb;
public TextView news_title;
public TextView news_info;
public ImageButton news_btn;
public ImageButton like;
}
public class MyAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context context;
private List<musicInfo> results;
private List<Map<String,Object>> data;
DbUtils db;
private Fragment fragment;//用于接收传递过来的Context对象
public MyAdapter(Context contaxt, List<Map<String, Object>> data,List<musicInfo> results,DbUtils db ){
this.context = contaxt;
this.data = data;
this.results=results;
this.db=db;
this.mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
SubFragment3.ViewHolder holder=null;
if(convertView==null){
holder=new SubFragment3.ViewHolder();
convertView=mInflater.inflate(R.layout.listview1,null);
holder.news_thumb=(ImageView)convertView.findViewById(R.id.news_thumb);
holder.news_title=(TextView)convertView.findViewById(R.id.news_title);
holder.news_info=(TextView)convertView.findViewById(R.id.news_info);
holder.news_btn=(ImageButton)convertView.findViewById(R.id.news_btn);
holder.like=(ImageButton)convertView.findViewById(R.id.like);
convertView.setTag(holder);
}
else {
holder=(SubFragment3.ViewHolder)convertView.getTag();
}
holder.news_thumb.setBackgroundResource((Integer)mData.get(position).get("news_thumb"));
holder.news_title.setText((String)mData.get(position).get("news_title"));
holder.news_info.setText((String)mData.get(position).get("news_info"));
holder.news_btn.setTag(position);
holder.like.setTag(position);
final ImageButton storeMusic = holder.like;
final TextView sname = holder.news_title;
final TextView info = holder.news_info;
//将歌曲列表存入表musicList
String gm=sname.getText().toString();
String gs=info.getText().toString();
Integer songuri=(Integer)mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
try {
if(db.findAll(Selector.from(musicList.class).where("songname", "=", gm)).isEmpty()) {
musicList l = new musicList(gm, gs, songuri, imguri);
db.save(l);
}
}catch (Exception e){}
try {
List<musicInfo> musicstored = db.findAll(Selector.from(musicInfo.class).where("songname", "=", sname.getText().toString()));
if(musicstored.isEmpty()){
holder.like.setImageResource(R.drawable.unlike);
}else {
holder.like.setImageResource(R.drawable.like);
}
}catch (Exception e){
}
holder.news_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
playMusic(position);
switchToPlayActivity((Integer) mData.get(position).get("url"));
}
});
holder.like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
storeMusic.setImageResource(R.drawable.like);
Intent intent=new Intent(getActivity(),loveFragment.class);
try{
String songname=sname.getText().toString();
String singer=info.getText().toString();
Integer uri=(Integer) mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
Log.e("======",songname);
Log.e("======",singer);
if(db.findAll(Selector.from(musicInfo.class).where("songname", "=", songname)).isEmpty()){
musicInfo m=new musicInfo(songname,singer,uri,imguri);
db.save(m);
Log.e("======",songname);
Log.e("======",singer);
Toast.makeText(getActivity(),"收藏成功!",Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
}
}
});
return convertView;
}
}
public void playMusic(int position) {
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
musicService.play((Integer) mData.get(position).get("url"));
Log.e("________",mData.get(position).get("url").toString());
}
public void switchToPlayActivity(Integer uri) {
Log.e("puturi",uri.toString());
playingFragment fragment=new playingFragment();
Intent intent = new Intent();
intent.putExtra("uri", uri);
intent.setAction("updateSong");
getActivity().sendBroadcast(intent);
}
}

@ -0,0 +1,251 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class SubFragment4 extends Fragment {
private ListView news_list;
private List<Map<String,Object>> mData;
private List<musicInfo> results;
private MusicService musicService;
private int id = 0;
DbUtils db;
public SubFragment4() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
private List<Map<String,Object>>getData(){
List<Map<String,Object>>list=new ArrayList<Map<String, Object>>();
Map<String,Object>map=new HashMap<String, Object>();
map=new HashMap<String, Object>();
map.put("news_title","Cheers");
map.put("news_info","MAISONdes、Tani Yuuki、菅原圭 - Cheers");
map.put("news_thumb",R.drawable.cheers);
map.put("url",R.raw.cheers);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","LET'S START WW3");
map.put("news_info","World Order - WW3");
map.put("news_thumb",R.drawable.letsstartww3);
map.put("url",R.raw.letsstartww3);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","深夜诗人");
map.put("news_info","洛天依、言和、liem - 2:3");
map.put("news_thumb",R.drawable.shenyeshiren);
map.put("url",R.raw.shenyeshiren);
list.add(map);
return list;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_sub_fragment4,container,false);
news_list=(ListView)view.findViewById(R.id.news_list);
mData=getData();
DbUtils.DaoConfig config = new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db = DbUtils.create(config);
try {
db.createTableIfNotExist(musicList.class);
}catch (Exception e){}
MyAdapter adapter = new MyAdapter(getActivity(), mData,results,db);
news_list.setAdapter(adapter);
Intent mintent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(mintent,mSerConn,Context.BIND_AUTO_CREATE);
return view;
}
@Override
public void onResume() {
try {
List<musicInfo> results = db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter = new MyAdapter(getActivity(), mData, results, db);
news_list.setAdapter(adapter);
}catch (DbException e){
}
super.onResume();
}
public final class ViewHolder{
public ImageView news_thumb;
public TextView news_title;
public TextView news_info;
public ImageButton news_btn;
public ImageButton like;
}
public class MyAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context context;
private List<Map<String,Object>> data;
private List<musicInfo> results;
private Fragment fragment;//用于接收传递过来的Context对象
DbUtils db;
public MyAdapter(Context contaxt, List<Map<String, Object>> data,List<musicInfo> results,DbUtils db ){
this.context = contaxt;
this.data = data;
this.results=results;
this.db=db;
this.mInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
SubFragment4.ViewHolder holder=null;
if(convertView==null){
holder=new SubFragment4.ViewHolder();
convertView=mInflater.inflate(R.layout.listview1,null);
holder.news_thumb=(ImageView)convertView.findViewById(R.id.news_thumb);
holder.news_title=(TextView)convertView.findViewById(R.id.news_title);
holder.news_info=(TextView)convertView.findViewById(R.id.news_info);
holder.news_btn=(ImageButton)convertView.findViewById(R.id.news_btn);
holder.like=(ImageButton)convertView.findViewById(R.id.like);
convertView.setTag(holder);
}
else {
holder=(SubFragment4.ViewHolder)convertView.getTag();
}
holder.news_thumb.setBackgroundResource((Integer)mData.get(position).get("news_thumb"));
holder.news_title.setText((String)mData.get(position).get("news_title"));
holder.news_info.setText((String)mData.get(position).get("news_info"));
holder.news_btn.setTag(position);
holder.like.setTag(position);
final ImageButton storeMusic = holder.like;
final TextView sname = holder.news_title;
final TextView info = holder.news_info;
//将歌曲列表存入表musicList
String gm=sname.getText().toString();
String gs=info.getText().toString();
Integer songuri=(Integer)mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
try {
if(db.findAll(Selector.from(musicList.class).where("songname", "=", gm)).isEmpty()) {
musicList l = new musicList(gm, gs, songuri, imguri);
db.save(l);
}
}catch (Exception e){}
try {
List<musicInfo> musicstored = db.findAll(Selector.from(musicInfo.class).where("songname", "=", sname.getText().toString()));
if(musicstored.isEmpty()){
holder.like.setImageResource(R.drawable.unlike);
}else {
holder.like.setImageResource(R.drawable.like);
}
}catch (Exception e){
}
holder.news_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
playMusic(position);
switchToPlayActivity((Integer) mData.get(position).get("url"));
}
});
holder.like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
storeMusic.setImageResource(R.drawable.like);
Intent intent=new Intent(getActivity(),loveFragment.class);
try{
String songname=sname.getText().toString();
String singer=info.getText().toString();
Integer uri=(Integer) mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
Log.e("======",songname);
Log.e("======",singer);
if(db.findAll(Selector.from(musicInfo.class).where("songname", "=", songname)).isEmpty()){
musicInfo m=new musicInfo(songname,singer,uri,imguri);
db.save(m);
Log.e("======",songname);
Log.e("======",singer);
Toast.makeText(getActivity(),"收藏成功!",Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
}
}
});
return convertView;
}
}
public void playMusic(int position) {
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
musicService.play((Integer) mData.get(position).get("url"));
Log.e("________",mData.get(position).get("url").toString());
}
public void switchToPlayActivity(Integer uri) {
Log.e("puturi",uri.toString());
playingFragment fragment=new playingFragment();
Intent intent = new Intent();
intent.putExtra("uri", uri);
intent.setAction("updateSong");
getActivity().sendBroadcast(intent);
}
}

@ -0,0 +1,250 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class SubFragment5 extends Fragment {
private ListView news_list;
private List<Map<String,Object>> mData;
private List<musicInfo> results;
private MusicService musicService;
private int id = 0;
DbUtils db;
public SubFragment5() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
private List<Map<String,Object>>getData(){
List<Map<String,Object>>list=new ArrayList<Map<String, Object>>();
Map<String,Object>map=new HashMap<String, Object>();
map.put("news_title","カッシーワのテーマ");
map.put("news_info","岩田恭明 - ゼルダの伝説 ブレス オブ ザ ワイルド SOUND SELECTION");
map.put("news_thumb", R.drawable.kaxiwa);
map.put("url",R.raw.kaxiwa);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","Eastward");
map.put("news_info","Joel Corelitz - Eastward (Original Soundtrack)");
map.put("news_thumb",R.drawable.eastward);
map.put("url",R.raw.eastward);
list.add(map);
map=new HashMap<String, Object>();
map.put("news_title","Sealed Vessel");
map.put("news_info","Christopher Larkin - Hollow Knight (Original Soundtrack)");
map.put("news_thumb",R.drawable.sealedvessel);
map.put("url",R.raw.sealedvessel);
list.add(map);
return list;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_sub_fragment5,container,false);
news_list=(ListView)view.findViewById(R.id.news_list);
mData=getData();
DbUtils.DaoConfig config = new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db = DbUtils.create(config);
try {
db.createTableIfNotExist(musicList.class);
}catch (Exception e){}
MyAdapter adapter = new MyAdapter(getActivity(), mData,results,db); news_list.setAdapter(adapter);
Intent mintent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(mintent,mSerConn,Context.BIND_AUTO_CREATE);
return view;
}
@Override
public void onResume() {
try {
List<musicInfo> results = db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter = new MyAdapter(getActivity(), mData, results, db);
news_list.setAdapter(adapter);
}catch (DbException e){
}
super.onResume();
}
public final class ViewHolder{
public ImageView news_thumb;
public TextView news_title;
public TextView news_info;
public ImageButton news_btn;
public ImageButton like;
}
public class MyAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Context context;
private List<Map<String,Object>> data;
private List<musicInfo> results;
DbUtils db;
private Fragment fragment;//用于接收传递过来的Context对象
public MyAdapter(Context contaxt, List<Map<String, Object>> data,List<musicInfo> results,DbUtils db ) {
this.context=contaxt;
this.data=data;
this.results=results;
this.db=db;
this.mInflater=LayoutInflater.from(context);
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
SubFragment5.ViewHolder holder=null;
if(convertView==null){
holder=new SubFragment5.ViewHolder();
convertView=mInflater.inflate(R.layout.listview1,null);
holder.news_thumb=(ImageView)convertView.findViewById(R.id.news_thumb);
holder.news_title=(TextView)convertView.findViewById(R.id.news_title);
holder.news_info=(TextView)convertView.findViewById(R.id.news_info);
holder.news_btn=(ImageButton)convertView.findViewById(R.id.news_btn);
holder.like=(ImageButton)convertView.findViewById(R.id.like);
convertView.setTag(holder);
}
else {
holder=(SubFragment5.ViewHolder)convertView.getTag();
}
holder.news_thumb.setBackgroundResource((Integer)mData.get(position).get("news_thumb"));
holder.news_title.setText((String)mData.get(position).get("news_title"));
holder.news_info.setText((String)mData.get(position).get("news_info"));
holder.news_btn.setTag(position);
holder.like.setTag(position);
final ImageButton storeMusic = holder.like;
final TextView sname = holder.news_title;
final TextView info = holder.news_info;
//将歌曲列表存入表musicList
String gm=sname.getText().toString();
String gs=info.getText().toString();
Integer songuri=(Integer)mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
try {
if(db.findAll(Selector.from(musicList.class).where("songname", "=", gm)).isEmpty()) {
musicList l = new musicList(gm, gs, songuri, imguri);
db.save(l);
}
}catch (Exception e){}
try {
List<musicInfo> musicstored = db.findAll(Selector.from(musicInfo.class).where("songname", "=", sname.getText().toString()));
if(musicstored.isEmpty()){
holder.like.setImageResource(R.drawable.unlike);
}else {
holder.like.setImageResource(R.drawable.like);
}
}catch (Exception e){
}
holder.news_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
playMusic(position);
switchToPlayActivity((Integer) mData.get(position).get("url"));
}
});
holder.like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
storeMusic.setImageResource(R.drawable.like);
Intent intent=new Intent(getActivity(),loveFragment.class);
try{
String songname=sname.getText().toString();
String singer=info.getText().toString();
Integer uri=(Integer) mData.get(position).get("url");
Integer imguri=(Integer) mData.get(position).get("news_thumb");
Log.e("======",songname);
Log.e("======",singer);
if(db.findAll(Selector.from(musicInfo.class).where("songname", "=", songname)).isEmpty()){
musicInfo m=new musicInfo(songname,singer,uri,imguri);
db.save(m);
Log.e("======",songname);
Log.e("======",singer);
Toast.makeText(getActivity(),"收藏成功!",Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
}
}
});
return convertView;
}
}
public void playMusic(int position) {
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
musicService.play((Integer) mData.get(position).get("url"));
Log.e("________",mData.get(position).get("url").toString());
}
public void switchToPlayActivity(Integer uri) {
Log.e("puturi",uri.toString());
playingFragment fragment=new playingFragment();
Intent intent = new Intent();
intent.putExtra("uri", uri);
intent.setAction("updateSong");
getActivity().sendBroadcast(intent);
}
}

@ -0,0 +1,148 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.provider.CalendarContract;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.astuetz.PagerSlidingTabStrip;
import com.lidroid.xutils.DbUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class findFragment extends Fragment {
//private ListView news_list;
//private List<Map<String,Object>> mData;
private SubFragment1 subFragment1;
private SubFragment2 subFragment2;
private SubFragment3 subFragment3;
private SubFragment4 subFragment4;
private SubFragment5 subFragment5;
private PagerSlidingTabStrip tabs;
private DisplayMetrics dm; //获取当前屏幕的密度
DbUtils db;
public findFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//创建界面Fragment
View view = inflater.inflate(R.layout.find,container,false);
initView(view);
DbUtils.DaoConfig config=new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db=DbUtils.create(config);
return view;
}
private void initView(View view) {
dm = getResources().getDisplayMetrics();
ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
tabs = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
pager.setAdapter(new MyPagerAdapter(getChildFragmentManager()));
tabs.setViewPager(pager);
setTabsValue();
}
private void setTabsValue() {
// 设置Tab是自动填充满屏幕的
tabs.setShouldExpand(true);
// 设置Tab的分割线是透明的
tabs.setDividerColor(Color.TRANSPARENT);
// tabs.setDividerColor(Color.BLACK);
// 设置Tab底部线的高度
tabs.setUnderlineHeight((int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 1, dm));
// 设置Tab Indicator的高度
tabs.setIndicatorHeight((int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 4, dm));// 4
// 设置Tab标题文字的大小
tabs.setTextSize((int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, 16, dm)); // 16
// 设置Tab Indicator的颜色
tabs.setIndicatorColor(Color.parseColor("#be8dbd"));
// 设置选中Tab文字的颜色 (这是自定义的一个方法)
//tabs.setSelectedTextColor(Color.parseColor("#45c01a"));// #45c01a
// 取消单击Tab时的背景色
tabs.setTabBackground(0);
}
public class MyPagerAdapter extends FragmentStatePagerAdapter {
public MyPagerAdapter(FragmentManager fm) {
super(fm);
// TODO Auto-generated constructor stub
}
private final String[] titles = { "红色", "电子", "民乐", "流行", "游戏原声" };
@Override
public CharSequence getPageTitle(int position) {
return titles[position];
}
@Override
public int getCount() {
return titles.length;
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
if (null == subFragment1) {
subFragment1 = new SubFragment1();
}
return subFragment1;
case 1:
if (null == subFragment2) {
subFragment2 = new SubFragment2();
}
return subFragment2;
case 2:
if (null == subFragment3) {
subFragment3 = new SubFragment3();
}
return subFragment3;
case 3:
if (null == subFragment4) {
subFragment4 = new SubFragment4();
}
return subFragment4;
case 4:
if (null == subFragment5) {
subFragment5 = new SubFragment5();
}
subFragment1 = new SubFragment1();
return subFragment5;
default:
return null;
}
}
}
}

@ -0,0 +1,163 @@
package com.example.musicPlayer;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
public class login extends AppCompatActivity {
private EditText ed_username;
private EditText ed_password;
private ImageButton btn_zhuCe,btn_dengLu;
private String userName,password;//获取EditText中输入的用户名和密码
private String spPassword;//spPassword 为 根据从SharedPreferences中用户名读取密码
private CheckBox cb_remember;
private Context mContext;
private NotificationManager mManager;
private NotificationCompat.Builder mbuilder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
init();
}
private void init(){
final AlertDialog.Builder builder=new AlertDialog.Builder(this);
ed_username=(EditText)findViewById(R.id.ed_username1);
ed_password=(EditText)findViewById(R.id.ed_password1) ;
btn_zhuCe=(ImageButton)findViewById(R.id.btn_zhuCe1);
btn_dengLu=(ImageButton)findViewById(R.id.btn_dengLu);
cb_remember=(CheckBox)findViewById(R.id.cb_remember);
mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mContext=login.this;
btn_zhuCe.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {//跳转到注册页面
Intent intent1=new Intent(login.this,zuceActivity.class);
finish();
startActivity(intent1);
}
});
//登录按钮
btn_dengLu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
userName=ed_username.getText().toString().trim();
password=ed_password.getText().toString().trim();
spPassword=readPassword(userName);//根据从SharedPreferences中用户名读取密码
if(TextUtils.isEmpty(userName)){//用户名为空
builder.setTitle("消息提示").setMessage("请输入用户名").setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
}
}).show();
}else if (TextUtils.isEmpty(password)){//密码为空
builder.setTitle("消息提示").setMessage("请输入密码").setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
}
}).show();
}else if(password.equals(spPassword)){//注册时的密码与登录的密码一样
Intent intent = new Intent(mContext,MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0); //设置图片,通知标题,发送时间,提示方式等属性
mbuilder =new NotificationCompat.Builder(mContext);
mbuilder.setContentTitle("通知") //标题
.setContentIntent(pendingIntent).setContentText("您正在登录账号"+userName) //内容
.setTicker("收到来自音乐播放器的的消息~").setWhen(System.currentTimeMillis()).setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE)
.setSmallIcon(R.mipmap.musicnote).setDefaults(Notification.DEFAULT_SOUND).setAutoCancel(true); //设置点击后取消Notification
mManager.notify(1,mbuilder.build());
builder.setTitle("消息提示").setMessage("登录成功,欢迎您").setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
saveLoginStatus(true,userName);
finish();
startActivity(new Intent(login.this, MainActivity.class));
}
}).show();
}else if((spPassword!=null&&!TextUtils.isEmpty(spPassword)&&!password.equals(spPassword))){
builder.setTitle("消息提示").setMessage("输入的用户名和密码不一致").setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
}
}).show();
}else {
builder.setTitle("消息提示").setMessage("此用户名不存在").setPositiveButton("确定",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog,int which){
}
}).show();
}
}
});
}
private String readPassword(String userName){
SharedPreferences sp=getSharedPreferences("loginInfo", MODE_PRIVATE);
return sp.getString(userName , null);
}
private void saveLoginStatus(boolean status,String userName){
SharedPreferences sp=getSharedPreferences("loginInfo",MODE_PRIVATE);
SharedPreferences.Editor editor=sp.edit();
editor.putBoolean("isLogin",status);//存入账号的登录状态
editor.putString("loginUserName",userName);//存入登录状态时的用户名
editor.commit();
}
public void rememberMe(String userName,String password){
SharedPreferences sp=getSharedPreferences("loginInfo",MODE_PRIVATE);
SharedPreferences.Editor editor=sp.edit();
editor.putString("password",password);//存入账号的登录状态
editor.putString("username",userName);//存入登录状态时的用户名
editor.commit();
}
@Override
protected void onStop(){
super.onStop();
if(cb_remember.isChecked()) {
this.rememberMe(ed_username.getText().toString(),ed_password.getText().toString());
}
}
public void checkIfRemember() {
SharedPreferences sp = getSharedPreferences("loginInfo", MODE_PRIVATE);
String username = sp.getString("username", null);
String password = sp.getString("password", null);
if (username != null && password != null) {
ed_username.setText(username);
ed_password.setText(password);
cb_remember.setChecked(true);
}
}
@Override
public void onStart(){
super.onStart();
checkIfRemember();
}
}

@ -0,0 +1,181 @@
package com.example.musicPlayer;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.musicPlayer.R;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
*/
public class loveFragment extends Fragment {
private ListView news_list;
private MusicService musicService;
public loveFragment() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.love,container,false);
news_list=(ListView)view.findViewById(R.id.news_list);
Intent mintent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(mintent,mSerConn,Context.BIND_AUTO_CREATE);
//数据库
DbUtils.DaoConfig config=new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
DbUtils db=DbUtils.create(config);
try {
db.createTableIfNotExist(musicInfo.class);
List<musicInfo> results=db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter=new MyAdapter(getActivity(),results,db);
news_list.setAdapter(adapter);
}catch (DbException e){
e.printStackTrace();
}
return view;
}
public final class ViewHolder{
public TextView songname;
public TextView singer;
public ImageButton news_btn;
public ImageButton like;
}
public class MyAdapter extends BaseAdapter{
private LayoutInflater mInflater;
private Context context;
private List<musicInfo> results;
private Fragment fragment;//用于接收传递过来的Context对象
DbUtils db;
public MyAdapter(Context context,List<musicInfo> results,DbUtils db) {
this.context=context;
this.results=results;
this.db=db;
mInflater=LayoutInflater.from(context);
}
@Override
public int getCount() {
return results.size();
}
@Override
public Object getItem(int position) {
return results.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
if(convertView==null){
holder=new ViewHolder();
convertView=mInflater.inflate(R.layout.listview_love,null);
holder.songname=(TextView) convertView.findViewById(R.id.songname);
holder.singer=(TextView)convertView.findViewById(R.id.singer);
holder.news_btn=(ImageButton)convertView.findViewById(R.id.news_btn);
holder.like=(ImageButton)convertView.findViewById(R.id.like);
convertView.setTag(holder);
}
else {
holder=(ViewHolder)convertView.getTag();
}
holder.songname.setText(results.get(position).getSongname());
holder.singer.setText(results.get(position).getSinger());
//播放、删除收藏功能
holder.news_btn.setTag(position);
holder.like.setTag(position);
final ImageButton storeMusic = holder.like;
final int id=results.get(position).getId();
holder.like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
storeMusic.setImageResource(R.drawable.unlike);
try {
db.deleteById(musicInfo.class,id);
List<musicInfo> results=db.findAll(Selector.from(musicInfo.class));
MyAdapter adapter=new MyAdapter(getActivity(),results,db);
news_list.setAdapter(adapter);
}catch (DbException e)
{
}
Toast.makeText(getContext(),"取消收藏!",Toast.LENGTH_SHORT).show();
}
});
holder.news_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
playMusic(position);
switchToPlayActivity((Integer) results.get(position).getSonguri());
}
});
return convertView;
}
public void playMusic(int position) {
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
Integer uri=results.get(position).getSonguri();
musicService.play(uri);
Log.d("________",uri.toString());
}
public void switchToPlayActivity(Integer uri) {
Log.e("puturi",uri.toString());
playingFragment fragment=new playingFragment();
Intent intent = new Intent();
intent.putExtra("uri", uri);
intent.setAction("updateSong");
getActivity().sendBroadcast(intent);
}
}
}

@ -0,0 +1,71 @@
package com.example.musicPlayer;
import android.media.Image;
import com.lidroid.xutils.db.annotation.Column;
import com.lidroid.xutils.db.annotation.Id;
import com.lidroid.xutils.db.annotation.Table;
@Table(name = "musicInfo")
public class musicInfo {
@Id
@Column(column = "id")
public int id;
@Column(column = "songname")
public String songname;
@Column(column = "singer")
public String singer;
@Column(column = "songuri")
public int songuri;
@Column(column = "imguri")
public int imguri;
public musicInfo(){
}
public musicInfo(String songname,String singer,int songuri,int imguri){
this.songname=songname;
this.singer=singer;
this.songuri=songuri;
this.imguri=imguri;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSongname() {
return songname;
}
public void setSongname(String songname) {
this.songname = songname;
}
public String getSinger() {
return singer;
}
public void setSinger(String singer) {
this.singer = singer;
}
public int getSonguri() {
return songuri;
}
public void setSonguri(int songuri) {
this.songuri = songuri;
}
public int getImguri() {
return imguri;
}
public void setImguri(int imguri) {
this.imguri = imguri;
}
}

@ -0,0 +1,68 @@
package com.example.musicPlayer;
import com.lidroid.xutils.db.annotation.Column;
import com.lidroid.xutils.db.annotation.Id;
import com.lidroid.xutils.db.annotation.Table;
@Table(name="musicList")
public class musicList {
@Id
@Column(column = "id")
public int id;
@Column(column = "songname")
public String songname;
@Column(column = "singer")
public String singer;
@Column(column = "songuri")
public int songuri;
@Column(column = "imguri")
public int imguri;
public musicList(){
}
public musicList(String songname,String singer,int songuri,int imguri){
this.songname=songname;
this.singer=singer;
this.songuri=songuri;
this.imguri=imguri;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSongname() {
return songname;
}
public void setSongname(String songname) {
this.songname = songname;
}
public String getSinger() {
return singer;
}
public void setSinger(String singer) {
this.singer = singer;
}
public int getSonguri() {
return songuri;
}
public void setSonguri(int songuri) {
this.songuri = songuri;
}
public int getImguri() {
return imguri;
}
public void setImguri(int imguri) {
this.imguri = imguri;
}
}

@ -0,0 +1,262 @@
package com.example.musicPlayer;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.os.IBinder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.example.musicPlayer.R;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.view.annotation.event.OnClick;
import java.io.IOException;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
*/
public class playingFragment extends Fragment {
private MusicService musicService;
DbUtils db;
private boolean isplaying;
private SeekBar mSeekBar;
private ImageButton playingPre,playingNext,playingPlay;
private TextView songtitle,singerinfo,stime,etime;
private de.hdodenhof.circleimageview.CircleImageView disc;
private IntentFilter intentFilter;
private int currentsongid,currentsonguri;
public playingFragment() {
// Required empty public constructor
}
private ServiceConnection mSerConn=new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
musicService = ((MusicService.MyBinder)service).getService();
}
@Override
public void onServiceDisconnected(ComponentName name) {
musicService = null;
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.playing,container,false);
Intent intent=new Intent(getActivity(),MusicService.class);
getActivity().getApplicationContext().bindService(intent,mSerConn,Context.BIND_AUTO_CREATE);
intentFilter = new IntentFilter();
intentFilter.addAction("updateSong");
intentFilter.addAction("action.updateplayedtime");
getContext().registerReceiver(updateReceiver, intentFilter);
mSeekBar=view.findViewById(R.id.seekBar);
mSeekBar.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) {
int progress = seekBar.getProgress();
Log.i("TAG:", "" + progress + "");
int musicMax = musicService.musicPlayer.getDuration(); //得到该首歌曲最长秒数
int seekBarMax = seekBar.getMax();
musicService.musicPlayer.seekTo(musicMax * progress / seekBarMax);//跳到该曲该秒
}
});
playingPre = view.findViewById(R.id.premusic);
playingPlay = view.findViewById(R.id.bf);
playingNext = view.findViewById(R.id.nextmusic);
songtitle=view.findViewById(R.id.songName);
singerinfo=view.findViewById(R.id.singer);
disc = view.findViewById(R.id.songImg);
stime=view.findViewById(R.id.stime);
etime=view.findViewById(R.id.etime);
stime.setText("00:00");
//数据库保存歌曲列表
DbUtils.DaoConfig config = new DbUtils.DaoConfig(getActivity());
config.setDbName("music");
config.setDbVersion(1);
db = DbUtils.create(config);
setEvent();
return view;
}
@Override
public void onDestroyView() {
super.onDestroyView();
getContext().unregisterReceiver(updateReceiver);
}
public void playmusic(final Integer songuri) {
try {
final List<musicList> musicplayed = db.findAll(Selector.from(musicList.class).where("songuri", "=", songuri));
//SubFragment点击播放传参设置
currentsonguri=songuri;
Integer songimg = musicplayed.get(0).getImguri();
currentsongid=musicplayed.get(0).getId();
Log.e("imguri", songimg.toString());
isplaying=true;
playingPlay.setImageResource(R.drawable.zt);
disc.setImageResource(songimg);
songtitle.setText(musicplayed.get(0).getSongname());
singerinfo.setText(musicplayed.get(0).getSinger());
etime.setText(formatDuration(musicService.musicPlayer.getDuration()));
setanim();
musicService.refreshSeekBar();
}catch (Exception e){}
}
public void setEvent(){
//设置按钮单击事件
try {
final List<musicList> musicList=db.findAll(Selector.from(musicList.class));
//设置动画
setanim();
playingPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
musicService.refreshSeekBar();
if(musicService.musicPlayer.isPlaying()){
musicService.pause();
playingPlay.setImageResource(R.drawable.bf);
disc.clearAnimation();
//isplaying=false;
}else {
playingPlay.setImageResource(R.drawable.zt);
musicService.goPlay();
setanim();
//isplaying=true;
}
}
});
playingPre.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSeekBar.setProgress(0);
try{
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
if(currentsongid==0){
currentsongid=musicList.size()-1;
}else {
currentsongid--;
}
setInfo(currentsongid);
playingPlay.setImageResource(R.drawable.zt);
isplaying=true;
}catch (Exception e){}
}
});
playingNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mSeekBar.setProgress(0);
try{
if(musicService.musicPlayer.isPlaying()){
musicService.musicPlayer.stop();
}
if(currentsongid==musicList.size()-1){
currentsongid=0;
}else {
currentsongid++;
}
setInfo(currentsongid);
playingPlay.setImageResource(R.drawable.zt);
isplaying=true;
}catch (Exception e){}
}
});
}catch (Exception e){}
}
public void setInfo(int id){//设置图片歌名信息
try {
List<musicList> musicplayed = db.findAll(Selector.from(musicList.class).where("id", "=", id));
Integer songimg = musicplayed.get(0).getImguri();
currentsonguri=musicplayed.get(0).getSonguri();
Log.e("imguri", songimg.toString());
disc.setImageResource(songimg);
songtitle.setText(musicplayed.get(0).getSongname());
singerinfo.setText(musicplayed.get(0).getSinger());
musicService.play(currentsonguri);
etime.setText(formatDuration(musicService.musicPlayer.getDuration()));
setanim();
musicService.refreshSeekBar();
}catch (Exception e){}
}
public void setanim(){//动画旋转
Animation operatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.animation);
LinearInterpolator lin = new LinearInterpolator();//LinearInterpolator为匀速效果
operatingAnim.setInterpolator(lin);//setInterpolator表示设置旋转速率。
disc.startAnimation(operatingAnim);//开始旋转
}
//将毫秒形式的音乐时长信息转化为00:00形式
public static String formatDuration(long dur) {
long totalSecond = dur / 1000;
String minute = totalSecond / 60 + "";
if (minute.length() < 2) minute = "0" + minute ;
String second = totalSecond % 60 + "";
if (second.length() < 2) second = "0" + second;
return minute + ":" + second;
}
private BroadcastReceiver updateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if(intentFilter.hasAction("updateSong")) {
Integer uri = intent.getIntExtra("uri", 0);
playmusic(uri);
}
if(intentFilter.hasAction("action.updateplayedtime")) {
long newtime = (long)intent.getIntExtra("playedTime", 0);
stime.setText(formatDuration(newtime));
int durationMusic = musicService.musicPlayer.getDuration();
long progress = newtime*100/durationMusic;
mSeekBar.setProgress((int)progress);
}
}
};
}

@ -0,0 +1,139 @@
package com.example.musicPlayer;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
public class zuceActivity extends AppCompatActivity {
private EditText ed_username;
private EditText ed_password;
private EditText ed_password_again;
private ImageButton btn_zhuCe1;
private ImageButton btn_back;
private CheckBox cb_protocol;
private String userName;//保存用户名
private String passord;//保存密码
private String password_again;//保存确认密码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zuce);
init();
}
private void init() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
ed_username = findViewById(R.id.ed_username1);
ed_password = findViewById(R.id.ed_password1);
ed_password_again = findViewById(R.id.ed_password_again);
btn_zhuCe1 = findViewById(R.id.btn_zhuCe1);
btn_back = findViewById(R.id.btn_back);//返回按钮
cb_protocol=findViewById(R.id.cb_protocol);
btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//返回按钮
Intent intent2 = new Intent(zuceActivity.this, login.class);
finish();
startActivity(intent2);
}
});
btn_zhuCe1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {//注册按钮
//获取输入在相应控件中的字符串
getEditString();
//判断输入框内容
if (TextUtils.isEmpty(userName)) {
builder.setTitle("消息提示").setMessage("请输入用户名").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
} else if (TextUtils.isEmpty(passord)) {
builder.setTitle("消息提示").setMessage("请输入密码").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
} else if (TextUtils.isEmpty(password_again)) {
builder.setTitle("消息提示").setMessage("请输入再次输入密码").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
} else if (!passord.equals(password_again)) {
builder.setTitle("消息提示").setMessage("两次输入的密码不一样,请重新输入").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
} else if (isExistUserName(userName)) {//从SharedPreferences中读取输入的用户名判断SharedPreferences中是否有此用户名
builder.setTitle("消息提示").setMessage("此账户名已经存在").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
} else {
if(cb_protocol.isChecked()){
builder.setTitle("消息提示").setMessage("注册成功").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {//保存账号和密码到SharedPreferences中
savaLoginInfo(userName, passord);
Intent intent1 = new Intent(zuceActivity.this, login.class);
finish();
startActivity(intent1);
}
}).show();}else{
builder.setTitle("消息提示").setMessage("请同意软件用户协议").setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
}
}
});
}
private void getEditString() {
userName = ed_username.getText().toString().trim();//trim()作用为去除字符串头尾空格
passord = ed_password.getText().toString().trim();
password_again = ed_password_again.getText().toString().trim();
}
private boolean isExistUserName(String userName) {
boolean has_userName = false;
SharedPreferences sp = getSharedPreferences("loginInfo", MODE_PRIVATE);
String spPassword = sp.getString(userName, null);
if (!TextUtils.isEmpty(spPassword)) {
has_userName = true;
}
return has_userName;
}
private void savaLoginInfo(String userName, String passord) {
SharedPreferences sp = getSharedPreferences("loginInfo", MODE_PRIVATE);//文件名loginInfo
SharedPreferences.Editor editor = sp.edit();
editor.putString(userName, passord);
editor.commit();
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="100000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="-1"
android:toDegrees="360"
/>
</set>

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/red" />
<item android:state_focused="true" android:drawable="@color/red"/>
<item android:drawable="@android:color/transparent"/>
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 KiB

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_music"
app:menu="@menu/activity_music2_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@drawable/registerbackground"
tools:context=".MainActivity">
<EditText
android:id="@+id/ed_username1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.686"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.364" />
<EditText
android:id="@+id/ed_password1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:ems="10"
android:inputType="textPassword"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.664"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.488" />
<TextView
android:id="@+id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:text="用户名:"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.024"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.373" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:text="密 码:"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ed_password1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.493" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:textColor="#191970"
android:textStyle="bold"
android:text="登 录"
android:textSize="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.121" />
<CheckBox
android:id="@+id/cb_remember"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="记住我"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.806"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.095" />
<ImageButton
android:id="@+id/btn_zhuCe1"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.163"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.827"
app:srcCompat="@drawable/zhuce" />
<ImageButton
android:id="@+id/btn_dengLu"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="@+id/btn_zhuCe1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.796"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/btn_zhuCe1"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/denglu" />
</androidx.constraintlayout.widget.ConstraintLayout>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save