Skip to content

Commit

Permalink
Merge branch 'v1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
brookmg committed Sep 15, 2019
2 parents ed81b58 + 67b50af commit 352acf1
Show file tree
Hide file tree
Showing 21 changed files with 403 additions and 34 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
compileSdkVersion 28
Expand All @@ -11,6 +13,7 @@ android {
versionName String.valueOf(appVersionMajor) + "." + String.valueOf(appVersionMinor) + "." + String.valueOf(appVersionBuild) + "." + String.valueOf(iterationNumber)
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
manifestPlaceholders = [
yenepayReturnScheme: "app.kuwas.android"
]
Expand Down Expand Up @@ -41,6 +44,7 @@ dependencies {
implementation project(":soccerethiopiaapi")
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation "com.airbnb.android:lottie:3.0.1"
implementation 'androidx.multidex:multidex:2.0.1'

//LIFECYCLE
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
Expand All @@ -54,6 +58,11 @@ dependencies {

implementation firebase.core
implementation firebase.config
implementation firebase.performance
implementation firebase.messaging
implementation firebase.adslite

implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
android:configChanges="orientation|screenLayout|screenSize|keyboard|keyboardHidden"
android:label="@string/team_information"
android:theme="@style/KuwasLightTheme" />

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-1846679736594156~3305825629"/>

</application>

</manifest>
13 changes: 12 additions & 1 deletion app/src/main/java/app/kuwas/android/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,26 @@
import android.content.res.Configuration;
import android.util.Log;

import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import com.yenepaySDK.PaymentOrderManager;
import com.yenepaySDK.model.YenePayConfiguration;

import java.util.HashMap;
import java.util.Map;

import app.kuwas.android.ui.activities.AboutActivity;
import app.kuwas.android.utils.Constants;
import app.kuwas.android.utils.Utils;
import io.brookmg.soccerethiopiaapi.access.SoccerEthiopiaApi;

/**
* Created by BrookMG on 5/18/2019 in app.kuwas.android
* inside the project Kuwas .
*/
public class App extends Application {
public class App extends MultiDexApplication {

private static App instance;
private SoccerEthiopiaApi api;
Expand All @@ -43,9 +50,13 @@ public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
instance = this;

remoteConfig = FirebaseRemoteConfig.getInstance();
Map<String, Object> defaults = new HashMap<>();
defaults.put(Constants.FRC_SHOW_ADS , true);
remoteConfig.setDefaults(defaults);
remoteConfig.fetchAndActivate().addOnCompleteListener(
task -> Log.d("REMOTE_CONFIG", "completed - " +
(task.isComplete() && task.isSuccessful() ? "YAP" : "NOP"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package app.kuwas.android.ui.activities;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -49,7 +50,6 @@
import static app.kuwas.android.utils.FabStates.FabState;
import static app.kuwas.android.utils.Utils.getCurrentTheme;
import static app.kuwas.android.utils.Utils.openPlayStore;
import static app.kuwas.android.utils.Utils.setCurrentTheme;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -106,7 +106,9 @@ private void changeTheme() {
int currentTheme = Utils.getCurrentTheme(this);
if (currentTheme == 0) Utils.setCurrentTheme(this , 1);
else Utils.setCurrentTheme(this, 0);
recreate();
startActivity(new Intent(this, MainActivity.class));
overridePendingTransition(0,0);
finish();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.core.widget.ContentLoadingProgressBar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.transition.TransitionInflater;
Expand Down Expand Up @@ -54,6 +57,8 @@ public class NewsFragment extends BaseFragment {

private RecyclerView mainRecycler;
private Integer recyclerViewY = 0;
private RelativeLayout contentLoadingIndicator;
private View errorLayout;

static NewsFragment newInstance() {
Bundle args = new Bundle();
Expand All @@ -75,10 +80,28 @@ private boolean listContainsNews(List<NewsItem> items, int id) {
return false;
}

private void showLoadingLayout() {
if (contentLoadingIndicator != null) {
contentLoadingIndicator.animate().alpha(1f).setDuration(500).start();
}
}

private void hideLoadingLayout() {
if (contentLoadingIndicator != null) {
contentLoadingIndicator.animate().alpha(0f).setDuration(500).start();
}
}

private void changeErrorVisibility(boolean show) {
errorLayout.setVisibility(show ? View.VISIBLE : View.GONE);
errorLayout.animate().alpha(show ? 1 : 0).setDuration(500).start();
}

@Override
public void refresh() {
super.refresh();
if (mainRecycler != null) {
showLoadingLayout();
App.getInstance().getApi().getLatestNews(
news -> {
Collections.sort(news, (o1, o2) -> {
Expand Down Expand Up @@ -111,8 +134,14 @@ public boolean onItemLongClicked(View view, int position) {
}
});
mainRecycler.setAdapter(adapter);
hideLoadingLayout();
changeErrorVisibility(false);
},
error -> Log.e("NewsFragment:", error != null ? error : "Unknown")
error -> {
Log.e("NewsFragment:", error != null ? error : "Unknown");
hideLoadingLayout();
changeErrorVisibility(true);
}
);
}
}
Expand All @@ -127,9 +156,12 @@ private void computeRecyclerViewScrollForAppbarElevation(Integer yDiff) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.news_fragment, container, false);
mainRecycler = mainView.findViewById(R.id.mainNewsRecyclerView);
contentLoadingIndicator = mainView.findViewById(R.id.loading_layout);
errorLayout = mainView.findViewById(R.id.error_layout);
mainRecycler.setHasFixedSize(true); //for performance increments

refresh();
mainView.findViewById(R.id.refresh_button).setOnClickListener(v -> refresh());

mainRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.material.chip.Chip;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import app.kuwas.android.App;
import app.kuwas.android.R;
import app.kuwas.android.ui.adapters.TagsChipRecyclerAdapter;
import app.kuwas.android.utils.Constants;
import io.brookmg.soccerethiopiaapi.data.NewsItem;

import static app.kuwas.android.utils.Utils.dpToPx;
Expand Down Expand Up @@ -142,6 +145,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
newsDateTimePlusAuthor = mainView.findViewById(R.id.news_date_time_plus_author);
handleTopMarginOnFAB(mainView.findViewById(R.id.back_button));

if (App.getInstance().getRemoteConfig().getBoolean(Constants.FRC_SHOW_ADS)) {
AdView banner = mainView.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("2F3A40AA575193DE16F63722988863C8").build();
banner.loadAd(adRequest);
}

mainView.findViewById(R.id.back_button).setOnClickListener(v -> getActivity().onBackPressed());

return mainView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -47,6 +48,8 @@ public class ScoresFragment extends BaseFragment {

private RecyclerView mainRecycler;
private Integer recyclerViewY = 0;
private RelativeLayout contentLoadingIndicator;
private View errorLayout;

static ScoresFragment newInstance() {
Bundle args = new Bundle();
Expand All @@ -55,9 +58,22 @@ static ScoresFragment newInstance() {
return fragment;
}

private void showLoadingLayout() {
if (contentLoadingIndicator != null) {
contentLoadingIndicator.animate().alpha(1f).setDuration(500).start();
}
}

private void hideLoadingLayout() {
if (contentLoadingIndicator != null) {
contentLoadingIndicator.animate().alpha(0f).setDuration(500).start();
}
}

@Override
public void refresh() {
super.refresh();
showLoadingLayout();
if (mainRecycler != null)
App.getInstance().getApi().getThisWeekLeagueSchedule(
scheduleItems -> {
Expand All @@ -67,8 +83,14 @@ public void refresh() {
intent.putExtra("team", team);
startActivity(intent);
}));
hideLoadingLayout();
changeErrorVisibility(false);
},
error -> Log.e("ScoresFragment" , error)
error -> {
Log.e("ScoresFragment" , error);
hideLoadingLayout();
changeErrorVisibility(true);
}
);
}

Expand All @@ -77,13 +99,21 @@ private void computeRecyclerViewYForAppbarElevation(Integer yDiff) {
setAppBarElevation(round(min(recyclerViewY * 0.4f, 19f)));
}

private void changeErrorVisibility(boolean show) {
errorLayout.setVisibility(show ? View.VISIBLE : View.GONE);
errorLayout.animate().alpha(show ? 1 : 0).setDuration(500).start();
}

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.scores_fragment, container, false);
mainRecycler = mainView.findViewById(R.id.mainScoresRecyclerView);
contentLoadingIndicator = mainView.findViewById(R.id.loading_layout);
errorLayout = mainView.findViewById(R.id.error_layout);

refresh();
mainView.findViewById(R.id.refresh_button).setOnClickListener(v -> refresh());

mainRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -45,6 +46,8 @@
public class StandingFragment extends BaseFragment {

private StandingTable mainTable;
private RelativeLayout contentLoadingIndicator;
private View errorLayout;

static StandingFragment newInstance() {
Bundle args = new Bundle();
Expand All @@ -53,26 +56,54 @@ static StandingFragment newInstance() {
return fragment;
}

private void showLoadingLayout() {
if (contentLoadingIndicator != null) {
contentLoadingIndicator.animate().alpha(1f).setDuration(500).start();
}
}

private void hideLoadingLayout() {
if (contentLoadingIndicator != null) {
contentLoadingIndicator.animate().alpha(0f).setDuration(500).start();
}
}

@Override
public void refresh() {
super.refresh();
showLoadingLayout();
if (mainTable != null)
App.getInstance().getApi().getLatestTeamRanking(
ranking -> {
mainTable.clearTable();
mainTable.populateTable(ranking);
mainTable.invalidate();
}, error -> Log.e("Ranking" , error)
hideLoadingLayout();
changeErrorVisibility(false);
}, error -> {
Log.e("Ranking" , error);
hideLoadingLayout();
changeErrorVisibility(true);
}
, true
);
}

private void changeErrorVisibility(boolean show) {
errorLayout.setVisibility(show ? View.VISIBLE : View.GONE);
errorLayout.animate().alpha(show ? 1 : 0).setDuration(500).start();
}

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.standing_fragment, container, false);
mainTable = mainView.findViewById(R.id.main_standing_table);
contentLoadingIndicator = mainView.findViewById(R.id.loading_layout);
errorLayout = mainView.findViewById(R.id.error_layout);

refresh();
mainView.findViewById(R.id.refresh_button).setOnClickListener(v -> refresh());
((NestedScrollView) mainView.findViewById(R.id.nested_scroll_view)).setOnScrollChangeListener(
(NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) ->
setAppBarElevation(round(min(scrollY * 0.4f , 12f)))
Expand Down
Loading

0 comments on commit 352acf1

Please sign in to comment.