实现我的界面UI交互完整化
删除exoplayer播放器SDK改用android原生player
This commit is contained in:
parent
22cd5b5e30
commit
c7e3897f38
|
@ -57,6 +57,7 @@
|
||||||
android:theme="@style/fragment_dialog" />
|
android:theme="@style/fragment_dialog" />
|
||||||
|
|
||||||
<activity android:name=".fragment.mp3" />
|
<activity android:name=".fragment.mp3" />
|
||||||
|
<activity android:name=".fragment.gd" />
|
||||||
<activity android:name=".activity_about_software" />
|
<activity android:name=".activity_about_software" />
|
||||||
<activity android:name=".sz" />
|
<activity android:name=".sz" />
|
||||||
<activity android:name=".mq.llq" />
|
<activity android:name=".mq.llq" />
|
||||||
|
|
|
@ -171,6 +171,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
||||||
Media.setProgress(0);
|
Media.setProgress(0);
|
||||||
Media.setname(name);
|
Media.setname(name);
|
||||||
Media.setzz(zz);
|
Media.setzz(zz);
|
||||||
|
bfq_an.islike();
|
||||||
}
|
}
|
||||||
bfq_db.setname(name + "/" + zz);
|
bfq_db.setname(name + "/" + zz);
|
||||||
if (com.muqingbfq.fragment.mp3.lbspq != null) {
|
if (com.muqingbfq.fragment.mp3.lbspq != null) {
|
||||||
|
|
|
@ -12,9 +12,12 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
@ -23,17 +26,22 @@ import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.google.android.material.card.MaterialCardView;
|
import com.google.android.material.card.MaterialCardView;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
import com.muqingbfq.MP3;
|
||||||
import com.muqingbfq.R;
|
import com.muqingbfq.R;
|
||||||
import com.muqingbfq.api.playlist;
|
import com.muqingbfq.api.playlist;
|
||||||
|
import com.muqingbfq.api.resource;
|
||||||
import com.muqingbfq.bfq_an;
|
import com.muqingbfq.bfq_an;
|
||||||
import com.muqingbfq.bfqkz;
|
import com.muqingbfq.bfqkz;
|
||||||
import com.muqingbfq.databinding.FragmentGdBinding;
|
import com.muqingbfq.databinding.FragmentGdBinding;
|
||||||
|
import com.muqingbfq.databinding.FragmentMp3Binding;
|
||||||
|
import com.muqingbfq.list.MyViewHoder;
|
||||||
import com.muqingbfq.main;
|
import com.muqingbfq.main;
|
||||||
import com.muqingbfq.mq.gj;
|
import com.muqingbfq.mq.gj;
|
||||||
import com.muqingbfq.mq.wj;
|
import com.muqingbfq.mq.wj;
|
||||||
import com.muqingbfq.mq.wl;
|
import com.muqingbfq.mq.wl;
|
||||||
import com.muqingbfq.xm;
|
import com.muqingbfq.xm;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -42,76 +50,63 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class gd extends Fragment {
|
public class gd extends com.muqingbfq.mq.FragmentActivity {
|
||||||
public static String gdid;
|
public static String gdid;
|
||||||
FragmentGdBinding binding;
|
private final List<xm> list = new ArrayList<>();
|
||||||
|
public static RecyclerView.Adapter<VH> adapter;
|
||||||
|
|
||||||
|
int k;
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onResume();
|
super.onCreate(savedInstanceState);
|
||||||
getActivity().getSupportFragmentManager().beginTransaction()
|
FragmentMp3Binding binding = FragmentMp3Binding.inflate(getLayoutInflater());
|
||||||
.replace(R.id.bfq_db, new bfq_db())
|
Intent intent = getIntent();
|
||||||
.commit();
|
binding.title.setText(intent.getStringExtra("name"));
|
||||||
|
// inflate.toolbar.setTitle(intent.getStringExtra("name"));
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
adapter = new baseadapter(this,list);
|
||||||
|
k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f);
|
||||||
|
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, k / 120);
|
||||||
|
binding.lb.setLayoutManager(gridLayoutManager);
|
||||||
|
binding.lb.setAdapter(adapter);
|
||||||
|
String id = intent.getStringExtra("id");
|
||||||
|
// inflate.bfqDb.setBackground(gd.color);
|
||||||
|
new start(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
class start extends Thread {
|
||||||
|
String id;
|
||||||
|
public start(String id) {
|
||||||
|
this.id = id;
|
||||||
|
list.clear();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
public void run() {
|
||||||
Bundle savedInstanceState) {
|
super.run();
|
||||||
binding = FragmentGdBinding.inflate(inflater, container, false);
|
if (id.equals("排行榜")) {
|
||||||
binding.viewPager.setAdapter(new adaper(getActivity()));
|
resource.排行榜(list);
|
||||||
|
} else {
|
||||||
// 将 ViewPager2 绑定到 TabLayout
|
String hq = wl.hq("/search?keywords=" + id + "&limit=" + (k * 3) + "&type=1000");
|
||||||
binding.tablayout.setOnItemSelectedListener(item -> {
|
try {
|
||||||
int itemId = item.getItemId();
|
JSONArray jsonArray = new JSONObject(hq).getJSONObject("result")
|
||||||
if (itemId == R.id.a) {
|
.getJSONArray("playlists");
|
||||||
binding.viewPager.setCurrentItem(0);
|
int length = jsonArray.length();
|
||||||
} else if (itemId == R.id.b) {
|
for (int i = 0; i < length; i++) {
|
||||||
binding.viewPager.setCurrentItem(1);
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||||
} else if (itemId == R.id.c) {
|
String id = jsonObject.getString("id");
|
||||||
binding.viewPager.setCurrentItem(2);
|
String name = jsonObject.getString("name");
|
||||||
}
|
String coverImgUrl = jsonObject.getString("coverImgUrl");
|
||||||
return true;
|
list.add(new xm(id, name, coverImgUrl, false));
|
||||||
});
|
}
|
||||||
binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
} catch (Exception e) {
|
||||||
@Override
|
gj.sc(e);
|
||||||
public void onPageSelected(int position) {
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
binding.tablayout.setSelectedItemId(R.id.a);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
binding.tablayout.setSelectedItemId(R.id.b);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
binding.tablayout.setSelectedItemId(R.id.c);
|
|
||||||
wode fragment = (wode) list.get(position);
|
|
||||||
fragment.sx();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
main.handler.post(new lbspq_sx());
|
||||||
return binding.getRoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Fragment> list = new ArrayList<>();
|
|
||||||
|
|
||||||
private class adaper extends FragmentStateAdapter {
|
|
||||||
public adaper(@NonNull FragmentActivity fragmentActivity) {
|
|
||||||
super(fragmentActivity);
|
|
||||||
list.add(new gd_adapter());
|
|
||||||
list.add(new gd_adapter.paihangbang());
|
|
||||||
list.add(new wode());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Fragment createFragment(int position) {
|
|
||||||
return list.get(position);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return list.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +119,22 @@ public class gd extends Fragment {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean bool = false;
|
||||||
|
public baseadapter(Context context, List<xm> list,boolean bool) {
|
||||||
|
this.context = context;
|
||||||
|
this.list = list;
|
||||||
|
this.bool = bool;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(context)
|
if (bool) {
|
||||||
.inflate(R.layout.list_gd, parent, false);
|
return new VH(LayoutInflater.from(context)
|
||||||
return new VH(view);
|
.inflate(R.layout.list_gd_b, parent, false));
|
||||||
|
}
|
||||||
|
return new VH(LayoutInflater.from(context)
|
||||||
|
.inflate(R.layout.list_gd, parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setList(List<xm> list) {
|
public void setList(List<xm> list) {
|
||||||
|
@ -247,4 +252,12 @@ public class gd extends Fragment {
|
||||||
kg = itemView.findViewById(R.id.kg);
|
kg = itemView.findViewById(R.id.kg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class lbspq_sx implements Runnable {
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -52,34 +52,6 @@ public class gd_adapter extends Fragment {
|
||||||
}.start();
|
}.start();
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class paihangbang extends Fragment {
|
|
||||||
List<xm> list = new ArrayList<>();
|
|
||||||
gd.baseadapter baseadapter;
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
|
||||||
@Nullable Bundle savedInstanceState) {
|
|
||||||
FrameLayout layout = new FrameLayout(getContext());
|
|
||||||
RecyclerView recyclerView = new RecyclerView(layout.getContext());
|
|
||||||
int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f);
|
|
||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(layout.getContext(), k / 120);
|
|
||||||
recyclerView.setLayoutManager(gridLayoutManager);
|
|
||||||
layout.addView(recyclerView);
|
|
||||||
baseadapter = new gd.baseadapter(getContext(), list);
|
|
||||||
recyclerView.setAdapter(baseadapter);
|
|
||||||
new Thread() {
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
super.run();
|
|
||||||
resource.排行榜(list);
|
|
||||||
main.handler.postDelayed(new sx(baseadapter),500);
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static class sx implements Runnable {
|
private static class sx implements Runnable {
|
||||||
gd.baseadapter baseadapter;
|
gd.baseadapter baseadapter;
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,6 @@ public class search extends Fragment {
|
||||||
xmList.add(new xm(id, name, coverImgUrl, false));
|
xmList.add(new xm(id, name, coverImgUrl, false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
gj.sc(e);
|
gj.sc(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class wode extends Fragment {
|
||||||
|
|
||||||
FragmentWdBinding binding;
|
FragmentWdBinding binding;
|
||||||
private final List<com.muqingbfq.xm> list = new ArrayList<>();
|
private final List<com.muqingbfq.xm> list = new ArrayList<>();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
@ -51,26 +52,26 @@ public class wode extends Fragment {
|
||||||
jieshao = binding.text2;
|
jieshao = binding.text2;
|
||||||
imageView = binding.imageView;
|
imageView = binding.imageView;
|
||||||
binding.cardview.setOnClickListener(v -> {
|
binding.cardview.setOnClickListener(v -> {
|
||||||
if (main.getToken() == null) {
|
if (main.getToken() == null) {
|
||||||
startActivity(new Intent(getContext(), user_logs.class));
|
startActivity(new Intent(getContext(), user_logs.class));
|
||||||
} else {
|
} else {
|
||||||
startActivity(new Intent(getContext(), user_editing.class));
|
startActivity(new Intent(getContext(), user_editing.class));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new user_message();
|
new user_message();
|
||||||
int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f);
|
// int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f);
|
||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), k / 120);
|
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 4);
|
||||||
binding.recyclerview1.setLayoutManager(gridLayoutManager);
|
binding.recyclerview1.setLayoutManager(gridLayoutManager);
|
||||||
final Object[][] lista ={
|
final Object[][] lista = {
|
||||||
{R.drawable.bf,"最近播放"},
|
{R.drawable.bf, "最近播放", "mp3_hc.json"},
|
||||||
{R.drawable.download,"下载音乐"},
|
{R.drawable.download, "下载音乐", "mp3_xz.json"},
|
||||||
{R.drawable.like,"喜欢音乐"},
|
{R.drawable.like, "喜欢音乐", "mp3_like.json"},
|
||||||
{R.drawable.icon,"本地搜索"},
|
{R.drawable.icon, "本地搜索", ""},
|
||||||
{R.drawable.icon,"我的歌单"},
|
{R.drawable.icon, "我的歌单", ""},
|
||||||
{R.drawable.icon,"导入歌单"},
|
{R.drawable.icon, "导入歌单", ""},
|
||||||
{R.drawable.icon,"开发中"},
|
{R.drawable.paihangbang, "排行榜", "排行榜"},
|
||||||
{R.drawable.icon,"开发者"}
|
{R.drawable.icon, "开发中", ""}
|
||||||
};
|
};
|
||||||
binding.recyclerview1.setAdapter(new RecyclerView.Adapter<VH>() {
|
binding.recyclerview1.setAdapter(new RecyclerView.Adapter<VH>() {
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -87,27 +88,23 @@ public class wode extends Fragment {
|
||||||
Glide.with(getContext())
|
Glide.with(getContext())
|
||||||
.load(lista[position][0])
|
.load(lista[position][0])
|
||||||
.into(holder.imageView);
|
.into(holder.imageView);
|
||||||
|
String data = lista[position][2].toString();
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
Intent a = new Intent(getContext(), com.muqingbfq.fragment.mp3.class);
|
switch (data) {
|
||||||
switch (position) {
|
case "mp3_hc.json":
|
||||||
case 0:
|
case "mp3_xz.json":
|
||||||
a.putExtra("id", "mp3_hc.json");
|
case "mp3_like.json":
|
||||||
|
Intent a = new Intent(getContext(), com.muqingbfq.fragment.mp3.class);
|
||||||
|
a.putExtra("id", data);
|
||||||
a.putExtra("name", s);
|
a.putExtra("name", s);
|
||||||
getContext().startActivity(a);
|
getContext().startActivity(a);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case "排行榜":
|
||||||
a.putExtra("id", "mp3_xz.json");
|
Intent b = new Intent(getContext(), com.muqingbfq.fragment.gd.class);
|
||||||
a.putExtra("name", s);
|
b.putExtra("id", data);
|
||||||
getContext().startActivity(a);
|
b.putExtra("name", s);
|
||||||
|
getContext().startActivity(b);
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
a.putExtra("id", "mp3_like.json");
|
|
||||||
a.putExtra("name", s);
|
|
||||||
getContext().startActivity(a);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -118,20 +115,21 @@ public class wode extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sx();
|
sx();
|
||||||
binding.recyclerview2.setLayoutManager(new LinearLayoutManager(getContext()){
|
binding.recyclerview2.setLayoutManager(new LinearLayoutManager(getContext()) {
|
||||||
@Override
|
@Override
|
||||||
public boolean canScrollVertically() {
|
public boolean canScrollVertically() {
|
||||||
return false;//禁止滑动
|
return false;//禁止滑动
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
binding.recyclerview2.setFocusable(false);
|
binding.recyclerview2.setFocusable(false);
|
||||||
binding.recyclerview2.setAdapter(new gd.baseadapter(getContext(),list));
|
binding.recyclerview2.setAdapter(new gd.baseadapter(getContext(), list, true));
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
class VH extends RecyclerView.ViewHolder {
|
class VH extends RecyclerView.ViewHolder {
|
||||||
public ImageView imageView;
|
public ImageView imageView;
|
||||||
public TextView textView;
|
public TextView textView;
|
||||||
|
|
||||||
public VH(@NonNull View itemView) {
|
public VH(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
imageView = itemView.findViewById(R.id.image);
|
imageView = itemView.findViewById(R.id.image);
|
||||||
|
@ -139,8 +137,10 @@ public class wode extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sx(){
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
|
public void sx() {
|
||||||
try {
|
try {
|
||||||
|
List<xm> a = new ArrayList<>(list);
|
||||||
list.clear();
|
list.clear();
|
||||||
JSONObject date = new JSONObject(wj.dqwb(wj.gd_xz));
|
JSONObject date = new JSONObject(wj.dqwb(wj.gd_xz));
|
||||||
for (Iterator<String> it = date.keys(); it.hasNext(); ) {
|
for (Iterator<String> it = date.keys(); it.hasNext(); ) {
|
||||||
|
@ -151,14 +151,19 @@ public class wode extends Fragment {
|
||||||
String picUrl = jsonObject.getString("picUrl");
|
String picUrl = jsonObject.getString("picUrl");
|
||||||
list.add(new xm(id, name, picUrl, cz));
|
list.add(new xm(id, name, picUrl, cz));
|
||||||
}
|
}
|
||||||
binding.recyclerview2.getAdapter().notifyDataSetChanged();
|
if (list.equals(a)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
main.handler.post(() -> binding.recyclerview2.getAdapter().notifyDataSetChanged());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
gj.sc(e);
|
gj.sc(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setname(String string) {
|
public static void setname(String string) {
|
||||||
main.handler.post(() -> name.setText(string));
|
main.handler.post(() -> name.setText(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setqianming(String string) {
|
public static void setqianming(String string) {
|
||||||
main.handler.post(() -> {
|
main.handler.post(() -> {
|
||||||
if (string == null) {
|
if (string == null) {
|
||||||
|
|
|
@ -11,20 +11,27 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.google.android.material.navigation.NavigationView;
|
import com.muqingbfq.databinding.ActivityHomeBinding;
|
||||||
import com.muqingbfq.fragment.Media;
|
import com.muqingbfq.fragment.Media;
|
||||||
import com.muqingbfq.fragment.bfq_db;
|
import com.muqingbfq.fragment.bfq_db;
|
||||||
import com.muqingbfq.fragment.gd;
|
import com.muqingbfq.fragment.gd;
|
||||||
|
import com.muqingbfq.fragment.gd_adapter;
|
||||||
|
import com.muqingbfq.fragment.wode;
|
||||||
import com.muqingbfq.mq.gj;
|
import com.muqingbfq.mq.gj;
|
||||||
import com.muqingbfq.mq.wj;
|
import com.muqingbfq.mq.wj;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.util.ArrayList;
|
||||||
import java.io.ObjectOutputStream;
|
import java.util.List;
|
||||||
|
|
||||||
import me.wcy.lrcview.LrcView;
|
import me.wcy.lrcview.LrcView;
|
||||||
|
|
||||||
|
@ -33,16 +40,18 @@ public class home extends AppCompatActivity {
|
||||||
public static AppCompatActivity appCompatActivity;
|
public static AppCompatActivity appCompatActivity;
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
public static ImageView imageView;
|
public static ImageView imageView;
|
||||||
|
ActivityHomeBinding binding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
appCompatActivity = this;
|
appCompatActivity = this;
|
||||||
setTheme(R.style.Theme_muqing);
|
setTheme(R.style.Theme_muqing);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
if (true) {
|
if (false) {
|
||||||
com.muqingbfq.mq.floating.start(this);
|
com.muqingbfq.mq.floating.start(this);
|
||||||
}
|
}
|
||||||
setContentView(R.layout.activity_home);
|
binding = ActivityHomeBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||||
main.k = dm.widthPixels;
|
main.k = dm.widthPixels;
|
||||||
main.g = dm.heightPixels;
|
main.g = dm.heightPixels;
|
||||||
|
@ -60,27 +69,25 @@ public class home extends AppCompatActivity {
|
||||||
Media.lrcview = new LrcView(this);
|
Media.lrcview = new LrcView(this);
|
||||||
// 请将Context替换为实际的上下文对象
|
// 请将Context替换为实际的上下文对象
|
||||||
// 设置LrcView的属性
|
// 设置LrcView的属性
|
||||||
Media.lrcview.setCurrentColor(getResources().getColor(R.color.text));
|
Media.lrcview.setCurrentColor(ContextCompat.getColor(this,R.color.text));
|
||||||
Media.lrcview.setLabel(getString(R.string.app_name));
|
Media.lrcview.setLabel(getString(R.string.app_name));
|
||||||
Media.lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
Media.lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
||||||
TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics()));
|
TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics()));
|
||||||
// lrcView.setLrcPadding(16);
|
// lrcView.setLrcPadding(16);
|
||||||
Media.lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
Media.lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
||||||
TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()));
|
TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()));
|
||||||
Media.lrcview.setTimelineTextColor(getResources().getColor(R.color.text_tm));
|
Media.lrcview.setTimelineTextColor(ContextCompat.getColor(this,R.color.text_tm));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//初始化工具栏
|
//初始化工具栏
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
setSupportActionBar(binding.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
DrawerLayout drawerLayout = findViewById(R.id.chct);
|
DrawerLayout drawerLayout = findViewById(R.id.chct);
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
this, drawerLayout, toolbar, R.string.app_name, R.string.app_name);
|
this, drawerLayout, binding.toolbar, R.string.app_name, R.string.app_name);
|
||||||
drawerLayout.addDrawerListener(toggle);
|
drawerLayout.addDrawerListener(toggle);
|
||||||
toggle.syncState();
|
toggle.syncState();
|
||||||
//初始化侧滑
|
//初始化侧滑
|
||||||
NavigationView chb = findViewById(R.id.chb);
|
binding.chb.setNavigationItemSelectedListener(item -> {
|
||||||
chb.setNavigationItemSelectedListener(item -> {
|
|
||||||
com.muqingbfq.fragment.sz.switch_sz(home.this, item.getItemId());
|
com.muqingbfq.fragment.sz.switch_sz(home.this, item.getItemId());
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -92,12 +99,75 @@ public class home extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
//检测更新
|
//检测更新
|
||||||
new gj.jianchagengxin(this);
|
new gj.jianchagengxin(this);
|
||||||
|
binding.editView.setOnClickListener(view ->
|
||||||
|
startActivity(new Intent(this, activity_search.class)));
|
||||||
|
UI();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
yc.tc(this, e);
|
yc.tc(this, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Fragment> list = new ArrayList<>();
|
||||||
|
|
||||||
|
private class adaper extends FragmentStateAdapter {
|
||||||
|
public adaper(@NonNull FragmentActivity fragmentActivity) {
|
||||||
|
super(fragmentActivity);
|
||||||
|
list.add(new gd_adapter());
|
||||||
|
list.add(new wode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Fragment createFragment(int position) {
|
||||||
|
return list.get(position);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return list.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UI() {
|
||||||
|
binding.viewPager.setAdapter(new adaper(this));
|
||||||
|
|
||||||
|
// 将 ViewPager2 绑定到 TabLayout
|
||||||
|
binding.tablayout.setOnItemSelectedListener(item -> {
|
||||||
|
int itemId = item.getItemId();
|
||||||
|
if (itemId == R.id.a) {
|
||||||
|
binding.viewPager.setCurrentItem(0);
|
||||||
|
} else if (itemId == R.id.c) {
|
||||||
|
binding.viewPager.setCurrentItem(1);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
binding.tablayout.setSelectedItemId(R.id.a);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
binding.tablayout.setSelectedItemId(R.id.c);
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
try {
|
||||||
|
sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.toString();
|
||||||
|
}
|
||||||
|
wode fragment = (wode) list.get(position);
|
||||||
|
fragment.sx();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static Intent serviceIntent;
|
private static Intent serviceIntent;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,6 +184,13 @@ public class home extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.bfq_db, new bfq_db())
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
private long time;
|
private long time;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,33 +24,43 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?attr/actionBarSize">
|
android:minHeight="?attr/actionBarSize">
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/editView"
|
||||||
|
android:background="@drawable/ui_editview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
<EditText
|
android:layout_margin="10dp">
|
||||||
android:id="@+id/editview"
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="6dp"
|
|
||||||
android:autofillHints=""
|
android:autofillHints=""
|
||||||
android:background="@drawable/ui_editview"
|
android:enabled="false"
|
||||||
android:hint="@string/search"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:imeOptions="actionSearch"
|
android:text="@string/search"
|
||||||
android:inputType="text"
|
|
||||||
android:minHeight="48dp"
|
android:minHeight="48dp"
|
||||||
android:paddingStart="3dp"
|
android:paddingStart="3dp"
|
||||||
android:paddingEnd="3dp" />
|
android:paddingEnd="3dp"
|
||||||
</LinearLayout>
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</com.google.android.material.appbar.MaterialToolbar>
|
</com.google.android.material.appbar.MaterialToolbar>
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/gd"
|
android:id="@+id/viewPager"
|
||||||
android:name="com.muqingbfq.fragment.gd"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"/>
|
||||||
tools:layout="@layout/fragment_gd" />
|
|
||||||
|
<androidx.fragment.app.FragmentContainerView
|
||||||
|
android:id="@+id/bfq_db"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:layout="@layout/fragment_bfq_db" />
|
||||||
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
android:id="@+id/tablayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:contentDescription="@string/Playlist"
|
||||||
|
app:menu="@menu/bottom_gd"/>
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<com.google.android.material.navigation.NavigationView
|
<com.google.android.material.navigation.NavigationView
|
||||||
|
|
|
@ -3,23 +3,27 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
android:id="@+id/viewPager"
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<com.muqingbfq.view.Text
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:textSize="26sp"
|
||||||
|
android:textColor="@color/text"/>
|
||||||
|
</com.google.android.material.appbar.MaterialToolbar>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/lb"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/bfq_db"
|
android:id="@+id/bfq_db"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:name="com.muqingbfq.fragment.bfq_db"
|
||||||
tools:layout="@layout/fragment_bfq_db" />
|
tools:layout="@layout/fragment_bfq_db" />
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
|
||||||
android:id="@+id/tablayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:contentDescription="@string/Playlist"
|
|
||||||
app:menu="@menu/bottom_gd"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -8,7 +8,6 @@
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<com.muqingbfq.view.Text
|
<com.muqingbfq.view.Text
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -5,7 +5,17 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".fragment.sz"
|
tools:context=".fragment.sz">
|
||||||
android:fitsSystemWindows="true"
|
<TextView
|
||||||
android:focusable="true">
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:text="云音乐"
|
||||||
|
android:layout_margin="16dp" />
|
||||||
|
|
||||||
|
<com.google.android.material.divider.MaterialDivider
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:dividerInsetStart="16dp"
|
||||||
|
app:dividerInsetEnd="16dp"/>
|
||||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
android:id="@+id/a"
|
android:id="@+id/a"
|
||||||
android:icon="@drawable/zhuye"
|
android:icon="@drawable/zhuye"
|
||||||
android:title="推荐" />
|
android:title="推荐" />
|
||||||
<item
|
|
||||||
android:id="@+id/b"
|
|
||||||
android:icon="@drawable/paihangbang"
|
|
||||||
android:title="排行榜" />
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/c"
|
android:id="@+id/c"
|
||||||
android:icon="@drawable/user"
|
android:icon="@drawable/user"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user