Skip to content

Commit

Permalink
Current Status: Imageview loading on detailactivity screen done with …
Browse files Browse the repository at this point in the history
…Picasso library

Removed unused dependencies
Unused Imports removed from details screen
  • Loading branch information
thatsabhi22 committed May 30, 2020
1 parent c3f1f20 commit fe14e03
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
Expand All @@ -22,13 +21,11 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ShareCompat;
import androidx.palette.graphics.Palette;

import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader;
import com.example.xyzreader.R;
import com.example.xyzreader.data.ArticleLoader;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.squareup.picasso.Picasso;

import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand All @@ -50,7 +47,6 @@ public class ArticleDetailFragment extends Fragment implements
private long mItemId;
private View mRootView;
private int mMutedColor = 0xFF333333;
private ObservableScrollView mScrollView;
private DrawInsetsFrameLayout mDrawInsetsFrameLayout;
private ColorDrawable mStatusBarColorDrawable;

Expand Down Expand Up @@ -197,23 +193,9 @@ private void bindViews() {

}
bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY).replaceAll("(\r\n|\n)", "<br />")));
ImageLoaderHelper.getInstance(getActivity()).getImageLoader()
.get(mCursor.getString(ArticleLoader.Query.PHOTO_URL), new ImageLoader.ImageListener() {
@Override
public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) {
Bitmap bitmap = imageContainer.getBitmap();
if (bitmap != null) {
Palette p = Palette.generate(bitmap, 12);
mMutedColor = p.getDarkMutedColor(0xFF333333);
mPhotoView.setImageBitmap(imageContainer.getBitmap());
}
}

@Override
public void onErrorResponse(VolleyError volleyError) {

}
});
Picasso.get()
.load(mCursor.getString(ArticleLoader.Query.PHOTO_URL))
.into(mPhotoView);
} else {
mRootView.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import androidx.appcompat.widget.Toolbar;
import android.text.Html;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.example.xyzreader.R;
import com.example.xyzreader.data.ArticleLoader;
import com.example.xyzreader.data.ItemsContract;
Expand Down Expand Up @@ -52,7 +49,17 @@ public class ArticleListActivity extends AppCompatActivity implements
// Use default locale format
private SimpleDateFormat outputFormat = new SimpleDateFormat();
// Most time functions can only handle 1902 - 2037
private GregorianCalendar START_OF_EPOCH = new GregorianCalendar(2,1,1);
private GregorianCalendar START_OF_EPOCH = new GregorianCalendar(2, 1, 1);
private boolean mIsRefreshing = false;
private BroadcastReceiver mRefreshingReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (UpdaterService.BROADCAST_ACTION_STATE_CHANGE.equals(intent.getAction())) {
mIsRefreshing = intent.getBooleanExtra(UpdaterService.EXTRA_REFRESHING, false);
updateRefreshingUI();
}
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -61,7 +68,6 @@ protected void onCreate(Bundle savedInstanceState) {

mToolbar = (Toolbar) findViewById(R.id.toolbar);


final View toolbarContainerView = findViewById(R.id.toolbar_container);

mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
Expand Down Expand Up @@ -91,18 +97,6 @@ protected void onStop() {
unregisterReceiver(mRefreshingReceiver);
}

private boolean mIsRefreshing = false;

private BroadcastReceiver mRefreshingReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (UpdaterService.BROADCAST_ACTION_STATE_CHANGE.equals(intent.getAction())) {
mIsRefreshing = intent.getBooleanExtra(UpdaterService.EXTRA_REFRESHING, false);
updateRefreshingUI();
}
}
};

private void updateRefreshingUI() {
mSwipeRefreshLayout.setRefreshing(mIsRefreshing);
}
Expand All @@ -119,7 +113,7 @@ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
mRecyclerView.setAdapter(adapter);
int columnCount = getResources().getInteger(R.integer.list_column_count);
GridLayoutManager sglm =
new GridLayoutManager(this,columnCount);
new GridLayoutManager(this, columnCount);
mRecyclerView.setLayoutManager(sglm);
}

Expand All @@ -128,6 +122,20 @@ public void onLoaderReset(Loader<Cursor> loader) {
mRecyclerView.setAdapter(null);
}

public static class ViewHolder extends RecyclerView.ViewHolder {
public ImageView thumbnailView;
public TextView titleView;
public TextView subtitleView;

public ViewHolder(View view) {
super(view);
thumbnailView = view.findViewById(R.id.thumbnail);
thumbnailView.setScaleType(ImageView.ScaleType.FIT_XY);
titleView = view.findViewById(R.id.article_title);
//subtitleView = (TextView) view.findViewById(R.id.article_subtitle);
}
}

private class Adapter extends RecyclerView.Adapter<ViewHolder> {
private Cursor mCursor;

Expand Down Expand Up @@ -182,18 +190,4 @@ public int getItemCount() {
return mCursor.getCount();
}
}

public static class ViewHolder extends RecyclerView.ViewHolder {
public ImageView thumbnailView;
public TextView titleView;
public TextView subtitleView;

public ViewHolder(View view) {
super(view);
thumbnailView = view.findViewById(R.id.thumbnail);
thumbnailView.setScaleType(ImageView.ScaleType.FIT_XY);
titleView = view.findViewById(R.id.article_title);
//subtitleView = (TextView) view.findViewById(R.id.article_subtitle);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit fe14e03

Please sign in to comment.