Merge branch 'feature/kotlin' into dev

This commit is contained in:
2017-07-21 18:12:45 -04:00
parent 2db4c06fe8
commit 180c18f6bf
147 changed files with 3835 additions and 5594 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.isoron.androidbase.activities;
import android.content.*;
import dagger.*;
@Module
public class ActivityContextModule
{
private Context context;
public ActivityContextModule(Context context)
{
this.context = context;
}
@Provides
@ActivityContext
public Context getContext()
{
return context;
}
}

View File

@@ -19,29 +19,20 @@
package org.isoron.androidbase.activities;
import android.content.*;
import dagger.*;
@Module
public class ActivityModule
public class BaseActivityModule
{
private BaseActivity activity;
public ActivityModule(BaseActivity activity)
public BaseActivityModule(BaseActivity activity)
{
this.activity = activity;
}
@Provides
public BaseActivity getActivity()
{
return activity;
}
@Provides
@ActivityContext
public Context getContext()
public BaseActivity getBaseActivity()
{
return activity;
}

View File

@@ -51,6 +51,15 @@ public class StyledResources
return bool;
}
public int getDimension(@AttrRes int attrId)
{
TypedArray ta = getTypedArray(attrId);
int dim = ta.getDimensionPixelSize(0, 0);
ta.recycle();
return dim;
}
public int getColor(@AttrRes int attrId)
{
TypedArray ta = getTypedArray(attrId);
@@ -80,13 +89,13 @@ public class StyledResources
public int[] getPalette()
{
int resourceId = getStyleResource(R.attr.palette);
int resourceId = getResource(R.attr.palette);
if (resourceId < 0) throw new RuntimeException("resource not found");
return context.getResources().getIntArray(resourceId);
}
int getStyleResource(@AttrRes int attrId)
public int getResource(@AttrRes int attrId)
{
TypedArray ta = getTypedArray(attrId);
int resourceId = ta.getResourceId(0, -1);