jun 11 months ago
parent acd8a217e1
commit 49b6cc7e0c
  1. 25
      app/src/main/java/com/github/tvbox/osc/ui/dialog/ApiDialog.java
  2. 9
      app/src/main/java/com/github/tvbox/osc/ui/fragment/ModelSettingFragment.java
  3. 22
      app/src/main/java/com/github/tvbox/osc/util/HistoryHelper.java

@ -18,6 +18,7 @@ import com.github.tvbox.osc.server.ControlManager;
import com.github.tvbox.osc.ui.adapter.ApiHistoryDialogAdapter;
import com.github.tvbox.osc.ui.tv.QRCodeGen;
import com.github.tvbox.osc.util.HawkConfig;
import com.github.tvbox.osc.util.HistoryHelper;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
@ -68,13 +69,7 @@ public class ApiDialog extends BaseDialog {
public void onClick(View v) {
String newApi = inputApi.getText().toString().trim();
if (!newApi.isEmpty()) {
ArrayList<String> history = Hawk.get(HawkConfig.API_HISTORY, new ArrayList<String>());
if (!history.contains(newApi))
history.add(0, newApi);
if (history.size() > 30)
history.remove(30);
Hawk.put(HawkConfig.API_HISTORY, history);
// String newLiveApi = inputApi.getText().toString().trim();
HistoryHelper.setApiHistory(newApi);
if(!newApi.equals(Hawk.get(HawkConfig.API_URL, newApi))){
inputApiLive.setText(newApi);
Hawk.put(HawkConfig.LIVE_API_URL, newApi);
@ -89,14 +84,7 @@ public class ApiDialog extends BaseDialog {
public void onClick(View v) {
String newApi = inputApiLive.getText().toString().trim();
if (!newApi.isEmpty()) {
ArrayList<String> history = Hawk.get(HawkConfig.LIVE_API_HISTORY, new ArrayList<String>());
if (!history.contains(newApi)) {
history.add(0, newApi);
}
if (history.size() > 30) {
history.remove(30);
}
Hawk.put(HawkConfig.LIVE_API_HISTORY, history);
HistoryHelper.setLiveApiHistory(newApi);
}
Hawk.put(HawkConfig.LIVE_API_URL, newApi);
dismiss();
@ -167,12 +155,7 @@ public class ApiDialog extends BaseDialog {
if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
String newApi = inputApi.getText().toString().trim();
if (!newApi.isEmpty()) {
ArrayList<String> history = Hawk.get(HawkConfig.API_HISTORY, new ArrayList<String>());
if (!history.contains(newApi))
history.add(0, newApi);
if (history.size() > 30)
history.remove(30);
Hawk.put(HawkConfig.API_HISTORY, history);
HistoryHelper.setApiHistory(newApi);
if(!newApi.equals(Hawk.get(HawkConfig.API_URL, newApi))){
inputApiLive.setText(newApi);

@ -325,14 +325,7 @@ public class ModelSettingFragment extends BaseLazyFragment {
public void click(String value) {
Hawk.put(HawkConfig.API_URL, value);
Hawk.put(HawkConfig.LIVE_API_URL, value);
ArrayList<String> history = Hawk.get(HawkConfig.LIVE_API_HISTORY, new ArrayList<String>());
if (!history.contains(value)) {
history.add(0, value);
}
if (history.size() > 30) {
history.remove(30);
}
Hawk.put(HawkConfig.LIVE_API_HISTORY, history);
HistoryHelper.setLiveApiHistory(value);
tvApi.setText(value);
dialog.dismiss();
}

@ -32,4 +32,26 @@ public class HistoryHelper {
}
Hawk.put(HawkConfig.SEARCH_HISTORY, history);
}
public static void setLiveApiHistory(String value){
ArrayList<String> history = Hawk.get(HawkConfig.LIVE_API_HISTORY, new ArrayList<String>());
if (!history.contains(value)) {
history.add(0, value);
}
if (history.size() > 30) {
history.remove(30);
}
Hawk.put(HawkConfig.LIVE_API_HISTORY, history);
}
public static void setApiHistory(String value){
ArrayList<String> history = Hawk.get(HawkConfig.API_HISTORY, new ArrayList<String>());
if (!history.contains(value)) {
history.add(0, value);
}
if (history.size() > 30) {
history.remove(30);
}
Hawk.put(HawkConfig.API_HISTORY, history);
}
}

Loading…
Cancel
Save