Skip to content

Commit

Permalink
Bug Fixes and Minor Additions
Browse files Browse the repository at this point in the history
Preparing 0.2.1 release to MCentral
  • Loading branch information
r0adkll committed May 7, 2015
1 parent 359bf47 commit 44c2403
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=0.2.1-SNAPSHOT
VERSION_NAME=0.2.1
VERSION_CODE=7
GROUP=com.52inc

Expand Down
8 changes: 6 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ dependencies {
compile 'com.squareup.dagger:dagger:1.2.2'

// Wharton Libraries
compile 'com.jakewharton.timber:timber:3.0.1'
compile 'com.jakewharton.timber:timber:3.0.2'
compile 'com.jakewharton:butterknife:6.1.0'

// Rx
compile 'io.reactivex:rxjava:1.0.10'
compile 'io.reactivex:rxandroid:0.24.0'

// UI Libraries
compile 'com.github.clans:fab:1.4.0'
compile 'com.nispok:snackbar:2.10.7'
compile 'com.nispok:snackbar:2.10.8'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.0@aar'

}
Expand Down
20 changes: 10 additions & 10 deletions library/library.iml
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,23 @@
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="snackbar-2.10.7" level="project" />
<orderEntry type="library" exported="" name="rxandroid-0.24.0" level="project" />
<orderEntry type="library" exported="" name="dagger-1.2.2" level="project" />
<orderEntry type="library" exported="" name="rxjava-1.0.10" level="project" />
<orderEntry type="library" exported="" name="timber-3.0.2" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
<orderEntry type="library" exported="" name="butterknife-6.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="snackbar-2.10.8" level="project" />
<orderEntry type="library" exported="" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" name="timber-3.0.1" level="project" />
<orderEntry type="library" exported="" name="library-0.4.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" />
<orderEntry type="library" exported="" name="fab-1.4.0" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="butterknife-6.1.0" level="project" />
<orderEntry type="library" exported="" name="fab-1.4.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.0.0" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void query(String query){

// Force an application of the query
notifyDataSetChanged();

}

