Some fixes

This commit is contained in:
stom79 2018-09-10 19:35:17 +02:00
parent d8bb009dc3
commit fdaf41f2c9
4 changed files with 87 additions and 72 deletions

View File

@ -84,14 +84,15 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
cal.setTime(new Date( )); cal.setTime(new Date( ));
cal.add(Calendar.MINUTE, -5); cal.add(Calendar.MINUTE, -5);
Date dateAllowed = cal.getTime(); Date dateAllowed = cal.getTime();
if( lastDateListNameRefresh == null || Helper.stringToDate(WhoToFollowActivity.this, lastDateListNameRefresh).after(dateAllowed)) if( lastDateListNameRefresh == null || Helper.stringToDate(WhoToFollowActivity.this, lastDateListNameRefresh).before(dateAllowed)) {
new WhoToFollowAsyncTask(WhoToFollowActivity.this, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new WhoToFollowAsyncTask(WhoToFollowActivity.this, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else { mainLoader.setVisibility(View.VISIBLE);
}else {
String lastList = sharedpreferences.getString(Helper.LAST_LIST_NAME + item, null); String lastList = sharedpreferences.getString(Helper.LAST_LIST_NAME + item, null);
List<String> list = Helper.restoreArrayFromString(lastList); List<String> list = Helper.restoreArrayFromString(lastList);
displayResults(list); displayResults(list);
} }
mainLoader.setVisibility(View.VISIBLE);
setTitle(item); setTitle(item);
} }

View File

@ -20,6 +20,7 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -58,17 +59,18 @@ public class WhoToFollowFragment extends Fragment implements OnRetrieveWhoToFoll
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String lastDateListRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_REFRESH, null); String lastDateListRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_REFRESH, null);
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(new Date( )); cal.setTime(new Date());
cal.add(Calendar.MINUTE, -15); cal.add(Calendar.MINUTE, -15);
Date dateAllowed = cal.getTime(); Date dateAllowed = cal.getTime();
if( lastDateListRefresh == null || Helper.stringToDate(context, lastDateListRefresh).after(dateAllowed)) if (lastDateListRefresh == null || Helper.stringToDate(context, lastDateListRefresh).before(dateAllowed)){
mainLoader.setVisibility(View.VISIBLE);
new WhoToFollowAsyncTask(context, null, WhoToFollowFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new WhoToFollowAsyncTask(context, null, WhoToFollowFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else { }else {
String lastList = sharedpreferences.getString(Helper.LAST_LIST, null); String lastList = sharedpreferences.getString(Helper.LAST_LIST, null);
List<String> list = Helper.restoreArrayFromString(lastList); List<String> list = Helper.restoreArrayFromString(lastList);
displayResults(list); displayResults(list);
} }
mainLoader.setVisibility(View.VISIBLE);
return rootView; return rootView;
} }

View File

@ -17,15 +17,15 @@
--> -->
<android.support.v4.widget.DrawerLayout <android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
> >
<android.support.design.widget.CoordinatorLayout <android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="fr.gouv.etalab.mastodon.activities.HashTagActivity"> tools:context="fr.gouv.etalab.mastodon.activities.HashTagActivity">
@ -61,6 +61,7 @@ android:fitsSystemWindows="true"
android:divider="@null" android:divider="@null"
> >
</ListView> </ListView>
<RelativeLayout <RelativeLayout
android:id="@+id/no_action" android:id="@+id/no_action"
android:visibility="gone" android:visibility="gone"
@ -73,7 +74,7 @@ android:fitsSystemWindows="true"
android:layout_gravity="center" android:layout_gravity="center"
android:textStyle="italic|bold" android:textStyle="italic|bold"
android:typeface="serif" android:typeface="serif"
android:text="@string/action_lists_empty_content" android:text="@string/action_who_to_follow_empty_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</RelativeLayout> </RelativeLayout>
@ -91,5 +92,14 @@ android:fitsSystemWindows="true"
android:indeterminate="true" /> android:indeterminate="true" />
</RelativeLayout> </RelativeLayout>
</RelativeLayout> </RelativeLayout>
</android.support.design.widget.CoordinatorLayout> <Button
android:id="@+id/follow_accounts"
android:layout_gravity="bottom|end"
android:gravity="center"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:text="@string/follow_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

View File

@ -586,6 +586,8 @@
<string name="action_update_filter">Update filter</string> <string name="action_update_filter">Update filter</string>
<string name="action_filter_create">Create filter</string> <string name="action_filter_create">Create filter</string>
<string name="how_to_follow">Who to follow</string> <string name="how_to_follow">Who to follow</string>
<string name="action_who_to_follow_empty_content">There is no accounts listed for the moment!</string>
<string name="follow_account">Follow</string>
<string-array translatable="false" name="proxy_type_choice"> <string-array translatable="false" name="proxy_type_choice">