From c1dbc4a8ea26ff69821987dee2eda4b02ab12f66 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Thu, 4 Oct 2018 18:55:25 +0300 Subject: [PATCH] init layouts and adapter --- .../main/shoutbox/ShoutAdapter.java | 41 +++++++++++++++++++ .../main/shoutbox/ShoutboxFragment.java | 34 +++++++++++++++ .../main/shoutbox/ShoutboxTask.java | 4 +- app/src/main/res/layout/fragment_recent.xml | 1 - app/src/main/res/layout/fragment_shoutbox.xml | 34 +++++++++++++++ app/src/main/res/layout/shout.xml | 6 +++ 6 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java create mode 100644 app/src/main/res/layout/fragment_shoutbox.xml create mode 100644 app/src/main/res/layout/shout.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java new file mode 100644 index 00000000..542d90fc --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java @@ -0,0 +1,41 @@ +package gr.thmmy.mthmmy.activities.main.shoutbox; + +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; + +import androidx.annotation.NonNull; +import gr.thmmy.mthmmy.model.Shout; +import gr.thmmy.mthmmy.utils.CustomRecyclerView; + +public class ShoutAdapter extends CustomRecyclerView.Adapter { + private ArrayList shouts; + + public ShoutAdapter(ArrayList shouts) { + this.shouts = shouts; + } + + @NonNull + @Override + public ShoutViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return null; + } + + @Override + public void onBindViewHolder(@NonNull ShoutViewHolder holder, int position) { + + } + + @Override + public int getItemCount() { + return shouts.size(); + } + + static class ShoutViewHolder extends CustomRecyclerView.ViewHolder { + + public ShoutViewHolder(@NonNull View itemView) { + super(itemView); + } + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java index 25d659cc..4c0d08d9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java @@ -1,7 +1,41 @@ package gr.thmmy.mthmmy.activities.main.shoutbox; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.activities.main.forum.ForumFragment; import gr.thmmy.mthmmy.base.BaseFragment; +import gr.thmmy.mthmmy.utils.CustomRecyclerView; +import me.zhanghai.android.materialprogressbar.MaterialProgressBar; public class ShoutboxFragment extends BaseFragment { + private static final String TAG = "ShoutboxFragment"; + + private MaterialProgressBar progressBar; + + public static ForumFragment newInstance(int sectionNumber) { + ForumFragment fragment = new ForumFragment(); + Bundle args = new Bundle(); + args.putString(ARG_TAG, TAG); + args.putInt(ARG_SECTION_NUMBER, sectionNumber); + fragment.setArguments(args); + return fragment; + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + final View rootView = inflater.inflate(R.layout.fragment_shoutbox, container, false); + + progressBar = rootView.findViewById(R.id.progressBar); + CustomRecyclerView recyclerView = rootView.findViewById(R.id.shoutbox_recyclerview); + + return super.onCreateView(inflater, container, savedInstanceState); + } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java index 88dad072..74359195 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java @@ -2,11 +2,11 @@ package gr.thmmy.mthmmy.activities.main.shoutbox; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; -import org.jsoup.select.Elements; import java.util.ArrayList; import gr.thmmy.mthmmy.model.Shout; +import gr.thmmy.mthmmy.utils.NetworkResultCodes; import gr.thmmy.mthmmy.utils.parsing.NewParseTask; import gr.thmmy.mthmmy.utils.parsing.ParseException; import gr.thmmy.mthmmy.utils.parsing.ParseHelpers; @@ -37,6 +37,6 @@ public class ShoutboxTask extends NewParseTask> { @Override protected int getResultCode(Response response, ArrayList data) { - return 0; + return data.size() > 0 ? NetworkResultCodes.SUCCESSFUL : NetworkResultCodes.PERFORM_TASK_ERROR; } } diff --git a/app/src/main/res/layout/fragment_recent.xml b/app/src/main/res/layout/fragment_recent.xml index 372bc70c..356f96ae 100644 --- a/app/src/main/res/layout/fragment_recent.xml +++ b/app/src/main/res/layout/fragment_recent.xml @@ -34,5 +34,4 @@ android:visibility="invisible" app:mpb_indeterminateTint="@color/accent" app:mpb_progressStyle="horizontal"/> - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_shoutbox.xml b/app/src/main/res/layout/fragment_shoutbox.xml new file mode 100644 index 00000000..107db8b8 --- /dev/null +++ b/app/src/main/res/layout/fragment_shoutbox.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/shout.xml b/app/src/main/res/layout/shout.xml new file mode 100644 index 00000000..3509b841 --- /dev/null +++ b/app/src/main/res/layout/shout.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file