TheBlueCat
TheBlueCat

Reputation: 1195

public Abstract notable examples

I was browsing through a Repo for a Reddit app on Github. Now, For the link between between the dialog and the Task they choose to add:

public abstract void onLoginChosen(String user, String password);

They then have a Task class that handles the data and makes and receives the input and then parses it to the UI.

I don't understand, how does the abstraction in this constructor then go onto to the Task.

There task doesn't even extend this dialog task.

public class LoginTask extends AsyncTask<Void, Void, Boolean> {

    private static final String TAG = "LoginTask";

    protected String mUsername;
    private String mPassword;
    protected String mUserError = null;

    private RedditSettings mSettings;
    private HttpClient mClient;
    private Context mContext;

    protected LoginTask(String username, String password, RedditSettings settings, HttpClient client, Context context) {
        mUsername = username;
        mPassword = password;
        mSettings = settings;
        mClient = client;
        mContext = context;
    }

    @Override
    public Boolean doInBackground(Void... v) {
        return doLogin(mUsername, mPassword, mSettings, mClient, mContext);
    }

How does the data go from one class to another in this example? I'm stumped and it's making this part to understand.

Repo

Upvotes: 0

Views: 134

Answers (1)

TalkLittle
TalkLittle

Reputation: 9111

There's an implementation in the Activity here:

https://github.com/talklittle/reddit-is-fun/blob/master/src/com/andrewshu/android/reddit/threads/ThreadsListActivity.java#L1220

and other activities too, where the login dialog is able to be shown.

Side note: that is very old code, and the latest closed source version of the app avoids things like that.

Upvotes: 1

Related Questions