Search in sources :

Example 1 with TimelineAdapter

use of com.keylesspalace.tusky.adapter.TimelineAdapter in project Tusky by Vavassor.

the class TimelineFragment method onLoadMore.

private void onLoadMore(RecyclerView view) {
    TimelineAdapter adapter = (TimelineAdapter) view.getAdapter();
    Status status = adapter.getItem(adapter.getItemCount() - 2);
    if (status != null) {
        sendFetchTimelineRequest(status.id, null);
    } else {
        sendFetchTimelineRequest(null, null);
    }
}
Also used : Status(com.keylesspalace.tusky.entity.Status) TimelineAdapter(com.keylesspalace.tusky.adapter.TimelineAdapter)

Example 2 with TimelineAdapter

use of com.keylesspalace.tusky.adapter.TimelineAdapter 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 3 with TimelineAdapter

use of com.keylesspalace.tusky.adapter.TimelineAdapter 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)

Aggregations

TimelineAdapter (com.keylesspalace.tusky.adapter.TimelineAdapter)3 Context (android.content.Context)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TimelineReceiver (com.keylesspalace.tusky.receiver.TimelineReceiver)2 SharedPreferences (android.content.SharedPreferences)1 Status (com.keylesspalace.tusky.entity.Status)1