Browse Source

Created event when user press back for news fragment.

Added full text on news fragment view.
Some fixes on news fragment xml.
master
Defend 8 years ago
parent
commit
ef57ba8722
  1. 7
      app/src/main/java/ru/defend/defdevteam/tstu/CabinetActivity.java
  2. 8
      app/src/main/java/ru/defend/defdevteam/tstu/FeedController.java
  3. 8
      app/src/main/java/ru/defend/defdevteam/tstu/FeedParser.java
  4. 2
      app/src/main/java/ru/defend/defdevteam/tstu/NewsFragment.java
  5. 43
      app/src/main/res/layout/fragment_news.xml

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

@ -62,7 +62,6 @@ public class CabinetActivity extends AppCompatActivity
@Override
public void onFragmentInteraction(Uri uri) {
}
@ -185,7 +184,10 @@ public class CabinetActivity extends AppCompatActivity
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
int c = getFragmentManager().getBackStackEntryCount();
if (c > 0) {
getFragmentManager().popBackStack();
} else if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
@ -350,6 +352,7 @@ public class CabinetActivity extends AppCompatActivity
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
NewsFragment newsFragment = new NewsFragment().newInstance(group);
fragmentTransaction.add(R.id.newsfeeder, newsFragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
// RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.newsfeeder);
// View layout = getLayoutInflater().inflate(R.layout.cabinet_newsfeed_floatingitem, relativeLayout, false);

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

@ -56,8 +56,8 @@ public class FeedController implements FeedReader.ReaderCallback, FeedParser.Par
}
}
public void addNewsList(String title, String text, String link) {
newsItemList.add(new NewsItemGroup(title, text, link));
public void addNewsList(NewsItemGroup group) {
newsItemList.add(group);
}
@ -110,8 +110,8 @@ public class FeedController implements FeedReader.ReaderCallback, FeedParser.Par
}
@Override
public void contentDispatcher(String title, String text, String link) {
addNewsList(title, text, link);
public void contentDispatcher(NewsItemGroup group) {
addNewsList(group);
}

8
app/src/main/java/ru/defend/defdevteam/tstu/FeedParser.java

@ -22,7 +22,7 @@ public class FeedParser {
interface ParserCallback {
void onSuccessParsing();
void onFailureParsing();
void contentDispatcher(String title, String text, String link);
void contentDispatcher(NewsItemGroup group);
}
void registerCallback(ParserCallback callback) {
@ -127,8 +127,10 @@ public class FeedParser {
if (qName.equalsIgnoreCase("item") && item) {
item = false;
String imageLink = getImageLink(descriptionStr);
descriptionStr = getDescriptionShort(descriptionStr);
callback.contentDispatcher(titleStr, descriptionStr, imageLink);
String shortDescriptionStr = getDescriptionShort(descriptionStr);
NewsItemGroup group = new NewsItemGroup(titleStr, shortDescriptionStr, imageLink);
group.setFullText(deleteHtmlTag(descriptionStr, "<", ">"));
callback.contentDispatcher(group);
refreshStrings();
}
}

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

@ -41,7 +41,7 @@ public class NewsFragment extends Fragment {
NewsFragment newsFragment = new NewsFragment();
Bundle arg = new Bundle();
arg.putString(ARG_PARAM1, group.getTitle());
arg.putString(ARG_PARAM2, group.getText());
arg.putString(ARG_PARAM2, group.getFullText());
arg.putString(ARG_PARAM3, group.getLink());
newsFragment.setArguments(arg);
return newsFragment;

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

@ -1,34 +1,34 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout 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
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:alpha="0.6"
android:background="@android:color/darker_gray">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.6"
android:background="@android:color/darker_gray">
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="15dp">
</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">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:alpha="1"
android:background="@android:color/background_light"
android:id="@+id/floatingitem_second">
<TextView
android:text="TextView"
@ -50,12 +50,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat"
android:id="@+id/floatingnews_content"/>
android:id="@+id/floatingnews_content"
android:padding="5dp"/>
</LinearLayout>
</FrameLayout>
</ScrollView>
</FrameLayout>
</FrameLayout>
</LinearLayout>

Loading…
Cancel
Save