Search in sources :

Example 1 with ConversationLineItemDecoration

use of com.keylesspalace.tusky.view.ConversationLineItemDecoration in project Tusky by tuskyapp.

the class ViewThreadFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_view_thread, container, false);
    Context context = getContext();
    swipeRefreshLayout = rootView.findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.primary);
    swipeRefreshLayout.setProgressBackgroundColorSchemeColor(ThemeUtils.getColor(context, android.R.attr.colorBackground));
    recyclerView = rootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
    Drawable dividerDrawable = ThemeUtils.getDrawable(context, R.attr.status_divider_drawable, R.drawable.status_divider_dark);
    divider.setDrawable(dividerDrawable);
    recyclerView.addItemDecoration(divider);
    Drawable threadLineDrawable = ThemeUtils.getDrawable(context, R.attr.conversation_thread_line_drawable, R.drawable.conversation_thread_line_dark);
    recyclerView.addItemDecoration(new ConversationLineItemDecoration(context, threadLineDrawable));
    adapter = new ThreadAdapter(this);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    alwaysShowSensitiveMedia = preferences.getBoolean("alwaysShowSensitiveMedia", false);
    boolean mediaPreviewEnabled = preferences.getBoolean("mediaPreviewEnabled", true);
    adapter.setMediaPreviewEnabled(mediaPreviewEnabled);
    recyclerView.setAdapter(adapter);
    statuses.clear();
    thisThreadsStatusId = null;
    timelineReceiver = new TimelineReceiver(this, this);
    LocalBroadcastManager.getInstance(context.getApplicationContext()).registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null));
    return rootView;
}
Also used : Context(android.content.Context) StatusContext(com.keylesspalace.tusky.entity.StatusContext) SharedPreferences(android.content.SharedPreferences) ThreadAdapter(com.keylesspalace.tusky.adapter.ThreadAdapter) Drawable(android.graphics.drawable.Drawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ConversationLineItemDecoration(com.keylesspalace.tusky.view.ConversationLineItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TimelineReceiver(com.keylesspalace.tusky.receiver.TimelineReceiver) Nullable(android.support.annotation.Nullable)

Example 2 with ConversationLineItemDecoration

use of com.keylesspalace.tusky.view.ConversationLineItemDecoration in project Tusky by Vavassor.

the class ViewThreadFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_view_thread, container, false);
    Context context = getContext();
    swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
    recyclerView = rootView.findViewById(R.id.recyclerView);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAccessibilityDelegateCompat(new ListStatusAccessibilityDelegate(recyclerView, this, statuses::getPairedItemOrNull));
    DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
    recyclerView.addItemDecoration(divider);
    recyclerView.addItemDecoration(new ConversationLineItemDecoration(context));
    alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
    alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
    reloadFilters();
    recyclerView.setAdapter(adapter);
    statuses.clear();
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    return rootView;
}
Also used : Context(android.content.Context) ListStatusAccessibilityDelegate(com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) ConversationLineItemDecoration(com.keylesspalace.tusky.view.ConversationLineItemDecoration) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

Context (android.content.Context)2 View (android.view.View)2 ConversationLineItemDecoration (com.keylesspalace.tusky.view.ConversationLineItemDecoration)2 SharedPreferences (android.content.SharedPreferences)1 Drawable (android.graphics.drawable.Drawable)1 Nullable (android.support.annotation.Nullable)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 SimpleItemAnimator (androidx.recyclerview.widget.SimpleItemAnimator)1 ThreadAdapter (com.keylesspalace.tusky.adapter.ThreadAdapter)1 StatusContext (com.keylesspalace.tusky.entity.StatusContext)1 TimelineReceiver (com.keylesspalace.tusky.receiver.TimelineReceiver)1 ListStatusAccessibilityDelegate (com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate)1