Search in sources :

Example 6 with MultiSubreddit

use of net.dean.jraw.models.MultiSubreddit in project Slide by ccrama.

the class UserSubscriptions method syncMultiReddits.

public static void syncMultiReddits(Context c) {
    try {
        multireddits = new ArrayList<>(new MultiRedditManager(Authentication.reddit).mine());
        for (MultiReddit multiReddit : multireddits) {
            if (MainActivity.multiNameToSubsMap.containsKey(ReorderSubreddits.MULTI_REDDIT + multiReddit.getDisplayName())) {
                StringBuilder concatenatedSubs = new StringBuilder();
                for (MultiSubreddit subreddit : multiReddit.getSubreddits()) {
                    concatenatedSubs.append(subreddit.getDisplayName());
                    concatenatedSubs.append("+");
                }
                MainActivity.multiNameToSubsMap.put(ReorderSubreddits.MULTI_REDDIT + multiReddit.getDisplayName(), concatenatedSubs.toString());
                UserSubscriptions.setSubNameToProperties(ReorderSubreddits.MULTI_REDDIT + multiReddit.getDisplayName(), concatenatedSubs.toString());
            }
        }
    } catch (ApiException e) {
        e.printStackTrace();
    } catch (NetworkException e) {
        e.printStackTrace();
    }
}
Also used : MultiRedditManager(net.dean.jraw.managers.MultiRedditManager) MultiSubreddit(net.dean.jraw.models.MultiSubreddit) MultiReddit(net.dean.jraw.models.MultiReddit) NetworkException(net.dean.jraw.http.NetworkException) ApiException(net.dean.jraw.ApiException)

Example 7 with MultiSubreddit

use of net.dean.jraw.models.MultiSubreddit in project Slide by ccrama.

the class CreateMulti method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    overrideRedditSwipeAnywhere();
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_createmulti);
    setupAppBar(R.id.toolbar, "", true, true);
    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showSelectDialog();
        }
    });
    title = (EditText) findViewById(R.id.name);
    subs = new ArrayList<>();
    if (getIntent().hasExtra(EXTRA_MULTI)) {
        final String multi = getIntent().getExtras().getString(EXTRA_MULTI);
        old = multi;
        title.setText(multi.replace("%20", " "));
        UserSubscriptions.getMultireddits(new UserSubscriptions.MultiCallback() {

            @Override
            public void onComplete(List<MultiReddit> multis) {
                for (MultiReddit multiReddit : multis) {
                    if (multiReddit.getDisplayName().equals(multi)) {
                        for (MultiSubreddit sub : multiReddit.getSubreddits()) {
                            subs.add(sub.getDisplayName().toLowerCase(Locale.ENGLISH));
                        }
                    }
                }
            }
        });
    }
    recyclerView = (RecyclerView) findViewById(R.id.subslist);
    adapter = new CustomAdapter(subs);
    // adapter.setHasStableIds(true);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
Also used : MultiSubreddit(net.dean.jraw.models.MultiSubreddit) MultiReddit(net.dean.jraw.models.MultiReddit) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) UserSubscriptions(me.ccrama.redditslide.UserSubscriptions)

Aggregations

MultiReddit (net.dean.jraw.models.MultiReddit)7 MultiSubreddit (net.dean.jraw.models.MultiSubreddit)7 View (android.view.View)6 TextView (android.widget.TextView)6 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 Snackbar (android.support.design.widget.Snackbar)3 RecyclerView (android.support.v7.widget.RecyclerView)3 AlertDialogWrapper (com.afollestad.materialdialogs.AlertDialogWrapper)3 ArrayList (java.util.ArrayList)3 CaseInsensitiveArrayList (me.ccrama.redditslide.CaseInsensitiveArrayList)3 ApiException (net.dean.jraw.ApiException)3 NetworkException (net.dean.jraw.http.NetworkException)3 MultiRedditManager (net.dean.jraw.managers.MultiRedditManager)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2 AsyncTask (android.os.AsyncTask)2 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 CompoundButton (android.widget.CompoundButton)2