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.add(Calendar.MINUTE, -5);
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);
else {
mainLoader.setVisibility(View.VISIBLE);
}else {
String lastList = sharedpreferences.getString(Helper.LAST_LIST_NAME + item, null);
List<String> list = Helper.restoreArrayFromString(lastList);
displayResults(list);
}
mainLoader.setVisibility(View.VISIBLE);
setTitle(item);
}

View File

@ -20,6 +20,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
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);
String lastDateListRefresh = sharedpreferences.getString(Helper.LAST_DATE_LIST_REFRESH, null);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date( ));
cal.setTime(new Date());
cal.add(Calendar.MINUTE, -15);
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);
else {
}else {
String lastList = sharedpreferences.getString(Helper.LAST_LIST, null);
List<String> list = Helper.restoreArrayFromString(lastList);
displayResults(list);
}
mainLoader.setVisibility(View.VISIBLE);
return rootView;
}

View File

@ -17,79 +17,89 @@
-->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="fr.gouv.etalab.mastodon.activities.HashTagActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
android:fitsSystemWindows="true"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/AppThemeDark_NoActionBar"
app:popupTheme="?attr/popupOverlay"/>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Listview who to follow -->
<ListView
android:id="@+id/lv_list"
android:layout_height="match_parent"
tools:context="fr.gouv.etalab.mastodon.activities.HashTagActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"
android:theme="@style/AppTheme.AppBarOverlay"
>
</ListView>
<RelativeLayout
android:id="@+id/no_action"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:padding="10dp"
android:gravity="center"
android:textSize="25sp"
android:layout_gravity="center"
android:textStyle="italic|bold"
android:typeface="serif"
android:text="@string/action_lists_empty_content"
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<!-- Main Loader -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/AppThemeDark_NoActionBar"
app:popupTheme="?attr/popupOverlay"/>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:paddingLeft="@dimen/fab_margin"
android:paddingRight="@dimen/fab_margin"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Listview who to follow -->
<ListView
android:id="@+id/lv_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:divider="@null"
>
</ListView>
<RelativeLayout
android:id="@+id/no_action"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:padding="10dp"
android:gravity="center"
android:textSize="25sp"
android:layout_gravity="center"
android:textStyle="italic|bold"
android:typeface="serif"
android:text="@string/action_who_to_follow_empty_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<!-- Main Loader -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loader"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
</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>

View File

@ -586,6 +586,8 @@
<string name="action_update_filter">Update filter</string>
<string name="action_filter_create">Create filter</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">