/**
Expand Down
9 changes: 9 additions & 0 deletions library/src/main/java/com/ftinc/kit/di/Stub.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ftinc.kit.di;

/**
* Project: android-52Kit
* Package: com.ftinc.kit.di
* Created by drew.heavner on 5/7/15.
*/
public class Stub {
}
10 changes: 10 additions & 0 deletions library/src/main/java/com/ftinc/kit/di/qualifiers/Flavor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.ftinc.kit.di.qualifiers;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import javax.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface Flavor {}
10 changes: 10 additions & 0 deletions library/src/main/java/com/ftinc/kit/di/qualifiers/Sauce.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.ftinc.kit.di.qualifiers;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import javax.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface Sauce {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import butterknife.ButterKnife;
import timber.log.Timber;

/**
* @deprecated Found a better Float Label library to use: "https://github.com/rengwuxian/MaterialEditText"
*/
@Deprecated
public class FloatLabelFocusChangeListener implements View.OnFocusChangeListener{

private Context ctx;
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/com/ftinc/kit/util/FormatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class FormatUtils {
/**
* Precision ENUM for condensing a file size
*/
public static enum Precision {
public enum Precision {
ONE_DIGIT("%.1f"),
TWO_DIGIT("%.2f"),
THREE_DIGIT("%.3f"),
Expand Down
113 changes: 113 additions & 0 deletions library/src/main/java/com/ftinc/kit/util/RxUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.ftinc.kit.util;

import android.os.Handler;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
* Utility Helper class for RxJava additions
*
* Project: android-52Kit
* Package: com.ftinc.kit.util
* Created by drew.heavner on 5/7/15.
*/
public class RxUtils {

/**
* <p>
* Apply the subscribeOn/observeOn transformation of io/mainThread
* to an observable via compose()
* </p>
*
* <p>
* Only apply this to observables that are handling I/O work, e.g.; Networking, Database, etc...
* </p>
*
* @param <T> the transformation type
* @return the observable post-transform
*/
public static <T> Observable.Transformer<T, T> applyIOSchedulers() {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(Observable<T> observable) {
return observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
};
}

/**
* <p>
* Apply the subscribeOn/observeOn transformation of computation/mainThread
* to an observable via compose()
* </p>
*
* <p>
* Only apply this to observables that are handling computation tasks in the background. Basically
* all non-IO work
* </p>
*
* @param <T> the transformation type
* @return the observable post-transform
*/
public static <T> Observable.Transformer<T, T> applyWorkSchedulers() {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(Observable<T> observable) {
return observable.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread());
}
};
}

/**
* <p>
* Apply the subscribeOn/observeOn transformation of {custom_handler}/mainThread
* to an observable via compose()
* </p>
*
* <p>
* Only apply this to observables that are handling computation tasks in the background. Basically
* all non-IO work
* </p>
*
* @param <T> the transformation type
* @return the observable post-transform
*/
public static <T> Observable.Transformer<T, T> applyCustomSchedulers(final Handler subscribeHandler) {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(Observable<T> observable) {
return observable.subscribeOn(AndroidSchedulers.handlerThread(subscribeHandler))
.observeOn(AndroidSchedulers.mainThread());
}
};
}

/**
* <p>
* Apply the subscribeOn/observeOn transformation of computation/mainThread
* to an observable via compose()
* </p>
*
* <p>
* Only apply this to observables that are handling computation tasks in the background. Basically
* all non-IO work
* </p>
*
* @param <T> the transformation type
* @return the observable post-transform
*/
public static <T> Observable.Transformer<T, T> applyCustomSchedulers(final Handler subscribeHandler, final Handler observeHandler) {
return new Observable.Transformer<T, T>() {
@Override
public Observable<T> call(Observable<T> observable) {
return observable.subscribeOn(AndroidSchedulers.handlerThread(subscribeHandler))
.observeOn(AndroidSchedulers.handlerThread(observeHandler));
}
};
}

}
70 changes: 69 additions & 1 deletion library/src/main/java/com/ftinc/kit/util/TimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@

import com.ftinc.kit.R;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Formatter;
import java.util.TimeZone;

import static java.util.Calendar.DAY_OF_MONTH;
import static java.util.Calendar.MONTH;
import static java.util.Calendar.YEAR;

/**
* Created by r0adkll on 3/8/15.
*/
Expand All @@ -34,7 +40,16 @@ public class TimeUtils {
private static final int HOUR = 60 * MINUTE;
private static final int DAY = 24 * HOUR;

public static String getTimeAgo(long time, Context ctx) {
/**
* <p>
* Get a timestamp in a an *ago format <br/>
* e.g.; "just now", "a minute ago", "5 minutes ago", "10 hours ago", "2 days ago", etc...
* </p>
*
* @param time the time to format
* @return the formated time
*/
public static String getTimeAgo(long time) {
// TODO: use DateUtils methods instead
if (time < 1000000000000L) {
// if timestamp given in seconds, convert to millis
Expand Down Expand Up @@ -64,7 +79,60 @@ public static String getTimeAgo(long time, Context ctx) {
}
}

/**
* Generate a fancy timestamp based on unix epoch time that is more user friendly than just
* a raw output by collapsing the time into manageable formats based on how much time has
* elapsed since epoch
*
* @param epoch the time in unix epoch
* @return the fancy timestamp
*/
public static String fancyTimestamp(long epoch){

// First, check to see if it's within 1 minute of the current date
if(System.currentTimeMillis() - epoch < 60000){
return "Just now";
}

// Get calendar for just now
Calendar now = Calendar.getInstance();

// Generate Calendar for this time
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(epoch);

// Based on the date, determine what to print out
// 1) Determine if time is the same day
if(cal.get(YEAR) == now.get(YEAR)){

if(cal.get(MONTH) == now.get(MONTH)){

if(cal.get(DAY_OF_MONTH) == now.get(DAY_OF_MONTH)){

// Return just the time
SimpleDateFormat format = new SimpleDateFormat("h:mm a");
return format.format(cal.getTime());
} else {

// Return the day and time
SimpleDateFormat format = new SimpleDateFormat("EEE, h:mm a");
return format.format(cal.getTime());
}

}else{

SimpleDateFormat format = new SimpleDateFormat("EEE, MMM d, h:mm a");
return format.format(cal.getTime());
}

}else{

SimpleDateFormat format = new SimpleDateFormat("M/d/yy");
return format.format(cal.getTime());

}

}

/**
* Returns "Today", "Tomorrow", "Yesterday", or a short date format.
Expand Down

0 comments on commit 44c2403

Please sign in to comment.