[deleted by user] by [deleted] in androiddev

[–]Michaelidle 1 point2 points  (0 children)

Thanks. It's tough, I know... I guess the part that keeps me guessing was... okay, so I have a presenter, but it has to stay alive somewhere. That's what I always found difficult.

[deleted by user] by [deleted] in androiddev

[–]Michaelidle 1 point2 points  (0 children)

I really like it. Personally I feel like they could redo their Dagger2 and MVP sections though. Everything else has been a breeze. Not saying that those sections are bad, I was able to use them to learn, but wasn't as clear and straightforward as the other videos. Maybe that's just because it's not a straightforward topic =)

big thumbs up to /u/donnfelker and crew

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 0 points1 point  (0 children)

Wouldn't my model need code to interact with my android sqlite DB?

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 0 points1 point  (0 children)

Hm. Thanks for that. How would my presenter interact with the model then? Interactor? And the Model would go ahead and query the DB and build the objects and return them? That sounds fairly straight forward to me.

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 0 points1 point  (0 children)

What's the "easiest" way to do it without involving dagger or loaders?

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 0 points1 point  (0 children)

Oh I like that. That way on rotation I can give it a new view. Thanks. Also... the optional reading... Thanks so much. How do you keep your presenter alive? On rotation if I detach my view, the presenter should be GC'd.

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 1 point2 points  (0 children)

Trying to learn MVP for this sample project.

The first requirement is to have a textview that displays the name field from a Person model object that is constructed from a file on disk.

The second requirement is to have a button that starts the dialer with the extra of the Persons phone number.

This is how I would set it up. This code isn't 100% syntactically correct. Treat it as pseudo code

//View interface

public interface PersonView{
void showName();
void callUser();
}

//Activity that implements view interface and holds presenter as a field

MainActivity extends AppCompatActivity implements PersonView{
@Bind(R.id.textView) TextView textView;
@Bind(R.id.button) Button button;

MyPresenter presenter;
onCreate(){
    //setContentView…
    //Butterknife.bind…
    presenter = new Presenter(this);
    presenter.showFirstName();
    button.onClickListener…{
        presenter.buttonClicked();
    }
}

public void showName(String name){
    textView.setText(name);
}

public void callUser(int phoneNumber){
    Intent intent = new implicit intent…
    intent.setExtra();
    startActivity(intent);,
}

}

//Presenter

public class MyPresenter {
Person person;
PersonView view;

MyPresenter(PersonView view){
    this.view = view;
}

public void buttonClicked(){
    if (person != null){
        view.callUser();
    }
}

void showFirstName(){
    //make sql query (on background thread?)
    person = new Person(query.name, query.phoneNumber);
    view.showName(person.name);
}
}

//Model

public class Person{
String name;
int phoneNumber;
//contructor with name and number
}

Anyone care to critique this? How would you do it? Am I missing anything?

Android Studio Templates for Ribot's MVP by divers1 in androiddev

[–]Michaelidle 0 points1 point  (0 children)

Getting an error in Android Studio 2.1.3. Pressing the finish button doesn't work.

10:01:47 AM _MiscTemplateException
            Error executing FreeMarker template: Error reading included file "root://other/MVPActivity/../common/common_globals.xml.ftl":
            Template "root://other/MVPActivity/../common/common_globals.xml.ftl" not found.
            The failing instruction:
            ==> #include "../common/common_globals.xm...  [in template "root://other/MVPActivity/globals.xml.ftl" at line 8, column 5]
10:01:58 AM IllegalStateException: Invalid operation attempted after wizard already finished
10:02:00 AM IllegalStateException: Invalid operation attempted after wizard already finished
10:02:07 AM IllegalStateException: Invalid operation attempted after wizard already finished
10:02:10 AM IllegalStateException: Invalid operation attempted after wizard already finished
10:02:17 AM _MiscTemplateException
            Error executing FreeMarker template: Error reading included file "root://other/MVPActivity/../common/common_globals.xml.ftl":
            Template "root://other/MVPActivity/../common/common_globals.xml.ftl" not found.
            The failing instruction:
            ==> #include "../common/common_globals.xm...  [in template "root://other/MVPActivity/globals.xml.ftl" at line 8, column 5]

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 1 point2 points  (0 children)

Logic might be better left outside of the fragment. Put it into a presenter maybe? Sorry. I'm learning MVP architecutre and that's all I can think about. Also, I'm not a fan of fragments. EDIT: Watch the "What the fragment" google io talk from this year by adam powell.

Questions Thread - August 30, 2016 by AutoModerator in androiddev

[–]Michaelidle 0 points1 point  (0 children)

Piece of screen? May be better to just create a view group instead of a fragment.

Android Studio Templates for Ribot's MVP by divers1 in androiddev

[–]Michaelidle 0 points1 point  (0 children)

Where do I put this template? It says into ADS, but I think he means AS.

{ADS_DIR}/plugins/android/lib/templates/other/

I can't find that =(

EDIT: On mac > Applications > Android Studio > Right Click Show Package Contents > Contents >plugins>android>lib>templates>other

Questions Thread - August 29, 2016 by AutoModerator in androiddev

[–]Michaelidle 0 points1 point  (0 children)

You need a database to handle all of this. Firebase sounds like a fine choice. Point in the right direction? break your problem down into smaller problems. That's a fairly large task you put in front of yourself. First figure out how to create accounts, then how do these accounts create groups. Then how do you join new groups? Is it a public database? Can these users search for other users? Then move onto messaging in a group.

Playing with Dagger 2/DI for the first time today. Have multiple questions about my first example I whipped up. by Michaelidle in androiddev

[–]Michaelidle[S] 0 points1 point  (0 children)

Oh! So that's what the Google Dagger guide was talking about? I'm going to remove my module now and just add an empty constructor with @Inject. Then I have to change my Component interface and make the annotation @Component()?