Browse Source

A lot of refactoring. Was created and then was changed layout draw method for full news view.

NewsItemList divided in two new class - NewsItemList and NewsItemGroup.
master
Defend 8 years ago
parent
commit
957b4ec5b7
  1. 12
      .idea/libraries/animated_vector_drawable_23_4_0.xml
  2. 15
      .idea/libraries/appcompat_v7_23_4_0.xml
  3. 15
      .idea/libraries/design_23_4_0.xml
  4. 15
      .idea/libraries/recyclerview_v7_23_4_0.xml
  5. 11
      .idea/libraries/support_annotations_23_4_0.xml
  6. 16
      .idea/libraries/support_v4_23_4_0.xml
  7. 12
      .idea/libraries/support_vector_drawable_23_4_0.xml
  8. 54
      app/app.iml
  9. 5
      app/build.gradle
  10. 65
      app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java
  11. 11
      app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java
  12. 94
      app/src/main/java/ru/defend/defdevteam/tstu/NewsFragment.java
  13. 48
      app/src/main/java/ru/defend/defdevteam/tstu/NewsItemGroup.java
  14. 125
      app/src/main/java/ru/defend/defdevteam/tstu/NewsItemList.java
  15. 39
      app/src/main/res/layout/cabinet_newsfeed_floatingitem.xml
  16. 61
      app/src/main/res/layout/fragment_news.xml

12
.idea/libraries/animated_vector_drawable_23_4_0.xml

@ -1,12 +0,0 @@
<component name="libraryTable">
<library name="animated-vector-drawable-23.4.0">
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/animated-vector-drawable/23.4.0/animated-vector-drawable-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

15
.idea/libraries/appcompat_v7_23_4_0.xml

@ -1,15 +0,0 @@
<component name="libraryTable">
<library name="appcompat-v7-23.4.0">
<ANNOTATIONS>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.4.0/appcompat-v7-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

15
.idea/libraries/design_23_4_0.xml

@ -1,15 +0,0 @@
<component name="libraryTable">
<library name="design-23.4.0">
<ANNOTATIONS>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.4.0/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.4.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/design/23.4.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/design/23.4.0/design-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

15
.idea/libraries/recyclerview_v7_23_4_0.xml

@ -1,15 +0,0 @@
<component name="libraryTable">
<library name="recyclerview-v7-23.4.0">
<ANNOTATIONS>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.4.0/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.4.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.4.0/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/recyclerview-v7/23.4.0/recyclerview-v7-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

11
.idea/libraries/support_annotations_23_4_0.xml

@ -1,11 +0,0 @@
<component name="libraryTable">
<library name="support-annotations-23.4.0">
<CLASSES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.4.0/support-annotations-23.4.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-annotations/23.4.0/support-annotations-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

16
.idea/libraries/support_v4_23_4_0.xml

@ -1,16 +0,0 @@
<component name="libraryTable">
<library name="support-v4-23.4.0">
<ANNOTATIONS>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/annotations.zip!/" />
</ANNOTATIONS>
<CLASSES>
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/res" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/jars/classes.jar!/" />
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/jars/libs/internal_impl-23.4.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

12
.idea/libraries/support_vector_drawable_23_4_0.xml

@ -1,12 +0,0 @@
<component name="libraryTable">
<library name="support-vector-drawable-23.4.0">
<CLASSES>
<root url="jar://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.4.0/jars/classes.jar!/" />
<root url="file://$PROJECT_DIR$/app/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.4.0/res" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/support-vector-drawable/23.4.0/support-vector-drawable-23.4.0-sources.jar!/" />
</SOURCES>
</library>
</component>

54
app/app.iml

@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
@ -82,17 +74,31 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/23.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/transition/25.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
@ -114,15 +120,21 @@
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="design-23.4.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.4.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.4.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-25.1.0" level="project" />
<orderEntry type="library" exported="" name="design-25.1.0" level="project" />
<orderEntry type="library" exported="" name="transition-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-fragment-25.1.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.4.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.4.0" level="project" />
<orderEntry type="library" exported="" name="support-core-ui-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-media-compat-25.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.4.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.4.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-25.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-25.1.0" level="project" />
<orderEntry type="library" exported="" name="support-core-utils-25.1.0" level="project" />
<orderEntry type="library" exported="" name="android-android-25" level="project" />
</component>
</module>

