fix some Linter warnings

This commit is contained in:
badaix 2017-02-07 18:47:53 +01:00
parent 998f6b3f47
commit 5c78d2380b
13 changed files with 45 additions and 98 deletions

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -30,8 +30,11 @@ public class AboutActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about); setContentView(R.layout.activity_about);
getSupportActionBar().setTitle(getString(R.string.about) + " Snapcast"); try {
PackageInfo pInfo = null; getSupportActionBar().setTitle(getString(R.string.about) + " Snapcast");
} catch (Exception e) {
}
PackageInfo pInfo;
try { try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
getSupportActionBar().setSubtitle("v" + pInfo.versionName); getSupportActionBar().setSubtitle("v" + pInfo.versionName);

View file

@ -30,7 +30,6 @@ import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import de.badaix.snapcast.control.json.Client; import de.badaix.snapcast.control.json.Client;
import de.badaix.snapcast.control.json.ServerStatus;
import de.badaix.snapcast.control.json.Volume; import de.badaix.snapcast.control.json.Volume;
public class ClientItem extends LinearLayout implements SeekBar.OnSeekBarChangeListener, View.OnClickListener, PopupMenu.OnMenuItemClickListener { public class ClientItem extends LinearLayout implements SeekBar.OnSeekBarChangeListener, View.OnClickListener, PopupMenu.OnMenuItemClickListener {
@ -42,10 +41,13 @@ public class ClientItem extends LinearLayout implements SeekBar.OnSeekBarChangeL
private ImageButton ibMute; private ImageButton ibMute;
private ImageButton ibOverflow; private ImageButton ibOverflow;
private Client client; private Client client;
private ServerStatus server;
private ClientItemListener listener = null; private ClientItemListener listener = null;
public ClientItem(Context context, ServerStatus server, Client client) { public ClientItem(Context context) {
this(context, null);
}
public ClientItem(Context context, Client client) {
super(context); super(context);
LayoutInflater vi = (LayoutInflater) context LayoutInflater vi = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@ -58,7 +60,6 @@ public class ClientItem extends LinearLayout implements SeekBar.OnSeekBarChangeL
ibOverflow = (ImageButton) findViewById(R.id.ibOverflow); ibOverflow = (ImageButton) findViewById(R.id.ibOverflow);
ibOverflow.setOnClickListener(this); ibOverflow.setOnClickListener(this);
volumeSeekBar.setOnSeekBarChangeListener(this); volumeSeekBar.setOnSeekBarChangeListener(this);
this.server = server;
setClient(client); setClient(client);
} }

View file

@ -94,7 +94,7 @@ public class GroupItem extends LinearLayout implements SeekBar.OnSeekBarChangeLi
if ((client == null) || client.isDeleted() || (hideOffline && !client.isConnected())) if ((client == null) || client.isDeleted() || (hideOffline && !client.isConnected()))
continue; continue;
ClientItem clientItem = new ClientItem(this.getContext(), server, client); ClientItem clientItem = new ClientItem(this.getContext(), client);
clientItem.setListener(this); clientItem.setListener(this);
clientItems.add(clientItem); clientItems.add(clientItem);
llClient.addView(clientItem); llClient.addView(clientItem);

View file

@ -20,6 +20,8 @@ package de.badaix.snapcast;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -43,11 +45,6 @@ public class GroupListFragment extends Fragment {
private static final String TAG = "GroupList"; private static final String TAG = "GroupList";
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
private GroupItem.GroupItemListener groupItemListener; private GroupItem.GroupItemListener groupItemListener;
private GroupAdapter groupAdapter; private GroupAdapter groupAdapter;
private ServerStatus serverStatus = null; private ServerStatus serverStatus = null;
@ -57,29 +54,13 @@ public class GroupListFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
* <p/>
* //@param param1 Parameter 1.
*
* @return A new instance of fragment GroupListFragment.
* // TODO: Rename and change types and number of parameters
* public static GroupListFragment newInstance(String param1) {
* GroupListFragment fragment = new GroupListFragment();
* Bundle args = new Bundle();
* args.putString(ARG_PARAM1, param1);
* fragment.setArguments(args);
* return fragment;
* }
*/
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getArguments() != null) { // if (getArguments() != null) {
// mParam1 = getArguments().getString(ARG_PARAM1); // mParam1 = getArguments().getString(ARG_PARAM1);
} // }
} }
@Override @Override
@ -137,14 +118,17 @@ public class GroupListFragment extends Fragment {
private boolean hideOffline = false; private boolean hideOffline = false;
private ServerStatus serverStatus = new ServerStatus(); private ServerStatus serverStatus = new ServerStatus();
public GroupAdapter(Context context, GroupItem.GroupItemListener listener) { GroupAdapter(Context context, GroupItem.GroupItemListener listener) {
super(context, 0); super(context, 0);
this.context = context; this.context = context;
this.listener = listener; this.listener = listener;
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public
@NonNull
View getView(int position, @Nullable View convertView,
@NonNull ViewGroup parent) {
Group group = getItem(position); Group group = getItem(position);
final GroupItem groupItem; final GroupItem groupItem;
@ -159,7 +143,7 @@ public class GroupListFragment extends Fragment {
return groupItem; return groupItem;
} }
public void updateServer(final ServerStatus serverStatus) { void updateServer(final ServerStatus serverStatus) {
if (serverStatus != null) { if (serverStatus != null) {
GroupAdapter.this.serverStatus = serverStatus; GroupAdapter.this.serverStatus = serverStatus;
update(); update();
@ -167,14 +151,12 @@ public class GroupListFragment extends Fragment {
} }
public void update() { void update() {
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
clear(); clear();
// TODO: group
for (Group group : GroupAdapter.this.serverStatus.getGroups()) { for (Group group : GroupAdapter.this.serverStatus.getGroups()) {
// add(group);
if (group.getClients().isEmpty()) if (group.getClients().isEmpty())
continue; continue;
@ -198,7 +180,7 @@ public class GroupListFragment extends Fragment {
}); });
} }
public void setHideOffline(boolean hideOffline) { void setHideOffline(boolean hideOffline) {
if (this.hideOffline == hideOffline) if (this.hideOffline == hideOffline)
return; return;
this.hideOffline = hideOffline; this.hideOffline = hideOffline;

View file

@ -44,7 +44,7 @@ import de.badaix.snapcast.control.json.Stream;
public class GroupSettingsFragment extends PreferenceFragment { public class GroupSettingsFragment extends PreferenceFragment {
private static final String TAG = "GroupSettingsFragment"; //private static final String TAG = "GroupSettingsFragment";
private ListPreference prefStreams; private ListPreference prefStreams;
private Group group = null; private Group group = null;

View file

@ -34,7 +34,6 @@ import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -79,7 +78,6 @@ public class MainActivity extends AppCompatActivity implements GroupItem.GroupIt
private ServerStatus serverStatus = null; private ServerStatus serverStatus = null;
private SnapclientService snapclientService; private SnapclientService snapclientService;
private GroupListFragment groupListFragment; private GroupListFragment groupListFragment;
private TabLayout tabLayout;
private Snackbar warningSamplerateSnackbar = null; private Snackbar warningSamplerateSnackbar = null;
private int nativeSampleRate = 0; private int nativeSampleRate = 0;
private CoordinatorLayout coordinatorLayout; private CoordinatorLayout coordinatorLayout;
@ -154,7 +152,7 @@ public class MainActivity extends AppCompatActivity implements GroupItem.GroupIt
} }
public void checkFirstRun() { public void checkFirstRun() {
PackageInfo pInfo = null; PackageInfo pInfo;
try { try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
final int verCode = pInfo.versionCode; final int verCode = pInfo.versionCode;
@ -396,7 +394,7 @@ public class MainActivity extends AppCompatActivity implements GroupItem.GroupIt
return; return;
} }
if (requestCode == CLIENT_PROPERTIES_REQUEST) { if (requestCode == CLIENT_PROPERTIES_REQUEST) {
Client client = null; Client client;
try { try {
client = new Client(new JSONObject(data.getStringExtra("client"))); client = new Client(new JSONObject(data.getStringExtra("client")));
} catch (JSONException e) { } catch (JSONException e) {
@ -404,7 +402,7 @@ public class MainActivity extends AppCompatActivity implements GroupItem.GroupIt
return; return;
} }
Client clientOriginal = null; Client clientOriginal;
try { try {
clientOriginal = new Client(new JSONObject(data.getStringExtra("clientOriginal"))); clientOriginal = new Client(new JSONObject(data.getStringExtra("clientOriginal")));
} catch (JSONException e) { } catch (JSONException e) {
@ -597,7 +595,7 @@ public class MainActivity extends AppCompatActivity implements GroupItem.GroupIt
groupListFragment.updateServer(serverStatus); groupListFragment.updateServer(serverStatus);
} }
}); });
mySnackbar.setCallback(new Snackbar.Callback() { mySnackbar.addCallback(new Snackbar.Callback() {
@Override @Override
public void onDismissed(Snackbar snackbar, int event) { public void onDismissed(Snackbar snackbar, int event) {
super.onDismissed(snackbar, event); super.onDismissed(snackbar, event);

View file

@ -122,7 +122,6 @@ public class ServerDialogFragment extends DialogFragment implements View.OnClick
if (context instanceof Activity) { if (context instanceof Activity) {
update(); update();
} }
} }
private void update() { private void update() {

View file

@ -26,10 +26,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.Binder; import android.os.Binder;
import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager; import android.os.PowerManager;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder; import android.support.v4.app.TaskStackBuilder;
@ -73,10 +70,10 @@ public class SnapclientService extends Service {
if (intent == null) if (intent == null)
return START_NOT_STICKY; return START_NOT_STICKY;
if (intent.getAction() == ACTION_STOP) { if (intent.getAction().equals(ACTION_STOP)) {
stopService(); stopService();
return START_NOT_STICKY; return START_NOT_STICKY;
} else if (intent.getAction() == ACTION_START) { } else if (intent.getAction().equals(ACTION_START)) {
String host = intent.getStringExtra(EXTRA_HOST); String host = intent.getStringExtra(EXTRA_HOST);
int port = intent.getIntExtra(EXTRA_PORT, 1704); int port = intent.getIntExtra(EXTRA_PORT, 1704);
@ -111,11 +108,8 @@ public class SnapclientService extends Service {
PendingIntent.FLAG_UPDATE_CURRENT PendingIntent.FLAG_UPDATE_CURRENT
); );
builder.setContentIntent(resultPendingIntent); builder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on. // mId allows you to update the notification later on.
final Notification notification = builder.build(); final Notification notification = builder.build();
// mNotificationManager.notify(123, notification);
startForeground(123, notification); startForeground(123, notification);
start(host, port); start(host, port);
@ -257,31 +251,6 @@ public class SnapclientService extends Service {
} }
} }
// Handler that receives messages from the thread
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg) {
// Normally we would do some work here, like download a file.
// For our sample, we just sleep for 5 seconds.
long endTime = System.currentTimeMillis() + 5 * 1000;
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
// Stop the service using the startId, so that we don't stop
// the service in the middle of handling another job
stopSelf(msg.arg1);
}
}
} }

View file

@ -18,6 +18,7 @@
package de.badaix.snapcast.control.json; package de.badaix.snapcast.control.json;
import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import org.json.JSONArray; import org.json.JSONArray;
@ -203,7 +204,7 @@ public class Group implements JsonSerialisable, Comparable<Group> {
} }
@Override @Override
public int compareTo(Group another) { public int compareTo(@NonNull Group another) {
if (getClients().isEmpty()) if (getClients().isEmpty())
return -1; return -1;
if (another.getClients().isEmpty()) if (another.getClients().isEmpty())

View file

@ -2,17 +2,16 @@
<string name="app_name">Snapcast</string> <string name="app_name">Snapcast</string>
<string name="ticker_text">Snapclient gestartet</string> <string name="ticker_text">Snapclient gestartet</string>
<string name="notification_title">Snapclient</string> <string name="notification_title">Snapclient</string>
<string name="notification_text">Snapclient läuft...</string> <string name="notification_text">Snapclient läuft</string>
<string name="notification_info">Info...</string> <string name="notification_info">Info</string>
<string name="stop">Stop</string> <string name="stop">Stop</string>
<string name="menu_details">Details</string> <string name="menu_details">Details</string>
<string name="menu_delete">Löschen</string> <string name="menu_delete">Löschen</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="title_activity_snapcast">Snapcast</string> <string name="title_activity_snapcast">Snapcast</string>
<string name="action_about">Über...</string> <string name="action_about">Über</string>
<string name="action_settings">Einstellungen...</string> <string name="action_settings">Einstellungen</string>
<string name="action_scan">Suche nach Server</string> <string name="action_scan">Suche nach Server</string>
<string name="action_refresh">Aktualisiere Client-Liste</string> <string name="action_refresh">Aktualisiere Client-Liste</string>
<string name="action_hide_offline">Verstecke offline Clients</string> <string name="action_hide_offline">Verstecke offline Clients</string>
@ -36,7 +35,6 @@
<string name="about_file">files/about.html</string> <string name="about_file">files/about.html</string>
<string name="about">Über</string> <string name="about">Über</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="client_stream">Stream</string> <string name="client_stream">Stream</string>
<string name="first_run_title">Warnung</string> <string name="first_run_title">Warnung</string>
<string name="first_run_text">Dies ist ein Test-Client.\nNicht für den Produktiv-Einsatz vorgesehen.</string> <string name="first_run_text">Dies ist ein Test-Client.\nNicht für den Produktiv-Einsatz vorgesehen.</string>

View file

@ -2,17 +2,16 @@
<string name="app_name">Snapcast</string> <string name="app_name">Snapcast</string>
<string name="ticker_text">Snapclient 開始しました</string> <string name="ticker_text">Snapclient 開始しました</string>
<string name="notification_title">Snapclient</string> <string name="notification_title">Snapclient</string>
<string name="notification_text">Snapclient は実行中です...</string> <string name="notification_text">Snapclient は実行中です</string>
<string name="notification_info">情報...</string> <string name="notification_info">情報</string>
<string name="stop">停止</string> <string name="stop">停止</string>
<string name="menu_details">詳細</string> <string name="menu_details">詳細</string>
<string name="menu_delete">削除</string> <string name="menu_delete">削除</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="title_activity_snapcast">Snapcast</string> <string name="title_activity_snapcast">Snapcast</string>
<string name="action_about">アプリについて...</string> <string name="action_about">アプリについて</string>
<string name="action_settings">設定...</string> <string name="action_settings">設定</string>
<string name="action_scan">サーバーのスキャン</string> <string name="action_scan">サーバーのスキャン</string>
<string name="action_refresh">クライアント一覧の更新</string> <string name="action_refresh">クライアント一覧の更新</string>
<string name="action_hide_offline">オフラインのクライアントを非表示</string> <string name="action_hide_offline">オフラインのクライアントを非表示</string>
@ -36,7 +35,6 @@
<string name="about_file">files/about.html</string> <string name="about_file">files/about.html</string>
<string name="about">アプリについて</string> <string name="about">アプリについて</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="client_stream">ストリーム</string> <string name="client_stream">ストリーム</string>
<string name="first_run_title">警告</string> <string name="first_run_title">警告</string>
<string name="first_run_text">これはテストクライアントです。\n正式利用用途ではありません。</string> <string name="first_run_text">これはテストクライアントです。\n正式利用用途ではありません。</string>

View file

@ -2,18 +2,17 @@
<string name="app_name">Snapcast</string> <string name="app_name">Snapcast</string>
<string name="ticker_text">Snapclient started</string> <string name="ticker_text">Snapclient started</string>
<string name="notification_title">Snapclient</string> <string name="notification_title">Snapclient</string>
<string name="notification_text">Snapclient is running...</string> <string name="notification_text">Snapclient is running</string>
<string name="notification_info">info...</string> <string name="notification_info">info</string>
<string name="stop">stop</string> <string name="stop">stop</string>
<string name="menu_details">Details</string> <string name="menu_details">Details</string>
<string name="menu_delete">Delete</string> <string name="menu_delete">Delete</string>
<string name="menu_group">Group</string> <string name="menu_group">Group</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="title_activity_snapcast">Snapcast</string> <string name="title_activity_snapcast">Snapcast</string>
<string name="action_about">About...</string> <string name="action_about">About</string>
<string name="action_settings">Settings...</string> <string name="action_settings">Settings</string>
<string name="action_scan">Scan for server</string> <string name="action_scan">Scan for server</string>
<string name="action_refresh">Refresh client list</string> <string name="action_refresh">Refresh client list</string>
<string name="action_hide_offline">Hide offline clients</string> <string name="action_hide_offline">Hide offline clients</string>
@ -41,7 +40,6 @@
<string name="about_file">files/about.html</string> <string name="about_file">files/about.html</string>
<string name="about">About</string> <string name="about">About</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="client_stream">Stream</string> <string name="client_stream">Stream</string>
<string name="first_run_title">Warning</string> <string name="first_run_title">Warning</string>
<string name="first_run_text">This is just a test client.\nNot meant for production use.</string> <string name="first_run_text">This is just a test client.\nNot meant for production use.</string>