diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/AnimationTimelineFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/AnimationTimelineFragment.java index f93e5d0..046b1ee 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/AnimationTimelineFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/AnimationTimelineFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -13,6 +14,7 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.AnimationTimelineAdapter; @@ -20,7 +22,9 @@ import cn.luern0313.wristbilibili.models.AnimationTimelineModel; import cn.luern0313.wristbilibili.ui.BangumiActivity; import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -31,7 +35,7 @@ public class AnimationTimelineFragment extends Fragment { Context ctx; View rootLayout; - private ListView arListView; + private ListView uiListView; private WaveSwipeRefreshLayout waveSwipeRefreshLayout; public static boolean isLogin; @@ -39,75 +43,49 @@ public class AnimationTimelineFragment extends Fragment private ArrayList animationTimelineList; AnimationTimelineAdapter adapter; private AnimationTimelineAdapter.AnimationTimelineListener adapterListener; + private TitleView.TitleViewListener titleViewListener; Handler handler = new Handler(); private Runnable runnableUi, runnableNoWeb; + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ctx = getActivity(); rootLayout = inflater.inflate(R.layout.fragment_aniremind, container, false); - arListView = rootLayout.findViewById(R.id.ar_listview); + uiListView = rootLayout.findViewById(R.id.ar_listview); waveSwipeRefreshLayout = rootLayout.findViewById(R.id.ar_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - //noinspection ConstantConditions - waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, getContext())); - waveSwipeRefreshLayout.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() - { - @Override - public void onRefresh() + waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { + if(isLogin) { - handler.post(new Runnable() - { - @Override - public void run() - { - if(isLogin) - { - arListView.setVisibility(View.GONE); - getAnimTimeline(); - } - else waveSwipeRefreshLayout.setRefreshing(false); - } - }); + uiListView.setVisibility(View.GONE); + getAnimTimeline(); } - }); + else waveSwipeRefreshLayout.setRefreshing(false); + })); - adapterListener = new AnimationTimelineAdapter.AnimationTimelineListener() - { - @Override - public void onClick(int viewId, int position) - { - onViewClick(viewId, position); - } - }; + adapterListener = this::onViewClick; - runnableUi = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.ar_nologin).setVisibility(View.GONE); - rootLayout.findViewById(R.id.ar_noweb).setVisibility(View.GONE); - adapter = new AnimationTimelineAdapter(inflater, animationTimelineList, arListView, adapterListener); - arListView.setAdapter(adapter); - arListView.setVisibility(View.VISIBLE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableUi = () -> { + rootLayout.findViewById(R.id.ar_nologin).setVisibility(View.GONE); + rootLayout.findViewById(R.id.ar_noweb).setVisibility(View.GONE); + adapter = new AnimationTimelineAdapter(inflater, animationTimelineList, uiListView, adapterListener); + uiListView.setAdapter(adapter); + uiListView.setVisibility(View.VISIBLE); + waveSwipeRefreshLayout.setRefreshing(false); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - waveSwipeRefreshLayout.setRefreshing(false); - rootLayout.findViewById(R.id.ar_noweb).setVisibility(View.VISIBLE); - rootLayout.findViewById(R.id.ar_nologin).setVisibility(View.GONE); - } + runnableNoWeb = () -> { + waveSwipeRefreshLayout.setRefreshing(false); + rootLayout.findViewById(R.id.ar_noweb).setVisibility(View.VISIBLE); + rootLayout.findViewById(R.id.ar_nologin).setVisibility(View.GONE); }; + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + isLogin = SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies); if(isLogin) { @@ -125,22 +103,17 @@ public void run() private void getAnimTimeline() { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try + { + animationTimelineApi = new AnimationTimelineApi(); + animationTimelineList = animationTimelineApi.getAnimTimelineList(); + handler.post(runnableUi); + } + catch (IOException e) { - try - { - animationTimelineApi = new AnimationTimelineApi(); - animationTimelineList = animationTimelineApi.getAnimTimelineList(); - handler.post(runnableUi); - } - catch (IOException e) - { - handler.post(runnableNoWeb); - e.printStackTrace(); - } + handler.post(runnableNoWeb); + e.printStackTrace(); } }).start(); } @@ -159,4 +132,12 @@ private void onViewClick(int id, int position) intent.putExtra("season_id", animationTimelineSeasonModel.getSeasonId()); startActivity(intent); } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/ArticleDetailFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/ArticleDetailFragment.java index 0a572cf..f1618fc 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/ArticleDetailFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/ArticleDetailFragment.java @@ -72,6 +72,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -120,14 +121,8 @@ public void onLinkClick(String url) else if(articleModel.getUpOfficial() == 1) layoutArticleHeader.findViewById(R.id.article_card_off_2).setVisibility(View.VISIBLE); - layoutArticleHeader.findViewById(R.id.article_card_follow).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - articleDetailFragmentListener.onArticleDetailFragmentViewClick(v.getId()); - } - }); + layoutArticleHeader.findViewById(R.id.article_card_follow).setOnClickListener( + v -> articleDetailFragmentListener.onArticleDetailFragmentViewClick(v.getId())); setArticleIcon(); @@ -137,39 +132,24 @@ public void onClick(View v) layoutArticleHeader.findViewById(R.id.article_article_bt_fav).setOnClickListener(this); layoutArticleHeader.findViewById(R.id.article_article_bt_share).setOnClickListener(this); + uiArticleListView.setOnTouchListener(new ListViewTouchListener(uiArticleListView, titleViewListener)); + articleAdapter = new ArticleAdapter(inflater, img_width, articleModel.getArticleCardModelList(), uiArticleListView, articleListener); uiArticleListView.addHeaderView(layoutArticleHeader); uiArticleListView.addFooterView(layoutArticleFooter); uiArticleListView.setAdapter(articleAdapter); - layoutArticleFooter.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiArticleListView.smoothScrollToPositionFromTop(0, 0, 500); - uiArticleListView.postDelayed(new Runnable() - { - @Override - public void run() - { - uiArticleListView.setSelection(0); - } - }, 500); - } + layoutArticleFooter.setOnClickListener(v -> { + titleViewListener.showTitle(); + uiArticleListView.smoothScrollToPositionFromTop(0, 0, 500); + uiArticleListView.postDelayed(() -> uiArticleListView.setSelection(0), 500); }); - layoutArticleHeader.findViewById(R.id.article_card_lay).setOnClickListener( - new View.OnClickListener() - { - @Override - public void onClick(View v) - { - Intent intent = new Intent(ctx, UserActivity.class); - intent.putExtra("mid", articleModel.getUpMid()); - ArticleDetailFragment.this.startActivity(intent); - } - }); + layoutArticleHeader.findViewById(R.id.article_card_lay).setOnClickListener(v -> { + Intent intent = new Intent(ctx, UserActivity.class); + intent.putExtra("mid", articleModel.getUpMid()); + ArticleDetailFragment.this.startActivity(intent); + }); return rootLayout; } @@ -253,7 +233,7 @@ public void onEventMainThread(ArticleModel articleModel) } @Override - public void onAttach(Context context) + public void onAttach(@NonNull Context context) { super.onAttach(context); if(context instanceof ArticleDetailFragmentListener) @@ -274,9 +254,10 @@ public void onArticleDetailActivityLoadingFin() }); } else - { throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener"); - } + + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; } @Override diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiDetailFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiDetailFragment.java index 51ace25..0b2d38d 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiDetailFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiDetailFragment.java @@ -88,7 +88,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa uiDetailSectionsRecyclerView = rootLayout.findViewById(R.id.bgm_detail_video_other); ((TextView) rootLayout.findViewById(R.id.bgm_detail_title)).setText(bangumiModel.getTitle()); - if(bangumiModel.getScore().equals("")) + if(bangumiModel.getScore() == null) rootLayout.findViewById(R.id.bgm_detail_score).setVisibility(View.GONE); else ((TextView) rootLayout.findViewById(R.id.bgm_detail_score)).setText(bangumiModel.getScore()); @@ -115,7 +115,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa setBangumiIcon(); - if(bangumiModel.getEpisodes().size() != 0) + if(bangumiModel.getEpisodes() != null && bangumiModel.getEpisodes().size() != 0) { rootLayout.findViewById(R.id.bgm_detail_video_part_layout).setVisibility(View.VISIBLE); ((TextView) rootLayout.findViewById(R.id.bgm_detail_video_part_text)).setText(String.format(getString(R.string.bangumi_episodes_title), bangumiModel.getEpisodes().size(), bangumiModel.getTypeEp())); @@ -129,7 +129,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa layoutManager.scrollToPositionWithOffset(bangumiModel.getUserProgressPosition(), 0); } - if(bangumiModel.getSections().size() != 0) + if(bangumiModel.getSections() != null && bangumiModel.getSections().size() != 0) { rootLayout.findViewById(R.id.bgm_detail_video_other_layout).setVisibility(View.VISIBLE); ((TextView) rootLayout.findViewById(R.id.bgm_detail_video_other_text)).setText(bangumiModel.getSectionName()); @@ -143,7 +143,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa layoutManager.scrollToPositionWithOffset(bangumiModel.getUserProgressPosition(), 0); } - if(bangumiModel.getSeasons().size() > 1) + if(bangumiModel.getSeasons() != null && bangumiModel.getSeasons().size() > 1) { rootLayout.findViewById(R.id.bgm_detail_video_season_layout).setVisibility(View.VISIBLE); LinearLayout episodesLinearLayout = rootLayout.findViewById(R.id.bgm_detail_video_season); @@ -251,14 +251,14 @@ private void clickBangumiDetailOther(int position) private TextView getVideoSeasonButton(final BangumiModel.BangumiSeasonModel season) { TextView textView = new TextView(ctx); - textView.setWidth(120); + textView.setWidth(DataProcessUtil.dip2px(80)); textView.setBackgroundResource(seasonId.equals(season.getSeasonId()) ? R.drawable.selector_bg_bangumi_episode_now : R.drawable.selector_bg_bangumi_episode); textView.setPadding(12, 6, 12, 6); textView.setText(season.getSeasonTitle()); textView.setLines(1); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setTextSize(14); - textView.setTextColor(getResources().getColor(seasonId.equals(season.getSeasonId()) ? ColorUtil.getColor(R.attr.colorPrimary, textView.getContext()) : R.color.gray_77)); + //textView.setTextColor(seasonId.equals(season.getSeasonId()) ? ColorUtil.getColor(R.attr.colorPrimary, textView.getContext()) : getResources().getColor(R.color.gray_77)); textView.setOnClickListener(seasonId.equals(season.getSeasonId()) ? null : (View.OnClickListener) v -> { Intent intent = new Intent(ctx, BangumiActivity.class); intent.putExtra("season_id", season.getSeasonId()); diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiRecommendFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiRecommendFragment.java index a50e99b..4961cf9 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiRecommendFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/BangumiRecommendFragment.java @@ -1,6 +1,7 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -11,11 +12,14 @@ import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.ListBangumiAdapter; import cn.luern0313.wristbilibili.models.ListBangumiModel; import cn.luern0313.wristbilibili.ui.BangumiActivity; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; /** * 被 luern0313 创建于 2020/3/20. @@ -31,6 +35,7 @@ public class BangumiRecommendFragment extends Fragment private ListBangumiAdapter bangumiRecommendAdapter; private ArrayList bangumiRecommendModelArrayList; private ListBangumiAdapter.ListBangumiAdapterListener listBangumiAdapterListener; + private TitleView.TitleViewListener titleViewListener; public BangumiRecommendFragment() { } @@ -53,23 +58,18 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ctx = getActivity(); rootLayout = inflater.inflate(R.layout.fragment_bangumi_recommend, container, false); - listBangumiAdapterListener = new ListBangumiAdapter.ListBangumiAdapterListener() - { - @Override - public void onListBangumiAdapterClick(int viewId, int position) - { - onViewClick(viewId, position); - } - }; + listBangumiAdapterListener = this::onViewClick; uiRecommendListView = rootLayout.findViewById(R.id.bgm_recommend_listview); uiRecommendListView.setEmptyView(rootLayout.findViewById(R.id.bgm_recommend_nothing)); + uiRecommendListView.setOnTouchListener(new ListViewTouchListener(uiRecommendListView, titleViewListener)); bangumiRecommendAdapter = new ListBangumiAdapter(inflater, uiRecommendListView, bangumiRecommendModelArrayList, listBangumiAdapterListener); uiRecommendListView.setAdapter(bangumiRecommendAdapter); @@ -86,4 +86,12 @@ private void onViewClick(int viewId, int position) startActivity(intent); } } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/DownloadFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/DownloadFragment.java index 490d412..8644f33 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/DownloadFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/DownloadFragment.java @@ -3,10 +3,10 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; import android.content.pm.PackageInfo; @@ -15,7 +15,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; @@ -27,12 +26,15 @@ import java.util.List; import java.util.Objects; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.DownloadAdapter; import cn.luern0313.wristbilibili.models.DownloadModel; import cn.luern0313.wristbilibili.service.DownloadService; import cn.luern0313.wristbilibili.util.FileUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; public class DownloadFragment extends Fragment { @@ -44,6 +46,7 @@ public class DownloadFragment extends Fragment private LinearLayout uiListViewEmpty; private TextView uiTip; private DownloadAdapter downloadAdapter; + private TitleView.TitleViewListener titleViewListener; private ArrayList downloadingItems; private ArrayList downloadedItems; @@ -111,6 +114,7 @@ public void onError() } }; + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -129,107 +133,82 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa Intent intent = new Intent(ctx, DownloadService.class); getActivity().bindService(intent, connection, Context.BIND_AUTO_CREATE); - uiListView.setOnItemClickListener(new AdapterView.OnItemClickListener() - { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) + uiListView.setOnItemClickListener((parent, view, position, id) -> { + if(position == 0 || position == downloadingItems.size()) + return; + if(position < downloadingItems.size()) { - if(position == 0 || position == downloadingItems.size()) - return; - if(position < downloadingItems.size()) + if(downloadingItems.get(position).getDownloadMode() != 2) { - if(downloadingItems.get(position).getDownloadMode() != 2) + if(downloadingItems.get(position).getDownloadState() == 1) { - if(downloadingItems.get(position).getDownloadState() == 1) - { - myBinder.pause(position); - downloadAdapter.notifyDataSetChanged(); - } - else if(downloadingItems.get(position).getDownloadState() == 3 || downloadingItems.get(position).getDownloadState() == 5) - { - myBinder.start(position); - downloadAdapter.notifyDataSetChanged(); - } + myBinder.pause(position); + downloadAdapter.notifyDataSetChanged(); } - } - else - { - String name = getVideoName(); - if(!Objects.equals(name, "")) + else if(downloadingItems.get(position).getDownloadState() == 3 || downloadingItems.get(position).getDownloadState() == 5) { - DownloadModel downloadItem = downloadedItems.get(position - downloadingItems.size()); - Intent intent = new Intent(); - intent.setComponent(new ComponentName(name, name + ".ui.PlayerActivity")); - intent.putExtra("mode", 2); - intent.putExtra("url", ctx.getExternalFilesDir(null) + "/download/" + downloadItem.getDownloadAid() + "/" + downloadItem.getDownloadCid() + "/video.mp4"); - intent.putExtra("title", downloadItem.getDownloadTitle()); - startActivityForResult(intent, 0); + myBinder.start(position); + downloadAdapter.notifyDataSetChanged(); } - else - Toast.makeText(ctx, "你没有安装配套视频软件:腕上视频,请先前往应用商店下载!", Toast.LENGTH_LONG).show(); } } + else + { + String name = getVideoName(); + if(!Objects.equals(name, "")) + { + DownloadModel downloadItem = downloadedItems.get(position - downloadingItems.size()); + Intent intent1 = new Intent(); + intent1.setComponent(new ComponentName(name, name + ".ui.PlayerActivity")); + intent1.putExtra("mode", 2); + intent1.putExtra("url", ctx.getExternalFilesDir(null) + "/download/" + downloadItem.getDownloadAid() + "/" + downloadItem.getDownloadCid() + "/video.mp4"); + intent1.putExtra("title", downloadItem.getDownloadTitle()); + startActivityForResult(intent1, 0); + } + else + Toast.makeText(ctx, "你没有安装配套视频软件:腕上视频,请先前往应用商店下载!", Toast.LENGTH_LONG).show(); + } }); - uiListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() - { - @Override - public boolean onItemLongClick(AdapterView parent, View view, final int position, long id) - { - if(position == 0 || position == downloadingItems.size()) - return false; - new AlertDialog.Builder(ctx) - .setMessage("你确定要删除该任务及本地文件吗?") - .setPositiveButton("删除", new DialogInterface.OnClickListener() + uiListView.setOnItemLongClickListener((parent, view, position, id) -> { + if(position == 0 || position == downloadingItems.size()) + return false; + new AlertDialog.Builder(ctx) + .setMessage("你确定要删除该任务及本地文件吗?") + .setPositiveButton("删除", (dialog, which) -> { + DownloadModel downloadItem; + if(position < downloadingItems.size()) { - @Override - public void onClick(DialogInterface dialog, int which) - { - DownloadModel downloadItem; - if(position < downloadingItems.size()) - { - myBinder.pause(position); - downloadItem = downloadingItems.get(position); - downloadingItems.remove(position); - } - else - { - downloadItem = downloadedItems.get(position - downloadingItems.size()); - downloadedItems.remove(position - downloadingItems.size()); - } - FileUtil.deleteDir(new File(ctx.getExternalFilesDir(null) + - "/download/" + downloadItem.getDownloadAid() + "/" + downloadItem.getDownloadCid() + "/")); - File dirFile = new File(ctx.getExternalFilesDir(null) + "/download/" + downloadItem.getDownloadAid() + "/"); - if(dirFile.list().length == 0) - FileUtil.deleteDir(dirFile); - downloadAdapter.notifyDataSetChanged(); - } - }) - .setNegativeButton("取消", null).show(); - return true; - } + myBinder.pause(position); + downloadItem = downloadingItems.get(position); + downloadingItems.remove(position); + } + else + { + downloadItem = downloadedItems.get(position - downloadingItems.size()); + downloadedItems.remove(position - downloadingItems.size()); + } + FileUtil.deleteDir(new File(ctx.getExternalFilesDir(null) + + "/download/" + downloadItem.getDownloadAid() + "/" + downloadItem.getDownloadCid() + "/")); + File dirFile = new File(ctx.getExternalFilesDir(null) + "/download/" + downloadItem.getDownloadAid() + "/"); + if(dirFile.list().length == 0) + FileUtil.deleteDir(dirFile); + downloadAdapter.notifyDataSetChanged(); + }) + .setNegativeButton("取消", null).show(); + return true; }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + uiTip.setText(String.format(getString(R.string.download_tip), BASE_DOWNLOAD_PATH)); - uiTipBtu.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiTip.setVisibility(View.VISIBLE); - ObjectAnimator.ofFloat(uiTip, "alpha", 0.0f, 1.0f).setDuration(500).start(); - } + uiTipBtu.setOnClickListener(v -> { + uiTip.setVisibility(View.VISIBLE); + ObjectAnimator.ofFloat(uiTip, "alpha", 0.0f, 1.0f).setDuration(500).start(); }); - uiTip.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - tipAnim.start(); - } - }); + uiTip.setOnClickListener(v -> tipAnim.start()); tipAnim = ObjectAnimator.ofFloat(uiTip, "alpha", 1.0f, 0.0f); tipAnim.setDuration(500); @@ -265,6 +244,14 @@ else if(packageInfo.packageName.equals("cn.luern0313.wristvideoplayer_free")) return ver; } + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } + @Override public void onDestroyView() { diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicDetailFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicDetailFragment.java index fec4d12..e5e29d7 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicDetailFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicDetailFragment.java @@ -22,7 +22,9 @@ import cn.luern0313.wristbilibili.ui.UnsupportedLinkActivity; import cn.luern0313.wristbilibili.ui.UserActivity; import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.MyApplication; +import cn.luern0313.wristbilibili.widget.TitleView; public class DynamicDetailFragment extends Fragment { @@ -34,8 +36,7 @@ public class DynamicDetailFragment extends Fragment private DynamicAdapter dynamicAdapter; private DynamicAdapter.DynamicAdapterListener dynamicAdapterListener; private DynamicAdapter.ViewHolder viewHolder; - - private int dynamicWidth; + private TitleView.TitleViewListener titleViewListener; private DynamicDetailFragmentListener dynamicDetailFragmentListener; @@ -73,7 +74,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa WindowManager manager = getActivity().getWindowManager(); DisplayMetrics outMetrics = new DisplayMetrics(); manager.getDefaultDisplay().getMetrics(outMetrics); - dynamicWidth = outMetrics.widthPixels - DataProcessUtil.dip2px(18) * 2; + int dynamicWidth = outMetrics.widthPixels - DataProcessUtil.dip2px(18) * 2; dynamicAdapterListener = new DynamicAdapter.DynamicAdapterListener() { @@ -82,8 +83,16 @@ public void onClick(int viewId, int position, boolean isShared) { onDynamicClick(viewId, position, isShared); } + + @Override + public boolean onLongClick(int viewId, int position, boolean isShared) + { + return false; + } }; + rootLayout.findViewById(R.id.dynamic_detail_lay).setOnTouchListener(new ListViewTouchListener(rootLayout.findViewById(R.id.dynamic_detail_lay), titleViewListener)); + rootLayout.findViewById(R.id.item_dynamic_lay).setBackground(null); dynamicAdapter = new DynamicAdapter(inflater, null, rootLayout, dynamicWidth, dynamicAdapterListener); viewHolder = dynamicAdapter.getViewHolder(dynamicModel, rootLayout, R.id.item_dynamic_dynamic); @@ -97,13 +106,12 @@ public void onAttach(@NonNull Context context) { super.onAttach(context); if(context instanceof DynamicDetailFragmentListener) - { dynamicDetailFragmentListener = (DynamicDetailFragmentListener) context; - } else - { throw new RuntimeException(context.toString() + " must implement DynamicDetailFragmentListener"); - } + + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; } @Subscribe(threadMode = ThreadMode.MAIN) diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicFragment.java index cecd25d..82911ed 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/DynamicFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -19,6 +20,7 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.DynamicAdapter; @@ -26,12 +28,15 @@ import cn.luern0313.wristbilibili.api.SendDynamicApi; import cn.luern0313.wristbilibili.models.DynamicModel; import cn.luern0313.wristbilibili.ui.BangumiActivity; +import cn.luern0313.wristbilibili.ui.SelectPartActivity; import cn.luern0313.wristbilibili.ui.SendDynamicActivity; import cn.luern0313.wristbilibili.ui.UnsupportedLinkActivity; import cn.luern0313.wristbilibili.ui.UserActivity; import cn.luern0313.wristbilibili.util.ColorUtil; import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -50,6 +55,8 @@ public class DynamicFragment extends Fragment private DynamicApi dynamicApi; private SendDynamicApi sendDynamicApi; private ArrayList dynamicList; + private TitleView.TitleViewListener titleViewListener; + private int dynamicType = 0; private View rootLayout; private ListView dyListView; @@ -94,6 +101,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ctx = getActivity(); @@ -102,7 +110,7 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun dyListView = rootLayout.findViewById(R.id.dy_listview); loadingView = inflater.inflate(R.layout.widget_loading, null); sendDynamicView = inflater.inflate(R.layout.widget_dy_senddynamic, null); - sendDynamicButton = sendDynamicView.findViewById(R.id.wid_dy_senddynamic); + sendDynamicButton = sendDynamicView.findViewById(R.id.wid_dy_send); WindowManager manager = getActivity().getWindowManager(); DisplayMetrics outMetrics = new DisplayMetrics(); @@ -169,8 +177,8 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun waveSwipeRefreshLayout = rootLayout.findViewById(R.id.dy_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - //noinspection ConstantConditions - waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, getContext())); + waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { isLogin = SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies); if(isLogin) @@ -204,13 +212,36 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + dyListView.setOnTouchListener(new ListViewTouchListener(dyListView, titleViewListener)); + + sendDynamicView.findViewById(R.id.wid_dy_title).setOnClickListener(v -> { + Intent intent = new Intent(ctx, SelectPartActivity.class); + intent.putExtra("title", getString(R.string.dynamic_filter_title)); + intent.putExtra("options_name", getResources().getStringArray(R.array.dynamic_filter)); + intent.putExtra("options_id", DynamicApi.DYNAMIC_TYPES); + startActivityForResult(intent, RESULT_DYNAMIC_FILTER); + }); + sendDynamicButton.setOnClickListener(v -> { Intent intent = new Intent(ctx, SendDynamicActivity.class); intent.putExtra("is_share", false); startActivityForResult(intent, RESULT_DYNAMIC_SEND_DYNAMIC); }); - adapterListener = this::onViewClick; + adapterListener = new DynamicAdapter.DynamicAdapterListener() + { + @Override + public void onClick(int viewId, int position, boolean isShared) + { + onViewClick(viewId, position, isShared); + } + + @Override + public boolean onLongClick(int viewId, int position, boolean isShared) + { + return false; + } + }; if(isLogin) { @@ -231,11 +262,12 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun private void getDynamic() { isLoading = true; + ((TextView) sendDynamicView.findViewById(R.id.wid_dy_title_title)).setText(getResources().getStringArray(R.array.dynamic_filter)[dynamicType]); new Thread(() -> { try { dynamicApi = new DynamicApi(mid, isShowSendButton); - dynamicApi.getDynamic(); + dynamicApi.getDynamic(dynamicType); dynamicList = dynamicApi.getDynamicList(); if(dynamicList != null && dynamicList.size() != 0) { @@ -266,7 +298,7 @@ private void getMoreDynamic() new Thread(() -> { try { - dynamicApi.getHistoryDynamic(); + dynamicApi.getHistoryDynamic(dynamicType); dynamicList.addAll(dynamicApi.getDynamicList()); isLoading = false; handler.post(runnableMore); @@ -408,6 +440,14 @@ else if(viewId == R.id.dynamic_favor_author) } } + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } + @Override public void onActivityResult(final int requestCode, int resultCode, final Intent data) { @@ -472,6 +512,11 @@ else if(requestCode == RESULT_DYNAMIC_SHARE) } }).start(); } + else if(requestCode == RESULT_DYNAMIC_FILTER) + { + dynamicType = data.getIntExtra("option_position", 0); + getDynamic(); + } } private void getShareIntent(Intent intent, DynamicModel.DynamicBaseModel dynamicModel) diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorArticleFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorArticleFragment.java index 2cd37d5..5a1214f 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorArticleFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorArticleFragment.java @@ -1,8 +1,8 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; @@ -19,12 +19,17 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.ListArticleAdapter; -import cn.luern0313.wristbilibili.api.FavorArticleApi; +import cn.luern0313.wristbilibili.api.FavorOtherApi; import cn.luern0313.wristbilibili.models.ListArticleModel; import cn.luern0313.wristbilibili.ui.ArticleActivity; +import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -39,10 +44,11 @@ public class FavorArticleFragment extends Fragment private View layoutLoading; private WaveSwipeRefreshLayout waveSwipeRefreshLayout; - private FavorArticleApi favorArticleApi; + private FavorOtherApi favorArticleApi; private ArrayList listArticleModelArrayList; private ListArticleAdapter listArticleAdapter; private ListArticleAdapter.ListArticleAdapterListener listArticleAdapterListener; + private TitleView.TitleViewListener titleViewListener; private final Handler handler = new Handler(); private Runnable runnableUi, runnableNoWeb, runnableNoData, runnableMore, runnableMoreNoWeb, runnableMoreNoData; @@ -55,6 +61,7 @@ public static Fragment newInstance() return new FavorArticleFragment(); } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -65,23 +72,12 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun layoutLoading = inflater.inflate(R.layout.widget_loading, null); waveSwipeRefreshLayout = rootLayout.findViewById(R.id.favor_article_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - waveSwipeRefreshLayout.setWaveColor(Color.argb(255, 250, 114, 152)); - waveSwipeRefreshLayout.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() - { - @Override - public void onRefresh() - { - handler.post(new Runnable() - { - @Override - public void run() - { - getFavorArticle(); - waveSwipeRefreshLayout.setRefreshing(false); - } - }); - } - }); + waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); + waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { + getFavorArticle(); + waveSwipeRefreshLayout.setRefreshing(false); + })); uiListView.addFooterView(layoutLoading, null, true); uiListView.setHeaderDividersEnabled(false); @@ -100,82 +96,45 @@ public void onListArticleAdapterLongClick(int viewId, int position) } }; - runnableUi = new Runnable() - { - @Override - public void run() - { - isFavorLoading = false; - rootLayout.findViewById(R.id.favor_article_no_web).setVisibility(View.GONE); - rootLayout.findViewById(R.id.favor_article_no_data).setVisibility(View.GONE); - listArticleAdapter = new ListArticleAdapter(inflater, listArticleModelArrayList, uiListView, listArticleAdapterListener); - uiListView.setAdapter(listArticleAdapter); - uiListView.setVisibility(View.VISIBLE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableUi = () -> { + isFavorLoading = false; + rootLayout.findViewById(R.id.favor_article_no_web).setVisibility(View.GONE); + rootLayout.findViewById(R.id.favor_article_no_data).setVisibility(View.GONE); + listArticleAdapter = new ListArticleAdapter(inflater, listArticleModelArrayList, uiListView, listArticleAdapterListener); + uiListView.setAdapter(listArticleAdapter); + uiListView.setVisibility(View.VISIBLE); + waveSwipeRefreshLayout.setRefreshing(false); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.favor_article_no_web).setVisibility(View.VISIBLE); - rootLayout.findViewById(R.id.favor_article_no_data).setVisibility(View.GONE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableNoWeb = () -> { + rootLayout.findViewById(R.id.favor_article_no_web).setVisibility(View.VISIBLE); + rootLayout.findViewById(R.id.favor_article_no_data).setVisibility(View.GONE); + waveSwipeRefreshLayout.setRefreshing(false); }; - runnableNoData = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.favor_article_no_web).setVisibility(View.GONE); - rootLayout.findViewById(R.id.favor_article_no_data).setVisibility(View.VISIBLE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableNoData = () -> { + rootLayout.findViewById(R.id.favor_article_no_web).setVisibility(View.GONE); + rootLayout.findViewById(R.id.favor_article_no_data).setVisibility(View.VISIBLE); + waveSwipeRefreshLayout.setRefreshing(false); }; - runnableMore = new Runnable() - { - @Override - public void run() - { - isFavorLoading = false; - listArticleAdapter.notifyDataSetChanged(); - } + runnableMore = () -> { + isFavorLoading = false; + listArticleAdapter.notifyDataSetChanged(); }; - runnableMoreNoWeb = new Runnable() - { - @Override - public void run() - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_web)); - layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); - isFavorLoading = false; - } + runnableMoreNoWeb = () -> { + ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_web)); + layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); + isFavorLoading = false; }; - runnableMoreNoData = new Runnable() - { - @Override - public void run() - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data)); - } - }; + runnableMoreNoData = () -> ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data)); - layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data_loading)); - layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); - getMoreFavorArticle(); - } + layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(v -> { + ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data_loading)); + layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); + getMoreFavorArticle(); }); uiListView.setOnScrollListener(new AbsListView.OnScrollListener() @@ -195,6 +154,8 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + waveSwipeRefreshLayout.setRefreshing(true); getFavorArticle(); @@ -205,25 +166,20 @@ private void getFavorArticle() { isFavorLoading = true; favorPage = 1; - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - favorArticleApi = new FavorArticleApi(); - listArticleModelArrayList = favorArticleApi.getFavorArticle(favorPage); - if(listArticleModelArrayList != null && listArticleModelArrayList.size() > 0) - handler.post(runnableUi); - else - handler.post(runnableNoData); - } - catch (IOException e) - { - handler.post(runnableNoWeb); - e.printStackTrace(); - } + favorArticleApi = new FavorOtherApi(); + listArticleModelArrayList = favorArticleApi.getFavorArticle(favorPage); + if(listArticleModelArrayList != null && listArticleModelArrayList.size() > 0) + handler.post(runnableUi); + else + handler.post(runnableNoData); + } + catch (IOException e) + { + handler.post(runnableNoWeb); + e.printStackTrace(); } }).start(); } @@ -232,28 +188,23 @@ private void getMoreFavorArticle() { isFavorLoading = true; favorPage++; - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - favorArticleApi = new FavorArticleApi(); - ArrayList articleModelArrayList = favorArticleApi.getFavorArticle(favorPage); - if(articleModelArrayList.size() > 0) - { - listArticleModelArrayList.addAll(articleModelArrayList); - handler.post(runnableMore); - } - else - handler.post(runnableMoreNoData); - } - catch (IOException e) + favorArticleApi = new FavorOtherApi(); + ArrayList articleModelArrayList = favorArticleApi.getFavorArticle(favorPage); + if(articleModelArrayList.size() > 0) { - handler.post(runnableMoreNoWeb); - e.printStackTrace(); + listArticleModelArrayList.addAll(articleModelArrayList); + handler.post(runnableMore); } + else + handler.post(runnableMoreNoData); + } + catch (IOException e) + { + handler.post(runnableMoreNoWeb); + e.printStackTrace(); } }).start(); } @@ -274,41 +225,38 @@ private void onViewLongClick(int id, final int position) { new AlertDialog.Builder(ctx) .setMessage(ctx.getString(R.string.favor_article_delete_message)) - .setPositiveButton(ctx.getString(R.string.favor_article_delete_ok), new DialogInterface.OnClickListener() - { - @Override - public void onClick(DialogInterface dialog, int which) - { - new Thread(new Runnable() - { - @Override - public void run() - { - try - { - String result = favorArticleApi.cancelFavorArticle(String.valueOf(listArticleModelArrayList.get(position).getId())); - if(result.equals("")) - { - listArticleModelArrayList.remove(position); - handler.post(runnableMore); - Looper.prepare(); - Toast.makeText(ctx, ctx.getString(R.string.favor_article_delete_done), Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } - Looper.loop(); - } - catch(IOException e) - { - e.printStackTrace(); - } - } - }).start(); - } - }).setNegativeButton(ctx.getString(R.string.favor_article_delete_cancel), null).show(); + .setPositiveButton(ctx.getString(R.string.favor_article_delete_ok), + (dialog, which) -> new Thread(() -> { + try + { + String result = favorArticleApi.cancelFavorArticle(String.valueOf(listArticleModelArrayList.get(position).getId())); + if(result.equals("")) + { + listArticleModelArrayList.remove(position); + handler.post(runnableMore); + Looper.prepare(); + Toast.makeText(ctx, ctx.getString(R.string.favor_article_delete_done), Toast.LENGTH_SHORT).show(); + } + else + { + Looper.prepare(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); + } + Looper.loop(); + } + catch(IOException e) + { + e.printStackTrace(); + } + }).start()).setNegativeButton(ctx.getString(R.string.favor_article_delete_cancel), null).show(); } } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorBoxFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorBoxFragment.java index cc4d57d..ed57b91 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorBoxFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/FavorBoxFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -13,15 +14,19 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.FavorBoxAdapter; import cn.luern0313.wristbilibili.api.FavorBoxApi; import cn.luern0313.wristbilibili.models.FavorBoxModel; -import cn.luern0313.wristbilibili.ui.FavorArticleActivity; +import cn.luern0313.wristbilibili.ui.FavorOtherActivity; import cn.luern0313.wristbilibili.ui.FavorVideoActivity; import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -41,6 +46,7 @@ public class FavorBoxFragment extends Fragment private FavorBoxApi favorBoxApi; private ArrayList favorBoxArrayList; private FavorBoxAdapter.FavorBoxAdapterListener favorBoxAdapterListener; + private TitleView.TitleViewListener titleViewListener; private View rootLayout; private ListView favListView; @@ -74,6 +80,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -83,97 +90,70 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun favListView = rootLayout.findViewById(R.id.fav_listview); waveSwipeRefreshLayout = rootLayout.findViewById(R.id.fav_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - //noinspection ConstantConditions - waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, getContext())); - waveSwipeRefreshLayout.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() - { - @Override - public void onRefresh() + waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); + waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { + if(isLogin) { - handler.post(new Runnable() - { - @Override - public void run() - { - if(isLogin) - { - favListView.setVisibility(View.GONE); - getFavorBox(); - } - else waveSwipeRefreshLayout.setRefreshing(false); - } - }); + favListView.setVisibility(View.GONE); + getFavorBox(); } - }); + else waveSwipeRefreshLayout.setRefreshing(false); + })); - favorBoxAdapterListener = new FavorBoxAdapter.FavorBoxAdapterListener() - { - @Override - public void onClick(int viewId, int position) + favorBoxAdapterListener = (viewId, position) -> { + if(viewId == R.id.favor_lay) { - if(viewId == R.id.favor_lay) + FavorBoxModel favorBoxModel = favorBoxArrayList.get(position); + if(favorBoxModel.getMode() == 0) + { + Intent intent = new Intent(ctx, FavorVideoActivity.class); + intent.putExtra("fid", favorBoxArrayList.get(position).getFid()); + intent.putExtra("mid", mid); + startActivity(intent); + } + else if(favorBoxModel.getMode() == 1) + { + Intent intent = new Intent(ctx, FavorOtherActivity.class); + intent.putExtra("mode", 0); + startActivity(intent); + } + else if(favorBoxModel.getMode() == 2) { - FavorBoxModel favorBoxModel = favorBoxArrayList.get(position); - if(favorBoxModel.getMode() == 0) - { - Intent intent = new Intent(ctx, FavorVideoActivity.class); - intent.putExtra("fid", favorBoxArrayList.get(position).getFid()); - intent.putExtra("mid", mid); - startActivity(intent); - } - else if(favorBoxModel.getMode() == 1) - { - Intent intent = new Intent(ctx, FavorArticleActivity.class); - startActivity(intent); - } - else if(favorBoxModel.getMode() == 2) - { - - } + Intent intent = new Intent(ctx, FavorOtherActivity.class); + intent.putExtra("mode", 1); + startActivity(intent); } } }; - runnableUi = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.fav_nologin).setVisibility(View.GONE); - rootLayout.findViewById(R.id.fav_noweb).setVisibility(View.GONE); - rootLayout.findViewById(R.id.fav_nonthing).setVisibility(View.GONE); - favListView.setAdapter(new FavorBoxAdapter(inflater, favorBoxArrayList, favListView, favorBoxAdapterListener)); - favListView.setVisibility(View.VISIBLE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableUi = () -> { + rootLayout.findViewById(R.id.fav_nologin).setVisibility(View.GONE); + rootLayout.findViewById(R.id.fav_noweb).setVisibility(View.GONE); + rootLayout.findViewById(R.id.fav_nonthing).setVisibility(View.GONE); + favListView.setAdapter(new FavorBoxAdapter(inflater, favorBoxArrayList, favListView, favorBoxAdapterListener)); + favListView.setVisibility(View.VISIBLE); + waveSwipeRefreshLayout.setRefreshing(false); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.fav_nologin).setVisibility(View.GONE); - rootLayout.findViewById(R.id.fav_noweb).setVisibility(View.VISIBLE); - rootLayout.findViewById(R.id.fav_nonthing).setVisibility(View.GONE); - favListView.setVisibility(View.GONE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableNoWeb = () -> { + rootLayout.findViewById(R.id.fav_nologin).setVisibility(View.GONE); + rootLayout.findViewById(R.id.fav_noweb).setVisibility(View.VISIBLE); + rootLayout.findViewById(R.id.fav_nonthing).setVisibility(View.GONE); + favListView.setVisibility(View.GONE); + waveSwipeRefreshLayout.setRefreshing(false); }; - runnableNoData = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.fav_nologin).setVisibility(View.GONE); - rootLayout.findViewById(R.id.fav_noweb).setVisibility(View.GONE); - rootLayout.findViewById(R.id.fav_nonthing).setVisibility(View.VISIBLE); - favListView.setVisibility(View.GONE); - waveSwipeRefreshLayout.setRefreshing(false); - } + runnableNoData = () -> { + rootLayout.findViewById(R.id.fav_nologin).setVisibility(View.GONE); + rootLayout.findViewById(R.id.fav_noweb).setVisibility(View.GONE); + rootLayout.findViewById(R.id.fav_nonthing).setVisibility(View.VISIBLE); + favListView.setVisibility(View.GONE); + waveSwipeRefreshLayout.setRefreshing(false); }; + favListView.setOnTouchListener(new ListViewTouchListener(favListView, titleViewListener)); + isLogin = SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies); if(isLogin) { @@ -191,31 +171,34 @@ public void run() private void getFavorBox() { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - favorBoxApi = new FavorBoxApi(mid, isShowOtherBox); - favorBoxArrayList = favorBoxApi.getFavorBox(); - if(favorBoxArrayList != null && favorBoxArrayList.size() != 0) - handler.post(runnableUi); - else - handler.post(runnableNoData); - } - catch (NullPointerException e) - { + favorBoxApi = new FavorBoxApi(mid, isShowOtherBox); + favorBoxArrayList = favorBoxApi.getFavorBox(); + if(favorBoxArrayList != null && favorBoxArrayList.size() != 0) + handler.post(runnableUi); + else handler.post(runnableNoData); - e.printStackTrace(); - } - catch (IOException e) - { - handler.post(runnableNoWeb); - e.printStackTrace(); - } + } + catch (NullPointerException e) + { + handler.post(runnableNoData); + e.printStackTrace(); + } + catch (IOException e) + { + handler.post(runnableNoWeb); + e.printStackTrace(); } }).start(); } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/HistoryFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/HistoryFragment.java index 90ac444..31e5f2f 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/HistoryFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/HistoryFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -15,6 +16,7 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.ListVideoAdapter; @@ -22,7 +24,10 @@ import cn.luern0313.wristbilibili.models.ListVideoModel; import cn.luern0313.wristbilibili.ui.VideoActivity; import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; public class HistoryFragment extends Fragment @@ -36,6 +41,7 @@ public class HistoryFragment extends Fragment private ListVideoAdapter listVideoAdapter; private ListVideoAdapter.ListVideoAdapterListener listVideoAdapterListener; private ListView uiListView; + private TitleView.TitleViewListener titleViewListener; private final ArrayList historyArrayList = new ArrayList<>(); @@ -54,6 +60,7 @@ public static HistoryFragment newInstance() return new HistoryFragment(); } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -65,8 +72,8 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun uiListView.addFooterView(uiLoadingView); waveSwipeRefreshLayout = rootLayout.findViewById(R.id.history_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - //noinspection ConstantConditions - waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, getContext())); + waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { if(isLogin) { @@ -151,6 +158,8 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + isLogin = SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies); if(isLogin) { @@ -214,4 +223,12 @@ private void getMoreHistory() } }).start(); } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/RankingFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/RankingFragment.java index 081b7d3..29fc6c2 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/RankingFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/RankingFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; @@ -23,21 +24,26 @@ import java.util.LinkedHashMap; import java.util.Locale; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.RankingAdapter; +import cn.luern0313.wristbilibili.api.DynamicApi; import cn.luern0313.wristbilibili.api.RankingApi; import cn.luern0313.wristbilibili.api.VideoApi; import cn.luern0313.wristbilibili.models.RankingModel; import cn.luern0313.wristbilibili.models.VideoModel; +import cn.luern0313.wristbilibili.ui.SelectPartActivity; import cn.luern0313.wristbilibili.ui.TextActivity; import cn.luern0313.wristbilibili.ui.UserActivity; import cn.luern0313.wristbilibili.ui.VideoActivity; import cn.luern0313.wristbilibili.util.ColorUtil; import cn.luern0313.wristbilibili.util.DataProcessUtil; import cn.luern0313.wristbilibili.util.ImageDownloaderUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -49,19 +55,19 @@ public class RankingFragment extends Fragment Context ctx; View rootLayout; private RankingAdapter rankingAdapter; - private RankingAdapter.RankingAdapterListener adapterListener; private VideoApi videoDetailsApi; private VideoModel videoModel; + private TitleView.TitleViewListener titleViewListener; private ListView uiListView; private WaveSwipeRefreshLayout uiWaveSwipeRefreshLayout; - private View uiPickUpView; + private View uiPickUpView, uiToolbarView, sendDynamicView; private View uiLoadingView; private RankingApi rankingApi; private final ArrayList rankingVideoArrayList = new ArrayList<>(); private LinkedHashMap pickUpHashMap = new LinkedHashMap<>(); - private String pickupday; + private String pickupDay; private int pn = 1; private boolean isLoading = true; private Bitmap bitmapPickUpUpFace; @@ -82,238 +88,155 @@ public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup cont rankingApi = new RankingApi(); uiPickUpView = inflater.inflate(R.layout.widget_ranking_pickup, null, false); + uiToolbarView = inflater.inflate(R.layout.widget_ranking_toolbar, null, false); uiLoadingView = inflater.inflate(R.layout.widget_loading, null, false); + sendDynamicView = uiToolbarView.findViewById(R.id.widget_ranking_toolbar_title); uiListView = rootLayout.findViewById(R.id.rk_listview); uiListView.addFooterView(uiLoadingView); + uiListView.addHeaderView(uiToolbarView); + uiListView.addHeaderView(uiPickUpView); uiWaveSwipeRefreshLayout = rootLayout.findViewById(R.id.rk_swipe); uiWaveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - //noinspection ConstantConditions - uiWaveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, getContext())); - uiWaveSwipeRefreshLayout.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() - { - @Override - public void onRefresh() - { - handler.post(new Runnable() - { - @Override - public void run() - { - isLoading = true; - rankingVideoArrayList.clear(); - pn = 1; - uiListView.setVisibility(View.GONE); - getRanking(); - } - }); - } - }); - - adapterListener = new RankingAdapter.RankingAdapterListener() - { - @Override - public void onClick(int viewId, int position) - { - onViewClick(viewId, position); - } - }; + uiWaveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + uiWaveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); + uiWaveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { + isLoading = true; + rankingVideoArrayList.clear(); + pn = 1; + uiListView.setVisibility(View.GONE); + getRanking(); + })); + + RankingAdapter.RankingAdapterListener adapterListener = this::onViewClick; rankingAdapter = new RankingAdapter(inflater, rankingVideoArrayList, uiListView, adapterListener); uiListView.setAdapter(rankingAdapter); - runnableUi = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.rk_noweb).setVisibility(View.GONE); - uiListView.setVisibility(View.VISIBLE); - uiWaveSwipeRefreshLayout.setRefreshing(false); - isLoading = false; - rankingAdapter.notifyDataSetChanged(); - } + runnableUi = () -> { + rootLayout.findViewById(R.id.rk_noweb).setVisibility(View.GONE); + uiListView.setVisibility(View.VISIBLE); + uiWaveSwipeRefreshLayout.setRefreshing(false); + isLoading = false; + rankingAdapter.notifyDataSetChanged(); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - uiWaveSwipeRefreshLayout.setRefreshing(false); - rootLayout.findViewById(R.id.rk_noweb).setVisibility(View.VISIBLE); - isLoading = false; - } + runnableNoWeb = () -> { + uiWaveSwipeRefreshLayout.setRefreshing(false); + rootLayout.findViewById(R.id.rk_noweb).setVisibility(View.VISIBLE); + isLoading = false; }; - runnableNoWebH = new Runnable() - { - @Override - public void run() - { - ((TextView) uiLoadingView.findViewById(R.id.wid_load_button)).setText(ctx.getString(R.string.main_tip_no_more_web)); - uiLoadingView.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); - } + runnableNoWebH = () -> { + ((TextView) uiLoadingView.findViewById(R.id.wid_load_button)).setText(ctx.getString(R.string.main_tip_no_more_web)); + uiLoadingView.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); }; - runnableNoMore = new Runnable() - { - @Override - public void run() - { - ((TextView) uiLoadingView.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data)); - } - }; + runnableNoMore = () -> ((TextView) uiLoadingView.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data)); - runnablePickNodata = new Runnable() - { - @Override - public void run() - { - uiPickUpView.findViewById(R.id.rk_pu_lay).setVisibility(View.GONE); - } - }; + runnablePickNodata = () -> uiListView.removeHeaderView(uiPickUpView); - runnablePick = new Runnable() - { - @Override - public void run() + runnablePick = () -> { + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); + int today_int = Integer.parseInt(format.format(new Date(System.currentTimeMillis()))); + ArrayList dates = new ArrayList<>(pickUpHashMap.keySet()); + Collections.sort(dates); + for(int i = dates.size() - 1; i >= 0; i--) { - SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); - int today_int = Integer.parseInt(format.format(new Date(System.currentTimeMillis()))); - ArrayList dates = new ArrayList<>(pickUpHashMap.keySet()); - Collections.sort(dates); - for(int i = dates.size() - 1; i >= 0; i--) + if(dates.get(i) <= today_int) { - if(dates.get(i) <= today_int) - { - pickupday = String.valueOf(dates.get(i)); - videoDetailsApi = new VideoApi(pickUpHashMap.get(dates.get(i)), ""); - new Thread(new Runnable() + pickupDay = String.valueOf(dates.get(i)); + videoDetailsApi = new VideoApi(pickUpHashMap.get(dates.get(i)), ""); + new Thread(() -> { + try { - @Override - public void run() - { - try - { - videoModel = videoDetailsApi.getVideoDetails(); - if(videoModel != null) - handler.post(runnablePickUi); - else - handler.post(runnablePickNodata); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - }).start(); - break; - } + videoModel = videoDetailsApi.getVideoDetails(); + if(videoModel != null) + handler.post(runnablePickUi); + else + handler.post(runnablePickNodata); + } + catch (IOException e) + { + e.printStackTrace(); + } + }).start(); + break; } } }; - runnablePickUi = new Runnable() - { - @Override - public void run() + runnablePickUi = () -> { + try { - try - { - if(uiListView.getHeaderViewsCount() == 0) uiListView.addHeaderView(uiPickUpView); - uiPickUpView.findViewById(R.id.rk_pu_lay).setVisibility(View.VISIBLE); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_title)).setText(videoModel.video_title); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_up_name)).setText(videoModel.video_up_name); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_date_date)).setText(pickupday.substring(4, 6) + "月" + pickupday.substring(6, 8) + "日"); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_play)).setText(videoModel.video_play); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_danmaku)).setText(videoModel.video_danmaku); - if(SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.firstPickUp, true)) - uiPickUpView.findViewById(R.id.rk_pu_date_click).setVisibility(View.VISIBLE); - - Drawable playNumDrawable = ctx.getResources().getDrawable(R.drawable.icon_number_play); - Drawable danmakuNumDrawable = ctx.getResources().getDrawable(R.drawable.icon_number_danmu); - playNumDrawable.setBounds(0, 0, DataProcessUtil.dip2px(10), DataProcessUtil.dip2px(10)); - danmakuNumDrawable.setBounds(0, 0, DataProcessUtil.dip2px(10), DataProcessUtil.dip2px(10)); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_play)).setCompoundDrawables(playNumDrawable,null, null,null); - ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_danmaku)).setCompoundDrawables(danmakuNumDrawable,null, null,null); - - uiPickUpView.findViewById(R.id.rk_pu_date).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiPickUpView.findViewById(R.id.rk_pu_date_click).setVisibility(View.GONE); - SharedPreferencesUtil.putBoolean(SharedPreferencesUtil.firstPickUp, false); - Intent intent = new Intent(ctx, TextActivity.class); - intent.putExtra("title", "说明"); - intent.putExtra("text", ("Pick Up视频说明\n" + "每天由用户推荐并投票选出一个精选视频,在排行榜的上方Pick Up栏推广展示一天\n" + "目的是让一些制作精良但播放不高的视频获得更多的曝光\n" + "(相关规则和投票系统正在制作中,目前推荐视频为手动设置,你可以在qq或b站私聊开发者推荐你喜欢的视频)\n" + "(相关要求:连续五天不能推荐同一名up主的视频,上榜视频非引战或有争议视频,播放量少的视频优先等)").replaceAll("\n", "

")); - startActivity(intent); - } - }); + uiPickUpView.findViewById(R.id.rk_pu_lay).setVisibility(View.VISIBLE); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_title)).setText(videoModel.getTitle()); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_up_name)).setText(videoModel.getUpName()); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_date_date)).setText(String.format(ctx.getString(R.string.ranking_pickup_date), pickupDay + .substring(4, 6), pickupDay.substring(6, 8))); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_play)).setText(videoModel.getPlay()); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_danmaku)).setText(videoModel.getDanmaku()); + if(SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.firstPickUp, true)) + uiPickUpView.findViewById(R.id.rk_pu_date_click).setVisibility(View.VISIBLE); + + Drawable playNumDrawable = ctx.getResources().getDrawable(R.drawable.icon_number_play); + Drawable danmakuNumDrawable = ctx.getResources().getDrawable(R.drawable.icon_number_danmu); + playNumDrawable.setBounds(0, 0, DataProcessUtil.dip2px(10), DataProcessUtil.dip2px(10)); + danmakuNumDrawable.setBounds(0, 0, DataProcessUtil.dip2px(10), DataProcessUtil.dip2px(10)); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_play)).setCompoundDrawables(playNumDrawable,null, null,null); + ((TextView) uiPickUpView.findViewById(R.id.rk_pu_video_danmaku)).setCompoundDrawables(danmakuNumDrawable,null, null,null); + + uiPickUpView.findViewById(R.id.rk_pu_date).setOnClickListener(v -> { + uiPickUpView.findViewById(R.id.rk_pu_date_click).setVisibility(View.GONE); + SharedPreferencesUtil.putBoolean(SharedPreferencesUtil.firstPickUp, false); + Intent intent = new Intent(ctx, TextActivity.class); + intent.putExtra("title", "说明"); + intent.putExtra("text", ("Pick Up视频说明\n" + "每天由用户推荐并投票选出一个精选视频,在排行榜的上方Pick Up栏推广展示一天\n" + "目的是让一些制作精良但播放不高的视频获得更多的曝光\n" + "(相关规则和投票系统正在制作中,目前推荐视频为手动设置,你可以在qq或b站私聊开发者推荐你喜欢的视频)\n" + "(相关要求:连续五天不能推荐同一名up主的视频,上榜视频非引战或有争议视频,播放量少的视频优先等)").replaceAll("\n", "

")); + startActivity(intent); + }); - uiPickUpView.findViewById(R.id.rk_pu_video_up).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - Intent intent = new Intent(ctx, UserActivity.class); - intent.putExtra("mid", videoModel.video_up_mid); - startActivity(intent); - } - }); + uiPickUpView.findViewById(R.id.rk_pu_video_up).setOnClickListener(v -> { + Intent intent = new Intent(ctx, UserActivity.class); + intent.putExtra("mid", videoModel.getUpMid()); + startActivity(intent); + }); - uiPickUpView.findViewById(R.id.rk_pu_lay).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - new Thread(new Runnable() - { - @Override - public void run() - { - rankingApi.clickPickUpVideo(); - } - }).start(); - startActivity(VideoActivity.getActivityIntent(ctx, videoModel.video_aid, "")); - } - }); + uiPickUpView.findViewById(R.id.rk_pu_lay).setOnClickListener(v -> { + new Thread(() -> rankingApi.clickPickUpVideo()).start(); + startActivity(VideoActivity.getActivityIntent(ctx, videoModel.getAid(), "")); + }); - new Thread(new Runnable() + new Thread(() -> { + try { - @Override - public void run() - { - try - { - bitmapPickUpUpFace = ImageDownloaderUtil.downloadImage(videoModel.video_up_face); - bitmapPickUpVideoCover = ImageDownloaderUtil.downloadImage(videoModel.video_cover); - handler.post(runnablePickImg); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - }).start(); - } - catch (RuntimeException e) - { - e.printStackTrace(); - } + bitmapPickUpUpFace = ImageDownloaderUtil.downloadImage(videoModel.getUpFace()); + bitmapPickUpVideoCover = ImageDownloaderUtil.downloadImage(videoModel.getCover()); + handler.post(runnablePickImg); + } + catch (IOException e) + { + e.printStackTrace(); + } + }).start(); } - }; - - runnablePickImg = new Runnable() - { - @Override - public void run() + catch (RuntimeException e) { - ((ImageView) uiPickUpView.findViewById(R.id.rk_pu_video_up_head)).setImageBitmap(bitmapPickUpUpFace); - ((ImageView) uiPickUpView.findViewById(R.id.rk_pu_video_img)).setImageBitmap(bitmapPickUpVideoCover); + e.printStackTrace(); } }; + runnablePickImg = () -> { + ((ImageView) uiPickUpView.findViewById(R.id.rk_pu_video_up_head)).setImageBitmap(bitmapPickUpUpFace); + ((ImageView) uiPickUpView.findViewById(R.id.rk_pu_video_img)).setImageBitmap(bitmapPickUpVideoCover); + }; + + sendDynamicView.findViewById(R.id.wid_dy_title).setOnClickListener(v -> { + Intent intent = new Intent(ctx, SelectPartActivity.class); + intent.putExtra("title", getString(R.string.dynamic_filter_title)); + intent.putExtra("options_name", getResources().getStringArray(R.array.region_list_title)); + intent.putExtra("options_id", DynamicApi.DYNAMIC_TYPES); + startActivityForResult(intent, RESULT_RANKING_REGION); + }); + uiListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override @@ -332,6 +255,8 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + uiListView.setVisibility(View.GONE); uiWaveSwipeRefreshLayout.setRefreshing(true); getRanking(); @@ -342,33 +267,28 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun private void getRanking() { uiPickUpView.findViewById(R.id.rk_pu_lay).setVisibility(View.GONE); - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + ArrayList rankingModelArrayList = rankingApi.getRankingVideo(pn); + pickUpHashMap = rankingApi.getPickUpVideo(); + if(rankingModelArrayList != null && rankingModelArrayList.size() != 0) { - ArrayList rankingModelArrayList = rankingApi.getRankingVideo(pn); - pickUpHashMap = rankingApi.getPickUpVideo(); - if(rankingModelArrayList != null && rankingModelArrayList.size() != 0) - { - rankingVideoArrayList.addAll(rankingModelArrayList); - pn++; - handler.post(runnableUi); - if(pickUpHashMap == null || pickUpHashMap.size() == 0) - handler.post(runnablePickNodata); - else - handler.post(runnablePick); - } + rankingVideoArrayList.addAll(rankingModelArrayList); + pn++; + handler.post(runnableUi); + if(pickUpHashMap == null || pickUpHashMap.size() == 0) + handler.post(runnablePickNodata); else - handler.post(runnableNoMore); - } - catch (IOException e) - { - handler.post(runnableNoWeb); - e.printStackTrace(); + handler.post(runnablePick); } + else + handler.post(runnableNoMore); + } + catch (IOException e) + { + handler.post(runnableNoWeb); + e.printStackTrace(); } }).start(); } @@ -390,4 +310,12 @@ else if(viewId == R.id.rk_video_video_up) startActivity(intent); } } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/RecommendFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/RecommendFragment.java index efb7d92..6ea2a3b 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/RecommendFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/RecommendFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -15,6 +16,7 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; @@ -23,6 +25,9 @@ import cn.luern0313.wristbilibili.models.RecommendModel; import cn.luern0313.wristbilibili.ui.VideoActivity; import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -38,6 +43,7 @@ public class RecommendFragment extends Fragment private ListView uiListView; private WaveSwipeRefreshLayout uiWaveSwipeRefreshLayout; private View uiLoadingView; + private TitleView.TitleViewListener titleViewListener; private RecommendApi recommendApi; private final ArrayList recommendVideoArrayList = new ArrayList<>(); @@ -46,6 +52,7 @@ public class RecommendFragment extends Fragment Handler handler = new Handler(); private Runnable runnableUi, runnableNoWeb, runnableNoMore, RunnableNoWebH; + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { @@ -58,79 +65,38 @@ public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup cont uiListView.addFooterView(uiLoadingView); uiWaveSwipeRefreshLayout = rootLayout.findViewById(R.id.rc_swipe); uiWaveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); - //noinspection ConstantConditions - uiWaveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, getContext())); - uiWaveSwipeRefreshLayout.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() - { - @Override - public void onRefresh() - { - handler.post(new Runnable() - { - @Override - public void run() - { - isLoading = true; - getRecommend(1); - } - }); - } - }); + uiWaveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + uiWaveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); + uiWaveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { + isLoading = true; + getRecommend(1); + })); - adapterListener = new RecommendAdapter.RecommendAdapterListener() - { - @Override - public void onClick(int viewId, int position) - { - onViewClick(viewId, position); - } - }; + adapterListener = this::onViewClick; recommendAdapter = new RecommendAdapter(inflater, recommendVideoArrayList, uiListView, adapterListener); uiListView.setAdapter(recommendAdapter); - runnableUi = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.rc_noweb).setVisibility(View.GONE); - uiListView.setVisibility(View.VISIBLE); - uiWaveSwipeRefreshLayout.setRefreshing(false); - isLoading = false; - recommendAdapter.notifyDataSetChanged(); - } + runnableUi = () -> { + rootLayout.findViewById(R.id.rc_noweb).setVisibility(View.GONE); + uiListView.setVisibility(View.VISIBLE); + uiWaveSwipeRefreshLayout.setRefreshing(false); + isLoading = false; + recommendAdapter.notifyDataSetChanged(); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - uiWaveSwipeRefreshLayout.setRefreshing(false); - rootLayout.findViewById(R.id.rc_noweb).setVisibility(View.VISIBLE); - isLoading = false; - } + runnableNoWeb = () -> { + uiWaveSwipeRefreshLayout.setRefreshing(false); + rootLayout.findViewById(R.id.rc_noweb).setVisibility(View.VISIBLE); + isLoading = false; }; - RunnableNoWebH = new Runnable() - { - @Override - public void run() - { - ((TextView) uiLoadingView.findViewById(R.id.wid_load_button)).setText(ctx.getString(R.string.main_tip_no_more_web)); - uiLoadingView.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); - } + RunnableNoWebH = () -> { + ((TextView) uiLoadingView.findViewById(R.id.wid_load_button)).setText(ctx.getString(R.string.main_tip_no_more_web)); + uiLoadingView.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); }; - runnableNoMore = new Runnable() - { - @Override - public void run() - { - ((TextView) uiLoadingView.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data)); - } - }; + runnableNoMore = () -> ((TextView) uiLoadingView.findViewById(R.id.wid_load_text)).setText(ctx.getString(R.string.main_tip_no_more_data)); uiListView.setOnScrollListener(new AbsListView.OnScrollListener() { @@ -150,6 +116,8 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + uiListView.setVisibility(View.GONE); uiWaveSwipeRefreshLayout.setRefreshing(true); getRecommend(2); @@ -159,36 +127,31 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun private void getRecommend(final int mode) //1上 2下 { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + ArrayList rankingModelArrayList = recommendApi.getRecommendVideo(mode == 1); + if(rankingModelArrayList != null && rankingModelArrayList.size() != 0) { - ArrayList rankingModelArrayList = recommendApi.getRecommendVideo(mode == 1); - if(rankingModelArrayList != null && rankingModelArrayList.size() != 0) + if(mode == 1) { - if(mode == 1) - { - recommendVideoArrayList.add(0, new RecommendModel(1)); - recommendVideoArrayList.addAll(0, rankingModelArrayList); - } - else - recommendVideoArrayList.addAll(rankingModelArrayList); - handler.post(runnableUi); + recommendVideoArrayList.add(0, new RecommendModel(1)); + recommendVideoArrayList.addAll(0, rankingModelArrayList); } else - { - handler.post(runnableNoMore); - } + recommendVideoArrayList.addAll(rankingModelArrayList); + handler.post(runnableUi); } - catch (IOException e) + else { - handler.post(runnableNoWeb); - e.printStackTrace(); + handler.post(runnableNoMore); } } + catch (IOException e) + { + handler.post(runnableNoWeb); + e.printStackTrace(); + } }).start(); } @@ -211,4 +174,12 @@ else if(viewId == R.id.widget_recommend_update_lay) getRecommend(1); } } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/ReplyFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/ReplyFragment.java index 44eea19..6f26040 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/ReplyFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/ReplyFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.Color; @@ -18,6 +19,7 @@ import java.io.IOException; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.ReplyAdapter; @@ -30,6 +32,8 @@ import cn.luern0313.wristbilibili.ui.UserActivity; import cn.luern0313.wristbilibili.util.ColorUtil; import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -60,6 +64,7 @@ public class ReplyFragment extends Fragment private ReplyAdapter replyAdapter; private ReplyAdapter.ReplyAdapterListener replyAdapterListener; + private TitleView.TitleViewListener titleViewListener; private final Handler handler = new Handler(); private Runnable runnableUi, runnableNoWeb, runnableNothing, runnableMoreNoMore, runnableMoreErr, runnableUpdate; @@ -98,6 +103,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -152,20 +158,24 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + waveSwipeRefreshLayout = rootLayout.findViewById(R.id.reply_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { rootLayout.findViewById(R.id.reply_listview).setVisibility(View.GONE); getReply(oid, type, sort); })); layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(v -> { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(" 加载中. . ."); + ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_data_loading)); layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); getMoreReply(); }); + uiReplyListView.setOnTouchListener(new ListViewTouchListener(uiReplyListView, titleViewListener)); + runnableUi = () -> { try { @@ -196,10 +206,10 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun rootLayout.findViewById(R.id.reply_loading).setVisibility(View.GONE); }; - runnableMoreNoMore = () -> ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(" 没有更多了..."); + runnableMoreNoMore = () -> ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_data)); runnableMoreErr = () -> { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText("好像没有网络...\n检查下网络?"); + ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_web)); layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); isReplyLoading = false; }; @@ -215,7 +225,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun isReplyLoading = false; if(replyApi.replyIsEnd) - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(" 没有更多了..."); + ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_data)); replyAdapter.notifyDataSetChanged(); } catch (Exception e) @@ -322,7 +332,8 @@ else if(viewId == R.id.item_reply_dislike) } }).start(); } - else if(viewId == R.id.item_reply_reply_show || viewId == R.id.item_reply_reply) + else if(viewId == R.id.item_reply_reply_show_1 || viewId == R.id.item_reply_reply_show_2 || + viewId == R.id.item_reply_reply_show_3 || viewId == R.id.item_reply_reply_show_show || viewId == R.id.item_reply_reply) { if(root == null) { @@ -354,6 +365,14 @@ else if(mode == 1) } } + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } + @Override public void onActivityResult(final int requestCode, int resultCode, final Intent data) { diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/SearchFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/SearchFragment.java index bf4cf54..3daa9d8 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/SearchFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/SearchFragment.java @@ -1,5 +1,9 @@ package cn.luern0313.wristbilibili.fragment; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.graphics.drawable.AnimationDrawable; @@ -8,12 +12,15 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.InputMethodManager; import android.widget.AbsListView; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.GridView; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -21,6 +28,7 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; @@ -30,7 +38,9 @@ import cn.luern0313.wristbilibili.ui.BangumiActivity; import cn.luern0313.wristbilibili.ui.UserActivity; import cn.luern0313.wristbilibili.ui.VideoActivity; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SearchHtmlTagHandlerUtil; +import cn.luern0313.wristbilibili.widget.TitleView; /** * Created by liupe on 2018/11/16. @@ -62,12 +72,16 @@ public class SearchFragment extends Fragment private Runnable runnableHotWord, runnableHotWordErr, runnableNoweb, runnableUi; private Runnable runnableAddlist, runnableNoWebH, runnableNoresult, runnableNomore; + private ObjectAnimator searchBoxAnimator; + private String[] hotWordArray; private ArrayList searchResult; private HotWordAdapter hotwordAdapter; private boolean isLoading = true; + private boolean isHide; + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -75,148 +89,94 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun rootLayout = inflater.inflate(R.layout.fragment_search, container, false); searchApi = new SearchApi(); htmlTagHandlerUtil = new SearchHtmlTagHandlerUtil(ctx); - searchAdapterListener = new SearchAdapter.SearchAdapterListener() + searchAdapterListener = this::onViewClick; + + listViewScrollListener = new ListViewTouchListener.ListViewScrollListener() { @Override - public void onClick(int viewId, int position) + public void hide() { - onViewClick(viewId, position); + hideSearchBox(); + } + + @Override + public void show() + { + showSearchBox(); } }; - seaHotWordText = rootLayout.findViewById(R.id.sea_hotwordtext); + seaHotWordText = rootLayout.findViewById(R.id.sea_hotword_text); seaHotWordList = rootLayout.findViewById(R.id.sea_hotword); seaListView = rootLayout.findViewById(R.id.sea_listview); loadingView = inflater.inflate(R.layout.widget_loading, null); + searchBox = rootLayout.findViewById(R.id.sea_box); seaEdittext = rootLayout.findViewById(R.id.sea_edittext); inButton = rootLayout.findViewById(R.id.sea_inbutton); seaButton = rootLayout.findViewById(R.id.sea_seabutton); seaLoadImg = rootLayout.findViewById(R.id.sea_searching_img); - runnableHotWord = new Runnable() - { - @Override - public void run() - { - hotwordAdapter = new HotWordAdapter(ctx, android.R.layout.simple_list_item_1, hotWordArray); - seaHotWordText.setText("大家都在搜"); - seaHotWordList.setAdapter(hotwordAdapter); - } + runnableHotWord = () -> { + hotwordAdapter = new HotWordAdapter(ctx, android.R.layout.simple_list_item_1, hotWordArray); + seaHotWordText.setText("大家都在搜"); + seaHotWordList.setAdapter(hotwordAdapter); }; - runnableHotWordErr = new Runnable() - { - @Override - public void run() - { - seaHotWordText.setText("搜索热词加载失败"); - } - }; + runnableHotWordErr = () -> seaHotWordText.setText("搜索热词加载失败"); - runnableNoweb = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.sea_noweb).setVisibility(View.VISIBLE); - rootLayout.findViewById(R.id.sea_searching).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_listview).setVisibility(View.GONE); - } + runnableNoweb = () -> { + rootLayout.findViewById(R.id.sea_noweb).setVisibility(View.VISIBLE); + rootLayout.findViewById(R.id.sea_searching).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_listview).setVisibility(View.GONE); }; - runnableNoWebH = new Runnable() - { - @Override - public void run() - { - ((TextView) loadingView.findViewById(R.id.wid_load_text)).setText("好像没有网络...\n检查下网络?"); - loadingView.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); - } + runnableNoWebH = () -> { + ((TextView) loadingView.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_web)); + loadingView.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); }; - runnableUi = new Runnable() - { - @Override - public void run() - { - searchAdapter = new SearchAdapter(inflater, searchResult, seaListView, searchAdapterListener, htmlTagHandlerUtil); - seaListView.setAdapter(searchAdapter); - rootLayout.findViewById(R.id.sea_noweb).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_searching).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_listview).setVisibility(View.VISIBLE); - } + runnableUi = () -> { + searchAdapter = new SearchAdapter(inflater, searchResult, seaListView, searchAdapterListener, htmlTagHandlerUtil); + seaListView.setAdapter(searchAdapter); + rootLayout.findViewById(R.id.sea_noweb).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_searching).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_listview).setVisibility(View.VISIBLE); }; - runnableNoresult = new Runnable() - { - @Override - public void run() - { - rootLayout.findViewById(R.id.sea_noweb).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_searching).setVisibility(View.GONE); - rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.VISIBLE); - rootLayout.findViewById(R.id.sea_listview).setVisibility(View.GONE); - } + runnableNoresult = () -> { + rootLayout.findViewById(R.id.sea_noweb).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_searching).setVisibility(View.GONE); + rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.VISIBLE); + rootLayout.findViewById(R.id.sea_listview).setVisibility(View.GONE); }; - runnableNomore = new Runnable() - { - @Override - public void run() - { - ((TextView) loadingView.findViewById(R.id.wid_load_text)).setText(" 没有更多了..."); - } - }; + runnableNomore = () -> ((TextView) loadingView.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_data)); - runnableAddlist = new Runnable() - { - @Override - public void run() - { - searchAdapter.notifyDataSetChanged(); - } - }; + runnableAddlist = () -> searchAdapter.notifyDataSetChanged(); - loadingView.findViewById(R.id.wid_load_button).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - ((TextView) loadingView.findViewById(R.id.wid_load_text)).setText(" 加载中. . ."); - loadingView.findViewById(R.id.wid_load_button).setVisibility(View.GONE); - getMoreSearch(); - } + loadingView.findViewById(R.id.wid_load_button).setOnClickListener(v -> { + ((TextView) loadingView.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_data_loading)); + loadingView.findViewById(R.id.wid_load_button).setVisibility(View.GONE); + getMoreSearch(); }); - inButton.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) + inButton.setOnClickListener(v -> { + try { - try - { - Intent voiceInputIntent = new Intent("com.mobvoi.ticwear.action.SPEECH"); - voiceInputIntent.putExtra("start_mode", "start_mode_with_voice_input"); - startActivityForResult(voiceInputIntent, 0); - } - catch (Exception e) - { - Toast.makeText(ctx, "抱歉,该手表不支持语音输入", Toast.LENGTH_SHORT).show(); - } + Intent voiceInputIntent = new Intent("com.mobvoi.ticwear.action.SPEECH"); + voiceInputIntent.putExtra("start_mode", "start_mode_with_voice_input"); + startActivityForResult(voiceInputIntent, 0); } - }); - - seaButton.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) + catch (Exception e) { - getSearch(); + Toast.makeText(ctx, getString(R.string.main_tip_voice_input), Toast.LENGTH_SHORT).show(); } }); + seaButton.setOnClickListener(v -> getSearch()); + seaListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override @@ -236,24 +196,21 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); - new Thread(new Runnable() - { - @Override - public void run() + seaListView.setOnTouchListener(new ListViewTouchListener(seaListView, titleViewListener, listViewScrollListener)); + + new Thread(() -> { + try { - try - { - //获取搜索关键词 - hotWordArray = searchApi.getHotWord(); - if(hotWordArray != null && hotWordArray.length != 0) - handler.post(runnableHotWord); - else handler.post(runnableHotWordErr); - } - catch (IOException e) - { - e.printStackTrace(); - handler.post(runnableHotWordErr); - } + //获取搜索关键词 + hotWordArray = searchApi.getHotWord(); + if(hotWordArray != null && hotWordArray.length != 0) + handler.post(runnableHotWord); + else handler.post(runnableHotWordErr); + } + catch (IOException e) + { + e.printStackTrace(); + handler.post(runnableHotWordErr); } }).start(); @@ -262,9 +219,9 @@ public void run() return rootLayout; } - private class HotWordAdapter extends ArrayAdapter + private class HotWordAdapter extends ArrayAdapter { - HotWordAdapter(Context context, int resource, Object[] objects) + HotWordAdapter(Context context, int resource, String[] objects) { super(context, resource, objects); } @@ -286,7 +243,6 @@ public View getView(int position, View convertView, ViewGroup parent) return convertView; } - //MyListener类继承OnClickListener,用来监听每个Item的点击事件 private class MyListener implements View.OnClickListener { @Override @@ -298,7 +254,7 @@ public void onClick(View v) } } - void getSearch() + private void getSearch() { InputMethodManager inputMethodManager = (InputMethodManager) ctx.getSystemService(AppCompatActivity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(seaEdittext.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); @@ -314,59 +270,95 @@ void getSearch() rootLayout.findViewById(R.id.sea_searching).setVisibility(View.VISIBLE); rootLayout.findViewById(R.id.sea_nonthing).setVisibility(View.GONE); rootLayout.findViewById(R.id.sea_listview).setVisibility(View.GONE); - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + searchResult = searchApi.getSearchResult(); + if(searchResult != null && searchResult.size() != 0) + handler.post(runnableUi); + else handler.post(runnableNoresult); + isLoading = false; + } + catch (IOException e) + { + e.printStackTrace(); + handler.post(runnableNoweb); + } + }).start(); + } + + private void getMoreSearch() + { + new Thread(() -> { + try + { + ArrayList arrayList = searchApi.getSearchResult(); + if(arrayList.size() != 0) { - searchResult = searchApi.getSearchResult(); - if(searchResult != null && searchResult.size() != 0) - handler.post(runnableUi); - else handler.post(runnableNoresult); + searchResult.addAll(arrayList); isLoading = false; + handler.post(runnableAddlist); } - catch (IOException e) + else { - e.printStackTrace(); - handler.post(runnableNoweb); + handler.post(runnableNomore); } } + catch (IOException e) + { + handler.post(runnableNoWebH); + e.printStackTrace(); + } }).start(); } - void getMoreSearch() + private void hideSearchBox() { - new Thread(new Runnable() + if(!isHide) { - @Override - public void run() + searchBoxAnimator = ObjectAnimator.ofFloat(searchBox, "alpha", 0); + searchBoxAnimator.setDuration(200); + searchBoxAnimator.setInterpolator(new AccelerateInterpolator()); + searchBoxAnimator.addListener(new AnimatorListenerAdapter() { - try + boolean isCancel; + + @Override + public void onAnimationCancel(Animator animation) { - ArrayList arrayList = searchApi.getSearchResult(); - if(arrayList.size() != 0) - { - searchResult.addAll(arrayList); - isLoading = false; - handler.post(runnableAddlist); - } - else - { - handler.post(runnableNomore); - } + isCancel = true; } - catch (IOException e) + + @Override + public void onAnimationEnd(Animator animation) { - handler.post(runnableNoWebH); - e.printStackTrace(); + if(isCancel) + isCancel = false; + else + searchBox.setVisibility(View.GONE); } - } - }).start(); + }); + searchBoxAnimator.start(); + isHide = true; + } + } + + private void showSearchBox() + { + if(isHide) + { + searchBox.setVisibility(View.VISIBLE); + if(searchBoxAnimator.isRunning()) + searchBoxAnimator.cancel(); + searchBoxAnimator = ObjectAnimator.ofFloat(searchBox, "alpha", 1); + searchBoxAnimator.setDuration(200); + searchBoxAnimator.setInterpolator(new DecelerateInterpolator()); + searchBoxAnimator.start(); + isHide = false; + } } - void onViewClick(int id, int position) + private void onViewClick(int id, int position) { SearchModel.SearchBaseModel searchModel = searchResult.get(position); if(searchModel.getSearchMode() == 0) @@ -404,4 +396,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) } } } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/SettingFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/SettingFragment.java index d5a8d7b..85fc502 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/SettingFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/SettingFragment.java @@ -1,12 +1,12 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ListView; import android.widget.TextView; @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Arrays; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.ui.AboutActivity; @@ -27,6 +28,8 @@ import cn.luern0313.wristbilibili.ui.TextActivity; import cn.luern0313.wristbilibili.ui.ThemeActivity; import cn.luern0313.wristbilibili.ui.VideoActivity; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; /** * Created by liupe on 2018/11/15. @@ -40,94 +43,112 @@ public class SettingFragment extends Fragment Context ctx; View rootLayout; - private ListView setList; + private ListView uiListView; + private TitleView.TitleViewListener titleViewListener; + + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ctx = this.getActivity(); rootLayout = inflater.inflate(R.layout.fragment_setting, container, false); - setList = rootLayout.findViewById(R.id.set_listview); + uiListView = rootLayout.findViewById(R.id.set_listview); final ArrayList list = new ArrayList(Arrays.asList("注销", "关注作者b站账号", "主题设置", "小尾巴设置", "发动态炫耀一下", "查看介绍视频", "支持作者", "关于开源", "更新日志", "联系作者", "关于")); mAdapter mAdapter = new mAdapter(inflater, list); - setList.setAdapter(mAdapter); + uiListView.setAdapter(mAdapter); - setList.setOnItemClickListener(new AdapterView.OnItemClickListener() - { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) + uiListView.setOnItemClickListener((parent, view, position, id) -> { + switch (list.get(position)) { - if(list.get(position).equals("注销")) + case "注销": { Intent intent = new Intent(ctx, LogsoffActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("关注作者b站账号")) + case "关注作者b站账号": { Intent intent = new Intent(ctx, FollowmeActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("主题设置")) + case "主题设置": { Intent intent = new Intent(ctx, ThemeActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("小尾巴设置")) + case "小尾巴设置": { Intent intent = new Intent(ctx, TailActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("发动态炫耀一下")) + case "发动态炫耀一下": { Intent intent = new Intent(ctx, SueActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("查看介绍视频")) - { + case "查看介绍视频": startActivity(VideoActivity.getActivityIntent(ctx, "37132444", "")); - } - else if(list.get(position).equals("支持作者")) + break; + case "支持作者": { Intent intent = new Intent(ctx, SupportActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("关于开源")) + case "关于开源": { Intent intent = new Intent(ctx, OpensourceActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("更新日志")) + case "更新日志": { Intent intent = new Intent(ctx, TextActivity.class); intent.putExtra("title", "更新日志"); intent.putExtra("text", getString(R.string.update)); startActivity(intent); + break; } - else if(list.get(position).equals("联系作者")) + case "联系作者": { Intent intent = new Intent(ctx, JoinqqActivity.class); startActivity(intent); + break; } - else if(list.get(position).equals("关于")) + case "关于": { Intent intent = new Intent(ctx, AboutActivity.class); startActivity(intent); + break; } - else - { + default: throw new AssertionError(); - } } }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + return rootLayout; } - class mAdapter extends BaseAdapter + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } + + private static class mAdapter extends BaseAdapter { - private LayoutInflater mInflater; - private ArrayList setList; + private final LayoutInflater mInflater; + private final ArrayList setList; TextView text; public mAdapter(LayoutInflater inflater, ArrayList setList) diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoDetailFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoDetailFragment.java index f2beec2..c405926 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoDetailFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoDetailFragment.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Random; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -38,6 +39,8 @@ import cn.luern0313.wristbilibili.ui.VideoActivity; import cn.luern0313.wristbilibili.util.ColorUtil; import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; public class VideoDetailFragment extends Fragment implements View.OnClickListener { @@ -46,6 +49,7 @@ public class VideoDetailFragment extends Fragment implements View.OnClickListene private Context ctx; private View rootLayout; private VideoDetailFragmentListener videoDetailFragmentListener; + private TitleView.TitleViewListener titleViewListener; private VideoModel videoModel; @@ -182,6 +186,8 @@ else if(videoModel.getUpOfficial() == 1) } else rootLayout.findViewById(R.id.vd_video_part_layout).setVisibility(View.GONE); + rootLayout.findViewById(R.id.vd_lay).setOnTouchListener(new ListViewTouchListener(rootLayout.findViewById(R.id.vd_lay), titleViewListener)); + rootLayout.findViewById(R.id.vd_like).setOnTouchListener((view, motionEvent) -> { switch (motionEvent.getAction()) { @@ -367,7 +373,7 @@ public void onEventMainThread(VideoModel videoModel) } @Override - public void onAttach(Context context) + public void onAttach(@Nullable Context context) { super.onAttach(context); if(context instanceof VideoDetailFragmentListener) @@ -391,6 +397,9 @@ public void onVideoDetailActivityLoadingFin() { throw new RuntimeException(context.toString() + " must implement VideoDetailFragmentListener"); } + + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; } @Override diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoRecommendFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoRecommendFragment.java index ef8abac..153f563 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoRecommendFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/VideoRecommendFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; @@ -7,11 +8,14 @@ import android.view.ViewGroup; import android.widget.ListView; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.VideoRecommendAdapter; import cn.luern0313.wristbilibili.models.VideoModel; import cn.luern0313.wristbilibili.ui.VideoActivity; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; public class VideoRecommendFragment extends Fragment { @@ -22,6 +26,7 @@ public class VideoRecommendFragment extends Fragment private VideoModel videoModel; private ListView uiListView; + private TitleView.TitleViewListener titleViewListener; public VideoRecommendFragment() {} @@ -44,6 +49,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -53,10 +59,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa uiListView = rootLayout.findViewById(R.id.vd_recommend_listview); uiListView.setEmptyView(rootLayout.findViewById(R.id.vd_recommend_nothing)); uiListView.setOnItemClickListener((parent, view, position, id) -> startActivity(VideoActivity.getActivityIntent(ctx, videoModel.getRecommendList().get(position).recommendVideoAid, ""))); - VideoRecommendAdapter recommendAdapter = new VideoRecommendAdapter(inflater, videoModel.getRecommendList(), uiListView); - uiListView.setAdapter(recommendAdapter); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + + if(videoModel.getRecommendList() != null) + { + VideoRecommendAdapter recommendAdapter = new VideoRecommendAdapter(inflater, videoModel.getRecommendList(), uiListView); + uiListView.setAdapter(recommendAdapter); + } + else + rootLayout.findViewById(R.id.vd_recommend_nothing).setVisibility(View.VISIBLE); return rootLayout; } + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/WatchlaterFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/WatchlaterFragment.java index 415e3cc..0bafc73 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/WatchlaterFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/WatchlaterFragment.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.fragment; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Color; import android.os.Bundle; @@ -12,6 +13,7 @@ import java.io.IOException; import java.util.ArrayList; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.ListVideoAdapter; @@ -19,7 +21,10 @@ import cn.luern0313.wristbilibili.models.ListVideoModel; import cn.luern0313.wristbilibili.ui.VideoActivity; import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; /** @@ -35,6 +40,7 @@ public class WatchlaterFragment extends Fragment private ListVideoAdapter.ListVideoAdapterListener listVideoAdapterListener; private WaveSwipeRefreshLayout waveSwipeRefreshLayout; private WatchLaterApi watchLaterApi; + private TitleView.TitleViewListener titleViewListener; public static boolean isLogin; @@ -43,6 +49,7 @@ public class WatchlaterFragment extends Fragment private ArrayList watchLaterVideoArrayList; + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -53,6 +60,7 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun waveSwipeRefreshLayout = rootLayout.findViewById(R.id.wl_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { if(isLogin) { @@ -101,6 +109,7 @@ public void onListVideoAdapterLongClick(int viewId, final int position) }; wlListView.setOnItemClickListener((parent, view, position, id) -> startActivity(VideoActivity.getActivityIntent(ctx, watchLaterVideoArrayList.get(position).getAid(), ""))); + wlListView.setOnTouchListener(new ListViewTouchListener(wlListView, titleViewListener)); isLogin = SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies); if(isLogin) @@ -145,4 +154,12 @@ private void getWatchLater() } }).start(); } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserBangumiFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserBangumiFragment.java index 05caa44..0324c85 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserBangumiFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserBangumiFragment.java @@ -76,6 +76,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -83,14 +84,7 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun rootLayout = inflater.inflate(R.layout.fragment_user_bangumi, container, false); userApi = new UserApi(mid); - listBangumiAdapterListener = new ListBangumiAdapter.ListBangumiAdapterListener() - { - @Override - public void onListBangumiAdapterClick(int viewId, int position) - { - onViewClick(viewId, position); - } - }; + listBangumiAdapterListener = this::onViewClick; layoutLoading = inflater.inflate(R.layout.widget_loading, null, false); uiListView = rootLayout.findViewById(R.id.user_bangumi_listview); @@ -100,78 +94,39 @@ public void onListBangumiAdapterClick(int viewId, int position) uiListView.addFooterView(layoutLoading); - runnableUi = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.GONE); - uiNothing.setVisibility(View.GONE); - listBangumiAdapter = new ListBangumiAdapter(inflater, uiListView, listBangumiModelArrayList, listBangumiAdapterListener); - uiListView.setAdapter(listBangumiAdapter); - } + runnableUi = () -> { + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.GONE); + uiNothing.setVisibility(View.GONE); + listBangumiAdapter = new ListBangumiAdapter(inflater, uiListView, listBangumiModelArrayList, listBangumiAdapterListener); + uiListView.setAdapter(listBangumiAdapter); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.VISIBLE); - uiNothing.setVisibility(View.GONE); - } + runnableNoWeb = () -> { + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.VISIBLE); + uiNothing.setVisibility(View.GONE); }; - runnableNothing = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.GONE); - uiNothing.setVisibility(View.VISIBLE); - } + runnableNothing = () -> { + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.GONE); + uiNothing.setVisibility(View.VISIBLE); }; - runnableMore = new Runnable() - { - @Override - public void run() - { - listBangumiAdapter.notifyDataSetChanged(); - } - }; + runnableMore = () -> listBangumiAdapter.notifyDataSetChanged(); - runnableMoreNoWeb = new Runnable() - { - @Override - public void run() - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText("好像没有网络...\n检查下网络?"); - layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); - } + runnableMoreNoWeb = () -> { + ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText(getString(R.string.main_tip_no_more_web)); + layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); }; - runnableMoreNothing = new Runnable() - { - @Override - public void run() - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(" 没有更多了..."); - } - }; + runnableMoreNothing = () -> ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(getString(R.string.main_tip_no_more_data)); - layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText(" 加载中..."); - layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); - getMoreBangumi(); - } + layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(v -> { + ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText(getString(R.string.main_tip_no_more_data_loading)); + layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); + getMoreBangumi(); }); uiListView.setOnScrollListener(new AbsListView.OnScrollListener() @@ -192,28 +147,25 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); - new Thread(new Runnable() - { - @Override - public void run() + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + + new Thread(() -> { + try { - try - { - ArrayList b = userApi.getUserBangumi(page, mode); - isLoading = false; - if(b != null && b.size() != 0) - { - listBangumiModelArrayList.addAll(b); - handler.post(runnableUi); - } - else - handler.post(runnableNothing); - } - catch (IOException e) + ArrayList b = userApi.getUserBangumi(page, mode); + isLoading = false; + if(b != null && b.size() != 0) { - e.printStackTrace(); - handler.post(runnableNoWeb); + listBangumiModelArrayList.addAll(b); + handler.post(runnableUi); } + else + handler.post(runnableNothing); + } + catch (IOException e) + { + e.printStackTrace(); + handler.post(runnableNoWeb); } }).start(); @@ -222,29 +174,24 @@ public void run() private void getMoreBangumi() { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + page++; + ArrayList b = userApi.getUserBangumi(page, mode); + isLoading = false; + if(b != null && b.size() != 0) { - page++; - ArrayList b = userApi.getUserBangumi(page, mode); - isLoading = false; - if(b != null && b.size() != 0) - { - listBangumiModelArrayList.addAll(b); - handler.post(runnableMore); - } - else - handler.post(runnableMoreNothing); - } - catch (IOException e) - { - e.printStackTrace(); - handler.post(runnableMoreNoWeb); + listBangumiModelArrayList.addAll(b); + handler.post(runnableMore); } + else + handler.post(runnableMoreNothing); + } + catch (IOException e) + { + e.printStackTrace(); + handler.post(runnableMoreNoWeb); } }).start(); } @@ -258,4 +205,13 @@ private void onViewClick(int viewId, int position) startActivity(intent); } } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserDetailFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserDetailFragment.java index 3b02273..bdd3ebd 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserDetailFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserDetailFragment.java @@ -61,6 +61,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -82,6 +83,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa startActivity(intent); }); + ((ScrollView) rootLayout.findViewById(R.id.user_detail_lay)).setOnTouchListener(new ListViewTouchListener(rootLayout.findViewById(R.id.user_detail_lay), titleViewListener)); + rootLayout.findViewById(R.id.user_detail_video).setOnClickListener(this); rootLayout.findViewById(R.id.user_detail_favor).setOnClickListener(this); rootLayout.findViewById(R.id.user_detail_bangumi).setOnClickListener(this); @@ -168,13 +171,12 @@ public void onAttach(Context context) { super.onAttach(context); if(context instanceof UserDetailFragmentListener) - { userDetailFragmentListener = (UserDetailFragmentListener) context; - } else - { throw new RuntimeException(context.toString() + " must implement UserDetailFragmentListener"); - } + + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; } @Override diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserListPeopleFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserListPeopleFragment.java index 2a377f8..d0ddc6c 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserListPeopleFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserListPeopleFragment.java @@ -142,6 +142,8 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + new Thread(() -> { try { @@ -198,4 +200,12 @@ private void getMoreListPeople() } }).start(); } + + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserVideoFragment.java b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserVideoFragment.java index ef7f049..4455d5d 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserVideoFragment.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/fragment/user/UserVideoFragment.java @@ -73,6 +73,7 @@ public void onCreate(Bundle savedInstanceState) } } + @SuppressLint("ClickableViewAccessibility") @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -85,7 +86,7 @@ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bun @Override public void onListVideoAdapterClick(int viewId, int position) { - Intent intent = VideoActivity.getActivityIntent(ctx, "", listVideoModelArrayList.get(position).getVideoBvid()); + Intent intent = VideoActivity.getActivityIntent(ctx, "", listVideoModelArrayList.get(position).getBvid()); startActivity(intent); } @@ -102,78 +103,39 @@ public void onListVideoAdapterLongClick(int viewId, int position) uiNoWeb = rootLayout.findViewById(R.id.user_video_noweb); uiNothing = rootLayout.findViewById(R.id.user_video_nonthing); - runnableUi = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.GONE); - uiNothing.setVisibility(View.GONE); - listVideoAdapter = new ListVideoAdapter(inflater, listVideoModelArrayList, uiListView, listVideoAdapterListener); - uiListView.setAdapter(listVideoAdapter); - } + runnableUi = () -> { + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.GONE); + uiNothing.setVisibility(View.GONE); + listVideoAdapter = new ListVideoAdapter(inflater, listVideoModelArrayList, false, uiListView, listVideoAdapterListener); + uiListView.setAdapter(listVideoAdapter); }; - runnableNoWeb = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.VISIBLE); - uiNothing.setVisibility(View.GONE); - } + runnableNoWeb = () -> { + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.VISIBLE); + uiNothing.setVisibility(View.GONE); }; - runnableNothing = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.GONE); - uiNothing.setVisibility(View.VISIBLE); - } + runnableNothing = () -> { + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.GONE); + uiNothing.setVisibility(View.VISIBLE); }; - runnableMore = new Runnable() - { - @Override - public void run() - { - listVideoAdapter.notifyDataSetChanged(); - } - }; + runnableMore = () -> listVideoAdapter.notifyDataSetChanged(); - runnableMoreNoWeb = new Runnable() - { - @Override - public void run() - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText("好像没有网络...\n检查下网络?"); - layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); - } + runnableMoreNoWeb = () -> { + ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText("好像没有网络...\n检查下网络?"); + layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.VISIBLE); }; - runnableMoreNothing = new Runnable() - { - @Override - public void run() - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(" 没有更多了..."); - } - }; + runnableMoreNothing = () -> ((TextView) layoutLoading.findViewById(R.id.wid_load_text)).setText(" 没有更多了..."); - layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText(" 加载中..."); - layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); - getMoreVideo(); - } + layoutLoading.findViewById(R.id.wid_load_button).setOnClickListener(v -> { + ((TextView) layoutLoading.findViewById(R.id.wid_load_button)).setText(" 加载中..."); + layoutLoading.findViewById(R.id.wid_load_button).setVisibility(View.GONE); + getMoreVideo(); }); uiListView.setOnScrollListener(new AbsListView.OnScrollListener() @@ -194,33 +156,30 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); - new Thread(new Runnable() - { - @Override - public void run() + uiListView.setOnTouchListener(new ListViewTouchListener(uiListView, titleViewListener)); + + new Thread(() -> { + try { - try - { - ArrayList v = userApi.getUserVideo(page); - isLoading = false; - if(v != null && v.size() != 0) - { - listVideoModelArrayList.addAll(v); - handler.post(runnableUi); - } - else - handler.post(runnableNothing); - } - catch (IOException e) + ArrayList v = userApi.getUserVideo(page); + isLoading = false; + if(v != null && v.size() != 0) { - e.printStackTrace(); - handler.post(runnableNoWeb); + listVideoModelArrayList.addAll(v); + handler.post(runnableUi); } - catch (NullPointerException e) - { - e.printStackTrace(); + else handler.post(runnableNothing); - } + } + catch (IOException e) + { + e.printStackTrace(); + handler.post(runnableNoWeb); + } + catch (NullPointerException e) + { + e.printStackTrace(); + handler.post(runnableNothing); } }).start(); @@ -229,31 +188,33 @@ public void run() private void getMoreVideo() { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - page++; - ArrayList v = userApi.getUserVideo(page); - isLoading = false; - if(v != null && v.size() != 0) - { - listVideoModelArrayList.addAll(v); - handler.post(runnableMore); - } - else - handler.post(runnableMoreNothing); - } - catch (IOException | NullPointerException e) + page++; + ArrayList v = userApi.getUserVideo(page); + isLoading = false; + if(v != null && v.size() != 0) { - e.printStackTrace(); - handler.post(runnableMoreNoWeb); + listVideoModelArrayList.addAll(v); + handler.post(runnableMore); } + else + handler.post(runnableMoreNothing); + } + catch (IOException | NullPointerException e) + { + e.printStackTrace(); + handler.post(runnableMoreNoWeb); } }).start(); } + @Override + public void onAttach(@NonNull Context context) + { + super.onAttach(context); + if(context instanceof TitleView.TitleViewListener) + titleViewListener = (TitleView.TitleViewListener) context; + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/AboutActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/AboutActivity.java index 0d4563c..2b2aa08 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/AboutActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/AboutActivity.java @@ -1,10 +1,10 @@ package cn.luern0313.wristbilibili.ui; -import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.widget.ImageView; +import android.widget.TextView; import cn.luern0313.wristbilibili.R; @@ -20,6 +20,8 @@ protected void onCreate(Bundle savedInstanceState) setContentView(R.layout.activity_about); ctx = this; + + ((TextView) findViewById(R.id.about_app_name)).setText(String.format(getString(R.string.about_app_name), getString(R.string.app_name), "3.1")); ui33 = findViewById(R.id.about_33); ui33.setImageResource(R.drawable.anim_33); AnimationDrawable loadingImgAnim = (AnimationDrawable) ui33.getDrawable(); diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/ArticleActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/ArticleActivity.java index 43bc3cf..c0ad58f 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/ArticleActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/ArticleActivity.java @@ -13,7 +13,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Toast; -import android.widget.ViewFlipper; import org.greenrobot.eventbus.EventBus; @@ -30,9 +29,10 @@ import cn.luern0313.wristbilibili.fragment.ReplyFragment; import cn.luern0313.wristbilibili.models.article.ArticleModel; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; -public class ArticleActivity extends BaseActivity implements ArticleDetailFragment.ArticleDetailFragmentListener +public class ArticleActivity extends BaseActivity implements ArticleDetailFragment.ArticleDetailFragmentListener, TitleView.TitleViewListener { Context ctx; Intent intent; @@ -44,7 +44,7 @@ public class ArticleActivity extends BaseActivity implements ArticleDetailFragme PagerAdapter pagerAdapter; ArticleDetailActivityListener articleDetailActivityListener; - ViewFlipper uiTitle; + TitleView uiTitleView; ViewPager uiViewPager; ImageView uiLoadingImg; LinearLayout uiLoading; @@ -75,7 +75,7 @@ protected void onCreate(Bundle savedInstanceState) inflater = getLayoutInflater(); layoutReplyLoading = inflater.inflate(R.layout.widget_loading, null); - uiTitle = findViewById(R.id.art_title_title); + uiTitleView = findViewById(R.id.art_title); uiViewPager = findViewById(R.id.art_viewpager); uiViewPager.setOffscreenPageLimit(1); uiLoadingImg = findViewById(R.id.art_loading_img); @@ -90,67 +90,45 @@ protected void onCreate(Bundle savedInstanceState) loadingImgAnim.start(); uiLoading.setVisibility(View.VISIBLE); - runnableUi = new Runnable() - { - @Override - public void run() + runnableUi = () -> { + try { - try - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.GONE); - uiViewPager.setAdapter(pagerAdapter); - } - catch (Exception e) - { - e.printStackTrace(); - handler.post(runnableNodata); - } + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.GONE); + uiViewPager.setAdapter(pagerAdapter); } - }; - - runnableNoWeb = new Runnable() - { - @Override - public void run() + catch (Exception e) { - try - { - uiLoading.setVisibility(View.GONE); - uiNoWeb.setVisibility(View.VISIBLE); - } - catch (Exception e) - { - e.printStackTrace(); - } + e.printStackTrace(); + handler.post(runnableNodata); } }; - runnableNodata = new Runnable() - { - @Override - public void run() + runnableNoWeb = () -> { + try { - try - { - ArticleActivity.this.findViewById(R.id.art_novideo).setVisibility(View.VISIBLE); - } - catch (Exception e) - { - e.printStackTrace(); - } + uiLoading.setVisibility(View.GONE); + uiNoWeb.setVisibility(View.VISIBLE); + } + catch (Exception e) + { + e.printStackTrace(); } }; - runnableLoadingFin = new Runnable() - { - @Override - public void run() + runnableNodata = () -> { + try { - ArticleActivity.this.findViewById(R.id.article_article_loading).setVisibility(View.GONE); + ArticleActivity.this.findViewById(R.id.art_novideo).setVisibility(View.VISIBLE); + } + catch (Exception e) + { + e.printStackTrace(); } }; + runnableLoadingFin = () -> ArticleActivity.this.findViewById(R.id.article_article_loading).setVisibility(View.GONE); + pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override @@ -182,46 +160,38 @@ public void onPageScrollStateChanged(int state) {} @Override public void onPageSelected(int position) { - while(uiTitle.getDisplayedChild() != position) + while(uiTitleView.getDisplayedChild() != position) { - if(uiTitle.getDisplayedChild() < position) + uiTitleView.show(); + if(uiTitleView.getDisplayedChild() < position) { - uiTitle.setInAnimation(ctx, R.anim.slide_in_right); - uiTitle.setOutAnimation(ctx, R.anim.slide_out_left); - uiTitle.showNext(); + uiTitleView.setInAnimation(ctx, R.anim.slide_in_right); + uiTitleView.setOutAnimation(ctx, R.anim.slide_out_left); + uiTitleView.showNext(); } else { - uiTitle.setInAnimation(ctx, android.R.anim.slide_in_left); - uiTitle.setOutAnimation(ctx, android.R.anim.slide_out_right); - uiTitle.showPrevious(); + uiTitleView.setInAnimation(ctx, android.R.anim.slide_in_left); + uiTitleView.setOutAnimation(ctx, android.R.anim.slide_out_right); + uiTitleView.showPrevious(); } } } }); - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - articleModel = articleApi.getArticleModel(); - if(articleModel != null) - { - handler.post(runnableUi); - } - else - { - handler.post(runnableNodata); - } - } - catch (IOException e) - { - e.printStackTrace(); - handler.post(runnableNoWeb); - } + articleModel = articleApi.getArticleModel(); + if(articleModel != null) + handler.post(runnableUi); + else + handler.post(runnableNodata); + } + catch (IOException e) + { + e.printStackTrace(); + handler.post(runnableNoWeb); } }).start(); } @@ -242,159 +212,144 @@ public void onArticleDetailFragmentViewClick(int viewId) } else if(viewId == R.id.article_article_bt_like) { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + if(articleModel.isUserLike()) { - if(articleModel.isUserLike()) + String result = articleApi.likeArticle(2); + if(result.equals("")) { - String result = articleApi.likeArticle(2); - if(result.equals("")) - { - articleModel.setLike(articleModel.getLike() - 1); - articleModel.setUserLike(false); - Looper.prepare(); - Toast.makeText(ctx, "已取消喜欢...", Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } + articleModel.setLike(articleModel.getLike() - 1); + articleModel.setUserLike(false); + Looper.prepare(); + Toast.makeText(ctx, "已取消喜欢...", Toast.LENGTH_SHORT).show(); } else { - String result = articleApi.likeArticle(1); - if(result.equals("")) - { - articleModel.setLike(articleModel.getLike() + 1); - articleModel.setUserLike(true); - Looper.prepare(); - Toast.makeText(ctx, "已喜欢专栏!", Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } + Looper.prepare(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); } } - catch (IOException e) - { - e.printStackTrace(); - Looper.prepare(); - Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); - } - finally + else { - EventBus.getDefault().post(articleModel); - Looper.loop(); + String result = articleApi.likeArticle(1); + if(result.equals("")) + { + articleModel.setLike(articleModel.getLike() + 1); + articleModel.setUserLike(true); + Looper.prepare(); + Toast.makeText(ctx, "已喜欢专栏!", Toast.LENGTH_SHORT).show(); + } + else + { + Looper.prepare(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); + } } } + catch (IOException e) + { + e.printStackTrace(); + Looper.prepare(); + Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + } + finally + { + EventBus.getDefault().post(articleModel); + Looper.loop(); + } }).start(); } else if(viewId == R.id.article_article_bt_coin) { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + if(articleModel.getUserCoin() == 0) { - if(articleModel.getUserCoin() == 0) + String result = articleApi.coinArticle(); + if(result.equals("")) { - String result = articleApi.coinArticle(); - if(result.equals("")) - { - articleModel.setCoin(articleModel.getCoin() + 1); - articleModel.setUserCoin(1); - Looper.prepare(); - Toast.makeText(ctx, "你投了一个硬币!", Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } + articleModel.setCoin(articleModel.getCoin() + 1); + articleModel.setUserCoin(1); + Looper.prepare(); + Toast.makeText(ctx, "你投了一个硬币!", Toast.LENGTH_SHORT).show(); } else { Looper.prepare(); - Toast.makeText(ctx, "投币失败,超过投币上限!", Toast.LENGTH_SHORT).show(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); } } - catch (IOException e) + else { - e.printStackTrace(); Looper.prepare(); - Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); - } - finally - { - EventBus.getDefault().post(articleModel); - Looper.loop(); + Toast.makeText(ctx, "投币失败,超过投币上限!", Toast.LENGTH_SHORT).show(); } } + catch (IOException e) + { + e.printStackTrace(); + Looper.prepare(); + Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + } + finally + { + EventBus.getDefault().post(articleModel); + Looper.loop(); + } }).start(); } else if(viewId == R.id.article_article_bt_fav) { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + if(articleModel.isUserFavor()) { - if(articleModel.isUserFavor()) + String result = articleApi.favArticle(2); + if(result.equals("")) { - String result = articleApi.favArticle(2); - if(result.equals("")) - { - articleModel.setFavor(articleModel.getFavor() - 1); - articleModel.setUserFavor(false); - Looper.prepare(); - Toast.makeText(ctx, "已取消收藏...", Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } + articleModel.setFavor(articleModel.getFavor() - 1); + articleModel.setUserFavor(false); + Looper.prepare(); + Toast.makeText(ctx, "已取消收藏...", Toast.LENGTH_SHORT).show(); } else { - String result = articleApi.favArticle(1); - if(result.equals("")) - { - articleModel.setFavor(articleModel.getFavor() + 1); - articleModel.setUserFavor(true); - Looper.prepare(); - Toast.makeText(ctx, "已收藏专栏!", Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } + Looper.prepare(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); } } - catch (IOException e) - { - e.printStackTrace(); - Looper.prepare(); - Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); - } - finally + else { - EventBus.getDefault().post(articleModel); - Looper.loop(); + String result = articleApi.favArticle(1); + if(result.equals("")) + { + articleModel.setFavor(articleModel.getFavor() + 1); + articleModel.setUserFavor(true); + Looper.prepare(); + Toast.makeText(ctx, "已收藏专栏!", Toast.LENGTH_SHORT).show(); + } + else + { + Looper.prepare(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); + } } } + catch (IOException e) + { + e.printStackTrace(); + Looper.prepare(); + Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + } + finally + { + EventBus.getDefault().post(articleModel); + Looper.loop(); + } }).start(); } else if(viewId == R.id.article_article_bt_share) @@ -408,38 +363,33 @@ else if(viewId == R.id.article_article_bt_share) } else if(viewId == R.id.article_card_follow) { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + String result = articleApi.followUp(); + if(result.equals("")) { - String result = articleApi.followUp(); - if(result.equals("")) - { - articleModel.setUpFansNum(articleModel.getUpFansNum() + 1); - Looper.prepare(); - Toast.makeText(ctx, "已关注UP主", Toast.LENGTH_SHORT).show(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - } - } - catch (IOException e) - { - e.printStackTrace(); + articleModel.setUpFansNum(articleModel.getUpFansNum() + 1); Looper.prepare(); - Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + Toast.makeText(ctx, "已关注UP主", Toast.LENGTH_SHORT).show(); } - finally + else { - EventBus.getDefault().post(articleModel); - Looper.loop(); + Looper.prepare(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); } } + catch (IOException e) + { + e.printStackTrace(); + Looper.prepare(); + Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + } + finally + { + EventBus.getDefault().post(articleModel); + Looper.loop(); + } }).start(); } } @@ -451,39 +401,46 @@ protected void onActivityResult(final int requestCode, int resultCode, final Int if(resultCode != 0) return; if(requestCode == RESULT_DETAIL_SHARE) { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + String result = articleApi.shareArticle(data.getStringExtra("text")); + if(result.equals("")) { - String result = articleApi.shareArticle(data.getStringExtra("text")); - if(result.equals("")) - { - Looper.prepare(); - Toast.makeText(ctx, "发送成功!", Toast.LENGTH_SHORT).show(); - Looper.loop(); - } - else - { - Looper.prepare(); - Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); - Looper.loop(); - } + Looper.prepare(); + Toast.makeText(ctx, "发送成功!", Toast.LENGTH_SHORT).show(); + Looper.loop(); } - catch (IOException e) + else { - e.printStackTrace(); Looper.prepare(); - Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + Toast.makeText(ctx, result, Toast.LENGTH_SHORT).show(); Looper.loop(); } } + catch (IOException e) + { + e.printStackTrace(); + Looper.prepare(); + Toast.makeText(ctx, ArticleActivity.this.getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); + Looper.loop(); + } }).start(); } } + @Override + public boolean hideTitle() + { + return uiTitleView.hide(); + } + + @Override + public boolean showTitle() + { + return uiTitleView.show(); + } + public interface ArticleDetailActivityListener { void onArticleDetailActivityLoadingStart(); diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/BangumiActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/BangumiActivity.java index 219508b..a1597d4 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/BangumiActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/BangumiActivity.java @@ -13,9 +13,7 @@ import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.TextView; import android.widget.Toast; -import android.widget.ViewFlipper; import org.greenrobot.eventbus.EventBus; @@ -32,12 +30,13 @@ import cn.luern0313.wristbilibili.fragment.BangumiDetailFragment; import cn.luern0313.wristbilibili.fragment.BangumiRecommendFragment; import cn.luern0313.wristbilibili.fragment.ReplyFragment; -import cn.luern0313.wristbilibili.models.ListBangumiModel; import cn.luern0313.wristbilibili.models.BangumiModel; +import cn.luern0313.wristbilibili.models.ListBangumiModel; import cn.luern0313.wristbilibili.service.DownloadService; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; -public class BangumiActivity extends BaseActivity implements BangumiDetailFragment.BangumiDetailFragmentListener +public class BangumiActivity extends BaseActivity implements BangumiDetailFragment.BangumiDetailFragmentListener, TitleView.TitleViewListener { Context ctx; Intent intent; @@ -51,7 +50,7 @@ public class BangumiActivity extends BaseActivity implements BangumiDetailFragme FragmentPagerAdapter pagerAdapter; ArrayList bangumiRecommendModelArrayList; - ViewFlipper uiTitle; + TitleView uiTitleView; ViewPager uiViewPager; ImageView uiLoadingImg; LinearLayout uiLoading; @@ -86,7 +85,7 @@ protected void onCreate(Bundle savedInstanceState) inflater = getLayoutInflater(); - uiTitle = findViewById(R.id.bgm_title_title); + uiTitleView = findViewById(R.id.bgm_title); uiViewPager = findViewById(R.id.bgm_viewpager); uiViewPager.setOffscreenPageLimit(2); uiLoadingImg = findViewById(R.id.bgm_loading_img); @@ -102,8 +101,8 @@ protected void onCreate(Bundle savedInstanceState) uiLoading.setVisibility(View.VISIBLE); runnableUi = () -> { - ((TextView) uiTitle.findViewWithTag("1")).setText(String.format(getString(R.string.bangumi_title_detail), bangumiModel.getTypeName())); - ((TextView) uiTitle.findViewWithTag("2")).setText(String.format(getString(R.string.bangumi_title_reply), bangumiModel.getTypeEp())); + uiTitleView.setTitle(0, String.format(getString(R.string.bangumi_title_detail), bangumiModel.getTypeName())); + uiTitleView.setTitle(1, String.format(getString(R.string.bangumi_title_reply), bangumiModel.getTypeEp())); uiLoading.setVisibility(View.GONE); uiNoWeb.setVisibility(View.GONE); @@ -171,19 +170,20 @@ public void onPageScrollStateChanged(int state) @Override public void onPageSelected(int position) { - while(uiTitle.getDisplayedChild() != position) + while(uiTitleView.getDisplayedChild() != position) { - if(uiTitle.getDisplayedChild() < position) + uiTitleView.show(); + if(uiTitleView.getDisplayedChild() < position) { - uiTitle.setInAnimation(ctx, R.anim.slide_in_right); - uiTitle.setOutAnimation(ctx, R.anim.slide_out_left); - uiTitle.showNext(); + uiTitleView.setInAnimation(ctx, R.anim.slide_in_right); + uiTitleView.setOutAnimation(ctx, R.anim.slide_out_left); + uiTitleView.showNext(); } else { - uiTitle.setInAnimation(ctx, android.R.anim.slide_in_left); - uiTitle.setOutAnimation(ctx, android.R.anim.slide_out_right); - uiTitle.showPrevious(); + uiTitleView.setInAnimation(ctx, android.R.anim.slide_in_left); + uiTitleView.setOutAnimation(ctx, android.R.anim.slide_out_right); + uiTitleView.showPrevious(); } } } @@ -337,6 +337,18 @@ public void onBangumiDetailFragmentReplyUpdate(String epId, int mode, int positi bangumiReplyActivityListener.onBangumiReplyUpdate(bangumiModel.getUserProgressAid(), "1"); } + @Override + public boolean hideTitle() + { + return uiTitleView.hide(); + } + + @Override + public boolean showTitle() + { + return uiTitleView.show(); + } + class BangumiDownloadServiceConnection implements ServiceConnection { @Override diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/CheckreplyActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/CheckreplyActivity.java index f4f8540..f0bc6c6 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/CheckreplyActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/CheckreplyActivity.java @@ -5,14 +5,14 @@ import android.os.Bundle; import android.view.LayoutInflater; -import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.fragment.ReplyFragment; import cn.luern0313.wristbilibili.models.ReplyModel; +import cn.luern0313.wristbilibili.widget.TitleView; -public class CheckreplyActivity extends BaseActivity +public class CheckreplyActivity extends BaseActivity implements TitleView.TitleViewListener { Context ctx; LayoutInflater inflater; @@ -20,6 +20,8 @@ public class CheckreplyActivity extends BaseActivity ReplyModel root; int position; + TitleView titleView; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -31,9 +33,23 @@ protected void onCreate(Bundle savedInstanceState) root = intent.hasExtra("root") ? (ReplyModel) intent.getSerializableExtra("root") : null; position = intent.getIntExtra("position", -1); + titleView = findViewById(R.id.cr_title); + FragmentManager fm = getSupportFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); transaction.replace(R.id.cr_frame, ReplyFragment.newInstance(intent.getStringExtra("oid"), intent.getStringExtra("type"), root, position)); transaction.commit(); } + + @Override + public boolean hideTitle() + { + return titleView.hide(); + } + + @Override + public boolean showTitle() + { + return titleView.show(); + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/DynamicDetailActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/DynamicDetailActivity.java index 2fb1b5c..db0fbb6 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/DynamicDetailActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/DynamicDetailActivity.java @@ -8,7 +8,6 @@ import android.view.View; import android.widget.ImageView; import android.widget.Toast; -import android.widget.ViewFlipper; import org.greenrobot.eventbus.EventBus; @@ -27,15 +26,16 @@ import cn.luern0313.wristbilibili.models.DynamicModel; import cn.luern0313.wristbilibili.util.MyApplication; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; -public class DynamicDetailActivity extends BaseActivity implements DynamicDetailFragment.DynamicDetailFragmentListener +public class DynamicDetailActivity extends BaseActivity implements DynamicDetailFragment.DynamicDetailFragmentListener, TitleView.TitleViewListener { Context ctx; FragmentPagerAdapter pagerAdapter; DynamicApi dynamicApi; DynamicModel.DynamicBaseModel dynamicModel; - ViewFlipper uiTitle; + TitleView uiTitleView; ViewPager uiViewPager; ImageView uiLoading; @@ -49,7 +49,7 @@ protected void onCreate(Bundle savedInstanceState) ctx = MyApplication.getContext(); dynamicApi = new DynamicApi(SharedPreferencesUtil.getString(SharedPreferencesUtil.mid, ""), false); - uiTitle = findViewById(R.id.dynamic_detail_title_title); + uiTitleView = findViewById(R.id.dynamic_detail_title); uiViewPager = findViewById(R.id.dynamic_detail_viewpager); uiLoading = findViewById(R.id.dynamic_detail_loading_img); @@ -110,19 +110,20 @@ public void onPageScrollStateChanged(int state) @Override public void onPageSelected(int position) { - while(uiTitle.getDisplayedChild() != position) + while(uiTitleView.getDisplayedChild() != position) { - if(uiTitle.getDisplayedChild() < position) + uiTitleView.show(); + if(uiTitleView.getDisplayedChild() < position) { - uiTitle.setInAnimation(ctx, R.anim.slide_in_right); - uiTitle.setOutAnimation(ctx, R.anim.slide_out_left); - uiTitle.showNext(); + uiTitleView.setInAnimation(ctx, R.anim.slide_in_right); + uiTitleView.setOutAnimation(ctx, R.anim.slide_out_left); + uiTitleView.showNext(); } else { - uiTitle.setInAnimation(ctx, android.R.anim.slide_in_left); - uiTitle.setOutAnimation(ctx, android.R.anim.slide_out_right); - uiTitle.showPrevious(); + uiTitleView.setInAnimation(ctx, android.R.anim.slide_in_left); + uiTitleView.setOutAnimation(ctx, android.R.anim.slide_out_right); + uiTitleView.showPrevious(); } } } @@ -131,7 +132,7 @@ public void onPageSelected(int position) new Thread(() -> { try { - dynamicModel = dynamicApi.getDynamicDetail(getIntent().getStringExtra("dynamic_id")); + dynamicModel = dynamicApi.getDynamicDetail(getIntent().getStringExtra("dynamic_id"), getIntent().getStringExtra("type")); if(dynamicModel != null) handler.post(runnableUi); else @@ -174,7 +175,7 @@ else if(viewId == R.id.item_dynamic_like_lay) { e.printStackTrace(); Looper.prepare(); - Toast.makeText(ctx, "操作失败,请检查网络...", Toast.LENGTH_SHORT).show(); + Toast.makeText(ctx, getString(R.string.main_error_web), Toast.LENGTH_SHORT).show(); } finally { @@ -185,7 +186,19 @@ else if(viewId == R.id.item_dynamic_like_lay) } } - class DynamicDetailFragmentPagerAdapter extends FragmentPagerAdapter + @Override + public boolean hideTitle() + { + return uiTitleView.hide(); + } + + @Override + public boolean showTitle() + { + return uiTitleView.show(); + } + + private class DynamicDetailFragmentPagerAdapter extends FragmentPagerAdapter { DynamicDetailFragmentPagerAdapter(@NonNull FragmentManager fm, int behavior) { diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/FavorVideoActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/FavorVideoActivity.java index 4d2d627..2e4395f 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/FavorVideoActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/FavorVideoActivity.java @@ -1,5 +1,6 @@ package cn.luern0313.wristbilibili.ui; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.content.Context; import android.content.Intent; @@ -22,9 +23,12 @@ import cn.luern0313.wristbilibili.api.FavorVideoApi; import cn.luern0313.wristbilibili.models.ListVideoModel; import cn.luern0313.wristbilibili.util.ColorUtil; +import cn.luern0313.wristbilibili.util.DataProcessUtil; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout; -public class FavorVideoActivity extends BaseActivity +public class FavorVideoActivity extends BaseActivity implements TitleView.TitleViewListener { private Context ctx; private Intent intent; @@ -49,6 +53,7 @@ public class FavorVideoActivity extends BaseActivity int page = 0; boolean isLoading = true; + @SuppressLint("ClickableViewAccessibility") @Override protected void onCreate(Bundle savedInstanceState) { @@ -60,6 +65,9 @@ protected void onCreate(Bundle savedInstanceState) mid = intent.getStringExtra("mid"); fid = intent.getStringExtra("fid"); + titleView = findViewById(R.id.favor_video_title); + titleViewListener = this; + listVideoAdapterListener = new ListVideoAdapter.ListVideoAdapterListener() { @Override @@ -103,37 +111,38 @@ public void onListVideoAdapterLongClick(int viewId, final int position) }; loadingView = inflater.inflate(R.layout.widget_loading, null); - favvListView = findViewById(R.id.favv_listview); - waveSwipeRefreshLayout = findViewById(R.id.favv_swipe); + listView = findViewById(R.id.favor_video_listview); + waveSwipeRefreshLayout = findViewById(R.id.favor_video_swipe); waveSwipeRefreshLayout.setColorSchemeColors(Color.WHITE, Color.WHITE); waveSwipeRefreshLayout.setWaveColor(ColorUtil.getColor(R.attr.colorPrimary, ctx)); + waveSwipeRefreshLayout.setTopOffsetOfWave(DataProcessUtil.dip2px(33)); waveSwipeRefreshLayout.setOnRefreshListener(() -> handler.post(() -> { - favvListView.setVisibility(View.GONE); + listView.setVisibility(View.GONE); getFavorVideo(); })); runnableUi = () -> { isLoading = false; - findViewById(R.id.favv_noweb).setVisibility(View.GONE); - findViewById(R.id.favv_nonthing).setVisibility(View.GONE); - favvListView.setVisibility(View.VISIBLE); + findViewById(R.id.favor_video_noweb).setVisibility(View.GONE); + findViewById(R.id.favor_video_nonthing).setVisibility(View.GONE); + listView.setVisibility(View.VISIBLE); waveSwipeRefreshLayout.setRefreshing(false); - listVideoAdapter = new ListVideoAdapter(inflater, favorVideoList, false, favvListView, listVideoAdapterListener); - favvListView.setAdapter(listVideoAdapter); + listVideoAdapter = new ListVideoAdapter(inflater, favorVideoList, false, listView, listVideoAdapterListener); + listView.setAdapter(listVideoAdapter); }; runnableNothing = () -> { - findViewById(R.id.favv_noweb).setVisibility(View.GONE); - findViewById(R.id.favv_nonthing).setVisibility(View.VISIBLE); - favvListView.setVisibility(View.GONE); + findViewById(R.id.favor_video_noweb).setVisibility(View.GONE); + findViewById(R.id.favor_video_nonthing).setVisibility(View.VISIBLE); + listView.setVisibility(View.GONE); waveSwipeRefreshLayout.setRefreshing(false); }; runnableNoWeb = () -> { - findViewById(R.id.favv_noweb).setVisibility(View.VISIBLE); - findViewById(R.id.favv_nonthing).setVisibility(View.GONE); - favvListView.setVisibility(View.GONE); + findViewById(R.id.favor_video_noweb).setVisibility(View.VISIBLE); + findViewById(R.id.favor_video_nonthing).setVisibility(View.GONE); + listView.setVisibility(View.GONE); waveSwipeRefreshLayout.setRefreshing(false); }; @@ -155,7 +164,7 @@ public void onListVideoAdapterLongClick(int viewId, final int position) getMoreFavorVideo(); }); - favvListView.setOnScrollListener(new AbsListView.OnScrollListener() + listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) @@ -172,12 +181,14 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } }); + listView.setOnTouchListener(new ListViewTouchListener(listView, titleViewListener)); + waveSwipeRefreshLayout.setRefreshing(true); - favvListView.addFooterView(loadingView); + listView.addFooterView(loadingView); getFavorVideo(); } - void getFavorVideo() + private void getFavorVideo() { isLoading = true; favorVideoApi = new FavorVideoApi(mid, fid); @@ -198,7 +209,7 @@ void getFavorVideo() }).start(); } - void getMoreFavorVideo() + private void getMoreFavorVideo() { isLoading = true; page++; @@ -221,4 +232,16 @@ void getMoreFavorVideo() } }).start(); } + + @Override + public boolean hideTitle() + { + return titleView.hide(); + } + + @Override + public boolean showTitle() + { + return titleView.show(); + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/FollowmeActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/FollowmeActivity.java index 8f58b8c..3f64c11 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/FollowmeActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/FollowmeActivity.java @@ -82,38 +82,28 @@ protected void onCreate(@Nullable Bundle savedInstanceState) uiVideoCoin = findViewById(R.id.fme_coin); uiVideoCoinImg = findViewById(R.id.fme_coin_img); - runnVideo = new Runnable() - { - @Override - public void run() + runnVideo = () -> { + try { - try - { - uiVideoTitle.setText(listVideoModel.getVideoTitle()); - if(listVideoModel.getVideoTitle().startsWith("【互动")) - uiVideoStarLin.setVisibility(View.VISIBLE); - uiVideoLC.setVisibility(View.VISIBLE); - } - catch (Exception e) - { - e.printStackTrace(); - } + uiVideoTitle.setText(listVideoModel.getTitle()); + if(listVideoModel.getTitle().startsWith("【互动")) + uiVideoStarLin.setVisibility(View.VISIBLE); + uiVideoLC.setVisibility(View.VISIBLE); + } + catch (Exception e) + { + e.printStackTrace(); } }; - runnImg = new Runnable() - { - @Override - public void run() + runnImg = () -> { + try { - try - { - uiVideoImg.setImageBitmap(videoCover); - } - catch (Exception e) - { - e.printStackTrace(); - } + uiVideoImg.setImageBitmap(videoCover); + } + catch (Exception e) + { + e.printStackTrace(); } }; @@ -121,162 +111,102 @@ public void run() findViewById(R.id.fme_nologin).setVisibility(View.VISIBLE); else { - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - listVideoModel = userApi.getUserVideo(1).get(0); - videoDetail = new VideoApi("", listVideoModel.getBvid()); - handler.post(runnVideo); + listVideoModel = userApi.getUserVideo(1).get(0); + videoDetail = new VideoApi("", listVideoModel.getBvid()); + handler.post(runnVideo); - byte[] picByte = NetWorkUtil.readStream(NetWorkUtil.get(listVideoModel.getCover()).body().byteStream()); - videoCover = BitmapFactory.decodeByteArray(picByte, 0, picByte.length); - handler.post(runnImg); - } - catch (Exception e) - { - e.printStackTrace(); - } + byte[] picByte = NetWorkUtil.readStream(NetWorkUtil.get(listVideoModel.getCover()).body().byteStream()); + videoCover = BitmapFactory.decodeByteArray(picByte, 0, picByte.length); + handler.post(runnImg); + } + catch (Exception e) + { + e.printStackTrace(); } }).start(); } - cardView.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - cardViewText.setText("已关注"); - cardViewText.setBackgroundResource(R.drawable.shape_bg_anre_followbgyes); - new Thread(new Runnable() + cardView.setOnClickListener(v -> { + cardViewText.setText("已关注"); + cardViewText.setBackgroundResource(R.drawable.shape_bg_anre_followbgyes); + new Thread(() -> { + try { - @Override - public void run() - { - try - { - userApi.follow(); - } - catch (Exception e) - { - e.printStackTrace(); - Looper.prepare(); - Toast.makeText(ctx, "关注失败...", Toast.LENGTH_SHORT).show(); - Looper.loop(); - } - } - }).start(); - } + userApi.follow(); + } + catch (Exception e) + { + e.printStackTrace(); + Looper.prepare(); + Toast.makeText(ctx, "关注失败...", Toast.LENGTH_SHORT).show(); + Looper.loop(); + } + }).start(); }); - uiVideo.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - if(videoDetail != null) - startActivity(VideoActivity.getActivityIntent(ctx, "", videoDetail.bvid)); - } + uiVideo.setOnClickListener(v -> { + if(videoDetail != null) + startActivity(VideoActivity.getActivityIntent(ctx, "", videoDetail.bvid)); }); - uiVote.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiVote.setText("感谢投票~"); - uiVote.setBackgroundResource(R.drawable.shape_bg_anre_followbgyes); - new Thread(new Runnable() + uiVote.setOnClickListener(v -> { + uiVote.setText("感谢投票~"); + uiVote.setBackgroundResource(R.drawable.shape_bg_anre_followbgyes); + new Thread(() -> { + try { - @Override - public void run() - { - try - { - videoDetail.scoreVideo(5); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - }).start(); - } + videoDetail.scoreVideo(5); + } + catch (IOException e) + { + e.printStackTrace(); + } + }).start(); }); - uiVideoStarLin.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiVideoStar.setImageResource(R.drawable.img_fme_star_yes); - new Thread(new Runnable() + uiVideoStarLin.setOnClickListener(v -> { + uiVideoStar.setImageResource(R.drawable.img_fme_star_yes); + new Thread(() -> { + try { - @Override - public void run() - { - try - { - videoDetail.scoreVideo(5); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - }).start(); - } + videoDetail.scoreVideo(5); + } + catch (IOException e) + { + e.printStackTrace(); + } + }).start(); }); - uiVideoLike.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiVideoLikeImg.setImageResource(R.drawable.icon_like_yes); - new Thread(new Runnable() + uiVideoLike.setOnClickListener(v -> { + uiVideoLikeImg.setImageResource(R.drawable.icon_like_yes); + new Thread(() -> { + try { - @Override - public void run() - { - try - { - videoDetail.likeVideo(1); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - }).start(); - } + videoDetail.likeVideo(1); + } + catch (Exception e) + { + e.printStackTrace(); + } + }).start(); }); - uiVideoCoin.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - uiVideoCoinImg.setImageResource(R.drawable.icon_coin_yes); - new Thread(new Runnable() + uiVideoCoin.setOnClickListener(v -> { + uiVideoCoinImg.setImageResource(R.drawable.icon_coin_yes); + new Thread(() -> { + try { - @Override - public void run() - { - try - { - videoDetail.coinVideo(2); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - }).start(); - } + videoDetail.coinVideo(2); + } + catch (Exception e) + { + e.printStackTrace(); + } + }).start(); }); } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/ImgActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/ImgActivity.java index 64f983b..2568d37 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/ImgActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/ImgActivity.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.ViewPager; import cn.luern0313.wristbilibili.R; @@ -200,10 +199,8 @@ public void onClick(View v) private BitmapDrawable setImageFormWeb(String url) { - if(LruCacheUtil.getLruCache().get(url) != null) - { + if(url != null && LruCacheUtil.getLruCache().get(url) != null) return LruCacheUtil.getLruCache().get(url); - } else { ImageTaskUtil it = new ImageTaskUtil(uiViewPager, 500, true); diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/FavorArticleActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/LotteryActivity.java similarity index 57% rename from app/src/main/java/cn/luern0313/wristbilibili/ui/FavorArticleActivity.java rename to app/src/main/java/cn/luern0313/wristbilibili/ui/LotteryActivity.java index 2718010..605b8e5 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/FavorArticleActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/LotteryActivity.java @@ -1,31 +1,32 @@ package cn.luern0313.wristbilibili.ui; import android.content.Context; +import android.content.Intent; import android.os.Bundle; -import android.view.LayoutInflater; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import cn.luern0313.wristbilibili.R; -import cn.luern0313.wristbilibili.fragment.FavorArticleFragment; +import cn.luern0313.wristbilibili.fragment.LotteryFragment; -public class FavorArticleActivity extends BaseActivity +public class LotteryActivity extends BaseActivity { + public static final String ARG_LOTTERY_ID = "id"; + Context ctx; - LayoutInflater inflater; + Intent intent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_favor_article); - + setContentView(R.layout.activity_lottery); ctx = this; - inflater = getLayoutInflater(); + intent = getIntent(); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction transaction = fm.beginTransaction(); - transaction.replace(R.id.favor_article_frame, FavorArticleFragment.newInstance()); + transaction.replace(R.id.lottery_frame, LotteryFragment.newInstance(intent.getStringExtra(ARG_LOTTERY_ID))); transaction.commit(); } } \ No newline at end of file diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/MainActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/MainActivity.java index 0ddae56..39ce0ff 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/MainActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/MainActivity.java @@ -7,18 +7,19 @@ import android.os.Bundle; import android.util.DisplayMetrics; import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; import android.widget.Toast; import com.liulishuo.filedownloader.FileDownloader; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import cn.luern0313.wristbilibili.R; +import cn.luern0313.wristbilibili.api.RegionApi; import cn.luern0313.wristbilibili.api.StatisticsApi; import cn.luern0313.wristbilibili.fragment.AnimationTimelineFragment; import cn.luern0313.wristbilibili.fragment.DownloadFragment; @@ -27,18 +28,21 @@ import cn.luern0313.wristbilibili.fragment.HistoryFragment; import cn.luern0313.wristbilibili.fragment.RankingFragment; import cn.luern0313.wristbilibili.fragment.RecommendFragment; +import cn.luern0313.wristbilibili.fragment.RegionListFragment; import cn.luern0313.wristbilibili.fragment.SearchFragment; import cn.luern0313.wristbilibili.fragment.SettingFragment; import cn.luern0313.wristbilibili.fragment.WatchlaterFragment; import cn.luern0313.wristbilibili.service.DownloadService; +import cn.luern0313.wristbilibili.util.DataProcessUtil; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; /** * Created by liupe on 2018/10/25. * fragment..... */ -public class MainActivity extends BaseActivity +public class MainActivity extends BaseActivity implements TitleView.TitleViewListener { Context ctx; @@ -47,8 +51,20 @@ public class MainActivity extends BaseActivity private FragmentTransaction transaction; DisplayMetrics dm; - TextView titleText; - ImageView titleImg; + TitleView titleView; + + private final static Class[] menuFragment = new Class[]{ + DynamicFragment.class, RecommendFragment.class, RankingFragment.class, + AnimationTimelineFragment.class, RegionListFragment.class, DownloadFragment.class, + SearchFragment.class, FavorBoxFragment.class, WatchlaterFragment.class, + HistoryFragment.class, SettingFragment.class + }; + private final static Object[][] menuFragmentParameter = new Object[][]{ + {true, SharedPreferencesUtil.getString(SharedPreferencesUtil.mid, "")}, + {}, {}, {}, {}, {}, {}, + {SharedPreferencesUtil.getString(SharedPreferencesUtil.mid, ""), true}, + {}, {}, {} + }; @Override protected void onCreate(@Nullable Bundle savedInstanceState) @@ -58,14 +74,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) ctx = this; + titleView = findViewById(R.id.main_title); dm = getResources().getDisplayMetrics(); fm = getSupportFragmentManager(); transaction = fm.beginTransaction(); - transaction.replace(R.id.main_frame, DynamicFragment.newInstance(true, SharedPreferencesUtil.getString(SharedPreferencesUtil.mid, ""))); - transaction.commit(); - - titleText = findViewById(R.id.main_title_title); - titleImg = findViewById(R.id.main_title_extraicon); + switchFragment(0); FileDownloader.setup(this); @@ -116,11 +129,25 @@ protected void onCreate(@Nullable Bundle savedInstanceState) // finish(); //startActivity(VideoActivity.getActivityIntent(ctx, "78732000", "")); + new Thread(() -> { + try + { + new RegionApi().getRegionList(); + } + catch (IOException e) + { + e.printStackTrace(); + } + }).start(); - Intent intent = new Intent(ctx, UserActivity.class); - intent.putExtra("mid", "399460614"); + /*Intent intent = new Intent(ctx, UserActivity.class); + intent.putExtra("mid", "476315827"); startActivity(intent); + intent = new Intent(ctx, LotteryActivity.class); + intent.putExtra(LotteryActivity.ARG_LOTTERY_ID, "474964958500946284"); + startActivity(intent);*/ + serviceIntent = new Intent(this, DownloadService.class); startService(serviceIntent); } @@ -131,63 +158,28 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) super.onActivityResult(requestCode, resultCode, data); if(requestCode == 0 && resultCode == 0 && data != null) { + switchFragment(data.getIntExtra("activity", 0)); + } + } + + private void switchFragment(int choose) + { + try + { + showTitle(); fm = getSupportFragmentManager(); transaction = fm.beginTransaction(); - switch (data.getIntExtra("activity", 0)) - { - case 1: - transaction.replace(R.id.main_frame, DynamicFragment.newInstance(true, SharedPreferencesUtil.getString(SharedPreferencesUtil.mid, ""))); - titleText.setText(getString(R.string.menu_dynamic)); - titleText.setTextSize(14); - break; - case 2: - transaction.replace(R.id.main_frame, new RecommendFragment()); - titleText.setText(getString(R.string.menu_recommend)); - titleText.setTextSize(14); - break; - case 3: - transaction.replace(R.id.main_frame, new RankingFragment()); - titleText.setText(getString(R.string.menu_ranking)); - titleText.setTextSize(14); - break; - case 4: - transaction.replace(R.id.main_frame, new AnimationTimelineFragment()); - titleText.setText(getString(R.string.menu_remind)); - titleText.setTextSize(13); - break; - case 5: - transaction.replace(R.id.main_frame, new DownloadFragment()); - titleText.setText(getString(R.string.menu_download)); - titleText.setTextSize(13); - break; - case 6: - transaction.replace(R.id.main_frame, new SearchFragment()); - titleText.setText(getString(R.string.menu_search)); - titleText.setTextSize(14); - break; - case 7: - transaction.replace(R.id.main_frame, FavorBoxFragment.newInstance(SharedPreferencesUtil.getString(SharedPreferencesUtil.mid, ""), true)); - titleText.setText(getString(R.string.menu_collect)); - titleText.setTextSize(14); - break; - case 8: - transaction.replace(R.id.main_frame, new WatchlaterFragment()); - titleText.setText(getString(R.string.menu_watchlater)); - titleText.setTextSize(13); - break; - case 9: - transaction.replace(R.id.main_frame, new HistoryFragment()); - titleText.setText(getString(R.string.menu_history)); - titleText.setTextSize(14); - break; - case 10: - transaction.replace(R.id.main_frame, new SettingFragment()); - titleText.setText(getString(R.string.menu_setting)); - titleText.setTextSize(14); - break; - } + if(menuFragmentParameter[choose].length > 0) + transaction.replace(R.id.main_frame, (Fragment) menuFragment[choose].getDeclaredMethod("newInstance", DataProcessUtil.getParameterTypes(menuFragmentParameter[choose])).invoke(null, menuFragmentParameter[choose])); + else + transaction.replace(R.id.main_frame, (Fragment) menuFragment[choose].newInstance()); + titleView.setTitle(getResources().getStringArray(R.array.menu_title)[choose]); transaction.commit(); } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) + { + e.printStackTrace(); + } } public void buttonTitle(final View view) @@ -203,4 +195,16 @@ protected void onDestroy() super.onDestroy(); stopService(serviceIntent); } + + @Override + public boolean hideTitle() + { + return titleView.hide(); + } + + @Override + public boolean showTitle() + { + return titleView.show(); + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/MenuActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/MenuActivity.java index b0e239a..6f708b7 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/MenuActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/MenuActivity.java @@ -7,8 +7,10 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; +import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; +import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -18,8 +20,9 @@ import java.io.FileOutputStream; import java.io.IOException; -import androidx.appcompat.app.AppCompatActivity; +import cn.luern0313.lson.LsonUtil; import cn.luern0313.wristbilibili.R; +import cn.luern0313.wristbilibili.adapter.MenuAdapter; import cn.luern0313.wristbilibili.api.UserInfoApi; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; @@ -51,16 +54,23 @@ protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu); ctx = this; + inflater = getLayoutInflater(); - uiUserName = findViewById(R.id.menu_username); - uiUserCoin = findViewById(R.id.menu_usercoin); - uiUserLV = findViewById(R.id.menu_userlv); - uiUserHead = findViewById(R.id.menu_useric); - uiUserVip = findViewById(R.id.menu_uservip); + uiListView = findViewById(R.id.menu_listview); + layoutMenuHeader = inflater.inflate(R.layout.widget_menu_header, null); + uiListView.addHeaderView(layoutMenuHeader); - uiUserName.setText(SharedPreferencesUtil.getString(SharedPreferencesUtil.userName, "你还没登录呢~")); - uiUserCoin.setText("硬币 : " + SharedPreferencesUtil.getString(SharedPreferencesUtil.userCoin, "0")); - uiUserLV.setText("LV" + SharedPreferencesUtil.getInt(SharedPreferencesUtil.userLV, 0)); + menuAdapterListener = this::onClick; + + uiUserName = layoutMenuHeader.findViewById(R.id.menu_username); + uiUserCoin = layoutMenuHeader.findViewById(R.id.menu_user_coin); + uiUserLV = layoutMenuHeader.findViewById(R.id.menu_user_lv); + uiUserHead = layoutMenuHeader.findViewById(R.id.menu_user_img); + uiUserVip = layoutMenuHeader.findViewById(R.id.menu_user_vip); + + uiUserName.setText(SharedPreferencesUtil.getString(SharedPreferencesUtil.userName, getString(R.string.menu_default_login))); + uiUserCoin.setText(String.format(getString(R.string.menu_coin), SharedPreferencesUtil.getString(SharedPreferencesUtil.userCoin, "0"))); + uiUserLV.setText(String.format(getString(R.string.menu_lv), SharedPreferencesUtil.getInt(SharedPreferencesUtil.userLV, 0))); uiUserVip.setVisibility(SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.userVip, false) ? View.VISIBLE : View.GONE); try { @@ -71,6 +81,9 @@ protected void onCreate(Bundle savedInstanceState) e.printStackTrace(); } + menuAdapter = new MenuAdapter(inflater, getMenuSort(), 0, uiListView, menuAdapterListener); + uiListView.setAdapter(menuAdapter); + resultIntent = new Intent(); setResult(-1, resultIntent); @@ -83,52 +96,42 @@ public void setUserInfo() if(SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies)) //是否登录(←错错错错错错错错!!cookie有时限!!!!) { final UserInfoApi userInfoApi = new UserInfoApi(); - runnableUi = new Runnable() - { - @Override - public void run() - { - uiUserName.setText(userInfoApi.getUserName()); - uiUserCoin.setText("硬币 : " + userInfoApi.getUserCoin()); - uiUserLV.setText("LV" + userInfoApi.getUserLV()); - uiUserHead.setImageBitmap(head); - uiUserVip.setVisibility(userInfoApi.isVip() ? View.VISIBLE : View.GONE); - - SharedPreferencesUtil.putString(SharedPreferencesUtil.userName, userInfoApi.getUserName()); - SharedPreferencesUtil.putString(SharedPreferencesUtil.userCoin, userInfoApi.getUserCoin()); - SharedPreferencesUtil.putInt(SharedPreferencesUtil.userLV, userInfoApi.getUserLV()); - SharedPreferencesUtil.putBoolean(SharedPreferencesUtil.userVip, userInfoApi.isVip()); - } + runnableUi = () -> { + uiUserName.setText(userInfoApi.getUserName()); + uiUserCoin.setText(String.format(getString(R.string.menu_coin), userInfoApi.getUserCoin())); + uiUserLV.setText(String.format(getString(R.string.menu_lv), userInfoApi.getUserLV())); + uiUserHead.setImageBitmap(head); + uiUserVip.setVisibility(userInfoApi.isVip() ? View.VISIBLE : View.GONE); + + SharedPreferencesUtil.putString(SharedPreferencesUtil.userName, userInfoApi.getUserName()); + SharedPreferencesUtil.putString(SharedPreferencesUtil.userCoin, userInfoApi.getUserCoin()); + SharedPreferencesUtil.putInt(SharedPreferencesUtil.userLV, userInfoApi.getUserLV()); + SharedPreferencesUtil.putBoolean(SharedPreferencesUtil.userVip, userInfoApi.isVip()); }; - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try + int stat = userInfoApi.getUserInfo(); + //0正常,-1其他问题,-2登录过期 + if(stat == 0) { - int stat = userInfoApi.getUserInfo(); - //0正常,-1其他问题,-2登录过期 - if(stat == 0) - { - head = userInfoApi.getUserHead(); - saveBitmap(head); - handler.post(runnableUi); - } - else if(stat == -2) - { - Looper.prepare(); - Toast.makeText(getApplicationContext(), "您的登录信息已过期,请注销后重新登录", Toast.LENGTH_LONG).show(); - Intent i = new Intent(ctx, LogsoffActivity.class); - startActivity(i); - Looper.loop(); - } + head = userInfoApi.getUserHead(); + saveBitmap(head); + handler.post(runnableUi); } - catch (IOException e) + else if(stat == -2) { - e.printStackTrace(); + Looper.prepare(); + Toast.makeText(getApplicationContext(), "您的登录信息已过期,请注销后重新登录", Toast.LENGTH_LONG).show(); + Intent i = new Intent(ctx, LogsoffActivity.class); + startActivity(i); + Looper.loop(); } } + catch (IOException e) + { + e.printStackTrace(); + } }).start(); } } @@ -164,7 +167,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) } } - public void buutonUser(View view) //个人信息/登录 + public void buttonUser(View view) //个人信息/登录 { if(!SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies))//是否登录的验证 { @@ -180,6 +183,19 @@ public void buutonUser(View view) //个人信息/登录 } } + public void onClick(int position) + { + resultIntent.putExtra("activity", position); + setResult(0, resultIntent); + finish(); + overridePendingTransition(0, R.anim.anim_activity_out_up); + } + + public int[] getMenuSort() + { + return LsonUtil.fromJson(LsonUtil.parse(SharedPreferencesUtil.getString(SharedPreferencesUtil.menuSort, "[0,1,2,3,4,5,6,7,8,9,10]")), int[].class); + } + public void buttonDynamic(View view) { resultIntent.putExtra("activity", 1); @@ -212,7 +228,7 @@ public void buttonRemind(View view) overridePendingTransition(0, R.anim.anim_activity_out_up); } - public void buttonDL(View view) + public void buttonRegion(View view) { resultIntent.putExtra("activity", 5); setResult(0, resultIntent); @@ -220,7 +236,7 @@ public void buttonDL(View view) overridePendingTransition(0, R.anim.anim_activity_out_up); } - public void buttonSearch(View view) + public void buttonDL(View view) { resultIntent.putExtra("activity", 6); setResult(0, resultIntent); @@ -228,7 +244,7 @@ public void buttonSearch(View view) overridePendingTransition(0, R.anim.anim_activity_out_up); } - public void buttonCollect(View view) + public void buttonSearch(View view) { resultIntent.putExtra("activity", 7); setResult(0, resultIntent); @@ -236,7 +252,7 @@ public void buttonCollect(View view) overridePendingTransition(0, R.anim.anim_activity_out_up); } - public void buttonWatchlater(View view) + public void buttonCollect(View view) { resultIntent.putExtra("activity", 8); setResult(0, resultIntent); @@ -244,7 +260,7 @@ public void buttonWatchlater(View view) overridePendingTransition(0, R.anim.anim_activity_out_up); } - public void buttonHistory(View view) + public void buttonWatchlater(View view) { resultIntent.putExtra("activity", 9); setResult(0, resultIntent); @@ -252,11 +268,19 @@ public void buttonHistory(View view) overridePendingTransition(0, R.anim.anim_activity_out_up); } - public void buttonSetting(View view) + public void buttonHistory(View view) { resultIntent.putExtra("activity", 10); setResult(0, resultIntent); finish(); overridePendingTransition(0, R.anim.anim_activity_out_up); } + + public void buttonSetting(View view) + { + resultIntent.putExtra("activity", 11); + setResult(0, resultIntent); + finish(); + overridePendingTransition(0, R.anim.anim_activity_out_up); + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/QRActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/RegionListActivity.java similarity index 64% rename from app/src/main/java/cn/luern0313/wristbilibili/ui/QRActivity.java rename to app/src/main/java/cn/luern0313/wristbilibili/ui/RegionListActivity.java index 9ee78fa..c5f4c40 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/QRActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/RegionListActivity.java @@ -2,19 +2,17 @@ import android.content.Context; import android.os.Bundle; -import android.widget.ImageView; import cn.luern0313.wristbilibili.R; -public class QRActivity extends BaseActivity +public class RegionListActivity extends BaseActivity { Context ctx; - ImageView qrImageView; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_qr); + setContentView(R.layout.activity_region_list); + ctx = this; } -} +} \ No newline at end of file diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/ReplyActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/ReplyActivity.java index ca226a9..4dc166c 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/ReplyActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/ReplyActivity.java @@ -8,7 +8,6 @@ import android.widget.EditText; import android.widget.Toast; -import androidx.appcompat.app.AppCompatActivity; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; @@ -44,7 +43,7 @@ public void rp_clickVoiceInput(View view) } catch (Exception e) { - Toast.makeText(ctx, "抱歉,该手表不支持语音输入", Toast.LENGTH_SHORT).show(); + Toast.makeText(ctx, getString(R.string.main_tip_voice_input), Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/SelectPartActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/SelectPartActivity.java index 33859ac..6253279 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/SelectPartActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/SelectPartActivity.java @@ -1,32 +1,36 @@ package cn.luern0313.wristbilibili.ui; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; import android.widget.ListView; import android.widget.TextView; -import androidx.appcompat.app.AppCompatActivity; import cn.luern0313.wristbilibili.R; +import cn.luern0313.wristbilibili.adapter.SelectPartAdapter; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; +import cn.luern0313.wristbilibili.widget.TitleView; -public class SelectPartActivity extends BaseActivity +public class SelectPartActivity extends BaseActivity implements TitleView.TitleViewListener { Context ctx; Intent inIntent; LayoutInflater inflater; + SelectPartAdapter.SelectPartListener selectPartListener; String title; String tip; String[] options; String[] optionsId; - ListView spListView; + TitleView titleView; + ListView listView; View selectPartTipView; + @SuppressLint("ClickableViewAccessibility") @Override protected void onCreate(Bundle savedInstanceState) { @@ -38,91 +42,52 @@ protected void onCreate(Bundle savedInstanceState) setResult(-1, inIntent); - title = inIntent.hasExtra("title") ? inIntent.getStringExtra("title") : "请选择"; - tip = inIntent.hasExtra("tip") ? inIntent.getStringExtra("tip") : ""; + title = inIntent.hasExtra("title") ? inIntent.getStringExtra("title") : getString(R.string.select_title); + tip = inIntent.getStringExtra("tip"); options = inIntent.hasExtra("options_name") ? inIntent.getStringArrayExtra("options_name") : new String[0]; optionsId = inIntent.hasExtra("options_id") ? inIntent.getStringArrayExtra("options_id") : new String[0]; - spListView = findViewById(R.id.sp_list); - ((TextView) findViewById(R.id.sp_title_title)).setText(title); - if(!"".equals(tip)) + titleView = findViewById(R.id.sp_title); + titleView.setTitle(title); + listView = findViewById(R.id.sp_list); + if(tip != null) { selectPartTipView = inflater.inflate(R.layout.widget_select_part_tip, null); ((TextView) selectPartTipView.findViewById(R.id.sp_tip_text)).setText(tip); - spListView.addHeaderView(selectPartTipView, null, false); - spListView.setHeaderDividersEnabled(false); + listView.addHeaderView(selectPartTipView, null, false); + listView.setHeaderDividersEnabled(false); } - mAdapter mAdapter = new mAdapter(getLayoutInflater(), options); + selectPartListener = this::onClick; - spListView.setAdapter(mAdapter); - } - - class mAdapter extends BaseAdapter - { - private LayoutInflater mInflater; - - private String[] spList; - - public mAdapter(LayoutInflater inflater, String[] spList) - { - mInflater = inflater; - this.spList = spList; - } + listView.setOnTouchListener(new ListViewTouchListener(listView, (TitleView.TitleViewListener) ctx)); - @Override - public int getCount() - { - return spList.length; - } + SelectPartAdapter mAdapter = new SelectPartAdapter(getLayoutInflater(), options, selectPartListener); - @Override - public Object getItem(int position) - { - return position; - } + listView.setAdapter(mAdapter); + } - @Override - public long getItemId(int position) + private void onClick(int id, int position) + { + if(optionsId.length > position) { - return position; + inIntent.putExtra("option_id", optionsId[position]); + inIntent.putExtra("option_position", position); + inIntent.putExtra("option_name", options[position]); + setResult(0, inIntent); + finish(); } + } - @Override - public View getView(final int position, View convertView, ViewGroup viewGroup) - { - ViewHolder viewHolder; - if(convertView == null) - { - convertView = mInflater.inflate(R.layout.item_select_part, null); - viewHolder = new ViewHolder(); - convertView.setTag(viewHolder); - viewHolder.text = convertView.findViewById(R.id.sp_item_text); - } - else - { - viewHolder = (ViewHolder) convertView.getTag(); - } - viewHolder.text.setText(spList[position]); - - viewHolder.text.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - if(optionsId.length != 0) inIntent.putExtra("option_id", optionsId[position]); - inIntent.putExtra("option_position", position); - inIntent.putExtra("option_name", options[position]); - setResult(0, inIntent); - finish(); - } - }); - return convertView; - } + @Override + public boolean hideTitle() + { + return titleView.hide(); + } - class ViewHolder - { - TextView text; - } + @Override + public boolean showTitle() + { + return titleView.show(); } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/SendDynamicActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/SendDynamicActivity.java index f46db25..9628685 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/SendDynamicActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/SendDynamicActivity.java @@ -15,7 +15,6 @@ import java.io.IOException; -import androidx.appcompat.app.AppCompatActivity; import androidx.cardview.widget.CardView; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.util.ImageDownloaderUtil; @@ -55,8 +54,8 @@ protected void onCreate(Bundle savedInstanceState) if(inIntent.getBooleanExtra("is_share", false)) { findViewById(R.id.senddy_share).setVisibility(View.VISIBLE); - up = inIntent.hasExtra("share_up") ? inIntent.getStringExtra("share_up") : ""; - img = inIntent.hasExtra("share_img") ? inIntent.getStringExtra("share_img") : ""; + up = inIntent.getStringExtra("share_up"); + img =inIntent.getStringExtra("share_img"); title = inIntent.hasExtra("share_title") ? inIntent.getStringExtra("share_title") : ""; text = inIntent.hasExtra("share_text") ? inIntent.getStringExtra("share_text") : ""; @@ -66,28 +65,23 @@ protected void onCreate(Bundle savedInstanceState) uiShareImg = findViewById(R.id.senddy_share_img_img); uiShareTitle = findViewById(R.id.senddy_share_title); - if(!up.equals("")) + if(up != null) uiShareUp.setText(Html.fromHtml("转发自 @" + up + ":")); else uiShareUp.setVisibility(View.GONE); uiShareTitle.setText(title); - if(!img.equals("")) + if(img != null) { uiShareCardview.setVisibility(View.VISIBLE); - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - image = ImageDownloaderUtil.downloadImage(img); - handler.post(runnableUi); - } - catch (IOException e) - { - e.printStackTrace(); - } + image = ImageDownloaderUtil.downloadImage(img); + handler.post(runnableUi); + } + catch (IOException e) + { + e.printStackTrace(); } }).start(); } @@ -97,19 +91,14 @@ public void run() if(!SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.tail, true)) findViewById(R.id.senddy_tail).setVisibility(View.GONE); - runnableUi = new Runnable() - { - @Override - public void run() + runnableUi = () -> { + try + { + uiShareImg.setImageBitmap(image); + } + catch (Exception e) { - try - { - uiShareImg.setImageBitmap(image); - } - catch (Exception e) - { - e.printStackTrace(); - } + e.printStackTrace(); } }; } @@ -124,7 +113,7 @@ public void senddy_clickVoiceInput(View view) } catch (Exception e) { - Toast.makeText(ctx, "抱歉,该手表不支持语音输入", Toast.LENGTH_SHORT).show(); + Toast.makeText(ctx, getString(R.string.main_tip_voice_input), Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/SueActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/SueActivity.java index e48c064..9858faa 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/SueActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/SueActivity.java @@ -12,19 +12,21 @@ import java.io.IOException; -import androidx.appcompat.app.AppCompatActivity; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.api.SendDynamicApi; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; -public class SueActivity extends BaseActivity +public class SueActivity extends BaseActivity implements TitleView.TitleViewListener { Context ctx; SendDynamicApi sendDynamicApi; + TitleView titleView; TextView uiText; LinearLayout uiLoading; - LinearLayout uiNologin; + LinearLayout uiNoLogin; Handler handler = new Handler(); Runnable runnableUi; @@ -35,32 +37,19 @@ protected void onCreate(Bundle savedInstanceState) setContentView(R.layout.activity_sue); ctx = this; - uiText = findViewById(R.id.dt_text); - uiLoading = findViewById(R.id.dt_loading); - uiNologin = findViewById(R.id.dt_nologin); + titleView = findViewById(R.id.sue_title); + uiText = findViewById(R.id.sue_text); + uiLoading = findViewById(R.id.sue_loading); + uiNoLogin = findViewById(R.id.dt_nologin); sendDynamicApi = new SendDynamicApi(); uiText.setText(Html.fromHtml("#腕上哔哩# #用手表上b站# " + sendDynamicApi.getNextShareText())); if(!SharedPreferencesUtil.contains(SharedPreferencesUtil.cookies)) - uiNologin.setVisibility(View.VISIBLE); + uiNoLogin.setVisibility(View.VISIBLE); - runnableUi = new Runnable() - { - @Override - public void run() - { - uiLoading.setVisibility(View.GONE); - } - }; + findViewById(R.id.sue_lay).setOnTouchListener(new ListViewTouchListener(findViewById(R.id.sue_lay), (TitleView.TitleViewListener) ctx)); - findViewById(R.id.dt_title_layout).setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) - { - finish(); - } - }); + runnableUi = () -> uiLoading.setVisibility(View.GONE); } public void clickRe(View view) @@ -71,28 +60,35 @@ public void clickRe(View view) public void clickSend(View view) { uiLoading.setVisibility(View.VISIBLE); - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - sendDynamicApi.shareVideo("#腕上哔哩# #用手表上b站# " + sendDynamicApi.getNowShareText()); - Looper.prepare(); - Toast.makeText(ctx, "发送成功!", Toast.LENGTH_SHORT).show(); - handler.post(runnableUi); - Looper.loop(); - } - catch (IOException e) - { - Looper.prepare(); - Toast.makeText(ctx, "好像没有网络连接呢...", Toast.LENGTH_SHORT).show(); - handler.post(runnableUi); - Looper.loop(); - e.printStackTrace(); - } + sendDynamicApi.shareVideo("#腕上哔哩# #用手表上b站# " + sendDynamicApi.getNowShareText()); + Looper.prepare(); + Toast.makeText(ctx, "发送成功!", Toast.LENGTH_SHORT).show(); + handler.post(runnableUi); + Looper.loop(); + } + catch (IOException e) + { + Looper.prepare(); + Toast.makeText(ctx, "好像没有网络连接呢...", Toast.LENGTH_SHORT).show(); + handler.post(runnableUi); + Looper.loop(); + e.printStackTrace(); } }).start(); } + + @Override + public boolean hideTitle() + { + return titleView.hide(); + } + + @Override + public boolean showTitle() + { + return titleView.show(); + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/TailActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/TailActivity.java index 244cc23..4a05100 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/TailActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/TailActivity.java @@ -6,22 +6,19 @@ import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; -import android.view.View; -import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageView; -import android.widget.Switch; import android.widget.TextView; import android.widget.Toast; -import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.SwitchCompat; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; public class TailActivity extends BaseActivity { Context ctx; - Switch uiSwitch; + SwitchCompat uiSwitch; EditText uiEditText; ImageView uiVoice; @@ -35,24 +32,19 @@ protected void onCreate(Bundle savedInstanceState) uiSwitch = findViewById(R.id.tail_switch); uiEditText = findViewById(R.id.tail_preview); uiVoice = findViewById(R.id.tail_voice); - ((Switch) findViewById(R.id.tail_switch)).setChecked(SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.tail, true)); + ((SwitchCompat) findViewById(R.id.tail_switch)).setChecked(SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.tail, true)); ((TextView) findViewById(R.id.tail_preview)).setText(getTail(false)); - uiVoice.setOnClickListener(new View.OnClickListener() - { - @Override - public void onClick(View v) + uiVoice.setOnClickListener(v -> { + Intent voiceInputIntent = new Intent("com.mobvoi.ticwear.action.SPEECH"); + voiceInputIntent.putExtra("start_mode", "start_mode_with_voice_input"); + try { - Intent voiceInputIntent = new Intent("com.mobvoi.ticwear.action.SPEECH"); - voiceInputIntent.putExtra("start_mode", "start_mode_with_voice_input"); - try - { - startActivityForResult(voiceInputIntent, 0); - } - catch (Exception e) - { - Toast.makeText(ctx, "抱歉,该手表不支持语音输入", Toast.LENGTH_SHORT).show(); - } + startActivityForResult(voiceInputIntent, 0); + } + catch (Exception e) + { + Toast.makeText(ctx, getString(R.string.main_tip_voice_input), Toast.LENGTH_SHORT).show(); } }); @@ -72,14 +64,7 @@ public void afterTextChanged(Editable s) {} }); uiSwitch.setChecked(SharedPreferencesUtil.getBoolean(SharedPreferencesUtil.tail, true)); - uiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() - { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) - { - SharedPreferencesUtil.putBoolean(SharedPreferencesUtil.tail, isChecked); - } - }); + uiSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> SharedPreferencesUtil.putBoolean(SharedPreferencesUtil.tail, isChecked)); } @Override diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/TextActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/TextActivity.java index 3a4a798..697f8c9 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/TextActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/TextActivity.java @@ -6,15 +6,15 @@ import android.text.Html; import android.widget.TextView; -import androidx.appcompat.app.AppCompatActivity; import cn.luern0313.wristbilibili.R; +import cn.luern0313.wristbilibili.widget.TitleView; public class TextActivity extends BaseActivity { Context ctx; Intent intent; - TextView uiTitle; + TitleView uiTitle; TextView uiText; @Override @@ -25,9 +25,9 @@ protected void onCreate(Bundle savedInstanceState) ctx = this; intent = getIntent(); - uiTitle = findViewById(R.id.text_title_title); + uiTitle = findViewById(R.id.text_title); uiText = findViewById(R.id.text_textview); - uiTitle.setText(intent.getStringExtra("title")); + uiTitle.setTitle(intent.getStringExtra("title")); uiText.setText(Html.fromHtml(intent.getStringExtra("text"))); //fromHtml(, new MImageGetter(uiText, ctx), null) } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/ThemeActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/ThemeActivity.java index 0052cde..a7f3e31 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/ThemeActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/ThemeActivity.java @@ -1,6 +1,7 @@ package cn.luern0313.wristbilibili.ui; import android.animation.ObjectAnimator; +import android.annotation.SuppressLint; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; @@ -18,21 +19,27 @@ import androidx.recyclerview.widget.RecyclerView; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.adapter.ThemeAdapter; +import cn.luern0313.wristbilibili.util.ListViewTouchListener; import cn.luern0313.wristbilibili.util.ThemeUtil; +import cn.luern0313.wristbilibili.widget.TitleView; -public class ThemeActivity extends AppCompatActivity +public class ThemeActivity extends AppCompatActivity implements TitleView.TitleViewListener { private Context ctx; + private TitleView titleView; + + @SuppressLint("ClickableViewAccessibility") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ThemeUtil.changeTheme(this, ThemeUtil.getCurrentTheme()); setContentView(R.layout.activity_theme); - ctx = this; + titleView = findViewById(R.id.theme_title); + ThemeAdapter.ThemeAdapterListener themeAdapterListener = new ThemeAdapter.ThemeAdapterListener() { @Override @@ -53,6 +60,7 @@ public void onChangeTheme(ViewGroup group, int primary, int fore) ThemeAdapter themeAdapter = new ThemeAdapter(ctx, getLayoutInflater(), themeAdapterListener, recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); + recyclerView.setOnTouchListener(new ListViewTouchListener(recyclerView, (TitleView.TitleViewListener) ctx)); recyclerView.setAdapter(themeAdapter); } @@ -63,23 +71,13 @@ private void changeTheme(ViewGroup group, @ColorInt int primary, @ColorInt int f { View v = group.getChildAt(i); if(v instanceof ViewGroup) - { changeTheme((ViewGroup) v, primary, fore); - } - if(v.getId() == R.id.theme_title_layout) - { + if(v.getId() == R.id.theme_title) animate(v, "backgroundColor", ((ColorDrawable) v.getBackground()).getColor(), primary); - } else if (v.getId() == R.id.theme_item_name) - { - //noinspection ConstantConditions animate(v, "textColor", ((TextView) v).getTextColors().getDefaultColor(), fore); - } else if (v.getId() == R.id.theme_item_check) - { - //noinspection ConstantConditions ((ImageView) v).getDrawable().applyTheme(getTheme()); - } } } @@ -97,4 +95,16 @@ public void finish() super.finish(); AppCompatDelegate.setDefaultNightMode(ThemeUtil.getCurrentTheme().isDarkTheme() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO); } + + @Override + public boolean hideTitle() + { + return titleView.hide(); + } + + @Override + public boolean showTitle() + { + return titleView.show(); + } } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/UnsupportedLinkActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/UnsupportedLinkActivity.java index 7cd3ca3..b235e48 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/UnsupportedLinkActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/UnsupportedLinkActivity.java @@ -14,7 +14,6 @@ import java.io.IOException; -import androidx.appcompat.app.AppCompatActivity; import cn.luern0313.wristbilibili.R; import cn.luern0313.wristbilibili.api.UnsupportedLinkApi; import cn.luern0313.wristbilibili.models.UnsupportedLinkModel; @@ -56,44 +55,29 @@ protected void onCreate(Bundle savedInstanceState) ((TextView) findViewById(R.id.ul_link)).setText(unsupportedLinkApi.getUrl()); ((ImageView) findViewById(R.id.ul_qr)).setImageBitmap(QRCodeUtil.createQRCodeBitmap(unsupportedLinkApi.getUrl(), 120, 120)); - runnableUi = new Runnable() - { - @Override - public void run() - { - findViewById(R.id.ul_loading).setVisibility(View.GONE); - ((HtmlTextView) findViewById(R.id.ul_info)).setHtml(unsupportedLinkModel.getDetail()); - } + runnableUi = () -> { + findViewById(R.id.ul_loading).setVisibility(View.GONE); + ((HtmlTextView) findViewById(R.id.ul_info)).setHtml(unsupportedLinkModel.getDetail()); }; - runnableErr = new Runnable() - { - @Override - public void run() - { - findViewById(R.id.ul_loading).setVisibility(View.GONE); - ((HtmlTextView) findViewById(R.id.ul_info)).setHtml("获取页面信息失败"); - } + runnableErr = () -> { + findViewById(R.id.ul_loading).setVisibility(View.GONE); + ((HtmlTextView) findViewById(R.id.ul_info)).setHtml("获取页面信息失败"); }; - new Thread(new Runnable() - { - @Override - public void run() + new Thread(() -> { + try { - try - { - unsupportedLinkModel = unsupportedLinkApi.getUnsupportedLink(); - if(unsupportedLinkModel != null) - handler.post(runnableUi); - else - handler.post(runnableErr); - } - catch (IOException | IllegalArgumentException e) - { - e.printStackTrace(); + unsupportedLinkModel = unsupportedLinkApi.getUnsupportedLink(); + if(unsupportedLinkModel != null) + handler.post(runnableUi); + else handler.post(runnableErr); - } + } + catch (IOException | IllegalArgumentException e) + { + e.printStackTrace(); + handler.post(runnableErr); } }).start(); } diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/UserActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/UserActivity.java index d769f64..0842987 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/UserActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/UserActivity.java @@ -9,9 +9,7 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; -import android.widget.TextView; import android.widget.Toast; -import android.widget.ViewFlipper; import org.greenrobot.eventbus.EventBus; @@ -32,6 +30,7 @@ import cn.luern0313.wristbilibili.fragment.user.UserVideoFragment; import cn.luern0313.wristbilibili.models.UserModel; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; /** * 被 luern0313 创建于 不知道什么时候. @@ -41,7 +40,7 @@ * * ok现在好多了 */ -public class UserActivity extends BaseActivity implements UserDetailFragment.UserDetailFragmentListener +public class UserActivity extends BaseActivity implements UserDetailFragment.UserDetailFragmentListener, TitleView.TitleViewListener { Context ctx; Intent intent; @@ -53,7 +52,7 @@ public class UserActivity extends BaseActivity implements UserDetailFragment.Use Handler handler = new Handler(); Runnable runnableUi, runnableNoWeb, runnableNothing; - ViewFlipper uiTitle; + TitleView uiTitleView; ViewPager uiViewPager; ImageView uiLoading; @@ -68,7 +67,7 @@ protected void onCreate(Bundle savedInstanceState) inflater = getLayoutInflater(); userApi = new UserApi(intent.getStringExtra("mid")); - uiTitle = findViewById(R.id.user_title_title); + uiTitleView = findViewById(R.id.user_title); uiViewPager = findViewById(R.id.user_viewpager); uiLoading = findViewById(R.id.ou_loading_img); @@ -79,7 +78,7 @@ protected void onCreate(Bundle savedInstanceState) findViewById(R.id.user_noweb).setVisibility(View.GONE); for (int i = 1; i < userModel.getTab().size(); i++) - ((ViewFlipper) findViewById(R.id.user_title_title)).addView(getTitleTextView(userModel.getTab().get(i).get(1))); + uiTitleView.addTitle(userModel.getTab().get(i).get(1)); uiViewPager.setAdapter(pagerAdapter); }; @@ -131,19 +130,20 @@ public void onPageScrollStateChanged(int state) @Override public void onPageSelected(int position) { - while(uiTitle.getDisplayedChild() != position) + while(uiTitleView.getDisplayedChild() != position) { - if(uiTitle.getDisplayedChild() < position) + uiTitleView.show(); + if(uiTitleView.getDisplayedChild() < position) { - uiTitle.setInAnimation(ctx, R.anim.slide_in_right); - uiTitle.setOutAnimation(ctx, R.anim.slide_out_left); - uiTitle.showNext(); + uiTitleView.setInAnimation(ctx, R.anim.slide_in_right); + uiTitleView.setOutAnimation(ctx, R.anim.slide_out_left); + uiTitleView.showNext(); } else { - uiTitle.setInAnimation(ctx, android.R.anim.slide_in_left); - uiTitle.setOutAnimation(ctx, android.R.anim.slide_out_right); - uiTitle.showPrevious(); + uiTitleView.setInAnimation(ctx, android.R.anim.slide_in_left); + uiTitleView.setOutAnimation(ctx, android.R.anim.slide_out_right); + uiTitleView.showPrevious(); } } } @@ -153,10 +153,8 @@ public void onPageSelected(int position) try { userModel = userApi.getUserInfo(); - if(userModel != null) - handler.post(runnableUi); - else - handler.post(runnableNothing); + if(userModel != null) handler.post(runnableUi); + else handler.post(runnableNothing); } catch (IOException e) { @@ -166,14 +164,6 @@ public void onPageSelected(int position) }).start(); } - private TextView getTitleTextView(String title) - { - TextView t = new TextView(ctx); - t.setText(title); - t.setTextColor(getResources().getColor(R.color.white)); - return t; - } - @Override public void onUserDetailFragmentViewClick(int viewId) { @@ -268,6 +258,18 @@ private int getPositionFormTab(String tabName) return -1; } + @Override + public boolean hideTitle() + { + return uiTitleView.hide(); + } + + @Override + public boolean showTitle() + { + return uiTitleView.show(); + } + class UserFragmentPagerAdapter extends FragmentPagerAdapter { private final String selfMid; diff --git a/app/src/main/java/cn/luern0313/wristbilibili/ui/VideoActivity.java b/app/src/main/java/cn/luern0313/wristbilibili/ui/VideoActivity.java index ca6e8b5..0654f51 100644 --- a/app/src/main/java/cn/luern0313/wristbilibili/ui/VideoActivity.java +++ b/app/src/main/java/cn/luern0313/wristbilibili/ui/VideoActivity.java @@ -14,7 +14,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Toast; -import android.widget.ViewFlipper; import org.greenrobot.eventbus.EventBus; @@ -37,8 +36,9 @@ import cn.luern0313.wristbilibili.models.VideoModel; import cn.luern0313.wristbilibili.service.DownloadService; import cn.luern0313.wristbilibili.util.SharedPreferencesUtil; +import cn.luern0313.wristbilibili.widget.TitleView; -public class VideoActivity extends BaseActivity implements VideoDetailFragment.VideoDetailFragmentListener +public class VideoActivity extends BaseActivity implements VideoDetailFragment.VideoDetailFragmentListener, TitleView.TitleViewListener { Context ctx; Intent intent; @@ -55,7 +55,7 @@ public class VideoActivity extends BaseActivity implements VideoDetailFragment.V AnimationDrawable loadingImgAnim; - ViewFlipper uiTitle; + TitleView uiTitleView; ViewPager uiViewPager; View layoutSendReply, layoutLoading; ImageView uiLoadingImg; @@ -98,7 +98,7 @@ protected void onCreate(Bundle savedInstanceState) layoutSendReply = inflater.inflate(R.layout.widget_reply_sendreply, null); layoutLoading = inflater.inflate(R.layout.widget_loading, null); - uiTitle = findViewById(R.id.vd_title_title); + uiTitleView = findViewById(R.id.vd_title); uiViewPager = findViewById(R.id.vd_viewpager); uiViewPager.setOffscreenPageLimit(2); uiLoadingImg = findViewById(R.id.vd_loading_img); @@ -187,19 +187,20 @@ public void onPageScrollStateChanged(int state) @Override public void onPageSelected(int position) { - while(uiTitle.getDisplayedChild() != position) + while(uiTitleView.getDisplayedChild() != position) { - if(uiTitle.getDisplayedChild() < position) + uiTitleView.show(); + if(uiTitleView.getDisplayedChild() < position) { - uiTitle.setInAnimation(ctx, R.anim.slide_in_right); - uiTitle.setOutAnimation(ctx, R.anim.slide_out_left); - uiTitle.showNext(); + uiTitleView.setInAnimation(ctx, R.anim.slide_in_right); + uiTitleView.setOutAnimation(ctx, R.anim.slide_out_left); + uiTitleView.showNext(); } else { - uiTitle.setInAnimation(ctx, android.R.anim.slide_in_left); - uiTitle.setOutAnimation(ctx, android.R.anim.slide_out_right); - uiTitle.showPrevious(); + uiTitleView.setInAnimation(ctx, android.R.anim.slide_in_left); + uiTitleView.setOutAnimation(ctx, android.R.anim.slide_out_right); + uiTitleView.showPrevious(); } } } @@ -697,6 +698,18 @@ public void setVideoDetailActivityListener(VideoDetailActivityListener videoDeta this.videoDetailActivityListener = videoDetailActivityListener; } + @Override + public boolean hideTitle() + { + return uiTitleView.hide(); + } + + @Override + public boolean showTitle() + { + return uiTitleView.show(); + } + class VideoDownloadServiceConnection implements ServiceConnection { @Override diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 23d7309..d22a393 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -1,101 +1,76 @@ + android:layout_height="match_parent" + tools:ignore="SmallSp"> + android:orientation="vertical" + android:paddingLeft="19dp" + android:paddingRight="19dp"> - + app:mode="back" + app:title="@string/about_title" /> - + - - - + - - - - - - - - - + android:text="@string/about_app_desc" + android:textSize="12sp" /> - + - + - - + + + diff --git a/app/src/main/res/layout/activity_article.xml b/app/src/main/res/layout/activity_article.xml index 7526eaf..44dd62f 100644 --- a/app/src/main/res/layout/activity_article.xml +++ b/app/src/main/res/layout/activity_article.xml @@ -1,67 +1,28 @@ - - - - - - - - - - - - - - - + android:layout_height="match_parent" + tools:ignore="ContentDescription"> + android:layout_height="match_parent" /> + + @@ -87,7 +48,7 @@ android:id="@+id/art_noweb" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/art_title_layout" + android:layout_below="@+id/art_title" android:background="?android:attr/colorBackground" android:clickable="true" android:focusable="true" @@ -100,12 +61,12 @@ android:layout_width="wrap_content" android:layout_height="92dp" android:padding="6dp" - android:src="@drawable/img_noweb" /> + android:src="@drawable/img_no_web" /> @@ -113,7 +74,7 @@ android:id="@+id/art_novideo" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/art_title_layout" + android:layout_below="@+id/art_title" android:background="?android:attr/colorBackground" android:clickable="true" android:focusable="true" @@ -131,9 +92,8 @@ - diff --git a/app/src/main/res/layout/activity_bangumi.xml b/app/src/main/res/layout/activity_bangumi.xml index 968aa8c..7838bc8 100644 --- a/app/src/main/res/layout/activity_bangumi.xml +++ b/app/src/main/res/layout/activity_bangumi.xml @@ -1,78 +1,31 @@ - - - - - - - - - - - - - - - - - + android:layout_height="match_parent" + tools:ignore="ContentDescription"> + android:layout_height="match_parent" /> + + @@ -95,9 +48,10 @@ android:id="@+id/bgm_noweb" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/bgm_title_layout" + android:layout_below="@+id/bgm_title" android:background="?android:attr/colorBackground" android:clickable="true" + android:focusable="true" android:gravity="center" android:orientation="vertical" android:paddingBottom="33dp" @@ -107,12 +61,12 @@ android:layout_width="wrap_content" android:layout_height="92dp" android:padding="6dp" - android:src="@drawable/img_noweb" /> + android:src="@drawable/img_no_web" /> @@ -120,9 +74,10 @@ android:id="@+id/bgm_novideo" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/bgm_title_layout" + android:layout_below="@+id/bgm_title" android:background="?android:attr/colorBackground" android:clickable="true" + android:focusable="true" android:gravity="center" android:orientation="vertical" android:paddingBottom="33dp" @@ -137,7 +92,7 @@ diff --git a/app/src/main/res/layout/activity_checkreply.xml b/app/src/main/res/layout/activity_checkreply.xml index 3e5db2a..7d865cd 100644 --- a/app/src/main/res/layout/activity_checkreply.xml +++ b/app/src/main/res/layout/activity_checkreply.xml @@ -1,39 +1,19 @@ - - - - - - - + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:layout_height="match_parent"/> + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_dynamic_detail.xml b/app/src/main/res/layout/activity_dynamic_detail.xml index 7813d1c..8cd9447 100644 --- a/app/src/main/res/layout/activity_dynamic_detail.xml +++ b/app/src/main/res/layout/activity_dynamic_detail.xml @@ -1,66 +1,28 @@ - - - - - - - - - - - - - - - - + android:layout_height="match_parent" + tools:ignore="ContentDescription"> + android:layout_height="match_parent" /> + + @@ -85,7 +47,7 @@ android:id="@+id/dynamic_detail_noweb" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/dynamic_detail_title_layout" + android:layout_below="@+id/dynamic_detail_title" android:background="?android:attr/colorBackground" android:clickable="true" android:focusable="true" @@ -98,12 +60,12 @@ android:layout_width="wrap_content" android:layout_height="92dp" android:padding="6dp" - android:src="@drawable/img_noweb" /> + android:src="@drawable/img_no_web" /> @@ -111,7 +73,7 @@ android:id="@+id/dynamic_detail_nothing" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/dynamic_detail_title_layout" + android:layout_below="@+id/dynamic_detail_title" android:background="?android:attr/colorBackground" android:clickable="true" android:focusable="true" @@ -124,12 +86,12 @@ android:layout_width="wrap_content" android:layout_height="92dp" android:padding="6dp" - android:src="@drawable/img_noweb" /> + android:src="@drawable/img_no_web" /> diff --git a/app/src/main/res/layout/activity_favor_article.xml b/app/src/main/res/layout/activity_favor_article.xml index 55ebdc0..e8ecf26 100644 --- a/app/src/main/res/layout/activity_favor_article.xml +++ b/app/src/main/res/layout/activity_favor_article.xml @@ -1,40 +1,17 @@ - - - - - - - + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:layout_height="match_parent" /> + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_favor_video.xml b/app/src/main/res/layout/activity_favor_video.xml index 5fbd9f9..00c1211 100644 --- a/app/src/main/res/layout/activity_favor_video.xml +++ b/app/src/main/res/layout/activity_favor_video.xml @@ -1,53 +1,48 @@ + android:layout_height="match_parent" + tools:ignore="ContentDescription"> - + android:layout_height="match_parent"> - + + - - + + android:src="@drawable/img_no_web" /> + android:src="@drawable/img_no_data" /> - - - - - - diff --git a/app/src/main/res/layout/activity_followme.xml b/app/src/main/res/layout/activity_followme.xml index 3d4ba90..4fccaac 100644 --- a/app/src/main/res/layout/activity_followme.xml +++ b/app/src/main/res/layout/activity_followme.xml @@ -3,40 +3,20 @@ 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:layout_height="match_parent" + tools:ignore="SmallSp,ContentDescription"> - - - - - - - + app:mode="back" + app:title="@string/follow_me_title" /> + android:layout_below="@+id/fme_title"> @@ -78,13 +58,30 @@ android:layout_height="52dp" android:src="@drawable/img_temp" /> + + @@ -95,12 +92,12 @@ android:layout_below="@+id/fme_card_name" android:layout_marginStart="6dp" android:layout_toEndOf="@+id/fme_card_head" - android:background="@drawable/shape_lvbg_fme" + android:background="@drawable/shape_bg_fme_lv" android:paddingLeft="4dp" android:paddingTop="1dp" android:paddingRight="4dp" android:paddingBottom="1dp" - android:text="LV6" + android:text="@string/follow_me_follow_lv" android:textColor="?attr/colorAccent" android:textSize="8sp" /> @@ -111,27 +108,12 @@ android:layout_below="@+id/fme_card_name" android:layout_marginStart="4dp" android:layout_marginTop="-1dp" + android:layout_toStartOf="@id/fme_card_button" android:layout_toEndOf="@+id/fme_card_lv" - android:text="" + android:text="@string/follow_me_follow_lv" android:textColor="?attr/colorTitle" - android:textSize="10sp" - tools:text="123" /> + android:textSize="10sp" /> - @@ -141,7 +123,7 @@ android:layout_height="wrap_content" android:layout_marginTop="4dp" android:gravity="center_horizontal" - android:text="↓ ↓ 最新投稿 ↓ ↓" + android:text="" android:textSize="12sp" /> @@ -173,7 +156,7 @@ android:layout_toEndOf="@id/fme_video_img" android:ellipsize="end" android:maxLines="3" - android:text="请稍后..." + android:text="@string/main_tip_loading" android:textSize="12sp" /> @@ -197,14 +180,12 @@ android:gravity="center_horizontal" android:text="这个视频参加了“互动游戏开发大赛”,点击按钮为这个作品投一票~\n(之后一定要去亲自玩玩看!)" android:textColor="@color/white" - android:textSize="10dp" /> + android:textSize="10sp" /> @@ -295,6 +277,7 @@ android:background="?android:attr/selectableItemBackground" android:clickable="true" android:descendantFocusability="blocksDescendants" + android:focusable="true" android:gravity="center_horizontal" android:orientation="vertical" android:paddingTop="4dp" @@ -310,7 +293,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:text="给这个视频投币" + android:text="@string/follow_me_video_coin" android:textSize="11sp" /> @@ -323,10 +306,11 @@ android:id="@+id/fme_nologin" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/fme_title_layout" + android:layout_below="@+id/fme_title" android:layout_centerInParent="true" android:background="?android:attr/colorBackground" android:clickable="true" + android:focusable="true" android:gravity="center_horizontal" android:orientation="vertical" android:paddingTop="20dp" @@ -335,14 +319,13 @@ + android:text="@string/main_tip_no_login2" /> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_joinqq.xml b/app/src/main/res/layout/activity_joinqq.xml index 2914cfd..11ee531 100644 --- a/app/src/main/res/layout/activity_joinqq.xml +++ b/app/src/main/res/layout/activity_joinqq.xml @@ -1,7 +1,10 @@ + android:layout_height="match_parent" + tools:ignore="ContentDescription"> - - - - - - - + app:title="@string/join_qq_title" /> + android:text="@string/join_qq_report_bug" /> + android:layout_height="match_parent" + tools:ignore="ContentDescription"> - - - - - - - + android:layout_height="wrap_content" + app:title="@string/login_title" /> @@ -85,9 +66,9 @@ android:layout_height="120dp" android:layout_centerHorizontal="true" android:layout_gravity="center_horizontal" - android:layout_marginBottom="10dp" android:layout_marginTop="8dp" - android:src="@drawable/ic_qrloading" /> + android:layout_marginBottom="10dp" + android:src="@drawable/icon_qrloading" />