Commit some old stuff that cannot be identified or explained

This commit is contained in:
tar 2023-11-24 21:27:08 +01:00
parent 52b0c71eb2
commit af7de9e783
216 changed files with 235 additions and 23 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
.idea/.name Normal file → Executable file
View File

0
.idea/compiler.xml Normal file → Executable file
View File

0
.idea/copyright/profiles_settings.xml Normal file → Executable file
View File

0
.idea/dictionaries/tariel.xml Normal file → Executable file
View File

0
.idea/encodings.xml Normal file → Executable file
View File

0
.idea/gradle.xml Normal file → Executable file
View File

0
.idea/misc.xml Normal file → Executable file
View File

0
.idea/modules.xml Normal file → Executable file
View File

0
.idea/runConfigurations.xml Normal file → Executable file
View File

0
.idea/vcs.xml Normal file → Executable file
View File

0
app/.gitignore vendored Normal file → Executable file
View File

0
app/build.gradle Normal file → Executable file
View File

0
app/google-services.json Normal file → Executable file
View File

0
app/libs/socialauth-4.4.jar Normal file → Executable file
View File

0
app/libs/socialauth-android-3.2.jar Normal file → Executable file
View File

0
app/proguard-rules.pro vendored Normal file → Executable file
View File

View File

0
app/src/main/AndroidManifest.xml Normal file → Executable file
View File

0
app/src/main/assets/fonts/Ubuntu-B.ttf Normal file → Executable file
View File

0
app/src/main/assets/fonts/Ubuntu-M.ttf Normal file → Executable file
View File

0
app/src/main/assets/jsons/item_categories.json Normal file → Executable file
View File

0
app/src/main/assets/jsons/items.json Normal file → Executable file
View File

0
app/src/main/assets/jsons/sets.json Normal file → Executable file
View File

0
app/src/main/assets/jsons/sharing_photos.json Normal file → Executable file
View File

0
app/src/main/assets/oauth_consumer.properties Normal file → Executable file
View File

0
app/src/main/java/com/hikapro/backpack/App.java Normal file → Executable file
View File

View File

View File

View File

0
app/src/main/java/com/hikapro/backpack/model/Api.java Normal file → Executable file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -28,6 +28,7 @@ import com.hikapro.backpack.presenter.adapters.helper.AppRater;
import com.hikapro.backpack.presenter.adapters.helper.Util;
import com.hikapro.backpack.presenter.adapters.helper.items.DividerDecoration2;
import com.hikapro.backpack.presenter.adapters.helper.items.StickyHeaderDecoration;
import com.hikapro.backpack.presenter.adapters.helper.items.StickyHeaderDecorationCopy;
import com.hikapro.backpack.view.View;
import java.lang.ref.WeakReference;
@ -77,7 +78,13 @@ public class ItemListPresenter implements Presenter.ItemList {
recycler.setLayoutManager(llm);
recycler.setAdapter(adapter);
final StickyHeaderDecoration decoration = new StickyHeaderDecoration(adapter);
if (set != null) {
android.view.View con = view.findViewById(R.id.item_list_container);
applyBackground(con, set.getId());
}
//final StickyHeaderDecoration decoration = new StickyHeaderDecoration(adapter);
final StickyHeaderDecorationCopy decoration = new StickyHeaderDecorationCopy(adapter, getActivityContext(), R.drawable.divider2, Util.dp2px(getAppContext(), 16), view.getBackground());
recycler.addItemDecoration(decoration);
//recycler.addItemDecoration(new DividerDecoration(getActivityContext()));
recycler.addItemDecoration(new DividerDecoration2(getActivityContext(), R.drawable.divider, Util.dp2px(getAppContext(), 16)));
@ -101,10 +108,10 @@ public class ItemListPresenter implements Presenter.ItemList {
}
});
if (set != null) {
android.view.View con = view.findViewById(R.id.item_list_container);
applyBackground(con, set.getId());
}
// if (set != null) {
// android.view.View con = view.findViewById(R.id.item_list_container);
// applyBackground(con, set.getId());
// }
NetworkUtil.sendGoogleAnalyticsScreen(TAG);
return view;
}

View File

View File

View File

View File

@ -207,11 +207,7 @@ public class ItemListAdapter extends RecyclerView.Adapter<ItemViewHolder> implem
@Override
public long getHeaderId(int position) {
/*if (position == 0) {
return -1;
} else {*/
return presenter.getModel().getHeaderId(position);
//}
}
@Override