5
app/build.gradle

@ -21,7 +21,8 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}

65
app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java

@ -5,13 +5,14 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.view.menu.MenuView;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -29,21 +30,20 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import java.io.InputStream;
import java.io.StringReader;
import java.util.List;
public class CabinetActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
implements NavigationView.OnNavigationItemSelectedListener, NewsFragment.OnFragmentInteractionListener {
static public List<GroupList> group, faculty, subs;
@ -60,6 +60,10 @@ public class CabinetActivity extends AppCompatActivity
FeedController feedController;
OldCabinetController cabinetController;
@Override
public void onFragmentInteraction(Uri uri) {
}
public class groupAdapter extends ArrayAdapter<GroupList> {
@ -218,12 +222,8 @@ public class CabinetActivity extends AppCompatActivity
gRateLayout.setVisibility(View.INVISIBLE);
fRateLayout.setVisibility(View.INVISIBLE);
aboutLayout.setVisibility(View.INVISIBLE);
// if(!taskFinished) {
// progressLayout.setVisibility(View.VISIBLE);
// }
switch (id) {
case R.id.nav_newsfeed:
progressLayout.setVisibility(View.INVISIBLE);
newsLayout.setVisibility(View.VISIBLE);
myToolbar.setTitle(R.string.title_newsfeed);
break;
@ -244,7 +244,6 @@ public class CabinetActivity extends AppCompatActivity
myToolbar.setTitle(R.string.title_globalrate);
break;
case R.id.nav_aboutapp:
progressLayout.setVisibility(View.INVISIBLE);
aboutLayout.setVisibility(View.VISIBLE);
myToolbar.setTitle(R.string.title_about_dev);
break;
@ -309,11 +308,11 @@ public class CabinetActivity extends AppCompatActivity
}
}
public int addNewsItem(NewsItemList.Group group, Boolean LastItem) {
public int addNewsItem(NewsItemGroup group, Boolean LastItem) {
String title = group.getTitle();
String text = group.getText();
String link = group.getLink();
int viewId = group.getViewId();
int viewId = group.getViewID();
LayoutInflater inflater = getLayoutInflater();
LinearLayout newsFeed = (LinearLayout) findViewById(R.id.newsfeed_scroll);
View layout;
@ -344,10 +343,42 @@ public class CabinetActivity extends AppCompatActivity
}
public void OnNewsItemClick(View v) {
Log.i("View Id", Integer.toString(v.getId()));
// RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.newsfeeder);
// View layout = getLayoutInflater().inflate(R.layout.cabinet_newsfeed_floatingitem, relativeLayout, false);
// relativeLayout.addView(layout);
NewsItemList newsItemList = feedController.newsItemList;
NewsItemGroup group = newsItemList.getGroupByViewId(v.getId());
Log.i("ERROR DEBUG", "" +v.getId());
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
NewsFragment newsFragment = new NewsFragment().newInstance(group);
fragmentTransaction.add(R.id.newsfeeder, newsFragment);
fragmentTransaction.commit();
// RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.newsfeeder);
// View layout = getLayoutInflater().inflate(R.layout.cabinet_newsfeed_floatingitem, relativeLayout, false);
// relativeLayout.addView(layout);
//
// try {
// Log.i("ERROR DEBUG", "CLICK CLACK");
// TextView textView = (TextView) layout.findViewById(R.id.floatingnews_title);
// NewsItemList newsItemList = feedController.newsItemList;
// textView.setText(newsItemList.getGroupByViewId(v.getId()).getTitle());
// TextView textView1 = (TextView) layout.findViewById(R.id.floatingnews_content);
// textView1.setText(newsItemList.getGroupByViewId(v.getId()).getText());
//
// FrameLayout frameLayout = (FrameLayout) findViewById(R.id.floatingitem_first);
// LinearLayout linearLayout = (LinearLayout) findViewById(R.id.floatingitem_second);
// View.OnClickListener regionOnClickListner = new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// v.setVisibility(View.GONE);
// LinearLayout linearLayout = (LinearLayout) findViewById(R.id.floatingitem_instance);
// linearLayout.setVisibility(View.GONE);
// }
// };
// linearLayout.setOnClickListener(regionOnClickListner);
// frameLayout.setOnClickListener(regionOnClickListner);
// } catch (Exception e) {
// e.printStackTrace();
// }
}
public void clearNewsFeed() {

11
app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java

@ -57,11 +57,7 @@ public class FeedController implements FeedReader.ReaderCallback, FeedParser.Par
}
public void addNewsList(String title, String text, String link) {
newsItemList.add(new NewsItemList().new Group(
title,
text,
link
));
newsItemList.add(new NewsItemGroup(title, text, link));
}
@ -72,8 +68,9 @@ public class FeedController implements FeedReader.ReaderCallback, FeedParser.Par
activity.clearNewsFeed();
}
});
for (int i = 0; i < newsItemList.size(); i++) {
final NewsItemList.Group item = newsItemList.get(i);
NewsItemGroup array[] = newsItemList.toArray();
for (int i = 0; i < array.length; i++) {
final NewsItemGroup item = array[i];
if(i < newsItemList.size() - 1) {
activity.runOnUiThread(new Runnable() {
@Override

94
app/src/main/java/ru/defend/defdevteam/tstu/NewsFragment.java

@ -0,0 +1,94 @@
package ru.defend.defdevteam.tstu;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.w3c.dom.Text;
public class NewsFragment extends Fragment {
private static final String ARG_PARAM1 = "title";
private static final String ARG_PARAM2 = "text";
private static final String ARG_PARAM3 = "link";
private String mTitle;
private String mImgLink;
private String mText;
private OnFragmentInteractionListener mListener;
public NewsFragment() {
}
@Override
public void onResume() {
super.onResume();
if (getArguments() != null) {
mTitle = getArguments().getString(ARG_PARAM1);
mText = getArguments().getString(ARG_PARAM2);
mImgLink = getArguments().getString(ARG_PARAM3);
updateNewsFragment();
}
}
public static NewsFragment newInstance(NewsItemGroup group) {
NewsFragment newsFragment = new NewsFragment();
Bundle arg = new Bundle();
arg.putString(ARG_PARAM1, group.getTitle());
arg.putString(ARG_PARAM2, group.getText());
arg.putString(ARG_PARAM3, group.getLink());
newsFragment.setArguments(arg);
return newsFragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public void updateNewsFragment() {
TextView titleTextView = (TextView) getActivity().findViewById(R.id.floatingnews_title);
TextView textView = (TextView) getActivity().findViewById(R.id.floatingnews_content);
titleTextView.setText(mTitle);
textView.setText(mText);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_news, container, false);
}
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnFragmentInteractionListener {
void onFragmentInteraction(Uri uri);
}
}

48
app/src/main/java/ru/defend/defdevteam/tstu/NewsItemGroup.java

@ -0,0 +1,48 @@
package ru.defend.defdevteam.tstu;
/**
* Created by itsmy on 19.02.2017.
*/
public class NewsItemGroup {
protected String title;
protected String text;
protected String link;
protected String fullText;
protected int viewID;
public NewsItemGroup(String title, String text, String link) {
this.fullText = "";
this.text = text;
this.title = title;
this.link = link;
this.viewID = -1;
}
public String getTitle() {
return this.title;
}
public String getText() {
return this.text;
}
public String getLink() {
return this.link;
}
public void setFullText(String fullText) {
this.fullText = fullText;
}
public String getFullText() {
return this.fullText;
}
public int getViewID() {
return viewID;
}
public void setViewID(int viewID) {
this.viewID = viewID;
}
}

125
app/src/main/java/ru/defend/defdevteam/tstu/NewsItemList.java

@ -6,122 +6,55 @@ import android.view.View;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.Map;
/**
* Created by itsmy on 13.02.2017.
*/
public class NewsItemList {
private ArrayList<Group> list;
private HashMap<Integer, Integer> hashMap;
public class NewsItemList {
private HashMap<Integer, NewsItemGroup> hashMap;
NewsItemList() {
list = new ArrayList<>();
hashMap = new HashMap<>();
}
public NewsItemGroup[] toArray() {
int counter = 0;
NewsItemGroup[] array = new NewsItemGroup[size()];
for (Map.Entry<Integer, NewsItemGroup> entry: hashMap.entrySet()) {
array[counter] = entry.getValue();
counter++;
}
return array;
}
public int size() {
return list.size();
return hashMap.size();
}
public Group get(int index) {
return list.get(index);
public void add(NewsItemGroup group) {
int viewId = getViewId();
group.setViewID(viewId);
this.hashMap.put(viewId, group);
}
public void add(Group group) {
this.list.add(group);
this.hashMap.put(group.getViewId(), this.list.size());
public int getViewId() {
int viewId;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
viewId = View.generateViewId();
Log.i("Generated view id", Integer.toString(viewId));
} else {
viewId = -1;
}
return viewId;
}
//
// public void set(int index, Group group) {
// this.list.set(index, group);
// this.hashMap.keySet(group.getViewId(), this.list.size());
// }
public void clear() {
this.list.clear();
this.hashMap.clear();
}
public Group getGroupByViewId(int viewId) {
return this.list.get(this.hashMap.get(viewId));
public NewsItemGroup getGroupByViewId(int viewId) {
return this.hashMap.get(viewId);
}
// @Override
// public Iterator<Group> iterator() {
// return new NewsIterator();
// }
// private class NewsIterator implements Iterator<Group> {
// private int cursor;
//
// public NewsIterator() {
// this.cursor = 0;
// }
//
// public boolean hasNext() {
// return this.cursor < size();
// }
//
// public Group next() {
// if(this.hasNext()) {
// Group current = get(cursor);
// cursor ++;
// return current;
// }
// throw new NoSuchElementException();
// }
//
// public void remove() {
// throw new UnsupportedOperationException();
// }
// }
public class Group {
private String title;
private String text;
private String link;
private Integer viewId;
private String fullText;
Group(String title, String text, String link) {
this.title = title;
this.text = text;
this.link = link;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
this.viewId = View.generateViewId();
Log.i("Generated view id", Integer.toString(viewId));
} else {
this.viewId = -1;
}
}
public String getTitle() {
return this.title;
}
public String getText() {
return this.text;
}
public String getLink() {
return this.link;
}
public int getViewId() {
return this.viewId;
}
public void setFullText(String fullText) {
this.fullText = fullText;
}
}
}

39
app/src/main/res/layout/cabinet_newsfeed_floatingitem.xml

@ -1,37 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:id="@+id/floatingitem_instance"
android:clickable="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.4"
android:background="@android:color/darker_gray">
android:layout_height="match_parent">
<RelativeLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:layout_margin="25dp"
android:alpha="1">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:gravity="center_horizontal"
android:alpha="1"
android:background="@android:color/background_light" />
</RelativeLayout>
android:alpha="0.6"
android:background="@android:color/darker_gray"
android:id="@+id/floatingitem_first">
</FrameLayout>
</FrameLayout>
</LinearLayout>

61
app/src/main/res/layout/fragment_news.xml

@ -0,0 +1,61 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ru.defend.defdevteam.tstu.NewsFragment"
android:id="@+id/fragment_news">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.6"
android:background="@android:color/darker_gray">
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:alpha="1"
android:layout_margin="25dp"
android:background="@android:color/background_light"
android:id="@+id/floatingitem_second">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:gravity="center_horizontal"
android:alpha="1"
android:background="@android:color/background_light"
android:id="@+id/floatingnews_title"/>
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat"
android:id="@+id/floatingnews_content"/>
</LinearLayout>
</FrameLayout>
</ScrollView>
</FrameLayout>
Loading…
Cancel
Save