Verified Commit 7d7af316 authored by Andreas Redmer's avatar Andreas Redmer 👍

moved all adapters into adapter package

parent 04655c0d
Pipeline #57263777 passed with stages
in 6 minutes and 31 seconds
/*
* Copyright (C) 2018 Andreas Redmer <ar-gdroid@abga.be>
*
* 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.gdroid.gdroid;
import android.annotation.TargetApi;
import android.content.Context;
import android.database.DataSetObserver;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Adapter;
import android.widget.LinearLayout;
public class AdapterLinearLayout extends LinearLayout {
private Adapter adapter;
private DataSetObserver dataSetObserver = new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
reloadChildViews();
}
};
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public AdapterLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setOrientation(LinearLayout.HORIZONTAL);
}
public AdapterLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(LinearLayout.HORIZONTAL);
}
public AdapterLinearLayout(Context context) {
super(context);
setOrientation(LinearLayout.HORIZONTAL);
}
public void setAdapter(Adapter adapter) {
if (this.adapter == adapter) return;
this.adapter = adapter;
if (adapter != null) adapter.registerDataSetObserver(dataSetObserver);
reloadChildViews();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
if (adapter != null) adapter.unregisterDataSetObserver(dataSetObserver);
}
private void reloadChildViews() {
removeAllViews();
if (adapter == null) return;
int count = adapter.getCount();
for (int position = 0; position < count; ++position) {
View v = adapter.getView(position, null, this);
if (v != null) addView(v);
}
requestLayout();
}
}
\ No newline at end of file
......@@ -33,6 +33,7 @@ import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Display;
import org.gdroid.gdroid.adapters.AppBeanAdapter;
import org.gdroid.gdroid.beans.AppCollectionDescriptor;
import org.gdroid.gdroid.beans.ApplicationBean;
......
......@@ -57,6 +57,8 @@ import com.tonyodev.fetch2.Request;
import com.tonyodev.fetch2.Status;
import com.tonyodev.fetch2core.DownloadBlock;
import org.gdroid.gdroid.adapters.AppBeanAdapter;
import org.gdroid.gdroid.adapters.AppCollectionAdapter;
import org.gdroid.gdroid.adapters.CommentAdapter;
import org.gdroid.gdroid.adapters.VersionAdapter;
import org.gdroid.gdroid.beans.AppCollectionDescriptor;
......
......@@ -27,11 +27,10 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import org.gdroid.gdroid.authors.AuthorArrayAdapter;
import org.gdroid.gdroid.adapters.AuthorArrayAdapter;
import org.gdroid.gdroid.beans.AppDatabase;
import org.gdroid.gdroid.beans.AuthorBean;
import java.util.ArrayList;
import java.util.List;
public class AuthorListActivity extends AppCompatActivity {
......
......@@ -49,6 +49,8 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import org.gdroid.gdroid.adapters.AppBeanAdapter;
import org.gdroid.gdroid.adapters.AppCollectionAdapter;
import org.gdroid.gdroid.beans.AppCollectionDescriptor;
import org.gdroid.gdroid.beans.AppDatabase;
import org.gdroid.gdroid.beans.ApplicationBean;
......
/*
* Copyright (C) 2018,2019 Andreas Redmer <ar-gdroid@abga.be>
* Copyright (C) 2019 Andreas Redmer <ar-gdroid@abga.be>
*
* 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
......@@ -16,7 +16,7 @@
*
*/
package org.gdroid.gdroid;
package org.gdroid.gdroid.adapters;
import android.app.Activity;
import android.content.Context;
......@@ -40,6 +40,10 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.gdroid.gdroid.AppDetailActivity;
import org.gdroid.gdroid.GlideApp;
import org.gdroid.gdroid.R;
import org.gdroid.gdroid.Util;
import org.gdroid.gdroid.beans.ApplicationBean;
import org.gdroid.gdroid.repos.Repo;
......
/*
* Copyright (C) 2018,2019 Andreas Redmer <ar-gdroid@abga.be>
* Copyright (C) 2019 Andreas Redmer <ar-gdroid@abga.be>
*
* 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
......@@ -16,7 +16,7 @@
*
*/
package org.gdroid.gdroid;
package org.gdroid.gdroid.adapters;
import android.app.Activity;
import android.content.Context;
......@@ -33,6 +33,9 @@ import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import org.gdroid.gdroid.AppCollectionActivity;
import org.gdroid.gdroid.R;
import org.gdroid.gdroid.Util;
import org.gdroid.gdroid.beans.AppCollectionDescriptor;
import org.gdroid.gdroid.beans.ApplicationBean;
......
/*
* Copyright (C) 2018-2019 Andreas Redmer <ar-gdroid@abga.be>
* Copyright (C) 2019 Andreas Redmer <ar-gdroid@abga.be>
*
* 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
......@@ -16,7 +16,7 @@
*
*/
package org.gdroid.gdroid.authors;
package org.gdroid.gdroid.adapters;
import android.content.Context;
import android.view.LayoutInflater;
......
......@@ -21,7 +21,7 @@ package org.gdroid.gdroid.beans;
import android.content.Context;
import android.util.Pair;
import org.gdroid.gdroid.AppCollectionAdapter;
import org.gdroid.gdroid.adapters.AppCollectionAdapter;
import org.gdroid.gdroid.MapUtil;
import org.gdroid.gdroid.Util;
......
......@@ -28,7 +28,7 @@ import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import org.gdroid.gdroid.AppCollectionAdapter;
import org.gdroid.gdroid.adapters.AppCollectionAdapter;
import org.gdroid.gdroid.MainActivity;
import org.gdroid.gdroid.R;
import org.gdroid.gdroid.beans.AppCollectionDescriptor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment