2017-01-27 03:38:53 +08:00
|
|
|
package com.topjohnwu.magisk;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.Fragment;
|
|
|
|
import android.os.Bundle;
|
2017-01-28 01:10:50 +08:00
|
|
|
import android.support.v7.widget.RecyclerView;
|
2017-01-27 03:38:53 +08:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2017-01-28 01:10:50 +08:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import com.topjohnwu.magisk.adapters.SuLogAdapter;
|
|
|
|
import com.topjohnwu.magisk.superuser.SuLogDatabaseHelper;
|
|
|
|
import com.topjohnwu.magisk.superuser.SuLogEntry;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
|
|
import butterknife.ButterKnife;
|
|
|
|
import butterknife.Unbinder;
|
2017-01-27 03:38:53 +08:00
|
|
|
|
|
|
|
public class SuLogFragment extends Fragment {
|
|
|
|
|
2017-01-28 01:10:50 +08:00
|
|
|
@BindView(R.id.empty_rv) TextView emptyRv;
|
|
|
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
|
|
|
|
|
|
|
private Unbinder unbinder;
|
2017-01-27 03:38:53 +08:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
|
Bundle savedInstanceState) {
|
|
|
|
// Inflate the layout for this fragment
|
2017-01-28 01:10:50 +08:00
|
|
|
View v = inflater.inflate(R.layout.fragment_su_log, container, false);
|
|
|
|
unbinder = ButterKnife.bind(this, v);
|
|
|
|
|
|
|
|
SuLogDatabaseHelper dbHelper = new SuLogDatabaseHelper(getActivity());
|
|
|
|
List<SuLogEntry> logs = dbHelper.getLogList();
|
|
|
|
|
|
|
|
if (logs.size() == 0) {
|
|
|
|
emptyRv.setVisibility(View.VISIBLE);
|
|
|
|
recyclerView.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
recyclerView.setAdapter(new SuLogAdapter(logs).getAdapter());
|
|
|
|
emptyRv.setVisibility(View.GONE);
|
|
|
|
recyclerView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return v;
|
2017-01-27 03:38:53 +08:00
|
|
|
}
|
|
|
|
|
2017-01-28 01:10:50 +08:00
|
|
|
@Override
|
|
|
|
public void onDestroyView() {
|
|
|
|
super.onDestroyView();
|
|
|
|
unbinder.unbind();
|
|
|
|
}
|
2017-01-27 03:38:53 +08:00
|
|
|
}
|