Search in sources :

Example 1 with TimelineReceiver

use of com.keylesspalace.tusky.receiver.TimelineReceiver in project Tusky by Vavassor.

the class TimelineFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle arguments = getArguments();
    kind = Kind.valueOf(arguments.getString("kind"));
    if (kind == Kind.TAG || kind == Kind.USER) {
        hashtagOrId = arguments.getString("hashtag_or_id");
    }
    final View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);
    // Setup the SwipeRefreshLayout.
    Context context = getContext();
    swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    // Setup the RecyclerView.
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
    Drawable drawable = ThemeUtils.getDrawable(context, R.attr.status_divider_drawable, R.drawable.status_divider_dark);
    divider.setDrawable(drawable);
    recyclerView.addItemDecoration(divider);
    adapter = new TimelineAdapter(this);
    recyclerView.setAdapter(adapter);
    timelineReceiver = new TimelineReceiver(adapter);
    LocalBroadcastManager.getInstance(context.getApplicationContext()).registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind));
    return rootView;
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) TimelineAdapter(com.keylesspalace.tusky.adapter.TimelineAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TimelineReceiver(com.keylesspalace.tusky.receiver.TimelineReceiver)

Example 2 with TimelineReceiver

use of com.keylesspalace.tusky.receiver.TimelineReceiver in project Tusky by tuskyapp.

the class TimelineFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Bundle arguments = getArguments();
    kind = Kind.valueOf(arguments.getString(KIND_ARG));
    if (kind == Kind.TAG || kind == Kind.USER || kind == Kind.LIST) {
        hashtagOrId = arguments.getString(HASHTAG_OR_ID_ARG);
    }
    final View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);
    // Setup the SwipeRefreshLayout.
    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));
    // Setup the RecyclerView.
    recyclerView = rootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
    Drawable drawable = ThemeUtils.getDrawable(context, R.attr.status_divider_drawable, R.drawable.status_divider_dark);
    divider.setDrawable(drawable);
    recyclerView.addItemDecoration(divider);
    adapter = new TimelineAdapter(this);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    preferences.registerOnSharedPreferenceChangeListener(this);
    alwaysShowSensitiveMedia = preferences.getBoolean("alwaysShowSensitiveMedia", false);
    boolean mediaPreviewEnabled = preferences.getBoolean("mediaPreviewEnabled", true);
    adapter.setMediaPreviewEnabled(mediaPreviewEnabled);
    recyclerView.setAdapter(adapter);
    boolean filter = preferences.getBoolean("tabFilterHomeReplies", true);
    filterRemoveReplies = kind == Kind.HOME && !filter;
    filter = preferences.getBoolean("tabFilterHomeBoosts", true);
    filterRemoveReblogs = kind == Kind.HOME && !filter;
    timelineReceiver = new TimelineReceiver(this, this);
    LocalBroadcastManager.getInstance(context.getApplicationContext()).registerReceiver(timelineReceiver, TimelineReceiver.getFilter(kind));
    statuses.clear();
    topLoading = false;
    topFetches = 0;
    bottomLoading = false;
    bottomFetches = 0;
    bottomId = null;
    topId = null;
    return rootView;
}
Also used : Context(android.content.Context) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) Drawable(android.graphics.drawable.Drawable) TimelineAdapter(com.keylesspalace.tusky.adapter.TimelineAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TimelineReceiver(com.keylesspalace.tusky.receiver.TimelineReceiver)

Example 3 with TimelineReceiver

use of com.keylesspalace.tusky.receiver.TimelineReceiver in project Tusky by tuskyapp.

the class NotificationsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);
    // from inflater to silence warning
    @NonNull Context context = inflater.getContext();
    // Setup the SwipeRefreshLayout.
    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));
    // Setup the RecyclerView.
    recyclerView = rootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(context, layoutManager.getOrientation());
    Drawable drawable = ThemeUtils.getDrawable(context, R.attr.status_divider_drawable, R.drawable.status_divider_dark);
    divider.setDrawable(drawable);
    recyclerView.addItemDecoration(divider);
    adapter = new NotificationsAdapter(this, this);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    alwaysShowSensitiveMedia = preferences.getBoolean("alwaysShowSensitiveMedia", false);
    boolean mediaPreviewEnabled = preferences.getBoolean("mediaPreviewEnabled", true);
    adapter.setMediaPreviewEnabled(mediaPreviewEnabled);
    recyclerView.setAdapter(adapter);
    timelineReceiver = new TimelineReceiver(this);
    LocalBroadcastManager.getInstance(context.getApplicationContext()).registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null));
    notifications.clear();
    topLoading = false;
    topFetches = 0;
    bottomLoading = false;
    bottomFetches = 0;
    bottomId = null;
    topId = null;
    return rootView;
}
Also used : Context(android.content.Context) NotificationsAdapter(com.keylesspalace.tusky.adapter.NotificationsAdapter) SharedPreferences(android.content.SharedPreferences) NonNull(android.support.annotation.NonNull) Drawable(android.graphics.drawable.Drawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TimelineReceiver(com.keylesspalace.tusky.receiver.TimelineReceiver) Nullable(android.support.annotation.Nullable)

Example 4 with TimelineReceiver

use of com.keylesspalace.tusky.receiver.TimelineReceiver 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)

Aggregations

Context (android.content.Context)4 Drawable (android.graphics.drawable.Drawable)4 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 TimelineReceiver (com.keylesspalace.tusky.receiver.TimelineReceiver)4 SharedPreferences (android.content.SharedPreferences)3 Bundle (android.os.Bundle)2 Nullable (android.support.annotation.Nullable)2 TimelineAdapter (com.keylesspalace.tusky.adapter.TimelineAdapter)2 NonNull (android.support.annotation.NonNull)1 NotificationsAdapter (com.keylesspalace.tusky.adapter.NotificationsAdapter)1 ThreadAdapter (com.keylesspalace.tusky.adapter.ThreadAdapter)1 StatusContext (com.keylesspalace.tusky.entity.StatusContext)1 ConversationLineItemDecoration (com.keylesspalace.tusky.view.ConversationLineItemDecoration)1