タブレットモードでカラム追加/削除を行った後にCPUを浪費するバグを修正
This commit is contained in:
parent
6efb01f4f7
commit
99d20bd06d
|
@ -9,8 +9,8 @@ android {
|
|||
applicationId "jp.juggler.subwaytooter"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
versionCode 96
|
||||
versionName "0.9.6"
|
||||
versionCode 97
|
||||
versionName "0.9.7"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
|
|
@ -440,7 +440,7 @@ class Column implements StreamReader.Callback {
|
|||
}else{
|
||||
return getColumnTypeName( context, column_type );
|
||||
}
|
||||
|
||||
|
||||
case TYPE_SEARCH_PORTAL:
|
||||
if( bLong ){
|
||||
return context.getString( R.string.toot_search_of, search_query );
|
||||
|
@ -809,6 +809,7 @@ class Column implements StreamReader.Callback {
|
|||
|
||||
// カラムを閉じた後のnotifyDataSetChangedのタイミングで、add/removeされる順序が期待通りにならないので
|
||||
// 参照を1つだけ持つのではなく、リストを保持して先頭の要素を使うことにする
|
||||
|
||||
private final LinkedList< ColumnViewHolder > _holder_list = new LinkedList<>();
|
||||
|
||||
void addColumnViewHolder( @NonNull ColumnViewHolder cvh ){
|
||||
|
@ -842,6 +843,7 @@ class Column implements StreamReader.Callback {
|
|||
|
||||
private ColumnViewHolder getViewHolder(){
|
||||
if( is_dispose.get() ) return null;
|
||||
// 複数のリスナがある場合、最も新しいものを返す
|
||||
return _holder_list.isEmpty() ? null : _holder_list.getFirst();
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1064,7 @@ class Column implements StreamReader.Callback {
|
|||
if( result != null && result.array != null ){
|
||||
saveRange( result, true, true );
|
||||
//
|
||||
TootStatus.List src = TootStatus.parseList( log, access_info, access_info.host,result.array );
|
||||
TootStatus.List src = TootStatus.parseList( log, access_info, access_info.host, result.array );
|
||||
list_tmp = new ArrayList<>( src.size() );
|
||||
addWithFilter( list_tmp, src );
|
||||
//
|
||||
|
@ -1099,7 +1101,7 @@ class Column implements StreamReader.Callback {
|
|||
break;
|
||||
}
|
||||
|
||||
src = TootStatus.parseList( log, access_info, access_info.host,result2.array );
|
||||
src = TootStatus.parseList( log, access_info, access_info.host, result2.array );
|
||||
|
||||
addWithFilter( list_tmp, src );
|
||||
|
||||
|
@ -1263,7 +1265,7 @@ class Column implements StreamReader.Callback {
|
|||
result = client.request(
|
||||
String.format( Locale.JAPAN, PATH_STATUSES, status_id ) );
|
||||
if( result == null || result.object == null ) return result;
|
||||
TootStatus target_status = TootStatus.parse( log, access_info, access_info.host,result.object );
|
||||
TootStatus target_status = TootStatus.parse( log, access_info, access_info.host, result.object );
|
||||
target_status.conversation_main = true;
|
||||
|
||||
// 前後の会話
|
||||
|
@ -1272,7 +1274,7 @@ class Column implements StreamReader.Callback {
|
|||
if( result == null || result.object == null ) return result;
|
||||
|
||||
// 一つのリストにまとめる
|
||||
TootContext conversation_context = TootContext.parse( log, access_info, access_info.host,result.object );
|
||||
TootContext conversation_context = TootContext.parse( log, access_info, access_info.host, result.object );
|
||||
list_tmp = new ArrayList<>( 1 + conversation_context.ancestors.size() + conversation_context.descendants.size() );
|
||||
if( conversation_context.ancestors != null )
|
||||
addWithFilter( list_tmp, conversation_context.ancestors );
|
||||
|
@ -1290,7 +1292,7 @@ class Column implements StreamReader.Callback {
|
|||
result = client.request( path );
|
||||
if( result == null || result.object == null ) return result;
|
||||
|
||||
TootResults tmp = TootResults.parse( log, access_info, access_info.host,result.object );
|
||||
TootResults tmp = TootResults.parse( log, access_info, access_info.host, result.object );
|
||||
if( tmp != null ){
|
||||
list_tmp = new ArrayList<>();
|
||||
list_tmp.addAll( tmp.hashtags );
|
||||
|
@ -1300,7 +1302,7 @@ class Column implements StreamReader.Callback {
|
|||
return result;
|
||||
|
||||
case TYPE_SEARCH_PORTAL:
|
||||
|
||||
|
||||
max_id = "";
|
||||
String q = search_query.trim();
|
||||
if( q.length() <= 0 ){
|
||||
|
@ -1827,7 +1829,7 @@ class Column implements StreamReader.Callback {
|
|||
if( result != null && result.array != null ){
|
||||
saveRange( result, bBottom, ! bBottom );
|
||||
list_tmp = new ArrayList<>();
|
||||
TootNotification.List src = TootNotification.parseList( log, access_info,access_info.host, result.array );
|
||||
TootNotification.List src = TootNotification.parseList( log, access_info, access_info.host, result.array );
|
||||
addWithFilter( list_tmp, src );
|
||||
|
||||
if( ! src.isEmpty() ){
|
||||
|
@ -1871,7 +1873,7 @@ class Column implements StreamReader.Callback {
|
|||
break;
|
||||
}
|
||||
|
||||
src = TootNotification.parseList( log, access_info, access_info.host,result2.array );
|
||||
src = TootNotification.parseList( log, access_info, access_info.host, result2.array );
|
||||
if( ! src.isEmpty() ){
|
||||
addWithFilter( list_tmp, src );
|
||||
AlarmService.injectData( context, access_info.db_id, src );
|
||||
|
@ -1893,7 +1895,7 @@ class Column implements StreamReader.Callback {
|
|||
TootApiResult result = client.request( addRange( bBottom, path_base ) );
|
||||
if( result != null && result.array != null ){
|
||||
saveRange( result, bBottom, ! bBottom );
|
||||
TootStatus.List src = TootStatus.parseList( log, access_info, access_info.host,result.array );
|
||||
TootStatus.List src = TootStatus.parseList( log, access_info, access_info.host, result.array );
|
||||
list_tmp = new ArrayList<>();
|
||||
|
||||
addWithFilter( list_tmp, src );
|
||||
|
@ -1937,7 +1939,7 @@ class Column implements StreamReader.Callback {
|
|||
break;
|
||||
}
|
||||
|
||||
src = TootStatus.parseList( log, access_info, access_info.host,result2.array );
|
||||
src = TootStatus.parseList( log, access_info, access_info.host, result2.array );
|
||||
|
||||
addWithFilter( list_tmp, src );
|
||||
|
||||
|
@ -1993,7 +1995,7 @@ class Column implements StreamReader.Callback {
|
|||
break;
|
||||
}
|
||||
|
||||
src = TootStatus.parseList( log, access_info, access_info.host,result2.array );
|
||||
src = TootStatus.parseList( log, access_info, access_info.host, result2.array );
|
||||
addWithFilter( list_tmp, src );
|
||||
}
|
||||
}
|
||||
|
@ -2097,10 +2099,10 @@ class Column implements StreamReader.Callback {
|
|||
|
||||
case TYPE_SEARCH_PORTAL:
|
||||
|
||||
if(!bBottom){
|
||||
return new TootApiResult( "head of list.");
|
||||
if( ! bBottom ){
|
||||
return new TootApiResult( "head of list." );
|
||||
}
|
||||
|
||||
|
||||
TootApiResult result;
|
||||
String q = search_query.trim();
|
||||
if( q.length() <= 0 ){
|
||||
|
@ -2392,7 +2394,7 @@ class Column implements StreamReader.Callback {
|
|||
}
|
||||
|
||||
result = r2;
|
||||
TootNotification.List src = TootNotification.parseList( log, access_info, access_info.host,r2.array );
|
||||
TootNotification.List src = TootNotification.parseList( log, access_info, access_info.host, r2.array );
|
||||
|
||||
if( src.isEmpty() ){
|
||||
log.d( "gap-notification: empty." );
|
||||
|
@ -2448,7 +2450,7 @@ class Column implements StreamReader.Callback {
|
|||
// 成功した場合はそれを返したい
|
||||
result = r2;
|
||||
|
||||
TootStatus.List src = TootStatus.parseList( log, access_info,access_info.host, r2.array );
|
||||
TootStatus.List src = TootStatus.parseList( log, access_info, access_info.host, r2.array );
|
||||
if( src.size() == 0 ){
|
||||
// 直前の取得でカラのデータが帰ってきたら終了
|
||||
log.d( "gap-statuses: empty." );
|
||||
|
|
|
@ -835,7 +835,7 @@ class ColumnViewHolder
|
|||
|
||||
// タブレットモードでカラムを追加/削除した際に発生する。
|
||||
// このタイミングでスクロール位置を復元してもうまくいかないので延期する
|
||||
activity.handler.post( proc_restoreScrollPosition );
|
||||
activity.handler.postDelayed( proc_restoreScrollPosition ,100L);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package jp.juggler.subwaytooter;
|
||||
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -8,11 +7,11 @@ import android.view.ViewGroup;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
class TabletColumnPagerAdapter extends RecyclerView.Adapter<TabletColumnViewHolder >{
|
||||
class TabletColumnPagerAdapter extends RecyclerView.Adapter< TabletColumnViewHolder > {
|
||||
|
||||
private final ActMain activity;
|
||||
private final LayoutInflater mLayoutInflater;
|
||||
private final List<Column> column_list;
|
||||
private final List< Column > column_list;
|
||||
|
||||
TabletColumnPagerAdapter( ActMain activity ){
|
||||
super();
|
||||
|
@ -33,22 +32,23 @@ 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( activity,v );
|
||||
|
||||
return new TabletColumnViewHolder( activity, v );
|
||||
}
|
||||
|
||||
@Override public void onBindViewHolder( TabletColumnViewHolder holder, int position ){
|
||||
|
||||
|
||||
if( mColumnWidth > 0 ){
|
||||
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
|
||||
lp.width = mColumnWidth;
|
||||
holder.itemView.setLayoutParams( lp );
|
||||
}
|
||||
|
||||
holder.bind( column_list.get(position), position , column_list.size() );
|
||||
holder.bind( column_list.get( position ), position, column_list.size() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override public void onViewRecycled( TabletColumnViewHolder holder ){
|
||||
super.onViewRecycled( holder );
|
||||
holder.onViewRecycled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,30 +5,34 @@ import android.view.View;
|
|||
|
||||
import jp.juggler.subwaytooter.util.LogCategory;
|
||||
|
||||
class TabletColumnViewHolder extends RecyclerView.ViewHolder{
|
||||
class TabletColumnViewHolder extends RecyclerView.ViewHolder {
|
||||
static final LogCategory log = new LogCategory( "TabletColumnViewHolder" );
|
||||
|
||||
|
||||
final ColumnViewHolder vh;
|
||||
|
||||
|
||||
private int old_position = - 1;
|
||||
|
||||
TabletColumnViewHolder( ActMain activity, View v ){
|
||||
TabletColumnViewHolder( ActMain activity, View v ){
|
||||
super( v );
|
||||
|
||||
vh =new ColumnViewHolder( activity ,v);
|
||||
vh = new ColumnViewHolder( activity, v );
|
||||
v.findViewById( R.id.vTabletDivider ).setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
void bind(Column column,int position,int column_count ){
|
||||
log.d("bind. %d => %d ", old_position,position);
|
||||
void bind( Column column, int position, int column_count ){
|
||||
log.d( "bind. %d => %d ", old_position, position );
|
||||
old_position = position;
|
||||
|
||||
|
||||
vh.onPageDestroy( position );
|
||||
vh.onPageCreate( column, position,column_count );
|
||||
vh.onPageCreate( column, position, column_count );
|
||||
|
||||
if( ! column.bFirstInitialized ){
|
||||
column.startLoading();
|
||||
}
|
||||
}
|
||||
|
||||
void onViewRecycled(){
|
||||
log.d( "onViewRecycled %d" ,old_position);
|
||||
vh.onPageDestroy( old_position );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
powered by <a href="http://mastodonsearch.jp/">Mastodon Search Portal</a>, it indexes instances in Japan.<br/>If you want to remove your toot from search result, please contact to <a href="https://mstdn.jp/@mastodonsearch">@mastodonsearch@mstdn.jp</a>.
|
||||
powered by <a href="http://mastodonsearch.jp/">Mastodon Search Portal</a>, it indexes toots of instances in Japan.<br/>If you want to remove your toot from search result, please contact to <a href="https://mstdn.jp/@mastodonsearch">@mastodonsearch@mstdn.jp</a>.
|
||||
|
|
Loading…
Reference in New Issue