View File

@ -62,7 +62,6 @@ public class HeaderPositionCalculator {
* list that immediately precedes it. Items with no headers will always return false.
*
* @param position of the list item in questions
* @param isReverseLayout TRUE if layout manager has flag isReverseLayout
* @return true if this item has a different header than the previous item in the list
*/
public boolean hasNewHeader(int position) {
@ -76,8 +75,8 @@ public class HeaderPositionCalculator {
return false;
}
long nextItemHeaderId = -1;//TODO -1
int nextItemPosition = position - 1; // TODO -1
long nextItemHeaderId = -1;
int nextItemPosition = position - 1;
if (!indexOutOfBounds(nextItemPosition)) {
nextItemHeaderId = adapter.getHeaderId(nextItemPosition);
}
@ -216,8 +215,6 @@ public class HeaderPositionCalculator {
int adapterPosition = parent.getChildAdapterPosition(item);
if (adapterPosition == RecyclerView.NO_POSITION || headerProvider.getHeader(parent, adapterPosition) != header) {
// Resolves https://github.com/timehop/sticky-headers-recyclerview/issues/36
// Handles an edge case where a trailing header is smaller than the current sticky header.
return false;
}

View File

@ -1,7 +1,9 @@
package com.hikapro.backpack.presenter.adapters.helper.items;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@ -41,7 +43,10 @@ public class HeaderRenderer {
}
canvas.translate(offset.left, offset.top);
//header.setBackgroundColor(Color.BLUE); //TODO del
// Drawable drawable = header.getBackground();
// Drawable drawable1 = header.getglo
// header.getBackground().setAlpha(126);
header.draw(canvas);
canvas.restore();
}

View File

@ -0,0 +1,214 @@
package com.hikapro.backpack.presenter.adapters.helper.items;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.hikapro.backpack.R;
/**
* Created by tariel on 01/05/16.
*/
public class StickyHeaderDecorationCopy extends RecyclerView.ItemDecoration {
private final StickyHeaderAdapter adapter;
private final ItemVisibilityAdapter visibilityAdapter;
private final SparseArray<Rect> headerRects = new SparseArray<>();
private final HeaderProvider headerProvider;
private final HeaderPositionCalculator headerPositionCalculator;
private final HeaderRenderer renderer;
private final DimensionCalculator dimensionCalculator;
private Drawable divider;
private Drawable background;
private int paddingX;
private final Rect rect = new Rect();
public StickyHeaderDecorationCopy(StickyHeaderAdapter adapter, Context context, int resId, int paddingX, Drawable background) {
this(adapter, new DimensionCalculator(), null);
divider = ContextCompat.getDrawable(context, resId);
this.paddingX = paddingX;
this.background = background;
}
public StickyHeaderDecorationCopy(StickyHeaderAdapter adapter, Context context, int resId, int paddingX) {
this(adapter, new DimensionCalculator(), null);
divider = ContextCompat.getDrawable(context, resId);
this.paddingX = paddingX;
}
private StickyHeaderDecorationCopy(StickyHeaderAdapter adapter,
DimensionCalculator dimensionCalculator, ItemVisibilityAdapter visibilityAdapter) {
this(adapter, dimensionCalculator, new HeaderRenderer(), new HeaderViewCache(adapter), visibilityAdapter);
}
private StickyHeaderDecorationCopy(StickyHeaderAdapter adapter, DimensionCalculator dimensionCalculator,
HeaderRenderer headerRenderer, HeaderProvider headerProvider,
ItemVisibilityAdapter visibilityAdapter) {
this(adapter, headerRenderer, dimensionCalculator, headerProvider,
new HeaderPositionCalculator(adapter, headerProvider,
dimensionCalculator), visibilityAdapter);
}
private StickyHeaderDecorationCopy(StickyHeaderAdapter adapter, HeaderRenderer headerRenderer,
DimensionCalculator dimensionCalculator, HeaderProvider headerProvider,
HeaderPositionCalculator headerPositionCalculator, ItemVisibilityAdapter visibilityAdapter) {
this.adapter = adapter;
this.headerProvider = headerProvider;
this.renderer = headerRenderer;
this.dimensionCalculator = dimensionCalculator;
this.headerPositionCalculator = headerPositionCalculator;
this.visibilityAdapter = visibilityAdapter;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
int itemPosition = parent.getChildAdapterPosition(view);
if (itemPosition == RecyclerView.NO_POSITION) {
return;
}
if (headerPositionCalculator.hasNewHeader(itemPosition)) {
View header = getHeaderView(parent, itemPosition);
setItemOffsetsForHeader(outRect, header, LinearLayout.VERTICAL);
}
}
/**
* Sets the offsets for the first item in a section to make room for the header view
*
* @param itemOffsets rectangle to define offsets for the item
* @param header view used to calculate offset for the item
* @param orientation used to calculate offset for the item
*/
private void setItemOffsetsForHeader(Rect itemOffsets, View header, int orientation) {
dimensionCalculator.initMargins(rect, header);
if (orientation == LinearLayoutManager.VERTICAL) {
itemOffsets.top = header.getHeight() + rect.top + rect.bottom;
} else {
itemOffsets.left = header.getWidth() + rect.left + rect.right;
}
}
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDrawOver(c, parent, state);
final int childCount = parent.getChildCount();
if (childCount <= 0 || adapter.getItemCount() <= 0) {
return;
}
for (int i = 0; i < childCount; i++) {
View itemView = parent.getChildAt(i);
int position = parent.getChildAdapterPosition(itemView);
if (position == RecyclerView.NO_POSITION) {
continue;
}
boolean hasStickyHeader = headerPositionCalculator.hasStickyHeader(itemView, LinearLayout.VERTICAL, position);
if (hasStickyHeader || headerPositionCalculator.hasNewHeader(position)) {
View header = headerProvider.getHeader(parent, position);
//re-use existing Rect, if any.
Rect headerOffset = headerRects.get(position);
if (headerOffset == null) {
headerOffset = new Rect();
headerRects.put(position, headerOffset);
}
headerPositionCalculator.initHeaderBounds(headerOffset, parent, header, itemView, hasStickyHeader);
renderer.drawHeader(parent, c, header, headerOffset);
drawDivider(c, headerOffset, header);// TODO move to renderer?
drawBackground(header);
}
}
}
/**
* Gets the position of the header under the specified (x, y) coordinates.
*
* @param x x-coordinate
* @param y y-coordinate
* @return position of header, or -1 if not found
*/
public int findHeaderPositionUnder(int x, int y) {
for (int i = 0; i < headerRects.size(); i++) {
Rect rect = headerRects.get(headerRects.keyAt(i));
if (rect.contains(x, y)) {
int position = headerRects.keyAt(i);
if (visibilityAdapter == null || visibilityAdapter.isPositionVisible(position)) {
return position;
}
}
}
return -1;
}
/**
* Gets the header view for the associated position. If it doesn't exist yet, it will be
* created, measured, and laid out.
*
* @param parent the recyclerview
* @param position the position to get the header view for
* @return Header view
*/
public View getHeaderView(RecyclerView parent, int position) {
return headerProvider.getHeader(parent, position);
}
/**
* Invalidates cached headers. This does not invalidate the recyclerview, you should do that manually after
* calling this method.
*/
public void invalidateHeaders() {
headerProvider.invalidate();
headerRects.clear();
}
private void drawDivider(Canvas c, Rect bounds, View header) {
int left = bounds.left;
int right = bounds.right;
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) header.getLayoutParams();
int top = header.getBottom() + params.bottomMargin;
int bottom = top + divider.getIntrinsicHeight();
divider.setBounds(left + paddingX, top, right - paddingX, bottom);
divider.draw(c);
}
private void drawBackground(View header) {
if (this.background != null) {
Bitmap bitmap = ((BitmapDrawable)background).getBitmap();
Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, (int) header.getX(), (int) header.getY(), header.getWidth(), header.getHeight());
header.setBackground(new BitmapDrawable(croppedBitmap));
}
}
private void drawBackground(RecyclerView parent, View header) {
View rootView = parent.getRootView();
Bitmap originalBitmap = ((BitmapDrawable)rootView.getBackground()).getBitmap();;
Bitmap croppedBitmap = Bitmap.createBitmap(originalBitmap, (int)header.getX(), (int)header.getY(), header.getWidth(), header.getHeight());
header.setBackground(new BitmapDrawable(croppedBitmap));
}
}

0
app/src/main/java/com/hikapro/backpack/view/View.java Normal file → Executable file
View File

View File

Some files were not shown because too many files have changed in this diff Show More