カラムを並び替えるとカラム設定がリセットされる?問題の対策

This commit is contained in:
tateisu 2017-05-15 08:32:16 +09:00
parent ea8a38c865
commit 9af2aad20b
8 changed files with 300 additions and 275 deletions

View File

@ -10,6 +10,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsIntent;
@ -912,9 +913,10 @@ public class ActMain extends AppCompatActivity
// プロフURL
if( "https".equals( uri.getScheme() ) ){
if( uri.getPath().startsWith( "/@" ) ){
// ステータスをアプリ内で開く
Matcher m = reStatusPage.matcher( uri.toString() );
if( m.find() ){
// ステータスをアプリ内で開く
try{
// https://mastodon.juggler.jp/@SubwayTooter/(status_id)
final String host = m.group( 1 );
@ -955,9 +957,10 @@ public class ActMain extends AppCompatActivity
return;
}
// ユーザページをアプリ内で開く
m = reUserPage.matcher( uri.toString() );
if( m.find() ){
// ユーザページをアプリ内で開く
// https://mastodon.juggler.jp/@SubwayTooter
final String host = m.group( 1 );
final String user = Uri.decode( m.group( 2 ) );
@ -1021,7 +1024,11 @@ public class ActMain extends AppCompatActivity
long db_id = Long.parseLong( sv, 10 );
SavedAccount account = SavedAccount.loadAccount( log, db_id );
if( account != null ){
addColumn( getDefaultInsertPosition(), account, Column.TYPE_NOTIFICATIONS );
Column column = addColumn( getDefaultInsertPosition(), account, Column.TYPE_NOTIFICATIONS );
// 通知を読み直す
if( ! column.bInitialLoading ){
column.startLoading();
}
}
}catch( Throwable ex ){
ex.printStackTrace();
@ -1029,6 +1036,8 @@ public class ActMain extends AppCompatActivity
return;
}
// OAuth2 認証コールバック
final ProgressDialog progress = new ProgressDialog( ActMain.this );
final AsyncTask< Void, Void, TootApiResult > task = new AsyncTask< Void, Void, TootApiResult >() {
@ -3036,7 +3045,6 @@ public class ActMain extends AppCompatActivity
updateColumnStrip();
return index;
}
private void removeColumn( Column column ){

View File

@ -915,6 +915,13 @@ class Column implements StreamReader.Callback {
fireShowContent();
try{
ColumnViewHolder holder = getViewHolder();
if( holder != null ) holder.getRefreshLayout().setRefreshing( false );
}catch(Throwable ignored){
}
AsyncTask< Void, Void, TootApiResult > task = this.last_task = new AsyncTask< Void, Void, TootApiResult >() {
TootApiResult parseAccount1( TootApiClient client, String path_base ){

View File

@ -14,7 +14,7 @@ class ColumnPagerAdapter extends PagerAdapter {
private final ActMain activity;
private final LayoutInflater inflater;
final ArrayList< Column > column_list;
private final ArrayList< Column > column_list;
private final SparseArray< ColumnViewHolder > holder_list = new SparseArray<>();
@ -51,11 +51,11 @@ class ColumnPagerAdapter extends PagerAdapter {
container.addView( root, 0 );
Column column = column_list.get( page_idx );
ColumnViewHolder holder = new ColumnViewHolder( activity, column );
ColumnViewHolder holder = new ColumnViewHolder( activity,root );
//
holder_list.put( page_idx, holder );
//
holder.onPageCreate( root, page_idx, column_list.size() );
holder.onPageCreate( column, page_idx, column_list.size() );
return root;
}
@ -68,8 +68,7 @@ class ColumnPagerAdapter extends PagerAdapter {
ColumnViewHolder holder = holder_list.get( page_idx );
holder_list.remove( page_idx );
if( holder != null ){
holder.onPageDestroy( view );
holder.onPageDestroy();
}
}
}

View File

@ -3,6 +3,7 @@ package jp.juggler.subwaytooter;
import android.graphics.Bitmap;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.text.Editable;
import android.text.TextUtils;
@ -16,12 +17,12 @@ import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout;
import com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import jp.juggler.subwaytooter.table.AcctColor;
@ -38,68 +39,54 @@ class ColumnViewHolder
private static final LogCategory log = new LogCategory( "ColumnViewHolder" );
final ActMain activity;
final Column column;
private final AtomicBoolean is_destroyed = new AtomicBoolean( false );
private final ItemListAdapter status_adapter;
ColumnViewHolder( ActMain activity, Column column ){
this.activity = activity;
this.column = column;
this.status_adapter = new ItemListAdapter( activity, column );
}
private boolean isPageDestroyed(){
return is_destroyed.get() || activity.isFinishing();
}
void onPageDestroy( @SuppressWarnings("UnusedParameters") View root ){
log.d( "onPageDestroy:%s", column.getColumnName( true ) );
is_destroyed.set( true );
saveScrollPosition();
@Nullable Column column;
@Nullable private HeaderViewHolder vh_header;
@Nullable private ItemListAdapter status_adapter;
private final TextView tvLoading;
private final MyListView listView;
private final SwipyRefreshLayout swipyRefreshLayout;
private final View llColumnHeader;
private final TextView tvColumnIndex;
private final TextView tvColumnContext;
private final ImageView ivColumnIcon;
private final TextView tvColumnName;
private final View llColumnSetting;
listView.setAdapter( null );
column.setColumnViewHolder( null );
closeBitmaps();
activity.closeListItemPopup();
}
private final View btnSearch;
private final EditText etSearch;
private final CheckBox cbResolve;
private final EditText etRegexFilter;
private final TextView tvRegexFilterError;
private TextView tvLoading;
private MyListView listView;
private TextView tvColumnContext;
private TextView tvColumnName;
private HeaderViewHolder vh_header;
private SwipyRefreshLayout swipyRefreshLayout;
private View btnSearch;
private EditText etSearch;
private CheckBox cbResolve;
private View llColumnSetting;
private EditText etRegexFilter;
private TextView tvRegexFilterError;
private ImageView ivColumnIcon;
private final ImageButton btnColumnSetting;
private final ImageButton btnColumnReload;
private final ImageButton btnColumnClose;
private View llColumnHeader;
private TextView tvColumnIndex;
private ImageButton btnColumnSetting;
private ImageButton btnColumnReload;
private ImageButton btnColumnClose;
private final View flColumnBackground;
private final ImageView ivColumnBackgroundImage;
private final View llSearch;
private final CheckBox cbDontCloseColumn;
private final CheckBox cbWithAttachment;
private final CheckBox cbDontShowBoost;
private final CheckBox cbDontShowReply;
private final CheckBox cbDontStreaming;
private final CheckBox cbDontAutoRefresh;
private final CheckBox cbHideMediaDefault;
private final View llRegexFilter;
private final Button btnDeleteNotification;
private View flColumnBackground;
private ImageView ivColumnBackgroundImage;
void onPageCreate( View root, int page_idx, int page_count ){
log.d( "onPageCreate:%s", column.getColumnName( true ) );
ColumnViewHolder( ActMain arg_activity, View root ){
this.activity = arg_activity;
flColumnBackground = root.findViewById( R.id.flColumnBackground );
ivColumnBackgroundImage = (ImageView) root.findViewById( R.id.ivColumnBackgroundImage );
llColumnHeader = root.findViewById( R.id.llColumnHeader );
tvColumnIndex = (TextView) root.findViewById( R.id.tvColumnIndex );
tvColumnIndex.setText( activity.getString( R.string.column_index, page_idx + 1, page_count ) );
tvColumnName = (TextView) root.findViewById( R.id.tvColumnName );
tvColumnContext = (TextView) root.findViewById( R.id.tvColumnContext );
@ -109,208 +96,224 @@ class ColumnViewHolder
btnColumnReload = (ImageButton) root.findViewById( R.id.btnColumnReload );
btnColumnClose = (ImageButton) root.findViewById( R.id.btnColumnClose );
tvLoading = (TextView) root.findViewById( R.id.tvLoading );
listView = (MyListView) root.findViewById( R.id.listView );
btnSearch = root.findViewById( R.id.btnSearch );
etSearch = (EditText) root.findViewById( R.id.etSearch );
cbResolve = (CheckBox) root.findViewById( R.id.cbResolve );
llSearch = root.findViewById( R.id.llSearch );
llColumnSetting = root.findViewById( R.id.llColumnSetting );
cbDontCloseColumn = (CheckBox) root.findViewById( R.id.cbDontCloseColumn );
cbWithAttachment = (CheckBox) root.findViewById( R.id.cbWithAttachment );
cbDontShowBoost = (CheckBox) root.findViewById( R.id.cbDontShowBoost );
cbDontShowReply = (CheckBox) root.findViewById( R.id.cbDontShowReply );
cbDontStreaming = (CheckBox) root.findViewById( R.id.cbDontStreaming );
cbDontAutoRefresh = (CheckBox) root.findViewById( R.id.cbDontAutoRefresh );
cbHideMediaDefault = (CheckBox) root.findViewById( R.id.cbHideMediaDefault );
etRegexFilter = (EditText) root.findViewById( R.id.etRegexFilter );
llRegexFilter = root.findViewById( R.id.llRegexFilter );
tvRegexFilterError = (TextView) root.findViewById( R.id.tvRegexFilterError );
listView.setOnItemClickListener( status_adapter );
btnDeleteNotification = (Button) root.findViewById( R.id.btnDeleteNotification );
llColumnHeader.setOnClickListener( this );
btnColumnSetting.setOnClickListener( this );
btnColumnReload.setOnClickListener( this );
btnColumnClose.setOnClickListener( this );
llColumnHeader.setOnClickListener( this );
btnDeleteNotification.setOnClickListener( this );
root.findViewById( R.id.btnColor ).setOnClickListener( this );
tvLoading = (TextView) root.findViewById( R.id.tvLoading );
listView = (MyListView) root.findViewById( R.id.listView );
listView.setAdapter( null );
if( column.column_type == Column.TYPE_PROFILE ){
vh_header = new HeaderViewHolder( activity, column, listView );
status_adapter.header = vh_header;
}else{
status_adapter.header = null;
}
this.swipyRefreshLayout = (SwipyRefreshLayout) root.findViewById( R.id.swipyRefreshLayout );
swipyRefreshLayout.setOnRefreshListener( this );
swipyRefreshLayout.setDistanceToTriggerSync( (int) ( 0.5f + 20f * activity.density ) );
View llSearch = root.findViewById( R.id.llSearch );
btnSearch = root.findViewById( R.id.btnSearch );
etSearch = (EditText) root.findViewById( R.id.etSearch );
cbResolve = (CheckBox) root.findViewById( R.id.cbResolve );
cbDontCloseColumn.setOnCheckedChangeListener( this );
cbWithAttachment.setOnCheckedChangeListener( this );
cbDontShowBoost.setOnCheckedChangeListener( this );
cbDontShowReply.setOnCheckedChangeListener( this );
cbDontStreaming.setOnCheckedChangeListener( this );
cbDontAutoRefresh.setOnCheckedChangeListener( this );
cbHideMediaDefault.setOnCheckedChangeListener( this );
listView.setFastScrollEnabled( ! Pref.pref( activity ).getBoolean( Pref.KEY_DISABLE_FAST_SCROLLER, true ) );
boolean bAllowFilter;
switch( column.column_type ){
default:
bAllowFilter = true;
break;
case Column.TYPE_SEARCH:
case Column.TYPE_CONVERSATION:
case Column.TYPE_REPORTS:
case Column.TYPE_BLOCKS:
case Column.TYPE_MUTES:
case Column.TYPE_FOLLOW_REQUESTS:
case Column.TYPE_NOTIFICATIONS:
bAllowFilter = false;
break;
}
boolean bAllowFilterBoost;
switch( column.column_type ){
default:
bAllowFilterBoost = false;
break;
case Column.TYPE_HOME:
case Column.TYPE_PROFILE:
bAllowFilterBoost = true;
break;
}
llColumnSetting = root.findViewById( R.id.llColumnSetting );
llColumnSetting.setVisibility( View.GONE );
CheckBox cb;
cb = (CheckBox) root.findViewById( R.id.cbDontCloseColumn );
cb.setChecked( column.dont_close );
cb.setOnCheckedChangeListener( this );
cb = (CheckBox) root.findViewById( R.id.cbWithAttachment );
cb.setChecked( column.with_attachment );
cb.setOnCheckedChangeListener( this );
cb.setEnabled( bAllowFilter );
cb.setVisibility( bAllowFilter ? View.VISIBLE : View.GONE );
cb = (CheckBox) root.findViewById( R.id.cbDontShowBoost );
cb.setChecked( column.dont_show_boost );
cb.setOnCheckedChangeListener( this );
cb.setEnabled( bAllowFilter );
cb.setVisibility( bAllowFilterBoost ? View.VISIBLE : View.GONE );
cb = (CheckBox) root.findViewById( R.id.cbDontShowReply );
cb.setChecked( column.dont_show_reply );
cb.setOnCheckedChangeListener( this );
cb.setEnabled( bAllowFilter );
cb.setVisibility( bAllowFilterBoost ? View.VISIBLE : View.GONE );
cb = (CheckBox) root.findViewById( R.id.cbDontStreaming );
if( ! column.canStreaming() ){
cb.setVisibility( View.GONE );
}else{
cb.setVisibility( View.VISIBLE );
cb.setChecked( column.dont_streaming );
cb.setOnCheckedChangeListener( this );
}
cb = (CheckBox) root.findViewById( R.id.cbDontAutoRefresh );
if( ! column.canAutoRefresh() ){
cb.setVisibility( View.GONE );
}else{
cb.setVisibility(View.VISIBLE );
cb.setChecked( column.dont_auto_refresh );
cb.setOnCheckedChangeListener( this );
}
cb = (CheckBox) root.findViewById( R.id.cbHideMediaDefault );
if( ! column.canShowMedia() ){
cb.setVisibility( View.GONE );
}else{
cb.setVisibility(View.VISIBLE );
cb.setChecked( column.hide_media_default );
cb.setOnCheckedChangeListener( this );
}
etRegexFilter = (EditText) root.findViewById( R.id.etRegexFilter );
if( ! bAllowFilter ){
etRegexFilter.setVisibility( View.GONE );
root.findViewById( R.id.llRegexFilter ).setVisibility( View.GONE );
}else{
etRegexFilter.setText( column.regex_text );
// tvRegexFilterErrorの表示を更新
tvRegexFilterError = (TextView) root.findViewById( R.id.tvRegexFilterError );
isRegexValid();
// 入力の追跡
etRegexFilter.addTextChangedListener( new TextWatcher() {
@Override
public void beforeTextChanged( CharSequence s, int start, int count, int after ){
}
@Override
public void onTextChanged( CharSequence s, int start, int before, int count ){
}
@Override public void afterTextChanged( Editable s ){
activity.handler.removeCallbacks( proc_start_filter );
if( isRegexValid() ){
activity.handler.postDelayed( proc_start_filter, 1500L );
}
}
} );
}
Button button = (Button) root.findViewById( R.id.btnDeleteNotification );
if( column.column_type != Column.TYPE_NOTIFICATIONS ){
button.setVisibility( View.GONE );
}else{
button.setVisibility( View.VISIBLE );
button.setOnClickListener( this );
// 入力の追跡
etRegexFilter.addTextChangedListener( new TextWatcher() {
@Override
public void beforeTextChanged( CharSequence s, int start, int count, int after ){
}
}
@Override
public void onTextChanged( CharSequence s, int start, int before, int count ){
}
@Override public void afterTextChanged( Editable s ){
if( loading_busy ) return;
activity.handler.removeCallbacks( proc_start_filter );
if( isRegexValid() ){
activity.handler.postDelayed( proc_start_filter, 1500L );
}
}
} );
if( column.column_type != Column.TYPE_SEARCH ){
llSearch.setVisibility( View.GONE );
}else{
llSearch.setVisibility( View.VISIBLE );
etSearch.setText( column.search_query );
cbResolve.setChecked( column.search_resolve );
btnSearch.setOnClickListener( this );
etSearch.setOnEditorActionListener( new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction( TextView v, int actionId, KeyEvent event ){
btnSearch.setOnClickListener( this );
etSearch.setOnEditorActionListener( new TextView.OnEditorActionListener() {
@Override public boolean onEditorAction( TextView v, int actionId, KeyEvent event ){
if( !loading_busy ){
if( actionId == EditorInfo.IME_ACTION_SEARCH ){
btnSearch.performClick();
return true;
}
return false;
}
} );
}
return false;
}
} );
}
private boolean isPageDestroyed(){
return column ==null || activity.isFinishing();
}
void onPageDestroy(){
// タブレットモードの場合onPageCreateより前に呼ばれる
if( column != null ){
log.d( "onPageDestroy #%s", tvColumnName.getText() );
saveScrollPosition();
listView.setAdapter( null );
column.setColumnViewHolder( null );
column = null;
}
closeBitmaps();
switch( column.column_type ){
case Column.TYPE_CONVERSATION:
case Column.TYPE_SEARCH:
swipyRefreshLayout.setEnabled( false );
break;
default:
swipyRefreshLayout.setEnabled( true );
break;
activity.closeListItemPopup();
}
private static void vg( View v, boolean visible ){
v.setVisibility( visible ? View.VISIBLE : View.GONE );
}
private boolean loading_busy;
void onPageCreate( Column column, int page_idx, int page_count ){
loading_busy = true;
try{
this.column = column;
log.d( "onPageCreate:%s", column.getColumnName( true ) );
tvColumnIndex.setText( activity.getString( R.string.column_index, page_idx + 1, page_count ) );
listView.setAdapter( null );
this.status_adapter = new ItemListAdapter( activity, column );
if( column.column_type == Column.TYPE_PROFILE ){
vh_header = new HeaderViewHolder( activity, column, listView );
status_adapter.header = vh_header;
}else{
status_adapter.header = null;
}
boolean bAllowFilter;
switch( column.column_type ){
default:
bAllowFilter = true;
break;
case Column.TYPE_SEARCH:
case Column.TYPE_CONVERSATION:
case Column.TYPE_REPORTS:
case Column.TYPE_BLOCKS:
case Column.TYPE_MUTES:
case Column.TYPE_FOLLOW_REQUESTS:
case Column.TYPE_NOTIFICATIONS:
bAllowFilter = false;
break;
}
boolean bAllowFilterBoost;
switch( column.column_type ){
default:
bAllowFilterBoost = false;
break;
case Column.TYPE_HOME:
case Column.TYPE_PROFILE:
bAllowFilterBoost = true;
break;
}
llColumnSetting.setVisibility( View.GONE );
cbDontCloseColumn.setChecked( column.dont_close );
cbWithAttachment.setChecked( column.with_attachment );
cbDontShowBoost.setChecked( column.dont_show_boost );
cbDontShowReply.setChecked( column.dont_show_reply );
cbDontStreaming.setChecked( column.dont_streaming );
cbDontAutoRefresh.setChecked( column.dont_auto_refresh );
cbHideMediaDefault.setChecked( column.hide_media_default );
etRegexFilter.setText( column.regex_text );
etSearch.setText( column.search_query );
cbResolve.setChecked( column.search_resolve );
vg( cbWithAttachment, bAllowFilter );
vg( cbDontShowBoost, bAllowFilterBoost );
vg( cbDontShowReply, bAllowFilterBoost );
vg( cbDontStreaming, column.canStreaming() );
vg( cbDontAutoRefresh, column.canAutoRefresh() );
vg( cbHideMediaDefault, column.canShowMedia() );
vg( etRegexFilter, bAllowFilter );
vg( llRegexFilter, bAllowFilter );
vg( btnDeleteNotification, column.column_type == Column.TYPE_NOTIFICATIONS );
vg( llSearch, column.column_type == Column.TYPE_SEARCH );
// tvRegexFilterErrorの表示を更新
if( bAllowFilter ){
isRegexValid();
}
switch( column.column_type ){
case Column.TYPE_CONVERSATION:
case Column.TYPE_SEARCH:
swipyRefreshLayout.setEnabled( false );
break;
default:
swipyRefreshLayout.setEnabled( true );
break;
}
//
listView.setAdapter( status_adapter );
listView.setFastScrollEnabled( ! Pref.pref( activity ).getBoolean( Pref.KEY_DISABLE_FAST_SCROLLER, true ) );
column.setColumnViewHolder( this );
showColumnColor();
showContent();
}finally{
loading_busy = false;
}
if( column.bSimpleList ){
listView.setOnItemClickListener( status_adapter );
}else{
listView.setOnItemClickListener( null );
}
//
listView.setAdapter( status_adapter );
column.setColumnViewHolder( this );
showColumnColor();
showContent();
}
void showColumnColor(){
if( column == null ) return;
int c = column.header_bg_color;
if( c == 0 ){
llColumnHeader.setBackgroundResource( R.drawable.btn_bg_ddd );
}else{
ViewCompat.setBackground( llColumnHeader,Styler.getAdaptiveRippleDrawable(
ViewCompat.setBackground( llColumnHeader, Styler.getAdaptiveRippleDrawable(
c,
(column.header_fg_color != 0 ? column.header_fg_color :
Styler.getAttributeColor( activity,R.attr.colorRippleEffect ))
( column.header_fg_color != 0 ? column.header_fg_color :
Styler.getAttributeColor( activity, R.attr.colorRippleEffect ) )
) );
}
@ -396,6 +399,8 @@ class ColumnViewHolder
private final Runnable proc_start_filter = new Runnable() {
@Override public void run(){
if( isPageDestroyed() ) return;
if( column == null ) return;
if( isRegexValid() ){
column.regex_text = etRegexFilter.getText().toString();
activity.app_state.saveColumnList();
@ -433,10 +438,13 @@ class ColumnViewHolder
}
@Override public void onRefresh( SwipyRefreshLayoutDirection direction ){
if( column == null ) return;
column.startRefresh( false, direction == SwipyRefreshLayoutDirection.BOTTOM, - 1L, - 1 );
}
@Override public void onCheckedChanged( CompoundButton view, boolean isChecked ){
if( loading_busy || column ==null || status_adapter ==null ) return;
switch( view.getId() ){
case R.id.cbDontCloseColumn:
@ -457,7 +465,6 @@ class ColumnViewHolder
column.startLoading();
break;
case R.id.cbDontShowReply:
column.dont_show_reply = isChecked;
activity.app_state.saveColumnList();
@ -473,7 +480,7 @@ class ColumnViewHolder
column.stopStreaming();
}
break;
case R.id.cbDontAutoRefresh:
column.dont_auto_refresh = isChecked;
activity.app_state.saveColumnList();
@ -490,6 +497,8 @@ class ColumnViewHolder
@Override
public void onClick( View v ){
if( loading_busy || column ==null || status_adapter ==null ) return;
switch( v.getId() ){
case R.id.btnColumnClose:
activity.closeColumn( false, column );
@ -538,13 +547,10 @@ class ColumnViewHolder
swipyRefreshLayout.setVisibility( View.GONE );
// ロード完了後に先頭から表示させる
if( status_adapter.getCount() > 0 ){
listView.setSelectionFromTop( 0, 0 );
}
}
private void showColumnCloseButton(){
if( column == null ) return;
// カラム保護の状態
btnColumnClose.setEnabled( ! column.dont_close );
btnColumnClose.setAlpha( column.dont_close ? 0.3f : 1f );
@ -567,6 +573,7 @@ class ColumnViewHolder
// カラムヘッダなど負荷が低い部分の表示更新
void showColumnHeader(){
if( column == null ) return;
String acct = column.access_info.acct;
AcctColor ac = AcctColor.load( acct );
@ -595,14 +602,14 @@ class ColumnViewHolder
// クラッシュレポートにadapterとリストデータの状態不整合が多かったので
// とりあえずリストデータ変更の通知だけは最優先で行っておく
try{
status_adapter.notifyDataSetChanged();
}catch(Throwable ex){
ex.printStackTrace( );
if( status_adapter != null ) status_adapter.notifyDataSetChanged();
}catch( Throwable ex ){
ex.printStackTrace();
}
showColumnHeader();
if( column.is_dispose.get() ){
if( column == null || column.is_dispose.get() ){
showError( "column was disposed." );
return;
}
@ -648,8 +655,11 @@ class ColumnViewHolder
}
private void restoreScrollPosition(){
if( column == null ) return;
ScrollPosition sp = column.scroll_save;
if( sp == null ) return;
column.scroll_save = null;
if( listView.getVisibility() == View.VISIBLE ){
@ -659,11 +669,12 @@ class ColumnViewHolder
}
private void saveScrollPosition(){
if( listView.getVisibility() == View.VISIBLE ){
column.scroll_save = new ScrollPosition( listView );
}else{
column.scroll_save = new ScrollPosition( 0, 0 );
if( column != null && ! column.is_dispose.get() ){
if( listView.getVisibility() == View.VISIBLE ){
column.scroll_save = new ScrollPosition( listView );
}else{
column.scroll_save = new ScrollPosition( 0, 0 );
}
}
}
@ -672,14 +683,16 @@ class ColumnViewHolder
}
void setScrollPosition( @NonNull ScrollPosition sp, final float delta ){
final ListAdapter last_adapter = listView.getAdapter();
if( column == null || last_adapter == null ) return;
sp.restore( listView );
listView.postDelayed( new Runnable() {
@Override public void run(){
if( isPageDestroyed() ) return;
if( column == null || listView.getAdapter() != last_adapter ) return;
listView.scrollListBy( (int) ( delta * activity.density ) );
}
}, 20L );
}
}

View File

@ -78,9 +78,11 @@ class ItemListAdapter extends BaseAdapter implements AdapterView.OnItemClickList
@Override
public void onItemClick( AdapterView< ? > parent, View view, int position, long id ){
Object tag = view.getTag();
if( tag instanceof ItemViewHolder ){
( (ItemViewHolder) tag ).onItemClick( (MyListView) parent, view );
if( column.bSimpleList ){
Object tag = view.getTag();
if( tag instanceof ItemViewHolder ){
( (ItemViewHolder) tag ).onItemClick( (MyListView) parent, view );
}
}
}
}

View File

@ -34,7 +34,7 @@ class TabletColumnPagerAdapter extends RecyclerView.Adapter<TabletColumnViewHold
@Override public TabletColumnViewHolder onCreateViewHolder( ViewGroup parent, int viewType ){
View v = mLayoutInflater.inflate( R.layout.page_column, parent, false );
return new TabletColumnViewHolder( v );
return new TabletColumnViewHolder( activity,v );
}
@Override public void onBindViewHolder( TabletColumnViewHolder holder, int position ){
@ -45,7 +45,7 @@ class TabletColumnPagerAdapter extends RecyclerView.Adapter<TabletColumnViewHold
holder.itemView.setLayoutParams( lp );
}
holder.bind( activity, column_list.get(position), position , column_list.size() );
holder.bind( column_list.get(position), position , column_list.size() );
}

View File

@ -9,26 +9,22 @@ class TabletColumnViewHolder extends RecyclerView.ViewHolder{
static final LogCategory log = new LogCategory( "TabletColumnViewHolder" );
ColumnViewHolder vh;
private int old_position;
final ColumnViewHolder vh;
private int old_position = -1;
TabletColumnViewHolder( View v ){
TabletColumnViewHolder( ActMain activity, View v ){
super( v );
vh =new ColumnViewHolder( activity ,v);
v.findViewById( R.id.vTabletDivider ).setVisibility( View.VISIBLE );
}
void bind( ActMain activity, Column column,int position,int column_count ){
if( vh != null ){
log.d("destroy #%s",old_position);
vh.onPageDestroy( itemView );
vh = null;
}
old_position = position;
log.d("create #%s",position);
vh =new ColumnViewHolder( activity, column);
vh.onPageCreate( itemView,position,column_count );
void bind(Column column,int position,int column_count ){
log.d("bind. %d => %d ",old_position,position);
vh.onPageDestroy();
vh.onPageCreate( column, position,column_count );
if( ! column.bFirstInitialized ){
column.startLoading();

View File

@ -476,11 +476,11 @@
<!---->
<string name="confirm_follow_request_who_from">%2$s から鍵付きユーザ %1$s にフォローリクエストを送りますか?</string>
<!---->
<string name="confirm_follow_who_from">%2$s から %1$s をフォローしますか?</string>
<string name="confirm_follow_who_from">%2$s %1$s をフォローしますか?</string>
<!---->
<string name="confirm_post_from">%1$s から投稿します。よろしいですか?</string>
<!---->
<string name="confirm_unfollow_who_from">%2$s から %1$s をフォロー解除しますか?</string>
<string name="confirm_unfollow_who_from">%2$s %1$s をフォロー解除しますか?</string>
<!---->
<string name="dont_confirm_again">次回から確認しない</string>
<!---->
@ -599,6 +599,6 @@
<string name="disable_tablet_mode">タブレットモードを使わない(アプリ再起動が必要)</string>
<string name="media_thumbnail_height">添付メディアのサムネイルの高さ(デフォルト=64(dp)、アプリ再起動が必要)</string>
<string name="minimum_column_width">カラム最小幅(デフォルト=300(dp)、アプリ再起動が必要)</string>
<string name="account_picker_reply">どのアカウントから返信しますか?</string>
<string name="reply_from_another_account">別アカウントから返信</string>
<string name="account_picker_reply">どのアカウント返信しますか?</string>
<string name="reply_from_another_account">別アカウント返信</string>
</resources>