Skip to content

Instantly share code, notes, and snippets.

View masztalski's full-sized avatar

Michał Markiewicz masztalski

View GitHub Profile
devDebugRuntimeClasspath - Runtime classpath of compilation 'devDebug' (target (androidJvm)).
+--- androidx.databinding:databinding-common:7.3.1
+--- androidx.databinding:databinding-runtime:7.3.1
| +--- androidx.collection:collection:1.0.0 -> 1.1.0
| | \--- androidx.annotation:annotation:1.1.0 -> 1.3.0
| +--- androidx.databinding:databinding-common:7.3.1
| +--- androidx.databinding:viewbinding:7.3.1
| | \--- androidx.annotation:annotation:1.0.0 -> 1.3.0
| \--- androidx.lifecycle:lifecycle-runtime:2.4.0 -> 2.5.1
| +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
buildConfigField "java.lang.String", "BASE_URL", "\"https://MY_URL/\""
}
dexOptions {
jumboMode = true
javaMaxHeapSize "6g"
}
public class UserController {
@Inject
protected UserRepository mUserRepo;
@Inject
public UserController(){}
}
@Module
public class RepositoryModule {
@Provides
@Singleton
ConnectionSource providesConnectionSource(Application app) {
return new AndroidConnectionSource(new DatabaseHelper(app.getApplicationContext()));
}
@Provides
@Singleton
public class UserSQLImpl extends BaseSQLImpl<User, Integer> implements UserRepository{
public UserSQLImpl(ConnectionSource connectionSource){
try {
mDao = DaoManager.createDao(connectionSource, User.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public class BaseSQLImpl<T, I> implements BaseRepository<T, I> {
protected Dao<T,I> mDao;
@Override
public List<T> findAll() {
try {
return mDao.queryForAll();
} catch (SQLException e) {
e.printStackTrace();
}
public interface BaseRepository<T,I> {
List<T> findAll();
T findById(I id);
boolean create(T r);
boolean update(T r);
boolean delete(T r);
boolean deleteAll();
void bathCreate(List<T> objectList);
public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
// name of the database file for your application -- change to something
// appropriate for your app
private static final String DATABASE_NAME = "DB_NAME.db";
// any time you make changes to your database objects, you may have to
// increase the database version
private static final int DATABASE_VERSION = 1;
// the DAO object we use to access the SimpleData table
@DatabaseTable(tableName = "user_table")
public class User {
@DatabaseField(id = true)
private int userID;
@DatabaseField
private String userName;
@DatabaseField
private String userPhone;
public User(){}
@masztalski
masztalski / themes-debug.xml
Created September 5, 2017 12:11 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>