aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java
diff options
context:
space:
mode:
authorKyle Horimoto <khorimoto@gmail.com>2015-09-15 10:50:03 -0700
committerKyle Horimoto <khorimoto@gmail.com>2015-09-15 10:50:03 -0700
commit060439206855d3dd1b9bcb9d01fcdd0d4e17209c (patch)
tree43bb6208ba60ff6a73b96ae621ddb459ad1b580f /app/src/main/java
parent170638c7e3295c6fe7b0d5c644db8368845b2ad5 (diff)
downloadconnectbot-060439206855d3dd1b9bcb9d01fcdd0d4e17209c.tar.gz
connectbot-060439206855d3dd1b9bcb9d01fcdd0d4e17209c.tar.bz2
connectbot-060439206855d3dd1b9bcb9d01fcdd0d4e17209c.zip
Clean up code.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/org/connectbot/HostListActivity.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/app/src/main/java/org/connectbot/HostListActivity.java b/app/src/main/java/org/connectbot/HostListActivity.java
index cfe935c..bfdcc55 100644
--- a/app/src/main/java/org/connectbot/HostListActivity.java
+++ b/app/src/main/java/org/connectbot/HostListActivity.java
@@ -84,9 +84,9 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
private List<HostBean> hosts;
protected LayoutInflater inflater = null;
- private View mEmptyView;
- private RecyclerView mRecyclerView;
+ private RecyclerView mHostListView;
private HostAdapter mAdapter;
+ private View mEmptyView;
protected boolean sortedByColor = false;
@@ -185,10 +185,10 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
super.onCreate(icicle);
setContentView(R.layout.act_hostlist);
- mRecyclerView = (RecyclerView) findViewById(R.id.list);
- mRecyclerView.setHasFixedSize(true);
- mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
- mRecyclerView.addItemDecoration(new HostListItemDecoration(this));
+ mHostListView = (RecyclerView) findViewById(R.id.list);
+ mHostListView.setHasFixedSize(true);
+ mHostListView.setLayoutManager(new LinearLayoutManager(this));
+ mHostListView.addItemDecoration(new HostListItemDecoration(this));
mEmptyView = findViewById(R.id.empty);
@@ -225,9 +225,7 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
this.sortedByColor = prefs.getBoolean(PreferenceConstants.SORT_BY_COLOR, false);
- //this.list.setSelector(R.drawable.highlight_disabled_pressed);
-
- this.registerForContextMenu(mRecyclerView);
+ this.registerForContextMenu(mHostListView);
quickconnect = (TextView) this.findViewById(R.id.front_quickconnect);
quickconnect.setVisibility(makingShortcut ? View.GONE : View.VISIBLE);
@@ -415,7 +413,7 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
}
mAdapter = new HostAdapter(this, hosts, bound);
- mRecyclerView.setAdapter(mAdapter);
+ mHostListView.setAdapter(mAdapter);
adjustViewVisibility();
}
@@ -424,10 +422,13 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
updateList();
}
+ /**
+ * If the host list is empty, hides the list and shows the empty message; otherwise, shows
+ * the list and hides the empty message.
+ */
private void adjustViewVisibility() {
- Log.d(TAG, "num items: " + mAdapter.getItemCount());
boolean isEmpty = mAdapter.getItemCount() == 0;
- mRecyclerView.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
+ mHostListView.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
mEmptyView.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
}
@@ -435,11 +436,11 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
private final LayoutInflater inflater;
private final List<HostBean> hosts;
private final TerminalManager manager;
- private Context context;
+ private final Context context;
public final static int STATE_UNKNOWN = 1, STATE_CONNECTED = 2, STATE_DISCONNECTED = 3;
- public class ViewHolder extends RecyclerView.ViewHolder
+ class ViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener, View.OnCreateContextMenuListener {
public final ImageView icon;
public final TextView nickname;
@@ -645,6 +646,10 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
}
}
+ /**
+ * Item decorations for host list items, which adds a divider between items and leaves a
+ * small offset at the top of the list to adhere to the Material Design spec.
+ */
private class HostListItemDecoration extends RecyclerView.ItemDecoration {
private final int[] ATTRS = new int[]{
android.R.attr.listDivider
@@ -678,7 +683,8 @@ public class HostListActivity extends Activity implements OnHostStatusChangedLis
}
@Override
- public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
+ public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
+ RecyclerView.State state) {
int top = parent.getChildAdapterPosition(view) == 0 ? TOP_LIST_OFFSET : 0;
outRect.set(0, top, 0, mDivider.getIntrinsicHeight());
}
D; font-weight: bold } /* Literal.Number.Integer.Long */
/******************************************************************************
 *
 * Name: acoutput.h -- debug output
 *
 *****************************************************************************/

/*
 * Copyright (C) 2000 - 2007, R. Byron Moore
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions, and the following disclaimer,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    substantially similar to the "NO WARRANTY" disclaimer below
 *    ("Disclaimer") and any redistribution must be conditioned upon
 *    including a substantially similar Disclaimer requirement for further
 *    binary redistribution.
 * 3. Neither the names of the above-listed copyright holders nor the names
 *    of any contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE