MCPcopy Create free account
hub / github.com/M66B/NetGuard / bindView

Method bindView

app/src/main/java/eu/faircode/netguard/AdapterLog.java:129–331  ·  view source on GitHub ↗
(final View view, final Context context, final Cursor cursor)

Source from the content-addressed store, hash-verified

127 }
128
129 @Override
130 public void bindView(final View view, final Context context, final Cursor cursor) {
131 // Get values
132 long time = cursor.getLong(colTime);
133 int version = (cursor.isNull(colVersion) ? -1 : cursor.getInt(colVersion));
134 int protocol = (cursor.isNull(colProtocol) ? -1 : cursor.getInt(colProtocol));
135 String flags = cursor.getString(colFlags);
136 String saddr = cursor.getString(colSAddr);
137 int sport = (cursor.isNull(colSPort) ? -1 : cursor.getInt(colSPort));
138 String daddr = cursor.getString(colDAddr);
139 int dport = (cursor.isNull(colDPort) ? -1 : cursor.getInt(colDPort));
140 String dname = (cursor.isNull(colDName) ? null : cursor.getString(colDName));
141 int uid = (cursor.isNull(colUid) ? -1 : cursor.getInt(colUid));
142 String data = cursor.getString(colData);
143 int allowed = (cursor.isNull(colAllowed) ? -1 : cursor.getInt(colAllowed));
144 int connection = (cursor.isNull(colConnection) ? -1 : cursor.getInt(colConnection));
145 int interactive = (cursor.isNull(colInteractive) ? -1 : cursor.getInt(colInteractive));
146
147 // Get views
148 TextView tvTime = view.findViewById(R.id.tvTime);
149 TextView tvProtocol = view.findViewById(R.id.tvProtocol);
150 TextView tvFlags = view.findViewById(R.id.tvFlags);
151 TextView tvSAddr = view.findViewById(R.id.tvSAddr);
152 TextView tvSPort = view.findViewById(R.id.tvSPort);
153 final TextView tvDaddr = view.findViewById(R.id.tvDAddr);
154 TextView tvDPort = view.findViewById(R.id.tvDPort);
155 final TextView tvOrganization = view.findViewById(R.id.tvOrganization);
156 final ImageView ivIcon = view.findViewById(R.id.ivIcon);
157 TextView tvUid = view.findViewById(R.id.tvUid);
158 TextView tvData = view.findViewById(R.id.tvData);
159 ImageView ivConnection = view.findViewById(R.id.ivConnection);
160 ImageView ivInteractive = view.findViewById(R.id.ivInteractive);
161
162 // Show time
163 tvTime.setText(new SimpleDateFormat("HH:mm:ss").format(time));
164
165 // Show connection type
166 if (connection <= 0)
167 ivConnection.setImageResource(allowed > 0 ? R.drawable.host_allowed : R.drawable.host_blocked);
168 else {
169 if (allowed > 0)
170 ivConnection.setImageResource(connection == 1 ? R.drawable.wifi_on : R.drawable.other_on);
171 else
172 ivConnection.setImageResource(connection == 1 ? R.drawable.wifi_off : R.drawable.other_off);
173 }
174 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
175 Drawable wrap = DrawableCompat.wrap(ivConnection.getDrawable());
176 DrawableCompat.setTint(wrap, allowed > 0 ? colorOn : colorOff);
177 }
178
179 // Show if screen on
180 if (interactive <= 0)
181 ivInteractive.setImageDrawable(null);
182 else {
183 ivInteractive.setImageResource(R.drawable.screen_on);
184 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
185 Drawable wrap = DrawableCompat.wrap(ivInteractive.getDrawable());
186 DrawableCompat.setTint(wrap, colorOn);

Callers

nothing calls this directly

Calls 5

getProtocolNameMethod · 0.95
getKnownPortMethod · 0.95
getKnownAddressMethod · 0.95
isKnownAddressMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected