diff options
author | Eric Erfanian <erfanian@google.com> | 2017-06-05 13:35:02 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-06-07 20:44:54 +0000 |
commit | 91ce7d2a476bd04fe525049a37a2f8b2824e9724 (patch) | |
tree | b9bbc285430ffb5363a70eb27e382c38f5a85b7a /java/com/android/dialer/calllog/ui/NewCallLogFragment.java | |
parent | 75233ff03785f24789b32039ac2c208805b7e506 (diff) |
Update AOSP Dialer source from internal google3 repository at
cl/158012278.
Test: make, treehugger
This CL updates the AOSP Dialer source with all the changes that have
gone into the private google3 repository. This includes all the
changes from cl/152373142 (4/06/2017) to cl/158012278 (6/05/2017).
This goal of these drops is to keep the AOSP source in sync with the
internal google3 repository. Currently these sync are done by hand
with very minor modifications to the internal source code.
See the Android.mk file for list of modifications.
Our current goal is to do frequent drops (daily if possible) and
eventually switched to an automated process.
Change-Id: I4d3f14b5140e2e51bead9497bc118a205b3ebe76
Diffstat (limited to 'java/com/android/dialer/calllog/ui/NewCallLogFragment.java')
-rw-r--r-- | java/com/android/dialer/calllog/ui/NewCallLogFragment.java | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java index b8f2b1326..89ed52fd7 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java @@ -17,30 +17,30 @@ package com.android.dialer.calllog.ui; import android.app.Fragment; import android.app.LoaderManager.LoaderCallbacks; -import android.content.Context; +import android.content.CursorLoader; import android.content.Loader; import android.database.Cursor; import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.CursorAdapter; -import android.widget.ListView; -import android.widget.SimpleCursorAdapter; -import android.widget.TextView; import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.CallLogFramework; import com.android.dialer.calllog.CallLogFramework.CallLogUi; -import com.android.dialer.calllog.database.AnnotatedCallLog.Columns; +import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.CoalescedAnnotatedCallLog; import com.android.dialer.common.LogUtil; -import java.text.SimpleDateFormat; -import java.util.Locale; +import com.android.dialer.common.concurrent.DialerExecutor; +import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.common.concurrent.DialerExecutorFactory; /** The "new" call log fragment implementation, which is built on top of the annotated call log. */ public final class NewCallLogFragment extends Fragment implements CallLogUi, LoaderCallbacks<Cursor> { - private CursorAdapter cursorAdapter; + private DialerExecutor<Boolean> refreshAnnotatedCallLogTask; + private RecyclerView recyclerView; public NewCallLogFragment() { LogUtil.enterBlock("NewCallLogFragment.NewCallLogFragment"); @@ -52,8 +52,27 @@ public final class NewCallLogFragment extends Fragment LogUtil.enterBlock("NewCallLogFragment.onCreate"); - CallLogFramework callLogFramework = CallLogComponent.get(getContext()).callLogFramework(); + CallLogComponent component = CallLogComponent.get(getContext()); + CallLogFramework callLogFramework = component.callLogFramework(); callLogFramework.attachUi(this); + + DialerExecutorFactory dialerExecutorFactory = + DialerExecutorComponent.get(getContext()).dialerExecutorFactory(); + + refreshAnnotatedCallLogTask = + dialerExecutorFactory + .createUiTaskBuilder( + getFragmentManager(), + "NewCallLogFragment.refreshAnnotatedCallLog", + component.getRefreshAnnotatedCallLogWorker()) + .build(); + } + + @Override + public void onStart() { + super.onStart(); + + LogUtil.enterBlock("NewCallLogFragment.onStart"); } @Override @@ -64,6 +83,9 @@ public final class NewCallLogFragment extends Fragment CallLogFramework callLogFramework = CallLogComponent.get(getContext()).callLogFramework(); callLogFramework.attachUi(this); + + // TODO: Consider doing this when fragment becomes visible. + checkAnnotatedCallLogDirtyAndRefreshIfNecessary(); } @Override @@ -82,57 +104,44 @@ public final class NewCallLogFragment extends Fragment LogUtil.enterBlock("NewCallLogFragment.onCreateView"); View view = inflater.inflate(R.layout.new_call_log_fragment, container, false); - ListView listView = (ListView) view.findViewById(R.id.list); + recyclerView = view.findViewById(R.id.new_call_log_recycler_view); - this.cursorAdapter = - new MyCursorAdapter( - getContext(), - R.layout.new_call_log_entry, - null /* cursor */, - new String[] {Columns.TIMESTAMP, Columns.CONTACT_NAME}, - new int[] {R.id.timestamp, R.id.contact_name}, - 0); - listView.setAdapter(cursorAdapter); - - getLoaderManager().initLoader(0, null, this); + getLoaderManager().restartLoader(0, null, this); return view; } + private void checkAnnotatedCallLogDirtyAndRefreshIfNecessary() { + LogUtil.enterBlock("NewCallLogFragment.checkAnnotatedCallLogDirtyAndRefreshIfNecessary"); + refreshAnnotatedCallLogTask.executeSerial(false /* skipDirtyCheck */); + } + @Override public void invalidateUi() { LogUtil.enterBlock("NewCallLogFragment.invalidateUi"); - // TODO: Implementation. + refreshAnnotatedCallLogTask.executeSerial(true /* skipDirtyCheck */); } @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { - // TODO: This is sort of weird, do we need to implement a content provider? - return new AnnotatedCallLogCursorLoader(getContext()); + LogUtil.enterBlock("NewCallLogFragment.onCreateLoader"); + // CoalescedAnnotatedCallLog requires that all params be null. + return new CursorLoader( + getContext(), CoalescedAnnotatedCallLog.CONTENT_URI, null, null, null, null); } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor newCursor) { - cursorAdapter.swapCursor(newCursor); + LogUtil.enterBlock("NewCallLogFragment.onLoadFinished"); + + // TODO: Handle empty cursor by showing empty view. + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + recyclerView.setAdapter(new NewCallLogAdapter(newCursor)); } @Override public void onLoaderReset(Loader<Cursor> loader) { - cursorAdapter.swapCursor(null); - } - - private static class MyCursorAdapter extends SimpleCursorAdapter { - - MyCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) { - super(context, layout, c, from, to, flags); - } - - @Override - public void setViewText(TextView view, String text) { - if (view.getId() == R.id.timestamp) { - text = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(Long.valueOf(text)); - } - view.setText(text); - } + LogUtil.enterBlock("NewCallLogFragment.onLoaderReset"); + recyclerView.setAdapter(null); } } |