Skip to content

Commit 772774a

Browse files
committed
opt: format code
1 parent d37026d commit 772774a

File tree

16 files changed

+45
-91
lines changed

16 files changed

+45
-91
lines changed

src/app.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.
1717

1818
use std::{
19-
io::{stdout, Stdout},
19+
io::stdout,
2020
sync::mpsc,
21-
thread::{self, sleep_ms},
22-
time::{self, Duration, SystemTime},
21+
thread::{self},
2322
vec,
2423
};
2524

2625
use crossterm::{
27-
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode},
26+
event::{self, Event, KeyCode},
2827
execute,
2928
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
3029
};
@@ -33,16 +32,15 @@ use tui::{
3332
backend::{Backend, CrosstermBackend},
3433
layout::{Alignment, Constraint, Direction, Layout, Rect},
3534
style::{Color, Style},
36-
text::{Span, Text},
37-
widgets::{Block, BorderType, Borders, ListState, Paragraph, Widget, Wrap},
35+
text::Text,
36+
widgets::{Block, BorderType, Borders, ListState, Paragraph, Wrap},
3837
Frame, Terminal,
3938
};
4039

4140
use crate::{
4241
config::Config,
4342
fs::FsExplorer,
4443
handler::handle_keyboard_event,
45-
main,
4644
media::player::{MusicPlayer, Player, RadioPlayer},
4745
ui::{
4846
fs::draw_fs_tree,
@@ -231,7 +229,7 @@ impl App {
231229
// .margin(2)
232230
.split(area);
233231
// 左侧
234-
if (self.active_modules == ActiveModules::RadioList) {
232+
if self.active_modules == ActiveModules::RadioList {
235233
draw_radio_list(self, frame, main_layout[0]);
236234
} else {
237235
draw_fs_tree(self, frame, main_layout[0]);

src/handler/fs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use crate::{
2828
media::{Media, Source},
2929
player::Player,
3030
},
31-
ui::fs,
3231
};
3332

3433
fn add_media_to_player(app: &mut App, once: bool) -> bool {

src/handler/music_controller.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.
1717

18-
use std::cmp::max;
19-
2018
use crossterm::event::KeyCode;
2119

22-
use crate::{
23-
app::{ActiveModules, App},
24-
media::player::Player,
25-
};
20+
use crate::{app::App, media::player::Player};
2621

2722
pub fn handle_music_controller(app: &mut App, code: KeyCode) -> bool {
2823
// if app.active_modules != ActiveModules::MusicController {

src/handler/player.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.
1717

18-
use std::cmp::max;
19-
2018
use crossterm::event::KeyCode;
2119

2220
use crate::{app::App, media::player::Player};

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.
1717

1818
use app::*;
19-
use handler::*;
20-
use media::*;
19+
2120
use ui::*;
2221
use util::*;
2322

src/media/player.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,27 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.
1717

18-
use bytes::Bytes;
1918
use std::cmp::max;
20-
use std::fs;
21-
use std::future::Future;
22-
use std::io::Cursor;
23-
use std::sync::mpsc::{Receiver, Sender, TryRecvError};
19+
20+
use std::sync::mpsc::{Receiver, Sender};
2421
use std::{
25-
cell::{Ref, RefCell},
26-
fmt::Debug,
2722
fs::File,
28-
io::{BufReader, Error, Write},
23+
io::{BufReader, Write},
2924
ops::Add,
3025
path::Path,
31-
ptr::null,
32-
sync::{
33-
mpsc::{self, channel},
34-
Arc, Mutex,
35-
},
26+
sync::mpsc::channel,
3627
thread,
3728
time::{Duration, Instant, SystemTime},
3829
};
3930

4031
use m3u8_rs::{MediaPlaylist, Playlist};
41-
use rodio::decoder::DecoderError;
42-
use rodio::{cpal, source::Delay};
43-
use rodio::{Decoder, Devices, OutputStream, OutputStreamHandle, Sink, Source};
32+
33+
use rodio::cpal;
34+
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink, Source};
4435
use tui::widgets::ListState;
4536

46-
use crate::net::download;
37+
use crate::util::lyrics::Lyrics;
4738
use crate::util::m3u8::empty_cache;
48-
use crate::{
49-
app,
50-
util::lyrics::{Lyric, Lyrics},
51-
};
5239
use crate::{m3u8::download_m3u8_playlist, util::net::download_as_bytes};
5340

5441
use super::media::Media;
@@ -159,7 +146,7 @@ impl Player for MusicPlayer {
159146
super::media::Source::Local(path) => {
160147
return self.play_with_file(path, once);
161148
}
162-
super::media::Source::M3u8(path) => false,
149+
super::media::Source::M3u8(_path) => false,
163150
}
164151
}
165152

@@ -448,7 +435,7 @@ impl Player for RadioPlayer {
448435
match src {
449436
super::media::Source::Http(_) => false,
450437
super::media::Source::M3u8(url) => {
451-
let (tx, mut rx) = channel();
438+
let (tx, rx) = channel();
452439
let m3u8_url = url.url.clone();
453440
thread::spawn(move || {
454441
let playlist = download_m3u8_playlist(m3u8_url);
@@ -472,7 +459,7 @@ impl Player for RadioPlayer {
472459
return true;
473460
}
474461
}
475-
Err(err) => {
462+
Err(_err) => {
476463
// ignore
477464
}
478465
}

src/ui/effects.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use std::vec;
2020
use rand::Rng;
2121
use tui::{
2222
backend::Backend,
23-
layout::{Alignment, Constraint, Direction, Layout, Rect},
23+
layout::{Alignment, Rect},
2424
style::{Color, Modifier, Style},
25-
widgets::{BarChart, Block, BorderType, Borders, List, ListItem, Paragraph},
25+
widgets::{BarChart, Block, BorderType, Borders, List, ListItem},
2626
Frame,
2727
};
2828

src/ui/fs.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.
1717

1818
use std::env::current_dir;
19-
use std::fmt::{Debug, Display, Formatter};
20-
use std::fs::{DirEntry, ReadDir};
19+
use std::fmt::Debug;
20+
use std::fs;
21+
use std::fs::DirEntry;
2122
use std::path::Path;
22-
use std::{fs, os};
2323

24-
use crossterm::style::Colors;
2524
use failure::{Error, Fail};
2625
use tui::backend::Backend;
2726
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
2827
use tui::style::{Color, Style};
2928
use tui::text::Text;
30-
use tui::widgets::{
31-
Block, BorderType, Borders, List, ListItem, ListState, Paragraph, Widget, Wrap,
32-
};
29+
use tui::widgets::{Block, BorderType, Borders, List, ListItem, ListState, Paragraph, Wrap};
3330
use tui::Frame;
3431

3532
use crate::app::ActiveModules;

src/ui/help.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@
1717

1818
use std::vec;
1919

20-
use rand::Rng;
2120
use tui::{
2221
backend::Backend,
23-
layout::{self, Alignment, Constraint, Direction, Layout, Rect},
24-
style::{Color, Modifier, Style},
25-
widgets::{BarChart, Block, BorderType, Borders, Paragraph, Row, Table},
22+
layout::{Constraint, Direction, Layout, Rect},
23+
style::{Color, Style},
24+
widgets::{Block, BorderType, Borders, Paragraph, Row, Table},
2625
Frame,
2726
};
2827

2928
use crate::{app::App, media::player::Player};
3029

31-
pub fn draw_help<B>(app: &mut App, frame: &mut Frame<B>, area: Rect)
30+
pub fn draw_help<B>(_app: &mut App, frame: &mut Frame<B>, area: Rect)
3231
where
3332
B: Backend,
3433
{

src/ui/music_board.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ use tui::{
2525
Frame,
2626
};
2727

28-
use crate::{
29-
app::{ActiveModules, App},
30-
media::player::Player,
31-
};
28+
use crate::{app::App, media::player::Player};
3229

3330
use super::{effects::draw_bar_charts_effect, play_list::draw_play_list, progress::draw_progress};
3431

0 commit comments

Comments
 (0)