the initial commit

master
zzc 3 years ago
commit 2bfe2cbb46

@ -0,0 +1,14 @@
*.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
.cxx

@ -0,0 +1 @@
NetCloudSharing

@ -0,0 +1,134 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<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,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="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" 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,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>

@ -0,0 +1 @@
/build

@ -0,0 +1,43 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.netcloudsharing"
minSdkVersion 25
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.github.xujiaji:happy-bubble:1.1.4'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.10.0'
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}

@ -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 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]

@ -0,0 +1,27 @@
package com.example.netcloudsharing;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
assertEquals("com.example.netcloudsharing", appContext.getPackageName());
}
}

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.netcloudsharing">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/login_icon"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@drawable/login_icon"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".Music.MusicDownload"></activity>
<activity android:name=".Music.HttpGetDemoActivity" />
<activity android:name=".Music.MusicSearch" />
<service
android:name=".service.MusicService"
android:enabled="true"
android:exported="true" />
<activity android:name="Fragment.MainActivity">
</activity>
<activity android:name="Fragment.ActivityMusicHome" />
<activity android:name=".activity.RegisterActivity" />
<activity android:name=".activity.LoginActivity" />
<activity android:name=".diary.MainActivity" />
<activity android:name=".diary.AddContent" />
<activity android:name=".NetStart">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.netcloudsharing.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>
</manifest>

@ -0,0 +1,194 @@
package Fragment;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.netcloudsharing.LocalMusicAdapter;
import com.example.netcloudsharing.LocalMusicBean;
import com.example.netcloudsharing.R;
import com.example.netcloudsharing.diary.Permission;
import java.util.ArrayList;
import java.util.List;
import static Fragment.MainActivity.binder;
import static com.example.netcloudsharing.service.MusicService.currentPlayPosition;
public class ActivityMusicHome extends AppCompatActivity implements View.OnClickListener {
//三个播放歌曲按钮
private ImageView nextIv, playIv, lastIv, album;
//歌曲歌手
private TextView singerTv, songTv;
private RecyclerView musicRv;
private LocalMusicAdapter adapter;
//数据源
List<LocalMusicBean> mData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_home);
initView();
mData = new ArrayList<>();
//getActivity可能有问题
adapter = new LocalMusicAdapter(this, mData);
musicRv.setAdapter(adapter);
//设置布局管理器
LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
musicRv.setLayoutManager(layoutManager);
//加载本地数据源
loadLocalMusicData();
//设置每一项的点击事件
setEventListener();
Permission permission = new Permission();
permission.checkPermission(this);
}
private void setEventListener() {
adapter.setOnItemClickListener(new LocalMusicAdapter.OnItemClickListener() {
@Override
public void OnItemClick(View view, int position) {
currentPlayPosition = position;
LocalMusicBean musicBean = mData.get(position);
binder.playMusicPosition(musicBean);
setMusicBean(binder.getMusicBean());
}
});
}
/**
* MP3
*/
private void loadLocalMusicData() {
//1.获取ContentResolver对象
ContentResolver contentResolver = getContentResolver();
//2.获取本地音乐的Uri地址
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
//3.开始查询
Cursor cursor = contentResolver.query(uri, null, null, null, null);
//4.遍历
int id = 0;
while (cursor.moveToNext()) {
//内存里面存的是毫秒
long duration = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
int minute = (int) (duration / 1000 / 60);
int second = (int) (duration / 1000 % 60);
if (minute < 1) continue;
id++;
String song = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
String singer = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
String album = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM));
String sid = String.valueOf(id);
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
String time = String.valueOf(minute) + ":" + String.valueOf(second);
//将一行当中的数据封装到对象中
LocalMusicBean bean = new LocalMusicBean(sid, song, singer, album, time, path);
mData.add(bean);
}
//数据源发送变化,提示适配器更新
adapter.notifyDataSetChanged();
setMusicCount();
}
public void setMusicCount() {
SharedPreferences sp = getSharedPreferences("music_count", MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putInt("count", mData.size());
editor.apply();
}
/**
*
*/
private void initView() {
nextIv = findViewById(R.id.local_music_bottom_ivNext);
playIv = findViewById(R.id.local_music_bottom_ivPlay);
lastIv = findViewById(R.id.local_music_bottom_ivLast);
singerTv = findViewById(R.id.local_music_bottom_tvSinger);
songTv = findViewById(R.id.local_music_bottom_tvSong);
musicRv = findViewById(R.id.local_music_rv);
album = findViewById(R.id.local_music_bottom_ivIcon);
nextIv.setOnClickListener(this);
lastIv.setOnClickListener(this);
playIv.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.local_music_bottom_ivPlay:
if (currentPlayPosition == -1) {
//如果没有音乐在播放
binder.playMusicPosition(null);
setMusicBean(binder.getMusicBean());
playIv.setImageResource(R.mipmap.icon_pause);
return;
}
if (binder.isMusicPlaying()) {
//如果音乐正在播放,则暂停
binder.pauseMusic();
playIv.setImageResource(R.mipmap.icon_play);
} else {
//如果音乐正在暂停,则播放
binder.playMusic();
playIv.setImageResource(R.mipmap.icon_pause);
}
setMusicBean(binder.getMusicBean());
break;
case R.id.local_music_bottom_ivLast:
binder.playLastMusic();
setMusicBean(binder.getMusicBean());
break;
case R.id.local_music_bottom_ivNext:
binder.playNextMusic();
setMusicBean(binder.getMusicBean());
break;
}
}
private void setMusicBean(LocalMusicBean bean) {
singerTv.setText(bean.getSinger());
songTv.setText(bean.getSong());
if (binder.isMusicPlaying()) {
playIv.setImageResource(R.mipmap.icon_pause);
} else {
playIv.setImageResource(R.mipmap.icon_play);
}
}
@Override
protected void onResume() {
super.onResume();
//第二个判断条件是如果还没有播放,则会返回一个错误的值
if (binder != null && currentPlayPosition != -1) {
setMusicBean(binder.getMusicBean());
}
}
@Override
protected void onDestroy() {
SharedPreferences sp = getSharedPreferences("lastMusicPlayPosition",MODE_PRIVATE);
SharedPreferences.Editor edit = sp.edit();
edit.putInt("lastMusicPlayPosition",currentPlayPosition);
edit.commit();
super.onDestroy();
}
}

@ -0,0 +1,92 @@
package Fragment;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.netcloudsharing.R;
import com.example.netcloudsharing.game.WhitePiecesView;
public class FragmentCommunity extends Fragment implements WhitePiecesView.WhitePiecesListener {
private WhitePiecesView whitePiecesView;
private TextView scoreText;
private Activity mActivity;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.game, container, false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
whitePiecesView = view.findViewById(R.id.write_pieces);
scoreText = (TextView) view.findViewById(R.id.score);
whitePiecesView.setWhitePiecesListener(this);
}
@Override
public void getScore(int score, int grade) {
scoreText.setText("" + score + " 等级为" + grade);
}
@Override
public void gameOver() {
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle("Game Over")
.setMessage("您获得的分数为" + scoreText.getText() + "是否重新开始")
.setNegativeButton("是", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
whitePiecesView.restart();
return;
}
})
.setPositiveButton("否", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mActivity.finish();
}
}).show();
}
@Override
public void gameWin() {
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle("Game Wining")
.setMessage("您获得的分数为" + scoreText.getText() + " 是否重新开始")
.setNegativeButton("是", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
whitePiecesView.restart();
return;
}
})
.setPositiveButton("否", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mActivity.finish();
}
}).show();
}
public void onAttach(Context context) {
super.onAttach(context);
this.mActivity = (Activity) context;
}
}

@ -0,0 +1,26 @@
package Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.netcloudsharing.R;
public class FragmentMessage extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_message,container,false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
}

@ -0,0 +1,219 @@
package Fragment;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.example.netcloudsharing.LocalMusicBean;
import com.example.netcloudsharing.Music.MusicSearch;
import com.example.netcloudsharing.R;
import static Fragment.MainActivity.binder;
import static com.example.netcloudsharing.service.MusicService.currentPlayPosition;
public class FragmentMusic extends Fragment implements View.OnClickListener {
FragmentMusic_NewSong fragmentMusic_newSong;
FragmentMusic_RankingList fragmentMusic_rankingList;
FragmentMusic_SongList fragmentMusic_songList;
private Button btnNewSong;
private Button btnRankingList;
private Button btnSongList;
private TextView tvNewSong;
private TextView tvRankingList;
private TextView tvSongList;
private View thisView;
//三个播放歌曲按钮
private ImageView nextIv, playIv, lastIv, album;
//歌曲歌手
private TextView singerTv, songTv;
private boolean firstOpen = true;
private ImageButton ibSearch;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initView();
selectTab(0);
}
/**
*
*/
private void initView() {
btnNewSong = thisView.findViewById(R.id.fragment_music_btnNewSong);
btnRankingList = thisView.findViewById(R.id.fragment_music_btnRankingList);
btnSongList = thisView.findViewById(R.id.fragment_music_btnSongList);
ibSearch = thisView.findViewById(R.id.fragment_music_ibSearch);
tvNewSong = thisView.findViewById(R.id.fragment_music_tvNewSong);
tvRankingList = thisView.findViewById(R.id.fragment_music_tvRankingList);
tvSongList = thisView.findViewById(R.id.fragment_music_tvSongList);
singerTv = thisView.findViewById(R.id.local_music_bottom_tvSinger);
songTv = thisView.findViewById(R.id.local_music_bottom_tvSong);
btnNewSong.setOnClickListener(this);
btnRankingList.setOnClickListener(this);
btnSongList.setOnClickListener(this);
nextIv = thisView.findViewById(R.id.local_music_bottom_ivNext);
playIv = thisView.findViewById(R.id.local_music_bottom_ivPlay);
lastIv = thisView.findViewById(R.id.local_music_bottom_ivLast);
nextIv.setOnClickListener(this);
lastIv.setOnClickListener(this);
playIv.setOnClickListener(this);
ibSearch.setOnClickListener(this);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_music, container, false);
this.thisView = view;
return view;
}
@Override
public void onClick(View v) {
resetTab();
switch (v.getId()) {
case R.id.fragment_music_btnNewSong:
selectTab(0);
break;
case R.id.fragment_music_btnSongList:
selectTab(1);
break;
case R.id.fragment_music_btnRankingList:
selectTab(2);
break;
case R.id.local_music_bottom_ivPlay:
if (firstOpen) {
if (currentPlayPosition == -1) {
//如果没有音乐在播放
binder.playMusicPosition(null);
setMusicBean(binder.getMusicBean());
playIv.setImageResource(R.mipmap.icon_pause);
} else {
binder.playMusicPosition(currentPlayPosition);
}
firstOpen = false;
} else {
if (binder.isMusicPlaying()) {
//如果音乐正在播放,则暂停
binder.pauseMusic();
playIv.setImageResource(R.mipmap.icon_play);
} else {
//如果音乐正在暂停,则播放
binder.playMusic();
playIv.setImageResource(R.mipmap.icon_pause);
}
}
setMusicBean(binder.getMusicBean());
break;
case R.id.local_music_bottom_ivLast:
binder.playLastMusic();
setMusicBean(binder.getMusicBean());
break;
case R.id.local_music_bottom_ivNext:
binder.playNextMusic();
setMusicBean(binder.getMusicBean());
break;
case R.id.fragment_music_ibSearch:
Intent intent = new Intent(getActivity(), MusicSearch.class);
startActivity(intent);
}
}
public void setMusicBean(LocalMusicBean bean) {
singerTv.setText(bean.getSinger());
songTv.setText(bean.getSong());
if (binder.isMusicPlaying()) {
playIv.setImageResource(R.mipmap.icon_pause);
} else {
playIv.setImageResource(R.mipmap.icon_play);
}
}
private void resetTab() {
tvNewSong.setBackgroundColor(Color.WHITE);
tvSongList.setBackgroundColor(Color.WHITE);
tvRankingList.setBackgroundColor(Color.WHITE);
}
private void selectTab(int i) {
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
hideFragment(transaction);
switch (i) {
case 0:
tvNewSong.setBackgroundColor(Color.RED);
if (fragmentMusic_newSong == null) {
fragmentMusic_newSong = new FragmentMusic_NewSong();
transaction.add(R.id.fragment_music_fl, fragmentMusic_newSong);
} else {
transaction.show(fragmentMusic_newSong);
}
break;
case 1:
tvSongList.setBackgroundColor(Color.RED);
if (fragmentMusic_songList == null) {
fragmentMusic_songList = new FragmentMusic_SongList();
transaction.add(R.id.fragment_music_fl, fragmentMusic_songList);
} else {
transaction.show(fragmentMusic_songList);
}
break;
case 2:
tvRankingList.setBackgroundColor(Color.RED);
if (fragmentMusic_rankingList == null) {
fragmentMusic_rankingList = new FragmentMusic_RankingList();
transaction.add(R.id.fragment_music_fl, fragmentMusic_rankingList);
} else {
transaction.show(fragmentMusic_rankingList);
}
break;
}
transaction.commit();
}
private void hideFragment(FragmentTransaction transaction) {
if (fragmentMusic_newSong != null) {
transaction.hide(fragmentMusic_newSong);
}
if (fragmentMusic_songList != null) {
transaction.hide(fragmentMusic_songList);
}
if (fragmentMusic_rankingList != null) {
transaction.hide(fragmentMusic_rankingList);
}
}
@Override
public void onResume() {
super.onResume();
Log.d("MainActivity", "no");
if (binder != null) {
setMusicBean(binder.getMusicBean());
}
}
}

@ -0,0 +1,68 @@
package Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.netcloudsharing.Music.MusicDownload;
import com.example.netcloudsharing.R;
public class FragmentMusic_NewSong extends Fragment implements View.OnClickListener {
private TextView tvLocalMusicCount;
private View thisView;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_music_newsong, container, false);
this.thisView = view;
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
init();
}
private void init() {
tvLocalMusicCount = thisView.findViewById(R.id.fragment_music_tvLocalMusicCount);
thisView.findViewById(R.id.fragment_music_newSong_llLocalSong).setOnClickListener(this);
thisView.findViewById(R.id.fragment_music_newsong_ibDownloadMusic).setOnClickListener(this);
getMusicCount();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fragment_music_newSong_llLocalSong:
Intent intent = new Intent(getContext(), ActivityMusicHome.class);
startActivity(intent);
break;
case R.id.fragment_music_newsong_ibDownloadMusic:
Intent intent1 = new Intent(getContext(), MusicDownload.class);
startActivity(intent1);
break;
}
}
/**
*
*/
public void getMusicCount(){
SharedPreferences sp = getActivity().getSharedPreferences("music_count", Context.MODE_PRIVATE);
int count = sp.getInt("count",0);
tvLocalMusicCount.setText("("+count+")");
}
}

@ -0,0 +1,27 @@
package Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.netcloudsharing.R;
public class FragmentMusic_RankingList extends Fragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_music_rankinglist,container,false);
return view;
}
}

@ -0,0 +1,27 @@
package Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.netcloudsharing.R;
public class FragmentMusic_SongList extends Fragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_music_songlist,container,false);
return view;
}
}

@ -0,0 +1,46 @@
package Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.netcloudsharing.R;
import com.example.netcloudsharing.diary.MainActivity;
public class FragmentMy extends Fragment implements View.OnClickListener {
private Button btnDiary;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my,container,false);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
init(view);
}
private void init(View view) {
view.findViewById(R.id.fragment_my_ll_diary).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.fragment_my_ll_diary:
Intent intent = new Intent(getActivity(), MainActivity.class);
startActivity(intent);
break;
}
}
}

@ -0,0 +1,198 @@
package Fragment;
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.util.Log;
import android.view.View;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.example.netcloudsharing.R;
import com.example.netcloudsharing.service.MusicService;
import static com.example.netcloudsharing.service.MusicService.currentPlayPosition;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private FragmentMusic fragmentMusic;
private FragmentCommunity fragmentCommunity;
private FragmentMessage fragmentMessage;
private FragmentMy fragmentMy;
private ImageButton mImg1;
private ImageButton mImg2;
private ImageButton mImg3;
private ImageButton mImg4;
public static MusicService.MyBinder binder;
private myConn conn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();//初始化控件
initEvent();//初始化事件
conn = new myConn();
Intent intent = new Intent(this,MusicService.class);
bindService(intent,conn, Context.BIND_AUTO_CREATE);
Log.d("MainActivity","1");
selectTab(0);
}
/**
*
*/
private void initEvent() {
mImg1.setOnClickListener(this);
mImg2.setOnClickListener(this);
mImg3.setOnClickListener(this);
mImg4.setOnClickListener(this);
}
/**
*
*/
private void initView() {
//初始化ImageButton布局文件
mImg1 = findViewById(R.id.ib_tab_home);
mImg2 = findViewById(R.id.ib_tab_community);
mImg3 = findViewById(R.id.ib_tab_message);
mImg4 = findViewById(R.id.ib_tab_my);
}
//处理点击事件
@Override
public void onClick(View v) {
resetImages();
switch (v.getId()) {
case R.id.ib_tab_home:
selectTab(0);
break;
case R.id.ib_tab_community:
selectTab(1);
break;
case R.id.ib_tab_message:
selectTab(2);
break;
case R.id.ib_tab_my:
selectTab(3);
break;
}
}
//进行选中Tab的处理
private void selectTab(int i) {
//获取FragmentManager对象
FragmentManager manager = getSupportFragmentManager();
//获取FragmentTransaction对象
FragmentTransaction transaction = manager.beginTransaction();
//先隐藏好所有的Fragment
hideFragment(transaction);
switch (i) {
//将选中的Tab实例化并关联起来
case 0:
mImg1.setImageResource(R.drawable.select_home);
if (fragmentMusic == null) {
fragmentMusic = new FragmentMusic();
transaction.add(R.id.fl_content, fragmentMusic);
} else {
transaction.show(fragmentMusic);
}
break;
case 1:
mImg2.setImageResource(R.drawable.select_community);
if (fragmentCommunity == null) {
fragmentCommunity = new FragmentCommunity();
transaction.add(R.id.fl_content, fragmentCommunity);
} else {
transaction.show(fragmentCommunity);
}
break;
case 2:
mImg3.setImageResource(R.drawable.select_message);
if (fragmentMessage == null) {
fragmentMessage = new FragmentMessage();
transaction.add(R.id.fl_content, fragmentMessage);
} else {
transaction.show(fragmentMessage);
}
break;
case 3:
mImg4.setImageResource(R.drawable.select_my);
if (fragmentMy == null) {
fragmentMy = new FragmentMy();
transaction.add(R.id.fl_content, fragmentMy);
} else {
transaction.show(fragmentMy);
}
break;
}
//提交事务
transaction.commit();
}
//将Fragment进行隐藏
private void hideFragment(FragmentTransaction transaction) {
if (fragmentMusic != null) {
transaction.hide(fragmentMusic);
}
if (fragmentCommunity != null) {
transaction.hide(fragmentCommunity);
}
if (fragmentMessage != null) {
transaction.hide(fragmentMessage);
}
if (fragmentMy != null) {
transaction.hide(fragmentMy);
}
}
//重置导航图片
private void resetImages() {
mImg1.setImageResource(R.drawable.unselect_home);
mImg2.setImageResource(R.drawable.unselect_community);
mImg3.setImageResource(R.drawable.unselect_message);
mImg4.setImageResource(R.drawable.unselect_my);
}
private class myConn implements ServiceConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
binder = (MusicService.MyBinder) service;
Log.d("MainActivity","4");
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
}
@Override
protected void onDestroy() {
SharedPreferences sp = getSharedPreferences("lastMusicPlayPosition",MODE_PRIVATE);
SharedPreferences.Editor edit = sp.edit();
edit.putInt("lastMusicPlayPosition",currentPlayPosition);
edit.commit();
super.onDestroy();
}
}

