fix: crash on notification events
This commit is contained in:
@@ -125,7 +125,8 @@ public class MyScriptListFragment extends ViewPagerFragment implements BackPress
|
|||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.onDetach();
|
super.onDetach();
|
||||||
mFloatingActionMenu.setOnFloatingActionButtonClickListener(null);
|
if (mFloatingActionMenu != null)
|
||||||
|
mFloatingActionMenu.setOnFloatingActionButtonClickListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
@@ -316,6 +317,9 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
|
|||||||
@BindView(R.id.title)
|
@BindView(R.id.title)
|
||||||
TextView mTitle;
|
TextView mTitle;
|
||||||
|
|
||||||
|
@BindView(R.id.sort)
|
||||||
|
ImageView mSort;
|
||||||
|
|
||||||
CategoryViewHolder(View itemView) {
|
CategoryViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
@@ -326,5 +330,17 @@ public class ScriptListView extends SwipeRefreshLayout implements SwipeRefreshLa
|
|||||||
mTitle.setText(isDirCategory ? R.string.text_directory : R.string.text_file);
|
mTitle.setText(isDirCategory ? R.string.text_directory : R.string.text_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.order)
|
||||||
|
void changeSortOrder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.sort)
|
||||||
|
void showSortOptions() {
|
||||||
|
PopupMenu popupMenu = new PopupMenu(getContext(), mSort);
|
||||||
|
popupMenu.inflate(R.menu.menu_sort_options);
|
||||||
|
popupMenu.setOnMenuItemClickListener(ScriptListView.this);
|
||||||
|
popupMenu.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/order"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
android:tint="#828384"/>
|
android:tint="#828384"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:id="@+id/sort"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
|||||||
19
app/src/main/res/menu/menu_sort_options.xml
Normal file
19
app/src/main/res/menu/menu_sort_options.xml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/text_name"/>
|
||||||
|
<item
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/text_time"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/text_size"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/text_type"
|
||||||
|
/>
|
||||||
|
</menu>
|
||||||
@@ -249,6 +249,9 @@
|
|||||||
<string name="text_forgot_password">忘记密码</string>
|
<string name="text_forgot_password">忘记密码</string>
|
||||||
<string name="text_username_cannot_be_empty">用户名不能为空</string>
|
<string name="text_username_cannot_be_empty">用户名不能为空</string>
|
||||||
<string name="text_password_cannot_be_empty">密码不能为空</string>
|
<string name="text_password_cannot_be_empty">密码不能为空</string>
|
||||||
|
<string name="text_time">时间</string>
|
||||||
|
<string name="text_size">大小</string>
|
||||||
|
<string name="text_type">类型</string>
|
||||||
|
|
||||||
|
|
||||||
<string-array name="record_control_keys">
|
<string-array name="record_control_keys">
|
||||||
|
|||||||
@@ -213,10 +213,11 @@ public class Events extends EventEmitter implements OnKeyListener, TouchObserver
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotification(final AccessibilityEvent event, final Notification notification) {
|
public void onNotification(final AccessibilityEvent event, final Notification notification) {
|
||||||
|
final NotificationInfo info = NotificationInfo.fromEvent(event);
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
emit("notification", NotificationInfo.fromEvent(event), notification);
|
emit("notification", info, notification);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ public interface NotificationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NotificationInfo(CharSequence packageName, List<CharSequence> list) {
|
public NotificationInfo(CharSequence packageName, List<CharSequence> list) {
|
||||||
mPackageName = packageName.toString();
|
mPackageName = packageName == null ? "" : packageName.toString();
|
||||||
mTexts = new ArrayList<>(list.size());
|
mTexts = new ArrayList<>(list.size());
|
||||||
for (CharSequence text : list) {
|
for (CharSequence text : list) {
|
||||||
mTexts.add(text.toString());
|
if (text != null) {
|
||||||
|
mTexts.add(text.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mTexts.size() > 0) {
|
if (mTexts.size() > 0) {
|
||||||
mText = mTexts.get(0);
|
mText = mTexts.get(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user