Skip to content

Commit

Permalink
add settings
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonQS committed Jun 3, 2018
1 parent ec2e94b commit 2aa083a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package com.qsboy.antirecall.access;

import android.accessibilityservice.AccessibilityService;
import android.graphics.Rect;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
Expand Down Expand Up @@ -159,7 +158,8 @@ private class WXAutoLogin {
private int time = 0;

public void flagEnable() {
time = 10;
if (App.isWeChatAutoLogin)
time = 10;
}

private void autoLoginWX() {
Expand Down
34 changes: 21 additions & 13 deletions app/src/main/java/com/qsboy/antirecall/ui/QQFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;

Expand Down Expand Up @@ -58,15 +57,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
max = dao.getMaxID(Table_Recalled_Messages);
handler = new Handler();

adjuster = view.findViewById(R.id.adjuster);
recyclerViewRecalled = view.findViewById(R.id.main_recycler_view_recall);
recyclerViewAll = view.findViewById(R.id.main_recycler_view_all);
adapterRecalled = new MessageAdapter(dao, null, getActivity(), App.THEME_BLUE);
adapterAll = new MessageAdapter(dao, null, getActivity(), App.THEME_RED);
adjuster = view.findViewById(R.id.adjuster);

initList(recyclerViewRecalled, adapterRecalled, prepareRecalledData());
initList(recyclerViewAll, adapterAll, prepareAllData());
if (App.isShowAllQQMessages) {
initList(recyclerViewAll, adapterAll, prepareAllData());
initAdjuster(view);
} else {
setRecyclerViewRecalledHeight(App.layoutHeight);
App.layoutHeight = -1;
adjuster.setVisibility(View.GONE);
}


return view;
}

private void initAdjuster(View view) {
adjuster.setVisibility(View.VISIBLE);
relativeLayout = view.findViewById(R.id.relative_layout_lists);
relativeLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
Expand Down Expand Up @@ -116,8 +128,6 @@ public boolean onTouch(View v, MotionEvent event) {
return true;
}
});

return view;
}

private void onMeasured() {
Expand All @@ -131,22 +141,20 @@ private void onMeasured() {

private void setRecyclerViewAllHeight(int height) {
ViewGroup.LayoutParams params = recyclerViewAll.getLayoutParams();
params.height = App.recyclerViewAllHeight = height;
params.height = height;
App.recyclerViewAllHeight = height;
// App.recyclerViewRecalledHeight = App.layoutHeight - height;
recyclerViewAll.setLayoutParams(params);
}

private void setRecyclerViewRecalledHeight(int height) {
ViewGroup.LayoutParams params = recyclerViewRecalled.getLayoutParams();
params.height = App.recyclerViewRecalledHeight = height;
params.height = height;
App.recyclerViewRecalledHeight = height;
// App.recyclerViewAllHeight = App.layoutHeight - height;
recyclerViewRecalled.setLayoutParams(params);
}

// private void setAdjusterY(int y) {
// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) adjuster.getLayoutParams();
// params.topMargin = App.adjusterY = y;
// adjuster.setLayoutParams(params);
// }

private void initList(RecyclerView recyclerView, MessageAdapter adapter, List<Messages> messages) {
if (messages != null && messages.size() != 0)
adapter.addData(messages);
Expand Down
62 changes: 27 additions & 35 deletions app/src/main/java/com/qsboy/antirecall/ui/WeChatFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class WeChatFragment extends Fragment {

String TAG = "WeChatFragment";
// RecyclerView recyclerView;
RecyclerView recyclerViewAll;
MessageAdapter adapterAll;
RecyclerView recyclerView;
MessageAdapter adapter;

ImageView adjuster;
Dao dao;
Expand All @@ -49,25 +49,31 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
View view = inflater.inflate(R.layout.list_messages, container, false);

dao = Dao.getInstance(getContext(), Dao.DB_NAME_WE_CHAT);
adapterAll = new MessageAdapter(dao, null, getActivity(), App.THEME_GREEN);
recyclerViewAll = view.findViewById(R.id.main_recycler_view_all);
max = dao.getMaxID(Table_Recalled_Messages);

recyclerView = view.findViewById(R.id.main_recycler_view_all);
adapter = new MessageAdapter(dao, null, getActivity(), App.THEME_GREEN);
adjuster = view.findViewById(R.id.adjuster);
adjuster.setVisibility(View.GONE);

List<Messages> messages = prepareAllData();
if (messages != null && messages.size() != 0)
adapterAll.addData(messages);

recyclerViewAll.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerViewAll.setAdapter(adapterAll);
adapter.addData(messages);

ItemDragAndSwipeCallback itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(adapterAll);
ItemDragAndSwipeCallback itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(adapter);
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemDragAndSwipeCallback);
itemTouchHelper.attachToRecyclerView(recyclerViewAll);
itemTouchHelper.attachToRecyclerView(recyclerView);

recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(adapter);

if (App.isSwipeRemoveOn)
adapter.enableSwipeItem();
else
adapter.disableSwipeItem();

adapterAll.enableSwipeItem();
adapterAll.setOnItemSwipeListener(onItemSwipeListener);
adapter.enableSwipeItem();
adapter.setOnItemSwipeListener(onItemSwipeListener);

return view;
}
Expand All @@ -84,7 +90,7 @@ public void clearView(RecyclerView.ViewHolder viewHolder, int pos) {

@Override
public void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos) {
List<Messages> data = adapterAll.getData();
List<Messages> data = adapter.getData();
if (data.size() <= pos) {
Log.i(TAG, "onItemSwiped: size is too small: " + pos);
return;
Expand All @@ -105,35 +111,21 @@ public List<Messages> prepareAllData() {
List<Messages> list = dao.queryAllTheLastMessage(dao.queryAllTables());
Log.i(TAG, "prepareAllData: list: " + list);
return list;
// List<Messages> list = new ArrayList<>();
// Messages messages;
// cursor[0] = max + 1 - adapter.getData().size();
// for (int i = 0; i < 10; i++) {
// while (true) {
// cursor[0]--;
// if (cursor[0] == 0)
// return list;
// if ((messages = dao.queryRecallById(cursor[0])) != null)
// break;
// }
// adapter.addData(messages);
// }
// return list;
}

// TODO: 24/04/2018 refresh
public void refresh() {
if (adapterAll == null)
if (adapter == null)
return;
if (recyclerViewAll == null)
if (recyclerView == null)
return;
List<Messages> messages = adapterAll.prepareData();
List<Messages> messages = adapter.prepareData();
if (messages != null && messages.size() != 0)
if (adapterAll.getData().size() != messages.size()) {
adapterAll.getData().clear();
adapterAll.addData(messages);
if (adapter.getData().size() != messages.size()) {
adapter.getData().clear();
adapter.addData(messages);
}
adapterAll.notifyDataSetChanged();
recyclerViewAll.setAdapter(adapterAll);
adapter.notifyDataSetChanged();
recyclerView.setAdapter(adapter);
}
}

0 comments on commit 2aa083a

Please sign in to comment.