Browse Source

init layouts and adapter

pull/61/merge
Thodoris1999 6 years ago
parent
commit
c1dbc4a8ea
  1. 41
      app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutAdapter.java
  2. 34
      app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java
  3. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxTask.java
  4. 1
      app/src/main/res/layout/fragment_recent.xml
  5. 34
      app/src/main/res/layout/fragment_shoutbox.xml
  6. 6
      app/src/main/res/layout/shout.xml

41
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<ShoutAdapter.ShoutViewHolder> {
private ArrayList<Shout> shouts;
public ShoutAdapter(ArrayList<Shout> 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);
}
}
}

34
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);
}
}

4
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<ArrayList<Shout>> {
@Override
protected int getResultCode(Response response, ArrayList<Shout> data) {
return 0;
return data.size() > 0 ? NetworkResultCodes.SUCCESSFUL : NetworkResultCodes.PERFORM_TASK_ERROR;
}
}

1
app/src/main/res/layout/fragment_recent.xml

@ -34,5 +34,4 @@
android:visibility="invisible"
app:mpb_indeterminateTint="@color/accent"
app:mpb_progressStyle="horizontal"/>
</RelativeLayout>

34
app/src/main/res/layout/fragment_shoutbox.xml

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<gr.thmmy.mthmmy.utils.CustomRecyclerView
android:id="@+id/shoutbox_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/shout"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/progressBar"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding"
android:layout_width="match_parent"
android:layout_height="@dimen/progress_bar_height"
android:layout_alignParentTop="true"
android:indeterminate="true"
android:visibility="invisible"
app:mpb_indeterminateTint="@color/accent"
app:mpb_progressStyle="horizontal"/>
</RelativeLayout>

6
app/src/main/res/layout/shout.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
Loading…
Cancel
Save