Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
fix(adapter): validate get position on data
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <[email protected]>
  • Loading branch information
rafaelje authored and Hector Rondon committed Apr 12, 2018
1 parent 3d78330 commit c43e9cd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,15 @@ public long getItemId(int position) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {

Application app = data[position];

View vi = inflater.inflate(R.layout.list_item_application, null);
Application app;

try {
app = data[position];
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return vi;
}

TextView txtStatus = vi.findViewById(R.id.txtStatus);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.widget.TextView;

import org.flyve.mdm.agent.R;
import org.flyve.mdm.agent.utils.FlyveLog;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -85,11 +86,17 @@ public long getItemId(int position) {
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
HashMap<String, String> hashdata;
hashdata = this.data.get(position);


View vi = inflater.inflate(R.layout.list_item_connectivity, null);

HashMap<String, String> hashdata;
try {
hashdata = data.get(position);
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return vi;
}

TextView lblDescription = vi.findViewById(R.id.lblDescription);
lblDescription.setText(hashdata.get("description"));

Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/org/flyve/mdm/agent/adapter/DrawerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import org.flyve.mdm.agent.R;
import org.flyve.mdm.agent.utils.FlyveLog;

import java.util.HashMap;
import java.util.List;

Expand Down Expand Up @@ -83,10 +86,16 @@ public long getItemId(int position) {
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
HashMap<String, String> hashdata;
hashdata = this.data.get(position);

View vi = inflater.inflate(R.layout.list_item_drawer, null);
HashMap<String, String> hashdata;

try {
hashdata = data.get(position);
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return vi;
}

View viewSeparator = vi.findViewById(R.id.viewSeparator);
if(hashdata.containsKey("separator") && "true".equalsIgnoreCase(hashdata.get("separator"))) {
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/org/flyve/mdm/agent/adapter/FilesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ public long getItemId(int position) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {

File file = data[position];

View vi = inflater.inflate(R.layout.list_item_file, null);
File file;

try {
file = data[position];
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return vi;
}

TextView txtFileName = vi.findViewById(R.id.txtFileName);
txtFileName.setText(file.fileName);
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/org/flyve/mdm/agent/adapter/LogAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ public long getItemId(int position) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {

HashMap<String, String> hashdata = data.get(position);

View vi = inflater.inflate(R.layout.list_item_log, null);
HashMap<String, String> hashdata;

try {
hashdata = data.get(position);
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return vi;
}

TextView txtType = vi.findViewById(R.id.txtType);
txtType.setText(hashdata.get("type"));
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/org/flyve/mdm/agent/adapter/PoliciesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.widget.TextView;

import org.flyve.mdm.agent.R;
import org.flyve.mdm.agent.utils.FlyveLog;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -84,10 +85,16 @@ public long getItemId(int position) {
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
HashMap<String, String> hashdata;
hashdata = this.data.get(position);


View vi = inflater.inflate(R.layout.list_item_policies, null);
HashMap<String, String> hashdata;

try {
hashdata = data.get(position);
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return vi;
}

TextView lblDescription = vi.findViewById(R.id.lblDescription);
lblDescription.setText(hashdata.get("description"));
Expand Down

0 comments on commit c43e9cd

Please sign in to comment.