Skip to content

Commit

Permalink
code cleanup and fix Lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Hannes Achleitner <[email protected]>
  • Loading branch information
hannesa2 committed Dec 2, 2017
1 parent a34695f commit cac91b4
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 65 deletions.
4 changes: 2 additions & 2 deletions org.eclipse.paho.android.sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ dependencies {
}

task publishAPK(type: Copy) {
from file("${project.buildDir}/outputs/apk/" + rootProject.ext.sampleArchivesBaseName + "-debug.apk");
into '/shared/technology/paho/Android/' + rootProject.ext.sampleVersion + '/debug/';
from file("${project.buildDir}/outputs/apk/" + rootProject.ext.sampleArchivesBaseName + "-debug.apk")
into '/shared/technology/paho/Android/' + rootProject.ext.sampleVersion + '/debug/'
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
bundle.putString(ActivityConstants.CONNECTION_KEY, connection.handle());

// Initialise the tab-host
mTabHost = (FragmentTabHost) rootView.findViewById(android.R.id.tabhost);
mTabHost = rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), android.R.id.tabcontent);
// Add a tab to the tabHost
mTabHost.addTab(mTabHost.newTabSpec("History").setIndicator("History"), HistoryFragment.class, bundle);
Expand All @@ -64,7 +64,7 @@ private void changeConnectedState(boolean state) {
public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_connection, menu);

connectSwitch = (Switch) menu.findItem(R.id.connect_switch).getActionView().findViewById(R.id.switchForActionBar);
connectSwitch = menu.findItem(R.id.connect_switch).getActionView().findViewById(R.id.switchForActionBar);

connectSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_edit_connection, container, false);
clientId = (EditText) rootView.findViewById(R.id.client_id);
serverHostname = (EditText) rootView.findViewById(R.id.hostname);
serverPort = (EditText) rootView.findViewById(R.id.add_connection_port);
clientId = rootView.findViewById(R.id.client_id);
serverHostname = rootView.findViewById(R.id.hostname);
serverPort = rootView.findViewById(R.id.add_connection_port);
serverPort.setText("");
cleanSession = (Switch) rootView.findViewById(R.id.clean_session_switch);
username = (EditText) rootView.findViewById(R.id.username);
password = (EditText) rootView.findViewById(R.id.password);
tlsServerKey = (EditText) rootView.findViewById(R.id.tls_server_key);
tlsClientKey = (EditText) rootView.findViewById(R.id.tls_client_key);
timeout = (EditText) rootView.findViewById(R.id.timeout);
keepAlive = (EditText) rootView.findViewById(R.id.keepalive);
lwtTopic = (EditText) rootView.findViewById(R.id.lwt_topic);
lwtMessage = (EditText) rootView.findViewById(R.id.lwt_message);
lwtQos = (Spinner) rootView.findViewById(R.id.lwt_qos_spinner);
lwtRetain = (Switch) rootView.findViewById(R.id.retain_switch);
cleanSession = rootView.findViewById(R.id.clean_session_switch);
username = rootView.findViewById(R.id.username);
password = rootView.findViewById(R.id.password);
tlsServerKey = rootView.findViewById(R.id.tls_server_key);
tlsClientKey = rootView.findViewById(R.id.tls_client_key);
timeout = rootView.findViewById(R.id.timeout);
keepAlive = rootView.findViewById(R.id.keepalive);
lwtTopic = rootView.findViewById(R.id.lwt_topic);
lwtMessage = rootView.findViewById(R.id.lwt_message);
lwtQos = rootView.findViewById(R.id.lwt_qos_spinner);
lwtRetain = rootView.findViewById(R.id.retain_switch);


ArrayAdapter<CharSequence> adapter = ArrayAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflating view layout
View layout = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
RecyclerView recyclerView = (RecyclerView) layout.findViewById(R.id.drawerList);
RecyclerView recyclerView = layout.findViewById(R.id.drawerList);

TextView addConnectionTextView = (TextView) layout.findViewById(R.id.action_add_connection);
TextView addConnectionTextView = layout.findViewById(R.id.action_add_connection);

addConnectionTextView.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -106,7 +106,7 @@ public void onClick(View v) {
}
});

TextView helpTextView = (TextView) layout.findViewById(R.id.action_help);
TextView helpTextView = layout.findViewById(R.id.action_help);

helpTextView.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

final View rootView = inflater.inflate(R.layout.fragment_help, container, false);

Button websiteButton = (Button) rootView.findViewById(R.id.websiteButton);
Button websiteButton = rootView.findViewById(R.id.websiteButton);
websiteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -56,7 +56,7 @@ public void onClick(View v) {
}
});

Button feedbackButton = (Button) rootView.findViewById(R.id.feedbackButton);
Button feedbackButton = rootView.findViewById(R.id.feedbackButton);
feedbackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -67,7 +67,7 @@ public void onClick(View v) {
}
});

Switch enableLoggingSwitch = (Switch) rootView.findViewById(R.id.enable_logging_switch);
Switch enableLoggingSwitch = rootView.findViewById(R.id.enable_logging_switch);
enableLoggingSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View rootView = inflater.inflate(R.layout.fragment_connection_history, container, false);

messageListAdapter = new MessageListItemAdapter(getActivity(), messages);
ListView messageHistoryListView = (ListView) rootView.findViewById(R.id.history_list_view);
ListView messageHistoryListView = rootView.findViewById(R.id.history_list_view);
messageHistoryListView.setAdapter(messageListAdapter);

Button clearButton = (Button) rootView.findViewById(R.id.history_clear_button);
Button clearButton = rootView.findViewById(R.id.history_clear_button);
clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar mToolbar = findViewById(R.id.toolbar);

setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public void onCreate(Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_manage, container, false);
final String name = connection.getId() + "@" + connection.getHostName() + ":" + connection.getPort();
TextView label = (TextView) rootView.findViewById(R.id.connection_id_text);
TextView label = rootView.findViewById(R.id.connection_id_text);
label.setText(name);

Button deleteButton = (Button) rootView.findViewById(R.id.delete_button);
Button deleteButton = rootView.findViewById(R.id.delete_button);
deleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -73,7 +73,7 @@ public void onClick(View v) {
}
});

Button editButton = (Button) rootView.findViewById(R.id.edit_button);
Button editButton = rootView.findViewById(R.id.edit_button);
editButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_publish, container, false);
EditText topicText = (EditText) rootView.findViewById(R.id.topic);
EditText messageText = (EditText) rootView.findViewById(R.id.message);
Spinner qos = (Spinner) rootView.findViewById(R.id.qos_spinner);
final Switch retain = (Switch) rootView.findViewById(R.id.retain_switch);
EditText topicText = rootView.findViewById(R.id.topic);
EditText messageText = rootView.findViewById(R.id.message);
Spinner qos = rootView.findViewById(R.id.qos_spinner);
final Switch retain = rootView.findViewById(R.id.retain_switch);
topicText.setText(topic);

topicText.addTextChangedListener(new TextWatcher() {
Expand Down Expand Up @@ -111,7 +111,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
qos.setAdapter(adapter);

Button publishButton = (Button) rootView.findViewById(R.id.publish_button);
Button publishButton = rootView.findViewById(R.id.publish_button);
publishButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_subscriptions, container, false);
Button subscribeButton = (Button) rootView.findViewById(R.id.subscribe_button);
Button subscribeButton = rootView.findViewById(R.id.subscribe_button);

subscribeButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -63,7 +63,7 @@ public void onClick(View v) {
}
});

ListView subscriptionListView = (ListView) rootView.findViewById(R.id.subscription_list_view);
ListView subscriptionListView = rootView.findViewById(R.id.subscription_list_view);
SubscriptionListItemAdapter adapter = new SubscriptionListItemAdapter(this.getActivity(), subscriptions);