@ -0,0 +1,76 @@
package com.example.netcloudsharing;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
public class LocalMusicAdapter extends RecyclerView.Adapter<LocalMusicAdapter.LocalMusicViewHolder> {
Context context;
List<LocalMusicBean> mDatas;
OnItemClickListener onItemClickListener;
public interface OnItemClickListener {
public void OnItemClick(View view, int position);
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
public LocalMusicAdapter(Context context, List<LocalMusicBean> mDatas) {
this.context = context;
this.mDatas = mDatas;
}
@NonNull
@Override
public LocalMusicViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.item_local_music, parent, false);
LocalMusicViewHolder holder = new LocalMusicViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull LocalMusicViewHolder holder, final int position) {
//绑定viewholder并且对每一个控件来进行赋值展示
LocalMusicBean musicBean = mDatas.get(position);
holder.idTv.setText(musicBean.getId());
holder.songTv.setText(musicBean.getSong());
holder.singerTv.setText(musicBean.getSinger());
holder.albumTv.setText(musicBean.getAlbum());
holder.timeTv.setText(musicBean.getDuration());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onItemClickListener.OnItemClick(v,position);
}
});
}
@Override
public int getItemCount() {
return mDatas.size();
}
class LocalMusicViewHolder extends RecyclerView.ViewHolder {
TextView idTv, songTv, singerTv, albumTv, timeTv;
public LocalMusicViewHolder(@NonNull View itemView) {
super(itemView);
idTv = itemView.findViewById(R.id.item_local_music_num);
songTv = itemView.findViewById(R.id.item_local_music_song);
singerTv = itemView.findViewById(R.id.item_local_music_singer);
albumTv = itemView.findViewById(R.id.item_local_music_album);
timeTv = itemView.findViewById(R.id.item_local_music_durtion);
}
}
}

@ -0,0 +1,89 @@
package com.example.netcloudsharing;
public class LocalMusicBean {
private String id; //歌曲id
private String song; //歌曲名称
private String singer; //歌手名
private String album; //专辑
private String duration; //持续的时间
private String path; //歌曲路径
private int album_id; //歌曲图片id
public LocalMusicBean() {
}
public LocalMusicBean(String id, String song, String singer, String album, String duration, String path, int album_id) {
this.id = id;
this.song = song;
this.singer = singer;
this.album = album;
this.duration = duration;
this.path = path;
this.album_id = album_id;
}
public LocalMusicBean(String id, String song, String singer, String album, String duration, String path) {
this.id = id;
this.song = song;
this.singer = singer;
this.album = album;
this.duration = duration;
this.path = path;
}
public int getAlbum_id() {
return album_id;
}
public void setAlbum_id(int album_id) {
this.album_id = album_id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSong() {
return song;
}
public void setSong(String song) {
this.song = song;
}
public String getSinger() {
return singer;
}
public void setSinger(String singer) {
this.singer = singer;
}
public String getAlbum() {
return album;
}
public void setAlbum(String album) {
this.album = album;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

@ -0,0 +1,110 @@
package com.example.netcloudsharing.Music;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import com.example.netcloudsharing.R;
import static Fragment.MainActivity.binder;
public class HttpGetDemoActivity extends Activity {
/**
* Called when the activity is first created.
*/
private Button onlinPlay, stop = null;
private SeekBar seekBar = null;
private static final String TAG = "HttpGetDemoActivity";
private MusicPlayer musicPlayer = null;
private String pathtext = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_player);
findView();
pathtext = getIntent().getStringExtra("path");
musicPlayer = new MusicPlayer(seekBar);
if(binder.isMusicPlaying()){
binder.stopMusic();
}
}
private void findView() {
onlinPlay = (Button) findViewById(R.id.btn_play);
stop = (Button) findViewById(R.id.btn_pause);
seekBar = (SeekBar) findViewById(R.id.seekBar_playing);
ButtonClickListener clickListener = new ButtonClickListener();
SeekBarChangeEvent seekBarChangeEvent = new SeekBarChangeEvent();
onlinPlay.setOnClickListener(clickListener);
stop.setOnClickListener(clickListener);
seekBar.setOnSeekBarChangeListener(seekBarChangeEvent);
}
private final class ButtonClickListener implements OnClickListener {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btn_play:
new Thread(new Runnable() {
@Override
public void run() {
//把http://abv.cn/music/光辉岁月.mp3传入并 播放音乐
musicPlayer.play(pathtext);
}
}).start();
break;
case R.id.btn_pause:
//暂停
musicPlayer.pause();
break;
default:
break;
}
}
}
class SeekBarChangeEvent implements OnSeekBarChangeListener {
int progress;
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
/**
* SeekBar
* progress
* this.progress
*/
this.progress = progress * musicPlayer.mediaPlayer.getDuration() / seekBar.getMax();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
/**
*
*/
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
/**
*
* seekTo()seekBar.getMax()
*/
musicPlayer.mediaPlayer.seekTo(progress);
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
musicPlayer.stop();
}
}

@ -0,0 +1,16 @@
package com.example.netcloudsharing.Music;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.example.netcloudsharing.R;
public class MusicDownload extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_download);
}
}

@ -0,0 +1,116 @@
package com.example.netcloudsharing.Music;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnBufferingUpdateListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Handler;
import android.os.Message;
import android.widget.SeekBar;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
public class MusicPlayer implements OnBufferingUpdateListener, OnPreparedListener {
/* SeekBar拖动条 */
private SeekBar seekBar = null;
/* 播放器 */
public MediaPlayer mediaPlayer = null;
/* Timer定时器 */
private Timer mTimer = new Timer();
private static final int SHOW_SEEKBAR = 0;
private boolean isPlaying = false;
public MusicPlayer(SeekBar seekBar) {
this.seekBar = seekBar;
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setOnBufferingUpdateListener(this);
mediaPlayer.setOnPreparedListener(this);
//使用定时器来改变seekBar的进度
mTimer.schedule(timerTask, 0, 1000);
}
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
if (mediaPlayer == null)
return;
if (isPlaying && !seekBar.isPressed()) {
mHandler.sendEmptyMessage(SHOW_SEEKBAR);
}
}
};
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == SHOW_SEEKBAR) {
if (mediaPlayer != null) {
int posttion = mediaPlayer.getCurrentPosition();//获取当前播放位置
int duration = mediaPlayer.getDuration();//获取总长度
int pos = (int) (100 * ((float) posttion / (float) duration));
seekBar.setProgress((int) pos);
}
}
}
};
public void play(String url) {
try {
mediaPlayer.reset();
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void pause() {
mediaPlayer.pause();
}
public void stop() {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();//结束后release
mediaPlayer = null;
isPlaying = false;
}
}
@Override
public void onBufferingUpdate(MediaPlayer arg0, int arg1) {
/**
* stream buffer
* seekBar
*/
this.seekBar.setSecondaryProgress(arg1);
}
@Override
public void onPrepared(MediaPlayer mp) {
/**
*
*
*/
mp.start();
isPlaying = true;
}
}

@ -0,0 +1,88 @@
package com.example.netcloudsharing.Music;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SearchView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.netcloudsharing.R;
public class MusicSearch extends AppCompatActivity {
private String[] mStrings = new String[]{"http://data.flash127.com/mp3_flash127_com/mp3/201806/20180601_1854_774058.mp3", "http://data.flash127.com/mp3_flash127_com/mp3/201802/20180205_1546_724406.mp3"
, "http://k6.kekenet.com/Sound/2019/08/m200016581_1484302841_1444410KGM.mp3", "http://data.flash127.com/mp3_flash127_com/mp3/201605/1462090742.mp3"};
String path;
private ListView listView;
private SearchView searchView;
private EditText etURL;
private ImageButton ibBack;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.music_search);
init();
}
private void init() {
etURL = findViewById(R.id.activity_music_search_etURL);
ibBack = findViewById(R.id.fragment_music_ibBackToMusicHome);
ibBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
listView = findViewById(R.id.listview);
listView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, mStrings));
//设置ListView启用过滤
// listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
etURL.setText(mStrings[position]);
}
});
searchView = findViewById(R.id.searchview);
//设置该SearchView默认是否自动缩小为图标
searchView.setIconifiedByDefault(false);
//设置该SearchView显示搜索按钮
searchView.setSubmitButtonEnabled(true);
searchView.setQueryHint("查找");
//为该SearchView组件设置事件监听器
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
//单机搜索按钮时激发该方法
@Override
public boolean onQueryTextSubmit(String query) {
//实际应用中应该在该方法内执行实际查询此处仅使用Toast显示用户输入的查询内容
path = String.valueOf(searchView.getQuery());
Intent intent = new Intent(MusicSearch.this,HttpGetDemoActivity.class);
intent.putExtra("path",path);
startActivity(intent);
return false;
}
//用户输入字符时激发该方法
@Override
public boolean onQueryTextChange(String newText) {
// tvSearchView.setText(searchView.getQuery());
//如果newText不是长度为0的字符串
if (TextUtils.isEmpty(newText)) {
//清除ListView的过滤
listView.clearTextFilter();
} else {
//使用用户输入的内容对ListView的列表项进行过滤
listView.setFilterText(newText);
}
return true;
}
});
}
}

@ -0,0 +1,23 @@
package com.example.netcloudsharing;
import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import com.example.netcloudsharing.activity.LoginActivity;
import com.example.netcloudsharing.activity.RegisterActivity;
import com.example.netcloudsharing.tool.BaseTool;
public class NetStart extends AppCompatActivity {
private Button btnLogin;
private Button btnRegister;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net_start);
Button btnLogin = BaseTool.openActivity(this,(Button)findViewById(R.id.btn_login),LoginActivity.class);
Button btnRegister = BaseTool.openActivity(this,(Button)findViewById(R.id.btn_register), RegisterActivity.class);
}
}

@ -0,0 +1,264 @@
package com.example.netcloudsharing.activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.example.netcloudsharing.R;
import com.example.netcloudsharing.diary.Permission;
import com.example.netcloudsharing.tool.BaseTool;
import com.example.netcloudsharing.tool.UserDao;
import com.example.netcloudsharing.tool.Userinfo;
import Fragment.MainActivity;
public class LoginActivity extends AppCompatActivity{
private EditText etAccount;
private EditText etPassword;
private CheckBox cbAccount;
private CheckBox cbPassword;
private Handler mainHandle; //主线程
private UserDao dao; //用户数据库操作类
private String TAG = "LoginActivity";
private String SP_ACCOUNT = "sp_account";
private String SP_PASSWORD = "sp_password";
private String SP_IS_REMEMBER_ACCOUNT = "sp_is_remember_account";
private String SP_IS_REMEMBER_Password = "sp_is_remember_password";
private SharedPreferences sharedPreferences;
private boolean isCheckedAccount = false;
private boolean isCheckedPassword = false;
private Context context = this;
private Permission permission;
private Handler handler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
//super.handleMessage(msg);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
//初始化控件
initUI();
//初始化数据
initData();
permission = new Permission();
permission.checkPermission(LoginActivity.this);
}
private void initData() {
if(sharedPreferences==null){
sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE);
}
isCheckedAccount = sharedPreferences.getBoolean(SP_IS_REMEMBER_ACCOUNT,false);
isCheckedPassword = sharedPreferences.getBoolean(SP_IS_REMEMBER_Password,false);
//回写数据
if(isCheckedAccount){
etAccount.setText(sharedPreferences.getString(SP_ACCOUNT,""));
}
if(isCheckedPassword){
etPassword.setText(sharedPreferences.getString(SP_PASSWORD,""));
}
cbAccount.setChecked(isCheckedAccount);
cbPassword.setChecked(isCheckedPassword);
}
private void initUI(){
dao = new UserDao(); //操作数据库类
mainHandle = new Handler(getMainLooper()); //获取主线程
etAccount = findViewById(R.id.login_et_account);
etPassword = findViewById(R.id.login_et_password);
//设置编辑框监听器
login_etListener();
cbAccount = findViewById(R.id.cb_remember_account);
cbPassword = findViewById(R.id.cb_remember_password);
//设置复选框监听器
login_cbListener();
Button btnLogin = findViewById(R.id.login_btn_login);
//设立点击事件——登录
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String account = etAccount.getText().toString().trim();
String password = etPassword.getText().toString().trim();
login(account,password);
}
});
Button btnTouristLogin = findViewById(R.id.login_btn_tourist);
btnTouristLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BaseTool.showShortMsg(context,"欢迎进入");
BaseTool.navigateTo(context,MainActivity.class);
}
});
}
/**
*
*/
private void login_cbListener(){
/**
*
*/
cbAccount.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.d(TAG,"账号状态为:"+isChecked);
isCheckedAccount = isChecked;
//实例化sharedPreferences对象
if(sharedPreferences==null){
sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE);
}
//实例化sharedPreferences的编辑者对象
SharedPreferences.Editor edit = sharedPreferences.edit();
//存储数据
if(isChecked) {
edit.putString(SP_ACCOUNT, etAccount.getText().toString().trim());
}
edit.putBoolean(SP_IS_REMEMBER_ACCOUNT,isChecked);
//提交
edit.commit();
}
});
/**
*
*/
cbPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.d(TAG, "密码状态为:" + isChecked);
isCheckedPassword = isChecked;
//实例化sharedPreferences对象
if (sharedPreferences == null) {
sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE);
}
//实例化sharedPreferences的编辑者对象
SharedPreferences.Editor edit = sharedPreferences.edit();
//存储数据
if (isChecked) {
edit.putString(SP_PASSWORD, etPassword.getText().toString().trim());
}
edit.putBoolean(SP_IS_REMEMBER_Password, isChecked);
//提交
edit.commit();
}
});
}
/**
*
*/
private void login_etListener(){
etAccount.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if(isCheckedAccount){
//实例化sharedPreferences对象
if(sharedPreferences==null){
sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE);
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(SP_ACCOUNT,etAccount.getText().toString().trim());
edit.commit();
}
}
});
etPassword.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if(isCheckedPassword){
//实例化sharedPreferences对象
if(sharedPreferences==null){
sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE);
}
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(SP_PASSWORD, etPassword.getText().toString().trim());
edit.commit();
}
}
});
}
/**
*
* @param account
* @param password
*/
private void login(final String account, final String password){
if(TextUtils.isEmpty(account)){
BaseTool.showShortMsg(this,getString(R.string.please_input_account));
etAccount.requestFocus();
}else if(TextUtils.isEmpty(password)){
BaseTool.showShortMsg(this,getString(R.string.please_input_password));
etPassword.requestFocus();
}else{
new Thread(new Runnable() {
@Override
public void run() {
final Userinfo item = dao.getUserByUnameAndUpass(account,password);
mainHandle.post(new Runnable() {
@Override
public void run() {
if(item==null){
BaseTool.showDlaMsg(context,"用户名或密码错误");
}else{
BaseTool.showShortMsg(context,"登录成功");
Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(context,MainActivity.class);
context.startActivity(intent);
}
}
});
}
}).start();
}
}
}

@ -0,0 +1,91 @@
package com.example.netcloudsharing.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
//import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
//import android.widget.Toast;
import com.example.netcloudsharing.R;
import com.example.netcloudsharing.tool.BaseTool;
import com.example.netcloudsharing.tool.UserDao;
import com.example.netcloudsharing.tool.Userinfo;
import java.util.Date;
import Fragment.MainActivity;
public class RegisterActivity extends AppCompatActivity {
private EditText etAccount;
private EditText etPassword;
private Handler mainHandle; //主线程
private UserDao dao; //用户操作数据库类
private Context context = this;
// private Handler handler = new Handler(){
// @Override
// public void handleMessage(@NonNull Message msg) {
// //super.handleMessage(msg);
//
// }
// };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
etAccount = findViewById(R.id.register_et_account);
etPassword = findViewById(R.id.register_et_password);
Button btnRegister = findViewById(R.id.register_btn_register);
dao = new UserDao();
mainHandle = new Handler(getMainLooper());
btnRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String account = etAccount.getText().toString().trim();
String password = etPassword.getText().toString().trim();
String createDt = String.format("%tY-%<tm-%<td",new Date());
register(account,password,createDt);
}
});
}
private void register(final String account, final String password,final String createDt){
if(TextUtils.isEmpty(account)){
BaseTool.showShortMsg(RegisterActivity.this,getString(R.string.please_input_account));
etAccount.requestFocus();
}else if(TextUtils.isEmpty(password)){
BaseTool.showShortMsg(RegisterActivity.this,getString(R.string.please_input_password));
etPassword.requestFocus();
}else{
new Thread(new Runnable() {
@Override
public void run() {
Userinfo item = new Userinfo(0,account,password,createDt);
final int result = dao.addUser(item);
mainHandle.post(new Runnable() {
@Override
public void run() {
if(result==0)
BaseTool.showDlaMsg(RegisterActivity.this,"注册失败请等待5秒后重新注册");
else{
Intent intent = new Intent(context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(context,MainActivity.class);
context.startActivity(intent);
}
// BaseTool.showDlaMsg(RegisterActivity.this,"注册成功");
}
});
}
}).start();
}
}
}

@ -0,0 +1,119 @@
package com.example.netcloudsharing.diary;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.VideoView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.netcloudsharing.R;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class AddContent extends AppCompatActivity implements View.OnClickListener {
private String val;
private Button btnSave, btnCancel, btnBack;
private EditText etText;
private ImageView ivImage;
private VideoView vvVideo;
private NotesDB notesDB;
private SQLiteDatabase dbWriter;
private File file = null;
private String currentPath = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.diary_add_content);
init();
val = getIntent().getStringExtra("flag");
notesDB = new NotesDB(this);
dbWriter = notesDB.getWritableDatabase();
selectView();
}
/**
*
*/
public void selectView() {
NoteInfo info = (NoteInfo) getIntent().getSerializableExtra("noteInfo");
if (val.equals("1")) {
//文字
ivImage.setVisibility(View.GONE);
vvVideo.setVisibility(View.GONE);
if(info!=null){
etText.setText(info.getContent());
}
} else if (val.equals("2")) {
//图片
ivImage.setVisibility(View.VISIBLE);
vvVideo.setVisibility(View.GONE);
if(info!=null){
currentPath = info.getPath();
etText.setText(info.getContent());
}else{
currentPath = getIntent().getStringExtra("path");
}
Bitmap bitmap = BitmapFactory.decodeFile(currentPath);
ivImage.setImageBitmap(bitmap);
} else if (val.equals("3")) {
//视频
ivImage.setVisibility(View.GONE);
vvVideo.setVisibility(View.VISIBLE);
}
}
private void init() {
btnSave = findViewById(R.id.addContent_btnSave);
btnCancel = findViewById(R.id.addContent_btnCancel);
btnBack = findViewById(R.id.addContent_btnBack);
etText = findViewById(R.id.addContent_etText);
ivImage = findViewById(R.id.addContent_ivImage);
vvVideo = findViewById(R.id.addContent_vvVideo);
btnSave.setOnClickListener(this);
btnCancel.setOnClickListener(this);
btnBack.setOnClickListener(this);
}
public void addDB() {
ContentValues cv = new ContentValues();
cv.put(NotesDB.CONTENT, etText.getText().toString());
cv.put(NotesDB.TIME, getTime());
cv.put(NotesDB.PATH, currentPath);
cv.put(NotesDB.TYPE, val);
dbWriter.insert(NotesDB.TABLE_NAME, null, cv);
}
public String getTime() {
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss", Locale.CHINA);
Date curDate = new Date();
return format.format(curDate);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.addContent_btnSave:
addDB();
finish();
break;
case R.id.addContent_btnCancel:
finish();
break;
case R.id.addContent_btnBack:
finish();
break;
}
}
}

@ -0,0 +1,308 @@
package com.example.netcloudsharing.diary;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;
import com.example.netcloudsharing.R;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.xujiaji.happybubble.BubbleDialog;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private NotesDB notesDB;
private Button btnText, btnImg, btnVideo;
private ListView lv;
private Intent intent;
private MyAdapter adapter;
private BottomSheetDialog dialog;
private final int REQUEST_CAMERA = 1;
private final int REQUEST_PICK = 2;
private final int REQUEST_ALTER = 3;
private String currentPath = null;
private Permission permission;
private List<NoteInfo> mData;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.diary_main);
init();
mData = new ArrayList<>();
notesDB = new NotesDB(this);
Log.d("Main", "onCreate");
}
private void init() {
btnText = findViewById(R.id.btn_text);
btnImg = findViewById(R.id.btn_img);
btnVideo = findViewById(R.id.btn_video);
lv = findViewById(R.id.lv);
btnVideo.setOnClickListener(this);
btnText.setOnClickListener(this);
btnImg.setOnClickListener(this);
String[] mode = {"相机", "相册", "取消"};
ListView listView = new ListView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
listView.setLayoutParams(params);
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mode));
dialog = new BottomSheetDialog(this);
dialog.setContentView(listView);
//选择图文模块后顶部弹出listView选择框
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
permission = new Permission();
permission.checkPermission(MainActivity.this);
switch (position) {
case 0:
dispatchTakePictureIntent();
dialog.dismiss();
break;
case 1:
Intent intent1 = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent1.setType("image/*");
startActivityForResult(intent1, REQUEST_PICK);
dialog.dismiss();
break;
case 2:
dialog.dismiss();
break;
default:
break;
}
}
});
}
static final int REQUEST_IMAGE_CAPTURE = 1;
public void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//必须确保手机上有相机,才可以继续,否则会一直闪退,故加判断语句
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
ex.printStackTrace();
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(this, "com.example.netcloudsharing.fileprovider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
}
private File createImageFile() throws IOException {
//Create an image file name
String imageFileName = getTimeToPath();
Log.d("imageFileName", imageFileName);
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName,
".jpg",
storageDir
);
currentPath = image.getAbsolutePath();
Log.d("imageFileName", currentPath);
return image;
}
public String getTimeToPath() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA);
Date curDate = new Date();
return format.format(curDate);
}
@Override
public void onClick(View v) {
intent = new Intent(this, AddContent.class);
switch (v.getId()) {
case R.id.btn_text:
intent.putExtra("flag", "1");
startActivity(intent);
break;
case R.id.btn_img:
intent.putExtra("flag", "2");
dialog.show();
break;
case R.id.btn_video:
intent.putExtra("flag", "3");
startActivity(intent);
break;
}
}
public void deleteDB(int position) {
String id = mData.get(position).getId();
SQLiteDatabase dbWrite = notesDB.getWritableDatabase();
dbWrite.delete(NotesDB.TABLE_NAME, NotesDB.ID + "=?", new String[]{id + ""});
dbWrite.close();
selectDB();
}
public void selectDB() {
//将链表清空
mData.clear();
SQLiteDatabase dbReader = notesDB.getReadableDatabase();
Cursor cursor = dbReader.query(NotesDB.TABLE_NAME, null, null, null, null, null, null);
while (cursor.moveToNext()) {
String id = cursor.getString(cursor.getColumnIndex(NotesDB.ID));
String content = cursor.getString(cursor.getColumnIndex(NotesDB.CONTENT));
String path = cursor.getString(cursor.getColumnIndex(NotesDB.PATH));
String video = cursor.getString(cursor.getColumnIndex(NotesDB.VIDEO));
String time = cursor.getString(cursor.getColumnIndex(NotesDB.TIME));
int type = cursor.getInt(cursor.getColumnIndex(NotesDB.TYPE));
NoteInfo info = new NoteInfo(content, path, video, id, time, type);
mData.add(info);
}
cursor.close();
dbReader.close();
adapter = new MyAdapter(this, mData);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(MainActivity.this, AddContent.class);
NoteInfo noteInfo = mData.get(position);
intent.putExtra("noteInfo", noteInfo);
intent.putExtra("flag", noteInfo.getType() + "");
Log.d("flag", noteInfo.getType() + "");
startActivity(intent);
}
});
lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
View viewDelete = LayoutInflater.from(MainActivity.this).inflate(R.layout.diary_button_delete, null);
//设置长按删除按钮
final BubbleDialog bubbleDialog = new BubbleDialog(MainActivity.this);
bubbleDialog.addContentView(viewDelete).setClickedView(view).calBar(true).calBar(true).show();
Button btnDelete = viewDelete.findViewById(R.id.diary_btnDelete);
btnDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
deleteDB(position);
bubbleDialog.dismiss();
}
});
return true;
}
});
}
/**
*
*/
@Override
protected void onResume() {
super.onResume();
Log.d("Main", "OnResume");
selectDB();
}
/**
*
*
* @param requestCode
* @param resultCode
* @param data
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_CAMERA: {
Intent intent = new Intent(this, AddContent.class);
intent.putExtra("path", currentPath);
intent.putExtra("flag", "2");
startActivity(intent);
break;
}
case REQUEST_PICK: {
Uri uri = null;
// try 是有可能未选择图片就进行返回,会造成空指针
try {
uri = data.getData(); //获取系统返回的照片uri
} catch (NullPointerException e) {
e.printStackTrace();
} finally {
if (uri != null) {
// 使用ContentResolve 进行读取选择的图片路径
String[] strings = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(uri, strings, null, null, null);
cursor.moveToFirst();
int index = cursor.getColumnIndex(strings[0]);
String path = cursor.getString(index); //获取图片路径
cursor.close();
Intent intent = new Intent(this, AddContent.class);
intent.putExtra("path", path);
intent.putExtra("flag", "2");
startActivity(intent);
}
}
break;
}
}
}
}
/**
*
*
* @param requestCode
* @param permissions
* @param grantResults
*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == permission.REQUEST_CODE) {
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
Log.e("permission", permissions[i] + "not");
Log.e("permission", grantResults[i] + "not");
} else {
Log.e("permission", permissions[i] + "");
Log.e("permission", grantResults[i] + "");
}
}
}
}
}

@ -0,0 +1,100 @@
package com.example.netcloudsharing.diary;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.ThumbnailUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.netcloudsharing.R;
import java.util.List;
public class MyAdapter extends BaseAdapter {
private Context context;
private ViewHolder holder;
private List<NoteInfo> data;
MyAdapter(Context context, List<NoteInfo> data) {
this.context = context;
this.data = data;
}
@Override
public int getCount() {
return data.size();
}
@Override
public Object getItem(int position) {
return data.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.diary_list_item, parent, false);
holder = new ViewHolder();
holder.tv_listContent = convertView.findViewById(R.id.list_tvContent);
holder.tv_listTime = convertView.findViewById(R.id.list_tvTime);
holder.iv_listImage = convertView.findViewById(R.id.list_ivImg);
holder.iv_listVideo = convertView.findViewById(R.id.list_ivVideo);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.tv_listContent.setText(data.get(position).getContent());
holder.tv_listTime.setText(data.get(position).getTime());
holder.iv_listImage.setImageBitmap(getImageThumbnail(data.get(position).getPath(),
200, 200));
return convertView;
}
/**
*
*
* @param uri
* @param width
* @param height
* @return
*/
public Bitmap getImageThumbnail(String uri, int width, int height) {
Bitmap bitmap = null;
//获取缩略图
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
bitmap = BitmapFactory.decodeFile(uri, options);
options.inJustDecodeBounds = false;
int beWidth = options.outWidth / width;
int beHeight = options.outHeight / height;
int be = 1 ;
if (beWidth < beHeight) {
be = beWidth;
} else {
be = beHeight;
}
if (be <= 0) {
be = 1;
}
options.inSampleSize = be;
bitmap = BitmapFactory.decodeFile(uri, options);
bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height,
ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
return bitmap;
}
}
class ViewHolder {
public TextView tv_listContent, tv_listTime;
public ImageView iv_listImage, iv_listVideo;
}

