簡略ビューでポップアップがでない問題
This commit is contained in:
parent
bf781dfc16
commit
e9e03cd903
|
@ -513,12 +513,10 @@ class Column implements StreamReader.Callback {
|
|||
}
|
||||
}
|
||||
|
||||
boolean bSimpleList;
|
||||
|
||||
|
||||
boolean bFirstInitialized = false;
|
||||
|
||||
|
||||
private void init(){
|
||||
bSimpleList = ( column_type != Column.TYPE_CONVERSATION && app_state.pref.getBoolean( Pref.KEY_SIMPLE_LIST, false ) );
|
||||
}
|
||||
|
||||
void onNicknameUpdated(){
|
||||
|
|
|
@ -39,9 +39,8 @@ class ColumnViewHolder
|
|||
private static final LogCategory log = new LogCategory( "ColumnViewHolder" );
|
||||
|
||||
final ActMain activity;
|
||||
|
||||
|
||||
@Nullable Column column;
|
||||
@Nullable private HeaderViewHolder vh_header;
|
||||
@Nullable private ItemListAdapter status_adapter;
|
||||
|
||||
private final TextView tvLoading;
|
||||
|
@ -117,7 +116,8 @@ class ColumnViewHolder
|
|||
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 );
|
||||
|
||||
|
@ -208,14 +208,15 @@ class ColumnViewHolder
|
|||
|
||||
log.d( "onPageCreate:%s", column.getColumnName( true ) );
|
||||
|
||||
boolean bSimpleList = ( column.column_type != Column.TYPE_CONVERSATION && activity.pref.getBoolean( Pref.KEY_SIMPLE_LIST, false ) );
|
||||
|
||||
tvColumnIndex.setText( activity.getString( R.string.column_index, page_idx + 1, page_count ) );
|
||||
|
||||
listView.setAdapter( null );
|
||||
|
||||
this.status_adapter = new ItemListAdapter( activity, column );
|
||||
this.status_adapter = new ItemListAdapter( activity, column , bSimpleList );
|
||||
if( column.column_type == Column.TYPE_PROFILE ){
|
||||
vh_header = new HeaderViewHolder( activity, column, listView );
|
||||
status_adapter.header = vh_header;
|
||||
status_adapter.header =new HeaderViewHolder( activity, column, listView );
|
||||
}else{
|
||||
status_adapter.header = null;
|
||||
}
|
||||
|
@ -292,6 +293,7 @@ class ColumnViewHolder
|
|||
//
|
||||
listView.setAdapter( status_adapter );
|
||||
listView.setFastScrollEnabled( ! Pref.pref( activity ).getBoolean( Pref.KEY_DISABLE_FAST_SCROLLER, true ) );
|
||||
listView.setOnItemClickListener( status_adapter );
|
||||
|
||||
column.setColumnViewHolder( this );
|
||||
|
||||
|
@ -560,7 +562,7 @@ class ColumnViewHolder
|
|||
// Column から呼ばれる
|
||||
|
||||
boolean hasHeaderView(){
|
||||
return vh_header != null;
|
||||
return status_adapter != null && status_adapter.header != null;
|
||||
}
|
||||
|
||||
SwipyRefreshLayout getRefreshLayout(){
|
||||
|
@ -614,8 +616,8 @@ class ColumnViewHolder
|
|||
return;
|
||||
}
|
||||
|
||||
if( vh_header != null ){
|
||||
vh_header.bind( column.who_account );
|
||||
if( status_adapter.header != null ){
|
||||
status_adapter.header.bind( column.who_account );
|
||||
}
|
||||
|
||||
if( ! column.bFirstInitialized ){
|
||||
|
@ -643,7 +645,7 @@ class ColumnViewHolder
|
|||
}
|
||||
}
|
||||
|
||||
if( column.list_data.isEmpty() && vh_header == null ){
|
||||
if( status_adapter.getCount() == 0 ){
|
||||
showError( activity.getString( R.string.list_empty ) );
|
||||
}else{
|
||||
tvLoading.setVisibility( View.GONE );
|
||||
|
|
|
@ -15,11 +15,14 @@ class ItemListAdapter extends BaseAdapter implements AdapterView.OnItemClickList
|
|||
private final List< Object > list;
|
||||
|
||||
HeaderViewHolder header;
|
||||
|
||||
private final boolean bSimpleList;
|
||||
|
||||
ItemListAdapter( ActMain activity, Column column ){
|
||||
ItemListAdapter( ActMain activity, Column column ,boolean bSimpleList ){
|
||||
this.activity = activity;
|
||||
this.column = column;
|
||||
this.list = column.list_data;
|
||||
this.bSimpleList = bSimpleList;
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,8 +69,8 @@ class ItemListAdapter extends BaseAdapter implements AdapterView.OnItemClickList
|
|||
|
||||
ItemViewHolder holder;
|
||||
if( view == null ){
|
||||
view = activity.getLayoutInflater().inflate( column.bSimpleList ? R.layout.lv_status_simple : R.layout.lv_status, parent, false );
|
||||
holder = new ItemViewHolder( activity, column, this, view );
|
||||
view = activity.getLayoutInflater().inflate( bSimpleList ? R.layout.lv_status_simple : R.layout.lv_status, parent, false );
|
||||
holder = new ItemViewHolder( activity, column, this, view ,bSimpleList );
|
||||
view.setTag( holder );
|
||||
}else{
|
||||
holder = (ItemViewHolder) view.getTag();
|
||||
|
@ -78,7 +81,7 @@ class ItemListAdapter extends BaseAdapter implements AdapterView.OnItemClickList
|
|||
|
||||
@Override
|
||||
public void onItemClick( AdapterView< ? > parent, View view, int position, long id ){
|
||||
if( column.bSimpleList ){
|
||||
if( bSimpleList ){
|
||||
Object tag = view.getTag();
|
||||
if( tag instanceof ItemViewHolder ){
|
||||
( (ItemViewHolder) tag ).onItemClick( (MyListView) parent, view );
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package jp.juggler.subwaytooter;
|
||||
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.ViewGroupCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -83,11 +82,14 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|||
private TootGap gap;
|
||||
private int position;
|
||||
|
||||
ItemViewHolder( ActMain activity, Column column, ItemListAdapter list_adapter, View view ){
|
||||
private final boolean bSimpleList;
|
||||
|
||||
ItemViewHolder( ActMain activity, Column column, ItemListAdapter list_adapter, View view ,boolean bSimpleList ){
|
||||
this.activity = activity;
|
||||
this.column = column;
|
||||
this.access_info = column.access_info;
|
||||
this.list_adapter = list_adapter;
|
||||
this.bSimpleList = bSimpleList;
|
||||
|
||||
this.llBoosted = view.findViewById( R.id.llBoosted );
|
||||
this.ivBoosted = (ImageView) view.findViewById( R.id.ivBoosted );
|
||||
|
@ -117,7 +119,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|||
this.tvContent = (MyTextView) view.findViewById( R.id.tvContent );
|
||||
this.tvMentions = (MyTextView) view.findViewById( R.id.tvMentions );
|
||||
|
||||
this.buttons_for_status = column.bSimpleList ? null : new StatusButtons( activity, column, view );
|
||||
this.buttons_for_status = bSimpleList ? null : new StatusButtons( activity, column, view , false );
|
||||
|
||||
this.flMedia = view.findViewById( R.id.flMedia );
|
||||
this.btnShowMedia = view.findViewById( R.id.btnShowMedia );
|
||||
|
@ -211,7 +213,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|||
//
|
||||
showFollow( n.account );
|
||||
}else if( TootNotification.TYPE_MENTION.equals( n.type ) ){
|
||||
if( ! column.bSimpleList ){
|
||||
if( ! bSimpleList ){
|
||||
showBoost(
|
||||
n.account
|
||||
, n.time_created_at
|
||||
|
@ -448,7 +450,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|||
|
||||
case R.id.btnSearchTag:
|
||||
if( search_tag != null ){
|
||||
activity.openHashTag( pos,access_info, search_tag );
|
||||
activity.openHashTag( activity.nextPosition( column ),access_info, search_tag );
|
||||
}else if( gap != null ){
|
||||
column.startGap( gap, position );
|
||||
}
|
||||
|
@ -500,7 +502,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
|||
void onItemClick( MyListView listView, View anchor ){
|
||||
if( status != null ){
|
||||
activity.closeListItemPopup();
|
||||
activity.list_item_popup = new StatusButtonsPopup( activity, column );
|
||||
activity.list_item_popup = new StatusButtonsPopup( activity, column ,bSimpleList);
|
||||
activity.list_item_popup.show( listView, anchor, status );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,13 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
|
|||
private final ImageView ivFollowedBy2;
|
||||
private final View llFollow2;
|
||||
|
||||
StatusButtons( @NonNull ActMain activity, @NonNull Column column, @NonNull View viewRoot ){
|
||||
final boolean bSimpleList;
|
||||
|
||||
StatusButtons( @NonNull ActMain activity, @NonNull Column column, @NonNull View viewRoot ,boolean bSimpleList){
|
||||
this.activity = activity;
|
||||
this.column = column;
|
||||
this.access_info = column.access_info;
|
||||
this.bSimpleList = bSimpleList;
|
||||
|
||||
btnBoost = (Button) viewRoot.findViewById( R.id.btnBoost );
|
||||
btnFavourite = (Button) viewRoot.findViewById( R.id.btnFavourite );
|
||||
|
@ -133,7 +136,7 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
|
|||
, ! status.reblogged
|
||||
, status
|
||||
, false
|
||||
, column.bSimpleList ? activity.boost_complete_callback : null
|
||||
, bSimpleList ? activity.boost_complete_callback : null
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
@ -147,7 +150,7 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
|
|||
, false
|
||||
, ! status.favourited
|
||||
, status
|
||||
, column.bSimpleList ? activity.favourite_complete_callback : null
|
||||
, bSimpleList ? activity.favourite_complete_callback : null
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.Gravity;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ListView;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus;
|
||||
|
@ -19,10 +20,10 @@ class StatusButtonsPopup {
|
|||
private final View viewRoot;
|
||||
private final StatusButtons buttons_for_status;
|
||||
|
||||
@SuppressLint("InflateParams") StatusButtonsPopup( ActMain activity, Column column ){
|
||||
@SuppressLint("InflateParams") StatusButtonsPopup( ActMain activity, Column column ,boolean bSimpleList ){
|
||||
this.activity = activity;
|
||||
this.viewRoot = activity.getLayoutInflater().inflate( R.layout.list_item_popup, null, false );
|
||||
this.buttons_for_status = new StatusButtons( activity,column, viewRoot );
|
||||
this.buttons_for_status = new StatusButtons( activity,column, viewRoot , bSimpleList);
|
||||
}
|
||||
|
||||
private PopupWindow window;
|
||||
|
@ -60,6 +61,7 @@ class StatusButtonsPopup {
|
|||
int[] location = new int[ 2 ];
|
||||
|
||||
anchor.getLocationOnScreen( location );
|
||||
int anchor_left = location[ 0 ];
|
||||
int anchor_top = location[ 1 ];
|
||||
|
||||
listView.getLocationOnScreen( location );
|
||||
|
@ -85,11 +87,27 @@ class StatusButtonsPopup {
|
|||
viewRoot.findViewById( R.id.ivTriangleBottom ).setVisibility( View.VISIBLE );
|
||||
popup_y -= popup_height;
|
||||
}
|
||||
|
||||
int anchor_width = anchor.getWidth();
|
||||
int popup_width =getViewWidth(viewRoot);
|
||||
int popup_x = anchor_left + anchor_width/2 - popup_width/2;
|
||||
if( popup_x < 0 ) popup_x = 0;
|
||||
int popup_x_max = activity.getResources().getDisplayMetrics().widthPixels - popup_width;
|
||||
if( popup_x > popup_x_max ) popup_x = popup_x_max;
|
||||
|
||||
|
||||
window.showAtLocation(
|
||||
listView
|
||||
, Gravity.CENTER_HORIZONTAL | Gravity.TOP
|
||||
, 0
|
||||
, Gravity.LEFT | Gravity.TOP
|
||||
, popup_x
|
||||
, popup_y
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static int getViewWidth( View v ){
|
||||
int spec= View.MeasureSpec.makeMeasureSpec( 0, View.MeasureSpec.UNSPECIFIED );
|
||||
v.measure( spec,spec );
|
||||
return v.getMeasuredWidth();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue