Checkstyle fixes
This commit is contained in:
parent
6e3d012a8a
commit
6d3cc1a9da
|
@ -52,7 +52,7 @@ public class GPodnetServiceTest {
|
|||
ArrayList<String> l = new ArrayList<>();
|
||||
l.add("http://bitsundso.de/feed");
|
||||
l.add("http://gamesundso.de/feed");
|
||||
service.uploadSubscriptions( "radio", l);
|
||||
service.uploadSubscriptions("radio", l);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -116,9 +116,9 @@ public abstract class PodcastListFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
protected List<GpodnetPodcast> doInBackground(Void... params) {
|
||||
GpodnetService service = null;
|
||||
try {
|
||||
service = new GpodnetService(AntennapodHttpClient.getHttpClient(), GpodnetPreferences.getHostname());
|
||||
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(),
|
||||
GpodnetPreferences.getHostname());
|
||||
return loadPodcastData(service);
|
||||
} catch (GpodnetServiceException e) {
|
||||
exception = e;
|
||||
|
|
|
@ -92,7 +92,8 @@ public class TagListFragment extends ListFragment {
|
|||
|
||||
@Override
|
||||
protected List<GpodnetTag> doInBackground(Void... params) {
|
||||
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(), GpodnetPreferences.getHostname());
|
||||
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(),
|
||||
GpodnetPreferences.getHostname());
|
||||
try {
|
||||
return service.getTopTags(COUNT);
|
||||
} catch (GpodnetServiceException e) {
|
||||
|
|
|
@ -82,25 +82,25 @@ public class GpodderPreferencesFragment extends PreferenceFragmentCompat {
|
|||
return true;
|
||||
});
|
||||
findPreference(PREF_GPODNET_SYNC).setOnPreferenceClickListener(preference -> {
|
||||
SyncService.syncImmediately(getActivity().getApplicationContext());
|
||||
return true;
|
||||
});
|
||||
SyncService.syncImmediately(getActivity().getApplicationContext());
|
||||
return true;
|
||||
});
|
||||
findPreference(PREF_GPODNET_FORCE_FULL_SYNC).setOnPreferenceClickListener(preference -> {
|
||||
SyncService.fullSync(getContext());
|
||||
return true;
|
||||
});
|
||||
SyncService.fullSync(getContext());
|
||||
return true;
|
||||
});
|
||||
findPreference(PREF_GPODNET_LOGOUT).setOnPreferenceClickListener(preference -> {
|
||||
GpodnetPreferences.logout();
|
||||
Toast toast = Toast.makeText(activity, R.string.pref_gpodnet_logout_toast, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
updateGpodnetPreferenceScreen();
|
||||
return true;
|
||||
});
|
||||
GpodnetPreferences.logout();
|
||||
Toast toast = Toast.makeText(activity, R.string.pref_gpodnet_logout_toast, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
updateGpodnetPreferenceScreen();
|
||||
return true;
|
||||
});
|
||||
findPreference(PREF_GPODNET_HOSTNAME).setOnPreferenceClickListener(preference -> {
|
||||
GpodnetSetHostnameDialog.createDialog(activity).setOnDismissListener(
|
||||
dialog -> updateGpodnetPreferenceScreen());
|
||||
return true;
|
||||
});
|
||||
GpodnetSetHostnameDialog.createDialog(activity).setOnDismissListener(
|
||||
dialog -> updateGpodnetPreferenceScreen());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void updateGpodnetPreferenceScreen() {
|
||||
|
|
|
@ -176,7 +176,6 @@
|
|||
<property name="ignoreFinal" value="false"/>
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
|
|
|
@ -148,7 +148,7 @@ public class SyncService extends Worker {
|
|||
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||
String json = prefs.getString(PREF_QUEUED_EPISODE_ACTIONS, "[]");
|
||||
JSONArray queue = new JSONArray(json);
|
||||
queue.put(action.writeToJSONObject());
|
||||
queue.put(action.writeToJsonObject());
|
||||
prefs.edit().putString(PREF_QUEUED_EPISODE_ACTIONS, queue.toString()).apply();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -217,7 +217,7 @@ public class SyncService extends Worker {
|
|||
String json = prefs.getString(PREF_QUEUED_EPISODE_ACTIONS, "[]");
|
||||
JSONArray queue = new JSONArray(json);
|
||||
for (int i = 0; i < queue.length(); i++) {
|
||||
actions.add(EpisodeAction.readFromJSONObject(queue.getJSONObject(i)));
|
||||
actions.add(EpisodeAction.readFromJsonObject(queue.getJSONObject(i)));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -297,7 +297,7 @@ public class SyncService extends Worker {
|
|||
|
||||
synchronized (lock) {
|
||||
UploadChangesResponse uploadResponse = syncServiceImpl
|
||||
.uploadSubscriptionChanges(queuedAddedFeeds, queuedRemovedFeeds);
|
||||
.uploadSubscriptionChanges(queuedAddedFeeds, queuedRemovedFeeds);
|
||||
getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit()
|
||||
.putString(PREF_QUEUED_FEEDS_ADDED, "[]").apply();
|
||||
getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit()
|
||||
|
@ -406,6 +406,9 @@ public class SyncService extends Worker {
|
|||
case DELETE:
|
||||
// NEVER EVER call DBWriter.deleteFeedMediaOfItem() here, leads to an infinite loop
|
||||
break;
|
||||
default:
|
||||
Log.e(TAG, "Unknown action: " + action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class GpodnetService implements ISyncService {
|
|||
String response = executeRequest(request);
|
||||
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
return readPodcastListFromJSONArray(jsonArray);
|
||||
return readPodcastListFromJsonArray(jsonArray);
|
||||
|
||||
} catch (JSONException | MalformedURLException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -134,7 +134,7 @@ public class GpodnetService implements ISyncService {
|
|||
String response = executeRequest(request);
|
||||
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
return readPodcastListFromJSONArray(jsonArray);
|
||||
return readPodcastListFromJsonArray(jsonArray);
|
||||
|
||||
} catch (JSONException | MalformedURLException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -165,7 +165,7 @@ public class GpodnetService implements ISyncService {
|
|||
String response = executeRequest(request);
|
||||
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
return readPodcastListFromJSONArray(jsonArray);
|
||||
return readPodcastListFromJsonArray(jsonArray);
|
||||
} catch (JSONException | MalformedURLException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new GpodnetServiceException(e);
|
||||
|
@ -191,7 +191,7 @@ public class GpodnetService implements ISyncService {
|
|||
String response = executeRequest(request);
|
||||
|
||||
JSONArray jsonArray = new JSONArray(response);
|
||||
return readPodcastListFromJSONArray(jsonArray);
|
||||
return readPodcastListFromJsonArray(jsonArray);
|
||||
|
||||
} catch (JSONException | MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -216,7 +216,7 @@ public class GpodnetService implements ISyncService {
|
|||
Request.Builder request = new Request.Builder().url(url);
|
||||
String response = executeRequest(request);
|
||||
JSONArray devicesArray = new JSONArray(response);
|
||||
return readDeviceListFromJSONArray(devicesArray);
|
||||
return readDeviceListFromJsonArray(devicesArray);
|
||||
} catch (JSONException | MalformedURLException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new GpodnetServiceException(e);
|
||||
|
@ -393,7 +393,7 @@ public class GpodnetService implements ISyncService {
|
|||
|
||||
String response = executeRequest(request);
|
||||
JSONObject changes = new JSONObject(response);
|
||||
return readSubscriptionChangesFromJSONObject(changes);
|
||||
return readSubscriptionChangesFromJsonObject(changes);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException(e);
|
||||
|
@ -436,7 +436,7 @@ public class GpodnetService implements ISyncService {
|
|||
final JSONArray list = new JSONArray();
|
||||
for (int i = from; i < to; i++) {
|
||||
EpisodeAction episodeAction = episodeActions.get(i);
|
||||
JSONObject obj = episodeAction.writeToJSONObject();
|
||||
JSONObject obj = episodeAction.writeToJsonObject();
|
||||
if (obj != null) {
|
||||
obj.put("device", GpodnetPreferences.getDeviceID());
|
||||
list.put(obj);
|
||||
|
@ -474,7 +474,7 @@ public class GpodnetService implements ISyncService {
|
|||
|
||||
String response = executeRequest(request);
|
||||
JSONObject json = new JSONObject(response);
|
||||
return readEpisodeActionsFromJSONObject(json);
|
||||
return readEpisodeActionsFromJsonObject(json);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException(e);
|
||||
|
@ -570,15 +570,15 @@ public class GpodnetService implements ISyncService {
|
|||
}
|
||||
}
|
||||
|
||||
private List<GpodnetPodcast> readPodcastListFromJSONArray(@NonNull JSONArray array) throws JSONException {
|
||||
private List<GpodnetPodcast> readPodcastListFromJsonArray(@NonNull JSONArray array) throws JSONException {
|
||||
List<GpodnetPodcast> result = new ArrayList<>(array.length());
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
result.add(readPodcastFromJSONObject(array.getJSONObject(i)));
|
||||
result.add(readPodcastFromJsonObject(array.getJSONObject(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private GpodnetPodcast readPodcastFromJSONObject(JSONObject object) throws JSONException {
|
||||
private GpodnetPodcast readPodcastFromJsonObject(JSONObject object) throws JSONException {
|
||||
String url = object.getString("url");
|
||||
|
||||
String title;
|
||||
|
@ -623,15 +623,15 @@ public class GpodnetService implements ISyncService {
|
|||
return new GpodnetPodcast(url, title, description, subscribers, logoUrl, website, mygpoLink, author);
|
||||
}
|
||||
|
||||
private List<GpodnetDevice> readDeviceListFromJSONArray(@NonNull JSONArray array) throws JSONException {
|
||||
private List<GpodnetDevice> readDeviceListFromJsonArray(@NonNull JSONArray array) throws JSONException {
|
||||
List<GpodnetDevice> result = new ArrayList<>(array.length());
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
result.add(readDeviceFromJSONObject(array.getJSONObject(i)));
|
||||
result.add(readDeviceFromJsonObject(array.getJSONObject(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private GpodnetDevice readDeviceFromJSONObject(JSONObject object) throws JSONException {
|
||||
private GpodnetDevice readDeviceFromJsonObject(JSONObject object) throws JSONException {
|
||||
String id = object.getString("id");
|
||||
String caption = object.getString("caption");
|
||||
String type = object.getString("type");
|
||||
|
@ -639,7 +639,7 @@ public class GpodnetService implements ISyncService {
|
|||
return new GpodnetDevice(id, caption, type, subscriptions);
|
||||
}
|
||||
|
||||
private SubscriptionChanges readSubscriptionChangesFromJSONObject(@NonNull JSONObject object)
|
||||
private SubscriptionChanges readSubscriptionChangesFromJsonObject(@NonNull JSONObject object)
|
||||
throws JSONException {
|
||||
|
||||
List<String> added = new LinkedList<>();
|
||||
|
@ -664,7 +664,7 @@ public class GpodnetService implements ISyncService {
|
|||
return new SubscriptionChanges(added, removed, timestamp);
|
||||
}
|
||||
|
||||
private EpisodeActionChanges readEpisodeActionsFromJSONObject(@NonNull JSONObject object)
|
||||
private EpisodeActionChanges readEpisodeActionsFromJsonObject(@NonNull JSONObject object)
|
||||
throws JSONException {
|
||||
|
||||
List<EpisodeAction> episodeActions = new ArrayList<>();
|
||||
|
@ -673,7 +673,7 @@ public class GpodnetService implements ISyncService {
|
|||
JSONArray jsonActions = object.getJSONArray("actions");
|
||||
for (int i = 0; i < jsonActions.length(); i++) {
|
||||
JSONObject jsonAction = jsonActions.getJSONObject(i);
|
||||
EpisodeAction episodeAction = EpisodeAction.readFromJSONObject(jsonAction);
|
||||
EpisodeAction episodeAction = EpisodeAction.readFromJsonObject(jsonAction);
|
||||
if (episodeAction != null) {
|
||||
episodeActions.add(episodeAction);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.core.sync.model;
|
|||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.ObjectsCompat;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.util.DateUtils;
|
||||
import org.json.JSONException;
|
||||
|
@ -45,7 +46,7 @@ public class EpisodeAction {
|
|||
* @param object JSON representation
|
||||
* @return episode action object, or null if mandatory values are missing
|
||||
*/
|
||||
public static EpisodeAction readFromJSONObject(JSONObject object) {
|
||||
public static EpisodeAction readFromJsonObject(JSONObject object) {
|
||||
String podcast = object.optString("podcast", null);
|
||||
String episode = object.optString("episode", null);
|
||||
String actionString = object.optString("action", null);
|
||||
|
@ -98,7 +99,7 @@ public class EpisodeAction {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the position (in seconds) at which the client started playback
|
||||
* Returns the position (in seconds) at which the client started playback.
|
||||
*
|
||||
* @return start position (in seconds)
|
||||
*/
|
||||
|
@ -107,7 +108,7 @@ public class EpisodeAction {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the position (in seconds) at which the client stopped playback
|
||||
* Returns the position (in seconds) at which the client stopped playback.
|
||||
*
|
||||
* @return stop position (in seconds)
|
||||
*/
|
||||
|
@ -126,21 +127,18 @@ public class EpisodeAction {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || !(o instanceof EpisodeAction)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof EpisodeAction)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EpisodeAction that = (EpisodeAction) o;
|
||||
|
||||
if (started != that.started) return false;
|
||||
if (position != that.position) return false;
|
||||
if (total != that.total) return false;
|
||||
if (podcast != null ? !podcast.equals(that.podcast) : that.podcast != null) return false;
|
||||
if (episode != null ? !episode.equals(that.episode) : that.episode != null) return false;
|
||||
//if (deviceId != null ? !deviceId.equals(that.deviceId) : that.deviceId != null)
|
||||
// return false;
|
||||
if (action != that.action) return false;
|
||||
return !(timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null);
|
||||
|
||||
return started == that.started && position == that.position && total == that.total && action != that.action
|
||||
&& ObjectsCompat.equals(podcast, that.podcast)
|
||||
&& ObjectsCompat.equals(episode, that.episode)
|
||||
&& ObjectsCompat.equals(timestamp, that.timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,11 +154,11 @@ public class EpisodeAction {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON object representation of this object
|
||||
* Returns a JSON object representation of this object.
|
||||
*
|
||||
* @return JSON object representation, or null if the object is invalid
|
||||
*/
|
||||
public JSONObject writeToJSONObject() {
|
||||
public JSONObject writeToJsonObject() {
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.putOpt("podcast", this.podcast);
|
||||
|
@ -183,15 +181,15 @@ public class EpisodeAction {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EpisodeAction{" +
|
||||
"podcast='" + podcast + '\'' +
|
||||
", episode='" + episode + '\'' +
|
||||
", action=" + action +
|
||||
", timestamp=" + timestamp +
|
||||
", started=" + started +
|
||||
", position=" + position +
|
||||
", total=" + total +
|
||||
'}';
|
||||
return "EpisodeAction{"
|
||||
+ "podcast='" + podcast + '\''
|
||||
+ ", episode='" + episode + '\''
|
||||
+ ", action=" + action
|
||||
+ ", timestamp=" + timestamp
|
||||
+ ", started=" + started
|
||||
+ ", position=" + position
|
||||
+ ", total=" + total
|
||||
+ '}';
|
||||
}
|
||||
|
||||
public enum Action {
|
||||
|
|
|
@ -25,9 +25,9 @@ public class EpisodeActionChanges {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EpisodeActionGetResponse{" +
|
||||
"episodeActions=" + episodeActions +
|
||||
", timestamp=" + timestamp +
|
||||
'}';
|
||||
return "EpisodeActionGetResponse{"
|
||||
+ "episodeActions=" + episodeActions
|
||||
+ ", timestamp=" + timestamp
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue