Browse Source

Animated logo fix

RecentFragment AsyncTask fix
pull/24/head
Ezerous 8 years ago
parent
commit
fc2993dff4
  1. 10
      app/build.gradle
  2. 14
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  3. 26
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  4. 5
      app/src/main/res/layout/activity_login.xml
  5. 2
      app/src/release/java/mthmmy.utils/Report.java

10
app/build.gradle

@ -27,11 +27,11 @@ android {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.1' compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.0.1' compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.0.1' compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:cardview-v7:25.0.1' compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.0.1' compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.google.firebase:firebase-crash:10.0.1' compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.squareup.okhttp3:okhttp:3.5.0' compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.picasso:picasso:2.5.2'

14
app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java

@ -93,21 +93,21 @@ public class LoginActivity extends BaseActivity {
}); });
GifDrawable gifFromPath = null; //GIF logo init
GifImageView gifImageView = (GifImageView) findViewById(R.id.logo);
try { try {
gifFromPath = new GifDrawable( getResources(), R.drawable.logo_animated ); final GifDrawable gifFromPath = new GifDrawable(getResources(), R.drawable.logo_animated);
gifFromPath.setSpeed(0.75f); gifFromPath.setSpeed(0.7f);
gifFromPath.addAnimationListener(new AnimationListener() { gifFromPath.addAnimationListener(new AnimationListener() {
@Override @Override
public void onAnimationCompleted(int loopNumber) { public void onAnimationCompleted(int loopNumber) {
recreate(); gifFromPath.reset();
} }
}); });
gifImageView.setImageDrawable(gifFromPath);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Report.wtf(TAG,"IO at animated logo (?)");
} }
GifImageView gifImageView = (GifImageView) findViewById(R.id.logo);
gifImageView.setImageDrawable(gifFromPath);
} }
@Override @Override

26
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java

@ -58,6 +58,8 @@ public class RecentFragment extends Fragment {
private OkHttpClient client; private OkHttpClient client;
private RecentTask recentTask;
// Required empty public constructor // Required empty public constructor
public RecentFragment() { public RecentFragment() {
} }
@ -102,9 +104,11 @@ public class RecentFragment extends Fragment {
if (sectionNumber == 1)//temp if (sectionNumber == 1)//temp
{ {
if (topicSummaries.isEmpty()) if (topicSummaries.isEmpty())
new RecentTask().execute(); {
recentTask =new RecentTask();
recentTask.execute();
}
} }
Report.d(TAG, "onActivityCreated"); Report.d(TAG, "onActivityCreated");
} }
@ -158,7 +162,10 @@ public class RecentFragment extends Fragment {
new SwipeRefreshLayout.OnRefreshListener() { new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override
public void onRefresh() { public void onRefresh() {
new RecentTask().execute(); if(recentTask!=null&&recentTask.getStatus()!= AsyncTask.Status.RUNNING) {
recentTask = new RecentTask();
recentTask.execute();
}
} }
@ -183,6 +190,14 @@ public class RecentFragment extends Fragment {
} }
} }
@Override
public void onDestroy() {
super.onDestroy();
if(recentTask!=null&&recentTask.getStatus()!= AsyncTask.Status.RUNNING)
recentTask.cancel(true);
}
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();
@ -215,7 +230,6 @@ public class RecentFragment extends Fragment {
} }
protected Integer doInBackground(Void... voids) { protected Integer doInBackground(Void... voids) {
Request request = new Request.Builder() Request request = new Request.Builder()
.url(thmmyUrl) .url(thmmyUrl)
.build(); .build();
@ -225,10 +239,10 @@ public class RecentFragment extends Fragment {
parse(document); parse(document);
return 0; return 0;
} catch (IOException e) { } catch (IOException e) {
Report.d("DEB", "ERROR", e); Report.d(TAG, "ERROR", e);
return 1; return 1;
} catch (Exception e) { } catch (Exception e) {
Report.d("DEB", "ERROR", e); Report.d(TAG, "ERROR", e);
return 2; return 2;
} }

5
app/src/main/res/layout/activity_login.xml

@ -25,8 +25,9 @@
android:layout_height="100dp"/> android:layout_height="100dp"/>
<pl.droidsonroids.gif.GifImageView <pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/logo" android:id="@+id/logo"
/> />

2
app/src/release/java/mthmmy.utils/Report.java

@ -73,7 +73,7 @@ public class Report
private static void exception(String level, String TAG, String message, Throwable tr) private static void exception(String level, String TAG, String message, Throwable tr)
{ {
FirebaseCrash.log(level + "/" + TAG + ": " + message + ": " + tr.getMessage()); FirebaseCrash.log(level + "/" + TAG + ": " + message + ": " + tr.getMessage());
if(level.equals("E")) //report only serious exceptions if(level.equals("E")||level.equals("WTF")) //report only serious exceptions
FirebaseCrash.report(tr); FirebaseCrash.report(tr);
} }

Loading…
Cancel
Save