Skip to content

Commit

Permalink
updated gradle, implemented hashcode and equals in detail state. code…
Browse files Browse the repository at this point in the history
… clean up. removed unused code
  • Loading branch information
Zeyad-37 committed Aug 1, 2017
1 parent ace2e35 commit 0eca3ad
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 736 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jul 21 09:36:27 COT 2017
#Thu Jul 27 15:41:02 COT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
68 changes: 40 additions & 28 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,26 +59,11 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
Expand All @@ -85,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand Down Expand Up @@ -150,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
14 changes: 4 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

Expand Down Expand Up @@ -46,10 +46,9 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
Expand All @@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line
Expand Down
1 change: 1 addition & 0 deletions sampleApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ dependencies {
compile "com.jakewharton:butterknife:$butterKnife"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnife"
// Utilities
compile 'com.airbnb.android:lottie:2.1.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.zeyad.usecases.app.screens.user.detail;

import org.parceler.Parcel;

import com.google.gson.annotations.SerializedName;
import com.zeyad.usecases.app.screens.user.list.User;

import org.parceler.Parcel;

import io.realm.RealmObject;

/**
Expand All @@ -16,17 +16,14 @@ public class Repository extends RealmObject {
int id;
@SerializedName("name")
String name;
@SerializedName("full_name")
String fullName;
@SerializedName("owner")
User owner;

public Repository() {
}

public static boolean isEmpty(Repository repository) {
return repository == null || repository.name == null && repository.fullName == null &&
repository.owner == null;
return repository == null || repository.name == null && repository.owner == null;
}

public int getId() {
Expand All @@ -45,11 +42,30 @@ public void setName(String name) {
this.name = name;
}

public String getFullName() {
return fullName;
public User getOwner() {
return owner;
}

public void setOwner(User owner) {
this.owner = owner;
}

@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (owner != null ? owner.hashCode() : 0);
return result;
}

public void setFullName(String fullName) {
this.fullName = fullName;
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof Repository))
return false;
Repository that = (Repository) o;
return id == that.id && (name != null ? name.equals(that.name)
: that.name == null && (owner != null ? owner.equals(that.owner) : that.owner == null));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
package com.zeyad.usecases.app.screens.user.detail;

import static com.zeyad.rxredux.core.redux.BaseActivity.UI_MODEL;

import java.util.ArrayList;
import java.util.List;

import org.parceler.Parcels;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.zeyad.gadapter.GenericRecyclerViewAdapter;
import com.zeyad.gadapter.ItemInfo;
import com.zeyad.rxredux.core.redux.ErrorMessageFactory;
import com.zeyad.usecases.api.DataServiceFactory;
import com.zeyad.usecases.app.R;
import com.zeyad.usecases.app.screens.BaseFragment;
import com.zeyad.usecases.app.screens.user.list.User;
import com.zeyad.usecases.app.screens.user.list.UserListActivity;
import com.zeyad.usecases.app.utils.Utils;

import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.graphics.Bitmap;
Expand All @@ -22,31 +43,10 @@
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.zeyad.gadapter.GenericRecyclerViewAdapter;
import com.zeyad.gadapter.ItemInfo;
import com.zeyad.rxredux.core.redux.ErrorMessageFactory;
import com.zeyad.usecases.api.DataServiceFactory;
import com.zeyad.usecases.app.R;
import com.zeyad.usecases.app.screens.BaseFragment;
import com.zeyad.usecases.app.screens.user.list.User;
import com.zeyad.usecases.app.screens.user.list.UserListActivity;
import com.zeyad.usecases.app.utils.Utils;

import org.parceler.Parcels;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observable;

import static com.zeyad.rxredux.core.redux.BaseActivity.UI_MODEL;

/**
* A fragment representing a single Repository detail screen. This fragment is either contained in a
* {@link UserListActivity} in two-pane mode (on tablets) or a {@link UserDetailActivity} on
Expand Down Expand Up @@ -103,10 +103,10 @@ public void initialize() {
viewModel = ViewModelProviders.of(this).get(UserDetailVM.class);
viewModel.init((newResult, event, currentStateBundle) -> UserDetailState.builder()
.setRepos((List<Repository>) newResult)
.setUser(currentStateBundle.getUser())
.setUser(currentStateBundle.getUserLogin())
.setIsTwoPane(currentStateBundle.isTwoPane())
.build(), viewState, DataServiceFactory.getInstance());
events = Observable.just(new GetReposEvent(viewState.getUser().getLogin()));
events = Observable.just(new GetReposEvent(viewState.getUserLogin()));
}

@Override
Expand All @@ -133,7 +133,7 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@Override
public void renderSuccessState(UserDetailState userDetailState) {
viewState = userDetailState;
User user = viewState.getUser();
User user = viewState.getOwner();
List<Repository> repoModels = viewState.getRepos();
if (Utils.isNotEmpty(repoModels)) {
repositoriesAdapter.setDataList(Observable.fromIterable(repoModels)
Expand Down
Loading

0 comments on commit 0eca3ad

Please sign in to comment.