Differential D3373 Diff 8188 src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java
Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java
Context not available. | |||||
28 | import android.widget.AdapterView; | 28 | import android.widget.AdapterView; | ||
---|---|---|---|---|---|
29 | import android.widget.ListView; | 29 | import android.widget.ListView; | ||
30 | 30 | | |||
31 | import org.json.JSONException; | | |||
32 | import org.json.JSONObject; | | |||
33 | import org.kde.kdeconnect.BackgroundService; | 31 | import org.kde.kdeconnect.BackgroundService; | ||
34 | import org.kde.kdeconnect.Device; | 32 | import org.kde.kdeconnect.Device; | ||
35 | import org.kde.kdeconnect.UserInterface.List.ListAdapter; | 33 | import org.kde.kdeconnect.UserInterface.List.ListAdapter; | ||
36 | import org.kde.kdeconnect_tp.R; | 34 | import org.kde.kdeconnect_tp.R; | ||
37 | 35 | | |||
38 | import java.util.ArrayList; | 36 | import java.util.ArrayList; | ||
39 | import java.util.Collections; | | |||
40 | import java.util.Comparator; | | |||
41 | 37 | | |||
42 | public class RunCommandActivity extends ActionBarActivity { | 38 | public class RunCommandActivity extends ActionBarActivity { | ||
43 | 39 | | |||
Context not available. | |||||
60 | public void run() { | 56 | public void run() { | ||
61 | ListView view = (ListView) findViewById(R.id.listView1); | 57 | ListView view = (ListView) findViewById(R.id.listView1); | ||
62 | 58 | | |||
63 | final ArrayList<ListAdapter.Item> commandItems = new ArrayList<>(); | 59 | final ArrayList<ListAdapter.Item> commandItems = plugin.getCommandList(); | ||
64 | for (JSONObject obj : plugin.getCommandList()) { | | |||
65 | try { | | |||
66 | commandItems.add(new CommandEntry(obj.getString("name"), | | |||
67 | obj.getString("command"), obj.getString("key"))); | | |||
68 | } catch (JSONException e) { | | |||
69 | e.printStackTrace(); | | |||
70 | } | | |||
71 | } | | |||
72 | | ||||
73 | Collections.sort(commandItems, new Comparator<ListAdapter.Item>() { | | |||
74 | @Override | | |||
75 | public int compare(ListAdapter.Item lhs, ListAdapter.Item rhs) { | | |||
76 | String lName = ((CommandEntry) lhs).getName(); | | |||
77 | String rName = ((CommandEntry) rhs).getName(); | | |||
78 | return lName.compareTo(rName); | | |||
79 | } | | |||
80 | }); | | |||
81 | 60 | | |||
82 | ListAdapter adapter = new ListAdapter(RunCommandActivity.this, commandItems); | 61 | ListAdapter adapter = new ListAdapter(RunCommandActivity.this, commandItems); | ||
83 | 62 | | |||
Context not available. |