Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/1.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
JM committed Aug 2, 2016
2 parents 3db70b5 + 71c758d commit 60ddab6
Show file tree
Hide file tree
Showing 35 changed files with 690 additions and 308 deletions.
4 changes: 2 additions & 2 deletions LiferayScreens.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'LiferayScreens'
s.module_name = 'LiferayScreens'
s.version = '1.4.0'
s.version = '1.4.1'
s.summary = 'A family of visual components called screenlets that are connected to the Liferay Platform used as a backend'
s.homepage = 'https://www.liferay.com/liferay-screens'
s.license = {
Expand Down Expand Up @@ -51,7 +51,7 @@ Pod::Spec.new do |s|
}

# Core
s.dependency 'Liferay-iOS-SDK', '~> 7.0.3'
s.dependency 'Liferay-iOS-SDK', '~> 7.0.4'
s.dependency 'Liferay-OAuth', '~> 1.2.0'
s.dependency 'MBProgressHUD', '0.9.1'
s.dependency 'SMXMLDocument', '1.1'
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ ext {
targetSdkVersion = compileSdkVersion
buildToolsVersion = '23.0.3'

versionCode = 5
versionName = '1.4.0'
versionCode = 6
versionName = '1.4.1'

publishedGroupId = 'com.liferay.mobile'
libraryName = 'Liferay Screens for Android'
libraryDescription = 'Liferay Screens for Android includes the component (screenlets) library and a sample project'

bintrayRepo = 'liferay-mobile'
bintrayOrg = ''
bintrayOrg = 'liferay'
// bintrayOrg = 'liferay'

siteUrl = 'https://github.com/liferay/liferay-screens'
gitUrl = 'https://github.com/liferay/liferay-screens.git'
Expand All @@ -49,7 +49,7 @@ ext.libraries = [
junit : 'junit:junit:4.12',
gms : 'com.google.android.gms:play-services-gcm:7.0.0',
sdk : 'com.liferay.mobile:liferay-android-sdk:7.0.2',
push : 'com.liferay.mobile:liferay-push:1.0.8',
push : 'com.liferay.mobile:liferay-push:1.1.0',
oauth : 'com.liferay.mobile:liferay-android-oauth:1.3.0',
eventbus : 'de.greenrobot:eventbus:2.4.0',
picasso : 'com.squareup.picasso:picasso:2.5.2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ public static AssetEntry createInstance(Map<String, Object> map) {
map.putAll((Map) map.get("object"));

String stringLocale = (String) map.get("locale");
Locale locale = LiferayLocale.getLocaleWithoutDefault(stringLocale);

String className = (String) map.get("className");

if (className.contains("JournalArticle")) {
return new WebContent(map, locale);
}
else if (className.contains("DDLRecord")) {
return new Record(map, locale);
if (stringLocale != null) {
Locale locale = LiferayLocale.getLocaleWithoutDefault(stringLocale);

if (className.endsWith("JournalArticle")) {
return new WebContent(map, locale);
}
else if (className.endsWith("DDLRecord")) {
return new Record(map, locale);
}
}
}
return new AssetEntry(map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.liferay.mobile.screens.assetlist.interactor;

import com.liferay.mobile.screens.assetlist.AssetEntry;
import com.liferay.mobile.screens.base.context.RequestState;
import com.liferay.mobile.screens.base.interactor.BasicEvent;
import com.liferay.mobile.screens.base.interactor.InteractorAsyncTaskCallback;
import com.liferay.mobile.screens.base.list.interactor.BaseListEvent;
Expand Down Expand Up @@ -51,6 +52,20 @@ public BaseListResult transform(Object obj) throws Exception {
return result;
}

@Override
public void onSuccess(BaseListResult<AssetEntry> result) {
RequestState.getInstance().clear(getTargetScreenletId());

super.onSuccess(result);
}

@Override
public void onFailure(Exception e) {
RequestState.getInstance().clear(getTargetScreenletId());

super.onFailure(e);
}

@Override
protected BasicEvent createEvent(int targetScreenletId, BaseListResult<AssetEntry> result) {
return new BaseListEvent<>(targetScreenletId, 0, 0, null, result.getEntries(), result.getRowCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public synchronized static RequestState getInstance() {
return _instance;
}

public void clear(int targetScreenletId) {
_states.remove(targetScreenletId);
}

public synchronized void put(int targetScreenletId, Object state) {
HashSet<Object> set = _states.get(targetScreenletId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
public interface BaseListListener<E> extends CacheListener {

void onListPageFailed(BaseListScreenlet source, int page, Exception e);
void onListPageFailed(BaseListScreenlet source, int startRow, int endRow, Exception e);

void onListPageReceived(BaseListScreenlet source, int page, List<E> entries, int rowCount);
void onListPageReceived(BaseListScreenlet source, int startRow, int endRow, List<E> entries, int rowCount);

void onListItemSelected(E element, View view);
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,19 @@ public void loadPageForRow(int row) {

@Override
public void onListRowsFailure(int startRow, int endRow, Exception e) {
int page = getPageFromRow(startRow);

getViewModel().showFinishOperation(page, e);
getViewModel().showFinishOperation(startRow, endRow, e);

if (_listener != null) {
_listener.onListPageFailed(this, page, e);
_listener.onListPageFailed(this, startRow, endRow, e);
}
}

@Override
public void onListRowsReceived(int startRow, int endRow, List<E> entries, int rowCount) {
int page = getPageFromRow(startRow);

getViewModel().showFinishOperation(page, entries, rowCount);
getViewModel().showFinishOperation(startRow, endRow, entries, rowCount);

if (_listener != null) {
_listener.onListPageReceived(this, page, entries, rowCount);
_listener.onListPageReceived(this, startRow, endRow, entries, rowCount);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand Down Expand Up @@ -80,21 +79,56 @@ public void showFinishOperation(String actionName) {
}

@Override
public void showFinishOperation(int page, List<E> serverEntries, int rowCount) {
LiferayLogger.i("loaded page " + page + " of list with " + serverEntries);
public void showFinishOperation(int startRow, int endRow, List<E> serverEntries, int totalRowCount) {
LiferayLogger.i("loaded page " + startRow + " of list with " + serverEntries);

_progressBar.setVisibility(View.GONE);
_recyclerView.setVisibility(View.VISIBLE);

BaseListScreenlet screenlet = (BaseListScreenlet) getScreenlet();

A adapter = getAdapter();

List<E> entries = addNewServerEntries(serverEntries, page, rowCount);
// current entries in the adapter
List<E> entries = adapter.getEntries();

adapter.setRowCount(entries.size());
// we have to take into account that we start requesting the 2 page (and we don't want the first 2 ones)
int rowToFill = startRow - _firstRow;
int realRowCount = totalRowCount - _firstRow;

adapter.notifyDataSetChanged();
if (entries.isEmpty()) {

BaseListScreenlet screenlet = (BaseListScreenlet) getScreenlet();
_firstRow = rowToFill;
realRowCount = totalRowCount - _firstRow;
rowToFill = 0;

// we fill all entries in the first load
for (int i = 0; i < realRowCount; i++) {
entries.add(null);
}
}


if (realRowCount != entries.size()) {
if (realRowCount > entries.size()) {
for (int i = entries.size(); i < realRowCount; i++) {
entries.add(null);
}
}
else {
for (int i = realRowCount; i < entries.size(); i++) {
entries.remove(i);
}
}
}

for (int i = 0; i < serverEntries.size() && entries.size() > i + rowToFill; i++) {
entries.set(i + rowToFill, serverEntries.get(i));
}


adapter.setRowCount(realRowCount);
adapter.notifyDataSetChanged();
adapter.setLabelFields(screenlet.getLabelFields());
}

Expand All @@ -104,7 +138,7 @@ public void showFailedOperation(String actionName, Exception e) {
}

@Override
public void showFinishOperation(int page, Exception e) {
public void showFinishOperation(int startRow, int endRow, Exception e) {
_progressBar.setVisibility(View.GONE);
_recyclerView.setVisibility(View.VISIBLE);
LiferayLogger.e(getContext().getString(R.string.loading_list_error), e);
Expand Down Expand Up @@ -222,29 +256,6 @@ protected void setRecyclerView(RecyclerView value) {

protected abstract A createListAdapter(int itemLayoutId, int itemProgressLayoutId);

@NonNull
protected List<E> addNewServerEntries(List<E> serverEntries, int page, int rowCount) {
List<E> entries = getAdapter().getEntries();

BaseListScreenlet screenlet = (BaseListScreenlet) getScreenlet();
int row = screenlet.getFirstRowForPage(page) - _firstRow;

if (entries.isEmpty()) {
_firstRow = row;
row = 0;

//TODO better 'real' paginator
for (int i = 0; i < rowCount - _firstRow; i++) {
entries.add(null);
}
}

for (int i = 0; i < serverEntries.size() && entries.size() > i + row; i++) {
entries.set(i + row, serverEntries.get(i));
}
return entries;
}

protected int _firstRow = 0;
protected ProgressBar _progressBar;
protected RecyclerView _recyclerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/
public interface BaseListViewModel<E> extends BaseViewModel {

void showFinishOperation(int page, List<E> entries, int rowCount);
void showFinishOperation(int startRow, int endRow, List<E> entries, int rowCount);

void showFinishOperation(int page, Exception e);
void showFinishOperation(int startRow, int endRow, Exception e);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
*/
public enum LiferayPortalVersion {

VERSION_62, VERSION_70;
VERSION_62(62), VERSION_70(70);

private final int _version;

LiferayPortalVersion(int version) {
_version = version;
}

public int getVersion() {
return _version;
}

public static LiferayPortalVersion fromInt(int version) {
if (version == 70) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import android.content.res.Resources;

import com.liferay.mobile.android.util.PortalVersion;
import com.liferay.mobile.screens.R;

/**
Expand Down Expand Up @@ -83,6 +84,10 @@ public static boolean isLiferay62() {
return LiferayPortalVersion.VERSION_70.equals(_portalVersion);
}

public static LiferayPortalVersion getPortalVersion() {
return _portalVersion;
}

public static String getVersionFactory() {
return _versionFactory;
}
Expand All @@ -97,4 +102,5 @@ private static long getValueFromIntegerOrString(final Resources resources, final
private static String _classFactory;
private static LiferayPortalVersion _portalVersion;
private static String _versionFactory;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.liferay.mobile.push.Push;
import com.liferay.mobile.screens.BuildConfig;
import com.liferay.mobile.screens.context.OAuthAuthentication;
import com.liferay.mobile.screens.context.LiferayPortalVersion;
import com.liferay.mobile.screens.context.LiferayServerContext;
import com.liferay.mobile.screens.context.SessionContext;
import com.liferay.mobile.screens.util.LiferayLogger;

Expand Down Expand Up @@ -80,6 +82,8 @@ protected void registerWithPush() {
Session session = SessionContext.isLoggedIn() ?
SessionContext.createSessionFromCurrentSession() : getDefaultSession();
_push = Push.with(session);
LiferayPortalVersion portalVersion = LiferayServerContext.getPortalVersion();
_push.withPortalVersion(portalVersion.getVersion());

SharedPreferences preferences = getSharedPreferences();

Expand Down Expand Up @@ -153,6 +157,7 @@ private int getVersionCode() throws PackageManager.NameNotFoundException {
private SharedPreferences getSharedPreferences() {
return getSharedPreferences(PUSH_PREFERENCES, Context.MODE_PRIVATE);
}

private Push _push;

}
Loading

0 comments on commit 60ddab6

Please sign in to comment.