Skip to content

Commit

Permalink
Show emoji download progress, update libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
DSteve595 committed Dec 22, 2015
1 parent 4e0d5eb commit 2bff39a
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 121 deletions.
22 changes: 11 additions & 11 deletions Emoji Switcher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '22.0.1'
buildToolsVersion '23.0.2'

defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 14
versionName "2.0.1"
versionCode 16
versionName "2.0.2"
}

compileOptions {
Expand All @@ -18,16 +18,16 @@ android {
}

dependencies {
compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'commons-io:commons-io:2.4'
compile 'com.google.guava:guava:18.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.trello:rxlifecycle:0.2.0'
compile 'com.trello:rxlifecycle-components:0.2.0'
compile 'com.google.guava:guava:19.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.trello:rxlifecycle:0.4.0'
compile 'com.trello:rxlifecycle-components:0.4.0'
compile files('libs/RootTools-4.2.jar')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.yqritc:recyclerview-flexibledivider:1.2.5'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.yqritc:recyclerview-flexibledivider:1.2.6'
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.mani:thindownloadmanager:1.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void onNext(Boolean ready) {
});

if (InstallProgress.hasDownloadStage(emojiSet)) {
final InstallProgress progress = new InstallProgress();
InstallProgress progress = new InstallProgress();
progress.currentStage = InstallProgress.Stage.Download;
subscriber.onNext(progress);

Expand All @@ -155,6 +155,8 @@ public void onNext(Boolean ready) {
.subscribe(new Action1<Integer>() {
@Override
public void call(Integer percent) {
InstallProgress progress = new InstallProgress();
progress.currentStage = InstallProgress.Stage.Download;
progress.currentStageProgress = percent;
subscriber.onNext(progress);
}
Expand Down Expand Up @@ -198,29 +200,50 @@ public enum Stage {
public String getTitle() {
return "HTC override";
}
@Override
public boolean hasPercentProgress() {
return false;
}
}, Download {
@Override
public String getTitle() {
return "Download new emoji";
}
@Override
public boolean hasPercentProgress() {
return true;
}
}, Backup {
@Override
public String getTitle() {
return "Backup old emoji";
}
@Override
public boolean hasPercentProgress() {
return false;
}
}, Install {
@Override
public String getTitle() {
return "Install new emoji";
}
@Override
public boolean hasPercentProgress() {
return false;
}
}, Done {
@Override
public String getTitle() {
return "Done!";
}
@Override
public boolean hasPercentProgress() {
return false;
}
};

public abstract String getTitle();
public abstract boolean hasPercentProgress();
}

static boolean hasHtcStage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public InstallStageAdapter(boolean hasHtcStage, boolean hasDownloadStage, boolea
if (!hasHtcStage) stages.remove(EmojiSwitcherUtils.InstallProgress.Stage.HtcFix);
if (!hasDownloadStage) stages.remove(EmojiSwitcherUtils.InstallProgress.Stage.Download);
if (!hasBackupStage) stages.remove(EmojiSwitcherUtils.InstallProgress.Stage.Backup);
setHasStableIds(true);
}

public void updateProgress(EmojiSwitcherUtils.InstallProgress installProgress) {
Expand All @@ -164,7 +165,7 @@ public void updateProgress(EmojiSwitcherUtils.InstallProgress installProgress) {
if (oldProgress == null ||
oldProgress.currentStage != installProgress.currentStage ||
oldProgress.currentStageProgress != installProgress.currentStageProgress) {
notifyDataSetChanged();
notifyDataSetChanged();
}
}

Expand All @@ -176,25 +177,36 @@ public StageHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@Override
public void onBindViewHolder(StageHolder holder, int position) {
holder.title.setText((position + 1) + ". " + stages.get(position).getTitle());
if (position == getStagePosition(installProgress.currentStage)) {
EmojiSwitcherUtils.InstallProgress.Stage stage = stages.get(position);

holder.title.setText(String.format("%d. %s", (position + 1), stage.getTitle()));
if (stage == installProgress.currentStage) {
holder.title.setEnabled(true);
if (installProgress.currentStage == EmojiSwitcherUtils.InstallProgress.Stage.Done) {
if (stage == EmojiSwitcherUtils.InstallProgress.Stage.Done) {
holder.loading.setVisibility(View.INVISIBLE);
} else {
holder.loading.setVisibility(View.VISIBLE);
if (installProgress.currentStage.hasPercentProgress()) {
holder.loading.setVisibility(View.GONE);
holder.percent.setVisibility(View.VISIBLE);
holder.percent.setText(String.format("%d%%", installProgress.currentStageProgress));
} else {
holder.percent.setVisibility(View.INVISIBLE);
holder.loading.setVisibility(View.VISIBLE);
}
}
} else {
holder.title.setEnabled(false);
holder.loading.setVisibility(View.INVISIBLE);
holder.percent.setVisibility(View.INVISIBLE);
}
}

private int getStagePosition(EmojiSwitcherUtils.InstallProgress.Stage stage) {
return stages.indexOf(stage);
}
@Override
public long getItemId(int position) {
return stages.get(position).ordinal();
}

@Override
@Override
public int getItemCount() {
if (installProgress == null) {
return 0;
Expand All @@ -207,12 +219,14 @@ class StageHolder extends RecyclerView.ViewHolder {
private View root;
private TextView title;
private ProgressBar loading;
private TextView percent;

public StageHolder(View itemView) {
super(itemView);
root = itemView;
title = (TextView) itemView.findViewById(R.id.install_emoji_stages_listitem_title);
loading = (ProgressBar) itemView.findViewById(R.id.install_emoji_stages_listitem_loading);
percent = (TextView) itemView.findViewById(R.id.install_emoji_stages_listitem_percent);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
import com.stevenschoen.emojiswitcher.billing.IabHelper;
import com.stevenschoen.emojiswitcher.network.EmojiSetListing;

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

public class SetListingUtils {
public static boolean userOwnsSet(EmojiSetListing listing, IabHelper billingHelper) {
if (listing.googlePlaySku == null) {
if (listing.googlePlaySku == null || listing.free) {
return true;
} else {
List<String> skuList = new ArrayList<>();
skuList.add(listing.googlePlaySku);
List<String> skuList = Collections.singletonList(listing.googlePlaySku);
try {
return billingHelper.queryInventory(true, skuList, null).hasPurchase(listing.googlePlaySku);
} catch (IabException e) {
Expand Down
Loading

0 comments on commit 2bff39a

Please sign in to comment.