Skip to content
This repository has been archived by the owner on Jun 5, 2021. It is now read-only.

Commit

Permalink
1. Clean up code
Browse files Browse the repository at this point in the history
2. Optimize Ui
3. Update Lib

Signed-off-by: Gikode <827266641@qq.com>
  • Loading branch information
AugustToko committed Oct 5, 2019
1 parent 5bffd37 commit f4adf6e
Show file tree
Hide file tree
Showing 10 changed files with 1,737 additions and 26 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ android {
vectorDrawables.useSupportLibrary = true

applicationId 'top.geek_studio.chenlongcould.musicplayer'
versionCode 160
versionName '1.4.3'
versionCode 161
versionName '1.4.4'
applicationIdSuffix = 'Common'
multiDexEnabled = true
multiDexKeepFile file('multidex-config.txt')
Expand Down
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":160,"versionName":"1.4.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":161,"versionName":"1.4.4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
1 change: 1 addition & 0 deletions app/src/debug/assets/hotSongSample

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand All @@ -30,6 +31,8 @@
import com.kabouzeid.appthemehelper.util.ToolbarContentTintHelper;
import com.kabouzeid.chenlongcould.musicplayer.R;

import org.jetbrains.annotations.NotNull;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
Expand Down Expand Up @@ -73,6 +76,8 @@ public class LibraryFragment extends AbsMainActivityFragment
@BindView(R.id.pager)
ViewPager pager;

private ViewGroup root;

private MusicLibraryPagerAdapter pagerAdapter;

private MaterialCab cab;
Expand All @@ -87,6 +92,7 @@ public static LibraryFragment newInstance() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_library, container, false);
root = (ViewGroup) view;
unbinder = ButterKnife.bind(this, view);
return view;
}
Expand Down Expand Up @@ -243,7 +249,7 @@ public int getTotalAppBarScrollingRange() {
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (pager == null) return;

Expand Down Expand Up @@ -554,6 +560,14 @@ public boolean handleBackPress() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
/////////

// if (position == 0) {
// appbar.setAlpha(positionOffset);
// if (positionOffset == 0) appbar.setVisibility(View.GONE);
// else appbar.setVisibility(View.VISIBLE);
// } else {
// appbar.setAlpha(1);
// }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand All @@ -24,13 +25,11 @@
import com.kabouzeid.chenlongcould.musicplayer.R;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand All @@ -56,6 +55,7 @@
import top.geek_studio.chenlongcould.musicplayer.util.NavigationUtil;
import top.geek_studio.chenlongcould.musicplayer.util.PreferenceUtil;
import top.geek_studio.chenlongcould.musicplayer.views.CircularImageView;
import top.geek_studio.chenlongcould.musicplayer.views.RetroChip;

/**
* HomePage
Expand All @@ -79,6 +79,12 @@ public class HomeFragment extends AbsLibraryPagerFragment {

LinearLayout hitokotoView;

@BindView(R.id.hitokotoChipHead)
RetroChip hitokotoHead;

@BindView(R.id.userInfoContainer)
LinearLayout userInfoContainer;

private CompositeDisposable disposable = new CompositeDisposable();

@Override
Expand All @@ -90,7 +96,7 @@ public String getSubTitle() {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_home, container, false);
unbinder = ButterKnife.bind(view);
unbinder = ButterKnife.bind(this, view);

userImage = view.findViewById(R.id.userImage);
userName = view.findViewById(R.id.titleWelcome);
Expand Down Expand Up @@ -130,6 +136,11 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
materialDialog.show();
return false;
});

userInfoContainer.setOnClickListener(v -> {
MaterialDialog dialog = new MaterialDialog.Builder(appCompatActivity).title("Building").content("Building").build();
dialog.show();
});
}

final RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
Expand All @@ -152,8 +163,7 @@ private void setUpHitokotoView(@NonNull Activity activity) {
Hitokoto hitokoto;
if ((hitokoto = HitokotoUtils.readHitokoFile(activity)) != null) {
getActivity().runOnUiThread(() -> {
((ATEPrimaryTextView) hitokotoView.findViewById(R.id.hitokoto)).setText(hitokoto.getHitokoto());
((ATESecondaryTextView) hitokotoView.findViewById(R.id.hitokotoFrom)).setText(hitokoto.getFrom());
putIntoHitokotoView(hitokoto);
if (activity instanceof MainActivity) {
((MainActivity) activity).mViewModel.HitokotoData.setValue(hitokoto);
}
Expand All @@ -167,14 +177,13 @@ private void setUpHitokotoView(@NonNull Activity activity) {

/**
* 从网络中获取一言
* */
*/
private void loadHitokoFromNet(Activity activity) {
HitokotoUtils.getHitokoto(activity, new TransDataCallback<Hitokoto>() {
@Override
public void onTrans(Hitokoto data) {
activity.runOnUiThread(() -> {
((ATEPrimaryTextView) hitokotoView.findViewById(R.id.hitokoto)).setText(data.getHitokoto());
((ATESecondaryTextView) hitokotoView.findViewById(R.id.hitokotoFrom)).setText(data.getFrom());
putIntoHitokotoView(data);
if (activity instanceof MainActivity) {
((MainActivity) activity).mViewModel.HitokotoData.setValue(data);
}
Expand All @@ -190,6 +199,13 @@ public void onError() {
});
}

@UiThread
private void putIntoHitokotoView(@NonNull Hitokoto data) {
((ATEPrimaryTextView) hitokotoView.findViewById(R.id.hitokoto)).setText(data.getHitokoto());
((ATESecondaryTextView) hitokotoView.findViewById(R.id.hitokotoFrom)).setText(data.getCreator());
hitokotoHead.setText(data.getFrom());
}

/**
* 设置用户信息
*
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/abs_playlists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="24dp"
android:paddingTop="10dp"
android:paddingTop="24dp"
android:paddingEnd="24dp"
android:paddingBottom="10dp"
tools:background="#C7C0C0">
tools:background="#C7C0C0"
android:background="?selectableItemBackground">

<top.geek_studio.chenlongcould.musicplayer.views.CircularImageView
android:id="@+id/userImage"
Expand Down
44 changes: 34 additions & 10 deletions app/src/main/res/layout/hitokoto_bar.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
<?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:id="@+id/hitokotoView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?selectableItemBackground"
android:orientation="vertical"
android:paddingStart="24dp"
android:paddingTop="10dp"
android:paddingEnd="24dp"
android:paddingBottom="10dp"
android:foreground="?selectableItemBackground">
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="12dp"
android:paddingBottom="12dp">

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="center"
android:background="#1E000000" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<top.geek_studio.chenlongcould.musicplayer.views.RetroChip
android:id="@+id/hitokotoChipHead"
style="@style/Widget.MaterialComponents.Chip.Action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:textAppearance="@style/ChipFont"
android:textColor="?android:textColorSecondary"
app:chipIconTint="?iconColor"
app:chipStrokeColor="?dividerColor"
app:chipStrokeWidth="1dp"
app:iconStartPadding="8dp"
app:chipIcon="@drawable/ic_comment_text_outline_white_24dp"
tools:text="@string/app_name"
android:layout_marginEnd="12dp" />

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_gravity="center"
android:background="#1E000000" />
</LinearLayout>

<com.kabouzeid.appthemehelper.common.views.ATEPrimaryTextView
android:id="@+id/hitokoto"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/section_recycler_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
app:chipStrokeColor="?dividerColor"
app:chipStrokeWidth="1dp"
app:iconStartPadding="8dp"
tools:chipIcon="@drawable/ic_person_white_24dp"
app:chipIcon="@drawable/ic_person_white_24dp"
tools:text="For You" />

<androidx.recyclerview.widget.RecyclerView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,5 @@
<string name="sort_order_artist">艺术家</string>
<string name="sort_order_album">专辑</string>
<string name="sort_order_year">年份</string>
<string name="home">主页</string>
</resources>

0 comments on commit f4adf6e

Please sign in to comment.