Questions tagged [mortar]

mortar - a simple library that makes it easy to pair thin views with dedicated controllers, isolated from most of the vagaries of the Activity life cycle.

Mortar eases the use of Dagger to divide Android apps into composable modules. It is not a framework: there are no abstract Application or Activity classes here. Mortar eschews magic. Rather, Mortar is a simple library that makes it easy to pair thin views with dedicated controllers (Presenters), isolated from most of the vagaries of the Activity life cycle. The patterns it encourages have evolved in parallel across several Android teams at Square.

Mortar relies on Dagger, and of course the Android runtime, but those are its only direct dependencies. That said, it works very well with Retrofit, Flow and RxJava. Butterknife can be a fun partner too. (Use of all of these libraries is illustrated in the sample app.)

GitHub page: https://github.com/square/mortar

39 questions
16
votes
2 answers

Mortar + Flow with third party libraries hooked to activity lifecycle

Some third party libraries use hooks into the activity lifecycle to work correctly - for instance, the Facebook SDK (https://developers.facebook.com/docs/android/login-with-facebook/). I'm having some trouble figuring out how to reconcile this model…
secureboot
  • 1,776
  • 4
  • 20
  • 32
11
votes
1 answer

Square Flow + Mortar tablet examples

I've been experimenting with using flow and mortar as an alternative architecture for our Android apps. I've been working on an app which at the minute is only a single phone layout, but I was wondering how the flow and mortar architecture might…
matto1990
  • 3,766
  • 2
  • 27
  • 32
9
votes
2 answers

Getting Started w/ Flow and Mortar

I have been searching all around the web for a simplified guide on using Mortar and Flow in Android but just found some snippets of code explained. Its really hard to understand how this library works.
user3426273
9
votes
0 answers

flow and mortar transition with shared components

I'm wondering if it is possible to make screens transition animation like Activity transition with shared components as it is frequently used in Android Lollipop and Material design. Thanks.
oleg.semen
  • 2,901
  • 2
  • 28
  • 56
8
votes
1 answer

Writing Tests for Flow and Mortar Apps

I was wondering if there were any examples of writing unit tests for Flow and Mortar Android apps. Part of the advantage of the MVP pattern that it offers the split of the presentation and view logic, and the presentation logic is what you want to…
spierce7
  • 14,797
  • 13
  • 65
  • 106
7
votes
1 answer

Recommended way to get Activity inside Mortar screen?

I am using Mortar and Flow to power my app. If I have the following View: public class MyView extends LinearLayout { @Inject MyScreen.Presenter presenter; private EditText someText; public MyView(Context context) { super(context); …
user4386126
  • 1,205
  • 5
  • 17
  • 32
6
votes
1 answer

Mortar and Flow libraries vs. ViewPager

I'm trying to adapt Mortar&Flow in my app and faced with an issue, that I can't make PageAdapter works with Screens, instead of Fragments. Anyone managed to get it right? I didn't succeed but, probably someone can guide me from this point: The…
Konstantin Loginov
  • 15,802
  • 5
  • 58
  • 95
6
votes
1 answer

What does Square mean by 'offscreen fragments being brought back to life' and 'no direct control over animations'?

While discovering Android libraries and frameworks, I came across Square's blog post on Flow and Mortar. The author states that some of the motivations for developing Flow and Mortar was because ... Offscreen fragments mysteriously being brought…
Some Noob Student
  • 14,186
  • 13
  • 65
  • 103
5
votes
0 answers

Sub containers in Flow

Is there documentation on how to construct sub containers within flow? For example, I have a Master, a Detail view. I intend to add a popup view which will have it's own backstack. The popup will function as a wizard asking the user to complete…
redDragonzz
  • 1,543
  • 2
  • 15
  • 33
5
votes
4 answers

Using Flow & Mortar with ViewPager

I'm in the process of writing an app using Flow and Mortar. I'm having trouble figuring out how to use this when it comes to a view pager with tabs. Only way I can think of is to treat the ViewPager screen as a single screen, and end up using…
yasith
  • 8,981
  • 7
  • 27
  • 32
5
votes
1 answer

How to @Provide an Activity for the MortarActivityScope, without leaking the Activity on orientation changes?

I have a Mortar application, with a MortarActivityScope as the first child under the root scope. The MortarActivityScope has an ActivityScope which @Provides an activity for injected classes: @Module(addsTo = ApplicationModule.class, injects =…
weefbellington
  • 302
  • 3
  • 8
5
votes
3 answers

No inject registered. You must explicitly add it to the 'injects' option in one of your modules

Hi I'm new to dagger and trying to study it with simple android app. I'm getting error from the title even if there is module that injects this view. Could anyone help me figure out why it does not inject view ? Here is my main module for…
oleg.semen
  • 2,901
  • 2
  • 28
  • 56
5
votes
1 answer

Getting user input from a dialog using Mortar + Flow

I'm build my app with Mortar + Flow. I'm trying to figure out the correct way to show a popup that requests some text from the user. I've created this popup class: public class SavedPageTitleInputPopup implements Popup
Edward Dale
  • 29,597
  • 13
  • 90
  • 129
4
votes
0 answers

Can Flow and Mortar load a screen in the background if it is slow to load (e.g. GoogleMap)?

I am having trouble with certain pages in an Android app loading slowly. I have fixed many by pushing the slow parts into services that preempt the user's requirements. I am struggling with GoogleMaps, which are slow to load at around 5 seconds on…
TTransmit
  • 3,270
  • 2
  • 28
  • 43
4
votes
0 answers

Mortar / Flow samples NoClassDefFoundError: com.example.mortar.MortarDemoApplication$1

I'm having a really hard time getting the Mortar/Flow examples working via Eclipse & Maven. My .apt_generated folder is created and there are numerous generated classes in that directory but MortarDemoApplication$1 is not generated for some…
helmy
  • 9,068
  • 3
  • 32
  • 31
1
2 3