Update fragment when item list removed

This commit is contained in:
Margaux Clerc 2016-02-18 10:56:13 +01:00
parent 4556aa1e8c
commit 7687c00aac
7 changed files with 84 additions and 7 deletions

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorH">
<LinearLayout
android:orientation="horizontal"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"/>
</RelativeLayout>

View file

@ -139,6 +139,9 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
editList.setVisibility(View.GONE);
topbar.setVisibility(View.VISIBLE);
refresh();
if(getResources().getBoolean(R.bool.isTablet)){
displayFirstChat();
}
}
public int getNbItemsChecked(){
@ -188,6 +191,8 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
public void displayFirstChat(){
if(mConversations.size() > 0) {
LinphoneActivity.instance().displayChat(mConversations.get(0));
} else {
LinphoneActivity.instance().displayEmptyFragment();
}
}

View file

@ -320,11 +320,16 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
editList.setVisibility(View.GONE);
topbar.setVisibility(View.VISIBLE);
invalidate();
if(getResources().getBoolean(R.bool.isTablet)){
displayFirstContact();
}
}
public void displayFirstContact(){
if(contactsList.getAdapter().getCount() > 0) {
LinphoneActivity.instance().displayContact((Contact) contactsList.getAdapter().getItem(0), false);
} else {
LinphoneActivity.instance().displayEmptyFragment();
}
}

View file

@ -0,0 +1,40 @@
package org.linphone;
/*
AboutFragment.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* @author Sylvain Berfini
*/
public class EmptyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.empty_fragment, container, false);
return view;
}
}

View file

@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
public enum FragmentsAvailable {
UNKNOW,
DIALER,
EMPTY,
HISTORY_LIST,
HISTORY_DETAIL,
CONTACTS_LIST,

View file

@ -37,9 +37,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@ -50,7 +47,6 @@ import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
/**
@ -131,6 +127,8 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
} else {
LinphoneActivity.instance().displayHistoryDetail(mLogs.get(0).getTo().toString(), mLogs.get(0));
}
} else {
LinphoneActivity.instance().displayEmptyFragment();
}
}
@ -335,6 +333,9 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
}
if(getResources().getBoolean(R.bool.isTablet)){
displayFirstLog();
}
}
class CallHistoryAdapter extends BaseAdapter {

View file

@ -461,13 +461,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
transaction.replace(R.id.fragmentContainer2, newFragment);
} else {
if(newFragmentType == FragmentsAvailable.EMPTY) {
ll.setVisibility(View.VISIBLE);
transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
}
if (newFragmentType == FragmentsAvailable.DIALER
|| newFragmentType == FragmentsAvailable.ABOUT
|| newFragmentType == FragmentsAvailable.SETTINGS
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
ll.setVisibility(View.GONE);
} else {
ll.setVisibility(View.INVISIBLE);
ll.setVisibility(View.VISIBLE);
transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
}
if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
@ -544,6 +550,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
}
public void displayEmptyFragment(){
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST,new Bundle());
}
@SuppressLint("SimpleDateFormat")
private String secondsToDisplayableString(int secs) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");