This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BaseActivity extends AppCompatActivity { | |
@Override | |
protected void onDestroy() { | |
super.onDestroy(); | |
RxBus.unregister(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BaseFragment extends Fragment { | |
@Override | |
public void onDestroy() { | |
super.onDestroy(); | |
RxBus.unregister(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseUpgradeHelper extends DaoMaster.OpenHelper { | |
public DatabaseUpgradeHelper(Context context, String name) { | |
super(context, name); | |
} | |
@Override | |
public void onUpgrade(Database db, int oldVersion, int newVersion) { | |
List<Migration> migrations = getMigrations(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
public class BusModule { | |
public static final String PROVIDER_TOP_SUBJECT = "PROVIDER_TOP_SUBJECT"; | |
public static final String PROVIDER_BOTTOM_SUBJECT = "PROVIDER_BOTTOM_SUBJECT"; | |
@Provides | |
@Singleton | |
@Named(PROVIDER_TOP_SUBJECT) | |
static PublishSubject<String> provideTopSubject() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component(modules = BusModule.class) | |
@Singleton | |
public interface BusComponent { | |
@Named(BusModule.PROVIDER_TOP_SUBJECT) | |
PublishSubject<String> getTopSubject(); | |
@Named(BusModule.PROVIDER_BOTTOM_SUBJECT) | |
PublishSubject<String> getBottomSubject(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App extends Application { | |
private static BusComponent sBusComponent; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
sBusComponent = DaggerBusComponent.create(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Subscribe to a subject | |
App.getBusComponent().getTopSubject().subscribe((message) -> { | |
if (mMessageView != null) { | |
mMessageView.setText(message); | |
} | |
}); | |
//Send an item to subscribers of a subject | |
App.getBusComponent().getBottomSubject().onNext("Hello!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<String> dataList; | |
//dataList gets populated here | |
List<DataModel> result = new ArrayList<>(); | |
for (String data : dataList) { | |
result.add(DataParser.createData(data)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity | |
android:name=".activity.MainEmptyActivity" | |
android:theme="@android:style/Theme.NoDisplay"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN"/> | |
<category android:name="android.intent.category.LAUNCHER"/> | |
</intent-filter> | |
</activity> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomView extends LinearLayout { | |
public CustomView(Context context, @Nullable AttributeSet attrs) { | |
super(context, attrs); | |
setOrientation(LinearLayout.VERTICAL); | |
LayoutInflater.from(context).inflate(R.layout.customview, this, true); | |
String title; | |
String subtitle; | |
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomView, 0, 0); |
OlderNewer