adapter.addOnUnsubscribeListner(new SubscriptionListItemAdapter.OnUnsubscribeListner() {
Expand All @@ -86,9 +86,9 @@ public void onUnsubscribe(Subscription subscription) {
private void showInputDialog() {
LayoutInflater layoutInflater = (LayoutInflater) this.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams") View promptView = layoutInflater.inflate(R.layout.subscription_dialog, null);
final EditText topicText = (EditText) promptView.findViewById(R.id.subscription_topic_edit_text);
final EditText topicText = promptView.findViewById(R.id.subscription_topic_edit_text);

final Spinner qos = (Spinner) promptView.findViewById(R.id.subscription_qos_spinner);
final Spinner qos = promptView.findViewById(R.id.subscription_qos_spinner);
final ArrayAdapter<CharSequence> adapter = ArrayAdapter
.createFromResource(getActivity(), R.array.qos_options, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Expand All @@ -105,7 +105,7 @@ public void onNothingSelected(AdapterView<?> parent) {
}
});

final Switch notifySwitch = (Switch) promptView.findViewById(R.id.show_notifications_switch);
final Switch notifySwitch = promptView.findViewById(R.id.show_notifications_switch);

AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
alertDialogBuilder.setView(promptView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class MyViewHolder extends RecyclerView.ViewHolder {

public MyViewHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.title);
icon = (ImageView) itemView.findViewById(R.id.connection_icon);
title = itemView.findViewById(R.id.title);
icon = itemView.findViewById(R.id.connection_icon);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public MessageListItemAdapter(Context context, ArrayList<ReceivedMessage> messag
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.message_list_item, parent, false);
TextView topicTextView = (TextView) rowView.findViewById(R.id.message_topic_text);
TextView messageTextView = (TextView) rowView.findViewById(R.id.message_text);
TextView dateTextView = (TextView) rowView.findViewById(R.id.message_date_text);
TextView topicTextView = rowView.findViewById(R.id.message_topic_text);
TextView messageTextView = rowView.findViewById(R.id.message_text);
TextView dateTextView = rowView.findViewById(R.id.message_date_text);
messageTextView.setText(new String(messages.get(position).getMessage().getPayload()));
topicTextView.setText(context.getString(R.string.topic_fmt, messages.get(position).getTopic()));
DateFormat dateTimeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public SubscriptionListItemAdapter(Context context, ArrayList<Subscription> topi
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.subscription_list_item, parent, false);
TextView topicTextView = (TextView) rowView.findViewById(R.id.message_text);
ImageView topicDeleteButton = (ImageView) rowView.findViewById(R.id.topic_delete_image);
TextView qosTextView = (TextView) rowView.findViewById(R.id.qos_label);
TextView topicTextView = rowView.findViewById(R.id.message_text);
ImageView topicDeleteButton = rowView.findViewById(R.id.topic_delete_image);
TextView qosTextView = rowView.findViewById(R.id.qos_label);
topicTextView.setText(topics.get(position).getTopic());
String qosString = context.getString(R.string.qos_text, topics.get(position).getQos());
qosTextView.setText(qosString);
TextView notifyTextView = (TextView) rowView.findViewById(R.id.show_notifications_label);
TextView notifyTextView = rowView.findViewById(R.id.show_notifications_label);
String notifyString = context
.getString(R.string.notify_text, (topics.get(position).isEnableNotifications() ? context.getString(R.string.enabled) : context
.getString(R.string.disabled)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public TextSelectComponent(Context context, AttributeSet attr) {
this.context = context;
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.text_select, this);
TextView mainLabel = (TextView) findViewById(R.id.mainLabel);
this.subLabel = (TextView) findViewById(R.id.subLabel);
RelativeLayout textSelectLayout = (RelativeLayout) findViewById(R.id.container);
TextView mainLabel = findViewById(R.id.mainLabel);
this.subLabel = findViewById(R.id.subLabel);
RelativeLayout textSelectLayout = findViewById(R.id.container);
final TypedArray attributeArray = context.obtainStyledAttributes(attr, R.styleable.TextSelectComponent);
mainLabel.setText(attributeArray.getString(R.styleable.TextSelectComponent_main_label));
this.subLabel.setText(attributeArray.getString(R.styleable.TextSelectComponent_default_value));
Expand All @@ -62,9 +62,9 @@ private void showInputDialog() {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@SuppressLint("InflateParams")
View promptView = layoutInflater.inflate(R.layout.text_input_dialog, null);
TextView promptText = (TextView) promptView.findViewById(R.id.textView);
TextView promptText = promptView.findViewById(R.id.textView);
promptText.setText(inputTitle);
final EditText promptEditText = (EditText) promptView.findViewById(R.id.edittext);
final EditText promptEditText = promptView.findViewById(R.id.edittext);
if (this.numberInput) {
Log.i(TAG, "NUMBER INPUT");
promptEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.paho.android.service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ android.libraryVariants.all { variant ->
ext.androidJar =
"${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
options.links("http://docs.oracle.com/javase/7/docs/api/")
options.links("http://d.android.com/reference/")
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest package="org.eclipse.paho.android.service"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,7 @@ public void onReceive(Context context, Intent intent) {
// by requesting a wake lock - we request the minimum possible wake
// lock - just enough to keep the CPU running until we've finished
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wl = pm
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT");
WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MQTT");
wl.acquire();
traceDebug(TAG, "Reconnect for Network recovery.");
if (isOnline()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MqttTokenAndroid implements IMqttToken {
* @see org.eclipse.paho.client.mqttv3.IMqttToken#waitForCompletion()
*/
@Override
public void waitForCompletion() throws MqttException, MqttSecurityException {
public void waitForCompletion() throws MqttException {
synchronized (waitObject) {
try {
waitObject.wait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public int getItemCount() {
public static class ViewHolder extends RecyclerView.ViewHolder {
public TextView mTextView;

public ViewHolder(View v) {
super(v);
mTextView = (TextView) v.findViewById(R.id.row_text);
public ViewHolder(View view) {
super(view);
mTextView = view.findViewById(R.id.row_text);
}
}

Expand Down
Loading

0 comments on commit cac91b4

Please sign in to comment.