diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-04-02 07:21:15 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-04-02 07:21:15 +0000 |
commit | 2d0aa76d3458800a7eeda357f85f38f11bcc0542 (patch) | |
tree | 47946170c858be81839d39631e51ea6743efc7d0 /app/src/main/java/ml | |
parent | 12f52ec4fd8876b43875f2971393404c91024469 (diff) | |
download | infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.tar infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.tar.gz infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.tar.bz2 infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.tar.lz infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.tar.xz infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.tar.zst infinity-for-reddit-2d0aa76d3458800a7eeda357f85f38f11bcc0542.zip |
New option: Crash Reports.
Diffstat (limited to 'app/src/main/java/ml')
3 files changed, 96 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java index 21f49973..2eb2de1d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LoginActivity.java @@ -95,6 +95,7 @@ public class LoginActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); + int llll = 0 / 0; setImmersiveModeNotApplicable(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CrashReportsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CrashReportsRecyclerViewAdapter.java new file mode 100644 index 00000000..641562b9 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CrashReportsRecyclerViewAdapter.java @@ -0,0 +1,45 @@ +package ml.docilealligator.infinityforreddit.adapters; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.List; + +import ml.docilealligator.infinityforreddit.R; + +public class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { + private List<String> crashReports; + + public CrashReportsRecyclerViewAdapter(List<String> crashReports) { + this.crashReports = crashReports; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new CrashReportViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_crash_report, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + ((CrashReportViewHolder) holder).crashReportTextView.setText(crashReports.get(position)); + } + + @Override + public int getItemCount() { + return crashReports == null ? 0 : crashReports.size(); + } + + private class CrashReportViewHolder extends RecyclerView.ViewHolder { + TextView crashReportTextView; + public CrashReportViewHolder(@NonNull View itemView) { + super(itemView); + crashReportTextView = (TextView) itemView; + } + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java new file mode 100644 index 00000000..6fee1427 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CrashReportsFragment.java @@ -0,0 +1,50 @@ +package ml.docilealligator.infinityforreddit.settings; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.crazylegend.crashyreporter.CrashyReporter; + +import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.adapters.CrashReportsRecyclerViewAdapter; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link CrashReportsFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class CrashReportsFragment extends Fragment { + + private Activity activity; + + public CrashReportsFragment() { + // Required empty public constructor + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + RecyclerView recyclerView = (RecyclerView) inflater.inflate(R.layout.fragment_crash_reports, container, false); + + recyclerView.setLayoutManager(new LinearLayoutManager(activity)); + recyclerView.setAdapter(new CrashReportsRecyclerViewAdapter(CrashyReporter.INSTANCE.getLogsAsStrings())); + + return recyclerView; + } + + @Override + public void onAttach(@NonNull Context context) { + super.onAttach(context); + activity = (Activity) context; + } +}
\ No newline at end of file |