Update fragment when item list removed
This commit is contained in:
parent
4556aa1e8c
commit
7687c00aac
7 changed files with 84 additions and 7 deletions
15
res/layout/empty_fragment.xml
Normal file
15
res/layout/empty_fragment.xml
Normal 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>
|
|
@ -139,6 +139,9 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
editList.setVisibility(View.GONE);
|
editList.setVisibility(View.GONE);
|
||||||
topbar.setVisibility(View.VISIBLE);
|
topbar.setVisibility(View.VISIBLE);
|
||||||
refresh();
|
refresh();
|
||||||
|
if(getResources().getBoolean(R.bool.isTablet)){
|
||||||
|
displayFirstChat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNbItemsChecked(){
|
public int getNbItemsChecked(){
|
||||||
|
@ -188,6 +191,8 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
public void displayFirstChat(){
|
public void displayFirstChat(){
|
||||||
if(mConversations.size() > 0) {
|
if(mConversations.size() > 0) {
|
||||||
LinphoneActivity.instance().displayChat(mConversations.get(0));
|
LinphoneActivity.instance().displayChat(mConversations.get(0));
|
||||||
|
} else {
|
||||||
|
LinphoneActivity.instance().displayEmptyFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,11 +320,16 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
||||||
editList.setVisibility(View.GONE);
|
editList.setVisibility(View.GONE);
|
||||||
topbar.setVisibility(View.VISIBLE);
|
topbar.setVisibility(View.VISIBLE);
|
||||||
invalidate();
|
invalidate();
|
||||||
|
if(getResources().getBoolean(R.bool.isTablet)){
|
||||||
|
displayFirstContact();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayFirstContact(){
|
public void displayFirstContact(){
|
||||||
if(contactsList.getAdapter().getCount() > 0) {
|
if(contactsList.getAdapter().getCount() > 0) {
|
||||||
LinphoneActivity.instance().displayContact((Contact) contactsList.getAdapter().getItem(0), false);
|
LinphoneActivity.instance().displayContact((Contact) contactsList.getAdapter().getItem(0), false);
|
||||||
|
} else {
|
||||||
|
LinphoneActivity.instance().displayEmptyFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
src/org/linphone/EmptyFragment.java
Normal file
40
src/org/linphone/EmptyFragment.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
public enum FragmentsAvailable {
|
public enum FragmentsAvailable {
|
||||||
UNKNOW,
|
UNKNOW,
|
||||||
DIALER,
|
DIALER,
|
||||||
|
EMPTY,
|
||||||
HISTORY_LIST,
|
HISTORY_LIST,
|
||||||
HISTORY_DETAIL,
|
HISTORY_DETAIL,
|
||||||
CONTACTS_LIST,
|
CONTACTS_LIST,
|
||||||
|
|
|
@ -37,9 +37,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
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.AbsListView;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
@ -50,7 +47,6 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,6 +127,8 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
||||||
} else {
|
} else {
|
||||||
LinphoneActivity.instance().displayHistoryDetail(mLogs.get(0).getTo().toString(), mLogs.get(0));
|
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.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||||
}
|
}
|
||||||
|
if(getResources().getBoolean(R.bool.isTablet)){
|
||||||
|
displayFirstLog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CallHistoryAdapter extends BaseAdapter {
|
class CallHistoryAdapter extends BaseAdapter {
|
||||||
|
|
|
@ -461,13 +461,19 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
||||||
}
|
}
|
||||||
transaction.replace(R.id.fragmentContainer2, newFragment);
|
transaction.replace(R.id.fragmentContainer2, newFragment);
|
||||||
} else {
|
} else {
|
||||||
|
if(newFragmentType == FragmentsAvailable.EMPTY) {
|
||||||
|
ll.setVisibility(View.VISIBLE);
|
||||||
|
transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
|
||||||
|
}
|
||||||
|
|
||||||
if (newFragmentType == FragmentsAvailable.DIALER
|
if (newFragmentType == FragmentsAvailable.DIALER
|
||||||
|| newFragmentType == FragmentsAvailable.ABOUT
|
|| newFragmentType == FragmentsAvailable.ABOUT
|
||||||
|| newFragmentType == FragmentsAvailable.SETTINGS
|
|| newFragmentType == FragmentsAvailable.SETTINGS
|
||||||
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
|
|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
|
||||||
ll.setVisibility(View.GONE);
|
ll.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ll.setVisibility(View.INVISIBLE);
|
ll.setVisibility(View.VISIBLE);
|
||||||
|
transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
|
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")
|
@SuppressLint("SimpleDateFormat")
|
||||||
private String secondsToDisplayableString(int secs) {
|
private String secondsToDisplayableString(int secs) {
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
|
Loading…
Reference in a new issue