-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from dhis2/develop
Develop
- Loading branch information
Showing
94 changed files
with
2,420 additions
and
161 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ build | |
|
||
#Windows | ||
*.db | ||
|
||
# Last commit file | ||
app/src/main/res/raw/lastcommit.txt |
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
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
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
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
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
101 changes: 101 additions & 0 deletions
101
api/src/main/java/org/hisp/dhis/android/dashboard/api/controllers/PullImageController.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package org.hisp.dhis.android.dashboard.api.controllers; | ||
|
||
import android.content.Context; | ||
|
||
import com.squareup.picasso.MemoryPolicy; | ||
import com.squareup.picasso.NetworkPolicy; | ||
|
||
import org.hisp.dhis.android.dashboard.api.models.DashboardElement; | ||
import org.hisp.dhis.android.dashboard.api.models.DashboardItemContent; | ||
import org.hisp.dhis.android.dashboard.api.models.Interpretation; | ||
import org.hisp.dhis.android.dashboard.api.models.InterpretationElement; | ||
import org.hisp.dhis.android.dashboard.api.network.APIException; | ||
import org.hisp.dhis.android.dashboard.api.utils.PicassoProvider; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
final class PullImageController { | ||
|
||
static Context mContext; | ||
|
||
public PullImageController(Context context) { | ||
mContext = context; | ||
} | ||
|
||
public void pullDashboardImages(DhisController.ImageNetworkPolicy imageNetworkPolicy) throws APIException { | ||
List<String> requestList = new ArrayList<>(); | ||
requestList = downloadDashboardImages(requestList); | ||
downloadImages(imageNetworkPolicy, requestList, mContext); | ||
} | ||
|
||
public void pullInterpretationImages(DhisController.ImageNetworkPolicy imageNetworkPolicy) throws APIException { | ||
List<String> requestList = new ArrayList<>(); | ||
requestList = downloadInterpretationImages(requestList); | ||
downloadImages(imageNetworkPolicy, requestList, mContext); | ||
} | ||
|
||
public static List<String> downloadInterpretationImages(List<String> requestList) { | ||
for (InterpretationElement interpretationElement : InterpretationController | ||
.queryAllInterpretationElements()) { | ||
if (interpretationElement == null || interpretationElement.getType() == null) { | ||
continue; | ||
} | ||
if (Interpretation.TYPE_CHART.equals(interpretationElement.getType())) { | ||
requestList.add( | ||
DhisController.buildImageUrl("charts", interpretationElement.getUId(), | ||
mContext)); | ||
} else if (Interpretation.TYPE_MAP.equals(interpretationElement.getType())) { | ||
requestList.add(DhisController.buildImageUrl("maps", interpretationElement.getUId(), | ||
mContext)); | ||
} | ||
} | ||
return requestList; | ||
} | ||
|
||
public static List<String> downloadDashboardImages(List<String> requestList) { | ||
for (DashboardElement element : DashboardController.queryAllDashboardElement()) { | ||
if (element.getDashboardItem() == null | ||
|| element.getDashboardItem().getType() == null) { | ||
continue; | ||
} | ||
|
||
switch (element.getDashboardItem().getType()) { | ||
case DashboardItemContent.TYPE_CHART: { | ||
requestList.add( | ||
DhisController.buildImageUrl("charts", element.getUId(), mContext)); | ||
break; | ||
} | ||
case DashboardItemContent.TYPE_EVENT_CHART: { | ||
requestList.add(DhisController.buildImageUrl("eventCharts", element.getUId(), | ||
mContext)); | ||
break; | ||
} | ||
case DashboardItemContent.TYPE_MAP: { | ||
requestList.add( | ||
DhisController.buildImageUrl("maps", element.getUId(), mContext)); | ||
break; | ||
} | ||
} | ||
} | ||
return requestList; | ||
} | ||
|
||
private static void downloadImages(DhisController.ImageNetworkPolicy imageNetworkPolicy, | ||
final List<String> requestUrlList, final Context context) { | ||
|
||
for (int i = 0; i < requestUrlList.size(); i++) { | ||
final String request = requestUrlList.get(i); | ||
|
||
if (imageNetworkPolicy == DhisController.ImageNetworkPolicy.NO_CACHE) { | ||
PicassoProvider.getInstance(context, false) | ||
.load(request).networkPolicy(NetworkPolicy.NO_CACHE) | ||
.memoryPolicy(MemoryPolicy.NO_CACHE).fetch(); | ||
} else { | ||
PicassoProvider.getInstance(context, false) | ||
.load(request).fetch(); | ||
} | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
api/src/main/java/org/hisp/dhis/android/dashboard/api/models/AttributeDimension.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.hisp.dhis.android.dashboard.api.models; | ||
|
||
import com.raizlabs.android.dbflow.annotation.Column; | ||
import com.raizlabs.android.dbflow.annotation.PrimaryKey; | ||
import com.raizlabs.android.dbflow.annotation.Table; | ||
import com.raizlabs.android.dbflow.structure.BaseModel; | ||
|
||
import org.hisp.dhis.android.dashboard.api.models.meta.DbDhis; | ||
|
||
@Table(databaseName = DbDhis.NAME) | ||
public class AttributeDimension extends BaseModel { | ||
|
||
@Column(name = "id") | ||
@PrimaryKey(autoincrement = true) | ||
long id; | ||
|
||
UIDObject attribute; | ||
|
||
public UIDObject getAttribute() { | ||
return attribute; | ||
} | ||
|
||
public void setAttribute(UIDObject attribute) { | ||
this.attribute = attribute; | ||
} | ||
} |
Oops, something went wrong.