首先: 抱歉,如果我拼错了.我来自巴拉圭,我正在使用谷歌翻译.
这可能看起来有点傻,我是一个完美主义者,像任何优秀的开发人员和设计师一样,不要在我的项目中存在错误.我正在学习,希望能和你学到很多东西
我见过媒体播放器应用程序允许用户快速反复按下播放/停止按钮而不会杀死应用程序,并且这仍然正常运行,所以我读到了Services,AsyncTask和Thread.不仅要在后台播放声音,还要在UI错误中不杀死我的应用程序.我还有很多问题.
I wonder if I'm on a good path using the following resource (found online), but I have tried and the application dies when I press for several times the play/stop buttom or sometimes simply not play the song.
package com.myaudioservice.app;
import android.app.Service;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.IBinder;
/**
* Service to serv MediaPlayer in background
*
* @author Eugeny Pozharsky
*/ …Run Code Online (Sandbox Code Playgroud) 我需要列出 json 的内容并按日期(部分)排序。到目前为止,我设法成功获取了 json 并列出了主要内容(名称和时间),但我需要按日期作为部分进行排序。
编辑: 如果我有超过 100 个“项目”(json 对象),并且在某些情况下重复了日期(如下面 json 的前两个对象),那么我希望这些项目位于以日期为每个部分的标题。
杰森:
[
{"date_raw":"1/18/2017 12:00:00 AM","name":"Hello 2","hour":"12:00 - 14:00","audio_url":"http://example.com/file2.mp4"},
{"date_raw":"1/18/2017 12:00:00 AM","name":"Hello 1","hour":"10:00 - 12:00","audio_url":"http://example.com/file1.mp4"},
{"date_raw":"1/17/2017 12:00:00 AM","name":"Hello","hour":"10:00 - 12:00","audio_url":"http://example.com/file.mp4"},
{"date_raw":"1/16/2017 12:00:00 AM","name":"Hello","hour":"10:00 - 12:00","audio_url":"http://example.com/file.mp4"}
]
Run Code Online (Sandbox Code Playgroud)
主要班级:
class MyVC: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
// date_raw
var section: [String] = []
// date_raw, name, hour, audio_url
var items: [(String, String, String, String)] = []
var dateV:String = ""
func tableView(_ tableView: UITableView, numberOfRowsInSection section: …Run Code Online (Sandbox Code Playgroud) 有些东西不起作用;我不知道这是模拟器的问题还是 Android Oreo 上的错误(我没有使用 Android O 的物理设备),但我无法像 Marshmallow 那样从深色状态栏主题切换到浅色状态栏主题。
样式.xml(来自api 23):
<resources>
<style name="ThemeLight" parent="MyBaseTheme">
<item name="android:windowBackground">?attr/colorPrimary</item>
<item name="android:statusBarColor">?attr/colorPrimary</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="ThemeDark" parent="MyBaseThemeDark">
<item name="android:windowBackground">?attr/colorPrimary</item>
<item name="android:statusBarColor">?attr/colorPrimary</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这在 Android M 上运行良好,当我使用 更改主题时setTheme(),但在 Android O 中,一旦我切换到浅色主题,它就不再更改并且状态栏保持黑色(windowLightStatusBar = true)/:
android android-theme android-6.0-marshmallow android-8.0-oreo