-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added AppWidget with Listview and the ability to swipe between recipe…
…s ingrediants - fixed on fragment detail view onSwipe function - created a content provider (no use for it yet)
- Loading branch information
Showing
22 changed files
with
422 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
app/src/main/java/ml/medyas/bakingapp/Database/RecipeContentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package ml.medyas.bakingapp.Database; | ||
|
||
import android.content.ContentProvider; | ||
import android.content.ContentValues; | ||
import android.content.Context; | ||
import android.content.UriMatcher; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
|
||
import ml.medyas.bakingapp.Classes.RecipeClass; | ||
|
||
public class RecipeContentProvider extends ContentProvider { | ||
|
||
public static final String AUTHORITY = "ml.medyas.baknigApp.RecipeContentProvider.provider"; | ||
public static final Uri URI_RECIPE = Uri.parse( | ||
"content://" + AUTHORITY + "/" + RecipeClass.TABLE_NAME); | ||
|
||
private static final UriMatcher MATCHER = new UriMatcher(UriMatcher.NO_MATCH); | ||
|
||
private DaoClass mDao; | ||
private Context context; | ||
/** The match code for some items in the Cheese table. */ | ||
private static final int CODE_RECIPE_DIR = 1; | ||
|
||
static { | ||
MATCHER.addURI(AUTHORITY, RecipeClass.TABLE_NAME, CODE_RECIPE_DIR); | ||
} | ||
|
||
public RecipeContentProvider() { | ||
} | ||
|
||
@Override | ||
public int delete(Uri uri, String selection, String[] selectionArgs) { | ||
// Implement this to handle requests to delete one or more rows. | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
|
||
@Override | ||
public String getType(Uri uri) { | ||
// TODO: Implement this to handle requests for the MIME type of the data | ||
// at the given URI. | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
|
||
@Override | ||
public Uri insert(Uri uri, ContentValues values) { | ||
// TODO: Implement this to handle requests to insert a new row. | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
|
||
@Override | ||
public boolean onCreate() { | ||
context = getContext(); | ||
mDao = RecipesRoomDB.getDatabase(context).recipeDao(); | ||
return true; | ||
} | ||
|
||
@Override | ||
public Cursor query(Uri uri, String[] projection, String selection, | ||
String[] selectionArgs, String sortOrder) { | ||
final int code = MATCHER.match(uri); | ||
if (code == CODE_RECIPE_DIR) { | ||
final Cursor cursor; | ||
cursor = mDao.getRecipesCursor(); | ||
cursor.setNotificationUri(context.getContentResolver(), uri); | ||
return cursor; | ||
} else { | ||
throw new IllegalArgumentException("Unknown URI: " + uri); | ||
} | ||
} | ||
|
||
@Override | ||
public int update(Uri uri, ContentValues values, String selection, | ||
String[] selectionArgs) { | ||
// TODO: Implement this to handle requests to update one or more rows. | ||
throw new UnsupportedOperationException("Not yet implemented"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
app/src/main/java/ml/medyas/bakingapp/Widget/ListWidgetService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package ml.medyas.bakingapp.Widget; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.widget.RemoteViews; | ||
import android.widget.RemoteViewsService; | ||
|
||
import ml.medyas.bakingapp.R; | ||
|
||
import static ml.medyas.bakingapp.Widget.RecipesWidget.INGRED_LIST; | ||
import static ml.medyas.bakingapp.Widget.RecipesWidget.ingred; | ||
|
||
public class ListWidgetService extends RemoteViewsService { | ||
|
||
|
||
private String[] mIngred = null; | ||
|
||
@Override | ||
public RemoteViewsFactory onGetViewFactory(final Intent intent) { | ||
return new ListWidgetRemoteViewsFactory(this.getApplicationContext(), intent); | ||
} | ||
|
||
|
||
class ListWidgetRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { | ||
|
||
private Context mContext; | ||
|
||
public ListWidgetRemoteViewsFactory(Context applicationContext, Intent intent) { | ||
mContext = applicationContext; | ||
mIngred = intent.getStringArrayExtra(INGRED_LIST); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
} | ||
|
||
@Override | ||
public void onDataSetChanged() { | ||
mIngred = ingred; | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
|
||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return mIngred.length; | ||
} | ||
|
||
@Override | ||
public RemoteViews getViewAt(int i) { | ||
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_list_item_layout); | ||
rv.setTextViewText(R.id.widget_ingred_text, mIngred[i]); | ||
|
||
// Return the remote views object. | ||
return rv; | ||
|
||
} | ||
|
||
@Override | ||
public RemoteViews getLoadingView() { | ||
return new RemoteViews(mContext.getPackageName(), R.layout.widget_list_item_loading_layout); | ||
} | ||
|
||
@Override | ||
public int getViewTypeCount() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public long getItemId(int i) { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean hasStableIds() { | ||
return false; | ||
} | ||
|
||
} | ||
} | ||
|
||
|
Oops, something went wrong.