Skip to content

Commit

Permalink
GibQuote 2.6.3 | Updater Phixes
Browse files Browse the repository at this point in the history
* Umm, I guess updater would be okay this time
  - currentVersionPosition is set to -1
    - If currentVersion isn't official, then this would remain to be -1
      - Update dialog wouldn't be shown, in that case

* Move updater code under a method

Signed-off-by: a7r3 <arvindultimate7352@gmail.com>
  • Loading branch information
a7r3 committed Jan 1, 2018
1 parent 82821c8 commit d2a4aea
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 16
targetSdkVersion 27
versionCode 2
versionName "2.6.2"
versionName "2.6.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/com/arvind/quote/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public class MainActivity extends AppCompatActivity implements PreferenceFragmen
// to make sure the same fragment isn't instantiated again
private MenuItem previousItem;
private BottomNavigationView bottomNavigationView;

// Root Layout
private RelativeLayout rootLayout;
// Updater Instance
private UpdaterUtils updaterUtils;
// AlertDialog in which UpdaterStuff would be shown
Expand Down Expand Up @@ -206,7 +207,7 @@ public void onClick(View view) {
// Set background of the Navigation drawer view
navigationView.setBackgroundColor(getResources().getColor(cardViewBackGround));

RelativeLayout rootLayout = findViewById(R.id.root_layout);
rootLayout = findViewById(R.id.root_layout);

if (themeKey.equals("translucent")) {
AnimationDrawable anim = (AnimationDrawable) rootLayout.getBackground();
Expand Down Expand Up @@ -295,6 +296,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
}

startUpdater();
}

public void startUpdater() {
// UpdaterUtils Instance
// Checks for Updates - Uses GitHub Releases/Tags System with GitHub API v3
updaterUtils = new UpdaterUtils(this.getApplicationContext(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class QuoteViewHolder extends RecyclerView.ViewHolder {
authorTextView = itemView.findViewById(R.id.author_text_view);

starQuoteView = itemView.findViewById(R.id.star_quote_button);

starQuoteView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
22 changes: 10 additions & 12 deletions app/src/main/java/com/arvind/quote/utils/UpdaterUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,24 @@ public void onResponse(JSONArray response) {
.replaceAll(".*/", "");

// Variable to hold current Tag's position in the list of tags
int currentVersionPosition;
int currentVersionPosition = -1;

// Get Position of currentVersion Tag in the tags List
String interVersion = null;
for (currentVersionPosition = 0; currentVersionPosition < response.length(); currentVersionPosition++) {
interVersion = response
.getJSONObject(currentVersionPosition)
String interVersion[] = new String[response.length()];
for(int i = 0; i < interVersion.length; i++) {
interVersion[i] = response.getJSONObject(i)
.getString("ref")
.replaceAll(".*/", "");
// If the intermediate version equals current, then break the loop
if (interVersion.equals(currentVersion))
break;
if(currentVersion.equals(interVersion[i]))
currentVersionPosition = i;
}

// If currentVersion is at the End, we're updated
boolean isAtEnd = currentVersionPosition == response.length();
boolean isAtEnd = currentVersionPosition == (response.length() - 1);
// If we're at end, and the End Version not equals Current Version
// >> deb Mode enabled
boolean isDev = isAtEnd && !interVersion.equals(currentVersion);
if (isDev) {
boolean isDev = isAtEnd && (currentVersionPosition == -1);
if(isDev) {
Log.d(TAG, "Hello Debluper");
Toast.makeText(context,
"Hello Debluper",
Expand All @@ -131,7 +129,7 @@ public void onResponse(JSONArray response) {
Toast.makeText(context,
"We're updated!",
Toast.LENGTH_LONG).show();
} else { // We're not
} else { // We're not updated
// The total number of Tag Requests
tagRequestCount = (response.length() - 1) + currentVersionPosition;
// Creating changeLog message array
Expand Down

0 comments on commit d2a4aea

Please sign in to comment.