From cba86340aeb2611de1616790a0ddbd20be131f09 Mon Sep 17 00:00:00 2001 From: 21561 <215613905@qq.com> Date: Sat, 8 Mar 2025 13:08:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=9B=B4=E6=92=AD=E5=8F=B3?= =?UTF-8?q?=E4=B8=8A=E8=A7=92=E4=B9=B1=E9=97=AA=20=E4=BC=98=E5=8C=96epg?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=80=BB=E8=BE=91=20=E8=BF=98=E5=8E=9F?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E6=89=93=E5=8C=85gradle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../osc/ui/activity/LivePlayActivity.java | 106 +++++++++--------- .../main/res/layout/activity_live_play.xml | 45 ++------ gradle.properties | 2 +- 3 files changed, 64 insertions(+), 89 deletions(-) diff --git a/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java b/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java index e2bd29d0..9c43cbc5 100644 --- a/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java +++ b/app/src/main/java/com/github/tvbox/osc/ui/activity/LivePlayActivity.java @@ -9,7 +9,6 @@ import android.content.Context; import android.net.Uri; import android.os.CountDownTimer; import android.os.Handler; -import android.os.Looper; import android.util.Base64; import android.util.Log; import android.view.Gravity; @@ -79,7 +78,6 @@ import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.Hashtable; @@ -127,7 +125,7 @@ public class LivePlayActivity extends BaseActivity { //EPG by 龍 private static LiveChannelItem channel_Name = null; - private static Hashtable hsEpg = new Hashtable(); + private static Hashtable> hsEpg = new Hashtable(); private CountDownTimer countDownTimer; // private CountDownTimer countDownTimerRightTop; private View ll_right_top_loading; @@ -226,7 +224,7 @@ public class LivePlayActivity extends BaseActivity { tv_curepg_left = (TextView) findViewById(R.id.tv_current_program);//当前节目 tv_nextepg_left= (TextView) findViewById(R.id.tv_current_program);//下一节目 ll_epg = (RelativeLayout) findViewById(R.id.ll_epg); - tv_right_top_tipnetspeed = (TextView)findViewById(R.id.tv_right_top_tipnetspeed); +// tv_right_top_tipnetspeed = (TextView)findViewById(R.id.tv_right_top_tipnetspeed); tv_right_top_channel_name = (TextView)findViewById(R.id.tv_right_top_channel_name); tv_right_top_epg_name = (TextView)findViewById(R.id.tv_right_top_epg_name); // tv_right_top_type = (TextView)findViewById(R.id.tv_right_top_type); @@ -323,18 +321,10 @@ public class LivePlayActivity extends BaseActivity { if (!fromuser) { return; } - if(fromuser){ - if(countDownTimer!=null){ - mVideoView.seekTo(progress); - countDownTimer.cancel(); - countDownTimer.start(); - } -/* - long duration = mControlWrapper.getDuration(); - long newPosition = (duration * progress) / seekBar.getMax(); - if (mCurrentTime != null) - mCurrentTime.setText(stringForTime((int) newPosition));*/ - + if(countDownTimer!=null){ + mVideoView.seekTo(progress); + countDownTimer.cancel(); + countDownTimer.start(); } } @@ -406,33 +396,52 @@ public class LivePlayActivity extends BaseActivity { } } + private String getFirstPartBeforeSpace(String str) { + if (str == null || str.isEmpty()) { + return str; + } + int spaceIndex = str.indexOf(' '); + if (spaceIndex == -1) { + return str; + } else { + return str.substring(0, spaceIndex); + } + } + public void getEpg(Date date) { String channelName = channel_Name.getChannelName(); + String channelNameReal = getFirstPartBeforeSpace(channelName); @SuppressLint("SimpleDateFormat") SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd"); timeFormat.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); - String[] epgInfo = EpgUtil.getEpgInfo(channelName); - String epgTagName = channelName; + String[] epgInfo = EpgUtil.getEpgInfo(channelNameReal); + String epgTagName = channelNameReal; updateChannelIcon(channelName, epgInfo == null ? null : epgInfo[0]); if (epgInfo != null && !epgInfo[1].isEmpty()) { epgTagName = epgInfo[1]; } epgListAdapter.CanBack(currentLiveChannelItem.getinclude_back()); - String url; if(epgStringAddress.contains("{name}") && epgStringAddress.contains("{date}")){ url= epgStringAddress.replace("{name}",URLEncoder.encode(epgTagName)).replace("{date}",timeFormat.format(date)); }else { url= epgStringAddress + "?ch="+ URLEncoder.encode(epgTagName) + "&date=" + timeFormat.format(date); } + + String savedEpgKey = channelName + "_" + Objects.requireNonNull(liveEpgDateAdapter.getItem(liveEpgDateAdapter.getSelectedIndex())).getDatePresented(); + if (hsEpg.containsKey(savedEpgKey)){ + showEpg(date, hsEpg.get(savedEpgKey)); + showBottomEpg(); + return; + } UrlHttpUtil.get(url, new CallBackUtil.CallBackString() { public void onFailure(int i, String str) { - showEpg(date, new ArrayList()); - showBottomEpg(); +// showEpg(date, new ArrayList<>()); +// showBottomEpg(); } public void onResponse(String paramString) { - - ArrayList arrayList = new ArrayList(); + LOG.i("echo-epgTagName:"+channelNameReal); + ArrayList arrayList = new ArrayList(); try { if (paramString.contains("epg_data")) { final JSONArray jSONArray = new JSONObject(paramString).optJSONArray("epg_data"); @@ -441,17 +450,14 @@ public class LivePlayActivity extends BaseActivity { JSONObject jSONObject = jSONArray.getJSONObject(b); Epginfo epgbcinfo = new Epginfo(date,jSONObject.optString("title"), date, jSONObject.optString("start"), jSONObject.optString("end"),b); arrayList.add(epgbcinfo); -// Log.d("EPG信息:", day +" "+ jSONObject.optString("start") +" - "+jSONObject.optString("end") + " " +jSONObject.optString("title")); } } } catch (JSONException jSONException) { jSONException.printStackTrace(); } + hsEpg.put(savedEpgKey, arrayList); showEpg(date, arrayList); - String savedEpgKey = channelName + "_" + liveEpgDateAdapter.getItem(liveEpgDateAdapter.getSelectedIndex()).getDatePresented(); - if (!hsEpg.contains(savedEpgKey)) - hsEpg.put(savedEpgKey, arrayList); showBottomEpg(); } }); @@ -472,27 +478,36 @@ public class LivePlayActivity extends BaseActivity { tip_epg2.setText("开源测试软件"); tv_next_program_name.setText(""); String savedEpgKey = channel_Name.getChannelName() + "_" + Objects.requireNonNull(liveEpgDateAdapter.getItem(liveEpgDateAdapter.getSelectedIndex())).getDatePresented(); + if (hsEpg.containsKey(savedEpgKey)) { - ArrayList arrayList = (ArrayList) hsEpg.get(savedEpgKey); + ArrayList arrayList = hsEpg.get(savedEpgKey); if (arrayList != null && arrayList.size() > 0) { Date date = new Date(); int size = arrayList.size() - 1; + boolean hasInfo = false; while (size >= 0) { - if (date.after(((Epginfo) arrayList.get(size)).startdateTime) & date.before(((Epginfo) arrayList.get(size)).enddateTime)) { - tip_epg1.setText(((Epginfo) arrayList.get(size)).start + "-" + ((Epginfo) arrayList.get(size)).end); - tv_current_program_name.setText(((Epginfo) arrayList.get(size)).title); + if (date.after((arrayList.get(size)).startdateTime) & date.before((arrayList.get(size)).enddateTime)) { + tip_epg1.setText((arrayList.get(size)).start + "-" + (arrayList.get(size)).end); + tv_current_program_name.setText((arrayList.get(size)).title); if (size != arrayList.size() - 1) { - tip_epg2.setText(((Epginfo) arrayList.get(size + 1)).start + "-" + ((Epginfo) arrayList.get(size + 1)).end); - tv_next_program_name.setText(((Epginfo) arrayList.get(size + 1)).title); + tip_epg2.setText((arrayList.get(size + 1)).start + "-" + (arrayList.get(size + 1)).end); + tv_next_program_name.setText((arrayList.get(size + 1)).title); } else { - tip_epg2.setText("00:00-23:59"); + tip_epg2.setText((arrayList.get(size)).end+"-23:59"); tv_next_program_name.setText("精彩节目-暂无节目预告信息"); } + hasInfo=true; break; } else { size--; } } + if(!hasInfo){ + tip_epg1.setText("00:00-"+(arrayList.get(0)).start); + tv_current_program_name.setText("精彩节目-暂无节目预告信息"); + tip_epg2.setText((arrayList.get(0)).start + "-" + (arrayList.get(0)).end); + tv_next_program_name.setText((arrayList.get(0)).title); + } } epgListAdapter.CanBack(currentLiveChannelItem.getinclude_back()); epgListAdapter.setNewData(arrayList); @@ -500,24 +515,27 @@ public class LivePlayActivity extends BaseActivity { int selectedIndex = liveEpgDateAdapter.getSelectedIndex(); if (selectedIndex < 0) getEpg(new Date()); - else - getEpg(liveEpgDateAdapter.getData().get(selectedIndex).getDateParamVal()); } if (countDownTimer != null) { countDownTimer.cancel(); } if(!tip_epg1.getText().equals("暂无信息")){ + ll_right_top_loading.setVisibility(View.VISIBLE); ll_epg.setVisibility(View.VISIBLE); countDownTimer = new CountDownTimer(postTimeout, 1000) {//底部epg隐藏时间设定 public void onTick(long j) { } public void onFinish() { + ll_right_top_loading.setVisibility(View.GONE); +// ll_right_top_huikan.setVisibility(View.GONE); ll_epg.setVisibility(View.GONE); } }; countDownTimer.start(); }else { + ll_right_top_loading.setVisibility(View.GONE); + ll_right_top_huikan.setVisibility(View.GONE); ll_epg.setVisibility(View.GONE); } if (channel_Name == null || channel_Name.getSourceNum() <= 0) { @@ -527,18 +545,6 @@ public class LivePlayActivity extends BaseActivity { } tv_right_top_channel_name.setText(channel_Name.getChannelName()); tv_right_top_epg_name.setText(channel_Name.getChannelName()); - - Handler handler = new Handler(Looper.getMainLooper()); - ll_right_top_loading.setVisibility(View.VISIBLE); - - // 延迟5秒后执行隐藏操作 - handler.postDelayed(new Runnable() { - @Override - public void run() { - ll_right_top_loading.setVisibility(View.GONE); - ll_right_top_huikan.setVisibility(View.GONE); - } - }, postTimeout); } } @@ -1747,7 +1753,7 @@ public class LivePlayActivity extends BaseActivity { }; private void showNetSpeed() { - tv_right_top_tipnetspeed.setVisibility(View.VISIBLE); +// tv_right_top_tipnetspeed.setVisibility(View.VISIBLE); if (Hawk.get(HawkConfig.LIVE_SHOW_NET_SPEED, false)) { mHandler.post(mUpdateNetSpeedRun); tvNetSpeed.setVisibility(View.VISIBLE); @@ -1763,7 +1769,7 @@ public class LivePlayActivity extends BaseActivity { if (mVideoView == null) return; String speed = PlayerHelper.getDisplaySpeed(mVideoView.getTcpSpeed()); tvNetSpeed.setText(speed); - tv_right_top_tipnetspeed.setText(speed); +// tv_right_top_tipnetspeed.setText(speed); mHandler.postDelayed(this, 1000); } }; diff --git a/app/src/main/res/layout/activity_live_play.xml b/app/src/main/res/layout/activity_live_play.xml index b1e032f6..8b8fc4da 100644 --- a/app/src/main/res/layout/activity_live_play.xml +++ b/app/src/main/res/layout/activity_live_play.xml @@ -718,66 +718,35 @@ - - + android:layout_centerVertical="true" + android:layout_marginRight="@dimen/vs_10" + android:src="@drawable/app_icon" /> - - + android:textSize="@dimen/vs_28" + android:layout_toLeftOf="@id/iv_circle_bg" + android:layout_centerVertical="true" + android:layout_marginRight="10dp" /> diff --git a/gradle.properties b/gradle.properties index 8e1f9a6b..2b801b14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,4 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true IsDebug=true -#org.gradle.jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED +org.gradle.jvmargs=-Xmx2048m --add-opens java.base/java.io=ALL-UNNAMED