2222import android .widget .Toast ;
2323
2424import com .google .android .material .floatingactionbutton .FloatingActionButton ;
25- import com .google .android .material .snackbar .BaseTransientBottomBar ;
2625import com .google .android .material .snackbar .Snackbar ;
2726
2827import java .io .File ;
@@ -57,13 +56,13 @@ protected void onCreate(Bundle savedInstanceState) {
5756 Toolbar toolbar = findViewById (R .id .toolbar );
5857 Button searchButton = findViewById (R .id .searchButton );
5958 inputTextView = findViewById (R .id .inputText );
60- inputTextView .setText ("ss25696" );//调试用
59+ // inputTextView.setText("ss25696");//调试用
6160 infoListView = findViewById (R .id .infoListView );
6261 infoListView .setAdapter (new ArrayAdapter <>(MainActivity .this , R .layout .support_simple_spinner_dropdown_item , seriesInfo .epInfo ));
6362 titleTextView = findViewById (R .id .titleTextView );
6463 LoadCookies ();
6564 LoadHistory ();
66- Settings .videoQuality = VideoQuality .list [Arrays .asList (VideoQuality .getEntries ()).indexOf (Objects .requireNonNull (getSharedPreferences ("Settings" , Context .MODE_PRIVATE ).getString ("quality" , "超清" )))];
65+ Settings .videoQuality = VideoQuality .list [Arrays .asList (VideoQuality .getEntries ()).indexOf (Objects .requireNonNull (getSharedPreferences ("Settings" , Context .MODE_PRIVATE ).getString ("quality" , VideoQuality . _2 . description )))];
6766 Settings .clientDownload = getSharedPreferences ("Settings" , Context .MODE_PRIVATE ).getBoolean ("clientDown" , true );
6867 searchButton .setOnClickListener (v -> {
6968 String URL = inputTextView .getText ().toString ();
@@ -101,14 +100,25 @@ protected void onPostExecute(String successMsg) {
101100 }
102101 Toast .makeText (MainActivity .this , "成功: 正在下载文件" , Toast .LENGTH_LONG ).show ();
103102 }
103+ int position = HistoryList .get (0 ).position ;//历史记录中的位置
104+ if (position != seriesInfo .position ) {
105+ if (position != -1 ) {
106+ EpInfo epInfo = seriesInfo .epInfo .get (position );
107+ epInfo .index_title = epInfo .index_title .substring (0 , epInfo .index_title .length () - 1 );
108+ }
109+ seriesInfo .epInfo .get (seriesInfo .position ).index_title += "☆" ;
110+ ((ArrayAdapter ) infoListView .getAdapter ()).notifyDataSetChanged ();
111+ HistoryList .get (0 ).position = seriesInfo .position ;
112+ StoreHistory (getApplicationContext ());
113+ }
104114 }
105115 }.execute ();
106116
107117 });
108118 setSupportActionBar (toolbar );
109119
110120 FloatingActionButton fab = findViewById (R .id .fab );
111- fab .setOnClickListener (view -> Snackbar .make (view , "Replace with your own action" , BaseTransientBottomBar .LENGTH_LONG )
121+ fab .setOnClickListener (view -> Snackbar .make (view , "Replace with your own action" , Snackbar .LENGTH_LONG )
112122 .setAction ("Action" , null ).show ());
113123 CheckPermissions ();
114124 }
@@ -178,7 +188,6 @@ protected void onCancelled(String errorMsg) {
178188
179189 @ Override
180190 protected void onPostExecute (String HTMLBody ) {
181- ((ArrayAdapter ) infoListView .getAdapter ()).notifyDataSetChanged ();
182191 titleTextView .setText (seriesInfo .title );
183192 //添加historylist
184193 String url ;
@@ -193,9 +202,15 @@ protected void onPostExecute(String HTMLBody) {
193202 url = "ss" ;
194203 break ;
195204 }
196- HistoryInfo info = new HistoryInfo (seriesInfo .title , url + seriesInfo .season_id );
197- HistoryList .remove (info );
205+ HistoryInfo info = new HistoryInfo (seriesInfo .title , url + seriesInfo .season_id , -1 );
206+ int position = HistoryList .indexOf (info );
207+ if (position > -1 ) {
208+ info .position = HistoryList .get (position ).position ;
209+ if (info .position > -1 ) seriesInfo .epInfo .get (info .position ).index_title += "☆" ;
210+ HistoryList .remove (position );
211+ }
198212 HistoryList .add (0 , info );
213+ ((ArrayAdapter ) infoListView .getAdapter ()).notifyDataSetChanged ();
199214 StoreHistory (getApplicationContext ());
200215 }
201216
@@ -247,7 +262,6 @@ public void onPageFinished(WebView view, String url) {
247262 .setTitle ("获取BiliPlus cookies" )
248263 .setView (webView )
249264 .setNegativeButton ("Close" , (dialog , id ) -> dialog .dismiss ())
250-
251265 .show ();
252266 }
253267
@@ -263,14 +277,12 @@ void LoadCookies() {
263277 }
264278
265279 void LoadHistory () {
266- SharedPreferences sharedPref = getPreferences (Context .MODE_PRIVATE );
267- List <String > HistoryStrList = new ArrayList <>(Objects .requireNonNull (sharedPref .getStringSet ("HistoryList" , new HashSet <>())));
280+ List <String > HistoryStrList = new ArrayList <>(Objects .requireNonNull (getSharedPreferences ("MainActivity" , Context .MODE_PRIVATE ).getStringSet ("HistoryList" , new HashSet <>())));
268281 Collections .sort (HistoryStrList );
269282 for (String history : HistoryStrList ) {
270283 String [] historys = history .split (";" );
271- HistoryList .add (new HistoryInfo (historys [1 ], historys [2 ]));
284+ HistoryList .add (new HistoryInfo (historys [1 ], historys [2 ], Integer . parseInt ( historys [ 3 ]) ));
272285 }
273-
274286 }
275287
276288 void ClearHistory () {
@@ -282,7 +294,7 @@ static void StoreHistory(Context context) {
282294 HashSet <String > HistoryStrSet = new HashSet <>();
283295 for (int i = 0 ; i < HistoryList .size (); i ++) {
284296 HistoryInfo info = HistoryList .get (i );
285- HistoryStrSet .add (i + ";" + info .title + ";" + info .url );
297+ HistoryStrSet .add (i + ";" + info .title + ";" + info .url + ";" + info . position );
286298 }
287299 SharedPreferences sharedPref = context .getSharedPreferences ("MainActivity" , Context .MODE_PRIVATE );
288300 sharedPref .edit ().putStringSet ("HistoryList" , HistoryStrSet ).apply ();
0 commit comments