Some fixes
This commit is contained in:
parent
5714d39433
commit
079c8473c4
|
@ -42,7 +42,7 @@ allprojects {
|
|||
}
|
||||
}
|
||||
ext.supportLibraryVersion = '27.1.1'
|
||||
ext.glideLibraryVersion = '4.8.0'
|
||||
ext.glideLibraryVersion = '4.6.1'
|
||||
ext.conscryptLibraryVersion = '1.2.0'
|
||||
ext.evernoteLibraryVersion = '1.3.0-alpha06'
|
||||
ext.gsonLibraryVersion = '2.8.2'
|
||||
|
|
|
@ -58,6 +58,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Card;
|
|||
import fr.gouv.etalab.mastodon.client.Entities.Context;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.drawers.ConversationDecoration;
|
||||
import fr.gouv.etalab.mastodon.drawers.StatusListAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveCardInterface;
|
||||
|
@ -337,18 +338,20 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
|
|||
statuses.addAll(context.getDescendants());
|
||||
}
|
||||
}
|
||||
|
||||
statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, position, null, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
loader.setVisibility(View.GONE);
|
||||
lv_status.setVisibility(View.VISIBLE);
|
||||
if( isRefreshed){
|
||||
position = statuses.size()-1;
|
||||
lv_status.scrollToPosition(position);
|
||||
}else {
|
||||
lv_status.smoothScrollToPosition(position);
|
||||
}
|
||||
statusListAdapter = new StatusListAdapter(ShowConversationActivity.this, position, null, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
// lv_status.addItemDecoration(new ConversationDecoration(ShowConversationActivity.this,position), DividerItemDecoration.VERTICAL);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
loader.setVisibility(View.GONE);
|
||||
lv_status.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
new RetrieveCardAsyncTask(getApplicationContext(), initialStatus.getId(), ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
||||
}
|
||||
|
|
|
@ -583,7 +583,7 @@ public class API {
|
|||
* @return APIResponse
|
||||
*/
|
||||
public APIResponse getInstanceTimelineSinceId(String instanceName, String since_id) {
|
||||
return getPublicTimeline(true, null, null, since_id, tootPerPage);
|
||||
return getPublicTimeline(true, instanceName, null, since_id, tootPerPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package fr.gouv.etalab.mastodon.drawers;
|
||||
/* Copyright 2018 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
|
||||
/**
|
||||
* Created by Thomas on 08/09/2018.
|
||||
* Adapter for thread decoration
|
||||
*/
|
||||
public class ConversationDecoration extends RecyclerView.ItemDecoration{
|
||||
|
||||
private Drawable divider;
|
||||
private Context context;
|
||||
private int statusOpenedPosition;
|
||||
|
||||
public ConversationDecoration(Context context, int statusOpenedPosition){
|
||||
divider = ContextCompat.getDrawable(context,R.drawable.line_divider);
|
||||
this.statusOpenedPosition = statusOpenedPosition;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
|
||||
canvas.save();
|
||||
int left = parent.getPaddingLeft();
|
||||
int right = parent.getWidth() - parent.getPaddingRight();
|
||||
int childCount = parent.getChildCount();
|
||||
int top = 0, bottom = 0;
|
||||
StatusListAdapter adapter = (StatusListAdapter) parent.getAdapter();
|
||||
int offSet = (int) Helper.convertDpToPixel(50, context);
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = parent.getChildAt(i);
|
||||
int position = parent.getChildAdapterPosition(child);
|
||||
Status status = adapter.getItem(position);
|
||||
if( status != null){
|
||||
Status statusBefore = null;
|
||||
if( position > 0)
|
||||
statusBefore = adapter.getItem(position - 1);
|
||||
top = (statusBefore != null && statusBefore.getId().equals(status.getIn_reply_to_id()))?
|
||||
child.getBottom(): (child.getTop() + offSet);
|
||||
Status statusAfter = null;
|
||||
if( adapter.getItemCount() > position+1)
|
||||
statusAfter = adapter.getItem(position + 1);
|
||||
bottom = (statusAfter != null && status.getId().equals(statusAfter.getIn_reply_to_id()) && position != statusOpenedPosition)?
|
||||
child.getTop():child.getTop()+offSet;
|
||||
|
||||
|
||||
}
|
||||
divider.setBounds(left, top, right, bottom);
|
||||
divider.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
}
|
|
@ -371,6 +371,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
}
|
||||
|
||||
public Status getItem(int position){
|
||||
return statuses.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import android.support.v4.content.ContextCompat;
|
|||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -443,7 +442,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true);
|
||||
editor.apply();
|
||||
if(liveNotifications) {
|
||||
Log.v(Helper.TAG,"streamingFederatedIntent: " + streamingFederatedIntent);
|
||||
streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class);
|
||||
try {
|
||||
context.startService(streamingFederatedIntent);
|
||||
|
@ -526,7 +524,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
}
|
||||
}else if (type == RetrieveFeedsAsyncTask.Type.LOCAL){
|
||||
Log.v(Helper.TAG,"visible: " + visible);
|
||||
if (visible) {
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true);
|
||||
|
|
|
@ -2024,7 +2024,12 @@ public class Helper {
|
|||
}else{
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
context.startActivity(intent);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
}catch (Exception e){
|
||||
Toast.makeText(context, R.string.toast_error, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<size android:width="4dp" />
|
||||
<solid android:color="?colorAccent" />
|
||||
</shape>
|
Loading…
Reference in New Issue