Browse Source

Board init, layout & color changes

pull/24/head
Ezerous 8 years ago
parent
commit
4f6c6b225c
  1. 10
      app/src/main/AndroidManifest.xml
  2. 48
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  3. 14
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  4. 24
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java
  5. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
  6. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java
  7. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  8. 10
      app/src/main/java/gr/thmmy/mthmmy/data/Board.java
  9. 10
      app/src/main/java/gr/thmmy/mthmmy/data/Category.java
  10. 40
      app/src/main/res/layout/activity_board.xml
  11. 2
      app/src/main/res/layout/fragment_recent.xml
  12. 2
      app/src/main/res/values/colors.xml

10
app/src/main/AndroidManifest.xml

@ -49,11 +49,19 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity"/>
</activity>
<activity android:name=".activities.base.BaseActivity"/>
<activity
android:name=".activities.profile.ProfileActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".activities.board.BoardActivity"
android:configChanges="orientation|screenSize"
android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activities.main.MainActivity"/>
</activity>
</application>
</manifest>

48
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -0,0 +1,48 @@
package gr.thmmy.mthmmy.activities.board;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.base.BaseActivity;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
public class BoardActivity extends BaseActivity {
/**
* Debug Tag for logging debug output to LogCat
*/
private static final String TAG = "BoardActivity";
/**
* The key to use when putting board's url String to {@link BoardActivity}'s Bundle.
*/
public static final String EXTRAS_BOARD_URL = "BOARD_URL";
/**
* The key to use when putting board's title String to {@link BoardActivity}'s Bundle.
*/
public static final String EXTRAS_BOARD_TITLE = "BOARD_TITLE";
private MaterialProgressBar progressBar;
private String boardTitle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_board);
Bundle extras = getIntent().getExtras();
boardTitle = extras.getString("BOARD_TITLE");
//Initializes graphics
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(boardTitle);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
createDrawer();
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar);
}
}

14
app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java