@ -0,0 +1,73 @@
package com.example.netcloudsharing.diary;
import java.io.Serializable;
public class NoteInfo implements Serializable {
private String content;
private String path;
private String video;
private String id;
private String time;
private int type;
public NoteInfo() {
}
public NoteInfo(String content, String path, String video, String id, String time,int type) {
this.content = content;
this.path = path;
this.video = video;
this.id = id;
this.time = time;
this.type = type;
}
public void setType(int type) {
this.type = type;
}
public int getType() {
return type;
}
public void setContent(String content) {
this.content = content;
}
public void setPath(String path) {
this.path = path;
}
public void setVideo(String video) {
this.video = video;
}
public void setId(String id) {
this.id = id;
}
public void setTime(String time) {
this.time = time;
}
public String getContent() {
return content;
}
public String getPath() {
return path;
}
public String getVideo() {
return video;
}
public String getId() {
return id;
}
public String getTime() {
return time;
}
}

@ -0,0 +1,33 @@
package com.example.netcloudsharing.diary;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class NotesDB extends SQLiteOpenHelper {
public static final String TABLE_NAME = "note";
public static final String CONTENT = "content";
public static final String PATH = "path";
public static final String VIDEO = "video";
public static final String ID = "_id";
public static final String TIME = "time";
public static final String TYPE = "type";
public NotesDB(Context context) {
super(context, "notes", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_NAME + "(" + ID
+ " integer not null primary key autoincrement," + CONTENT
+ " text," + PATH + " text," + VIDEO
+ " text," + TIME + " text not null,"+ TYPE
+ " tinyint not null)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

@ -0,0 +1,36 @@
package com.example.netcloudsharing.diary;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.util.ArrayList;
import java.util.List;
public class Permission {
private static final String[] permission = {
Manifest.permission.CAMERA,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_FINE_LOCATION};
private List<String> permissionList = new ArrayList<>();
public int REQUEST_CODE = 1000;
public void checkPermission(Activity activity) {
for (int i = 0; i < permission.length; i++) {
if (ContextCompat.checkSelfPermission(activity, permission[i]) != PackageManager.PERMISSION_GRANTED) {
permissionList.add(permission[i]);
}
}
if(permissionList.size()>0){
requestPermission(activity);
}
}
private void requestPermission(Activity activity) {
ActivityCompat.requestPermissions(activity,permissionList.toArray(new String[permissionList.size()]),REQUEST_CODE);
}
}

@ -0,0 +1,26 @@
package com.example.netcloudsharing.game;
import android.graphics.RectF;
public class PiecesRectF extends RectF {
private int type;
public final static int BLAKE = 0;//黑块
public final static int WRITE = 1;//白块
public final static int BLUE = 2;//黑块按下时的显示蓝块
public final static int START = 3;//标记有开始的黑块
public final static int RED = 4;//按到白块,或有黑块漏按,游戏结束时的红块
public PiecesRectF(){
super();
type = Math.random() > 0.5 ? 0:1;//初始化时给type随机一个白块或黑块
}
public void setType(int type) {
this.type = type;
}
public int getType() {
return type;
}
}

@ -0,0 +1,328 @@
package com.example.netcloudsharing.game;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.MotionEvent;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
public class WhitePiecesView extends androidx.appcompat.widget.AppCompatTextView {
private final static String TAG = WhitePiecesView.class.getSimpleName();
private Paint mPaint;
private PiecesRectF[][] ovals = new PiecesRectF[5][4];//屏幕上的方格块
private SparseArray<PiecesRectF> selectOvals = new SparseArray<PiecesRectF>();//点击时选中的方格块
private int topOvalHeight = 0;//最上面一行方格的高度
private int score = 0;
private boolean isGameOver;//游戏是否结束
private boolean isGameWin;//游戏输赢
private boolean once = true;
private int index;
private int speed = 20;
public WhitePiecesView(Context context) {
this(context,null);
}
public WhitePiecesView(Context context, AttributeSet attrs) {
this(context, attrs,0);
}
public WhitePiecesView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mPaint = new Paint();
initOvals();//初始化方块
}
private void initOvals(){
for (int i = 0;i < 5;i++){
for (int j = 0;j<4;j++){
ovals[i][j] = new PiecesRectF();
if (j == 1){
//如果是第二列,则若第一列的是黑块将这个方块设为白块
if (ovals[i][j-1].getType() == PiecesRectF.BLAKE ||
ovals[i][j-1].getType() == PiecesRectF.START) {
ovals[i][j].setType(PiecesRectF.WRITE);
}
}else if (j == 3){
//如果是第四列,同样若第一列的是黑块将这个方块设为白块
if (ovals[i][j-1].getType() == PiecesRectF.BLAKE ||
ovals[i][j-1].getType() == PiecesRectF.START) {
ovals[i][j].setType(PiecesRectF.WRITE);
}
//如果是第四列,且前四列的都为白块,则设为黑块
else if (ovals[i][j-2].getType() == PiecesRectF.WRITE &&
ovals[i][j-3].getType() == PiecesRectF.WRITE) {
ovals[i][j].setType(PiecesRectF.BLAKE);
}
}
if (i == 4){
if (ovals[i][j].getType() == PiecesRectF.BLAKE)
ovals[i][j].setType(PiecesRectF.START);//若是最后一行将黑块的type替换为START
}
}
}
}
private WhitePiecesListener MyWhitePiecesListener;
public void setWhitePiecesListener(WhitePiecesListener myWhitePiecesListener) {
MyWhitePiecesListener = myWhitePiecesListener;
}
public interface WhitePiecesListener{
void getScore(int score,int grade);
void gameOver();
void gameWin();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawRect(canvas);
}
private void drawRect(Canvas canvas){
int w = getWidth()/4;//得到每个小方块的宽
int h = getHeight()/4;//得到每个小方块的高
if(isGameWin){
MyWhitePiecesListener.gameWin();
isGameWin = false;
}
if (isGameOver){
//游戏结束
MyWhitePiecesListener.gameOver();
isGameOver = false;
}
for (int i = 0;i < 5;i++){
for (int j = 0;j < 4;j++){
ovals[i][j].left = w * j;
ovals[i][j].right = w * (j + 1);
ovals[i][j].bottom = topOvalHeight + i * h;
ovals[i][j].top = ovals[i][j].bottom - h;
mPaint.setStyle(Paint.Style.FILL);//绘制色块时设置画笔为FILL
switch (ovals[i][j].getType()){
case PiecesRectF.BLAKE:{
//绘制黑块
mPaint.setColor(Color.BLACK);
canvas.drawRect(ovals[i][j],mPaint);
break;
}
case PiecesRectF.BLUE:{
//绘制蓝块
mPaint.setColor(Color.BLUE);
canvas.drawRect(ovals[i][j],mPaint);
break;
}
case PiecesRectF.RED:{
//绘制红块
mPaint.setColor(Color.RED);
canvas.drawRect(ovals[i][j],mPaint);
break;
}
case PiecesRectF.START:{
//先绘制黑块
mPaint.setColor(Color.BLACK);
canvas.drawRect(ovals[i][j],mPaint);
//在绘制文字
mPaint.setColor(Color.parseColor("#ffffff"));
mPaint.setTextAlign(Paint.Align.CENTER);
mPaint.setTextSize(50);
String start = "开始";
Rect bounds = new Rect();
mPaint.getTextBounds(start,0,start.length(),bounds);
float x = ovals[i][j].left / 2 + ovals[i][j].right / 2;
float y = ovals[i][j].top / 2 + ovals[i][j].bottom / 2 + bounds.bottom / 2 - bounds.top / 2;
canvas.drawText(start,x,y,mPaint);
break;
}
}
//设置画笔为STROKE绘制边框
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.parseColor("#ffffff"));
mPaint.setStrokeWidth(3);
canvas.drawRect(ovals[i][j],mPaint);
}
}
}
//@android.support.annotation.RequiresApi(api = Build.VERSION_CODES.FROYO)
@Override
public boolean onTouchEvent(MotionEvent event) {
int index = event.getActionIndex();
switch (event.getActionMasked()){
case ACTION_DOWN:
case ACTION_POINTER_DOWN: {
int id = event.getPointerId(index);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 4; j++) {
PiecesRectF f = ovals[i][j];
if (event.getX() > f.left && event.getX() < f.right
&& event.getY() > f.top && event.getY() < f.bottom) {
selectOvals.put(id, f);//点击选中的方块存入SparseArray
switch (f.getType()){
case PiecesRectF.BLAKE:{
if (!once) {
f.setType(PiecesRectF.BLUE);
score++;
}
break;
}
case PiecesRectF.START:{
if (once){
//判断第一次按中
startThread();
once = false;
}
//按黑块处理
f.setType(PiecesRectF.BLUE);
score++;
break;
}
case PiecesRectF.WRITE:{
if (!once) {
//点中白块GameOver
f.setType(PiecesRectF.RED);
isGameOver = true;
invalidate();
}
break;
}
}
MyWhitePiecesListener.getScore(score,21-speed);
}
}
}
break;
}
case ACTION_UP:
case ACTION_POINTER_UP:{
int id = event.getPointerId(index);
PiecesRectF f = selectOvals.get(id,null);//得到某个手指选中的方块
if (f != null && f.getType() == PiecesRectF.BLUE ){
//手指抬起后,将蓝色重新变红
f.setType(PiecesRectF.WRITE);
}
break;
}
}
return true;
}
private void startThread() {
new Thread(new Runnable() {
@Override
public void run() {
while(true){
if(speed == 5){
isGameWin = true;
postInvalidate();
return;
}
if(score>=10*(21-speed)){
speed--;
}
topOvalHeight =topOvalHeight + 20;//这里写死了滑动速度
if (isGameOver) {//如果游戏已经结束,结束循环
return;
}
if (topOvalHeight > getHeight()/4) {
topOvalHeight = 0;//若最顶层的方块的高,超出正常方块的的高,清零。
if (checkBottomOvals()){//检测是否有黑色方块漏点
//有漏点,游戏结束
isGameOver = true;
postInvalidate();
return;
}else
//没有漏点,更新方块游戏结束
updateRectF();
}
try {
Thread.sleep(speed);
} catch (InterruptedException e) {
e.printStackTrace();
}
postInvalidate();
}
}
}).start();
}
private boolean checkBottomOvals(){
boolean haveBlake = false;
for (int i = 0;i < 4;i++){
if (ovals[4][i].getType() == PiecesRectF.BLAKE
|| ovals[4][i].getType() == PiecesRectF.START) {
//判断最后一行是否存在BLAKE或START方块
//如果有将其设为红色
ovals[4][i].setType(PiecesRectF.RED);
haveBlake = true;
}
}
return haveBlake;
}
/**
*
*/
private void updateRectF(){
for (int i = 4; i >= 0; i--) {
for (int j = 0; j < 4; j++) {
if (i == 0) {//如果是第一行,重新初始化一行
ovals[i][j] = new PiecesRectF();
if (j == 1){
if (ovals[i][j-1].getType() == PiecesRectF.BLAKE)
ovals[i][j].setType(PiecesRectF.WRITE);
}else if (j == 3){
if (ovals[i][j-1].getType() == PiecesRectF.BLAKE)
ovals[i][j].setType(PiecesRectF.WRITE);
else if (ovals[i][j-2].getType() == PiecesRectF.WRITE &&
ovals[i][j-3].getType() == PiecesRectF.WRITE)
ovals[i][j].setType(PiecesRectF.BLAKE);
}
}
else//否则,将行数后移
ovals[i][j] = ovals[i - 1][j];
}
}
}
public void restart(){
once = true;
topOvalHeight = 0;//顶层高度归零
score = 0;//分数归零
speed = 20;
MyWhitePiecesListener.getScore(score,21-speed);
initOvals();//重新初始化
invalidate();//再次绘制
}
}

