@ -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
|
@ -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>
|
@ -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'
|
||||
}
|
@ -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>
|
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,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,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,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>
|
After Width: | Height: | Size: 438 B |
After Width: | Height: | Size: 228 KiB |
After Width: | Height: | Size: 862 KiB |
After Width: | Height: | Size: 1.1 MiB |
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>
|
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 396 KiB |
After Width: | Height: | Size: 549 KiB |
After Width: | Height: | Size: 171 KiB |
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.6 KiB |
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>
|
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 7.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 477 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 912 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 343 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 658 B |
After Width: | Height: | Size: 698 B |
After Width: | Height: | Size: 985 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 981 B |
After Width: | Height: | Size: 842 B |
After Width: | Height: | Size: 516 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 338 KiB |
After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 113 KiB |
After Width: | Height: | Size: 26 MiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 677 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 877 B |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 589 KiB |
After Width: | Height: | Size: 225 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 852 B |
After Width: | Height: | Size: 919 B |
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>
|