Remove ViewPager from task edit

pull/384/head
Alex Baker 9 years ago
parent a60ed231e4
commit a88e2df174

@ -12,21 +12,17 @@ import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ScrollView;
import android.widget.LinearLayout;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.astrid.actfm.ActFmCameraModule;
@ -72,7 +68,7 @@ import static android.app.Activity.RESULT_OK;
* @author timsu
*
*/
public final class TaskEditFragment extends InjectingFragment implements EditNoteActivity.UpdatesChangedListener, Toolbar.OnMenuItemClickListener {
public final class TaskEditFragment extends InjectingFragment implements Toolbar.OnMenuItemClickListener {
public interface TaskEditFragmentCallbackHandler {
void taskEditFinished();
@ -125,9 +121,8 @@ public final class TaskEditFragment extends InjectingFragment implements EditNot
private EditNoteActivity editNotes;
@Bind(R.id.pager) ViewPager mPager;
@Bind(R.id.updatesFooter) View commentsBar;
@Bind(R.id.edit_scroll) ScrollView scrollView;
@Bind(R.id.edit_body) LinearLayout body;
@Bind(R.id.commentField) EditText commentField;
@Bind(R.id.toolbar) Toolbar toolbar;
@ -238,8 +233,7 @@ public final class TaskEditFragment extends InjectingFragment implements EditNot
taskService, this, getView(), model.getId());
editNotes.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
editNotes.addListener(this);
body.addView(editNotes);
}
}
@ -255,31 +249,7 @@ public final class TaskEditFragment extends InjectingFragment implements EditNot
if (timerControl != null) {
timerControl.setEditNotes(editNotes);
}
editNotes.addListener(this);
}
if (!showEditComments) {
return;
}
TaskEditViewPager adapter = new TaskEditViewPager();
adapter.parent = this;
mPager.setAdapter(adapter);
setCurrentTab(0);
setPagerHeightForPosition();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
updatesChanged();
}
}, 500L);
}
private void setCurrentTab(int position) {
mPager.setCurrentItem(position);
}
public Task stopTimer() {
@ -476,61 +446,6 @@ public final class TaskEditFragment extends InjectingFragment implements EditNot
* ======================================================================
*/
public View getPageView() {
return editNotes;
}
private void setPagerHeightForPosition() {
int height = 0;
View view = editNotes;
if (mPager == null) {
return;
}
int desiredWidth = MeasureSpec.makeMeasureSpec(view.getWidth(),
MeasureSpec.AT_MOST);
view.measure(desiredWidth, MeasureSpec.UNSPECIFIED);
height = Math.max(view.getMeasuredHeight(), height);
LayoutParams pagerParams = mPager.getLayoutParams();
if (height > 0 && height != pagerParams.height) {
pagerParams.height = height;
mPager.setLayoutParams(pagerParams);
}
}
// EditNoteActivity Listener when there are new updates/comments
@Override
public void updatesChanged() {
if (mPager != null) {
setPagerHeightForPosition();
}
}
// EditNoteActivity Lisener when there are new updates/comments
@Override
public void commentAdded() {
setPagerHeightForPosition();
scrollToView(editNotes);
}
// Scroll to view in edit task
public void scrollToView(View v) {
View child = v;
int top = v.getTop();
while (!child.equals(scrollView) ) {
top += child.getTop();
ViewParent parentView = child.getParent();
if (parentView != null && View.class.isInstance(parentView)) {
child = (View) parentView;
}
else {
break;
}
}
scrollView.smoothScrollTo(0, top);
}
private void hideKeyboard() {
getEditTitleControlSet().hideKeyboard();
AndroidUtilities.hideSoftInputForViews(getActivity(), commentField);

@ -1,45 +0,0 @@
/**
* Copyright (c) 2012 Todoroo Inc
*
* See the file "LICENSE" for the full license governing this code.
*/
package com.todoroo.astrid.activity;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
public class TaskEditViewPager extends PagerAdapter {
public TaskEditFragment parent;
@Override
public int getCount() {
return 1;
}
@Override
public Object instantiateItem(View pager, int position) {
View pageView = parent.getPageView();
((ViewPager) pager).addView(pageView, 0);
return pageView;
}
@Override
public void destroyItem(View pager, int position, Object view) {
((ViewPager) pager).removeView((View) view);
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view.equals(object);
}
@Override
public Parcelable saveState() {
return null;
}
}

@ -5,7 +5,6 @@
*/
package com.todoroo.astrid.notes;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.database.sqlite.SQLiteException;
@ -52,8 +51,6 @@ import org.tasks.R;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import timber.log.Timber;
@ -82,13 +79,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
private final int cameraButton;
private final List<UpdatesChangedListener> listeners = new LinkedList<>();
public interface UpdatesChangedListener {
void updatesChanged();
void commentAdded();
}
public EditNoteActivity(
ActFmCameraModule actFmCameraModule,
MetadataDao metadataDao,
@ -282,14 +272,10 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
});
this.addView(loadMore);
}
for (UpdatesChangedListener l : listeners) {
l.updatesChanged();
}
}
public View getUpdateNotes(NoteOrUpdate note, ViewGroup parent) {
View convertView = ((Activity)activity).getLayoutInflater().inflate(
View convertView = activity.getLayoutInflater().inflate(
R.layout.comment_adapter_row, parent, false);
bindView(convertView, note);
return convertView;
@ -375,9 +361,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
}
setUpListAdapter();
for (UpdatesChangedListener l : listeners) {
l.commentAdded();
}
}
private static class NoteOrUpdate {
@ -426,10 +409,6 @@ public class EditNoteActivity extends LinearLayout implements TimerActionListene
}
}
public void addListener(UpdatesChangedListener listener) {
listeners.add(listener);
}
@Override
public void timerStarted(Task t) {
addComment(String.format("%s %s", //$NON-NLS-1$

@ -15,13 +15,13 @@
<include layout="@layout/toolbar_separator" />
<ScrollView
android:id="@+id/edit_scroll"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="100"
android:overScrollMode="never">
<LinearLayout
android:id="@+id/edit_body"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
@ -82,14 +82,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="3dip"
android:layout_marginBottom="0dip"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>

Loading…
Cancel
Save