|
@ -1,7 +1,6 @@ |
|
|
package gr.thmmy.mthmmy.activities.bookmarks; |
|
|
package gr.thmmy.mthmmy.activities.bookmarks; |
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
import android.app.Activity; |
|
|
import android.graphics.Typeface; |
|
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
import android.graphics.drawable.Drawable; |
|
|
import android.os.Build; |
|
|
import android.os.Build; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
@ -34,6 +33,8 @@ public class BookmarksFragment extends Fragment { |
|
|
static final String INTERACTION_TOGGLE_BOARD_NOTIFICATION = "TOGGLE_BOARD_NOTIFICATION"; |
|
|
static final String INTERACTION_TOGGLE_BOARD_NOTIFICATION = "TOGGLE_BOARD_NOTIFICATION"; |
|
|
static final String INTERACTION_REMOVE_BOARD_BOOKMARK= "REMOVE_BOARD_BOOKMARK"; |
|
|
static final String INTERACTION_REMOVE_BOARD_BOOKMARK= "REMOVE_BOARD_BOOKMARK"; |
|
|
|
|
|
|
|
|
|
|
|
private TextView nothingBookmarkedTextView; |
|
|
|
|
|
|
|
|
private ArrayList<Bookmark> bookmarks = null; |
|
|
private ArrayList<Bookmark> bookmarks = null; |
|
|
private Type type; |
|
|
private Type type; |
|
|
private String interactionClick, interactionToggle, interactionRemove; |
|
|
private String interactionClick, interactionToggle, interactionRemove; |
|
@ -100,8 +101,10 @@ public class BookmarksFragment extends Fragment { |
|
|
final View rootView = layoutInflater.inflate(R.layout.fragment_bookmarks, container, false); |
|
|
final View rootView = layoutInflater.inflate(R.layout.fragment_bookmarks, container, false); |
|
|
//bookmarks container
|
|
|
//bookmarks container
|
|
|
final LinearLayout bookmarksLinearView = rootView.findViewById(R.id.bookmarks_container); |
|
|
final LinearLayout bookmarksLinearView = rootView.findViewById(R.id.bookmarks_container); |
|
|
|
|
|
nothingBookmarkedTextView = rootView.findViewById(R.id.nothing_bookmarked); |
|
|
|
|
|
|
|
|
if(this.bookmarks != null && !this.bookmarks.isEmpty()) { |
|
|
if(this.bookmarks != null && !this.bookmarks.isEmpty()) { |
|
|
|
|
|
hideNothingBookmarked(); |
|
|
for (final Bookmark bookmark : bookmarks) { |
|
|
for (final Bookmark bookmark : bookmarks) { |
|
|
if (bookmark != null && bookmark.getTitle() != null) { |
|
|
if (bookmark != null && bookmark.getTitle() != null) { |
|
|
final LinearLayout row = (LinearLayout) layoutInflater.inflate( |
|
|
final LinearLayout row = (LinearLayout) layoutInflater.inflate( |
|
@ -137,38 +140,27 @@ public class BookmarksFragment extends Fragment { |
|
|
row.setVisibility(View.GONE); |
|
|
row.setVisibility(View.GONE); |
|
|
|
|
|
|
|
|
if (bookmarks.isEmpty()){ |
|
|
if (bookmarks.isEmpty()){ |
|
|
bookmarksLinearView.addView(bookmarksListEmptyMessage()); |
|
|
showNothingBookmarked(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
bookmarksLinearView.addView(row); |
|
|
bookmarksLinearView.addView(row); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else |
|
|
} else |
|
|
bookmarksLinearView.addView(bookmarksListEmptyMessage()); |
|
|
showNothingBookmarked(); |
|
|
|
|
|
|
|
|
return rootView; |
|
|
return rootView; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private TextView bookmarksListEmptyMessage() { |
|
|
|
|
|
TextView emptyBookmarksCategory = new TextView(this.getContext()); |
|
|
private void showNothingBookmarked() { |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( |
|
|
if(nothingBookmarkedTextView!=null) |
|
|
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); |
|
|
nothingBookmarkedTextView.setVisibility(View.VISIBLE); |
|
|
params.setMargins(0, 12, 0, 0); |
|
|
} |
|
|
emptyBookmarksCategory.setLayoutParams(params); |
|
|
|
|
|
if(type==Type.TOPIC) |
|
|
private void hideNothingBookmarked(){ |
|
|
emptyBookmarksCategory.setText(getString(R.string.empty_topic_bookmarks)); |
|
|
if(nothingBookmarkedTextView!=null) |
|
|
else if(type==Type.BOARD) |
|
|
nothingBookmarkedTextView.setVisibility(View.INVISIBLE); |
|
|
emptyBookmarksCategory.setText(getString(R.string.empty_board_bookmarks)); |
|
|
|
|
|
|
|
|
|
|
|
emptyBookmarksCategory.setTypeface(emptyBookmarksCategory.getTypeface(), Typeface.BOLD); |
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) |
|
|
|
|
|
emptyBookmarksCategory.setTextColor(this.getContext().getColor(R.color.primary_text)); |
|
|
|
|
|
else { |
|
|
|
|
|
//noinspection deprecation
|
|
|
|
|
|
emptyBookmarksCategory.setTextColor(this.getContext().getResources().getColor(R.color.primary_text)); |
|
|
|
|
|
} |
|
|
|
|
|
emptyBookmarksCategory.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); |
|
|
|
|
|
return emptyBookmarksCategory; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|