Skip to content

Commit

Permalink
Added: add button to refresh application list in main page
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleo committed Mar 9, 2017
1 parent b452b10 commit 9b04c52
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 9 deletions.
Binary file removed res/drawable-hdpi/goback.png
Binary file not shown.
Binary file added res/drawable-hdpi/left_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-hdpi/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/drawable-hdpi/settings_pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions res/drawable/settings_button.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/settings_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/settings_pressed" android:state_focused="true"/>
<item android:drawable="@drawable/settings"></item>
</selector>
4 changes: 2 additions & 2 deletions res/layout/navigation_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:id="@+id/go_back"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/btn_back" />
android:src="@drawable/left_arrow" />
</LinearLayout>

<TextView
Expand All @@ -38,7 +38,7 @@
android:layout_height="match_parent"
android:layout_weight="0.1"
android:gravity="center_horizontal|center_vertical" >

<ImageView
android:id="@+id/btn_set"
android:layout_width="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,6 @@

<string name="root_failed_notification">无法获取root权限,请确认手机是否已root</string>
<string name="stop_when_exited">应用退出后停止监听</string>

<string name="update_list">列表更新成功</string>
</resources>
2 changes: 1 addition & 1 deletion res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dimen name="button_height">40dp</dimen>

<dimen name="image_padding">10dp</dimen>
<dimen name="image_padding_small">5dp</dimen>
<dimen name="image_padding_small">10dp</dimen>

<dimen name="line_height">1px</dimen>

Expand Down
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@
<string name="root_notification">(root is necessary)</string>
<string name="root_failed_notification">Fail to get root permission, please check if this phone is rooted</string>
<string name="stop_when_exited">Stop monitoring when app exited</string>

<string name="update_list">Update List Successfully</string>
</resources>
25 changes: 21 additions & 4 deletions src/com/netease/qa/emmagee/activity/MainPageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class MainPageActivity extends Activity {
private ImageView ivBtnSet;
private LinearLayout layBtnSet;
private Long mExitTime = (long) 0;
private ListAdapter la;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -128,7 +129,9 @@ public void onClick(View v) {
}
}
});
lstViProgramme.setAdapter(new ListAdapter());

la = new ListAdapter(processInfo.getAllPackages(getBaseContext()));
lstViProgramme.setAdapter(la);
lstViProgramme.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Expand All @@ -138,14 +141,23 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
});

nbTitle.setText(getString(R.string.app_name));
ivGoBack.setVisibility(ImageView.INVISIBLE);
ivGoBack.setImageResource(R.drawable.refresh);
ivBtnSet.setImageResource(R.drawable.settings_button);
layBtnSet.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
goToSettingsActivity();
}
});

ivGoBack.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Toast.makeText(MainPageActivity.this, R.string.update_list, Toast.LENGTH_SHORT).show();
la.swapItems(processInfo.getAllPackages(getBaseContext()));
}
});

receiver = new UpdateReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(EmmageeService.SERVICE_ACTION);
Expand Down Expand Up @@ -255,8 +267,8 @@ private class ListAdapter extends BaseAdapter {
Programe checkedProg;
int lastCheckedPosition = -1;

public ListAdapter() {
programes = processInfo.getAllPackages(getBaseContext());
public ListAdapter(List<Programe> programes) {
this.programes = programes;
}

@Override
Expand All @@ -273,6 +285,11 @@ public Object getItem(int position) {
public long getItemId(int position) {
return position;
}

public void swapItems(List<Programe> programes) {
this.programes = programes;
notifyDataSetChanged();
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
Expand Down

0 comments on commit 9b04c52

Please sign in to comment.