@ -0,0 +1,231 @@
package com.example.netcloudsharing.service;
import android.app.Service;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
import android.provider.MediaStore;
import android.util.Log;
import android.widget.Toast;
import com.example.netcloudsharing.LocalMusicBean;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class MusicService extends Service {
private static final String TAG = "MusicService";
private List<LocalMusicBean> mData;
MediaPlayer mediaPlayer;
//记录当前正在播放的音乐的位置
public static int currentPlayPosition = -1;//默认没有播放
//记录暂停音乐时进度条哦的位置
int currentPausePositionInSong = 0;
MyBinder binder;
public class MyBinder extends Binder {
/**
*
*
* @param position
*/
public void playMusicPosition(int position) {
if (position >= 0 && position <= mData.size())
playMusicPosition(mData.get(position));
}
/**
*
*
* @param musicBean
*/
public void playMusicPosition(LocalMusicBean musicBean) {
if (mData.size() == 0) return;
if (musicBean == null) {
musicBean = mData.get(0);
currentPlayPosition = 0;
}
stopMusic();
//重装多媒体播放器
mediaPlayer.reset();
//设置新的播放路径
try {
mediaPlayer.setDataSource(musicBean.getPath());
playMusic();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
*
*
* 1.
* 2.
*/
public void playMusic() {
if (mediaPlayer != null && !mediaPlayer.isPlaying()) {
if (currentPausePositionInSong == 0) {
try {
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
} else {
//从暂停到播放
mediaPlayer.seekTo(currentPausePositionInSong);
mediaPlayer.start();
}
}
}
/**
*
*/
public void pauseMusic() {
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
currentPausePositionInSong = mediaPlayer.getCurrentPosition();
mediaPlayer.pause();
}
}
/**
*
*/
public void stopMusic() {
if (mediaPlayer != null) {
currentPausePositionInSong = 0;
mediaPlayer.pause();
mediaPlayer.seekTo(0);
mediaPlayer.stop();
}
}
/**
*
*/
public void playLastMusic() {
if (currentPlayPosition == -1) {
Toast.makeText(getApplicationContext(), "没有音乐正在播放中", Toast.LENGTH_SHORT).show();
} else if (currentPlayPosition == 0) {
Toast.makeText(getApplicationContext(), "已经是第一首", Toast.LENGTH_SHORT).show();
} else {
currentPlayPosition--;
playMusicPosition(mData.get(currentPlayPosition));
}
}
/**
*
*/
public void playNextMusic() {
if (currentPlayPosition == -1) {
Toast.makeText(getApplicationContext(), "没有音乐正在播放中", Toast.LENGTH_SHORT).show();
} else if (currentPlayPosition == mData.size() - 1) {
Toast.makeText(getApplicationContext(), "已经是最后一首", Toast.LENGTH_SHORT).show();
} else {
currentPlayPosition++;
playMusicPosition(mData.get(currentPlayPosition));
}
}
public LocalMusicBean getMusicBean() {
return mData.get(currentPlayPosition);
}
/**
*
*
* @return
*/
public boolean isMusicPlaying() {
return mediaPlayer.isPlaying();
}
}
@Override
public void onCreate() {
super.onCreate();
Log.d("MainActivity", "2");
mData = new ArrayList<>();
//加载本地数据源
loadLocalMusicData();
mediaPlayer = new MediaPlayer();
//恢复上次关闭程序的播放位置
SharedPreferences sp = getSharedPreferences("lastMusicPlayPosition", MODE_PRIVATE);
currentPlayPosition = sp.getInt("lastMusicPlayPosition", -1);
//设置播放完成后自动播放下一曲
setAutoMusic();
}
/**
*
*/
private void setAutoMusic() {
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (currentPlayPosition == mData.size() - 1) {
Toast.makeText(getApplicationContext(), "最后一首歌曲啦,请重新播放", Toast.LENGTH_SHORT).show();
currentPlayPosition = 0;
binder.stopMusic();
} else {
currentPlayPosition++;
binder.playMusicPosition(currentPlayPosition);
}
}
});
}
@Override
public IBinder onBind(Intent intent) {
Log.d("MainActivity", "3");
this.binder = new MyBinder();
return this.binder;
}
/**
* MP3
*/
private void loadLocalMusicData() {
//1.获取ContentResolver对象
ContentResolver contentResolver = getContentResolver();
//2.获取本地音乐的Uri地址
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
//3.开始查询
Cursor cursor = contentResolver.query(uri, null, null, null, null);
//4.遍历
int id = 0;
while (cursor.moveToNext()) {
//内存里面存的是毫秒
long duration = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
int minute = (int) (duration / 1000 / 60);
int second = (int) (duration / 1000 % 60);
if (minute < 1) continue;
id++;
String song = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
String singer = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
String album = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM));
String sid = String.valueOf(id);
String path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
String time = String.valueOf(minute) + ":" + String.valueOf(second);
//将一行当中的数据封装到对象中
LocalMusicBean bean = new LocalMusicBean(sid, song, singer, album, time, path);
mData.add(bean);
}
}
}

@ -0,0 +1,68 @@
package com.example.netcloudsharing.tool;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class BaseTool{
/**
* button
* @param context
* @param btn
* @param cls class
* @return
*/
public static Button openActivity(final Context context, Button btn, final Class cls){
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BaseTool.navigateTo(context,cls);
}
});
return btn;
}
/**
* Activity
* @param context
* @param cls class
*/
public static void navigateTo(Context context,Class cls){
Intent intent = new Intent(context,cls);
context.startActivity(intent);
}
/**
*
* @param context
* @param msg
*/
public static void showShortMsg(Context context,String msg){
Toast.makeText(context,msg,Toast.LENGTH_SHORT).show();
}
/**
*
* @param context
* @param msg
*/
public static void showLongMsg(Context context,String msg){
Toast.makeText(context,msg,Toast.LENGTH_LONG).show();
}
/**
*
* @param context
* @param msg
*/
public static void showDlaMsg(Context context,String msg){
new AlertDialog.Builder(context)
.setTitle("提示信息")
.setMessage(msg)
.setPositiveButton("确定",null)
.setNegativeButton("取消",null)
.create().show();
}
}

@ -0,0 +1,55 @@
package com.example.netcloudsharing.tool;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
/*
*/
public class DbOpenHelper {
final static private String CLS = "com.mysql.jdbc.Driver";
final static private String URL = "jdbc:mysql://10.77.169.229:3306/netsharingdb";
final static private String USER = "zzc";
final static private String PWD = "112211";
public static Connection conn; //连接对象
public static Statement stmt; //命令集
public static PreparedStatement pStmt; //预编译命令集
public static ResultSet rs; //结果集
//取得连接的方法
public static void getConnection(){
try{
Class.forName(CLS);
conn = DriverManager.getConnection(URL,USER,PWD);
}catch(Exception ex){
ex.printStackTrace();
}
}
//关闭连接
public static void closeAll(){
try{
if(rs!=null){
rs.close();
rs=null;
}
if(pStmt!=null){
pStmt.close();
pStmt=null;
}
if(stmt!=null){
stmt.close();
stmt=null;
}
if(conn!=null){
conn.close();
conn=null;
}
}catch (Exception ex){
ex.printStackTrace();
}
}
}

@ -0,0 +1,32 @@
package com.example.netcloudsharing.tool;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/*
*/
public class MySqlHelp {
public static int getUserSize(){
final String CLS = "com.mysql.jdbc.Driver";
final String URL = "jdbc:mysql://10.77.169.229:3306/netsharingdb";
final String USER = "zzc";
final String PWD = "112211";
int count=0;
try{
Class.forName(CLS);
Connection conn = DriverManager.getConnection(URL,USER,PWD);
String sql ="select count(1) as sl from userinfo";
Statement stmt = conn.createStatement();
ResultSet rs =stmt.executeQuery(sql);
while(rs.next()){
count = rs.getInt("sl");
}
}catch (Exception ex){
ex.printStackTrace();
}
return count;
}
}

@ -0,0 +1,137 @@
package com.example.netcloudsharing.tool;
import java.util.ArrayList;
import java.util.List;
/*
CRUD
*/
public class UserDao extends DbOpenHelper {
/**
* R
* @return List<Userinfo>
*/
public List<Userinfo> getAllUserList(){
List<Userinfo> list = new ArrayList<>();
try{
getConnection(); //取得连接信息
String sql="select * from userinfo";
pStmt = conn.prepareStatement(sql);
rs = pStmt.executeQuery();
if(rs.next()){
Userinfo item = new Userinfo();
item.setId(rs.getInt("id"));
item.setUname(rs.getString("uname"));
item.setUpass(rs.getString("upass"));
item.setCreateDt(rs.getString("createDt"));
list.add(item);
}
}catch (Exception ex){
ex.printStackTrace();
}finally {
closeAll();
}
return list;
}
/**
* R
* @param uname
* @param upass
* @return Userinfo
*/
public Userinfo getUserByUnameAndUpass(String uname,String upass){
Userinfo item = null;
try{
getConnection(); //取得连接信息
String sql="select * from userinfo where uname = ? and upass = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1,uname);
pStmt.setString(2,upass);
rs = pStmt.executeQuery();
if(rs.next()){
item = new Userinfo();
item.setId(rs.getInt("id"));
item.setUname(uname);
item.setCreateDt(rs.getString("createDt"));
}
}catch (Exception ex){
ex.printStackTrace();
}finally {
closeAll();
}
return item;
}
/**
* C
* @param item
* @return int
*/
public int addUser(Userinfo item){
int iRow = 0;
try{
getConnection(); //取得连接信息
String sql="insert into userinfo(uname,upass,createDt) values(?,?,?)";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1,item.getUname());
pStmt.setString(2,item.getUpass());
pStmt.setString(3,item.getCreateDt());
iRow = pStmt.executeUpdate();
}catch (Exception ex){
ex.printStackTrace();
}finally {
closeAll();
}
return iRow;
}
/**
* U
* @param item
* @return int
*/
public int editUser(Userinfo item){
int iRow = 0;
try{
getConnection(); //取得连接信息
String sql="updata userinfo set uname = ?,upass = ? where id =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1,item.getUname());
pStmt.setString(2,item.getUpass());
pStmt.setInt(3,item.getId());
iRow = pStmt.executeUpdate();
}catch (Exception ex){
ex.printStackTrace();
}finally {
closeAll();
}
return iRow;
}
/**
* id D
* @param id id
* @return int
*/
public int delUser(int id){
int iRow = 0;
try{
getConnection(); //取得连接信息
String sql="delete from userinfo where id = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setInt(1,id);
iRow = pStmt.executeUpdate();
}catch (Exception ex){
ex.printStackTrace();
}finally {
closeAll();
}
return iRow;
}
}

@ -0,0 +1,54 @@
package com.example.netcloudsharing.tool;
/*
*/
import java.io.Serializable;
public class Userinfo implements Serializable{
private int id;
private String uname;
private String upass;
private String createDt;
public Userinfo() {
}
public Userinfo(int id, String uname, String upass, String createDt) {
this.id = id;
this.uname = uname;
this.upass = upass;
this.createDt = createDt;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUpass() {
return upass;
}
public void setUpass(String upass) {
this.upass = upass;
}
public String getCreateDt() {
return createDt;
}
public void setCreateDt(String createDt) {
this.createDt = createDt;
}
}

@ -0,0 +1,30 @@
<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:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
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="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 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="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 931 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="20dp"/>
<stroke android:width="1dp"
android:color="#bcb8b8"/>
<size android:width="300dp"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="9dp" />
<solid android:color="#c75fe768" />
</shape>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="9dp"/>
<solid android:color="#F2F2F2"/>
</shape>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="9dp" />
<solid android:color="#C75FE7C7" />
</shape>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="9dp" />
<solid android:color="#afee5d59" />
</shape>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="9dp"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".activity.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="329dp"
android:src="@mipmap/login"
android:scaleType="fitXY"
tools:ignore="ContentDescription"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:background="@drawable/shape_login_form"
android:paddingLeft="40dp"
android:paddingRight="31dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="278dp"
android:orientation="vertical"
android:gravity="center_vertical"
android:paddingStart="43dp"
android:paddingEnd="31dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/account"
tools:ignore="ContentDescription"/>
<EditText
android:id="@+id/login_et_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:hint="@string/please_input_account"
android:textColorHint="#bcbcbc"
android:textColor="@color/black"
android:textSize="18sp"
android:background="@null"
android:layout_marginStart="20dp"
android:inputType="text" />
</LinearLayout>
<View
android:layout_marginTop="23dp"
android:layout_marginBottom="23dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divide"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/password"
tools:ignore="ContentDescription"/>
<EditText
android:id="@+id/login_et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:hint="@string/please_input_password"
android:textColorHint="#bcbcbc"
android:textColor="@color/black"
android:textSize="18sp"
android:background="@null"
android:inputType="textPassword"
android:layout_marginStart="20dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<CheckBox
android:id="@+id/cb_remember_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cb_rm_account"/>
<CheckBox
android:id="@+id/cb_remember_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:text="@string/cb_rm_password"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/login_btn_login"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="50dp"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/shape_login_btn"
android:text="@string/login"
android:textSize="24sp"
android:textColor="@color/white"/>
<Button
android:id="@+id/login_btn_tourist"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/shape_login_tourist_btn"
android:text="@string/touristlogin"
android:textSize="24sp"
android:textColor="@color/white"/>
</LinearLayout>
</RelativeLayout>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="Fragment.MainActivity"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fl_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
<include layout="@layout/bottom"/>
</LinearLayout>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Music.MusicDownload"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="音乐下载"
android:textSize="20sp"/>
</RelativeLayout>

@ -0,0 +1,9 @@
<?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"
tools:context=".Music.MusicDownload">
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/music_buttom" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/local_music_rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/local_music_bottomLayout">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Music.HttpGetDemoActivity"
android:orientation="vertical"
android:background="@drawable/netmusicbackground">
<LinearLayout
android:id="@+id/activity_music_search_llButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_marginBottom="50dp"
android:background="#33E6E6E6"
>
<Button
android:id="@+id/btn_play"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="在线播放"
android:textSize="18sp"
android:background="#33E6E6E6"
android:layout_marginRight="30dp"/>
<Button
android:id="@+id/btn_pause"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="停止"
android:textSize="18sp"
android:background="#33E6E6E6"/>
</LinearLayout>
<SeekBar
android:id="@+id/seekBar_playing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/activity_music_search_llButton"
android:layout_marginBottom="100dp"
android:background="#33E6E6E6"/>
</RelativeLayout>

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/splash"
tools:context=".NetStart">
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dimen_90dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/dimen_44dp"
android:paddingRight="@dimen/dimen_44dp">
<Button
android:id="@+id/btn_login"
android:layout_alignParentLeft="true"
android:layout_width="@dimen/dimen_100dp"
android:layout_height="@dimen/dimen_40dp"
android:text="@string/login"
android:textSize="@dimen/size_20sp"
android:textColor="#ffffff"
android:background="@drawable/shape_login_btn"
android:layout_alignParentStart="true" />
<Button
android:id="@+id/btn_register"
android:layout_alignParentRight="true"
android:layout_width="@dimen/dimen_100dp"
android:layout_height="@dimen/dimen_40dp"
android:text="@string/register"
android:textSize="@dimen/size_20sp"
android:textColor="#ffffff"
android:background="@drawable/shape_register_btn"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".activity.LoginActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="329dp"
android:src="@mipmap/login"
android:scaleType="fitXY"
tools:ignore="ContentDescription"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="230dp"
android:background="@drawable/shape_login_form"
android:paddingLeft="43dp"
android:paddingRight="31dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="278dp"
android:orientation="vertical"
android:gravity="center_vertical"
android:paddingStart="43dp"
android:paddingEnd="31dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/account"
tools:ignore="ContentDescription"/>
<EditText
android:id="@+id/register_et_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:hint="@string/please_input_account"
android:textColorHint="#bcbcbc"
android:textColor="@color/black"
android:textSize="18sp"
android:background="@null"
android:layout_marginStart="20dp"
android:inputType="text" />
</LinearLayout>
<View
android:layout_marginTop="23dp"
android:layout_marginBottom="23dp"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divide"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@mipmap/password"
tools:ignore="ContentDescription"/>
<EditText
android:id="@+id/register_et_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:hint="@string/please_input_password"
android:textColorHint="#bcbcbc"
android:textColor="@color/black"
android:textSize="18sp"
android:background="@null"
android:inputType="textPassword"
android:layout_marginStart="20dp" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/register_btn_register"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="67dp"
android:layout_width="match_parent"
android:layout_height="55dp"
android:background="@drawable/shape_register_btn"
android:text="@string/register"
android:textSize="24sp"
android:textColor="@color/white"/>
</LinearLayout>
</RelativeLayout>

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

Loading…
Cancel
Save