use of ml.qingsu.fuckview.ui.fragments.select_app.SelectAppWizard in project fuckView by w568w.
the class MainFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
context = getActivity();
pm = context.getPackageManager();
FrameLayout layout = (FrameLayout) inflater.inflate(R.layout.main_fragment, null);
listView = (ListView) layout.findViewById(R.id.listView);
models = MainActivity.read();
try {
Collections.sort(models, new Comparator<BlockModel>() {
@Override
public int compare(BlockModel blockModel, BlockModel t1) {
String s1 = getAppTitle(pm, blockModel.packageName);
String s2 = getAppTitle(pm, t1.packageName);
// Synopsis: Updated sort behavior for Arrays and Collections may throw an IllegalArgumentException
if (s1.equals(s2)) {
return 0;
}
return Collator.getInstance(Locale.CHINA).compare(s1, s2);
}
});
} catch (IllegalArgumentException e) {
// So we will not sort them,OK?
e.printStackTrace();
}
adapter = new AppAdapter();
listView.setAdapter(adapter);
registerForContextMenu(listView);
final FloatingActionButton button = (FloatingActionButton) layout.findViewById(R.id.fab);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SelectAppWizard tw = new SelectAppWizard();
Bundle bundle = new Bundle();
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("system_app", false)) {
bundle.putBoolean("sys", true);
}
tw.setArguments(bundle);
if (context instanceof MainActivity) {
((MainActivity) context).setFragment(tw);
}
}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
BlockModel model = models.get(i);
Bundle bundle = new Bundle();
bundle.putString("pkg", model.packageName);
bundle.putString("record", model.record);
bundle.putString("className", model.className);
InfoFragment infoFragment = new InfoFragment();
infoFragment.setArguments(bundle);
if (context instanceof MainActivity) {
((MainActivity) context).setFragment(infoFragment);
}
}
});
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
/* 标记是否滑动 */
boolean scrollFlag = false;
/* 标记第一次进入,因为第一次进来lastVisibleItemPosition默认为0, */
boolean isFirst = true;
/*
此时如果listview的第一个显示的条目不是第一个(下表为0),则往下滑也会出现firstVisibleItem>lastVisibleItemPosition的情况
所以第一次进入时不做操作,第二次进来已经给lastVisibleItemPosition赋值,就可以判断了
*/
/* 标记上次的显示位置 */
int lastVisibleItemPosition;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
scrollFlag = scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (!isFirst) {
if (firstVisibleItem < lastVisibleItemPosition) {
button.show();
// 执行向上滑动时要做的逻辑
} else if (firstVisibleItem > lastVisibleItemPosition) {
button.hide();
}
// 记录当前条目
lastVisibleItemPosition = firstVisibleItem;
}
isFirst = false;
}
});
return layout;
}
use of ml.qingsu.fuckview.ui.fragments.select_app.SelectAppWizard in project fuckView by w568w.
the class WelcomeFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.welcome_fragment, null);
layout.findViewById(R.id.welcome_guide).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://w568.wodemo.net/entry/467891")));
} catch (ActivityNotFoundException a) {
a.printStackTrace();
Toast.makeText(getActivity(), getString(R.string.unsupport_of_package), Toast.LENGTH_SHORT).show();
}
}
});
layout.findViewById(R.id.welcome_pass).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).setFragmentWithoutBack(new SelectAppWizard());
}
}
});
return layout;
}
use of ml.qingsu.fuckview.ui.fragments.select_app.SelectAppWizard in project fuckView by w568w.
the class MainActivity method onCreate.
@SuppressLint("WorldReadableFiles")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme", false)) {
setTheme(R.style.DayTheme);
}
setContentView(R.layout.activity_main);
checkAndCallPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
sSharedPreferences = getSharedPreferences("data", Context.MODE_WORLD_READABLE);
dealWithIntent();
if (FirstRun.isFirstRun(this, "app")) {
setFragmentWithoutBack(new WelcomeFragment());
} else if ("".equals(readPreferences(LIST_NAME))) {
setFragmentWithoutBack(new SelectAppWizard());
if (!isModuleActive()) {
new AlertDialog.Builder(MainActivity.this).setTitle(R.string.xposed_is_unabled).setMessage(R.string.enable_module).setPositiveButton(R.string.OK, null).show();
}
} else {
setFragmentWithoutBack(new MainFragment());
if (!isModuleActive()) {
new AlertDialog.Builder(MainActivity.this).setTitle(R.string.xposed_is_unabled).setMessage(R.string.enable_module).setPositiveButton(R.string.OK, null).show();
}
}
}
Aggregations