mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Added no posts notice.
This commit is contained in:
parent
9058d059d8
commit
d2fbd4213e
@ -3,6 +3,7 @@ package org.communiquons.android.comunic.client.ui.fragments;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.UiThread;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
@ -11,6 +12,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
@ -74,6 +76,11 @@ public class UserPostsFragment extends Fragment
|
|||||||
*/
|
*/
|
||||||
private Button mCreatePostButton;
|
private Button mCreatePostButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No post on user page notice
|
||||||
|
*/
|
||||||
|
private TextView mNoPostNotice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create post layout
|
* Create post layout
|
||||||
*/
|
*/
|
||||||
@ -110,6 +117,9 @@ public class UserPostsFragment extends Fragment
|
|||||||
//Get the views
|
//Get the views
|
||||||
mCreatePostButton = view.findViewById(R.id.create_post_btn);
|
mCreatePostButton = view.findViewById(R.id.create_post_btn);
|
||||||
mCreatePostLayout = view.findViewById(R.id.create_posts_form_target);
|
mCreatePostLayout = view.findViewById(R.id.create_posts_form_target);
|
||||||
|
mNoPostNotice = view.findViewById(R.id.no_post_notice);
|
||||||
|
|
||||||
|
setNoPostNoticeVisibility(false);
|
||||||
|
|
||||||
mCreatePostButton.setOnClickListener(new View.OnClickListener() {
|
mCreatePostButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -120,6 +130,7 @@ public class UserPostsFragment extends Fragment
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Initialize helpers
|
//Initialize helpers
|
||||||
|
assert getActivity() != null;
|
||||||
mPostsHelper = new PostsHelper(getActivity());
|
mPostsHelper = new PostsHelper(getActivity());
|
||||||
mUserHelper = new GetUsersHelper(getActivity());
|
mUserHelper = new GetUsersHelper(getActivity());
|
||||||
|
|
||||||
@ -149,8 +160,13 @@ public class UserPostsFragment extends Fragment
|
|||||||
if(mPostsList != null)
|
if(mPostsList != null)
|
||||||
mUsersInfo = mUserHelper.getMultiple(mPostsList.getUsersId());
|
mUsersInfo = mUserHelper.getMultiple(mPostsList.getUsersId());
|
||||||
|
|
||||||
if(getActivity() != null)
|
if(getActivity() != null && getView() != null)
|
||||||
display_posts();
|
getView().post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
display_posts();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mLoadThread.start();
|
mLoadThread.start();
|
||||||
@ -160,6 +176,7 @@ public class UserPostsFragment extends Fragment
|
|||||||
/**
|
/**
|
||||||
* Display the list of posts
|
* Display the list of posts
|
||||||
*/
|
*/
|
||||||
|
@UiThread
|
||||||
private void display_posts(){
|
private void display_posts(){
|
||||||
|
|
||||||
//Check for errors
|
//Check for errors
|
||||||
@ -181,6 +198,8 @@ public class UserPostsFragment extends Fragment
|
|||||||
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
|
||||||
transaction.replace(R.id.posts_list_target, mPostsListFragment);
|
transaction.replace(R.id.posts_list_target, mPostsListFragment);
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
|
setNoPostNoticeVisibility(mPostsList.size() < 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,6 +240,10 @@ public class UserPostsFragment extends Fragment
|
|||||||
mCreatePostButton.setActivated(visible);
|
mCreatePostButton.setActivated(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setNoPostNoticeVisibility(boolean visible){
|
||||||
|
mNoPostNotice.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostCreated(Post post) {
|
public void onPostCreated(Post post) {
|
||||||
mPostsList = new PostsList();
|
mPostsList = new PostsList();
|
||||||
|
@ -18,6 +18,15 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout="@layout/post_create_form" />
|
android:layout="@layout/post_create_form" />
|
||||||
|
|
||||||
|
<!-- No post notice -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/no_post_notice"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/notice_no_post_user_page"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="10dp"/>
|
||||||
|
|
||||||
<!-- Posts target -->
|
<!-- Posts target -->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/posts_list_target"
|
android:id="@+id/posts_list_target"
|
||||||
|
Loading…
Reference in New Issue
Block a user