@ -13,11 +13,15 @@ import android.widget.Toast;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.base.BaseActivity;
import gr.thmmy.mthmmy.activities.board.BoardActivity;
import gr.thmmy.mthmmy.activities.main.forum.ForumFragment;
import gr.thmmy.mthmmy.activities.main.recent.RecentFragment;
import gr.thmmy.mthmmy.activities.topic.TopicActivity;
import gr.thmmy.mthmmy.data.Board;
import gr.thmmy.mthmmy.data.TopicSummary;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.EXTRAS_BOARD_TITLE;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.EXTRAS_BOARD_URL;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.EXTRAS_TOPIC_TITLE;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.EXTRAS_TOPIC_URL;
import static gr.thmmy.mthmmy.session.SessionManager.LOGGED_OUT;
@ -83,13 +87,21 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
}
@Override
public void onFragmentInteraction(TopicSummary topicSummary) {
public void onRecentFragmentInteraction(TopicSummary topicSummary) {
Intent i = new Intent(MainActivity.this, TopicActivity.class);
i.putExtra(EXTRAS_TOPIC_URL, topicSummary.getTopicUrl());
i.putExtra(EXTRAS_TOPIC_TITLE, topicSummary.getTitle());
startActivity(i);
}
@Override
public void onForumFragmentInteraction(Board board) {
Intent i = new Intent(MainActivity.this, BoardActivity.class);
i.putExtra(EXTRAS_BOARD_URL, board.getBoardURL());
i.putExtra(EXTRAS_BOARD_TITLE, board.getTitle());
startActivity(i);
}
//---------------------------------FragmentPagerAdapter---------------------------------------------
/**

24
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java

@ -6,7 +6,6 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bignerdranch.expandablerecyclerview.ChildViewHolder;
@ -62,6 +61,7 @@ class ForumAdapter extends ExpandableRecyclerAdapter<Category, Board, ForumAdapt
@Override
public void onBindChildViewHolder(@NonNull BoardViewHolder childViewHolder, int parentPosition, int childPosition, @NonNull Board child) {
childViewHolder.board = categories.get(parentPosition).getBoards().get(childPosition);
childViewHolder.bind(child);
}
@ -76,7 +76,7 @@ class ForumAdapter extends ExpandableRecyclerAdapter<Category, Board, ForumAdapt
}
void bind(Category category) {
categoryTextview.setText(category.getName());
categoryTextview.setText(category.getTitle());
}
}
@ -84,14 +84,30 @@ class ForumAdapter extends ExpandableRecyclerAdapter<Category, Board, ForumAdapt
class BoardViewHolder extends ChildViewHolder {
private TextView boardTextView;
public Board board;
BoardViewHolder(View itemView) {
super(itemView);
boardTextView = (TextView) itemView.findViewById(R.id.board);
}
void bind(Board board) {
boardTextView.setText(board.getName());
void bind(final Board board) {
boardTextView.setText(board.getTitle());
boardTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onForumFragmentInteraction(board); //?
}
}
});
}
}
}

3
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java

@ -149,7 +149,7 @@ public class ForumFragment extends BaseFragment
}
public interface ForumFragmentInteractionListener extends FragmentInteractionListener{
void onFragmentInteraction(TopicSummary topicSummary);
void onForumFragmentInteraction(Board board);
}
//---------------------------------------ASYNC TASK-----------------------------------
@ -179,7 +179,6 @@ public class ForumFragment extends BaseFragment
parse(document);
categories.clear();
categories.addAll(fetchedCategories);
Report.d(TAG, "SIZE: " + String.valueOf(fetchedCategories.get(0).getBoards().size()));
fetchedCategories.clear();
return 0;
} catch (IOException e) {

2
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java

@ -55,7 +55,7 @@ class RecentAdapter extends RecyclerView.Adapter<RecentAdapter.ViewHolder> {
if (null != mListener) {
// Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected.
mListener.onFragmentInteraction(holder.topic); //?
mListener.onRecentFragmentInteraction(holder.topic); //?
}

2
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java

@ -135,7 +135,7 @@ public class RecentFragment extends BaseFragment {
public interface RecentFragmentInteractionListener extends FragmentInteractionListener {
void onFragmentInteraction(TopicSummary topicSummary);
void onRecentFragmentInteraction(TopicSummary topicSummary);
}
//---------------------------------------ASYNC TASK-----------------------------------

10
app/src/main/java/gr/thmmy/mthmmy/data/Board.java

@ -3,21 +3,21 @@ package gr.thmmy.mthmmy.data;
import java.util.ArrayList;
public class Board {
private final String name;
private final String title;
private final String boardURL;
private ArrayList <Board> subBoards;
private ArrayList <TopicSummary> topicSummaries;
public Board(String name, String boardURL) {
this.name = name;
public Board(String title, String boardURL) {
this.title = title;
this.boardURL = boardURL;
subBoards = new ArrayList<>();
topicSummaries = new ArrayList<>();
}
public String getName() {
return name;
public String getTitle() {
return title;
}
public String getBoardURL() {

10
app/src/main/java/gr/thmmy/mthmmy/data/Category.java

@ -9,13 +9,13 @@ import static android.R.attr.id;
public class Category implements Parent<Board>
{
private final String name;
private final String title;
private final String categoryURL;
private boolean expanded = false;
private List<Board> boards;
public Category(String name, String categoryURL) {
this.name = name;
public Category(String title, String categoryURL) {
this.title = title;
this.categoryURL = categoryURL;
boards = new ArrayList<>();
}
@ -24,8 +24,8 @@ public class Category implements Parent<Board>
return id;
}
public String getName() {
return name;
public String getTitle() {
return title;
}
public String getCategoryURL() {

40
app/src/main/res/layout/activity_board.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.board.BoardActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/ToolbarTheme">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ToolbarTheme">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|center"
app:mpb_indeterminateTint="@color/accent"
android:visibility="invisible"
android:indeterminate="true"
app:mpb_progressStyle="horizontal"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" />
</android.support.design.widget.CoordinatorLayout>

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

@ -17,6 +17,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:paddingBottom="4dp"
android:paddingTop="4dp"
app:layoutManager="LinearLayoutManager"
tools:context=".activities.main.recent.RecentFragment"
tools:listitem="@layout/fragment_recent_row"/>

2
app/src/main/res/values/colors.xml

@ -27,7 +27,7 @@
<color name="primary">#2B2B2B</color>
<color name="primary_dark">#333333</color>
<color name="primary_light">#3C3C3C</color>
<color name="primary_lighter">#454545</color>
<color name="primary_lighter">#494949</color>
<color name="accent">#26A69A</color>
<color name="primary_text">#E7E7E7</color>
<color name="secondary_text">#757575</color>

Loading…
Cancel
Save