|
@ -22,6 +22,8 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; |
|
|
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; |
|
|
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; |
|
|
|
|
|
|
|
|
public class BookmarkActivity extends BaseActivity { |
|
|
public class BookmarkActivity extends BaseActivity { |
|
|
|
|
|
private TextView boardsTitle; |
|
|
|
|
|
private TextView topicsTitle; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
@ -43,93 +45,100 @@ public class BookmarkActivity extends BaseActivity { |
|
|
LinearLayout bookmarksLinearView = (LinearLayout) findViewById(R.id.bookmarks_container); |
|
|
LinearLayout bookmarksLinearView = (LinearLayout) findViewById(R.id.bookmarks_container); |
|
|
LayoutInflater layoutInflater = getLayoutInflater(); |
|
|
LayoutInflater layoutInflater = getLayoutInflater(); |
|
|
|
|
|
|
|
|
TextView tmp = new TextView(this); |
|
|
if(!getBoardsBookmarked().isEmpty()) { |
|
|
tmp.setLayoutParams(new LinearLayout.LayoutParams( |
|
|
boardsTitle = new TextView(this); |
|
|
LinearLayout.LayoutParams.MATCH_PARENT |
|
|
boardsTitle.setLayoutParams(new LinearLayout.LayoutParams( |
|
|
, LinearLayout.LayoutParams.WRAP_CONTENT)); |
|
|
LinearLayout.LayoutParams.MATCH_PARENT |
|
|
tmp.setText(getString(R.string.board_bookmarks_title)); |
|
|
, LinearLayout.LayoutParams.WRAP_CONTENT)); |
|
|
tmp.setTypeface(tmp.getTypeface(), Typeface.BOLD); |
|
|
boardsTitle.setText(getString(R.string.board_bookmarks_title)); |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
|
|
boardsTitle.setTypeface(boardsTitle.getTypeface(), Typeface.BOLD); |
|
|
tmp.setTextColor(getColor(R.color.primary_text)); |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
|
|
} else { |
|
|
boardsTitle.setTextColor(getColor(R.color.primary_text)); |
|
|
//noinspection deprecation
|
|
|
} else { |
|
|
tmp.setTextColor(getResources().getColor(R.color.primary_text)); |
|
|
//noinspection deprecation
|
|
|
} |
|
|
boardsTitle.setTextColor(getResources().getColor(R.color.primary_text)); |
|
|
tmp.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); |
|
|
} |
|
|
tmp.setTextSize(20f); |
|
|
boardsTitle.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); |
|
|
bookmarksLinearView.addView(tmp); |
|
|
boardsTitle.setTextSize(20f); |
|
|
|
|
|
bookmarksLinearView.addView(boardsTitle); |
|
|
|
|
|
|
|
|
for (final Bookmark bookmarkedBoard : getBoardsBookmarked()) { |
|
|
for (final Bookmark bookmarkedBoard : getBoardsBookmarked()) { |
|
|
if (bookmarkedBoard != null && bookmarkedBoard.getTitle() != null) { |
|
|
if (bookmarkedBoard != null && bookmarkedBoard.getTitle() != null) { |
|
|
final LinearLayout row = (LinearLayout) layoutInflater.inflate( |
|
|
final LinearLayout row = (LinearLayout) layoutInflater.inflate( |
|
|
R.layout.activity_bookmark_row, bookmarksLinearView, false); |
|
|
R.layout.activity_bookmark_row, bookmarksLinearView, false); |
|
|
row.setOnClickListener(new View.OnClickListener() { |
|
|
row.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View view) { |
|
|
public void onClick(View view) { |
|
|
Intent intent = new Intent(BookmarkActivity.this, BoardActivity.class); |
|
|
Intent intent = new Intent(BookmarkActivity.this, BoardActivity.class); |
|
|
Bundle extras = new Bundle(); |
|
|
Bundle extras = new Bundle(); |
|
|
extras.putString(BUNDLE_BOARD_URL, "https://www.thmmy.gr/smf/index.php?board=" |
|
|
extras.putString(BUNDLE_BOARD_URL, "https://www.thmmy.gr/smf/index.php?board=" |
|
|
+ bookmarkedBoard.getId() + ".0"); |
|
|
+ bookmarkedBoard.getId() + ".0"); |
|
|
extras.putString(BUNDLE_BOARD_TITLE, bookmarkedBoard.getTitle()); |
|
|
extras.putString(BUNDLE_BOARD_TITLE, bookmarkedBoard.getTitle()); |
|
|
intent.putExtras(extras); |
|
|
intent.putExtras(extras); |
|
|
startActivity(intent); |
|
|
startActivity(intent); |
|
|
finish(); |
|
|
finish(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedBoard.getTitle()); |
|
|
((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedBoard.getTitle()); |
|
|
(row.findViewById(R.id.remove_bookmark)).setOnClickListener(new View.OnClickListener() { |
|
|
(row.findViewById(R.id.remove_bookmark)).setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View view) { |
|
|
public void onClick(View view) { |
|
|
removeBookmark(bookmarkedBoard); |
|
|
removeBookmark(bookmarkedBoard); |
|
|
row.setVisibility(View.GONE); |
|
|
row.setVisibility(View.GONE); |
|
|
} |
|
|
updateTitles(); |
|
|
}); |
|
|
} |
|
|
bookmarksLinearView.addView(row); |
|
|
}); |
|
|
|
|
|
bookmarksLinearView.addView(row); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tmp = new TextView(this); |
|
|
|
|
|
tmp.setLayoutParams(new LinearLayout.LayoutParams( |
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT |
|
|
|
|
|
, LinearLayout.LayoutParams.WRAP_CONTENT)); |
|
|
|
|
|
tmp.setText(getString(R.string.topic_bookmarks_title)); |
|
|
|
|
|
tmp.setTypeface(tmp.getTypeface(), Typeface.BOLD); |
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
|
|
|
|
|
tmp.setTextColor(getColor(R.color.primary_text)); |
|
|
|
|
|
} else { |
|
|
|
|
|
//noinspection deprecation
|
|
|
|
|
|
tmp.setTextColor(getResources().getColor(R.color.primary_text)); |
|
|
|
|
|
} |
|
|
|
|
|
tmp.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); |
|
|
|
|
|
tmp.setTextSize(20f); |
|
|
|
|
|
bookmarksLinearView.addView(tmp); |
|
|
|
|
|
|
|
|
|
|
|
for (final Bookmark bookmarkedTopic : getTopicsBookmarked()) { |
|
|
if(!getTopicsBookmarked().isEmpty()) { |
|
|
if (bookmarkedTopic != null && bookmarkedTopic.getTitle() != null) { |
|
|
topicsTitle = new TextView(this); |
|
|
final LinearLayout row = (LinearLayout) layoutInflater.inflate( |
|
|
topicsTitle.setLayoutParams(new LinearLayout.LayoutParams( |
|
|
R.layout.activity_bookmark_row, bookmarksLinearView, false); |
|
|
LinearLayout.LayoutParams.MATCH_PARENT |
|
|
row.setOnClickListener(new View.OnClickListener() { |
|
|
, LinearLayout.LayoutParams.WRAP_CONTENT)); |
|
|
@Override |
|
|
topicsTitle.setText(getString(R.string.topic_bookmarks_title)); |
|
|
public void onClick(View view) { |
|
|
topicsTitle.setTypeface(topicsTitle.getTypeface(), Typeface.BOLD); |
|
|
Intent intent = new Intent(BookmarkActivity.this, TopicActivity.class); |
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
|
|
Bundle extras = new Bundle(); |
|
|
topicsTitle.setTextColor(getColor(R.color.primary_text)); |
|
|
extras.putString(BUNDLE_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic=" |
|
|
} else { |
|
|
+ bookmarkedTopic.getId() + "." + 2147483647); |
|
|
//noinspection deprecation
|
|
|
extras.putString(BUNDLE_TOPIC_TITLE, bookmarkedTopic.getTitle()); |
|
|
topicsTitle.setTextColor(getResources().getColor(R.color.primary_text)); |
|
|
intent.putExtras(extras); |
|
|
} |
|
|
startActivity(intent); |
|
|
topicsTitle.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); |
|
|
finish(); |
|
|
topicsTitle.setTextSize(20f); |
|
|
} |
|
|
bookmarksLinearView.addView(topicsTitle); |
|
|
}); |
|
|
|
|
|
((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedTopic.getTitle()); |
|
|
for (final Bookmark bookmarkedTopic : getTopicsBookmarked()) { |
|
|
(row.findViewById(R.id.remove_bookmark)).setOnClickListener(new View.OnClickListener() { |
|
|
if (bookmarkedTopic != null && bookmarkedTopic.getTitle() != null) { |
|
|
@Override |
|
|
final LinearLayout row = (LinearLayout) layoutInflater.inflate( |
|
|
public void onClick(View view) { |
|
|
R.layout.activity_bookmark_row, bookmarksLinearView, false); |
|
|
removeBookmark(bookmarkedTopic); |
|
|
row.setOnClickListener(new View.OnClickListener() { |
|
|
row.setVisibility(View.GONE); |
|
|
@Override |
|
|
} |
|
|
public void onClick(View view) { |
|
|
}); |
|
|
Intent intent = new Intent(BookmarkActivity.this, TopicActivity.class); |
|
|
bookmarksLinearView.addView(row); |
|
|
Bundle extras = new Bundle(); |
|
|
|
|
|
extras.putString(BUNDLE_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic=" |
|
|
|
|
|
+ bookmarkedTopic.getId() + "." + 2147483647); |
|
|
|
|
|
extras.putString(BUNDLE_TOPIC_TITLE, bookmarkedTopic.getTitle()); |
|
|
|
|
|
intent.putExtras(extras); |
|
|
|
|
|
startActivity(intent); |
|
|
|
|
|
finish(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
((TextView) row.findViewById(R.id.bookmark_title)).setText(bookmarkedTopic.getTitle()); |
|
|
|
|
|
(row.findViewById(R.id.remove_bookmark)).setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View view) { |
|
|
|
|
|
removeBookmark(bookmarkedTopic); |
|
|
|
|
|
row.setVisibility(View.GONE); |
|
|
|
|
|
updateTitles(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
bookmarksLinearView.addView(row); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -139,4 +148,12 @@ public class BookmarkActivity extends BaseActivity { |
|
|
drawer.setSelection(BOOKMARKS_ID); |
|
|
drawer.setSelection(BOOKMARKS_ID); |
|
|
super.onResume(); |
|
|
super.onResume(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updateTitles() |
|
|
|
|
|
{ |
|
|
|
|
|
if(getBoardsBookmarked().isEmpty()) |
|
|
|
|
|
boardsTitle.setVisibility(View.GONE); |
|
|
|
|
|
if(getTopicsBookmarked().isEmpty()) |
|
|
|
|
|
topicsTitle.setVisibility(View.GONE); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|